]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Omap35xxPkg/InterruptDxe: replace CPU Arch Protocol depex with notify
authorLaszlo Ersek <lersek@redhat.com>
Wed, 11 Apr 2018 22:03:45 +0000 (00:03 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Thu, 12 Apr 2018 19:24:12 +0000 (21:24 +0200)
In a later patch, we'll modify the depex of
"ArmPkg/Drivers/CpuDxe/CpuDxe.inf" (currently "AFTER gArmGicDxeFileGuid")
to "gHardwareInterruptProtocolGuid OR gHardwareInterrupt2ProtocolGuid".

Considering platforms that include "ArmPkg/Drivers/CpuDxe/CpuDxe.inf",
there are two classes:

(1) The platform gets its gHardwareInterruptProtocolGuid or
    gHardwareInterrupt2ProtocolGuid instance from
    "ArmPkg/Drivers/ArmGic/ArmGicDxe.inf". For such platforms, the
    upcoming CpuDxe change is not a problem, because commit 61a7b0ec634f
    made ArmGicDxe wait for the CPU Arch Protocol with a protocol notify.

(2) The platform gets its hardware interrupt protocol(s) from a different
    driver that has a hard depex on the CPU Arch Protocol. The upcoming
    CpuDxe change would lead to a loop in the DXE dispatch order.

In the edk2 tree, only "BeagleBoardPkg/BeagleBoardPkg.dsc" falls in class
(2), and the driver in question is "Omap35xxPkg/InterruptDxe". Port (most
of) commit 61a7b0ec634f to it.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Steve Capper <steve.capper@linaro.org>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@arm.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Omap35xxPkg/InterruptDxe/HardwareInterrupt.c
Omap35xxPkg/InterruptDxe/InterruptDxe.inf

index 09e22b5921b0fd10c40dea6e91173c605890ee75..2ddc7c0566d090162b011703c29e60b5d0862e3e 100644 (file)
@@ -296,6 +296,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 +362,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 +379,23 @@ InterruptDxeInitialize (
   ASSERT_EFI_ERROR(Status);\r
 \r
   //\r
-  // Get the CPU protocol that this driver requires.\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
+  // Install the interrupt handler as soon as the CPU arch protocol appears.\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
index 6deb8c3f675c3296b712a4be1e35b3589f408e1e..61ad89af27580b50ae73a666fde78acd819bb220 100644 (file)
   ArmLib\r
 \r
 [Protocols]\r
-  gHardwareInterruptProtocolGuid\r
-  gEfiCpuArchProtocolGuid\r
+  gHardwareInterruptProtocolGuid  ## PRODUCES\r
+  gEfiCpuArchProtocolGuid         ## CONSUMES ## NOTIFY\r
 \r
 [FixedPcd.common]\r
   gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress\r
 \r
 [Depex]\r
-  gEfiCpuArchProtocolGuid\r
+  TRUE\r