]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: Rename XenTimerDxe to LocalApicTimerDxe
authorMin Xu <min.m.xu@intel.com>
Mon, 25 Oct 2021 02:20:31 +0000 (10:20 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sat, 2 Apr 2022 08:15:12 +0000 (08:15 +0000)
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3711

XenTimerDxe is a local Apic timer driver and it has nothing to do
with Xen. So rename it to LocalApicTimerDxe.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Julien Grall <julien@xen.org>
Acked-by: Anthony PERARD <anthony.perard@citrix.com
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
12 files changed:
OvmfPkg/CloudHv/CloudHvX64.dsc
OvmfPkg/CloudHv/CloudHvX64.fdf
OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c [new file with mode: 0644]
OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.h [new file with mode: 0644]
OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf [new file with mode: 0644]
OvmfPkg/Microvm/MicrovmX64.dsc
OvmfPkg/Microvm/MicrovmX64.fdf
OvmfPkg/OvmfXen.dsc
OvmfPkg/OvmfXen.fdf
OvmfPkg/XenTimerDxe/XenTimerDxe.c [deleted file]
OvmfPkg/XenTimerDxe/XenTimerDxe.h [deleted file]
OvmfPkg/XenTimerDxe/XenTimerDxe.inf [deleted file]

index ee340cc654bffdbc605ad1b12e772c72a9bf4d9b..380438e0dc0ed2b613cba0ac0b0a3bc85b55f1da 100644 (file)
   MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
   UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf\r
   UefiCpuPkg/CpuDxe/CpuDxe.inf\r
-  OvmfPkg/XenTimerDxe/XenTimerDxe.inf\r
+  OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf\r
   OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf\r
   OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf\r
   MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {\r
index d80e13ae9040f86be7d9e7eef349fdfc740a2880..de64a3a709329ed51301844fa520e97f9a601e5e 100644 (file)
@@ -216,7 +216,7 @@ INF  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
 INF  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
 INF  UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf\r
 INF  UefiCpuPkg/CpuDxe/CpuDxe.inf\r
-INF  OvmfPkg/XenTimerDxe/XenTimerDxe.inf\r
+INF  OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf\r
 INF  OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf\r
 INF  OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf\r
 INF  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf\r
diff --git a/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c b/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c
new file mode 100644 (file)
index 0000000..dd9352b
--- /dev/null
@@ -0,0 +1,363 @@
+/** @file\r
+  Timer Architectural Protocol as defined in the DXE CIS\r
+\r
+Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2019, Citrix Systems, Inc.\r
+\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include "LocalApicTimerDxe.h"\r
+\r
+//\r
+// The handle onto which the Timer Architectural Protocol will be installed\r
+//\r
+EFI_HANDLE  mTimerHandle = NULL;\r
+\r
+//\r
+// The Timer Architectural Protocol that this driver produces\r
+//\r
+EFI_TIMER_ARCH_PROTOCOL  mTimer = {\r
+  TimerDriverRegisterHandler,\r
+  TimerDriverSetTimerPeriod,\r
+  TimerDriverGetTimerPeriod,\r
+  TimerDriverGenerateSoftInterrupt\r
+};\r
+\r
+//\r
+// Pointer to the CPU Architectural Protocol instance\r
+//\r
+EFI_CPU_ARCH_PROTOCOL  *mCpu;\r
+\r
+//\r
+// The notification function to call on every timer interrupt.\r
+// A bug in the compiler prevents us from initializing this here.\r
+//\r
+EFI_TIMER_NOTIFY  mTimerNotifyFunction;\r
+\r
+//\r
+// The current period of the timer interrupt\r
+//\r
+volatile UINT64  mTimerPeriod = 0;\r
+\r
+//\r
+// Worker Functions\r
+//\r
+\r
+/**\r
+  Interrupt Handler.\r
+\r
+  @param InterruptType    The type of interrupt that occurred\r
+  @param SystemContext    A pointer to the system context when the interrupt occurred\r
+**/\r
+VOID\r
+EFIAPI\r
+TimerInterruptHandler (\r
+  IN EFI_EXCEPTION_TYPE  InterruptType,\r
+  IN EFI_SYSTEM_CONTEXT  SystemContext\r
+  )\r
+{\r
+  EFI_TPL  OriginalTPL;\r
+\r
+  OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+\r
+  if (mTimerNotifyFunction != NULL) {\r
+    //\r
+    // @bug : This does not handle missed timer interrupts\r
+    //\r
+    mTimerNotifyFunction (mTimerPeriod);\r
+  }\r
+\r
+  gBS->RestoreTPL (OriginalTPL);\r
+\r
+  DisableInterrupts ();\r
+  SendApicEoi ();\r
+}\r
+\r
+/**\r
+\r
+  This function registers the handler NotifyFunction so it is called every time\r
+  the timer interrupt fires.  It also passes the amount of time since the last\r
+  handler call to the NotifyFunction.  If NotifyFunction is NULL, then the\r
+  handler is unregistered.  If the handler is registered, then EFI_SUCCESS is\r
+  returned.  If the CPU does not support registering a timer interrupt handler,\r
+  then EFI_UNSUPPORTED is returned.  If an attempt is made to register a handler\r
+  when a handler is already registered, then EFI_ALREADY_STARTED is returned.\r
+  If an attempt is made to unregister a handler when a handler is not registered,\r
+  then EFI_INVALID_PARAMETER is returned.  If an error occurs attempting to\r
+  register the NotifyFunction with the timer interrupt, then EFI_DEVICE_ERROR\r
+  is returned.\r
+\r
+\r
+  @param This             The EFI_TIMER_ARCH_PROTOCOL instance.\r
+  @param NotifyFunction   The function to call when a timer interrupt fires.  This\r
+                          function executes at TPL_HIGH_LEVEL.  The DXE Core will\r
+                          register a handler for the timer interrupt, so it can know\r
+                          how much time has passed.  This information is used to\r
+                          signal timer based events.  NULL will unregister the handler.\r
+\r
+  @retval        EFI_SUCCESS            The timer handler was registered.\r
+  @retval        EFI_UNSUPPORTED        The platform does not support timer interrupts.\r
+  @retval        EFI_ALREADY_STARTED    NotifyFunction is not NULL, and a handler is already\r
+                                        registered.\r
+  @retval        EFI_INVALID_PARAMETER  NotifyFunction is NULL, and a handler was not\r
+                                        previously registered.\r
+  @retval        EFI_DEVICE_ERROR       The timer handler could not be registered.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TimerDriverRegisterHandler (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
+  IN EFI_TIMER_NOTIFY         NotifyFunction\r
+  )\r
+{\r
+  //\r
+  // Check for invalid parameters\r
+  //\r
+  if ((NotifyFunction == NULL) && (mTimerNotifyFunction == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if ((NotifyFunction != NULL) && (mTimerNotifyFunction != NULL)) {\r
+    return EFI_ALREADY_STARTED;\r
+  }\r
+\r
+  mTimerNotifyFunction = NotifyFunction;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+\r
+  This function adjusts the period of timer interrupts to the value specified\r
+  by TimerPeriod.  If the timer period is updated, then the selected timer\r
+  period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned.  If\r
+  the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.\r
+  If an error occurs while attempting to update the timer period, then the\r
+  timer hardware will be put back in its state prior to this call, and\r
+  EFI_DEVICE_ERROR is returned.  If TimerPeriod is 0, then the timer interrupt\r
+  is disabled.  This is not the same as disabling the CPU's interrupts.\r
+  Instead, it must either turn off the timer hardware, or it must adjust the\r
+  interrupt controller so that a CPU interrupt is not generated when the timer\r
+  interrupt fires.\r
+\r
+\r
+  @param This            The EFI_TIMER_ARCH_PROTOCOL instance.\r
+  @param TimerPeriod     The rate to program the timer interrupt in 100 nS units.  If\r
+                         the timer hardware is not programmable, then EFI_UNSUPPORTED is\r
+                         returned.  If the timer is programmable, then the timer period\r
+                         will be rounded up to the nearest timer period that is supported\r
+                         by the timer hardware.  If TimerPeriod is set to 0, then the\r
+                         timer interrupts will be disabled.\r
+\r
+  @retval        EFI_SUCCESS       The timer period was changed.\r
+  @retval        EFI_UNSUPPORTED   The platform cannot change the period of the timer interrupt.\r
+  @retval        EFI_DEVICE_ERROR  The timer period could not be changed due to a device error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TimerDriverSetTimerPeriod (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
+  IN UINT64                   TimerPeriod\r
+  )\r
+{\r
+  UINT64  TimerCount;\r
+  UINT32  TimerFrequency;\r
+  UINT32  DivideValue = 1;\r
+\r
+  if (TimerPeriod == 0) {\r
+    //\r
+    // Disable timer interrupt for a TimerPeriod of 0\r
+    //\r
+    DisableApicTimerInterrupt ();\r
+  } else {\r
+    TimerFrequency = PcdGet32 (PcdFSBClock) / DivideValue;\r
+\r
+    //\r
+    // Convert TimerPeriod into local APIC counts\r
+    //\r
+    // TimerPeriod is in 100ns\r
+    // TimerPeriod/10000000 will be in seconds.\r
+    TimerCount = DivU64x32 (\r
+                   MultU64x32 (TimerPeriod, TimerFrequency),\r
+                   10000000\r
+                   );\r
+\r
+    // Check for overflow\r
+    if (TimerCount > MAX_UINT32) {\r
+      TimerCount = MAX_UINT32;\r
+      /* TimerPeriod = (MAX_UINT32 / TimerFrequency) * 10000000; */\r
+      TimerPeriod = 429496730;\r
+    }\r
+\r
+    //\r
+    // Program the timer with the new count value\r
+    //\r
+    InitializeApicTimer (DivideValue, (UINT32)TimerCount, TRUE, LOCAL_APIC_TIMER_VECTOR);\r
+\r
+    //\r
+    // Enable timer interrupt\r
+    //\r
+    EnableApicTimerInterrupt ();\r
+  }\r
+\r
+  //\r
+  // Save the new timer period\r
+  //\r
+  mTimerPeriod = TimerPeriod;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+\r
+  This function retrieves the period of timer interrupts in 100 ns units,\r
+  returns that value in TimerPeriod, and returns EFI_SUCCESS.  If TimerPeriod\r
+  is NULL, then EFI_INVALID_PARAMETER is returned.  If a TimerPeriod of 0 is\r
+  returned, then the timer is currently disabled.\r
+\r
+\r
+  @param This            The EFI_TIMER_ARCH_PROTOCOL instance.\r
+  @param TimerPeriod     A pointer to the timer period to retrieve in 100 ns units.  If\r
+                         0 is returned, then the timer is currently disabled.\r
+\r
+  @retval EFI_SUCCESS            The timer period was returned in TimerPeriod.\r
+  @retval EFI_INVALID_PARAMETER  TimerPeriod is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TimerDriverGetTimerPeriod (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
+  OUT UINT64                  *TimerPeriod\r
+  )\r
+{\r
+  if (TimerPeriod == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *TimerPeriod = mTimerPeriod;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+\r
+  This function generates a soft timer interrupt. If the platform does not support soft\r
+  timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned.\r
+  If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler()\r
+  service, then a soft timer interrupt will be generated. If the timer interrupt is\r
+  enabled when this service is called, then the registered handler will be invoked. The\r
+  registered handler should not be able to distinguish a hardware-generated timer\r
+  interrupt from a software-generated timer interrupt.\r
+\r
+\r
+  @param This              The EFI_TIMER_ARCH_PROTOCOL instance.\r
+\r
+  @retval EFI_SUCCESS       The soft timer interrupt was generated.\r
+  @retval EFI_UNSUPPORTED   The platform does not support the generation of soft timer interrupts.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TimerDriverGenerateSoftInterrupt (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This\r
+  )\r
+{\r
+  EFI_TPL  OriginalTPL;\r
+\r
+  if (GetApicTimerInterruptState ()) {\r
+    //\r
+    // Invoke the registered handler\r
+    //\r
+    OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+\r
+    if (mTimerNotifyFunction != NULL) {\r
+      //\r
+      // @bug : This does not handle missed timer interrupts\r
+      //\r
+      mTimerNotifyFunction (mTimerPeriod);\r
+    }\r
+\r
+    gBS->RestoreTPL (OriginalTPL);\r
+  } else {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Initialize the Timer Architectural Protocol driver\r
+\r
+  @param ImageHandle     ImageHandle of the loaded driver\r
+  @param SystemTable     Pointer to the System Table\r
+\r
+  @retval EFI_SUCCESS            Timer Architectural Protocol created\r
+  @retval EFI_OUT_OF_RESOURCES   Not enough resources available to initialize driver.\r
+  @retval EFI_DEVICE_ERROR       A device error occurred attempting to initialize the driver.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TimerDriverInitialize (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Initialize the pointer to our notify function.\r
+  //\r
+  mTimerNotifyFunction = NULL;\r
+\r
+  //\r
+  // Make sure the Timer Architectural Protocol is not already installed in the system\r
+  //\r
+  ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiTimerArchProtocolGuid);\r
+\r
+  //\r
+  // Find the CPU architectural protocol.\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&mCpu);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Force the timer to be disabled\r
+  //\r
+  Status = TimerDriverSetTimerPeriod (&mTimer, 0);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Install interrupt handler for Local APIC Timer\r
+  //\r
+  Status = mCpu->RegisterInterruptHandler (\r
+                   mCpu,\r
+                   LOCAL_APIC_TIMER_VECTOR,\r
+                   TimerInterruptHandler\r
+                   );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Force the timer to be enabled at its default period\r
+  //\r
+  Status = TimerDriverSetTimerPeriod (&mTimer, DEFAULT_TIMER_TICK_DURATION);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Install the Timer Architectural Protocol onto a new handle\r
+  //\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &mTimerHandle,\r
+                  &gEfiTimerArchProtocolGuid,\r
+                  &mTimer,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
diff --git a/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.h b/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.h
new file mode 100644 (file)
index 0000000..9370699
--- /dev/null
@@ -0,0 +1,178 @@
+/** @file\r
+  Private data structures\r
+\r
+Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2019, Citrix Systems, Inc.\r
+\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#ifndef LOCAL_APIC_TIMER_H_\r
+#define LOCAL_APIC_TIMER_H_\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Protocol/Cpu.h>\r
+#include <Protocol/Timer.h>\r
+\r
+#include <Register/LocalApic.h>\r
+\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/LocalApicLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+// The default timer tick duration is set to 10 ms = 100000 100 ns units\r
+//\r
+#define DEFAULT_TIMER_TICK_DURATION  100000\r
+\r
+//\r
+// The Timer Vector use for interrupt\r
+//\r
+#define LOCAL_APIC_TIMER_VECTOR  32\r
+\r
+//\r
+// Function Prototypes\r
+//\r
+\r
+/**\r
+  Initialize the Timer Architectural Protocol driver\r
+\r
+  @param ImageHandle     ImageHandle of the loaded driver\r
+  @param SystemTable     Pointer to the System Table\r
+\r
+  @retval EFI_SUCCESS            Timer Architectural Protocol created\r
+  @retval EFI_OUT_OF_RESOURCES   Not enough resources available to initialize driver.\r
+  @retval EFI_DEVICE_ERROR       A device error occurred attempting to initialize the driver.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TimerDriverInitialize (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+;\r
+\r
+/**\r
+\r
+  This function adjusts the period of timer interrupts to the value specified\r
+  by TimerPeriod.  If the timer period is updated, then the selected timer\r
+  period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned.  If\r
+  the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.\r
+  If an error occurs while attempting to update the timer period, then the\r
+  timer hardware will be put back in its state prior to this call, and\r
+  EFI_DEVICE_ERROR is returned.  If TimerPeriod is 0, then the timer interrupt\r
+  is disabled.  This is not the same as disabling the CPU's interrupts.\r
+  Instead, it must either turn off the timer hardware, or it must adjust the\r
+  interrupt controller so that a CPU interrupt is not generated when the timer\r
+  interrupt fires.\r
+\r
+\r
+  @param This            The EFI_TIMER_ARCH_PROTOCOL instance.\r
+  @param NotifyFunction  The rate to program the timer interrupt in 100 nS units.  If\r
+                         the timer hardware is not programmable, then EFI_UNSUPPORTED is\r
+                         returned.  If the timer is programmable, then the timer period\r
+                         will be rounded up to the nearest timer period that is supported\r
+                         by the timer hardware.  If TimerPeriod is set to 0, then the\r
+                         timer interrupts will be disabled.\r
+\r
+  @retval        EFI_SUCCESS       The timer period was changed.\r
+  @retval        EFI_UNSUPPORTED   The platform cannot change the period of the timer interrupt.\r
+  @retval        EFI_DEVICE_ERROR  The timer period could not be changed due to a device error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TimerDriverRegisterHandler (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
+  IN EFI_TIMER_NOTIFY         NotifyFunction\r
+  )\r
+;\r
+\r
+/**\r
+\r
+  This function adjusts the period of timer interrupts to the value specified\r
+  by TimerPeriod.  If the timer period is updated, then the selected timer\r
+  period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned.  If\r
+  the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.\r
+  If an error occurs while attempting to update the timer period, then the\r
+  timer hardware will be put back in its state prior to this call, and\r
+  EFI_DEVICE_ERROR is returned.  If TimerPeriod is 0, then the timer interrupt\r
+  is disabled.  This is not the same as disabling the CPU's interrupts.\r
+  Instead, it must either turn off the timer hardware, or it must adjust the\r
+  interrupt controller so that a CPU interrupt is not generated when the timer\r
+  interrupt fires.\r
+\r
+\r
+  @param This            The EFI_TIMER_ARCH_PROTOCOL instance.\r
+  @param TimerPeriod     The rate to program the timer interrupt in 100 nS units.  If\r
+                         the timer hardware is not programmable, then EFI_UNSUPPORTED is\r
+                         returned.  If the timer is programmable, then the timer period\r
+                         will be rounded up to the nearest timer period that is supported\r
+                         by the timer hardware.  If TimerPeriod is set to 0, then the\r
+                         timer interrupts will be disabled.\r
+\r
+  @retval        EFI_SUCCESS       The timer period was changed.\r
+  @retval        EFI_UNSUPPORTED   The platform cannot change the period of the timer interrupt.\r
+  @retval        EFI_DEVICE_ERROR  The timer period could not be changed due to a device error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TimerDriverSetTimerPeriod (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
+  IN UINT64                   TimerPeriod\r
+  )\r
+;\r
+\r
+/**\r
+\r
+  This function retrieves the period of timer interrupts in 100 ns units,\r
+  returns that value in TimerPeriod, and returns EFI_SUCCESS.  If TimerPeriod\r
+  is NULL, then EFI_INVALID_PARAMETER is returned.  If a TimerPeriod of 0 is\r
+  returned, then the timer is currently disabled.\r
+\r
+\r
+  @param This            The EFI_TIMER_ARCH_PROTOCOL instance.\r
+  @param TimerPeriod     A pointer to the timer period to retrieve in 100 ns units.  If\r
+                         0 is returned, then the timer is currently disabled.\r
+\r
+  @retval EFI_SUCCESS            The timer period was returned in TimerPeriod.\r
+  @retval EFI_INVALID_PARAMETER  TimerPeriod is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TimerDriverGetTimerPeriod (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
+  OUT UINT64                  *TimerPeriod\r
+  )\r
+;\r
+\r
+/**\r
+\r
+  This function generates a soft timer interrupt. If the platform does not support soft\r
+  timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned.\r
+  If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler()\r
+  service, then a soft timer interrupt will be generated. If the timer interrupt is\r
+  enabled when this service is called, then the registered handler will be invoked. The\r
+  registered handler should not be able to distinguish a hardware-generated timer\r
+  interrupt from a software-generated timer interrupt.\r
+\r
+\r
+  @param This              The EFI_TIMER_ARCH_PROTOCOL instance.\r
+\r
+  @retval EFI_SUCCESS       The soft timer interrupt was generated.\r
+  @retval EFI_UNSUPPORTED   The platform does not support the generation of soft timer interrupts.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TimerDriverGenerateSoftInterrupt (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This\r
+  )\r
+;\r
+\r
+#endif\r
diff --git a/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf b/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf
new file mode 100644 (file)
index 0000000..63b75b7
--- /dev/null
@@ -0,0 +1,42 @@
+## @file\r
+# Local APIC timer driver that provides Timer Arch protocol.\r
+#\r
+# Copyright (c) 2005 - 2019, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2019, Citrix Systems, Inc.\r
+#\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = LocalApicTimerDxe\r
+  FILE_GUID                      = 52fe8196-f9de-4d07-b22f-51f77a0e7c41\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = TimerDriverInitialize\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  UefiCpuPkg/UefiCpuPkg.dec\r
+  OvmfPkg/OvmfPkg.dec\r
+\r
+[LibraryClasses]\r
+  UefiBootServicesTableLib\r
+  BaseLib\r
+  DebugLib\r
+  UefiDriverEntryPoint\r
+  LocalApicLib\r
+\r
+[Sources]\r
+  LocalApicTimerDxe.h\r
+  LocalApicTimerDxe.c\r
+\r
+[Protocols]\r
+  gEfiCpuArchProtocolGuid       ## CONSUMES\r
+  gEfiTimerArchProtocolGuid     ## PRODUCES\r
+[Pcd]\r
+  gEfiMdePkgTokenSpaceGuid.PcdFSBClock  ## CONSUMES\r
+[Depex]\r
+  gEfiCpuArchProtocolGuid\r
index 9fc0ff2750b1e866aac6399ebc1e801e680c1714..59580ccd4691b710927096cc5654d812a0b8f999 100644 (file)
 \r
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
   MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
-  OvmfPkg/XenTimerDxe/XenTimerDxe.inf\r
+  OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf\r
   UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf\r
   UefiCpuPkg/CpuDxe/CpuDxe.inf\r
   OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf\r
index 6999ac1a87b9bb2313b29be17e9a00aaf58f804a..3adb492a4ad7e9bfebeef0553a73108092463a6e 100644 (file)
@@ -215,7 +215,7 @@ INF  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
 INF  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf\r
 INF  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
 INF  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
-INF  OvmfPkg/XenTimerDxe/XenTimerDxe.inf\r
+INF  OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf\r
 INF  UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf\r
 INF  UefiCpuPkg/CpuDxe/CpuDxe.inf\r
 INF  OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf\r
index 78d1509f75bd4ee19b4f3cad9f3b45c0ddd391c6..7bd594c6e263163e9482d89e8658a40e70b6be70 100644 (file)
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
 \r
   MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
-  OvmfPkg/XenTimerDxe/XenTimerDxe.inf\r
+  OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf\r
   UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf\r
   UefiCpuPkg/CpuDxe/CpuDxe.inf\r
   OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf\r
index 2e67db5d329cc00024322b97aaa0eebdfcc3fa5b..029b7dadcb2576ef8dca6ca45a477e4d3a861ca0 100644 (file)
@@ -245,7 +245,7 @@ INF  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
 INF  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf\r
 INF  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
 INF  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
-INF  OvmfPkg/XenTimerDxe/XenTimerDxe.inf\r
+INF  OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf\r
 INF  UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf\r
 INF  UefiCpuPkg/CpuDxe/CpuDxe.inf\r
 INF  OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf\r
diff --git a/OvmfPkg/XenTimerDxe/XenTimerDxe.c b/OvmfPkg/XenTimerDxe/XenTimerDxe.c
deleted file mode 100644 (file)
index bbd964e..0000000
+++ /dev/null
@@ -1,363 +0,0 @@
-/** @file\r
-  Timer Architectural Protocol as defined in the DXE CIS\r
-\r
-Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>\r
-Copyright (c) 2019, Citrix Systems, Inc.\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "XenTimerDxe.h"\r
-\r
-//\r
-// The handle onto which the Timer Architectural Protocol will be installed\r
-//\r
-EFI_HANDLE  mTimerHandle = NULL;\r
-\r
-//\r
-// The Timer Architectural Protocol that this driver produces\r
-//\r
-EFI_TIMER_ARCH_PROTOCOL  mTimer = {\r
-  TimerDriverRegisterHandler,\r
-  TimerDriverSetTimerPeriod,\r
-  TimerDriverGetTimerPeriod,\r
-  TimerDriverGenerateSoftInterrupt\r
-};\r
-\r
-//\r
-// Pointer to the CPU Architectural Protocol instance\r
-//\r
-EFI_CPU_ARCH_PROTOCOL  *mCpu;\r
-\r
-//\r
-// The notification function to call on every timer interrupt.\r
-// A bug in the compiler prevents us from initializing this here.\r
-//\r
-EFI_TIMER_NOTIFY  mTimerNotifyFunction;\r
-\r
-//\r
-// The current period of the timer interrupt\r
-//\r
-volatile UINT64  mTimerPeriod = 0;\r
-\r
-//\r
-// Worker Functions\r
-//\r
-\r
-/**\r
-  Interrupt Handler.\r
-\r
-  @param InterruptType    The type of interrupt that occurred\r
-  @param SystemContext    A pointer to the system context when the interrupt occurred\r
-**/\r
-VOID\r
-EFIAPI\r
-TimerInterruptHandler (\r
-  IN EFI_EXCEPTION_TYPE  InterruptType,\r
-  IN EFI_SYSTEM_CONTEXT  SystemContext\r
-  )\r
-{\r
-  EFI_TPL  OriginalTPL;\r
-\r
-  OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-\r
-  if (mTimerNotifyFunction != NULL) {\r
-    //\r
-    // @bug : This does not handle missed timer interrupts\r
-    //\r
-    mTimerNotifyFunction (mTimerPeriod);\r
-  }\r
-\r
-  gBS->RestoreTPL (OriginalTPL);\r
-\r
-  DisableInterrupts ();\r
-  SendApicEoi ();\r
-}\r
-\r
-/**\r
-\r
-  This function registers the handler NotifyFunction so it is called every time\r
-  the timer interrupt fires.  It also passes the amount of time since the last\r
-  handler call to the NotifyFunction.  If NotifyFunction is NULL, then the\r
-  handler is unregistered.  If the handler is registered, then EFI_SUCCESS is\r
-  returned.  If the CPU does not support registering a timer interrupt handler,\r
-  then EFI_UNSUPPORTED is returned.  If an attempt is made to register a handler\r
-  when a handler is already registered, then EFI_ALREADY_STARTED is returned.\r
-  If an attempt is made to unregister a handler when a handler is not registered,\r
-  then EFI_INVALID_PARAMETER is returned.  If an error occurs attempting to\r
-  register the NotifyFunction with the timer interrupt, then EFI_DEVICE_ERROR\r
-  is returned.\r
-\r
-\r
-  @param This             The EFI_TIMER_ARCH_PROTOCOL instance.\r
-  @param NotifyFunction   The function to call when a timer interrupt fires.  This\r
-                          function executes at TPL_HIGH_LEVEL.  The DXE Core will\r
-                          register a handler for the timer interrupt, so it can know\r
-                          how much time has passed.  This information is used to\r
-                          signal timer based events.  NULL will unregister the handler.\r
-\r
-  @retval        EFI_SUCCESS            The timer handler was registered.\r
-  @retval        EFI_UNSUPPORTED        The platform does not support timer interrupts.\r
-  @retval        EFI_ALREADY_STARTED    NotifyFunction is not NULL, and a handler is already\r
-                                        registered.\r
-  @retval        EFI_INVALID_PARAMETER  NotifyFunction is NULL, and a handler was not\r
-                                        previously registered.\r
-  @retval        EFI_DEVICE_ERROR       The timer handler could not be registered.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-TimerDriverRegisterHandler (\r
-  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
-  IN EFI_TIMER_NOTIFY         NotifyFunction\r
-  )\r
-{\r
-  //\r
-  // Check for invalid parameters\r
-  //\r
-  if ((NotifyFunction == NULL) && (mTimerNotifyFunction == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((NotifyFunction != NULL) && (mTimerNotifyFunction != NULL)) {\r
-    return EFI_ALREADY_STARTED;\r
-  }\r
-\r
-  mTimerNotifyFunction = NotifyFunction;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-\r
-  This function adjusts the period of timer interrupts to the value specified\r
-  by TimerPeriod.  If the timer period is updated, then the selected timer\r
-  period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned.  If\r
-  the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.\r
-  If an error occurs while attempting to update the timer period, then the\r
-  timer hardware will be put back in its state prior to this call, and\r
-  EFI_DEVICE_ERROR is returned.  If TimerPeriod is 0, then the timer interrupt\r
-  is disabled.  This is not the same as disabling the CPU's interrupts.\r
-  Instead, it must either turn off the timer hardware, or it must adjust the\r
-  interrupt controller so that a CPU interrupt is not generated when the timer\r
-  interrupt fires.\r
-\r
-\r
-  @param This            The EFI_TIMER_ARCH_PROTOCOL instance.\r
-  @param TimerPeriod     The rate to program the timer interrupt in 100 nS units.  If\r
-                         the timer hardware is not programmable, then EFI_UNSUPPORTED is\r
-                         returned.  If the timer is programmable, then the timer period\r
-                         will be rounded up to the nearest timer period that is supported\r
-                         by the timer hardware.  If TimerPeriod is set to 0, then the\r
-                         timer interrupts will be disabled.\r
-\r
-  @retval        EFI_SUCCESS       The timer period was changed.\r
-  @retval        EFI_UNSUPPORTED   The platform cannot change the period of the timer interrupt.\r
-  @retval        EFI_DEVICE_ERROR  The timer period could not be changed due to a device error.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-TimerDriverSetTimerPeriod (\r
-  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
-  IN UINT64                   TimerPeriod\r
-  )\r
-{\r
-  UINT64  TimerCount;\r
-  UINT32  TimerFrequency;\r
-  UINT32  DivideValue = 1;\r
-\r
-  if (TimerPeriod == 0) {\r
-    //\r
-    // Disable timer interrupt for a TimerPeriod of 0\r
-    //\r
-    DisableApicTimerInterrupt ();\r
-  } else {\r
-    TimerFrequency = PcdGet32 (PcdFSBClock) / DivideValue;\r
-\r
-    //\r
-    // Convert TimerPeriod into local APIC counts\r
-    //\r
-    // TimerPeriod is in 100ns\r
-    // TimerPeriod/10000000 will be in seconds.\r
-    TimerCount = DivU64x32 (\r
-                   MultU64x32 (TimerPeriod, TimerFrequency),\r
-                   10000000\r
-                   );\r
-\r
-    // Check for overflow\r
-    if (TimerCount > MAX_UINT32) {\r
-      TimerCount = MAX_UINT32;\r
-      /* TimerPeriod = (MAX_UINT32 / TimerFrequency) * 10000000; */\r
-      TimerPeriod = 429496730;\r
-    }\r
-\r
-    //\r
-    // Program the timer with the new count value\r
-    //\r
-    InitializeApicTimer (DivideValue, (UINT32)TimerCount, TRUE, LOCAL_APIC_TIMER_VECTOR);\r
-\r
-    //\r
-    // Enable timer interrupt\r
-    //\r
-    EnableApicTimerInterrupt ();\r
-  }\r
-\r
-  //\r
-  // Save the new timer period\r
-  //\r
-  mTimerPeriod = TimerPeriod;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-\r
-  This function retrieves the period of timer interrupts in 100 ns units,\r
-  returns that value in TimerPeriod, and returns EFI_SUCCESS.  If TimerPeriod\r
-  is NULL, then EFI_INVALID_PARAMETER is returned.  If a TimerPeriod of 0 is\r
-  returned, then the timer is currently disabled.\r
-\r
-\r
-  @param This            The EFI_TIMER_ARCH_PROTOCOL instance.\r
-  @param TimerPeriod     A pointer to the timer period to retrieve in 100 ns units.  If\r
-                         0 is returned, then the timer is currently disabled.\r
-\r
-  @retval EFI_SUCCESS            The timer period was returned in TimerPeriod.\r
-  @retval EFI_INVALID_PARAMETER  TimerPeriod is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-TimerDriverGetTimerPeriod (\r
-  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
-  OUT UINT64                  *TimerPeriod\r
-  )\r
-{\r
-  if (TimerPeriod == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *TimerPeriod = mTimerPeriod;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-\r
-  This function generates a soft timer interrupt. If the platform does not support soft\r
-  timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned.\r
-  If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler()\r
-  service, then a soft timer interrupt will be generated. If the timer interrupt is\r
-  enabled when this service is called, then the registered handler will be invoked. The\r
-  registered handler should not be able to distinguish a hardware-generated timer\r
-  interrupt from a software-generated timer interrupt.\r
-\r
-\r
-  @param This              The EFI_TIMER_ARCH_PROTOCOL instance.\r
-\r
-  @retval EFI_SUCCESS       The soft timer interrupt was generated.\r
-  @retval EFI_UNSUPPORTED   The platform does not support the generation of soft timer interrupts.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-TimerDriverGenerateSoftInterrupt (\r
-  IN EFI_TIMER_ARCH_PROTOCOL  *This\r
-  )\r
-{\r
-  EFI_TPL  OriginalTPL;\r
-\r
-  if (GetApicTimerInterruptState ()) {\r
-    //\r
-    // Invoke the registered handler\r
-    //\r
-    OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-\r
-    if (mTimerNotifyFunction != NULL) {\r
-      //\r
-      // @bug : This does not handle missed timer interrupts\r
-      //\r
-      mTimerNotifyFunction (mTimerPeriod);\r
-    }\r
-\r
-    gBS->RestoreTPL (OriginalTPL);\r
-  } else {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Initialize the Timer Architectural Protocol driver\r
-\r
-  @param ImageHandle     ImageHandle of the loaded driver\r
-  @param SystemTable     Pointer to the System Table\r
-\r
-  @retval EFI_SUCCESS            Timer Architectural Protocol created\r
-  @retval EFI_OUT_OF_RESOURCES   Not enough resources available to initialize driver.\r
-  @retval EFI_DEVICE_ERROR       A device error occurred attempting to initialize the driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-TimerDriverInitialize (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Initialize the pointer to our notify function.\r
-  //\r
-  mTimerNotifyFunction = NULL;\r
-\r
-  //\r
-  // Make sure the Timer Architectural Protocol is not already installed in the system\r
-  //\r
-  ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiTimerArchProtocolGuid);\r
-\r
-  //\r
-  // Find the CPU architectural protocol.\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&mCpu);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Force the timer to be disabled\r
-  //\r
-  Status = TimerDriverSetTimerPeriod (&mTimer, 0);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Install interrupt handler for Local APIC Timer\r
-  //\r
-  Status = mCpu->RegisterInterruptHandler (\r
-                   mCpu,\r
-                   LOCAL_APIC_TIMER_VECTOR,\r
-                   TimerInterruptHandler\r
-                   );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Force the timer to be enabled at its default period\r
-  //\r
-  Status = TimerDriverSetTimerPeriod (&mTimer, DEFAULT_TIMER_TICK_DURATION);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Install the Timer Architectural Protocol onto a new handle\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &mTimerHandle,\r
-                  &gEfiTimerArchProtocolGuid,\r
-                  &mTimer,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
diff --git a/OvmfPkg/XenTimerDxe/XenTimerDxe.h b/OvmfPkg/XenTimerDxe/XenTimerDxe.h
deleted file mode 100644 (file)
index b55ece0..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-/** @file\r
-  Private data structures\r
-\r
-Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>\r
-Copyright (c) 2019, Citrix Systems, Inc.\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-**/\r
-\r
-#ifndef _TIMER_H_\r
-#define _TIMER_H_\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/Cpu.h>\r
-#include <Protocol/Timer.h>\r
-\r
-#include <Register/LocalApic.h>\r
-\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/LocalApicLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-// The default timer tick duration is set to 10 ms = 100000 100 ns units\r
-//\r
-#define DEFAULT_TIMER_TICK_DURATION  100000\r
-\r
-//\r
-// The Timer Vector use for interrupt\r
-//\r
-#define LOCAL_APIC_TIMER_VECTOR  32\r
-\r
-//\r
-// Function Prototypes\r
-//\r
-\r
-/**\r
-  Initialize the Timer Architectural Protocol driver\r
-\r
-  @param ImageHandle     ImageHandle of the loaded driver\r
-  @param SystemTable     Pointer to the System Table\r
-\r
-  @retval EFI_SUCCESS            Timer Architectural Protocol created\r
-  @retval EFI_OUT_OF_RESOURCES   Not enough resources available to initialize driver.\r
-  @retval EFI_DEVICE_ERROR       A device error occurred attempting to initialize the driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-TimerDriverInitialize (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-;\r
-\r
-/**\r
-\r
-  This function adjusts the period of timer interrupts to the value specified\r
-  by TimerPeriod.  If the timer period is updated, then the selected timer\r
-  period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned.  If\r
-  the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.\r
-  If an error occurs while attempting to update the timer period, then the\r
-  timer hardware will be put back in its state prior to this call, and\r
-  EFI_DEVICE_ERROR is returned.  If TimerPeriod is 0, then the timer interrupt\r
-  is disabled.  This is not the same as disabling the CPU's interrupts.\r
-  Instead, it must either turn off the timer hardware, or it must adjust the\r
-  interrupt controller so that a CPU interrupt is not generated when the timer\r
-  interrupt fires.\r
-\r
-\r
-  @param This            The EFI_TIMER_ARCH_PROTOCOL instance.\r
-  @param NotifyFunction  The rate to program the timer interrupt in 100 nS units.  If\r
-                         the timer hardware is not programmable, then EFI_UNSUPPORTED is\r
-                         returned.  If the timer is programmable, then the timer period\r
-                         will be rounded up to the nearest timer period that is supported\r
-                         by the timer hardware.  If TimerPeriod is set to 0, then the\r
-                         timer interrupts will be disabled.\r
-\r
-  @retval        EFI_SUCCESS       The timer period was changed.\r
-  @retval        EFI_UNSUPPORTED   The platform cannot change the period of the timer interrupt.\r
-  @retval        EFI_DEVICE_ERROR  The timer period could not be changed due to a device error.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-TimerDriverRegisterHandler (\r
-  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
-  IN EFI_TIMER_NOTIFY         NotifyFunction\r
-  )\r
-;\r
-\r
-/**\r
-\r
-  This function adjusts the period of timer interrupts to the value specified\r
-  by TimerPeriod.  If the timer period is updated, then the selected timer\r
-  period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned.  If\r
-  the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.\r
-  If an error occurs while attempting to update the timer period, then the\r
-  timer hardware will be put back in its state prior to this call, and\r
-  EFI_DEVICE_ERROR is returned.  If TimerPeriod is 0, then the timer interrupt\r
-  is disabled.  This is not the same as disabling the CPU's interrupts.\r
-  Instead, it must either turn off the timer hardware, or it must adjust the\r
-  interrupt controller so that a CPU interrupt is not generated when the timer\r
-  interrupt fires.\r
-\r
-\r
-  @param This            The EFI_TIMER_ARCH_PROTOCOL instance.\r
-  @param TimerPeriod     The rate to program the timer interrupt in 100 nS units.  If\r
-                         the timer hardware is not programmable, then EFI_UNSUPPORTED is\r
-                         returned.  If the timer is programmable, then the timer period\r
-                         will be rounded up to the nearest timer period that is supported\r
-                         by the timer hardware.  If TimerPeriod is set to 0, then the\r
-                         timer interrupts will be disabled.\r
-\r
-  @retval        EFI_SUCCESS       The timer period was changed.\r
-  @retval        EFI_UNSUPPORTED   The platform cannot change the period of the timer interrupt.\r
-  @retval        EFI_DEVICE_ERROR  The timer period could not be changed due to a device error.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-TimerDriverSetTimerPeriod (\r
-  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
-  IN UINT64                   TimerPeriod\r
-  )\r
-;\r
-\r
-/**\r
-\r
-  This function retrieves the period of timer interrupts in 100 ns units,\r
-  returns that value in TimerPeriod, and returns EFI_SUCCESS.  If TimerPeriod\r
-  is NULL, then EFI_INVALID_PARAMETER is returned.  If a TimerPeriod of 0 is\r
-  returned, then the timer is currently disabled.\r
-\r
-\r
-  @param This            The EFI_TIMER_ARCH_PROTOCOL instance.\r
-  @param TimerPeriod     A pointer to the timer period to retrieve in 100 ns units.  If\r
-                         0 is returned, then the timer is currently disabled.\r
-\r
-  @retval EFI_SUCCESS            The timer period was returned in TimerPeriod.\r
-  @retval EFI_INVALID_PARAMETER  TimerPeriod is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-TimerDriverGetTimerPeriod (\r
-  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
-  OUT UINT64                  *TimerPeriod\r
-  )\r
-;\r
-\r
-/**\r
-\r
-  This function generates a soft timer interrupt. If the platform does not support soft\r
-  timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned.\r
-  If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler()\r
-  service, then a soft timer interrupt will be generated. If the timer interrupt is\r
-  enabled when this service is called, then the registered handler will be invoked. The\r
-  registered handler should not be able to distinguish a hardware-generated timer\r
-  interrupt from a software-generated timer interrupt.\r
-\r
-\r
-  @param This              The EFI_TIMER_ARCH_PROTOCOL instance.\r
-\r
-  @retval EFI_SUCCESS       The soft timer interrupt was generated.\r
-  @retval EFI_UNSUPPORTED   The platform does not support the generation of soft timer interrupts.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-TimerDriverGenerateSoftInterrupt (\r
-  IN EFI_TIMER_ARCH_PROTOCOL  *This\r
-  )\r
-;\r
-\r
-#endif\r
diff --git a/OvmfPkg/XenTimerDxe/XenTimerDxe.inf b/OvmfPkg/XenTimerDxe/XenTimerDxe.inf
deleted file mode 100644 (file)
index add1d01..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-## @file\r
-# Local APIC timer driver that provides Timer Arch protocol.\r
-#\r
-# Copyright (c) 2005 - 2019, Intel Corporation. All rights reserved.<BR>\r
-# Copyright (c) 2019, Citrix Systems, Inc.\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = XenTimerDxe\r
-  FILE_GUID                      = 52fe8196-f9de-4d07-b22f-51f77a0e7c41\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = TimerDriverInitialize\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  UefiCpuPkg/UefiCpuPkg.dec\r
-  OvmfPkg/OvmfPkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiBootServicesTableLib\r
-  BaseLib\r
-  DebugLib\r
-  UefiDriverEntryPoint\r
-  LocalApicLib\r
-\r
-[Sources]\r
-  XenTimerDxe.h\r
-  XenTimerDxe.c\r
-\r
-[Protocols]\r
-  gEfiCpuArchProtocolGuid       ## CONSUMES\r
-  gEfiTimerArchProtocolGuid     ## PRODUCES\r
-[Pcd]\r
-  gEfiMdePkgTokenSpaceGuid.PcdFSBClock  ## CONSUMES\r
-[Depex]\r
-  gEfiCpuArchProtocolGuid\r