Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

367 lines
16 KiB

  1. /*****************************************************************************
  2. *
  3. * (C) Copyright MICROSOFT Corp., 1996
  4. *
  5. * Title: ACPITABL.H --- Definitions and descriptions of the various BIOS supplied ACPI tables.
  6. *
  7. * Version: 1.00
  8. *
  9. * Date: 6-17-96
  10. *
  11. * Author: Jason Clark (jasoncl)
  12. *
  13. *------------------------------------------------------------------------------
  14. *
  15. * Change log:
  16. *
  17. * DATE REV DESCRIPTION
  18. * ----------- --- -----------------------------------------------------------
  19. *
  20. ****************************************************************************/
  21. // These map to bios provided structures, so turn on 1 byte packing
  22. #include <pshpack1.h>
  23. #define SPEC_VER 100
  24. #define RSDP_SIGNATURE 0x2052545020445352 // "RSD PTR "
  25. typedef struct _RSDP { // Root System Description Table Pointer Structure
  26. ULONGLONG Signature; // 8 UCHAR table signature 'RSD PTR '
  27. UCHAR Checksum; // sum of all UCHARs of structure must = 0
  28. UCHAR OEMID[6]; // String that uniquely ID's the OEM
  29. UCHAR Reserved[1]; // must be 0
  30. ULONG RsdtAddress; // physical address of Root System Description Table
  31. } RSDP;
  32. typedef RSDP *PRSDP;
  33. #ifndef NEC_98
  34. #define RSDP_SEARCH_RANGE_BEGIN 0xE0000 // physical address where we begin searching for the RSDP
  35. #else // NEC_98
  36. #define RSDP_SEARCH_RANGE_BEGIN 0xE8000 // physical address where we begin searching for the RSDP
  37. #endif // NEC_98
  38. #define RSDP_SEARCH_RANGE_END 0xFFFFF
  39. #define RSDP_SEARCH_RANGE_LENGTH (RSDP_SEARCH_RANGE_END-RSDP_SEARCH_RANGE_BEGIN+1)
  40. #define RSDP_SEARCH_INTERVAL 16 // search on 16 byte boundaries
  41. typedef struct _DESCRIPTION_HEADER { // Header structure appears at the beginning of each ACPI table
  42. ULONG Signature; // Signature used to identify the type of table
  43. ULONG Length; // Length of entire table including the DESCRIPTION_HEADER
  44. UCHAR Revision; // Minor version of ACPI spec to which this table conforms
  45. UCHAR Checksum; // sum of all bytes in the entire TABLE should = 0
  46. UCHAR OEMID[6]; // String that uniquely ID's the OEM
  47. UCHAR OEMTableID[8]; // String that uniquely ID's this table (used for table patching and replacement).
  48. ULONG OEMRevision; // OEM supplied table revision number. Bigger number = newer table.
  49. #if SPEC_VER > 92
  50. UCHAR CreatorID[4]; // Vendor ID of utility which created this table.
  51. ULONG CreatorRev; // Revision of utility that created the table.
  52. #endif
  53. } DESCRIPTION_HEADER;
  54. typedef DESCRIPTION_HEADER *PDESCRIPTION_HEADER;
  55. // Header constants
  56. #define ACPI_MAX_SIGNATURE 4
  57. #define ACPI_MAX_OEM_ID 6
  58. #define ACPI_MAX_TABLE_ID 8
  59. #define ACPI_MAX_TABLE_STRINGS ACPI_MAX_SIGNATURE + ACPI_MAX_OEM_ID + ACPI_MAX_TABLE_ID
  60. #define FACS_SIGNATURE 0x53434146 // "FACS"
  61. typedef struct _FACS { // Firmware ACPI Control Structure. Note that this table does not have a header, it is pointed to by the FADT
  62. ULONG Signature; // 'FACS'
  63. ULONG Length; // Length of entire firmware ACPI control structure (must be 64 bytes or larger)
  64. ULONG HardwareSignature;
  65. ULONG pFirmwareWakingVector; // physical address of location where the OS needs to put the firmware waking vector
  66. ULONG GlobalLock; // 32 bit structure used for sharing Embedded Controller
  67. #if SPEC_VER > 92
  68. ULONG Flags;
  69. UCHAR Reserved[40];
  70. #else
  71. UCHAR Reserved [44];
  72. #endif
  73. } FACS;
  74. typedef FACS *PFACS;
  75. // FACS.GlobalLock bit field definitions
  76. #define GL_PENDING_BIT 0x00
  77. #define GL_PENDING (1 << GL_PENDING_BIT)
  78. #define GL_OWNER_BIT 0x01
  79. #define GL_OWNER (1 << GL_OWNER_BIT)
  80. #define GL_NON_RESERVED_BITS_MASK (GL_PENDING+GL_OWNED)
  81. // FACS Flags definitions
  82. #define FACS_S4BIOS_SUPPORTED_BIT 0 // flag indicates whether or not the BIOS will save/restore memory around S4
  83. #define FACS_S4BIOS_SUPPORTED (1 << FACS_S4BIOS_SUPPORTED_BIT)
  84. #define FADT_SIGNATURE 0x50434146 // "FACP"
  85. typedef struct _FADT { // Fixed ACPI description table
  86. DESCRIPTION_HEADER Header;
  87. ULONG facs; // Physical address of the Firmware ACPI Control Structure
  88. ULONG dsdt; // Physical address of the Differentiated System Description Table
  89. UCHAR int_model; // System's Interrupt mode, 0=Dual PIC, 1=Multiple APIC, >1 reserved
  90. UCHAR reserved4;
  91. USHORT sci_int_vector; // Vector of SCI interrupt.
  92. PUCHAR smi_cmd_io_port; // Address in System I/O Space of the SMI Command port, used to enable and disable ACPI.
  93. UCHAR acpi_on_value; // Value out'd to smi_cmd_port to activate ACPI
  94. UCHAR acpi_off_value; // Value out'd to smi_cmd_port to deactivate ACPI
  95. UCHAR s4bios_req; // Value to write to SMI_CMD to enter the S4 state.
  96. UCHAR reserved1; // Must Be 0
  97. ULONG pm1a_evt_blk_io_port; // Address in System I/O Space of the PM1a_EVT_BLK register block
  98. ULONG pm1b_evt_blk_io_port; // Address in System I/O Space of the PM1b_EVT_BLK register block
  99. ULONG pm1a_ctrl_blk_io_port; // Address in System I/O Space of the PM1a_CNT_BLK register block
  100. ULONG pm1b_ctrl_blk_io_port; // Address in System I/O Space of the PM1b_CNT_BLK register block
  101. ULONG pm2_ctrl_blk_io_port; // Address in System I/O Space of the PM2_CNT_BLK register block
  102. ULONG pm_tmr_blk_io_port; // Address in System I/O Space of the PM_TMR register block
  103. ULONG gp0_blk_io_port; // Address in System I/O Space of the GP0 register block
  104. ULONG gp1_blk_io_port; // Address in System I/O Space of the GP1 register block
  105. UCHAR pm1_evt_len; // number of bytes decoded for PM1_BLK (must be >= 4)
  106. UCHAR pm1_ctrl_len; // number of bytes decoded for PM1_CNT (must be >= 2)
  107. UCHAR pm2_ctrl_len; // number of bytes decoded for PM1a_CNT (must be >= 1)
  108. UCHAR pm_tmr_len; // number of bytes decoded for PM_TMR (must be >= 4)
  109. UCHAR gp0_blk_len; // number of bytes decoded for GP0_BLK (must be multiple of 2)
  110. UCHAR gp1_blk_len; // number of bytes decoded for GP1_BLK (must be multiple of 2)
  111. UCHAR gp1_base; // index at which GP1 based events start
  112. UCHAR reserved2; // Must Be 0
  113. USHORT lvl2_latency; // Worst case latency in microseconds required to enter and leave the C2 processor state
  114. USHORT lvl3_latency; // Worst case latency in microseconds required to enter and leave the C3 processor state
  115. USHORT flush_size; // Ignored if WBINVD flag is 1 -- indicates size of memory read to flush dirty lines from
  116. // any processors memory caches. A size of zero indicates this is not supported.
  117. USHORT flush_stride; // Ignored if WBINVD flag is 1 -- the memory stride width, in bytes, to perform reads to flush
  118. // the processor's memory caches.
  119. UCHAR duty_offset; // zero based index of where the processor's duty cycle setting is within the processor's P_CNT register.
  120. UCHAR duty_width; // bit width of the processor's duty cycle setting value in the P_CNT register.
  121. // a value of zero indicates that processor duty cycle is not supported
  122. UCHAR day_alarm_index;
  123. UCHAR month_alarm_index;
  124. UCHAR century_alarm_index;
  125. #if SPEC_VER > 92
  126. UCHAR reserved3[3];
  127. ULONG flags;
  128. #else
  129. UCHAR reserved3;
  130. ULONG flags;
  131. #endif
  132. } FADT;
  133. typedef FADT *PFADT;
  134. // definition of FADT.flags bits
  135. // this one bit flag indicates whether or not the WBINVD instruction works properly,if this bit is not set we can not use S2, S3 states, or
  136. // C3 on MP machines
  137. #define WRITEBACKINVALIDATE_WORKS_BIT 0
  138. #define WRITEBACKINVALIDATE_WORKS (1 << WRITEBACKINVALIDATE_WORKS_BIT)
  139. // this flag indicates if wbinvd works EXCEPT that it does not invalidate the cache
  140. #define WRITEBACKINVALIDATE_DOESNT_INVALIDATE_BIT 1
  141. #define WRITEBACKINVALIDATE_DOESNT_INVALIDATE (1 << WRITEBACKINVALIDATE_DOESNT_INVALIDATE_BIT)
  142. // this flag indicates that the C1 state is supported on all processors.
  143. #define SYSTEM_SUPPORTS_C1_BIT 2
  144. #define SYSTEM_SUPPORTS_C1 (1 << SYSTEM_SUPPORTS_C1_BIT)
  145. // this one bit flag indicates whether support for the C2 state is restricted to uniprocessor machines
  146. #define P_LVL2_UP_ONLY_BIT 3
  147. #define P_LVL2_UP_ONLY (1 << P_LVL2_UP_ONLY_BIT)
  148. // this bit indicates whether the PWR button is treated as a fix feature (0) or a generic feature (1)
  149. #define PWR_BUTTON_GENERIC_BIT 4
  150. #define PWR_BUTTON_GENERIC (1 << PWR_BUTTON_GENERIC_BIT)
  151. #define SLEEP_BUTTON_GENERIC_BIT 5
  152. #define SLEEP_BUTTON_GENERIC (1 << SLEEP_BUTTON_GENERIC_BIT)
  153. // this bit indicates whether the RTC wakeup status is reported in fix register space (0) or not (1)
  154. #define RTC_WAKE_GENERIC_BIT 6
  155. #define RTC_WAKE_GENERIC (1 << RTC_WAKE_GENERIC_BIT)
  156. #define RTC_WAKE_FROM_S4_BIT 7
  157. #define RTC_WAKE_FROM_S4 (1 << RTC_WAKE_FROM_S4_BIT)
  158. // This bit indicates whether the machine implements a 24 or 32 bit timer.
  159. #define TMR_VAL_EXT_BIT 8
  160. #define TMR_VAL_EXT (1 << TMR_VAL_EXT_BIT)
  161. // This bit indicates whether the machine supports docking
  162. #define DCK_CAP_BIT 9
  163. #define DCK_CAP (1 << DCK_CAP_BIT)
  164. // spec defines maximum entry/exit latency values for C2 and C3, if the FADT indicates that these values are
  165. // exceeded then we do not use that C state.
  166. #define C2_MAX_LATENCY 100
  167. #define C3_MAX_LATENCY 1000
  168. #ifndef ANYSIZE_ARRAY
  169. #define ANYSIZE_ARRAY 1
  170. #endif
  171. // Multiple APIC description table
  172. typedef struct _MAPIC {
  173. DESCRIPTION_HEADER Header;
  174. ULONG LocalAPICAddress; // Physical Address at which each processor can access its local APIC
  175. ULONG Flags;
  176. ULONG APICTables[ANYSIZE_ARRAY]; // A list of APIC tables.
  177. } MAPIC;
  178. typedef MAPIC *PMAPIC;
  179. // Multiple APIC structure flags
  180. #define PCAT_COMPAT_BIT 0 // indicates that the system also has a dual 8259 pic setup.
  181. #define PCAT_COMPAT (1 << PCAT_COMPAT_BIT)
  182. // APIC Structure Types
  183. #define PROCESSOR_LOCAL_APIC 0
  184. #define IO_APIC 1
  185. #define ISA_VECTOR_OVERRIDE 2
  186. #define NMI_SOURCE 3
  187. #define PROCESSOR_LOCAL_APIC_LENGTH 8
  188. #define IO_APIC_LENGTH 12
  189. #define ISA_VECTOR_OVERRIDE_LENGTH 10
  190. #define NMI_SOURCE_LENGTH 8
  191. // The shared beginning info in all APIC Structures
  192. typedef struct _APICTABLE {
  193. UCHAR Type;
  194. UCHAR Length;
  195. } APICTABLE;
  196. typedef APICTABLE *PAPICTABLE;
  197. typedef struct _PROCLOCALAPIC {
  198. UCHAR Type; // should be zero to identify a ProcessorLocalAPIC structure
  199. UCHAR Length; // better be 8
  200. UCHAR ACPIProcessorID; // ProcessorID for which this processor is listed in the ACPI processor declaration
  201. // operator.
  202. UCHAR APICID; // The processor's local APIC ID.
  203. ULONG Flags;
  204. } PROCLOCALAPIC;
  205. typedef PROCLOCALAPIC *PPROCLOCALAPIC;
  206. // Processor Local APIC Flags
  207. #define PLAF_ENABLED_BIT 0
  208. #define PLAF_ENABLED (1 << PLAF_ENABLED_BIT)
  209. typedef struct _IOAPIC {
  210. UCHAR Type;
  211. UCHAR Length; // better be 12
  212. UCHAR IOAPICID;
  213. UCHAR Reserved;
  214. ULONG IOAPICAddress; // Physical address at which this IO APIC resides.
  215. ULONG SystemVectorBase; // system interrupt vector index for this APIC
  216. } IOAPIC;
  217. typedef IOAPIC *PIOAPIC;
  218. // Interrupt Source Override
  219. typedef struct {
  220. UCHAR Type; // Must be 2
  221. UCHAR Length; // Must be 10
  222. UCHAR Bus; // Must be 0
  223. UCHAR Source; // BusRelative IRQ
  224. ULONG GlobalSystemInterruptVector; // Global IRQ
  225. USHORT Flags; // Same as MPS INTI Flags
  226. } ISA_VECTOR, *PISA_VECTOR;
  227. // Non Maskable Source Interrupt
  228. typedef struct {
  229. UCHAR Type; // must be 3
  230. UCHAR Length; // better be 8
  231. USHORT Flags; // Same as MPS INTI Flags
  232. ULONG GlobalSystemInterruptVector; // Interrupt connected to NMI
  233. } NMISOURCE, *PNMISOURCE;
  234. typedef struct _SMARTBATTTABLE {
  235. DESCRIPTION_HEADER Header;
  236. ULONG WarningEnergyLevel; // mWh at which the OEM suggests we warn the user that the battery is getting low.
  237. ULONG LowEnergyLevel; // mWh at which the OEM suggests we put the machine into a sleep state.
  238. ULONG CriticalEnergyLevel; // mWH at which the OEM suggests we do an emergency shutdown.
  239. } SMARTBATTTABLE;
  240. typedef SMARTBATTTABLE *PSMARTBATTTABLE;
  241. #define RSDT_SIGNATURE 0x54445352 // "RSDT"
  242. typedef struct _RSDT { // Root System Description Table
  243. DESCRIPTION_HEADER Header;
  244. ULONG Tables[ANYSIZE_ARRAY]; // The structure contains an n length array of physical addresses each of which point to another table.
  245. } RSDT;
  246. typedef RSDT *PRSDT;
  247. // The below macro uses the min macro to protect against the case where we are running on machine which is compliant with
  248. // a spec prior to .99. If you had a .92 compliant header and one table pointer we would end of subtracting 32-36 resulting
  249. // in a really big number and hence we would think we had lots and lots of tables... Using the min macro we end up subtracting
  250. // the length-length getting zero which will be harmless and cause us to fail to load (with a red screen on Win9x) which is
  251. // the best we can do in this case.
  252. #ifndef min
  253. #define min(a,b) (((a) < (b)) ? (a) : (b))
  254. #endif
  255. #define NumTableEntriesFromRSDTPointer(p) (p->Header.Length-min(p->Header.Length,sizeof(DESCRIPTION_HEADER)))/4
  256. #define APIC_SIGNATURE 0x43495041 // "APIC"
  257. #define DSDT_SIGNATURE 0x54445344 // "DSDT"
  258. #define SSDT_SIGNATURE 0x54445353 // "SSDT"
  259. #define PSDT_SIGNATURE 0x54445350 // "PSDT"
  260. #define SBST_SIGNATURE 0x54534253 // "SBST"
  261. typedef struct _DSDT { // Differentiated System Description Table
  262. DESCRIPTION_HEADER Header;
  263. UCHAR DiffDefBlock[ANYSIZE_ARRAY]; // this is the AML describing the base system.
  264. } DSDT;
  265. typedef DSDT *PDSDT;
  266. // Resume normal structure packing
  267. #include <poppack.h>
  268. #ifdef BOOLEAN // hack to build ASL.exe
  269. typedef struct {
  270. UCHAR NamespaceProcID;
  271. UCHAR ApicID;
  272. UCHAR NtNumber;
  273. BOOLEAN Started;
  274. } PROC_LOCAL_APIC, *PPROC_LOCAL_APIC;
  275. extern PROC_LOCAL_APIC HalpProcLocalApicTable[];
  276. #endif