intr.c 3.1 KB

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