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.

326 lines
11 KiB

  1. ;/*
  2. ;++
  3. ;
  4. ; Copyright (c) 1992 Intel Corporation
  5. ; All rights reserved
  6. ;
  7. ; INTEL CORPORATION PROPRIETARY INFORMATION
  8. ;
  9. ; This software is supplied to Microsoft under the terms
  10. ; of a license agreement with Intel Corporation and may not be
  11. ; copied nor disclosed except in accordance with the terms
  12. ; of that agreement.
  13. ;
  14. ;
  15. ; Module Name:
  16. ;
  17. ; apic.inc
  18. ;
  19. ; Abstract:
  20. ;
  21. ; This module contains the definitions used by HAL to manipulate
  22. ; APIC interrupt controller and APIC-specific constants.
  23. ;
  24. ; WARNING: This file is included by both ASM and C files.
  25. ;
  26. ; Author:
  27. ;
  28. ; Hugh Bynum and Ron Mosgrove Aug-1992
  29. ;
  30. ;--
  31. if 0 ; Begin C only code */
  32. typedef volatile ULONG *PVULONG;
  33. //
  34. // APIC Version Register (both IO Unit and Local Units)
  35. //
  36. struct ApicVersion {
  37. UCHAR Version; // either 0.x or 1.x
  38. UCHAR Reserved1;
  39. UCHAR MaxRedirEntries; // Number of INTIs on unit
  40. UCHAR Reserved2;
  41. };
  42. typedef struct ApicVersion APIC_VERSION, *PAPIC_VERSION;
  43. //
  44. // IO Unit definition
  45. //
  46. struct ApicIoUnit {
  47. volatile ULONG RegisterSelect; // Write register number to access register
  48. volatile ULONG Reserved1[3];
  49. volatile ULONG RegisterWindow; // Data read/written here
  50. };
  51. typedef struct ApicIoUnit IO_APIC_UNIT, *PIO_APIC_UNIT;
  52. //
  53. // APIC defines for C code
  54. // BE SURE TO CHANGE THESE VALUES IN BOTH TABLES!
  55. //
  56. //
  57. // Default Physical addresses of the APICs in a PC+MP system
  58. //
  59. #define IO_BASE_ADDRESS 0xFEC00000 // Default address of
  60. // 1st IO Apic
  61. #define LU_BASE_ADDRESS 0xFEE00000 // Default address
  62. // of Local Apic
  63. #define IO_REGISTER_SELECT 0x00000000 //
  64. #define IO_REGISTER_WINDOW 0x00000010 //
  65. #define IO_ID_REGISTER 0x00000000
  66. #define IO_VERS_REGISTER 0x00000001
  67. #define IO_ARB_ID_REGISTER 0x00000002
  68. #define IO_REDIR_00_LOW 0x00000010
  69. #define IO_REDIR_00_HIGH 0x00000011
  70. #define IO_MAX_REDIR_MASK 0x00FF0000
  71. #define IO_VERSION_MASK 0x000000FF
  72. #define LU_ID_REGISTER 0x00000020 //
  73. #define LU_VERS_REGISTER 0x00000030 //
  74. #define LU_TPR 0x00000080 //
  75. #define LU_APR 0x00000090 //
  76. #define LU_PPR 0x000000A0 //
  77. #define LU_EOI 0x000000B0 //
  78. #define LU_REMOTE_REGISTER 0x000000C0 //
  79. #define LU_LOGICAL_DEST 0x000000D0 //
  80. #define LU_LOGICAL_DEST_MASK 0xFF000000
  81. #define LU_DEST_FORMAT 0x000000E0 //
  82. #define LU_DEST_FORMAT_MASK 0xF0000000
  83. #define LU_DEST_FORMAT_FLAT 0xFFFFFFFF
  84. #define LU_DEST_FORMAT_CLUSTER 0x0FFFFFFF
  85. #define LU_SPURIOUS_VECTOR 0x000000F0 //
  86. #define LU_FAULT_VECTOR 0x00000370 //
  87. #define LU_UNIT_ENABLED 0x00000100
  88. #define LU_UNIT_DISABLED 0x00000000
  89. #define LU_ISR_0 0x00000100 //
  90. #define LU_TMR_0 0x00000180 //
  91. #define LU_IRR_0 0x00000200 //
  92. #define LU_ERROR_STATUS 0x00000280 //
  93. #define LU_INT_CMD_LOW 0x00000300 //
  94. #define LU_INT_CMD_HIGH 0x00000310 //
  95. #define LU_TIMER_VECTOR 0x00000320 //
  96. #define LU_PERF_VECTOR 0x00000340
  97. #define LU_INT_VECTOR_0 0x00000350 // TEMPORARY - do not use
  98. #define LU_INT_VECTOR_1 0x00000360 // TEMPORARY - do not use
  99. #define LU_INITIAL_COUNT 0x00000380 //
  100. #define LU_CURRENT_COUNT 0x00000390 //
  101. #define LU_DIVIDER_CONFIG 0x000003E0 //
  102. #define LU_DIVIDE_BY_1 0x0000000B //
  103. #define APIC_ID_MASK 0xFF000000
  104. #define APIC_ID_SHIFT 24
  105. #define INT_VECTOR_MASK 0x000000FF
  106. #define RESERVED_HIGH_INT 0x000000F8
  107. #define DELIVERY_MODE_MASK 0x00000700
  108. #define DELIVER_FIXED 0x00000000
  109. #define DELIVER_LOW_PRIORITY 0x00000100
  110. #define DELIVER_SMI 0x00000200
  111. #define DELIVER_REMOTE_READ 0x00000300
  112. #define DELIVER_NMI 0x00000400
  113. #define DELIVER_INIT 0x00000500
  114. #define DELIVER_STARTUP 0x00000600
  115. #define DELIVER_EXTINT 0x00000700
  116. #define PHYSICAL_DESTINATION 0x00000000
  117. #define LOGICAL_DESTINATION 0x00000800
  118. #define DELIVERY_PENDING 0x00001000
  119. #define ACTIVE_LOW 0x00002000
  120. #define ACTIVE_HIGH 0x00000000
  121. #define REMOTE_IRR 0x00004000
  122. #define LEVEL_TRIGGERED 0x00008000
  123. #define EDGE_TRIGGERED 0x00000000
  124. #define INTERRUPT_MASKED 0x00010000
  125. #define INTERRUPT_MOT_MASKED 0x00000000
  126. #define PERIODIC_TIMER 0x00020000
  127. #define ICR_LEVEL_ASSERTED 0x00004000
  128. #define ICR_LEVEL_DEASSERTED 0x00000000
  129. #define ICR_RR_STATUS_MASK 0x00030000
  130. #define ICR_RR_INVALID 0x00000000
  131. #define ICR_RR_IN_PROGRESS 0x00010000
  132. #define ICR_RR_VALID 0x00020000
  133. #define ICR_SHORTHAND_MASK 0x000C0000
  134. #define ICR_USE_DEST_FIELD 0x00000000
  135. #define ICR_SELF 0x00040000
  136. #define ICR_ALL_INCL_SELF 0x00080000
  137. #define ICR_ALL_EXCL_SELF 0x000C0000
  138. //
  139. // Special ICR request to reset a remote processor
  140. //
  141. #define LU_RESET_ASSERT ( DELIVER_INIT | LEVEL_TRIGGERED | ICR_LEVEL_ASSERTED | \
  142. ICR_USE_DEST_FIELD | PHYSICAL_DESTINATION)
  143. #define LU_RESET_DEASSERT ( DELIVER_INIT | LEVEL_TRIGGERED | ICR_LEVEL_DEASSERTED | \
  144. ICR_USE_DEST_FIELD | PHYSICAL_DESTINATION)
  145. //
  146. // Special ICR request to reset a remote processor
  147. //
  148. #define LU_INIT_DEASSERT (DELIVER_INIT | LEVEL_TRIGGERED | \
  149. ICR_ALL_INCL_SELF | ICR_LEVEL_DEASSERTED )
  150. //
  151. // Startup ICR Requset - OR in the VV value needed
  152. //
  153. #define LU_STARTUP_IPI ( DELIVER_STARTUP | ICR_USE_DEST_FIELD | \
  154. PHYSICAL_DESTINATION)
  155. #define DESTINATION_MASK 0xFF000000
  156. #define DESTINATION_SHIFT 24
  157. //
  158. // APIC IO unit redirection table, interrupt destination field: this field
  159. // is 32 bits for the 82489DX APIC; future APIC implementations will put the
  160. // destination field in the upper 8 bits of the entry, not the full 32 bits
  161. //
  162. #define DESTINATION_CPU_0 (ULONG) (1 << DESTINATION_SHIFT)
  163. #define DESTINATION_ALL_CPUS (ULONG) (0xff << DESTINATION_SHIFT)
  164. //
  165. // Io Apic Entry definitions
  166. //
  167. // Interrupt Types Possible in the PC+MP Table
  168. // valid for both local and Io Apics
  169. //
  170. #define INT_TYPE_INTR 0x0
  171. #define INT_TYPE_NMI 0x1
  172. #define INT_TYPE_SMI 0x2
  173. #define INT_TYPE_EXTINT 0x3
  174. /*
  175. endif
  176. ; APIC defines for assembly code
  177. ; BE SURE TO CHANGE THESE VALUES IN BOTH TABLES!
  178. ;
  179. ;
  180. ; Default Physical addresses of the APICs in a PC+MP system
  181. ;
  182. IO_BASE_ADDRESS equ 0FEC00000H ; Default address of
  183. ; 1st IO Apic
  184. LU_BASE_ADDRESS equ 0FEE00000H ; Default address
  185. ; of Local Apic
  186. IO_REGISTER_SELECT equ 00000000H ;
  187. IO_REGISTER_WINDOW equ 00000010H ;
  188. IO_ID_REGISTER equ 00000000H ;
  189. IO_VERS_REGISTER equ 00000001H ;
  190. IO_ARB_ID_REGISTER equ 00000002H ;
  191. IO_REDIR_00_LOW equ 00000010H ;
  192. IO_REDIR_00_HIGH equ 00000011H ;
  193. IO_MAX_REDIR_MASK equ 00FF0000H ;
  194. IO_VERSION_MASK equ 000000FFH ;
  195. LU_ID_REGISTER equ 00000020H ;
  196. LU_VERS_REGISTER equ 00000030H ;
  197. LU_TPR equ 00000080H ;
  198. LU_APR equ 00000090H ;
  199. LU_PPR equ 000000A0H ;
  200. LU_EOI equ 000000B0H ;
  201. LU_REMOTE_REGISTER equ 000000C0H ;
  202. LU_LOGICAL_DEST equ 000000D0H ;
  203. LU_LOGICAL_DEST_MASK equ 0FF000000H ;
  204. LU_DEST_FORMAT equ 000000E0H ;
  205. LU_DEST_FORMAT_MASK equ 0F0000000H ;
  206. LU_DEST_FORMAT_FLAT equ 0FFFFFFFFH ;
  207. LU_DEST_FORMAT_CLUSTER equ 0FFFFFFFH
  208. LU_SPURIOUS_VECTOR equ 000000F0H ;
  209. LU_FAULT_VECTOR equ 00000370H ;
  210. LU_UNIT_ENABLED equ 00000100H ;
  211. LU_UNIT_DISABLED equ 00000000H ;
  212. LU_ISR_0 equ 00000100H ;
  213. LU_TMR_0 equ 00000180H ;
  214. LU_IRR_0 equ 00000200H ;
  215. LU_ERROR_STATUS equ 00000280H ;
  216. LU_INT_CMD_LOW equ 00000300H ;
  217. LU_INT_CMD_HIGH equ 00000310H ;
  218. LU_TIMER_VECTOR equ 00000320H ;
  219. LU_PERF_VECTOR equ 00000340H ;
  220. LU_INT_VECTOR_0 equ 00000350H ; TEMPORARY - do not use
  221. LU_INT_VECTOR_1 equ 00000360H ; TEMPORARY - do not use
  222. LU_INITIAL_COUNT equ 00000380H ;
  223. LU_CURRENT_COUNT equ 00000390H ;
  224. LU_DIVIDER_CONFIG equ 000003E0H ;
  225. LU_DIVIDE_BY_1 equ 0000000BH ;
  226. LU_DIVIDE_BY_2 equ 00000000H ;
  227. LU_DIVIDE_BY_4 equ 00000001H ;
  228. LU_DIVIDE_BY_8 equ 00000002H ;
  229. LU_DIVIDE_BY_16 equ 00000003H ;
  230. LU_DIVIDE_BY_32 equ 00000008H ;
  231. LU_DIVIDE_BY_64 equ 00000009H ;
  232. LU_DIVIDE_BY_128 equ 0000000AH ;
  233. APIC_ID_MASK equ 0FF000000H ;
  234. APIC_ID_SHIFT equ 24 ;
  235. INT_VECTOR_MASK equ 000000FFH ;
  236. RESERVED_HIGH_INT equ 000000F8H ;
  237. DELIVERY_MODE_MASK equ 00000700H ;
  238. DELIVER_FIXED equ 00000000H ;
  239. DELIVER_LOW_PRIORITY equ 00000100H ;
  240. DELIVER_SMI equ 00000200H ;
  241. DELIVER_REMOTE_READ equ 00000300H ;
  242. DELIVER_NMI equ 00000400H ;
  243. DELIVER_INIT equ 00000500H ;
  244. DELIVER_STARTUP equ 00000600H ;
  245. DELIVER_EXTINT equ 00000700H ;
  246. PHYSICAL_DESTINATION equ 00000000H ;
  247. LOGICAL_DESTINATION equ 00000800H ;
  248. DELIVERY_PENDING equ 00001000H ;
  249. ACTIVE_LOW equ 00002000H ;
  250. ACTIVE_HIGH equ 00000000H ;
  251. REMOTE_IRR equ 00004000H ;
  252. LEVEL_TRIGGERED equ 00008000H ;
  253. EDGE_TRIGGERED equ 00000000H ;
  254. INTERRUPT_MASKED equ 00010000H ;
  255. INTERRUPT_MOT_MASKED equ 00000000H ;
  256. PERIODIC_TIMER equ 00020000H ;
  257. ICR_LEVEL_ASSERTED equ 00004000H ;
  258. ICR_LEVEL_DEASSERTED equ 00000000H ;
  259. ICR_RR_STATUS_MASK equ 00030000H ;
  260. ICR_RR_INVALID equ 00000000H ;
  261. ICR_RR_IN_PROGRESS equ 00010000H ;
  262. ICR_RR_VALID equ 00020000H ;
  263. ICR_SHORTHAND_MASK equ 000C0000H ;
  264. ICR_USE_DEST_FIELD equ 00000000H ;
  265. ICR_SELF equ 00040000H ;
  266. ICR_ALL_INCL_SELF equ 00080000H ;
  267. ICR_ALL_EXCL_SELF equ 000C0000H ;
  268. DESTINATION_MASK equ 0FF000000H ;
  269. DESTINATION_SHIFT equ 24 ; shift count for dest. mask
  270. ;
  271. ; APIC IO unit redirection table, interrupt destination field: this field
  272. ; is 32 bits for the 82489DX APIC; future APIC implementations will put the
  273. ; destination field in the upper 8 bits of the entry, not the full 32 bits
  274. ;
  275. DESTINATION_CPU_0 equ 1 SHL DESTINATION_SHIFT
  276. DESTINATION_ALL_CPUS equ 0FFH SHL DESTINATION_SHIFT
  277. ;
  278. ; Interrupt Types Possible in the PC+MP Table
  279. ;
  280. INT_TYPE_INTR equ 0H
  281. INT_TYPE_NMI equ 01H
  282. INT_TYPE_SMI equ 02H
  283. INT_TYPE_EXTINT equ 03H
  284. ;*/