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
33 /* Generic Address structure */
35 u_int8_t address_space_id;
36 #define ACPI_GAS_MEMORY 0
38 #define ACPI_GAS_PCI 2
39 #define ACPI_GAS_EMBEDDED 3
40 #define ACPI_GAS_SMBUS 4
41 #define ACPI_GAS_FIXED 0x7f
48 /* Root System Description Pointer */
61 /* System Description Table */
72 #define SIZEOF_SDT_HDR 36 /* struct size except body */
73 u_int32_t body[1];/* This member should be casted */
76 /* Fixed ACPI Description Table (body) */
81 #define ACPI_FADT_INTMODEL_PIC 0 /* Standard PC-AT PIC */
82 #define ACPI_FADT_INTMODEL_APIC 1 /* Multiple APIC */
87 u_int8_t acpi_disable;
90 u_int32_t pm1a_evt_blk;
91 u_int32_t pm1b_evt_blk;
92 u_int32_t pm1a_cnt_blk;
93 u_int32_t pm1b_cnt_blk;
94 u_int32_t pm2_cnt_blk;
100 u_int8_t pm2_cnt_len;
106 u_int16_t p_lvl2_lat;
107 u_int16_t p_lvl3_lat;
108 u_int16_t flush_size;
109 u_int16_t flush_stride;
115 u_int16_t iapc_boot_arch;
116 #define FADT_FLAG_LEGACY_DEV 1 /* System has legacy devices */
117 #define FADT_FLAG_8042 2 /* 8042 keyboard controller */
120 #define FADT_FLAG_WBINVD 1 /* WBINVD is correctly supported */
121 #define FADT_FLAG_WBINVD_FLUSH 2 /* WBINVD flushes caches */
122 #define FADT_FLAG_PROC_C1 4 /* C1 power state supported */
123 #define FADT_FLAG_P_LVL2_UP 8 /* C2 power state works on SMP */
124 #define FADT_FLAG_PWR_BUTTON 16 /* Power button uses control method */
125 #define FADT_FLAG_SLP_BUTTON 32 /* Sleep button uses control method */
126 #define FADT_FLAG_FIX_RTC 64 /* RTC wakeup not supported */
127 #define FADT_FLAG_RTC_S4 128 /* RTC can wakeup from S4 state */
128 #define FADT_FLAG_TMR_VAL_EXT 256 /* TMR_VAL is 32bit */
129 #define FADT_FLAG_DCK_CAP 512 /* Can support docking */
130 #define FADT_FLAG_RESET_REG 1024 /* Supports RESET_REG */
131 #define FADT_FLAG_SEALED_CASE 2048 /* Case cannot be opened */
132 #define FADT_FLAG_HEADLESS 4096 /* No monitor */
133 #define FADT_FLAG_CPU_SW_SLP 8192 /* Supports CPU software sleep */
134 struct ACPIgas reset_reg;
135 u_int8_t reset_value;
136 u_int8_t reserved5[3];
137 u_int64_t x_facs_ptr;
138 u_int64_t x_dsdt_ptr;
139 struct ACPIgas x_pm1a_evt_blk;
140 struct ACPIgas x_pm1b_evt_blk;
141 struct ACPIgas x_pm1a_cnt_blk;
142 struct ACPIgas x_pm1b_cnt_blk;
143 struct ACPIgas x_pm2_cnt_blk;
144 struct ACPIgas x_pm_tmr_blk;
145 struct ACPIgas x_gpe0_blk;
146 struct ACPIgas x_gpe1_blk;
149 /* Firmware ACPI Control Structure */
155 * NOTE This should be filled with physical address below 1MB!!
158 u_int32_t firm_wake_vec;
159 u_int32_t global_lock;
160 #define FACS_FLAG_LOCK_PENDING 1 /* 5.2.6.1 Global Lock */
161 #define FACS_FLAG_LOCK_OWNED 2
163 #define FACS_FLAG_S4BIOS_F 1 /* Supports S4BIOS_SEQ */
164 u_int64_t x_firm_wake_vec;
169 struct MADT_local_apic {
173 #define ACPI_MADT_APIC_LOCAL_FLAG_ENABLED 1
176 struct MADT_io_apic {
183 struct MADT_int_override {
188 #define MPS_INT_FLAG_POLARITY_MASK 0x3
189 #define MPS_INT_FLAG_POLARITY_CONFORM 0x0
190 #define MPS_INT_FLAG_POLARITY_HIGH 0x1
191 #define MPS_INT_FLAG_POLARITY_LOW 0x3
192 #define MPS_INT_FLAG_TRIGGER_MASK 0xc
193 #define MPS_INT_FLAG_TRIGGER_CONFORM 0x0
194 #define MPS_INT_FLAG_TRIGGER_EDGE 0x4
195 #define MPS_INT_FLAG_TRIGGER_LEVEL 0xc
203 struct MADT_local_nmi {
209 struct MADT_local_apic_override {
214 struct MADT_io_sapic {
221 struct MADT_local_sapic {
229 struct MADT_int_src {
232 #define ACPI_MADT_APIC_INT_SOURCE_PMI 1
233 #define ACPI_MADT_APIC_INT_SOURCE_INIT 2
234 #define ACPI_MADT_APIC_INT_SOURCE_CPEI 3 /* Corrected Platform Error */
244 #define ACPI_MADT_APIC_TYPE_LOCAL_APIC 0
245 #define ACPI_MADT_APIC_TYPE_IO_APIC 1
246 #define ACPI_MADT_APIC_TYPE_INT_OVERRIDE 2
247 #define ACPI_MADT_APIC_TYPE_NMI 3
248 #define ACPI_MADT_APIC_TYPE_LOCAL_NMI 4
249 #define ACPI_MADT_APIC_TYPE_LOCAL_OVERRIDE 5
250 #define ACPI_MADT_APIC_TYPE_IO_SAPIC 6
251 #define ACPI_MADT_APIC_TYPE_LOCAL_SAPIC 7
252 #define ACPI_MADT_APIC_TYPE_INT_SRC 8
255 struct MADT_local_apic local_apic;
256 struct MADT_io_apic io_apic;
257 struct MADT_int_override int_override;
259 struct MADT_local_nmi local_nmi;
260 struct MADT_local_apic_override local_apic_override;
261 struct MADT_io_sapic io_sapic;
262 struct MADT_local_sapic local_sapic;
263 struct MADT_int_src int_src;
268 u_int32_t lapic_addr;
270 #define ACPI_APIC_FLAG_PCAT_COMPAT 1 /* System has dual-8259 setup. */
275 u_int32_t block_hwrev:8,
277 block_counter_size:1,
279 block_legacy_capable:1,
281 struct ACPIgas genaddr;
282 u_int8_t hpet_number;
283 u_int16_t clock_tick __packed;
286 /* Embedded Controller Description Table */
288 struct ACPIgas ec_control; /* Control register */
289 struct ACPIgas ec_data; /* Data register */
290 uint32_t uid; /* Same value as _UID in namespace */
291 uint8_t gpe_bit; /* GPE bit for the EC */
292 u_char ec_id[1]; /* Variable length name string */
295 /* Memory Mapped PCI config space base allocation structure */
299 uint64_t baseaddr; /* Base Address */
300 uint16_t seg_grp; /* Segment group number */
301 uint8_t start; /* Starting bus number */
302 uint8_t end; /* Ending bus number */
303 uint8_t rsvd[4]; /* Reserved */
308 * Addresses to scan on ia32 for the RSD PTR. According to section 5.2.2
309 * of the ACPI spec, we only consider two regions for the base address:
310 * 1. EBDA (1 KB area addressed to by 16 bit pointer at 0x40E)
311 * 2. High memory (0xE0000 - 0xFFFFF)
313 #define RSDP_EBDA_PTR 0x40E
314 #define RSDP_EBDA_SIZE 0x400
315 #define RSDP_HI_START 0xE0000
316 #define RSDP_HI_SIZE 0x20000
318 /* Find and map the RSD PTR structure and return it for parsing */
319 struct ACPIsdt *sdt_load_devmem(void);
322 * Load the DSDT from a previous save file. Note that other tables are
323 * not saved (i.e. FADT)
325 struct ACPIsdt *dsdt_load_file(char *);
327 /* Save the DSDT to a file */
328 void dsdt_save_file(char *, struct ACPIsdt *, struct ACPIsdt *);
330 /* Print out as many fixed tables as possible, given the RSD PTR */
331 void sdt_print_all(struct ACPIsdt *);
333 /* Disassemble the AML in the DSDT */
334 void aml_disassemble(struct ACPIsdt *, struct ACPIsdt *);
336 /* Routines for accessing tables in physical memory */
337 struct ACPIrsdp *acpi_find_rsd_ptr(void);
338 void *acpi_map_physical(vm_offset_t, size_t);
339 struct ACPIsdt *sdt_from_rsdt(struct ACPIsdt *, const char *,
341 struct ACPIsdt *dsdt_from_fadt(struct FADTbody *);
342 int acpi_checksum(void *, size_t);
344 /* Command line flags */
349 #endif /* !_ACPIDUMP_H_ */