1 #ifndef _ACPI_H_ 2 #define _ACPI_H_ 3 4 #include "libcflat.h" 5 6 /* 7 * All tables and structures must be byte-packed to match the ACPI 8 * specification, since the tables are provided by the system firmware. 9 */ 10 #pragma pack(1) 11 12 #define ACPI_SIGNATURE(c1, c2, c3, c4) \ 13 ((c1) | ((c2) << 8) | ((c3) << 16) | ((c4) << 24)) 14 15 #define RSDP_SIGNATURE ACPI_SIGNATURE('R','S','D','P') 16 #define RSDT_SIGNATURE ACPI_SIGNATURE('R','S','D','T') 17 #define XSDT_SIGNATURE ACPI_SIGNATURE('X','S','D','T') 18 #define FACP_SIGNATURE ACPI_SIGNATURE('F','A','C','P') 19 #define FACS_SIGNATURE ACPI_SIGNATURE('F','A','C','S') 20 #define SPCR_SIGNATURE ACPI_SIGNATURE('S','P','C','R') 21 #define GTDT_SIGNATURE ACPI_SIGNATURE('G','T','D','T') 22 23 #define ACPI_SIGNATURE_8BYTE(c1, c2, c3, c4, c5, c6, c7, c8) \ 24 (((uint64_t)(ACPI_SIGNATURE(c1, c2, c3, c4))) | \ 25 ((uint64_t)(ACPI_SIGNATURE(c5, c6, c7, c8)) << 32)) 26 27 #define RSDP_SIGNATURE_8BYTE (ACPI_SIGNATURE_8BYTE('R', 'S', 'D', ' ', 'P', 'T', 'R', ' ')) 28 29 struct acpi_table_rsdp { /* Root System Descriptor Pointer */ 30 u64 signature; /* ACPI signature, contains "RSD PTR " */ 31 u8 checksum; /* To make sum of struct == 0 */ 32 u8 oem_id[6]; /* OEM identification */ 33 u8 revision; /* Must be 0 for 1.0, 2 for 2.0 */ 34 u32 rsdt_physical_address; /* 32-bit physical address of RSDT */ 35 u32 length; /* XSDT Length in bytes including hdr */ 36 u64 xsdt_physical_address; /* 64-bit physical address of XSDT */ 37 u8 extended_checksum; /* Checksum of entire table */ 38 u8 reserved[3]; /* Reserved field must be 0 */ 39 }; 40 41 #define ACPI_TABLE_HEADER_DEF /* ACPI common table header */ \ 42 u32 signature; /* ACPI signature (4 ASCII characters) */ \ 43 u32 length; /* Length of table, in bytes, including header */ \ 44 u8 revision; /* ACPI Specification minor version # */ \ 45 u8 checksum; /* To make sum of entire table == 0 */ \ 46 u8 oem_id[6]; /* OEM identification */ \ 47 u8 oem_table_id[8]; /* OEM table identification */ \ 48 u32 oem_revision; /* OEM revision number */ \ 49 u8 asl_compiler_id[4]; /* ASL compiler vendor ID */ \ 50 u32 asl_compiler_revision; /* ASL compiler revision number */ 51 52 struct acpi_table { 53 ACPI_TABLE_HEADER_DEF 54 char data[]; 55 }; 56 57 struct acpi_table_rsdt_rev1 { 58 ACPI_TABLE_HEADER_DEF 59 u32 table_offset_entry[]; 60 }; 61 62 struct acpi_table_xsdt { 63 ACPI_TABLE_HEADER_DEF 64 u64 table_offset_entry[]; 65 }; 66 67 struct acpi_generic_address { 68 u8 space_id; /* Address space where struct or register exists */ 69 u8 bit_width; /* Size in bits of given register */ 70 u8 bit_offset; /* Bit offset within the register */ 71 u8 access_width; /* Minimum Access size (ACPI 3.0) */ 72 u64 address; /* 64-bit address of struct or register */ 73 }; 74 75 struct acpi_table_fadt { 76 ACPI_TABLE_HEADER_DEF /* ACPI common table header */ 77 u32 firmware_ctrl; /* Physical address of FACS */ 78 u32 dsdt; /* Physical address of DSDT */ 79 u8 model; /* System Interrupt Model */ 80 u8 reserved1; /* Reserved */ 81 u16 sci_int; /* System vector of SCI interrupt */ 82 u32 smi_cmd; /* Port address of SMI command port */ 83 u8 acpi_enable; /* Value to write to smi_cmd to enable ACPI */ 84 u8 acpi_disable; /* Value to write to smi_cmd to disable ACPI */ 85 u8 S4bios_req; /* Value to write to SMI CMD to enter S4BIOS state */ 86 u8 reserved2; /* Reserved - must be zero */ 87 u32 pm1a_evt_blk; /* Port address of Power Mgt 1a acpi_event Reg Blk */ 88 u32 pm1b_evt_blk; /* Port address of Power Mgt 1b acpi_event Reg Blk */ 89 u32 pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ 90 u32 pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */ 91 u32 pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */ 92 u32 pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ 93 u32 gpe0_blk; /* Port addr of General Purpose acpi_event 0 Reg Blk */ 94 u32 gpe1_blk; /* Port addr of General Purpose acpi_event 1 Reg Blk */ 95 u8 pm1_evt_len; /* Byte length of ports at pm1_x_evt_blk */ 96 u8 pm1_cnt_len; /* Byte length of ports at pm1_x_cnt_blk */ 97 u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */ 98 u8 pm_tmr_len; /* Byte Length of ports at pm_tm_blk */ 99 u8 gpe0_blk_len; /* Byte Length of ports at gpe0_blk */ 100 u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ 101 u8 gpe1_base; /* Offset in gpe model where gpe1 events start */ 102 u8 reserved3; /* Reserved */ 103 u16 plvl2_lat; /* Worst case HW latency to enter/exit C2 state */ 104 u16 plvl3_lat; /* Worst case HW latency to enter/exit C3 state */ 105 u16 flush_size; /* Size of area read to flush caches */ 106 u16 flush_stride; /* Stride used in flushing caches */ 107 u8 duty_offset; /* Bit location of duty cycle field in p_cnt reg */ 108 u8 duty_width; /* Bit width of duty cycle field in p_cnt reg */ 109 u8 day_alrm; /* Index to day-of-month alarm in RTC CMOS RAM */ 110 u8 mon_alrm; /* Index to month-of-year alarm in RTC CMOS RAM */ 111 u8 century; /* Index to century in RTC CMOS RAM */ 112 u16 boot_flags; /* IA-PC Boot Architecture Flags (see below for individual flags) */ 113 u8 reserved; /* Reserved, must be zero */ 114 u32 flags; /* Miscellaneous flag bits (see below for individual flags) */ 115 struct acpi_generic_address reset_register; /* 64-bit address of the Reset register */ 116 u8 reset_value; /* Value to write to the reset_register port to reset the system */ 117 u16 arm_boot_flags; /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */ 118 u8 minor_revision; /* FADT Minor Revision (ACPI 5.1) */ 119 u64 Xfacs; /* 64-bit physical address of FACS */ 120 u64 Xdsdt; /* 64-bit physical address of DSDT */ 121 struct acpi_generic_address xpm1a_event_block; /* 64-bit Extended Power Mgt 1a Event Reg Blk address */ 122 struct acpi_generic_address xpm1b_event_block; /* 64-bit Extended Power Mgt 1b Event Reg Blk address */ 123 struct acpi_generic_address xpm1a_control_block; /* 64-bit Extended Power Mgt 1a Control Reg Blk address */ 124 struct acpi_generic_address xpm1b_control_block; /* 64-bit Extended Power Mgt 1b Control Reg Blk address */ 125 struct acpi_generic_address xpm2_control_block; /* 64-bit Extended Power Mgt 2 Control Reg Blk address */ 126 struct acpi_generic_address xpm_timer_block; /* 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */ 127 struct acpi_generic_address xgpe0_block; /* 64-bit Extended General Purpose Event 0 Reg Blk address */ 128 struct acpi_generic_address xgpe1_block; /* 64-bit Extended General Purpose Event 1 Reg Blk address */ 129 struct acpi_generic_address sleep_control; /* 64-bit Sleep Control register (ACPI 5.0) */ 130 struct acpi_generic_address sleep_status; /* 64-bit Sleep Status register (ACPI 5.0) */ 131 u64 hypervisor_id; /* Hypervisor Vendor ID (ACPI 6.0) */ 132 }; 133 134 /* Masks for FADT ARM Boot Architecture Flags (arm_boot_flags) ACPI 5.1 */ 135 136 #define ACPI_FADT_PSCI_COMPLIANT (1) /* 00: [V5+] PSCI 0.2+ is implemented */ 137 #define ACPI_FADT_PSCI_USE_HVC (1<<1) /* 01: [V5+] HVC must be used instead of SMC as the PSCI conduit */ 138 139 struct acpi_table_facs_rev1 { 140 u32 signature; /* ACPI Signature */ 141 u32 length; /* Length of structure, in bytes */ 142 u32 hardware_signature; /* Hardware configuration signature */ 143 u32 firmware_waking_vector; /* ACPI OS waking vector */ 144 u32 global_lock; /* Global Lock */ 145 u32 S4bios_f:1; /* Indicates if S4BIOS support is present */ 146 u32 reserved1:31; /* Must be 0 */ 147 u8 reserved3[40]; /* Reserved - must be zero */ 148 }; 149 150 struct spcr_descriptor { 151 ACPI_TABLE_HEADER_DEF /* ACPI common table header */ 152 u8 interface_type; /* 0=full 16550, 1=subset of 16550 */ 153 u8 reserved[3]; 154 struct acpi_generic_address serial_port; 155 u8 interrupt_type; 156 u8 pc_interrupt; 157 u32 interrupt; 158 u8 baud_rate; 159 u8 parity; 160 u8 stop_bits; 161 u8 flow_control; 162 u8 terminal_type; 163 u8 reserved1; 164 u16 pci_device_id; 165 u16 pci_vendor_id; 166 u8 pci_bus; 167 u8 pci_device; 168 u8 pci_function; 169 u32 pci_flags; 170 u8 pci_segment; 171 u32 reserved2; 172 }; 173 174 struct acpi_table_gtdt { 175 ACPI_TABLE_HEADER_DEF /* ACPI common table header */ 176 u64 counter_block_addresss; 177 u32 reserved; 178 u32 secure_el1_interrupt; 179 u32 secure_el1_flags; 180 u32 non_secure_el1_interrupt; 181 u32 non_secure_el1_flags; 182 u32 virtual_timer_interrupt; 183 u32 virtual_timer_flags; 184 u32 non_secure_el2_interrupt; 185 u32 non_secure_el2_flags; 186 u64 counter_read_block_address; 187 u32 platform_timer_count; 188 u32 platform_timer_offset; 189 }; 190 191 /* Reset to default packing */ 192 #pragma pack() 193 194 void set_efi_rsdp(struct acpi_table_rsdp *rsdp); 195 void *find_acpi_table_addr(u32 sig); 196 197 #endif 198