Revision: 16953
          http://sourceforge.net/p/edk2/code/16953
Author:   lersek
Date:     2015-02-28 20:24:57 +0000 (Sat, 28 Feb 2015)
Log Message:
-----------
ArmPkg: allow HYP timer interrupt to be omitted

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 <[email protected]>
Reviewed-by: Laszlo Ersek <[email protected]>
Signed-off-by: Ard Biesheuvel <[email protected]>
Signed-off-by: Laszlo Ersek <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ArmPkg/Drivers/TimerDxe/TimerDxe.c
    trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c

Modified: trunk/edk2/ArmPkg/Drivers/TimerDxe/TimerDxe.c
===================================================================
--- trunk/edk2/ArmPkg/Drivers/TimerDxe/TimerDxe.c       2015-02-28 05:34:38 UTC 
(rev 16952)
+++ trunk/edk2/ArmPkg/Drivers/TimerDxe/TimerDxe.c       2015-02-28 20:24:57 UTC 
(rev 16953)
@@ -369,7 +369,8 @@
 {
   EFI_HANDLE  Handle = NULL;
   EFI_STATUS  Status;
-  UINTN TimerCtrlReg;
+  UINTN       TimerCtrlReg;
+  UINT32      TimerHypIntrNum;
 
   if (ArmIsArchTimerImplemented () == 0) {
     DEBUG ((EFI_D_ERROR, "ARM Architectural Timer is not available in the CPU, 
hence cann't use this Driver \n"));
@@ -395,8 +396,15 @@
   Status = gInterrupt->RegisterInterruptSource (gInterrupt, PcdGet32 
(PcdArmArchTimerVirtIntrNum), TimerInterruptHandler);
   ASSERT_EFI_ERROR (Status);
 
-  Status = gInterrupt->RegisterInterruptSource (gInterrupt, PcdGet32 
(PcdArmArchTimerHypIntrNum), TimerInterruptHandler);
-  ASSERT_EFI_ERROR (Status);
+  //
+  // The hypervisor timer interrupt may be omitted by implementations that
+  // execute under virtualization.
+  //
+  TimerHypIntrNum = PcdGet32 (PcdArmArchTimerHypIntrNum);
+  if (TimerHypIntrNum != 0) {
+    Status = gInterrupt->RegisterInterruptSource (gInterrupt, TimerHypIntrNum, 
TimerInterruptHandler);
+    ASSERT_EFI_ERROR (Status);
+  }
 
   Status = gInterrupt->RegisterInterruptSource (gInterrupt, PcdGet32 
(PcdArmArchTimerSecIntrNum), TimerInterruptHandler);
   ASSERT_EFI_ERROR (Status);

Modified: trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
===================================================================
--- trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c      
2015-02-28 05:34:38 UTC (rev 16952)
+++ trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c      
2015-02-28 20:24:57 UTC (rev 16953)
@@ -452,7 +452,7 @@
       //  hypervisor timers, in that order.
       //
       InterruptProp = fdt_getprop (DeviceTreeBase, Node, "interrupts", &Len);
-      ASSERT (Len == 48);
+      ASSERT (Len == 36 || Len == 48);
 
       SecIntrNum = fdt32_to_cpu (InterruptProp[0].Number)
                    + (InterruptProp[0].Type ? 16 : 0);
@@ -460,8 +460,8 @@
                 + (InterruptProp[1].Type ? 16 : 0);
       VirtIntrNum = fdt32_to_cpu (InterruptProp[2].Number)
                     + (InterruptProp[2].Type ? 16 : 0);
-      HypIntrNum = fdt32_to_cpu (InterruptProp[3].Number)
-                   + (InterruptProp[3].Type ? 16 : 0);
+      HypIntrNum = Len < 48 ? 0 : fdt32_to_cpu (InterruptProp[3].Number)
+                                  + (InterruptProp[3].Type ? 16 : 0);
 
       DEBUG ((EFI_D_INFO, "Found Timer interrupts %d, %d, %d, %d\n",
         SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum));


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to