\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
}\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
)\r
{\r
EFI_STATUS Status;\r
- EFI_CPU_ARCH_PROTOCOL *Cpu;\r
CONST UINTN RihArraySize =\r
(sizeof(HARDWARE_INTERRUPT_HANDLER) * mGicNumInterrupts);\r
\r
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