- Extract RX sensitivity calibration capability from EEPROM
[dragonfly.git] / usr.sbin / acpi / acpidump / acpidump.h
blobeb057d32a21ac34be15420d4830169515db603de
1 /*-
2 * Copyright (c) 1999 Doug Rabson
3 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
27 * $FreeBSD: src/usr.sbin/acpi/acpidump/acpidump.h,v 1.21 2005/02/17 21:09:26 scottl Exp $
28 * $DragonFly: src/usr.sbin/acpi/acpidump/acpidump.h,v 1.4 2007/01/10 12:23:23 hsu Exp $
31 #ifndef _ACPIDUMP_H_
32 #define _ACPIDUMP_H_
34 /* Generic Address structure */
35 struct ACPIgas {
36 u_int8_t address_space_id;
37 #define ACPI_GAS_MEMORY 0
38 #define ACPI_GAS_IO 1
39 #define ACPI_GAS_PCI 2
40 #define ACPI_GAS_EMBEDDED 3
41 #define ACPI_GAS_SMBUS 4
42 #define ACPI_GAS_FIXED 0x7f
43 u_int8_t bit_width;
44 u_int8_t bit_offset;
45 u_int8_t _reserved;
46 u_int64_t address;
47 } __packed;
49 /* Root System Description Pointer */
50 struct ACPIrsdp {
51 u_char signature[8];
52 u_char sum;
53 u_char oem[6];
54 u_char revision;
55 u_int32_t rsdt_addr;
56 u_int32_t length;
57 u_int64_t xsdt_addr;
58 u_char xsum;
59 u_char _reserved_[3];
60 } __packed;
62 /* System Description Table */
63 struct ACPIsdt {
64 u_char signature[4];
65 u_int32_t len;
66 u_char rev;
67 u_char check;
68 u_char oemid[6];
69 u_char oemtblid[8];
70 u_int32_t oemrev;
71 u_char creator[4];
72 u_int32_t crerev;
73 #define SIZEOF_SDT_HDR 36 /* struct size except body */
74 u_int32_t body[1];/* This member should be casted */
75 } __packed;
77 /* Fixed ACPI Description Table (body) */
78 struct FADTbody {
79 u_int32_t facs_ptr;
80 u_int32_t dsdt_ptr;
81 u_int8_t int_model;
82 #define ACPI_FADT_INTMODEL_PIC 0 /* Standard PC-AT PIC */
83 #define ACPI_FADT_INTMODEL_APIC 1 /* Multiple APIC */
84 u_int8_t pm_profile;
85 u_int16_t sci_int;
86 u_int32_t smi_cmd;
87 u_int8_t acpi_enable;
88 u_int8_t acpi_disable;
89 u_int8_t s4biosreq;
90 u_int8_t pstate_cnt;
91 u_int32_t pm1a_evt_blk;
92 u_int32_t pm1b_evt_blk;
93 u_int32_t pm1a_cnt_blk;
94 u_int32_t pm1b_cnt_blk;
95 u_int32_t pm2_cnt_blk;
96 u_int32_t pm_tmr_blk;
97 u_int32_t gpe0_blk;
98 u_int32_t gpe1_blk;
99 u_int8_t pm1_evt_len;
100 u_int8_t pm1_cnt_len;
101 u_int8_t pm2_cnt_len;
102 u_int8_t pm_tmr_len;
103 u_int8_t gpe0_len;
104 u_int8_t gpe1_len;
105 u_int8_t gpe1_base;
106 u_int8_t cst_cnt;
107 u_int16_t p_lvl2_lat;
108 u_int16_t p_lvl3_lat;
109 u_int16_t flush_size;
110 u_int16_t flush_stride;
111 u_int8_t duty_off;
112 u_int8_t duty_width;
113 u_int8_t day_alrm;
114 u_int8_t mon_alrm;
115 u_int8_t century;
116 u_int16_t iapc_boot_arch;
117 #define FADT_FLAG_LEGACY_DEV 1 /* System has legacy devices */
118 #define FADT_FLAG_8042 2 /* 8042 keyboard controller */
119 u_char reserved4[1];
120 u_int32_t flags;
121 #define FADT_FLAG_WBINVD 1 /* WBINVD is correctly supported */
122 #define FADT_FLAG_WBINVD_FLUSH 2 /* WBINVD flushes caches */
123 #define FADT_FLAG_PROC_C1 4 /* C1 power state supported */
124 #define FADT_FLAG_P_LVL2_UP 8 /* C2 power state works on SMP */
125 #define FADT_FLAG_PWR_BUTTON 16 /* Power button uses control method */
126 #define FADT_FLAG_SLP_BUTTON 32 /* Sleep button uses control method */
127 #define FADT_FLAG_FIX_RTC 64 /* RTC wakeup not supported */
128 #define FADT_FLAG_RTC_S4 128 /* RTC can wakeup from S4 state */
129 #define FADT_FLAG_TMR_VAL_EXT 256 /* TMR_VAL is 32bit */
130 #define FADT_FLAG_DCK_CAP 512 /* Can support docking */
131 #define FADT_FLAG_RESET_REG 1024 /* Supports RESET_REG */
132 #define FADT_FLAG_SEALED_CASE 2048 /* Case cannot be opened */
133 #define FADT_FLAG_HEADLESS 4096 /* No monitor */
134 #define FADT_FLAG_CPU_SW_SLP 8192 /* Supports CPU software sleep */
135 struct ACPIgas reset_reg;
136 u_int8_t reset_value;
137 u_int8_t reserved5[3];
138 u_int64_t x_facs_ptr;
139 u_int64_t x_dsdt_ptr;
140 struct ACPIgas x_pm1a_evt_blk;
141 struct ACPIgas x_pm1b_evt_blk;
142 struct ACPIgas x_pm1a_cnt_blk;
143 struct ACPIgas x_pm1b_cnt_blk;
144 struct ACPIgas x_pm2_cnt_blk;
145 struct ACPIgas x_pm_tmr_blk;
146 struct ACPIgas x_gpe0_blk;
147 struct ACPIgas x_gpe1_blk;
148 } __packed;
150 /* Firmware ACPI Control Structure */
151 struct FACSbody {
152 u_char signature[4];
153 u_int32_t len;
154 u_int32_t hw_sig;
156 * NOTE This should be filled with physical address below 1MB!!
157 * sigh....
159 u_int32_t firm_wake_vec;
160 u_int32_t global_lock;
161 #define FACS_FLAG_LOCK_PENDING 1 /* 5.2.6.1 Global Lock */
162 #define FACS_FLAG_LOCK_OWNED 2
163 u_int32_t flags;
164 #define FACS_FLAG_S4BIOS_F 1 /* Supports S4BIOS_SEQ */
165 u_int64_t x_firm_wake_vec;
166 u_int8_t version;
167 char reserved[31];
168 } __packed;
170 struct MADT_local_apic {
171 u_char cpu_id;
172 u_char apic_id;
173 u_int32_t flags;
174 #define ACPI_MADT_APIC_LOCAL_FLAG_ENABLED 1
175 } __packed;
177 struct MADT_io_apic {
178 u_char apic_id;
179 u_char reserved;
180 u_int32_t apic_addr;
181 u_int32_t int_base;
182 } __packed;
184 struct MADT_int_override {
185 u_char bus;
186 u_char source;
187 u_int32_t intr;
188 u_int16_t mps_flags;
189 #define MPS_INT_FLAG_POLARITY_MASK 0x3
190 #define MPS_INT_FLAG_POLARITY_CONFORM 0x0
191 #define MPS_INT_FLAG_POLARITY_HIGH 0x1
192 #define MPS_INT_FLAG_POLARITY_LOW 0x3
193 #define MPS_INT_FLAG_TRIGGER_MASK 0xc
194 #define MPS_INT_FLAG_TRIGGER_CONFORM 0x0
195 #define MPS_INT_FLAG_TRIGGER_EDGE 0x4
196 #define MPS_INT_FLAG_TRIGGER_LEVEL 0xc
197 } __packed;
199 struct MADT_nmi {
200 u_int16_t mps_flags;
201 u_int32_t intr;
202 } __packed;
204 struct MADT_local_nmi {
205 u_char cpu_id;
206 u_int16_t mps_flags;
207 u_char lintpin;
208 } __packed;
210 struct MADT_local_apic_override {
211 u_char reserved[2];
212 u_int64_t apic_addr;
213 } __packed;
215 struct MADT_io_sapic {
216 u_char apic_id;
217 u_char reserved;
218 u_int32_t int_base;
219 u_int64_t apic_addr;
220 } __packed;
222 struct MADT_local_sapic {
223 u_char cpu_id;
224 u_char apic_id;
225 u_char apic_eid;
226 u_char reserved[3];
227 u_int32_t flags;
228 } __packed;
230 struct MADT_int_src {
231 u_int16_t mps_flags;
232 u_char type;
233 #define ACPI_MADT_APIC_INT_SOURCE_PMI 1
234 #define ACPI_MADT_APIC_INT_SOURCE_INIT 2
235 #define ACPI_MADT_APIC_INT_SOURCE_CPEI 3 /* Corrected Platform Error */
236 u_char cpu_id;
237 u_char cpu_eid;
238 u_char sapic_vector;
239 u_int32_t intr;
240 u_char reserved[4];
241 } __packed;
243 struct MADT_APIC {
244 u_char type;
245 #define ACPI_MADT_APIC_TYPE_LOCAL_APIC 0
246 #define ACPI_MADT_APIC_TYPE_IO_APIC 1
247 #define ACPI_MADT_APIC_TYPE_INT_OVERRIDE 2
248 #define ACPI_MADT_APIC_TYPE_NMI 3
249 #define ACPI_MADT_APIC_TYPE_LOCAL_NMI 4
250 #define ACPI_MADT_APIC_TYPE_LOCAL_OVERRIDE 5
251 #define ACPI_MADT_APIC_TYPE_IO_SAPIC 6
252 #define ACPI_MADT_APIC_TYPE_LOCAL_SAPIC 7
253 #define ACPI_MADT_APIC_TYPE_INT_SRC 8
254 u_char len;
255 union {
256 struct MADT_local_apic local_apic;
257 struct MADT_io_apic io_apic;
258 struct MADT_int_override int_override;
259 struct MADT_nmi nmi;
260 struct MADT_local_nmi local_nmi;
261 struct MADT_local_apic_override local_apic_override;
262 struct MADT_io_sapic io_sapic;
263 struct MADT_local_sapic local_sapic;
264 struct MADT_int_src int_src;
265 } body;
266 } __packed;
268 struct MADTbody {
269 u_int32_t lapic_addr;
270 u_int32_t flags;
271 #define ACPI_APIC_FLAG_PCAT_COMPAT 1 /* System has dual-8259 setup. */
272 u_char body[1];
273 } __packed;
275 struct HPETbody {
276 u_int32_t block_hwrev:8,
277 block_comparitors:5,
278 block_counter_size:1,
280 block_legacy_capable:1,
281 block_pcivendor:16;
282 u_int32_t base_addr;
283 u_int64_t reserved1;
284 u_int8_t hpet_number;
285 u_int16_t clock_tick __packed;
286 } __packed;
288 /* Embedded Controller Description Table */
289 struct ECDTbody {
290 struct ACPIgas ec_control; /* Control register */
291 struct ACPIgas ec_data; /* Data register */
292 uint32_t uid; /* Same value as _UID in namespace */
293 uint8_t gpe_bit; /* GPE bit for the EC */
294 u_char ec_id[1]; /* Variable length name string */
295 } __packed;
297 /* Memory Mapped PCI config space base allocation structure */
298 struct MCFGbody {
299 uint8_t rsvd[8];
300 struct {
301 uint64_t baseaddr; /* Base Address */
302 uint16_t seg_grp; /* Segment group number */
303 uint8_t start; /* Starting bus number */
304 uint8_t end; /* Ending bus number */
305 uint8_t rsvd[4]; /* Reserved */
306 } s[1] __packed;
307 } __packed;
310 * Addresses to scan on ia32 for the RSD PTR. According to section 5.2.2
311 * of the ACPI spec, we only consider two regions for the base address:
312 * 1. EBDA (1 KB area addressed to by 16 bit pointer at 0x40E)
313 * 2. High memory (0xE0000 - 0xFFFFF)
315 #define RSDP_EBDA_PTR 0x40E
316 #define RSDP_EBDA_SIZE 0x400
317 #define RSDP_HI_START 0xE0000
318 #define RSDP_HI_SIZE 0x20000
320 /* Find and map the RSD PTR structure and return it for parsing */
321 struct ACPIsdt *sdt_load_devmem(void);
324 * Load the DSDT from a previous save file. Note that other tables are
325 * not saved (i.e. FADT)
327 struct ACPIsdt *dsdt_load_file(char *);
329 /* Save the DSDT to a file */
330 void dsdt_save_file(char *, struct ACPIsdt *, struct ACPIsdt *);
332 /* Print out as many fixed tables as possible, given the RSD PTR */
333 void sdt_print_all(struct ACPIsdt *);
335 /* Disassemble the AML in the DSDT */
336 void aml_disassemble(struct ACPIsdt *, struct ACPIsdt *);
338 /* Routines for accessing tables in physical memory */
339 struct ACPIrsdp *acpi_find_rsd_ptr(void);
340 void *acpi_map_physical(vm_offset_t, size_t);
341 struct ACPIsdt *sdt_from_rsdt(struct ACPIsdt *, const char *,
342 struct ACPIsdt *);
343 struct ACPIsdt *dsdt_from_fadt(struct FADTbody *);
344 int acpi_checksum(void *, size_t);
346 /* Command line flags */
347 extern int dflag;
348 extern int tflag;
349 extern int vflag;
351 #endif /* !_ACPIDUMP_H_ */