Revision: 14433
          http://sourceforge.net/p/edk2/code/14433
Author:   oliviermartin
Date:     2013-06-19 18:08:02 +0000 (Wed, 19 Jun 2013)
Log Message:
-----------
ArmPkg/Drivers/TimerDxe: Improve Timer initialisation.

- Registering a interrupt handler implicitly enables said interrupt. This
  is in the UEFI Spec. No need to enable the interrupts a second time.
- Make sure the Timer is completely disabled before configuring it. Only
  enable after configuration is complete.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <[email protected]>

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

Modified: trunk/edk2/ArmPkg/Drivers/TimerDxe/TimerDxe.c
===================================================================
--- trunk/edk2/ArmPkg/Drivers/TimerDxe/TimerDxe.c       2013-06-19 18:06:12 UTC 
(rev 14432)
+++ trunk/edk2/ArmPkg/Drivers/TimerDxe/TimerDxe.c       2013-06-19 18:08:02 UTC 
(rev 14433)
@@ -1,16 +1,16 @@
 /** @file
   Timer Architecture Protocol driver of the ARM flavor
 
-  Copyright (c) 2011 ARM Ltd. All rights reserved.<BR>
-  
-  This program and the accompanying materials                          
-  are licensed and made available under the terms and conditions of the BSD 
License         
-  which accompanies this distribution.  The full text of the license may be 
found at        
-  http://opensource.org/licenses/bsd-license.php                               
             
+  Copyright (c) 2011-2013 ARM Ltd. All rights reserved.<BR>
 
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,        
             
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.             
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
 
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
 **/
 
 
@@ -336,6 +336,10 @@
   ASSERT_EFI_ERROR (Status);
 
   // Disable the timer
+  TimerCtrlReg = ArmArchTimerGetTimerCtrlReg ();
+  TimerCtrlReg |= ARM_ARCH_TIMER_IMASK;
+  TimerCtrlReg &= ~ARM_ARCH_TIMER_ENABLE;
+  ArmArchTimerSetTimerCtrlReg (TimerCtrlReg);
   Status = TimerDriverSetTimerPeriod (&gTimer, 0);
   ASSERT_EFI_ERROR (Status);
 
@@ -349,11 +353,6 @@
   Status = gInterrupt->RegisterInterruptSource (gInterrupt, PcdGet32 
(PcdArmArchTimerIntrNum), TimerInterruptHandler);
   ASSERT_EFI_ERROR (Status);
 
-  // Unmask timer interrupts
-  TimerCtrlReg = ArmArchTimerGetTimerCtrlReg ();
-  TimerCtrlReg &= ~ARM_ARCH_TIMER_IMASK;
-  ArmArchTimerSetTimerCtrlReg (TimerCtrlReg);
-
   // Set up default timer
   Status = TimerDriverSetTimerPeriod (&gTimer, FixedPcdGet32(PcdTimerPeriod)); 
// TIMER_DEFAULT_PERIOD
   ASSERT_EFI_ERROR (Status);
@@ -366,12 +365,10 @@
                   );
   ASSERT_EFI_ERROR(Status);
 
-  // enable Secure timer interrupts
-  Status = gInterrupt->EnableInterruptSource (gInterrupt, PcdGet32 
(PcdArmArchTimerSecIntrNum));
+  // Everything is ready, unmask and enable timer interrupts
+  TimerCtrlReg = ARM_ARCH_TIMER_ENABLE;
+  ArmArchTimerSetTimerCtrlReg (TimerCtrlReg);
 
-  // enable NonSecure timer interrupts
-  Status = gInterrupt->EnableInterruptSource (gInterrupt, PcdGet32 
(PcdArmArchTimerIntrNum));
-
   // Register for an ExitBootServicesEvent
   Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY, 
ExitBootServicesEvent, NULL, &EfiExitBootServicesEvent);
   ASSERT_EFI_ERROR (Status);

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to