| 1 | /* |
|---|
| 2 | * Copyright (c) 2004, Intel Corporation. |
|---|
| 3 | * |
|---|
| 4 | * This program is free software; you can redistribute it and/or modify it |
|---|
| 5 | * under the terms and conditions of the GNU General Public License, |
|---|
| 6 | * version 2, as published by the Free Software Foundation. |
|---|
| 7 | * |
|---|
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 11 | * more details. |
|---|
| 12 | * |
|---|
| 13 | * You should have received a copy of the GNU General Public License along with |
|---|
| 14 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
|---|
| 15 | * Place - Suite 330, Boston, MA 02111-1307 USA. |
|---|
| 16 | * |
|---|
| 17 | */ |
|---|
| 18 | #ifndef _ACPI_2_0_H_ |
|---|
| 19 | #define _ACPI_2_0_H_ |
|---|
| 20 | |
|---|
| 21 | typedef unsigned char uint8_t; |
|---|
| 22 | typedef signed char int8_t; |
|---|
| 23 | typedef unsigned short uint16_t; |
|---|
| 24 | typedef signed short int16_t; |
|---|
| 25 | typedef unsigned int uint32_t; |
|---|
| 26 | typedef signed int int32_t; |
|---|
| 27 | #ifdef __i386__ |
|---|
| 28 | typedef unsigned long long uint64_t; |
|---|
| 29 | typedef signed long long int64_t; |
|---|
| 30 | #else |
|---|
| 31 | typedef unsigned long uint64_t; |
|---|
| 32 | typedef signed long int64_t; |
|---|
| 33 | #endif |
|---|
| 34 | |
|---|
| 35 | #include <xen/xen.h> |
|---|
| 36 | |
|---|
| 37 | #define ASCII32(a,b,c,d) \ |
|---|
| 38 | (((a) << 0) | ((b) << 8) | ((c) << 16) | ((d) << 24)) |
|---|
| 39 | #define ASCII64(a,b,c,d,e,f,g,h) \ |
|---|
| 40 | (((uint64_t)ASCII32(a,b,c,d)) | (((uint64_t)ASCII32(e,f,g,h)) << 32)) |
|---|
| 41 | |
|---|
| 42 | #pragma pack (1) |
|---|
| 43 | |
|---|
| 44 | /* |
|---|
| 45 | * Common ACPI header. |
|---|
| 46 | */ |
|---|
| 47 | struct acpi_header { |
|---|
| 48 | uint32_t signature; |
|---|
| 49 | uint32_t length; |
|---|
| 50 | uint8_t revision; |
|---|
| 51 | uint8_t checksum; |
|---|
| 52 | char oem_id[6]; |
|---|
| 53 | char oem_table_id[8]; |
|---|
| 54 | uint32_t oem_revision; |
|---|
| 55 | uint32_t creator_id; |
|---|
| 56 | uint32_t creator_revision; |
|---|
| 57 | }; |
|---|
| 58 | |
|---|
| 59 | #define ACPI_OEM_ID "Xen" |
|---|
| 60 | #define ACPI_OEM_TABLE_ID "HVM" |
|---|
| 61 | #define ACPI_OEM_REVISION 0 |
|---|
| 62 | |
|---|
| 63 | #define ACPI_CREATOR_ID ASCII32('H','V','M','L') /* HVMLoader */ |
|---|
| 64 | #define ACPI_CREATOR_REVISION 0 |
|---|
| 65 | |
|---|
| 66 | /* |
|---|
| 67 | * ACPI 2.0 Generic Address Space definition. |
|---|
| 68 | */ |
|---|
| 69 | struct acpi_20_generic_address { |
|---|
| 70 | uint8_t address_space_id; |
|---|
| 71 | uint8_t register_bit_width; |
|---|
| 72 | uint8_t register_bit_offset; |
|---|
| 73 | uint8_t reserved; |
|---|
| 74 | uint64_t address; |
|---|
| 75 | }; |
|---|
| 76 | |
|---|
| 77 | /* |
|---|
| 78 | * Generic Address Space Address IDs. |
|---|
| 79 | */ |
|---|
| 80 | #define ACPI_SYSTEM_MEMORY 0 |
|---|
| 81 | #define ACPI_SYSTEM_IO 1 |
|---|
| 82 | #define ACPI_PCI_CONFIGURATION_SPACE 2 |
|---|
| 83 | #define ACPI_EMBEDDED_CONTROLLER 3 |
|---|
| 84 | #define ACPI_SMBUS 4 |
|---|
| 85 | #define ACPI_FUNCTIONAL_FIXED_HARDWARE 0x7F |
|---|
| 86 | |
|---|
| 87 | /* |
|---|
| 88 | * Root System Description Pointer Structure in ACPI 1.0. |
|---|
| 89 | */ |
|---|
| 90 | struct acpi_10_rsdp { |
|---|
| 91 | uint64_t signature; |
|---|
| 92 | uint8_t checksum; |
|---|
| 93 | char oem_id[6]; |
|---|
| 94 | uint8_t reserved; |
|---|
| 95 | uint32_t rsdt_address; |
|---|
| 96 | }; |
|---|
| 97 | |
|---|
| 98 | /* |
|---|
| 99 | * Root System Description Pointer Structure. |
|---|
| 100 | */ |
|---|
| 101 | struct acpi_20_rsdp { |
|---|
| 102 | uint64_t signature; |
|---|
| 103 | uint8_t checksum; |
|---|
| 104 | char oem_id[6]; |
|---|
| 105 | uint8_t revision; |
|---|
| 106 | uint32_t rsdt_address; |
|---|
| 107 | uint32_t length; |
|---|
| 108 | uint64_t xsdt_address; |
|---|
| 109 | uint8_t extended_checksum; |
|---|
| 110 | uint8_t reserved[3]; |
|---|
| 111 | }; |
|---|
| 112 | |
|---|
| 113 | /* |
|---|
| 114 | * The maximum number of entrys in RSDT or XSDT. |
|---|
| 115 | */ |
|---|
| 116 | #define ACPI_MAX_NUM_TABLES 5 |
|---|
| 117 | |
|---|
| 118 | /* |
|---|
| 119 | * Root System Description Table (RSDT). |
|---|
| 120 | */ |
|---|
| 121 | struct acpi_20_rsdt { |
|---|
| 122 | struct acpi_header header; |
|---|
| 123 | uint32_t entry[1]; |
|---|
| 124 | }; |
|---|
| 125 | |
|---|
| 126 | /* |
|---|
| 127 | * Extended System Description Table (XSDT). |
|---|
| 128 | */ |
|---|
| 129 | struct acpi_20_xsdt { |
|---|
| 130 | struct acpi_header header; |
|---|
| 131 | uint64_t entry[1]; |
|---|
| 132 | }; |
|---|
| 133 | |
|---|
| 134 | /* |
|---|
| 135 | * TCG Hardware Interface Table (TCPA) |
|---|
| 136 | */ |
|---|
| 137 | struct acpi_20_tcpa { |
|---|
| 138 | struct acpi_header header; |
|---|
| 139 | uint16_t platform_class; |
|---|
| 140 | uint32_t laml; |
|---|
| 141 | uint64_t lasa; |
|---|
| 142 | }; |
|---|
| 143 | #define ACPI_2_0_TCPA_LAML_SIZE (64*1024) |
|---|
| 144 | |
|---|
| 145 | /* |
|---|
| 146 | * Fixed ACPI Description Table Structure (FADT) in ACPI 1.0. |
|---|
| 147 | */ |
|---|
| 148 | struct acpi_10_fadt { |
|---|
| 149 | struct acpi_header header; |
|---|
| 150 | uint32_t firmware_ctrl; |
|---|
| 151 | uint32_t dsdt; |
|---|
| 152 | uint8_t reserved0; |
|---|
| 153 | uint8_t preferred_pm_profile; |
|---|
| 154 | uint16_t sci_int; |
|---|
| 155 | uint32_t smi_cmd; |
|---|
| 156 | uint8_t acpi_enable; |
|---|
| 157 | uint8_t acpi_disable; |
|---|
| 158 | uint8_t s4bios_req; |
|---|
| 159 | uint8_t pstate_cnt; |
|---|
| 160 | uint32_t pm1a_evt_blk; |
|---|
| 161 | uint32_t pm1b_evt_blk; |
|---|
| 162 | uint32_t pm1a_cnt_blk; |
|---|
| 163 | uint32_t pm1b_cnt_blk; |
|---|
| 164 | uint32_t pm2_cnt_blk; |
|---|
| 165 | uint32_t pm_tmr_blk; |
|---|
| 166 | uint32_t gpe0_blk; |
|---|
| 167 | uint32_t gpe1_blk; |
|---|
| 168 | uint8_t pm1_evt_len; |
|---|
| 169 | uint8_t pm1_cnt_len; |
|---|
| 170 | uint8_t pm2_cnt_len; |
|---|
| 171 | uint8_t pm_tmr_len; |
|---|
| 172 | uint8_t gpe0_blk_len; |
|---|
| 173 | uint8_t gpe1_blk_len; |
|---|
| 174 | uint8_t gpe1_base; |
|---|
| 175 | uint8_t cst_cnt; |
|---|
| 176 | uint16_t p_lvl2_lat; |
|---|
| 177 | uint16_t p_lvl3_lat; |
|---|
| 178 | uint16_t flush_size; |
|---|
| 179 | uint16_t flush_stride; |
|---|
| 180 | uint8_t duty_offset; |
|---|
| 181 | uint8_t duty_width; |
|---|
| 182 | uint8_t day_alrm; |
|---|
| 183 | uint8_t mon_alrm; |
|---|
| 184 | uint8_t century; |
|---|
| 185 | uint16_t iapc_boot_arch; |
|---|
| 186 | uint8_t reserved1; |
|---|
| 187 | uint32_t flags; |
|---|
| 188 | }; |
|---|
| 189 | |
|---|
| 190 | /* |
|---|
| 191 | * Fixed ACPI Description Table Structure (FADT). |
|---|
| 192 | */ |
|---|
| 193 | struct acpi_20_fadt { |
|---|
| 194 | struct acpi_header header; |
|---|
| 195 | uint32_t firmware_ctrl; |
|---|
| 196 | uint32_t dsdt; |
|---|
| 197 | uint8_t reserved0; |
|---|
| 198 | uint8_t preferred_pm_profile; |
|---|
| 199 | uint16_t sci_int; |
|---|
| 200 | uint32_t smi_cmd; |
|---|
| 201 | uint8_t acpi_enable; |
|---|
| 202 | uint8_t acpi_disable; |
|---|
| 203 | uint8_t s4bios_req; |
|---|
| 204 | uint8_t pstate_cnt; |
|---|
| 205 | uint32_t pm1a_evt_blk; |
|---|
| 206 | uint32_t pm1b_evt_blk; |
|---|
| 207 | uint32_t pm1a_cnt_blk; |
|---|
| 208 | uint32_t pm1b_cnt_blk; |
|---|
| 209 | uint32_t pm2_cnt_blk; |
|---|
| 210 | uint32_t pm_tmr_blk; |
|---|
| 211 | uint32_t gpe0_blk; |
|---|
| 212 | uint32_t gpe1_blk; |
|---|
| 213 | uint8_t pm1_evt_len; |
|---|
| 214 | uint8_t pm1_cnt_len; |
|---|
| 215 | uint8_t pm2_cnt_len; |
|---|
| 216 | uint8_t pm_tmr_len; |
|---|
| 217 | uint8_t gpe0_blk_len; |
|---|
| 218 | uint8_t gpe1_blk_len; |
|---|
| 219 | uint8_t gpe1_base; |
|---|
| 220 | uint8_t cst_cnt; |
|---|
| 221 | uint16_t p_lvl2_lat; |
|---|
| 222 | uint16_t p_lvl3_lat; |
|---|
| 223 | uint16_t flush_size; |
|---|
| 224 | uint16_t flush_stride; |
|---|
| 225 | uint8_t duty_offset; |
|---|
| 226 | uint8_t duty_width; |
|---|
| 227 | uint8_t day_alrm; |
|---|
| 228 | uint8_t mon_alrm; |
|---|
| 229 | uint8_t century; |
|---|
| 230 | uint16_t iapc_boot_arch; |
|---|
| 231 | uint8_t reserved1; |
|---|
| 232 | uint32_t flags; |
|---|
| 233 | struct acpi_20_generic_address reset_reg; |
|---|
| 234 | uint8_t reset_value; |
|---|
| 235 | uint8_t reserved2[3]; |
|---|
| 236 | uint64_t x_firmware_ctrl; |
|---|
| 237 | uint64_t x_dsdt; |
|---|
| 238 | struct acpi_20_generic_address x_pm1a_evt_blk; |
|---|
| 239 | struct acpi_20_generic_address x_pm1b_evt_blk; |
|---|
| 240 | struct acpi_20_generic_address x_pm1a_cnt_blk; |
|---|
| 241 | struct acpi_20_generic_address x_pm1b_cnt_blk; |
|---|
| 242 | struct acpi_20_generic_address x_pm2_cnt_blk; |
|---|
| 243 | struct acpi_20_generic_address x_pm_tmr_blk; |
|---|
| 244 | struct acpi_20_generic_address x_gpe0_blk; |
|---|
| 245 | struct acpi_20_generic_address x_gpe1_blk; |
|---|
| 246 | }; |
|---|
| 247 | |
|---|
| 248 | /* |
|---|
| 249 | * FADT Boot Architecture Flags. |
|---|
| 250 | */ |
|---|
| 251 | #define ACPI_LEGACY_DEVICES (1 << 0) |
|---|
| 252 | #define ACPI_8042 (1 << 1) |
|---|
| 253 | |
|---|
| 254 | /* |
|---|
| 255 | * FADT Fixed Feature Flags. |
|---|
| 256 | */ |
|---|
| 257 | #define ACPI_WBINVD (1 << 0) |
|---|
| 258 | #define ACPI_WBINVD_FLUSH (1 << 1) |
|---|
| 259 | #define ACPI_PROC_C1 (1 << 2) |
|---|
| 260 | #define ACPI_P_LVL2_UP (1 << 3) |
|---|
| 261 | #define ACPI_PWR_BUTTON (1 << 4) |
|---|
| 262 | #define ACPI_SLP_BUTTON (1 << 5) |
|---|
| 263 | #define ACPI_FIX_RTC (1 << 6) |
|---|
| 264 | #define ACPI_RTC_S4 (1 << 7) |
|---|
| 265 | #define ACPI_TMR_VAL_EXT (1 << 8) |
|---|
| 266 | #define ACPI_DCK_CAP (1 << 9) |
|---|
| 267 | #define ACPI_RESET_REG_SUP (1 << 10) |
|---|
| 268 | #define ACPI_SEALED_CASE (1 << 11) |
|---|
| 269 | #define ACPI_HEADLESS (1 << 12) |
|---|
| 270 | #define ACPI_CPU_SW_SLP (1 << 13) |
|---|
| 271 | |
|---|
| 272 | /* |
|---|
| 273 | * Firmware ACPI Control Structure (FACS). |
|---|
| 274 | */ |
|---|
| 275 | struct acpi_20_facs { |
|---|
| 276 | uint32_t signature; |
|---|
| 277 | uint32_t length; |
|---|
| 278 | uint32_t hardware_signature; |
|---|
| 279 | uint32_t firmware_waking_vector; |
|---|
| 280 | uint32_t global_lock; |
|---|
| 281 | uint32_t flags; |
|---|
| 282 | uint64_t x_firmware_waking_vector; |
|---|
| 283 | uint8_t version; |
|---|
| 284 | uint8_t reserved[31]; |
|---|
| 285 | }; |
|---|
| 286 | |
|---|
| 287 | #define ACPI_2_0_FACS_VERSION 0x01 |
|---|
| 288 | |
|---|
| 289 | /* |
|---|
| 290 | * Multiple APIC Description Table header definition (MADT). |
|---|
| 291 | */ |
|---|
| 292 | struct acpi_20_madt { |
|---|
| 293 | struct acpi_header header; |
|---|
| 294 | uint32_t lapic_addr; |
|---|
| 295 | uint32_t flags; |
|---|
| 296 | }; |
|---|
| 297 | |
|---|
| 298 | |
|---|
| 299 | /* |
|---|
| 300 | * HPET Description Table |
|---|
| 301 | */ |
|---|
| 302 | struct acpi_20_hpet { |
|---|
| 303 | struct acpi_header header; |
|---|
| 304 | uint32_t timer_block_id; |
|---|
| 305 | struct acpi_20_generic_address addr; |
|---|
| 306 | uint8_t hpet_number; |
|---|
| 307 | uint16_t min_tick; |
|---|
| 308 | uint8_t page_protect; |
|---|
| 309 | }; |
|---|
| 310 | #define ACPI_HPET_ADDRESS 0xFED00000UL |
|---|
| 311 | |
|---|
| 312 | /* |
|---|
| 313 | * Multiple APIC Flags. |
|---|
| 314 | */ |
|---|
| 315 | #define ACPI_PCAT_COMPAT (1 << 0) |
|---|
| 316 | |
|---|
| 317 | /* |
|---|
| 318 | * Multiple APIC Description Table APIC structure types. |
|---|
| 319 | */ |
|---|
| 320 | #define ACPI_PROCESSOR_LOCAL_APIC 0x00 |
|---|
| 321 | #define ACPI_IO_APIC 0x01 |
|---|
| 322 | #define ACPI_INTERRUPT_SOURCE_OVERRIDE 0x02 |
|---|
| 323 | #define ACPI_NON_MASKABLE_INTERRUPT_SOURCE 0x03 |
|---|
| 324 | #define ACPI_LOCAL_APIC_NMI 0x04 |
|---|
| 325 | #define ACPI_LOCAL_APIC_ADDRESS_OVERRIDE 0x05 |
|---|
| 326 | #define ACPI_IO_SAPIC 0x06 |
|---|
| 327 | #define ACPI_PROCESSOR_LOCAL_SAPIC 0x07 |
|---|
| 328 | #define ACPI_PLATFORM_INTERRUPT_SOURCES 0x08 |
|---|
| 329 | |
|---|
| 330 | /* |
|---|
| 331 | * APIC Structure Definitions. |
|---|
| 332 | */ |
|---|
| 333 | |
|---|
| 334 | /* |
|---|
| 335 | * Processor Local APIC Structure Definition. |
|---|
| 336 | */ |
|---|
| 337 | struct acpi_20_madt_lapic { |
|---|
| 338 | uint8_t type; |
|---|
| 339 | uint8_t length; |
|---|
| 340 | uint8_t acpi_processor_id; |
|---|
| 341 | uint8_t apic_id; |
|---|
| 342 | uint32_t flags; |
|---|
| 343 | }; |
|---|
| 344 | |
|---|
| 345 | /* |
|---|
| 346 | * Local APIC Flags. All other bits are reserved and must be 0. |
|---|
| 347 | */ |
|---|
| 348 | #define ACPI_LOCAL_APIC_ENABLED (1 << 0) |
|---|
| 349 | |
|---|
| 350 | /* |
|---|
| 351 | * IO APIC Structure. |
|---|
| 352 | */ |
|---|
| 353 | struct acpi_20_madt_ioapic { |
|---|
| 354 | uint8_t type; |
|---|
| 355 | uint8_t length; |
|---|
| 356 | uint8_t ioapic_id; |
|---|
| 357 | uint8_t reserved; |
|---|
| 358 | uint32_t ioapic_addr; |
|---|
| 359 | uint32_t gsi_base; |
|---|
| 360 | }; |
|---|
| 361 | |
|---|
| 362 | struct acpi_20_madt_intsrcovr { |
|---|
| 363 | uint8_t type; |
|---|
| 364 | uint8_t length; |
|---|
| 365 | uint8_t bus; |
|---|
| 366 | uint8_t source; |
|---|
| 367 | uint32_t gsi; |
|---|
| 368 | uint16_t flags; |
|---|
| 369 | }; |
|---|
| 370 | |
|---|
| 371 | /* |
|---|
| 372 | * Table Signatures. |
|---|
| 373 | */ |
|---|
| 374 | #define ACPI_2_0_RSDP_SIGNATURE ASCII64('R','S','D',' ','P','T','R',' ') |
|---|
| 375 | #define ACPI_2_0_FACS_SIGNATURE ASCII32('F','A','C','S') |
|---|
| 376 | #define ACPI_2_0_FADT_SIGNATURE ASCII32('F','A','C','P') |
|---|
| 377 | #define ACPI_2_0_MADT_SIGNATURE ASCII32('A','P','I','C') |
|---|
| 378 | #define ACPI_2_0_RSDT_SIGNATURE ASCII32('R','S','D','T') |
|---|
| 379 | #define ACPI_2_0_XSDT_SIGNATURE ASCII32('X','S','D','T') |
|---|
| 380 | #define ACPI_2_0_TCPA_SIGNATURE ASCII32('T','C','P','A') |
|---|
| 381 | #define ACPI_2_0_HPET_SIGNATURE ASCII32('H','P','E','T') |
|---|
| 382 | |
|---|
| 383 | /* |
|---|
| 384 | * Table revision numbers. |
|---|
| 385 | */ |
|---|
| 386 | #define ACPI_2_0_RSDP_REVISION 0x02 |
|---|
| 387 | #define ACPI_2_0_FADT_REVISION 0x04 |
|---|
| 388 | #define ACPI_2_0_MADT_REVISION 0x02 |
|---|
| 389 | #define ACPI_2_0_RSDT_REVISION 0x01 |
|---|
| 390 | #define ACPI_2_0_XSDT_REVISION 0x01 |
|---|
| 391 | #define ACPI_2_0_TCPA_REVISION 0x02 |
|---|
| 392 | #define ACPI_2_0_HPET_REVISION 0x01 |
|---|
| 393 | #define ACPI_1_0_FADT_REVISION 0x01 |
|---|
| 394 | |
|---|
| 395 | #pragma pack () |
|---|
| 396 | |
|---|
| 397 | int acpi_build_tables(uint8_t *); |
|---|
| 398 | |
|---|
| 399 | #endif /* _ACPI_2_0_H_ */ |
|---|
| 400 | |
|---|
| 401 | /* |
|---|
| 402 | * Local variables: |
|---|
| 403 | * mode: C |
|---|
| 404 | * c-set-style: "BSD" |
|---|
| 405 | * c-basic-offset: 4 |
|---|
| 406 | * tab-width: 4 |
|---|
| 407 | * indent-tabs-mode: nil |
|---|
| 408 | * End: |
|---|
| 409 | */ |
|---|