]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Omap35xxPkg/InterruptDxe/HardwareInterrupt.c
ArmPkg/CompilerIntrinsicsLib: Add uread, uwrite GCC assembly sources
[mirror_edk2.git] / Omap35xxPkg / InterruptDxe / HardwareInterrupt.c
index 09e22b5921b0fd10c40dea6e91173c605890ee75..d15e68edfc0a2339d8d6d50335c57a96f86e71a9 100644 (file)
@@ -3,13 +3,7 @@
 \r
   Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
 \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 #include <PiDxe.h>\r
@@ -296,6 +290,54 @@ EFI_HARDWARE_INTERRUPT_PROTOCOL gHardwareInterruptProtocol = {
   EndOfInterrupt\r
 };\r
 \r
+STATIC VOID *mCpuArchProtocolNotifyEventRegistration;\r
+\r
+STATIC\r
+VOID\r
+EFIAPI\r
+CpuArchEventProtocolNotify (\r
+  IN  EFI_EVENT       Event,\r
+  IN  VOID            *Context\r
+  )\r
+{\r
+  EFI_CPU_ARCH_PROTOCOL   *Cpu;\r
+  EFI_STATUS              Status;\r
+\r
+  //\r
+  // Get the CPU protocol that this driver requires.\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&Cpu);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_ERROR, "%a: gBS->LocateProtocol() - %r\n", __FUNCTION__,\r
+      Status));\r
+    ASSERT (FALSE);\r
+    return;\r
+  }\r
+\r
+  //\r
+  // Unregister the default exception handler.\r
+  //\r
+  Status = Cpu->RegisterInterruptHandler (Cpu, EXCEPT_ARM_IRQ, NULL);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_ERROR, "%a: Cpu->RegisterInterruptHandler() - %r\n",\r
+      __FUNCTION__, Status));\r
+    ASSERT (FALSE);\r
+    return;\r
+  }\r
+\r
+  //\r
+  // Register to receive interrupts\r
+  //\r
+  Status = Cpu->RegisterInterruptHandler (Cpu, EXCEPT_ARM_IRQ,\r
+                  IrqInterruptHandler);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_ERROR, "%a: Cpu->RegisterInterruptHandler() - %r\n",\r
+      __FUNCTION__, Status));\r
+    ASSERT (FALSE);\r
+    return;\r
+  }\r
+}\r
+\r
 /**\r
   Initialize the state information for the CPU Architectural Protocol\r
 \r
@@ -314,7 +356,7 @@ InterruptDxeInitialize (
   )\r
 {\r
   EFI_STATUS  Status;\r
-  EFI_CPU_ARCH_PROTOCOL   *Cpu;\r
+  EFI_EVENT   CpuArchEvent;\r
 \r
   // Make sure the Interrupt Controller Protocol is not already installed in the system.\r
   ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gHardwareInterruptProtocolGuid);\r
@@ -331,26 +373,23 @@ InterruptDxeInitialize (
   ASSERT_EFI_ERROR(Status);\r
 \r
   //\r
-  // Get the CPU protocol that this driver requires.\r
+  // Install the interrupt handler as soon as the CPU arch protocol appears.\r
   //\r
-  Status = gBS->LocateProtocol(&gEfiCpuArchProtocolGuid, NULL, (VOID **)&Cpu);\r
-  ASSERT_EFI_ERROR(Status);\r
-\r
-  //\r
-  // Unregister the default exception handler.\r
-  //\r
-  Status = Cpu->RegisterInterruptHandler(Cpu, EXCEPT_ARM_IRQ, NULL);\r
-  ASSERT_EFI_ERROR(Status);\r
-\r
-  //\r
-  // Register to receive interrupts\r
-  //\r
-  Status = Cpu->RegisterInterruptHandler(Cpu, EXCEPT_ARM_IRQ, IrqInterruptHandler);\r
-  ASSERT_EFI_ERROR(Status);\r
+  CpuArchEvent = EfiCreateProtocolNotifyEvent (\r
+                   &gEfiCpuArchProtocolGuid,\r
+                   TPL_CALLBACK,\r
+                   CpuArchEventProtocolNotify,\r
+                   NULL,\r
+                   &mCpuArchProtocolNotifyEventRegistration\r
+                   );\r
+  ASSERT (CpuArchEvent != NULL);\r
 \r
   // Register for an ExitBootServicesEvent\r
   Status = gBS->CreateEvent(EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY, ExitBootServicesEvent, NULL, &EfiExitBootServicesEvent);\r
-  ASSERT_EFI_ERROR(Status);\r
+  if (EFI_ERROR (Status)) {\r
+    ASSERT_EFI_ERROR (Status);\r
+    gBS->CloseEvent (CpuArchEvent);\r
+  }\r
 \r
   return Status;\r
 }\r