Legacy8259.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /** @file
  2. This protocol abstracts the 8259 interrupt controller. This includes
  3. PCI IRQ routing needed to program the PCI Interrupt Line register.
  4. Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. @par Revision Reference:
  7. This protocol is defined in Framework for EFI Compatibility Support Module spec
  8. Version 0.97.
  9. **/
  10. #ifndef _EFI_LEGACY_8259_H_
  11. #define _EFI_LEGACY_8259_H_
  12. #define EFI_LEGACY_8259_PROTOCOL_GUID \
  13. { \
  14. 0x38321dba, 0x4fe0, 0x4e17, {0x8a, 0xec, 0x41, 0x30, 0x55, 0xea, 0xed, 0xc1 } \
  15. }
  16. typedef struct _EFI_LEGACY_8259_PROTOCOL EFI_LEGACY_8259_PROTOCOL;
  17. typedef enum {
  18. Efi8259Irq0,
  19. Efi8259Irq1,
  20. Efi8259Irq2,
  21. Efi8259Irq3,
  22. Efi8259Irq4,
  23. Efi8259Irq5,
  24. Efi8259Irq6,
  25. Efi8259Irq7,
  26. Efi8259Irq8,
  27. Efi8259Irq9,
  28. Efi8259Irq10,
  29. Efi8259Irq11,
  30. Efi8259Irq12,
  31. Efi8259Irq13,
  32. Efi8259Irq14,
  33. Efi8259Irq15,
  34. Efi8259IrqMax
  35. } EFI_8259_IRQ;
  36. typedef enum {
  37. Efi8259LegacyMode,
  38. Efi8259ProtectedMode,
  39. Efi8259MaxMode
  40. } EFI_8259_MODE;
  41. /**
  42. Get the 8259 interrupt masks for Irq0 - Irq15. A different mask exists for
  43. the legacy mode mask and the protected mode mask. The base address for the 8259
  44. is different for legacy and protected mode, so two masks are required.
  45. @param This The protocol instance pointer.
  46. @param MasterBase The base vector for the Master PIC in the 8259 controller.
  47. @param SlaveBase The base vector for the Slave PIC in the 8259 controller.
  48. @retval EFI_SUCCESS The new bases were programmed.
  49. @retval EFI_DEVICE_ERROR A device error occured programming the vector bases.
  50. **/
  51. typedef
  52. EFI_STATUS
  53. (EFIAPI *EFI_LEGACY_8259_SET_VECTOR_BASE)(
  54. IN EFI_LEGACY_8259_PROTOCOL *This,
  55. IN UINT8 MasterBase,
  56. IN UINT8 SlaveBase
  57. );
  58. /**
  59. Get the 8259 interrupt masks for Irq0 - Irq15. A different mask exists for
  60. the legacy mode mask and the protected mode mask. The base address for the 8259
  61. is different for legacy and protected mode, so two masks are required.
  62. @param This The protocol instance pointer.
  63. @param LegacyMask Bit 0 is Irq0 - Bit 15 is Irq15.
  64. @param LegacyEdgeLevel Bit 0 is Irq0 - Bit 15 is Irq15.
  65. @param ProtectedMask Bit 0 is Irq0 - Bit 15 is Irq15.
  66. @param ProtectedEdgeLevel Bit 0 is Irq0 - Bit 15 is Irq15.
  67. @retval EFI_SUCCESS 8259 status returned.
  68. @retval EFI_DEVICE_ERROR Error reading 8259.
  69. **/
  70. typedef
  71. EFI_STATUS
  72. (EFIAPI *EFI_LEGACY_8259_GET_MASK)(
  73. IN EFI_LEGACY_8259_PROTOCOL *This,
  74. OUT UINT16 *LegacyMask, OPTIONAL
  75. OUT UINT16 *LegacyEdgeLevel, OPTIONAL
  76. OUT UINT16 *ProtectedMask, OPTIONAL
  77. OUT UINT16 *ProtectedEdgeLevel OPTIONAL
  78. );
  79. /**
  80. Set the 8259 interrupt masks for Irq0 - Irq15. A different mask exists for
  81. the legacy mode mask and the protected mode mask. The base address for the 8259
  82. is different for legacy and protected mode, so two masks are required.
  83. Also set the edge/level masks.
  84. @param This The protocol instance pointer.
  85. @param LegacyMask Bit 0 is Irq0 - Bit 15 is Irq15.
  86. @param LegacyEdgeLevel Bit 0 is Irq0 - Bit 15 is Irq15.
  87. @param ProtectedMask Bit 0 is Irq0 - Bit 15 is Irq15.
  88. @param ProtectedEdgeLevel Bit 0 is Irq0 - Bit 15 is Irq15.
  89. @retval EFI_SUCCESS 8259 status returned.
  90. @retval EFI_DEVICE_ERROR Error writing 8259.
  91. **/
  92. typedef
  93. EFI_STATUS
  94. (EFIAPI *EFI_LEGACY_8259_SET_MASK)(
  95. IN EFI_LEGACY_8259_PROTOCOL *This,
  96. IN UINT16 *LegacyMask, OPTIONAL
  97. IN UINT16 *LegacyEdgeLevel, OPTIONAL
  98. IN UINT16 *ProtectedMask, OPTIONAL
  99. IN UINT16 *ProtectedEdgeLevel OPTIONAL
  100. );
  101. /**
  102. Set the 8259 mode of operation. The base address for the 8259 is different for
  103. legacy and protected mode. The legacy mode requires the master 8259 to have a
  104. master base of 0x08 and the slave base of 0x70. The protected mode base locations
  105. are not defined. Interrupts must be masked by the caller before this function
  106. is called. The interrupt mask from the current mode is saved. The interrupt
  107. mask for the new mode is Mask, or if Mask does not exist the previously saved
  108. mask is used.
  109. @param This The protocol instance pointer.
  110. @param Mode The mode of operation. i.e. the real mode or protected mode.
  111. @param Mask Optional interupt mask for the new mode.
  112. @param EdgeLevel Optional trigger mask for the new mode.
  113. @retval EFI_SUCCESS 8259 programmed.
  114. @retval EFI_DEVICE_ERROR Error writing to 8259.
  115. **/
  116. typedef
  117. EFI_STATUS
  118. (EFIAPI *EFI_LEGACY_8259_SET_MODE)(
  119. IN EFI_LEGACY_8259_PROTOCOL *This,
  120. IN EFI_8259_MODE Mode,
  121. IN UINT16 *Mask, OPTIONAL
  122. IN UINT16 *EdgeLevel OPTIONAL
  123. );
  124. /**
  125. Convert from IRQ to processor interrupt vector number.
  126. @param This The protocol instance pointer.
  127. @param Irq 8259 IRQ0 - IRQ15.
  128. @param Vector The processor vector number that matches an Irq.
  129. @retval EFI_SUCCESS The Vector matching Irq is returned.
  130. @retval EFI_INVALID_PARAMETER The Irq not valid.
  131. **/
  132. typedef
  133. EFI_STATUS
  134. (EFIAPI *EFI_LEGACY_8259_GET_VECTOR)(
  135. IN EFI_LEGACY_8259_PROTOCOL *This,
  136. IN EFI_8259_IRQ Irq,
  137. OUT UINT8 *Vector
  138. );
  139. /**
  140. Enable Irq by unmasking interrupt in 8259
  141. @param This The protocol instance pointer.
  142. @param Irq 8259 IRQ0 - IRQ15.
  143. @param LevelTriggered TRUE if level triggered. FALSE if edge triggered.
  144. @retval EFI_SUCCESS The Irq was enabled on 8259.
  145. @retval EFI_INVALID_PARAMETER The Irq is not valid.
  146. **/
  147. typedef
  148. EFI_STATUS
  149. (EFIAPI *EFI_LEGACY_8259_ENABLE_IRQ)(
  150. IN EFI_LEGACY_8259_PROTOCOL *This,
  151. IN EFI_8259_IRQ Irq,
  152. IN BOOLEAN LevelTriggered
  153. );
  154. /**
  155. Disable Irq by masking interrupt in 8259
  156. @param This The protocol instance pointer.
  157. @param Irq 8259 IRQ0 - IRQ15.
  158. @retval EFI_SUCCESS The Irq was disabled on 8259.
  159. @retval EFI_INVALID_PARAMETER The Irq is not valid.
  160. **/
  161. typedef
  162. EFI_STATUS
  163. (EFIAPI *EFI_LEGACY_8259_DISABLE_IRQ)(
  164. IN EFI_LEGACY_8259_PROTOCOL *This,
  165. IN EFI_8259_IRQ Irq
  166. );
  167. /**
  168. PciHandle represents a PCI config space of a PCI function. Vector
  169. represents Interrupt Pin (from PCI config space) and it is the data
  170. that is programmed into the Interrupt Line (from the PCI config space)
  171. register.
  172. @param This The protocol instance pointer.
  173. @param PciHandle The PCI function to return the vector for.
  174. @param Vector The vector for the function it matches.
  175. @retval EFI_SUCCESS A valid Vector was returned.
  176. @retval EFI_INVALID_PARAMETER PciHandle not valid.
  177. **/
  178. typedef
  179. EFI_STATUS
  180. (EFIAPI *EFI_LEGACY_8259_GET_INTERRUPT_LINE)(
  181. IN EFI_LEGACY_8259_PROTOCOL *This,
  182. IN EFI_HANDLE PciHandle,
  183. OUT UINT8 *Vector
  184. );
  185. /**
  186. Send an EOI to 8259
  187. @param This The protocol instance pointer.
  188. @param Irq 8259 IRQ0 - IRQ15.
  189. @retval EFI_SUCCESS EOI was successfully sent to 8259.
  190. @retval EFI_INVALID_PARAMETER The Irq isnot valid.
  191. **/
  192. typedef
  193. EFI_STATUS
  194. (EFIAPI *EFI_LEGACY_8259_END_OF_INTERRUPT)(
  195. IN EFI_LEGACY_8259_PROTOCOL *This,
  196. IN EFI_8259_IRQ Irq
  197. );
  198. /**
  199. @par Protocol Description:
  200. Abstracts the 8259 and APIC hardware control between EFI usage and
  201. Compatibility16 usage.
  202. @param SetVectorBase
  203. Sets the vector bases for master and slave PICs.
  204. @param GetMask
  205. Gets IRQ and edge/level masks for 16-bit real mode and 32-bit protected mode.
  206. @param SetMask
  207. Sets the IRQ and edge\level masks for 16-bit real mode and 32-bit protected mode.
  208. @param SetMode
  209. Sets PIC mode to 16-bit real mode or 32-bit protected mode.
  210. @param GetVector
  211. Gets the base vector assigned to an IRQ.
  212. @param EnableIrq
  213. Enables an IRQ.
  214. @param DisableIrq
  215. Disables an IRQ.
  216. @param GetInterruptLine
  217. Gets an IRQ that is assigned to a PCI device.
  218. @param EndOfInterrupt
  219. Issues the end of interrupt command.
  220. **/
  221. struct _EFI_LEGACY_8259_PROTOCOL {
  222. EFI_LEGACY_8259_SET_VECTOR_BASE SetVectorBase;
  223. EFI_LEGACY_8259_GET_MASK GetMask;
  224. EFI_LEGACY_8259_SET_MASK SetMask;
  225. EFI_LEGACY_8259_SET_MODE SetMode;
  226. EFI_LEGACY_8259_GET_VECTOR GetVector;
  227. EFI_LEGACY_8259_ENABLE_IRQ EnableIrq;
  228. EFI_LEGACY_8259_DISABLE_IRQ DisableIrq;
  229. EFI_LEGACY_8259_GET_INTERRUPT_LINE GetInterruptLine;
  230. EFI_LEGACY_8259_END_OF_INTERRUPT EndOfInterrupt;
  231. };
  232. extern EFI_GUID gEfiLegacy8259ProtocolGuid;
  233. #endif