]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg: allow HYP timer interrupt to be omitted
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Sat, 28 Feb 2015 20:24:57 +0000 (20:24 +0000)
committerlersek <lersek@Edk2>
Sat, 28 Feb 2015 20:24:57 +0000 (20:24 +0000)
The DT binding for the ARM generic timer describes the secure,
non-secure, virtual and hypervisor timer interrupts, respectively.
However, under virtualization, only the virtual timer is usable, and
the device tree may omit the hypervisor timer interrupt. (Other timer
interrupts cannot be omitted simply due to the fact that the virtual
timer is listed third)

Contributed-under: TianoCore Contribution Agreement 1.0
Reviewed-by: Olivier Martin <olivier.martin@arm.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16953 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Drivers/TimerDxe/TimerDxe.c
ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c

index d0a819fc27298f5cda933f372e88f8968240648f..1169d426b2559b8ff2fb84e757638c06665b6f9d 100644 (file)
@@ -369,7 +369,8 @@ TimerInitialize (
 {\r
   EFI_HANDLE  Handle = NULL;\r
   EFI_STATUS  Status;\r
-  UINTN TimerCtrlReg;\r
+  UINTN       TimerCtrlReg;\r
+  UINT32      TimerHypIntrNum;\r
 \r
   if (ArmIsArchTimerImplemented () == 0) {\r
     DEBUG ((EFI_D_ERROR, "ARM Architectural Timer is not available in the CPU, hence cann't use this Driver \n"));\r
@@ -395,8 +396,15 @@ TimerInitialize (
   Status = gInterrupt->RegisterInterruptSource (gInterrupt, PcdGet32 (PcdArmArchTimerVirtIntrNum), TimerInterruptHandler);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  Status = gInterrupt->RegisterInterruptSource (gInterrupt, PcdGet32 (PcdArmArchTimerHypIntrNum), TimerInterruptHandler);\r
-  ASSERT_EFI_ERROR (Status);\r
+  //\r
+  // The hypervisor timer interrupt may be omitted by implementations that\r
+  // execute under virtualization.\r
+  //\r
+  TimerHypIntrNum = PcdGet32 (PcdArmArchTimerHypIntrNum);\r
+  if (TimerHypIntrNum != 0) {\r
+    Status = gInterrupt->RegisterInterruptSource (gInterrupt, TimerHypIntrNum, TimerInterruptHandler);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
 \r
   Status = gInterrupt->RegisterInterruptSource (gInterrupt, PcdGet32 (PcdArmArchTimerSecIntrNum), TimerInterruptHandler);\r
   ASSERT_EFI_ERROR (Status);\r
index be74d62ad748fe14d74682f2a3b7753589379a3b..274cdeb8c8f49e5cced2d6e01261a715814df989 100644 (file)
@@ -452,7 +452,7 @@ InitializeVirtFdtDxe (
       //  hypervisor timers, in that order.\r
       //\r
       InterruptProp = fdt_getprop (DeviceTreeBase, Node, "interrupts", &Len);\r
-      ASSERT (Len == 48);\r
+      ASSERT (Len == 36 || Len == 48);\r
 \r
       SecIntrNum = fdt32_to_cpu (InterruptProp[0].Number)\r
                    + (InterruptProp[0].Type ? 16 : 0);\r
@@ -460,8 +460,8 @@ InitializeVirtFdtDxe (
                 + (InterruptProp[1].Type ? 16 : 0);\r
       VirtIntrNum = fdt32_to_cpu (InterruptProp[2].Number)\r
                     + (InterruptProp[2].Type ? 16 : 0);\r
-      HypIntrNum = fdt32_to_cpu (InterruptProp[3].Number)\r
-                   + (InterruptProp[3].Type ? 16 : 0);\r
+      HypIntrNum = Len < 48 ? 0 : fdt32_to_cpu (InterruptProp[3].Number)\r
+                                  + (InterruptProp[3].Type ? 16 : 0);\r
 \r
       DEBUG ((EFI_D_INFO, "Found Timer interrupts %d, %d, %d, %d\n",\r
         SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum));\r