intr.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. /*++
  2. Copyright (c) 2015 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. intr.c
  5. Abstract:
  6. This module implements platform interrupt support for the RK3288 Veyron.
  7. Author:
  8. Evan Green 10-Jul-2015
  9. Environment:
  10. Firmware
  11. --*/
  12. //
  13. // ------------------------------------------------------------------- Includes
  14. //
  15. #include <uefifw.h>
  16. #include "dev/gic.h"
  17. #include "veyronfw.h"
  18. //
  19. // ---------------------------------------------------------------- Definitions
  20. //
  21. //
  22. // ------------------------------------------------------ Data Type Definitions
  23. //
  24. //
  25. // ----------------------------------------------- Internal Function Prototypes
  26. //
  27. VOID
  28. EfipPlatformBeginInterrupt (
  29. UINT32 *InterruptNumber,
  30. VOID **InterruptContext
  31. );
  32. VOID
  33. EfipPlatformEndInterrupt (
  34. UINT32 InterruptNumber,
  35. VOID *InterruptContext
  36. );
  37. //
  38. // -------------------------------------------------------------------- Globals
  39. //
  40. GIC_CONTEXT EfiVeyronGic;
  41. //
  42. // ------------------------------------------------------------------ Functions
  43. //
  44. EFI_STATUS
  45. EfiPlatformInitializeInterrupts (
  46. EFI_PLATFORM_BEGIN_INTERRUPT *BeginInterruptFunction,
  47. EFI_PLATFORM_HANDLE_INTERRUPT *HandleInterruptFunction,
  48. EFI_PLATFORM_END_INTERRUPT *EndInterruptFunction
  49. )
  50. /*++
  51. Routine Description:
  52. This routine initializes support for platform interrupts. Interrupts are
  53. assumed to be disabled at the processor now. This routine should enable
  54. interrupts at the procesor core.
  55. Arguments:
  56. BeginInterruptFunction - Supplies a pointer where a pointer to a function
  57. will be returned that is called when an interrupt occurs.
  58. HandleInterruptFunction - Supplies a pointer where a pointer to a function
  59. will be returned that is called to handle a platform-specific interurpt.
  60. NULL may be returned here.
  61. EndInterruptFunction - Supplies a pointer where a pointer to a function
  62. will be returned that is called to complete an interrupt.
  63. Return Value:
  64. EFI Status code.
  65. --*/
  66. {
  67. EFI_STATUS Status;
  68. EfiVeyronGic.DistributorBase = (VOID *)RK32_GIC_DISTRIBUTOR_BASE;
  69. EfiVeyronGic.CpuInterfaceBase = (VOID *)RK32_GIC_CPU_INTERFACE_BASE;
  70. Status = EfipGicInitialize(&EfiVeyronGic);
  71. if (EFI_ERROR(Status)) {
  72. return Status;
  73. }
  74. *BeginInterruptFunction = EfipPlatformBeginInterrupt;
  75. *HandleInterruptFunction = NULL;
  76. *EndInterruptFunction = EfipPlatformEndInterrupt;
  77. EfiEnableInterrupts();
  78. return EFI_SUCCESS;
  79. }
  80. VOID
  81. EfiPlatformTerminateInterrupts (
  82. VOID
  83. )
  84. /*++
  85. Routine Description:
  86. This routine terminates interrupt services in preparation for transitioning
  87. out of boot services.
  88. Arguments:
  89. None.
  90. Return Value:
  91. None.
  92. --*/
  93. {
  94. return;
  95. }
  96. EFI_STATUS
  97. EfipPlatformSetInterruptLineState (
  98. UINT32 LineNumber,
  99. BOOLEAN Enabled,
  100. BOOLEAN EdgeTriggered
  101. )
  102. /*++
  103. Routine Description:
  104. This routine enables or disables an interrupt line.
  105. Arguments:
  106. LineNumber - Supplies the line number to enable or disable.
  107. Enabled - Supplies a boolean indicating if the line should be enabled or
  108. disabled.
  109. EdgeTriggered - Supplies a boolean indicating if the interrupt is edge
  110. triggered (TRUE) or level triggered (FALSE).
  111. Return Value:
  112. EFI Status code.
  113. --*/
  114. {
  115. EFI_STATUS Status;
  116. Status = EfipGicSetLineState(&EfiVeyronGic,
  117. LineNumber,
  118. Enabled,
  119. EdgeTriggered);
  120. return Status;
  121. }
  122. //
  123. // --------------------------------------------------------- Internal Functions
  124. //
  125. VOID
  126. EfipPlatformBeginInterrupt (
  127. UINT32 *InterruptNumber,
  128. VOID **InterruptContext
  129. )
  130. /*++
  131. Routine Description:
  132. This routine is called when an interrupts comes in. The platform code is
  133. responsible for reporting the interrupt number. Interrupts are disabled at
  134. the processor core at this point.
  135. Arguments:
  136. InterruptNumber - Supplies a pointer where interrupt line number will be
  137. returned.
  138. InterruptContext - Supplies a pointer where the platform can store a
  139. pointer's worth of context that will be passed back when ending the
  140. interrupt.
  141. Return Value:
  142. None.
  143. --*/
  144. {
  145. EfipGicBeginInterrupt(&EfiVeyronGic, InterruptNumber, InterruptContext);
  146. return;
  147. }
  148. VOID
  149. EfipPlatformEndInterrupt (
  150. UINT32 InterruptNumber,
  151. VOID *InterruptContext
  152. )
  153. /*++
  154. Routine Description:
  155. This routine is called to finish handling of a platform interrupt. This is
  156. where the End-Of-Interrupt would get sent to the interrupt controller.
  157. Arguments:
  158. InterruptNumber - Supplies the interrupt number that occurred.
  159. InterruptContext - Supplies the context returned by the interrupt
  160. controller when the interrupt began.
  161. Return Value:
  162. None.
  163. --*/
  164. {
  165. EfipGicEndInterrupt(&EfiVeyronGic, InterruptNumber, InterruptContext);
  166. return;
  167. }