]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmulatorPkg/TimerDxe/Timer.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / EmulatorPkg / TimerDxe / Timer.c
index 5230a9625e97a6843a5cc13b2903d140bc705666..4ec5c3ee2847b5fd3f3886207834eccbbab44eb4 100644 (file)
@@ -5,15 +5,9 @@
   timer service.  In the future, the Thread creation should possibly be\r
   abstracted by the CPU architectural protocol\r
 \r
   timer service.  In the future, the Thread creation should possibly be\r
   abstracted by the CPU architectural protocol\r
 \r
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
 Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.\r
 Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.\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
@@ -33,12 +27,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 //\r
 // Pointer to the CPU Architectural Protocol instance\r
 //\r
 //\r
 // Pointer to the CPU Architectural Protocol instance\r
 //\r
-EFI_CPU_ARCH_PROTOCOL   *mCpu;\r
+EFI_CPU_ARCH_PROTOCOL  *mCpu;\r
 \r
 //\r
 // The Timer Architectural Protocol that this driver produces\r
 //\r
 \r
 //\r
 // The Timer Architectural Protocol that this driver produces\r
 //\r
-EFI_TIMER_ARCH_PROTOCOL mTimer = {\r
+EFI_TIMER_ARCH_PROTOCOL  mTimer = {\r
   EmuTimerDriverRegisterHandler,\r
   EmuTimerDriverSetTimerPeriod,\r
   EmuTimerDriverGetTimerPeriod,\r
   EmuTimerDriverRegisterHandler,\r
   EmuTimerDriverSetTimerPeriod,\r
   EmuTimerDriverGetTimerPeriod,\r
@@ -48,22 +42,22 @@ EFI_TIMER_ARCH_PROTOCOL mTimer = {
 //\r
 // The notification function to call on every timer interrupt\r
 //\r
 //\r
 // The notification function to call on every timer interrupt\r
 //\r
-EFI_TIMER_NOTIFY        mTimerNotifyFunction = NULL;\r
+EFI_TIMER_NOTIFY  mTimerNotifyFunction = NULL;\r
 \r
 //\r
 // The current period of the timer interrupt\r
 //\r
 \r
 //\r
 // The current period of the timer interrupt\r
 //\r
-UINT64                  mTimerPeriodMs;\r
-\r
+UINT64  mTimerPeriodMs;\r
 \r
 VOID\r
 EFIAPI\r
 \r
 VOID\r
 EFIAPI\r
-TimerCallback (UINT64 DeltaMs)\r
+TimerCallback (\r
+  UINT64  DeltaMs\r
+  )\r
 {\r
   EFI_TPL           OriginalTPL;\r
   EFI_TIMER_NOTIFY  CallbackFunction;\r
 \r
 {\r
   EFI_TPL           OriginalTPL;\r
   EFI_TIMER_NOTIFY  CallbackFunction;\r
 \r
-\r
   OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
 \r
   if (OriginalTPL < TPL_HIGH_LEVEL) {\r
   OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
 \r
   if (OriginalTPL < TPL_HIGH_LEVEL) {\r
@@ -79,15 +73,15 @@ TimerCallback (UINT64 DeltaMs)
   }\r
 \r
   gBS->RestoreTPL (OriginalTPL);\r
   }\r
 \r
   gBS->RestoreTPL (OriginalTPL);\r
-\r
 }\r
 \r
 EFI_STATUS\r
 EFIAPI\r
 EmuTimerDriverRegisterHandler (\r
 }\r
 \r
 EFI_STATUS\r
 EFIAPI\r
 EmuTimerDriverRegisterHandler (\r
-  IN EFI_TIMER_ARCH_PROTOCOL           *This,\r
-  IN EFI_TIMER_NOTIFY                  NotifyFunction\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
+  IN EFI_TIMER_NOTIFY         NotifyFunction\r
   )\r
   )\r
+\r
 /*++\r
 \r
 Routine Description:\r
 /*++\r
 \r
 Routine Description:\r
@@ -133,11 +127,11 @@ Returns:
   //\r
   // Check for invalid parameters\r
   //\r
   //\r
   // Check for invalid parameters\r
   //\r
-  if (NotifyFunction == NULL && mTimerNotifyFunction == NULL) {\r
+  if ((NotifyFunction == NULL) && (mTimerNotifyFunction == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (NotifyFunction != NULL && mTimerNotifyFunction != NULL) {\r
+  if ((NotifyFunction != NULL) && (mTimerNotifyFunction != NULL)) {\r
     return EFI_ALREADY_STARTED;\r
   }\r
 \r
     return EFI_ALREADY_STARTED;\r
   }\r
 \r
@@ -148,6 +142,7 @@ Returns:
     /* Enable Timer.  */\r
     gEmuThunk->SetTimer (mTimerPeriodMs, TimerCallback);\r
   }\r
     /* Enable Timer.  */\r
     gEmuThunk->SetTimer (mTimerPeriodMs, TimerCallback);\r
   }\r
+\r
   mTimerNotifyFunction = NotifyFunction;\r
 \r
   return EFI_SUCCESS;\r
   mTimerNotifyFunction = NotifyFunction;\r
 \r
   return EFI_SUCCESS;\r
@@ -159,6 +154,7 @@ EmuTimerDriverSetTimerPeriod (
   IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
   IN UINT64                   TimerPeriod\r
   )\r
   IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
   IN UINT64                   TimerPeriod\r
   )\r
