8259.h 6.9 KB

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