8259.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /** @file
  2. Driver implementing the Tiano Legacy 8259 Protocol
  3. Copyright (c) 2005 - 2019, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _8259_H__
  7. #define _8259_H__
  8. #include <Protocol/Legacy8259.h>
  9. #include <Protocol/PciIo.h>
  10. #include <Library/UefiBootServicesTableLib.h>
  11. #include <Library/DebugLib.h>
  12. #include <Library/IoLib.h>
  13. #include <Library/BaseLib.h>
  14. #include <Library/PcdLib.h>
  15. #include <IndustryStandard/Pci.h>
  16. // 8259 Hardware definitions
  17. #define LEGACY_MODE_BASE_VECTOR_MASTER 0x08
  18. #define LEGACY_MODE_BASE_VECTOR_SLAVE 0x70
  19. #define PROTECTED_MODE_BASE_VECTOR_MASTER 0x68
  20. #define PROTECTED_MODE_BASE_VECTOR_SLAVE 0x70
  21. #define LEGACY_8259_CONTROL_REGISTER_MASTER 0x20
  22. #define LEGACY_8259_MASK_REGISTER_MASTER 0x21
  23. #define LEGACY_8259_CONTROL_REGISTER_SLAVE 0xA0
  24. #define LEGACY_8259_MASK_REGISTER_SLAVE 0xA1
  25. #define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER 0x4D0
  26. #define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE 0x4D1
  27. #define LEGACY_8259_EOI 0x20
  28. // Protocol Function Prototypes
  29. /**
  30. Sets the base address for the 8259 master and slave PICs.
  31. @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.
  32. @param[in] MasterBase Interrupt vectors for IRQ0-IRQ7.
  33. @param[in] SlaveBase Interrupt vectors for IRQ8-IRQ15.
  34. @retval EFI_SUCCESS The 8259 PIC was programmed successfully.
  35. @retval EFI_DEVICE_ERROR There was an error while writing to the 8259 PIC.
  36. **/
  37. EFI_STATUS
  38. EFIAPI
  39. Interrupt8259SetVectorBase (
  40. IN EFI_LEGACY_8259_PROTOCOL *This,
  41. IN UINT8 MasterBase,
  42. IN UINT8 SlaveBase
  43. );
  44. /**
  45. Gets the current 16-bit real mode and 32-bit protected-mode IRQ masks.
  46. @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.
  47. @param[out] LegacyMask 16-bit mode interrupt mask for IRQ0-IRQ15.
  48. @param[out] LegacyEdgeLevel 16-bit mode edge/level mask for IRQ-IRQ15.
  49. @param[out] ProtectedMask 32-bit mode interrupt mask for IRQ0-IRQ15.
  50. @param[out] ProtectedEdgeLevel 32-bit mode edge/level mask for IRQ0-IRQ15.
  51. @retval EFI_SUCCESS The 8259 PIC was programmed successfully.
  52. @retval EFI_DEVICE_ERROR There was an error while reading the 8259 PIC.
  53. **/
  54. EFI_STATUS
  55. EFIAPI
  56. Interrupt8259GetMask (
  57. IN EFI_LEGACY_8259_PROTOCOL *This,
  58. OUT UINT16 *LegacyMask OPTIONAL,
  59. OUT UINT16 *LegacyEdgeLevel OPTIONAL,
  60. OUT UINT16 *ProtectedMask OPTIONAL,
  61. OUT UINT16 *ProtectedEdgeLevel OPTIONAL
  62. );
  63. /**
  64. Sets the current 16-bit real mode and 32-bit protected-mode IRQ masks.
  65. @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.
  66. @param[in] LegacyMask 16-bit mode interrupt mask for IRQ0-IRQ15.
  67. @param[in] LegacyEdgeLevel 16-bit mode edge/level mask for IRQ-IRQ15.
  68. @param[in] ProtectedMask 32-bit mode interrupt mask for IRQ0-IRQ15.
  69. @param[in] ProtectedEdgeLevel 32-bit mode edge/level mask for IRQ0-IRQ15.
  70. @retval EFI_SUCCESS The 8259 PIC was programmed successfully.
  71. @retval EFI_DEVICE_ERROR There was an error while writing the 8259 PIC.
  72. **/
  73. EFI_STATUS
  74. EFIAPI
  75. Interrupt8259SetMask (
  76. IN EFI_LEGACY_8259_PROTOCOL *This,
  77. IN UINT16 *LegacyMask OPTIONAL,
  78. IN UINT16 *LegacyEdgeLevel OPTIONAL,
  79. IN UINT16 *ProtectedMask OPTIONAL,
  80. IN UINT16 *ProtectedEdgeLevel OPTIONAL
  81. );
  82. /**
  83. Sets the mode of the PICs.
  84. @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.
  85. @param[in] Mode 16-bit real or 32-bit protected mode.
  86. @param[in] Mask The value with which to set the interrupt mask.
  87. @param[in] EdgeLevel The value with which to set the edge/level mask.
  88. @retval EFI_SUCCESS The mode was set successfully.
  89. @retval EFI_INVALID_PARAMETER The mode was not set.
  90. **/
  91. EFI_STATUS
  92. EFIAPI
  93. Interrupt8259SetMode (
  94. IN EFI_LEGACY_8259_PROTOCOL *This,
  95. IN EFI_8259_MODE Mode,
  96. IN UINT16 *Mask OPTIONAL,
  97. IN UINT16 *EdgeLevel OPTIONAL
  98. );
  99. /**
  100. Translates the IRQ into a vector.
  101. @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.
  102. @param[in] Irq IRQ0-IRQ15.
  103. @param[out] Vector The vector that is assigned to the IRQ.
  104. @retval EFI_SUCCESS The Vector that matches Irq was returned.
  105. @retval EFI_INVALID_PARAMETER Irq is not valid.
  106. **/
  107. EFI_STATUS
  108. EFIAPI
  109. Interrupt8259GetVector (
  110. IN EFI_LEGACY_8259_PROTOCOL *This,
  111. IN EFI_8259_IRQ Irq,
  112. OUT UINT8 *Vector
  113. );
  114. /**
  115. Enables the specified IRQ.
  116. @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.
  117. @param[in] Irq IRQ0-IRQ15.
  118. @param[in] LevelTriggered 0 = Edge triggered; 1 = Level triggered.
  119. @retval EFI_SUCCESS The Irq was enabled on the 8259 PIC.
  120. @retval EFI_INVALID_PARAMETER The Irq is not valid.
  121. **/
  122. EFI_STATUS
  123. EFIAPI
  124. Interrupt8259EnableIrq (
  125. IN EFI_LEGACY_8259_PROTOCOL *This,
  126. IN EFI_8259_IRQ Irq,
  127. IN BOOLEAN LevelTriggered
  128. );
  129. /**
  130. Disables the specified IRQ.
  131. @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.
  132. @param[in] Irq IRQ0-IRQ15.
  133. @retval EFI_SUCCESS The Irq was disabled on the 8259 PIC.
  134. @retval EFI_INVALID_PARAMETER The Irq is not valid.
  135. **/
  136. EFI_STATUS
  137. EFIAPI
  138. Interrupt8259DisableIrq (
  139. IN EFI_LEGACY_8259_PROTOCOL *This,
  140. IN EFI_8259_IRQ Irq
  141. );
  142. /**
  143. Reads the PCI configuration space to get the interrupt number that is assigned to the card.
  144. @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.
  145. @param[in] PciHandle PCI function for which to return the vector.
  146. @param[out] Vector IRQ number that corresponds to the interrupt line.
  147. @retval EFI_SUCCESS The interrupt line value was read successfully.
  148. **/
  149. EFI_STATUS
  150. EFIAPI
  151. Interrupt8259GetInterruptLine (
  152. IN EFI_LEGACY_8259_PROTOCOL *This,
  153. IN EFI_HANDLE PciHandle,
  154. OUT UINT8 *Vector
  155. );
  156. /**
  157. Issues the End of Interrupt (EOI) commands to PICs.
  158. @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.
  159. @param[in] Irq The interrupt for which to issue the EOI command.
  160. @retval EFI_SUCCESS The EOI command was issued.
  161. @retval EFI_INVALID_PARAMETER The Irq is not valid.
  162. **/
  163. EFI_STATUS
  164. EFIAPI
  165. Interrupt8259EndOfInterrupt (
  166. IN EFI_LEGACY_8259_PROTOCOL *This,
  167. IN EFI_8259_IRQ Irq
  168. );
  169. #endif