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.

204 lines
4.6 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. ULONG NextCpu;
  51. PVOID RegBaseVirtual;
  52. PHYSICAL_ADDRESS RegBasePhysical;
  53. PINTR_METHODS IntrMethods;
  54. PIO_INTR_CONTROL flink;
  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. HalpSetInternalVector (
  91. IN ULONG InternalVector,
  92. IN VOID (*HalInterruptSerivceRoutine)(VOID)
  93. );
  94. VOID
  95. HalpEnableRedirEntry(
  96. ULONG Inti
  97. );
  98. VOID
  99. HalpDisableRedirEntry(
  100. ULONG Inti
  101. );
  102. VOID
  103. HalpWriteRedirEntry (
  104. IN ULONG GlobalInterrupt,
  105. IN UCHAR SapicVector,
  106. IN USHORT DestinationCPU,
  107. IN ULONG Flags,
  108. IN ULONG InterruptType
  109. );
  110. BOOLEAN
  111. HalpIsActiveLow(
  112. ULONG Inti
  113. );
  114. BOOLEAN
  115. HalpIsLevelTriggered(
  116. ULONG Inti
  117. );
  118. VOID
  119. HalpSetPolarity(
  120. ULONG Inti,
  121. BOOLEAN ActiveLow
  122. );
  123. VOID
  124. HalpSetLevel(
  125. ULONG Inti,
  126. BOOLEAN LevelTriggered
  127. );
  128. //
  129. // I/O SAPIC defines
  130. //
  131. #define IO_REGISTER_SELECT 0x00000000
  132. #define IO_REGISTER_WINDOW 0x00000010
  133. #define IO_EOI_REGISTER 0x00000040
  134. #define IO_ID_REGISTER 0x00000000 // Exists, but ignored by SAPIC
  135. #define IO_VERS_REGISTER 0x00000001
  136. #define IO_REDIR_00_LOW 0x00000010
  137. #define IO_REDIR_00_HIGH 0x00000011
  138. #define IO_MAX_REDIR_MASK 0x00FF0000
  139. #define IO_VERSION_MASK 0x000000FF
  140. #define SAPIC_ID_MASK 0xFF000000
  141. #define SAPIC_ID_SHIFT 24
  142. #define SAPIC_EID_MASK 0x00FF0000
  143. #define SAPIC_EID_SHIFT 16
  144. #define SAPIC_XID_MASK 0xFFFF0000
  145. #define SAPIC_XID_SHIFT 16
  146. #define INT_VECTOR_MASK 0x000000FF
  147. #define DELIVER_FIXED 0x00000000
  148. #define DELIVER_LOW_PRIORITY 0x00000100
  149. #define DELIVER_SMI 0x00000200
  150. #define DELIVER_NMI 0x00000400
  151. #define DELIVER_INIT 0x00000500
  152. #define DELIVER_EXTINT 0x00000700
  153. #define INT_TYPE_MASK 0x00000700
  154. #define ACTIVE_LOW 0x00002000
  155. #define ACTIVE_HIGH 0x00000000
  156. #define LEVEL_TRIGGERED 0x00008000
  157. #define EDGE_TRIGGERED 0x00000000
  158. #define INTERRUPT_MASKED 0x00010000
  159. #define INTERRUPT_MOT_MASKED 0x00000000
  160. #define MAX_INTR_VECTOR 256