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.

210 lines
4.9 KiB

  1. /*++
  2. Module Name:
  3. iosapic.h
  4. Abstract:
  5. This module contains the definitions used by HAL to manipulate
  6. the IO SAPIC interrupt controller and SAPIC-specific constants.
  7. Author:
  8. Todd Kjos (v-tkjos) 1-30-98
  9. Environment:
  10. Kernel mode only.
  11. Revision History:
  12. --*/
  13. #define STATIC
  14. #include "halp.h"
  15. #include "acpitabl.h"
  16. //
  17. // MPS INTi Flags related macros:
  18. //
  19. // Warning: these definitions do not consider the POLARITY or EL comformity with bus.
  20. //
  21. #define IS_LEVEL_TRIGGERED_MPS(vectorFlags) \
  22. ((vectorFlags & EL_LEVEL_TRIGGERED) == EL_LEVEL_TRIGGERED)
  23. #define IS_EDGE_TRIGGERED_MPS(vectorFlags) \
  24. ((vectorFlags & EL_EDGE_TRIGGERED) == EL_EDGE_TRIGGERED)
  25. #define IS_ACTIVE_LOW_MPS(vectorFlags) \
  26. ((vectorFlags & POLARITY_LOW) == POLARITY_LOW)
  27. #define IS_ACTIVE_HIGH_MPS(vectorFlags) \
  28. ((vectorFlags & POLARITY_HIGH) == POLARITY_HIGH)
  29. typedef struct {
  30. ULONG GlobalVector; // This is Node+IDT vector value seen by kernel
  31. ULONG Vector; // Bits 31:0 of the Rte entry (IDT vector+polarity...)
  32. ULONG Destination; // Bits 63:32 of Rte entry
  33. } IOSAPICINTI, *PIOSAPICINTI;
  34. typedef struct _INTR_METHODS INTR_METHODS, *PINTR_METHODS;
  35. typedef struct _IO_INTR_CONTROL IO_INTR_CONTROL, *PIO_INTR_CONTROL;
  36. typedef VOID (*PINTRMETHOD) (PIO_INTR_CONTROL,ULONG);
  37. typedef volatile ULONG * (*PGETEOI) (PIO_INTR_CONTROL);
  38. struct _INTR_METHODS {
  39. PINTRMETHOD MaskEntry;
  40. PINTRMETHOD SetEntry;
  41. PINTRMETHOD EnableEntry;
  42. };
  43. //
  44. // External interrupt controller structure.
  45. //
  46. struct _IO_INTR_CONTROL {
  47. ULONG IntiBase;
  48. ULONG IntiMax;
  49. ULONG InterruptAffinity;
  50. PVOID RegBaseVirtual;
  51. PHYSICAL_ADDRESS RegBasePhysical;
  52. PINTR_METHODS IntrMethods;
  53. PIO_INTR_CONTROL flink;
  54. USHORT FreeVectors[16];
  55. IOSAPICINTI Inti[ANYSIZE_ARRAY];
  56. };
  57. extern struct _MPINFO HalpMpInfo;
  58. extern PIO_INTR_CONTROL HalpIoSapicList;
  59. extern INTR_METHODS HalpIoSapicMethods;
  60. //
  61. // IO Unit definition
  62. //
  63. typedef struct {
  64. volatile ULONG RegisterSelect; // Write register number to access register
  65. volatile ULONG Reserved1[3];
  66. volatile ULONG RegisterWindow; // Data read/written here
  67. volatile ULONG Reserved2[3];
  68. volatile ULONG Reserved3[8];
  69. volatile ULONG Eoi; // EOI register for level triggered interrupts
  70. } IO_SAPIC_REGS, *PIO_SAPIC_REGS;
  71. //
  72. // IO SAPIC Version Register
  73. //
  74. struct SapicVersion {
  75. UCHAR Version; // either 0.x or 1.x
  76. UCHAR Reserved1;
  77. UCHAR MaxRedirEntries; // Number of INTIs on unit
  78. UCHAR Reserved2;
  79. };
  80. typedef struct SapicVersion SAPIC_VERSION, *PSAPIC_VERSION;
  81. BOOLEAN
  82. HalpGetSapicInterruptDesc (
  83. IN INTERFACE_TYPE BusType,
  84. IN ULONG BusNumber,
  85. IN ULONG BusInterruptLevel,
  86. OUT PULONG SapicInti,
  87. OUT PKAFFINITY InterruptAffinity
  88. );
  89. VOID
  90. HalpGetFreeVectors(
  91. IN ULONG InterruptInput,
  92. OUT PUSHORT *FreeVectors
  93. );
  94. VOID
  95. HalpSetVectorAllocated(
  96. IN ULONG InterruptInput,
  97. IN UCHAR Vector
  98. );
  99. VOID
  100. HalpEnableRedirEntry(
  101. ULONG Inti
  102. );
  103. VOID
  104. HalpDisableRedirEntry(
  105. ULONG Inti
  106. );
  107. VOID
  108. HalpWriteRedirEntry (
  109. IN ULONG GlobalInterrupt,
  110. IN UCHAR SapicVector,
  111. IN USHORT DestinationCPU,
  112. IN ULONG Flags,
  113. IN ULONG InterruptType
  114. );
  115. BOOLEAN
  116. HalpIsActiveLow(
  117. ULONG Inti
  118. );
  119. BOOLEAN
  120. HalpIsLevelTriggered(
  121. ULONG Inti
  122. );
  123. VOID
  124. HalpSetPolarity(
  125. ULONG Inti,
  126. BOOLEAN ActiveLow
  127. );
  128. VOID
  129. HalpSetLevel(
  130. ULONG Inti,
  131. BOOLEAN LevelTriggered
  132. );
  133. //
  134. // I/O SAPIC defines
  135. //
  136. #define IO_REGISTER_SELECT 0x00000000
  137. #define IO_REGISTER_WINDOW 0x00000010
  138. #define IO_EOI_REGISTER 0x00000040
  139. #define IO_ID_REGISTER 0x00000000 // Exists, but ignored by SAPIC
  140. #define IO_VERS_REGISTER 0x00000001
  141. #define IO_REDIR_00_LOW 0x00000010
  142. #define IO_REDIR_00_HIGH 0x00000011
  143. #define IO_MAX_REDIR_MASK 0x00FF0000
  144. #define IO_VERSION_MASK 0x000000FF
  145. #define SAPIC_ID_MASK 0xFF000000
  146. #define SAPIC_ID_SHIFT 24
  147. #define SAPIC_EID_MASK 0x00FF0000
  148. #define SAPIC_EID_SHIFT 16
  149. #define SAPIC_XID_MASK 0xFFFF0000
  150. #define SAPIC_XID_SHIFT 16
  151. #define INT_VECTOR_MASK 0x000000FF
  152. #define DELIVER_FIXED 0x00000000
  153. #define DELIVER_LOW_PRIORITY 0x00000100
  154. #define DELIVER_SMI 0x00000200
  155. #define DELIVER_NMI 0x00000400
  156. #define DELIVER_INIT 0x00000500
  157. #define DELIVER_EXTINT 0x00000700
  158. #define INT_TYPE_MASK 0x00000700
  159. #define ACTIVE_LOW 0x00002000
  160. #define ACTIVE_HIGH 0x00000000
  161. #define LEVEL_TRIGGERED 0x00008000
  162. #define EDGE_TRIGGERED 0x00000000
  163. #define INTERRUPT_MASKED 0x00010000
  164. #define INTERRUPT_MOT_MASKED 0x00000000
  165. #define MAX_INTR_VECTOR 256