intr.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. intr.c
  5. Abstract:
  6. This module implements UEFI core interrupt support.
  7. Author:
  8. Evan Green 3-Mar-2014
  9. Environment:
  10. Firmware
  11. --*/
  12. //
  13. // ------------------------------------------------------------------- Includes
  14. //
  15. #include "ueficore.h"
  16. #include <minoca/kernel/hmod.h>
  17. #include <minoca/kernel/kdebug.h>
  18. //
  19. // ---------------------------------------------------------------- Definitions
  20. //
  21. //
  22. // ------------------------------------------------------ Data Type Definitions
  23. //
  24. //
  25. // ----------------------------------------------- Internal Function Prototypes
  26. //
  27. //
  28. // -------------------------------------------------------------------- Globals
  29. //
  30. EFI_PLATFORM_BEGIN_INTERRUPT EfiBeginInterruptFunction;
  31. EFI_PLATFORM_HANDLE_INTERRUPT EfiHandleInterruptFunction;
  32. EFI_PLATFORM_END_INTERRUPT EfiEndInterruptFunction;
  33. //
  34. // ------------------------------------------------------------------ Functions
  35. //
  36. EFI_STATUS
  37. EfiCoreInitializeInterruptServices (
  38. VOID
  39. )
  40. /*++
  41. Routine Description:
  42. This routine initializes core interrupt services.
  43. Arguments:
  44. None.
  45. Return Value:
  46. EFI status code.
  47. --*/
  48. {
  49. EFI_STATUS Status;
  50. Status = EfiPlatformInitializeInterrupts(&EfiBeginInterruptFunction,
  51. &EfiHandleInterruptFunction,
  52. &EfiEndInterruptFunction);
  53. if (EFI_ERROR(Status)) {
  54. goto CoreInitializeInterruptServicesEnd;
  55. }
  56. CoreInitializeInterruptServicesEnd:
  57. return Status;
  58. }
  59. VOID
  60. EfiCoreTerminateInterruptServices (
  61. VOID
  62. )
  63. /*++
  64. Routine Description:
  65. This routine terminates interrupt services in preparation for transitioning
  66. out of boot services.
  67. Arguments:
  68. None.
  69. Return Value:
  70. None.
  71. --*/
  72. {
  73. EfiPlatformTerminateInterrupts();
  74. return;
  75. }
  76. VOID
  77. EfiCoreDispatchInterrupt (
  78. VOID
  79. )
  80. /*++
  81. Routine Description:
  82. This routine is called to service an interrupt.
  83. Arguments:
  84. None.
  85. Return Value:
  86. None.
  87. --*/
  88. {
  89. VOID *InterruptContext;
  90. UINT32 InterruptNumber;
  91. EFI_TPL OldTpl;
  92. ASSERT(EfiAreInterruptsEnabled() == FALSE);
  93. ASSERT((EfiBeginInterruptFunction != NULL) &&
  94. (EfiEndInterruptFunction != NULL));
  95. OldTpl = EfiCoreRaiseTpl(TPL_HIGH_LEVEL);
  96. EfiBeginInterruptFunction(&InterruptNumber, &InterruptContext);
  97. if (EfiHandleInterruptFunction != NULL) {
  98. EfiHandleInterruptFunction(InterruptNumber, &InterruptContext);
  99. }
  100. if (InterruptNumber == EfiClockTimerInterruptNumber) {
  101. KdPollForBreakRequest();
  102. EfiCoreServiceClockInterrupt(InterruptNumber);
  103. }
  104. EfiEndInterruptFunction(InterruptNumber, InterruptContext);
  105. EfiCoreRestoreTpl(OldTpl);
  106. return;
  107. }
  108. //
  109. // --------------------------------------------------------- Internal Functions
  110. //