Leaked source code of windows server 2003
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.

465 lines
11 KiB

  1. ;/*++
  2. ;
  3. ; Copyright (c) Microsoft Corporation. All rights reserved.
  4. ;
  5. ; Module Name:
  6. ;
  7. ; ntacpi.h
  8. ;
  9. ; Abstract:
  10. ;
  11. ;
  12. ; This module contains definitions specific to the HAL's
  13. ; ACPI function.
  14. ;
  15. ; Author:
  16. ;
  17. ; Jake Oshins (jakeo) Feb. 18, 1997
  18. ;
  19. ; Revision History:
  20. ;
  21. ;-
  22. if 0 ; Begin C only code */
  23. #ifndef _ACPI_H_
  24. #define _ACPI_H_
  25. #define SLEEP_STATE_FLUSH_CACHE 0x1
  26. #define SLEEP_STATE_FIRMWARE_RESTART 0x2
  27. #define SLEEP_STATE_SAVE_MOTHERBOARD 0x4
  28. #define SLEEP_STATE_OFF 0x8
  29. #define SLEEP_STATE_RESTART_OTHER_PROCESSORS 0x10
  30. typedef struct {
  31. union {
  32. struct {
  33. ULONG Pm1aVal:4;
  34. ULONG Pm1bVal:4;
  35. ULONG Flags:24;
  36. } bits;
  37. ULONG AsULONG;
  38. };
  39. } SLEEP_STATE_CONTEXT, *PSLEEP_STATE_CONTEXT;
  40. //
  41. // ACPI Register definitions
  42. //
  43. #define P_LVL2 4
  44. #define PBLK_THT_EN 0x10
  45. //
  46. // Register layout of PM1x_EVT register
  47. // Note also defined in acpiregs.h
  48. //
  49. #define PM1_PWRBTN_STS_BIT 8
  50. #define PM1_PWRBTN_STS (1 << PM1_PWRBTN_STS_BIT)
  51. //
  52. // Register layout of PM1x_CTL
  53. //
  54. #define SCI_EN 1
  55. #define BM_RLD 2
  56. #define CTL_IGNORE 0x200
  57. #define SLP_TYP_SHIFT 10
  58. #define SLP_EN 0x2000
  59. #define CTL_PRESERVE (SCI_EN + BM_RLD + CTL_IGNORE)
  60. #define PM_TMR_FREQ 3579545
  61. //
  62. // HAL's table
  63. //
  64. typedef enum {
  65. HalAcpiTimerInit,
  66. HalAcpiTimerInterrupt,
  67. HalAcpiMachineStateInit,
  68. HalAcpiQueryFlags,
  69. HalPicStateIntact,
  70. HalRestorePicState,
  71. HalPciInterfaceReadConfig,
  72. HalPciInterfaceWriteConfig,
  73. HalSetVectorState,
  74. HalGetIOApicVersion,
  75. HalSetMaxLegacyPciBusNumber,
  76. HalIsVectorValid,
  77. HalAcpiMaxFunction
  78. } HAL_DISPATCH_FUNCTION;
  79. typedef
  80. VOID
  81. (*pHalAcpiTimerInit)(
  82. IN ULONG TimerPort,
  83. IN BOOLEAN TimerValExt
  84. );
  85. typedef
  86. VOID
  87. (*pHalAcpiTimerInterrupt)(
  88. VOID
  89. );
  90. typedef struct {
  91. ULONG Count;
  92. ULONG Pblk[1];
  93. } PROCESSOR_INIT, *PPROCESSOR_INIT;
  94. #define HAL_C1_SUPPORTED 0x01
  95. #define HAL_C2_SUPPORTED 0x02
  96. #define HAL_C3_SUPPORTED 0x04
  97. #define HAL_S1_SUPPORTED 0x08
  98. #define HAL_S2_SUPPORTED 0x10
  99. #define HAL_S3_SUPPORTED 0x20
  100. #define HAL_S4_SUPPORTED 0x40
  101. #define HAL_S5_SUPPORTED 0x80
  102. typedef struct {
  103. BOOLEAN Supported;
  104. UCHAR Pm1aVal;
  105. UCHAR Pm1bVal;
  106. } HAL_SLEEP_VAL, *PHAL_SLEEP_VAL;
  107. typedef
  108. VOID
  109. (*pHalAcpiMachineStateInit)(
  110. IN PPROCESSOR_INIT ProcInit,
  111. IN PHAL_SLEEP_VAL SleepValues,
  112. OUT PULONG PicVal
  113. );
  114. typedef
  115. ULONG
  116. (*pHalAcpiQueryFlags)(
  117. VOID
  118. );
  119. typedef
  120. BOOLEAN
  121. (*pHalPicStateIntact)(
  122. VOID
  123. );
  124. typedef
  125. VOID
  126. (*pHalRestorePicState)(
  127. VOID
  128. );
  129. typedef
  130. ULONG
  131. (*pHalInterfaceReadWriteConfig)(
  132. IN PVOID Context,
  133. IN UCHAR BusOffset,
  134. IN ULONG Slot,
  135. IN PVOID Buffer,
  136. IN ULONG Offset,
  137. IN ULONG Length
  138. );
  139. //
  140. // Flags for interrupt vectors
  141. //
  142. #define VECTOR_MODE 1
  143. #define VECTOR_LEVEL 1
  144. #define VECTOR_EDGE 0
  145. #define VECTOR_POLARITY 2
  146. #define VECTOR_ACTIVE_LOW 2
  147. #define VECTOR_ACTIVE_HIGH 0
  148. //
  149. // Vector Type:
  150. //
  151. // VECTOR_SIGNAL = standard edge-triggered or
  152. // level-sensitive interrupt vector
  153. //
  154. // VECTOR_MESSAGE = an MSI (Message Signalled Interrupt) vector
  155. //
  156. #define VECTOR_TYPE 4
  157. #define VECTOR_SIGNAL 0
  158. #define VECTOR_MESSAGE 4
  159. #define IS_LEVEL_TRIGGERED(vectorFlags) \
  160. (vectorFlags & VECTOR_LEVEL)
  161. #define IS_EDGE_TRIGGERED(vectorFlags) \
  162. !(vectorFlags & VECTOR_LEVEL)
  163. #define IS_ACTIVE_LOW(vectorFlags) \
  164. (vectorFlags & VECTOR_ACTIVE_LOW)
  165. #define IS_ACTIVE_HIGH(vectorFlags) \
  166. !(vectorFlags & VECTOR_ACTIVE_LOW)
  167. typedef
  168. VOID
  169. (*pHalSetVectorState)(
  170. IN ULONG Vector,
  171. IN ULONG Flags
  172. );
  173. VOID
  174. HaliSetVectorState(
  175. IN ULONG Vector,
  176. IN ULONG Flags
  177. );
  178. #define HAL_ACPI_PCI_RESOURCES 0x01
  179. #define HAL_ACPI_PRT_SUPPORT 0x02
  180. typedef
  181. ULONG
  182. (*pHalGetIOApicVersion)(
  183. IN ULONG ApicNo
  184. );
  185. typedef
  186. VOID
  187. (*pHalSetMaxLegacyPciBusNumber)(
  188. IN ULONG BusNumber
  189. );
  190. typedef
  191. BOOLEAN
  192. (*pHalIsVectorValid)(
  193. IN ULONG Vector
  194. );
  195. BOOLEAN
  196. HaliIsVectorValid(
  197. IN ULONG Vector
  198. );
  199. //
  200. // typedef struct _PM_DISPATCH_TABLE {
  201. // ULONG Signature;
  202. // ULONG Version;
  203. // PVOID Function[1];
  204. // } PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE;
  205. //
  206. typedef struct {
  207. ULONG Signature;
  208. ULONG Version;
  209. pHalAcpiTimerInit HalpAcpiTimerInit;
  210. pHalAcpiTimerInterrupt HalpAcpiTimerInterrupt;
  211. pHalAcpiMachineStateInit HalpAcpiMachineStateInit;
  212. pHalAcpiQueryFlags HalpAcpiQueryFlags;
  213. pHalPicStateIntact HalxPicStateIntact;
  214. pHalRestorePicState HalxRestorePicState;
  215. pHalInterfaceReadWriteConfig HalpPciInterfaceReadConfig;
  216. pHalInterfaceReadWriteConfig HalpPciInterfaceWriteConfig;
  217. pHalSetVectorState HalpSetVectorState;
  218. pHalGetIOApicVersion HalpGetIOApicVersion;
  219. pHalSetMaxLegacyPciBusNumber HalpSetMaxLegacyPciBusNumber;
  220. pHalIsVectorValid HalpIsVectorValid;
  221. } HAL_ACPI_DISPATCH_TABLE, *PHAL_ACPI_DISPATCH_TABLE;
  222. #define HAL_ACPI_DISPATCH_SIGNATURE 'HAL '
  223. #define HAL_ACPI_DISPATCH_VERSION 2
  224. #define HalAcpiTimerInit ((pHalAcpiTimerInit)PmHalDispatchTable->Function[HalAcpiTimerInit])
  225. #define HalAcpiTimerInterrupt ((pHalAcpiTimerInterrupt)PmHalDispatchTable->Function[HalAcpiTimerInterrupt])
  226. #define HalAcpiMachineStateInit ((pHalAcpiMachineStateInit)PmHalDispatchTable->Function[HalAcpiMachineStateInit])
  227. #define HalPicStateIntact ((pHalPicStateIntact)PmHalDispatchTable->Function[HalPicStateIntact])
  228. #define HalRestorePicState ((pHalRestorePicState)PmHalDispatchTable->Function[HalRestorePicState])
  229. #define HalPciInterfaceReadConfig ((pHalInterfaceReadWriteConfig)PmHalDispatchTable->Function[HalPciInterfaceReadConfig])
  230. #define HalPciInterfaceWriteConfig ((pHalInterfaceReadWriteConfig)PmHalDispatchTable->Function[HalPciInterfaceWriteConfig])
  231. #define HalSetVectorState ((pHalSetVectorState)PmHalDispatchTable->Function[HalSetVectorState])
  232. #define HalGetIOApicVersion ((pHalGetIOApicVersion)PmHalDispatchTable->Function[HalGetIOApicVersion])
  233. #define HalSetMaxLegacyPciBusNumber ((pHalSetMaxLegacyPciBusNumber)PmHalDispatchTable->Function[HalSetMaxLegacyPciBusNumber])
  234. #define HalIsVectorValid ((pHalIsVectorValid)PmHalDispatchTable->Function[HalIsVectorValid])
  235. extern PPM_DISPATCH_TABLE PmAcpiDispatchTable;
  236. extern PPM_DISPATCH_TABLE PmHalDispatchTable;
  237. //
  238. // ACPI driver's table
  239. //
  240. typedef enum {
  241. AcpiEnableDisableGPEvents,
  242. AcpiInitEnableAcpi,
  243. AcpiGpeEnableWakeEvents,
  244. AcpiMaxFunction
  245. } ACPI_DISPATCH_FUNCTION;
  246. typedef
  247. VOID
  248. (*pAcpiEnableDisableGPEvents) (
  249. IN BOOLEAN Enable
  250. );
  251. typedef
  252. VOID
  253. (*pAcpiInitEnableAcpi) (
  254. IN BOOLEAN ReEnable
  255. );
  256. typedef
  257. VOID
  258. (*pAcpiGpeEnableWakeEvents)(
  259. VOID
  260. );
  261. typedef struct {
  262. ULONG Signature;
  263. ULONG Version;
  264. pAcpiEnableDisableGPEvents AcpipEnableDisableGPEvents;
  265. pAcpiInitEnableAcpi AcpipInitEnableAcpi;
  266. pAcpiGpeEnableWakeEvents AcpipGpeEnableWakeEvents;
  267. } ACPI_HAL_DISPATCH_TABLE, *PACPI_HAL_DISPATCH_TABLE;
  268. #define ACPI_HAL_DISPATCH_SIGNATURE 'ACPI'
  269. #define ACPI_HAL_DISPATCH_VERSION 1
  270. #define AcpiEnableDisableGPEvents (*(pAcpiEnableDisableGPEvents)PmAcpiDispatchTable->Function[AcpiEnableDisableGPEvents])
  271. #define AcpiInitEnableAcpi (*(pAcpiInitEnableAcpi)PmAcpiDispatchTable->Function[AcpiInitEnableAcpi])
  272. #define AcpiGpeEnableWakeEvents (*(pAcpiGpeEnableWakeEvents)PmAcpiDispatchTable->Function[AcpiGpeEnableWakeEvents])
  273. // from detect\i386\acpibios.h
  274. typedef struct {
  275. PHYSICAL_ADDRESS Base;
  276. LARGE_INTEGER Length;
  277. ULONGLONG Type;
  278. } ACPI_E820_ENTRY, *PACPI_E820_ENTRY;
  279. typedef struct _ACPI_BIOS_MULTI_NODE {
  280. PHYSICAL_ADDRESS RsdtAddress; // 64-bit physical address of RSDT
  281. ULONGLONG Count;
  282. ACPI_E820_ENTRY E820Entry[1];
  283. } ACPI_BIOS_MULTI_NODE;
  284. typedef ACPI_BIOS_MULTI_NODE UNALIGNED *PACPI_BIOS_MULTI_NODE;
  285. typedef enum {
  286. AcpiAddressRangeMemory = 1,
  287. AcpiAddressRangeReserved,
  288. AcpiAddressRangeACPI,
  289. AcpiAddressRangeNVS,
  290. AcpiAddressRangeMaximum,
  291. } ACPI_BIOS_E820_TYPE, *PACPI_BIOS_E820_TYPE;
  292. NTSTATUS
  293. HalpAcpiFindRsdt (
  294. OUT PACPI_BIOS_MULTI_NODE *AcpiMulti
  295. );
  296. #endif //_ACPI_H_
  297. /*
  298. endif
  299. ;
  300. ; Begin assembly part of the definitions
  301. ;
  302. ;
  303. ; Register layout of ACPI processor register block
  304. ;
  305. P_CNT equ 0
  306. P_LVL2 equ 4
  307. P_LVL3 equ 5
  308. ;
  309. ; Register layout of PM1x_EVT register
  310. ;
  311. BM_STS equ 10h
  312. WAK_STS equ 8000h
  313. ;
  314. ; Register layout of PM1x_Enable
  315. ;
  316. TMR_EN equ 0001h
  317. GBL_EN equ 0020h
  318. PWRBTN_EN equ 0100h
  319. SLPBTN_EN equ 0200h
  320. RTC_EN equ 0400h
  321. ;
  322. ; Register layout of PM1x_CTL
  323. ;
  324. SCI_EN equ 1
  325. BM_RLD equ 2
  326. CTL_IGNORE equ 200h
  327. SLP_TYP_SHIFT equ 10
  328. SLP_EN equ 2000h
  329. CTL_PRESERVE equ (SCI_EN + BM_RLD + CTL_IGNORE)
  330. ;
  331. ; Register layout of PM2_CNT
  332. ;
  333. ARB_DIS equ 1
  334. ;
  335. ; ACPI registers, as laid out in HalpFixedAcpiDescTable
  336. ;
  337. PM1a_EVT EQU _HalpFixedAcpiDescTable + 56
  338. PM1b_EVT EQU _HalpFixedAcpiDescTable + 60
  339. PM1_EVT_LEN EQU _HalpFixedAcpiDescTable + 88
  340. PM1a_CNT EQU _HalpFixedAcpiDescTable + 64
  341. PM1b_CNT EQU _HalpFixedAcpiDescTable + 68
  342. PM2_CNT_BLK EQU _HalpFixedAcpiDescTable + 72
  343. PM_TMR_BLK EQU _HalpFixedAcpiDescTable + 76
  344. PM_TMR_FREQ EQU 3579545
  345. GPE0_BLK EQU _HalpFixedAcpiDescTable + 80
  346. GPE1_BLK EQU _HalpFixedAcpiDescTable + 84
  347. GPE0_BLK_LEN EQU _HalpFixedAcpiDescTable + 92
  348. GPE1_BLK_LEN EQU _HalpFixedAcpiDescTable + 93
  349. FLUSH_SIZE EQU _HalpFixedAcpiDescTable + 100
  350. FLUSH_STRIDE EQU _HalpFixedAcpiDescTable + 102
  351. DUTY_OFFSET EQU _HalpFixedAcpiDescTable + 104
  352. RTC_DAY_ALRM EQU _HalpFixedAcpiDescTable + 106
  353. RTC_MON_ALRM EQU _HalpFixedAcpiDescTable + 107
  354. RTC_CENTURY EQU _HalpFixedAcpiDescTable + 108
  355. FADT_FLAGS EQU _HalpFixedAcpiDescTable + 112
  356. ;
  357. ; FADT flag values
  358. ;
  359. WBINVD_SUPPORTED EQU 1
  360. WBINVD_FLUSH EQU 2
  361. ;
  362. GeneralWakeupEnable EQU 0
  363. RtcWakeupEnable EQU 1
  364. ;
  365. ; Constants used in the Context parameter to HaliAcpiSleep
  366. ; (must match C code above)
  367. ;
  368. SLEEP_STATE_FLUSH_CACHE EQU 1
  369. SLEEP_STATE_FIRMWARE_RESTART EQU 2
  370. SLEEP_STATE_SAVE_MOTHERBOARD EQU 4
  371. SLEEP_STATE_OFF EQU 8
  372. SLEEP_STATE_RESTART_OTHER_PROCESSORS EQU 10h
  373. CONTEXT_FLAG_SHIFT EQU 8
  374. ;*/