]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c
ArmPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / ArmPkg / Drivers / ArmGic / ArmGicCommonDxe.c
index bff8d983cf02f7fd1fa6165824cb6556cdea5c6f..5fb33c5465df9e671f1524cae06c3551d55bd8a8 100644 (file)
@@ -2,13 +2,7 @@
 \r
 Copyright (c) 2013-2017, ARM Ltd. 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
 \r
@@ -121,6 +115,44 @@ RegisterInterruptSource (
   }\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
+  // Get the CPU protocol that this driver requires.\r
+  Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&Cpu);\r
+  if (EFI_ERROR (Status)) {\r
+    return;\r
+  }\r
+\r
+  // Unregister the default exception handler.\r
+  Status = Cpu->RegisterInterruptHandler (Cpu, ARM_ARCH_EXCEPTION_IRQ, NULL);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_ERROR, "%a: Cpu->RegisterInterruptHandler() - %r\n",\r
+      __FUNCTION__, Status));\r
+    return;\r
+  }\r
+\r
+  // Register to receive interrupts\r
+  Status = Cpu->RegisterInterruptHandler (Cpu, ARM_ARCH_EXCEPTION_IRQ,\r
+                  Context);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_ERROR, "%a: Cpu->RegisterInterruptHandler() - %r\n",\r
+      __FUNCTION__, Status));\r
+  }\r
+\r
+  gBS->CloseEvent (Event);\r
+}\r
+\r
 EFI_STATUS\r
 InstallAndRegisterInterruptService (\r
   IN EFI_HARDWARE_INTERRUPT_PROTOCOL   *InterruptProtocol,\r
@@ -130,7 +162,6 @@ InstallAndRegisterInterruptService (
   )\r
 {\r
   EFI_STATUS               Status;\r
-  EFI_CPU_ARCH_PROTOCOL   *Cpu;\r
   CONST UINTN              RihArraySize =\r
     (sizeof(HARDWARE_INTERRUPT_HANDLER) * mGicNumInterrupts);\r
 \r
@@ -152,27 +183,15 @@ InstallAndRegisterInterruptService (
     return Status;\r
   }\r
 \r
-  // Get the CPU protocol that this driver requires.\r
-  Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&Cpu);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  // Unregister the default exception handler.\r
-  Status = Cpu->RegisterInterruptHandler (Cpu, ARM_ARCH_EXCEPTION_IRQ, NULL);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  // Register to receive interrupts\r
-  Status = Cpu->RegisterInterruptHandler (\r
-                  Cpu,\r
-                  ARM_ARCH_EXCEPTION_IRQ,\r
-                  InterruptHandler\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
+  //\r
+  // Install the interrupt handler as soon as the CPU arch protocol appears.\r
+  //\r
+  EfiCreateProtocolNotifyEvent (\r
+    &gEfiCpuArchProtocolGuid,\r
+    TPL_CALLBACK,\r
+    CpuArchEventProtocolNotify,\r
+    InterruptHandler,\r
+    &mCpuArchProtocolNotifyEventRegistration);\r
 \r
   // Register for an ExitBootServicesEvent\r
   Status = gBS->CreateEvent (\r