+\r
 /*++\r
 \r
 Routine Description:\r
 /*++\r
 \r
 Routine Description:\r
@@ -196,14 +192,14 @@ Returns:
 \r
 **/\r
 {\r
 \r
 **/\r
 {\r
-\r
   //\r
   // If TimerPeriod is 0, then the timer thread should be canceled\r
   // If the TimerPeriod is valid, then create and/or adjust the period of the timer thread\r
   //\r
   //\r
   // If TimerPeriod is 0, then the timer thread should be canceled\r
   // If the TimerPeriod is valid, then create and/or adjust the period of the timer thread\r
   //\r
-  if (TimerPeriod == 0\r
-      || ((TimerPeriod > TIMER_MINIMUM_VALUE)\r
-    && (TimerPeriod < TIMER_MAXIMUM_VALUE))) {\r
+  if (  (TimerPeriod == 0)\r
+     || (  (TimerPeriod > TIMER_MINIMUM_VALUE)\r
+        && (TimerPeriod < TIMER_MAXIMUM_VALUE)))\r
+  {\r
     mTimerPeriodMs = DivU64x32 (TimerPeriod + 5000, 10000);\r
 \r
     gEmuThunk->SetTimer (mTimerPeriodMs, TimerCallback);\r
     mTimerPeriodMs = DivU64x32 (TimerPeriod + 5000, 10000);\r
 \r
     gEmuThunk->SetTimer (mTimerPeriodMs, TimerCallback);\r
@@ -215,9 +211,10 @@ Returns:
 EFI_STATUS\r
 EFIAPI\r
 EmuTimerDriverGetTimerPeriod (\r
 EFI_STATUS\r
 EFIAPI\r
 EmuTimerDriverGetTimerPeriod (\r
-  IN EFI_TIMER_ARCH_PROTOCOL            *This,\r
-  OUT UINT64                            *TimerPeriod\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
+  OUT UINT64                  *TimerPeriod\r
   )\r
   )\r
+\r
 /*++\r
 \r
 Routine Description:\r
 /*++\r
 \r
 Routine Description:\r
@@ -256,6 +253,7 @@ EFIAPI
 EmuTimerDriverGenerateSoftInterrupt (\r
   IN EFI_TIMER_ARCH_PROTOCOL  *This\r
   )\r
 EmuTimerDriverGenerateSoftInterrupt (\r
   IN EFI_TIMER_ARCH_PROTOCOL  *This\r
   )\r
+\r
 /*++\r
 \r
 Routine Description:\r
 /*++\r
 \r
 Routine Description:\r
@@ -276,7 +274,7 @@ Returns:
 \r
   EFI_SUCCESS       - The soft timer interrupt was generated.\r
 \r
 \r
   EFI_SUCCESS       - The soft timer interrupt was generated.\r
 \r
-  EFI_UNSUPPORTEDT  - The platform does not support the generation of soft timer interrupts.\r
+  EFI_UNSUPPORTED   - The platform does not support the generation of soft timer interrupts.\r
 \r
 **/\r
 {\r
 \r
 **/\r
 {\r
@@ -289,6 +287,7 @@ EmuTimerDriverInitialize (
   IN EFI_HANDLE        ImageHandle,\r
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
   IN EFI_HANDLE        ImageHandle,\r
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
+\r
 /*++\r
 \r
 Routine Description:\r
 /*++\r
 \r
 Routine Description:\r
@@ -307,7 +306,7 @@ Returns:
 \r
   EFI_OUT_OF_RESOURCES  - Not enough resources available to initialize driver.\r
 \r
 \r
   EFI_OUT_OF_RESOURCES  - Not enough resources available to initialize driver.\r
 \r
-  EFI_DEVICE_ERROR      - A device error occured attempting to initialize the driver.\r
+  EFI_DEVICE_ERROR      - A device error occurred attempting to initialize the driver.\r
 \r
 **/\r
 {\r
 \r
 **/\r
 {\r
@@ -347,6 +346,5 @@ Returns:
     return Status;\r
   }\r
 \r
     return Status;\r
   }\r
 \r
-\r
   return EFI_SUCCESS;\r
 }\r
   return EFI_SUCCESS;\r
 }\r