2 * Copyright (c) 1999 Doug Rabson
3 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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
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 $
34 /* Generic Address structure */
36 u_int8_t address_space_id;
37 #define ACPI_GAS_MEMORY 0
39 #define ACPI_GAS_PCI 2
40 #define ACPI_GAS_EMBEDDED 3
41 #define ACPI_GAS_SMBUS 4
42 #define ACPI_GAS_CMOS 5
43 #define ACPI_GAS_PCIBAR 6
44 #define ACPI_GAS_DATATABLE 7
45 #define ACPI_GAS_FIXED 0x7f
52 /* Root System Description Pointer */
65 /* System Description Table */
76 #define SIZEOF_SDT_HDR 36 /* struct size except body */
77 u_int32_t body[1]; /* This member should be casted */
80 /* Fixed ACPI Description Table (body) */
85 #define ACPI_FADT_INTMODEL_PIC 0 /* Standard PC-AT PIC */
86 #define ACPI_FADT_INTMODEL_APIC 1 /* Multiple APIC */
91 u_int8_t acpi_disable;
94 u_int32_t pm1a_evt_blk;
95 u_int32_t pm1b_evt_blk;
96 u_int32_t pm1a_cnt_blk;
97 u_int32_t pm1b_cnt_blk;
98 u_int32_t pm2_cnt_blk;
102 u_int8_t pm1_evt_len;
103 u_int8_t pm1_cnt_len;
104 u_int8_t pm2_cnt_len;
110 u_int16_t p_lvl2_lat;
111 u_int16_t p_lvl3_lat;
112 u_int16_t flush_size;
113 u_int16_t flush_stride;
119 u_int16_t iapc_boot_arch;
120 #define FADT_FLAG_LEGACY_DEV 1 /* System has legacy devices */
121 #define FADT_FLAG_8042 2 /* 8042 keyboard controller */
124 #define FADT_FLAG_WBINVD 1 /* WBINVD is correctly supported */
125 #define FADT_FLAG_WBINVD_FLUSH 2 /* WBINVD flushes caches */
126 #define FADT_FLAG_PROC_C1 4 /* C1 power state supported */
127 #define FADT_FLAG_P_LVL2_UP 8 /* C2 power state works on SMP */
128 #define FADT_FLAG_PWR_BUTTON 16 /* Power button uses control method */
129 #define FADT_FLAG_SLP_BUTTON 32 /* Sleep button uses control method */
130 #define FADT_FLAG_FIX_RTC 64 /* RTC wakeup not supported */
131 #define FADT_FLAG_RTC_S4 128 /* RTC can wakeup from S4 state */
132 #define FADT_FLAG_TMR_VAL_EXT 256 /* TMR_VAL is 32bit */
133 #define FADT_FLAG_DCK_CAP 512 /* Can support docking */
134 #define FADT_FLAG_RESET_REG 1024 /* Supports RESET_REG */
135 #define FADT_FLAG_SEALED_CASE 2048 /* Case cannot be opened */
136 #define FADT_FLAG_HEADLESS 4096 /* No monitor */
137 #define FADT_FLAG_CPU_SW_SLP 8192 /* Supports CPU software sleep */
138 #define FADT_FLAG_PCI_EXPRESS_WAKE (1<<14) /* PCIEXP_WAKE (STS/EN) bits */
139 #define FADT_FLAG_PLATFORM_CLOCK (1<<15) /* OSPM should use platform-provided tmr */
140 #define FADT_FLAG_S4_RTC_VALID (1<<16) /* RTC_STS valid after S4 wake */
141 #define FADT_FLAG_REMOTE_POWER_ON (1<<17) /* System is compat. with remote pwr on */
142 #define FADT_FLAG_APIC_CLUSTER (1<<18) /* All local APICs must use cluster model */
143 #define FADT_FLAG_APIC_PHYSICAL (1<<19) /*All local xAPICs must use phys dest mode*/
144 struct ACPIgas reset_reg;
145 u_int8_t reset_value;
146 u_int8_t reserved5[3];
147 u_int64_t x_facs_ptr;
148 u_int64_t x_dsdt_ptr;
149 struct ACPIgas x_pm1a_evt_blk;
150 struct ACPIgas x_pm1b_evt_blk;
151 struct ACPIgas x_pm1a_cnt_blk;
152 struct ACPIgas x_pm1b_cnt_blk;
153 struct ACPIgas x_pm2_cnt_blk;
154 struct ACPIgas x_pm_tmr_blk;
155 struct ACPIgas x_gpe0_blk;
156 struct ACPIgas x_gpe1_blk;
159 /* Firmware ACPI Control Structure */
165 * NOTE This should be filled with physical address below 1MB!!
168 u_int32_t firm_wake_vec;
169 u_int32_t global_lock;
170 #define FACS_FLAG_LOCK_PENDING 1 /* 5.2.6.1 Global Lock */
171 #define FACS_FLAG_LOCK_OWNED 2
173 #define FACS_FLAG_S4BIOS_F 1 /* Supports S4BIOS_SEQ */
174 u_int64_t x_firm_wake_vec;
179 struct MADT_local_apic {
183 #define ACPI_MADT_APIC_LOCAL_FLAG_ENABLED 1
186 struct MADT_io_apic {
193 struct MADT_int_override {
198 #define MPS_INT_FLAG_POLARITY_MASK 0x3
199 #define MPS_INT_FLAG_POLARITY_CONFORM 0x0
200 #define MPS_INT_FLAG_POLARITY_HIGH 0x1
201 #define MPS_INT_FLAG_POLARITY_LOW 0x3
202 #define MPS_INT_FLAG_TRIGGER_MASK 0xc
203 #define MPS_INT_FLAG_TRIGGER_CONFORM 0x0
204 #define MPS_INT_FLAG_TRIGGER_EDGE 0x4
205 #define MPS_INT_FLAG_TRIGGER_LEVEL 0xc
213 struct MADT_local_nmi {
219 struct MADT_local_apic_override {
224 struct MADT_io_sapic {
231 struct MADT_local_sapic {
239 struct MADT_int_src {
242 #define ACPI_MADT_APIC_INT_SOURCE_PMI 1
243 #define ACPI_MADT_APIC_INT_SOURCE_INIT 2
244 #define ACPI_MADT_APIC_INT_SOURCE_CPEI 3 /* Corrected Platform Error */
254 #define ACPI_MADT_APIC_TYPE_LOCAL_APIC 0
255 #define ACPI_MADT_APIC_TYPE_IO_APIC 1
256 #define ACPI_MADT_APIC_TYPE_INT_OVERRIDE 2
257 #define ACPI_MADT_APIC_TYPE_NMI 3
258 #define ACPI_MADT_APIC_TYPE_LOCAL_NMI 4
259 #define ACPI_MADT_APIC_TYPE_LOCAL_OVERRIDE 5
260 #define ACPI_MADT_APIC_TYPE_IO_SAPIC 6
261 #define ACPI_MADT_APIC_TYPE_LOCAL_SAPIC 7
262 #define ACPI_MADT_APIC_TYPE_INT_SRC 8
265 struct MADT_local_apic local_apic;
266 struct MADT_io_apic io_apic;
267 struct MADT_int_override int_override;
269 struct MADT_local_nmi local_nmi;
270 struct MADT_local_apic_override local_apic_override;
271 struct MADT_io_sapic io_sapic;
272 struct MADT_local_sapic local_sapic;
273 struct MADT_int_src int_src;
278 u_int32_t lapic_addr;
280 #define ACPI_APIC_FLAG_PCAT_COMPAT 1 /* System has dual-8259 setup. */
285 u_int32_t block_hwrev:8,
287 block_counter_size:1,
289 block_legacy_capable:1,
293 u_int8_t hpet_number;
294 u_int16_t clock_tick __packed;
297 /* Embedded Controller Description Table */
299 struct ACPIgas ec_control; /* Control register */
300 struct ACPIgas ec_data; /* Data register */
301 uint32_t uid; /* Same value as _UID in namespace */
302 uint8_t gpe_bit; /* GPE bit for the EC */
303 u_char ec_id[1]; /* Variable length name string */
306 /* Memory Mapped PCI config space base allocation structure */
310 uint64_t baseaddr; /* Base Address */
311 uint16_t seg_grp; /* Segment group number */
312 uint8_t start; /* Starting bus number */
313 uint8_t end; /* Ending bus number */
314 uint8_t rsvd[4]; /* Reserved */
318 /* SRAT - System Resource Affinity Table */
320 struct SRAT_cpu_affinity {
321 uint8_t proximity_domain_lo;
324 uint8_t local_sapic_eid;
325 uint8_t proximity_domain_hi[3];
326 uint32_t reserved; /* must be zero */
329 #define ACPI_SRAT_FLAG_CPU_ENABLED 1
331 struct SRAT_mem_affinity
333 uint32_t proximity_domain;
334 uint16_t reserved; /* must be zero */
335 uint64_t base_address;
338 #define ACPI_SRAT_FLAG_MEM_ENABLED 1
339 #define ACPI_SRAT_FLAG_MEM_HOT_PLUGGABLE 2
340 #define ACPI_SRAT_FLAG_MEM_NON_VOLATILE 4
342 uint64_t reserved2; /* must be zero */
346 struct SRAT_x2apic_cpu_affinity
348 uint16_t reserved; /* must be zero */
349 uint32_t proximity_domain;
352 uint32_t clock_domain;
358 #define ACPI_SRAT_APIC_TYPE_CPU_AFFINITY 0
359 #define ACPI_SRAT_APIC_TYPE_MEMORY_AFFINITY 1
360 #define ACPI_SRAT_APIC_TYPE_X2APIC_CPU_AFFINITY 2
361 #define ACPI_SRAT_APIC_TYPE_RESERVED 3
364 struct SRAT_cpu_affinity cpu_affinity;
365 struct SRAT_mem_affinity mem_affinity;
366 struct SRAT_x2apic_cpu_affinity x2apic_cpu_affinity;
377 * Addresses to scan on ia32 for the RSD PTR. According to section 5.2.2
378 * of the ACPI spec, we only consider two regions for the base address:
379 * 1. EBDA (1 KB area addressed to by 16 bit pointer at 0x40E)
380 * 2. High memory (0xE0000 - 0xFFFFF)
382 #define RSDP_EBDA_PTR 0x40E
383 #define RSDP_EBDA_SIZE 0x400
384 #define RSDP_HI_START 0xE0000
385 #define RSDP_HI_SIZE 0x20000
387 /* Find and map the RSD PTR structure and return it for parsing */
388 struct ACPIsdt *sdt_load_devmem(void);
391 * Load the DSDT from a previous save file. Note that other tables are
392 * not saved (i.e. FADT)
394 struct ACPIsdt *dsdt_load_file(char *);
396 /* Save the DSDT to a file */
397 void dsdt_save_file(char *, struct ACPIsdt *, struct ACPIsdt *);
399 /* Print out as many fixed tables as possible, given the RSD PTR */
400 void sdt_print_all(struct ACPIsdt *);
402 /* Disassemble the AML in the DSDT */
403 void aml_disassemble(struct ACPIsdt *, struct ACPIsdt *);
405 /* Routines for accessing tables in physical memory */
406 struct ACPIrsdp *acpi_find_rsd_ptr(void);
407 void *acpi_map_physical(vm_offset_t, size_t);
408 struct ACPIsdt *sdt_from_rsdt(struct ACPIsdt *, const char *,
410 struct ACPIsdt *dsdt_from_fadt(struct FADTbody *);
411 int acpi_checksum(void *, size_t);
413 /* Command line flags */
418 #endif /* !_ACPIDUMP_H_ */