]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: Move XenRealTimeClockLib from ArmVirtPkg
authorAnthony PERARD <anthony.perard@citrix.com>
Tue, 13 Aug 2019 11:31:18 +0000 (12:31 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Wed, 21 Aug 2019 16:03:50 +0000 (18:03 +0200)
Move XenRealTimeClockLib from ArmVirtPkg to OvmfPkg so it can be used
from the OvmfPkg by the following patch, "OvmfPkg/OvmfXen: use
RealTimeClockRuntimeDxe from EmbeddedPkg"

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20190813113119.14804-35-anthony.perard@citrix.com>

ArmVirtPkg/ArmVirtXen.dsc
ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c [deleted file]
ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf [deleted file]
Maintainers.txt
OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c [new file with mode: 0644]
OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf [new file with mode: 0644]

index 79304ee61d6dc1cb8436aa4b75452173337ae22b..1b42a9a813234967e15a9e10e593c3a7ef6b4beb 100644 (file)
@@ -27,7 +27,7 @@
 \r
 [LibraryClasses]\r
   SerialPortLib|OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.inf\r
-  RealTimeClockLib|ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf\r
+  RealTimeClockLib|OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf\r
   XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf\r
 \r
   ArmGenericTimerCounterLib|ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf\r
diff --git a/ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c b/ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
deleted file mode 100644 (file)
index e113bc8..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-/** @file\r
-  Implement EFI RealTimeClock runtime services via Xen shared info page\r
-\r
-  Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>\r
-\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include <Uefi.h>\r
-#include <PiDxe.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-\r
-/**\r
-  Converts Epoch seconds (elapsed since 1970 JANUARY 01, 00:00:00 UTC) to EFI_TIME\r
- **/\r
-STATIC\r
-VOID\r
-EpochToEfiTime (\r
-  IN  UINTN     EpochSeconds,\r
-  OUT EFI_TIME  *Time\r
-  )\r
-{\r
-  UINTN         a;\r
-  UINTN         b;\r
-  UINTN         c;\r
-  UINTN         d;\r
-  UINTN         g;\r
-  UINTN         j;\r
-  UINTN         m;\r
-  UINTN         y;\r
-  UINTN         da;\r
-  UINTN         db;\r
-  UINTN         dc;\r
-  UINTN         dg;\r
-  UINTN         hh;\r
-  UINTN         mm;\r
-  UINTN         ss;\r
-  UINTN         J;\r
-\r
-  J  = (EpochSeconds / 86400) + 2440588;\r
-  j  = J + 32044;\r
-  g  = j / 146097;\r
-  dg = j % 146097;\r
-  c  = (((dg / 36524) + 1) * 3) / 4;\r
-  dc = dg - (c * 36524);\r
-  b  = dc / 1461;\r
-  db = dc % 1461;\r
-  a  = (((db / 365) + 1) * 3) / 4;\r
-  da = db - (a * 365);\r
-  y  = (g * 400) + (c * 100) + (b * 4) + a;\r
-  m  = (((da * 5) + 308) / 153) - 2;\r
-  d  = da - (((m + 4) * 153) / 5) + 122;\r
-\r
-  Time->Year  = y - 4800 + ((m + 2) / 12);\r
-  Time->Month = ((m + 2) % 12) + 1;\r
-  Time->Day   = d + 1;\r
-\r
-  ss = EpochSeconds % 60;\r
-  a  = (EpochSeconds - ss) / 60;\r
-  mm = a % 60;\r
-  b = (a - mm) / 60;\r
-  hh = b % 24;\r
-\r
-  Time->Hour        = hh;\r
-  Time->Minute      = mm;\r
-  Time->Second      = ss;\r
-  Time->Nanosecond  = 0;\r
-\r
-}\r
-\r
-/**\r
-  Returns the current time and date information, and the time-keeping capabilities\r
-  of the hardware platform.\r
-\r
-  @param  Time                  A pointer to storage to receive a snapshot of the current time.\r
-  @param  Capabilities          An optional pointer to a buffer to receive the real time clock\r
-                                device's capabilities.\r
-\r
-  @retval EFI_SUCCESS           The operation completed successfully.\r
-  @retval EFI_INVALID_PARAMETER Time is NULL.\r
-  @retval EFI_DEVICE_ERROR      The time could not be retrieved due to hardware error.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LibGetTime (\r
-  OUT EFI_TIME                *Time,\r
-  OUT  EFI_TIME_CAPABILITIES  *Capabilities\r
-  )\r
-{\r
-  ASSERT (Time != NULL);\r
-\r
-  //\r
-  // For now, there is nothing that we can do besides returning a bogus time,\r
-  // as Xen's timekeeping uses a shared info page which cannot be shared\r
-  // between UEFI and the OS\r
-  //\r
-  EpochToEfiTime(1421770011, Time);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Sets the current local time and date information.\r
-\r
-  @param  Time                  A pointer to the current time.\r
-\r
-  @retval EFI_SUCCESS           The operation completed successfully.\r
-  @retval EFI_INVALID_PARAMETER A time field is out of range.\r
-  @retval EFI_DEVICE_ERROR      The time could not be set due due to hardware error.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LibSetTime (\r
-  IN EFI_TIME                *Time\r
-  )\r
-{\r
-  return EFI_DEVICE_ERROR;\r
-}\r
-\r
-\r
-/**\r
-  Returns the current wakeup alarm clock setting.\r
-\r
-  @param  Enabled               Indicates if the alarm is currently enabled or disabled.\r
-  @param  Pending               Indicates if the alarm signal is pending and requires acknowledgement.\r
-  @param  Time                  The current alarm setting.\r
-\r
-  @retval EFI_SUCCESS           The alarm settings were returned.\r
-  @retval EFI_INVALID_PARAMETER Any parameter is NULL.\r
-  @retval EFI_DEVICE_ERROR      The wakeup time could not be retrieved due to a hardware error.\r
-  @retval EFI_UNSUPPORTED       A wakeup timer is not supported on this platform.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LibGetWakeupTime (\r
-  OUT BOOLEAN     *Enabled,\r
-  OUT BOOLEAN     *Pending,\r
-  OUT EFI_TIME    *Time\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Sets the system wakeup alarm clock time.\r
-\r
-  @param  Enabled               Enable or disable the wakeup alarm.\r
-  @param  Time                  If Enable is TRUE, the time to set the wakeup alarm for.\r
-\r
-  @retval EFI_SUCCESS           If Enable is TRUE, then the wakeup alarm was enabled. If\r
-                                Enable is FALSE, then the wakeup alarm was disabled.\r
-  @retval EFI_INVALID_PARAMETER A time field is out of range.\r
-  @retval EFI_DEVICE_ERROR      The wakeup time could not be set due to a hardware error.\r
-  @retval EFI_UNSUPPORTED       A wakeup timer is not supported on this platform.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LibSetWakeupTime (\r
-  IN BOOLEAN      Enabled,\r
-  OUT EFI_TIME    *Time\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  This is the declaration of an EFI image entry point. This can be the entry point to an application\r
-  written to this specification, an EFI boot service driver, or an EFI runtime driver.\r
-\r
-  @param  ImageHandle           Handle that identifies the loaded image.\r
-  @param  SystemTable           System Table for this image.\r
-\r
-  @retval EFI_SUCCESS           The operation completed successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LibRtcInitialize (\r
-  IN EFI_HANDLE                            ImageHandle,\r
-  IN EFI_SYSTEM_TABLE                      *SystemTable\r
-  )\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf b/ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf
deleted file mode 100644 (file)
index f4b269b..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#/** @file\r
-#\r
-# Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>\r
-#\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-#**/\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = XenRealTimeClockLib\r
-  FILE_GUID                      = EC2557E8-7005-430B-9F6F-9BA109698248\r
-  MODULE_TYPE                    = BASE\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = RealTimeClockLib|DXE_CORE DXE_DRIVER UEFI_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION\r
-\r
-[Sources.common]\r
-  XenRealTimeClockLib.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  OvmfPkg/OvmfPkg.dec\r
-  EmbeddedPkg/EmbeddedPkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiLib\r
-  DebugLib\r
-  DxeServicesTableLib\r
-  UefiRuntimeLib\r
-\r
-[Guids]\r
-  gEfiEventVirtualAddressChangeGuid\r
index 79defd13bf81513374f2d826aa45335bfd7a3718..919baccc561e3bf15fbab2a70dde8cbf7e789350 100644 (file)
@@ -114,7 +114,6 @@ R: Leif Lindholm <leif.lindholm@linaro.org>
 ArmVirtPkg: modules used on Xen\r
 F: ArmVirtPkg/ArmVirtXen.*\r
 F: ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/\r
-F: ArmVirtPkg/Library/XenRealTimeClockLib/\r
 F: ArmVirtPkg/Library/XenVirtMemInfoLib/\r
 F: ArmVirtPkg/PrePi/\r
 F: ArmVirtPkg/XenAcpiPlatformDxe/\r
@@ -374,6 +373,7 @@ F: OvmfPkg/Library/XenConsoleSerialPortLib/
 F: OvmfPkg/Library/XenHypercallLib/\r
 F: OvmfPkg/Library/XenIoMmioLib/\r
 F: OvmfPkg/Library/XenPlatformLib/\r
+F: OvmfPkg/Library/XenRealTimeClockLib/\r
 F: OvmfPkg/OvmfXen.*\r
 F: OvmfPkg/OvmfXenElfHeaderGenerator.c\r
 F: OvmfPkg/PlatformPei/MemDetect.c\r
diff --git a/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c b/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
new file mode 100644 (file)
index 0000000..e113bc8
--- /dev/null
@@ -0,0 +1,190 @@
+/** @file\r
+  Implement EFI RealTimeClock runtime services via Xen shared info page\r
+\r
+  Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <Uefi.h>\r
+#include <PiDxe.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+/**\r
+  Converts Epoch seconds (elapsed since 1970 JANUARY 01, 00:00:00 UTC) to EFI_TIME\r
+ **/\r
+STATIC\r
+VOID\r
+EpochToEfiTime (\r
+  IN  UINTN     EpochSeconds,\r
+  OUT EFI_TIME  *Time\r
+  )\r
+{\r
+  UINTN         a;\r
+  UINTN         b;\r
+  UINTN         c;\r
+  UINTN         d;\r
+  UINTN         g;\r
+  UINTN         j;\r
+  UINTN         m;\r
+  UINTN         y;\r
+  UINTN         da;\r
+  UINTN         db;\r
+  UINTN         dc;\r
+  UINTN         dg;\r
+  UINTN         hh;\r
+  UINTN         mm;\r
+  UINTN         ss;\r
+  UINTN         J;\r
+\r
+  J  = (EpochSeconds / 86400) + 2440588;\r
+  j  = J + 32044;\r
+  g  = j / 146097;\r
+  dg = j % 146097;\r
+  c  = (((dg / 36524) + 1) * 3) / 4;\r
+  dc = dg - (c * 36524);\r
+  b  = dc / 1461;\r
+  db = dc % 1461;\r
+  a  = (((db / 365) + 1) * 3) / 4;\r
+  da = db - (a * 365);\r
+  y  = (g * 400) + (c * 100) + (b * 4) + a;\r
+  m  = (((da * 5) + 308) / 153) - 2;\r
+  d  = da - (((m + 4) * 153) / 5) + 122;\r
+\r
+  Time->Year  = y - 4800 + ((m + 2) / 12);\r
+  Time->Month = ((m + 2) % 12) + 1;\r
+  Time->Day   = d + 1;\r
+\r
+  ss = EpochSeconds % 60;\r
+  a  = (EpochSeconds - ss) / 60;\r
+  mm = a % 60;\r
+  b = (a - mm) / 60;\r
+  hh = b % 24;\r
+\r
+  Time->Hour        = hh;\r
+  Time->Minute      = mm;\r
+  Time->Second      = ss;\r
+  Time->Nanosecond  = 0;\r
+\r
+}\r
+\r
+/**\r
+  Returns the current time and date information, and the time-keeping capabilities\r
+  of the hardware platform.\r
+\r
+  @param  Time                  A pointer to storage to receive a snapshot of the current time.\r
+  @param  Capabilities          An optional pointer to a buffer to receive the real time clock\r
+                                device's capabilities.\r
+\r
+  @retval EFI_SUCCESS           The operation completed successfully.\r
+  @retval EFI_INVALID_PARAMETER Time is NULL.\r
+  @retval EFI_DEVICE_ERROR      The time could not be retrieved due to hardware error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LibGetTime (\r
+  OUT EFI_TIME                *Time,\r
+  OUT  EFI_TIME_CAPABILITIES  *Capabilities\r
+  )\r
+{\r
+  ASSERT (Time != NULL);\r
+\r
+  //\r
+  // For now, there is nothing that we can do besides returning a bogus time,\r
+  // as Xen's timekeeping uses a shared info page which cannot be shared\r
+  // between UEFI and the OS\r
+  //\r
+  EpochToEfiTime(1421770011, Time);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Sets the current local time and date information.\r
+\r
+  @param  Time                  A pointer to the current time.\r
+\r
+  @retval EFI_SUCCESS           The operation completed successfully.\r
+  @retval EFI_INVALID_PARAMETER A time field is out of range.\r
+  @retval EFI_DEVICE_ERROR      The time could not be set due due to hardware error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LibSetTime (\r
+  IN EFI_TIME                *Time\r
+  )\r
+{\r
+  return EFI_DEVICE_ERROR;\r
+}\r
+\r
+\r
+/**\r
+  Returns the current wakeup alarm clock setting.\r
+\r
+  @param  Enabled               Indicates if the alarm is currently enabled or disabled.\r
+  @param  Pending               Indicates if the alarm signal is pending and requires acknowledgement.\r
+  @param  Time                  The current alarm setting.\r
+\r
+  @retval EFI_SUCCESS           The alarm settings were returned.\r
+  @retval EFI_INVALID_PARAMETER Any parameter is NULL.\r
+  @retval EFI_DEVICE_ERROR      The wakeup time could not be retrieved due to a hardware error.\r
+  @retval EFI_UNSUPPORTED       A wakeup timer is not supported on this platform.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LibGetWakeupTime (\r
+  OUT BOOLEAN     *Enabled,\r
+  OUT BOOLEAN     *Pending,\r
+  OUT EFI_TIME    *Time\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Sets the system wakeup alarm clock time.\r
+\r
+  @param  Enabled               Enable or disable the wakeup alarm.\r
+  @param  Time                  If Enable is TRUE, the time to set the wakeup alarm for.\r
+\r
+  @retval EFI_SUCCESS           If Enable is TRUE, then the wakeup alarm was enabled. If\r
+                                Enable is FALSE, then the wakeup alarm was disabled.\r
+  @retval EFI_INVALID_PARAMETER A time field is out of range.\r
+  @retval EFI_DEVICE_ERROR      The wakeup time could not be set due to a hardware error.\r
+  @retval EFI_UNSUPPORTED       A wakeup timer is not supported on this platform.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LibSetWakeupTime (\r
+  IN BOOLEAN      Enabled,\r
+  OUT EFI_TIME    *Time\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  This is the declaration of an EFI image entry point. This can be the entry point to an application\r
+  written to this specification, an EFI boot service driver, or an EFI runtime driver.\r
+\r
+  @param  ImageHandle           Handle that identifies the loaded image.\r
+  @param  SystemTable           System Table for this image.\r
+\r
+  @retval EFI_SUCCESS           The operation completed successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LibRtcInitialize (\r
+  IN EFI_HANDLE                            ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                      *SystemTable\r
+  )\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf b/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf
new file mode 100644 (file)
index 0000000..f4b269b
--- /dev/null
@@ -0,0 +1,33 @@
+#/** @file\r
+#\r
+# Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>\r
+#\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+#\r
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = XenRealTimeClockLib\r
+  FILE_GUID                      = EC2557E8-7005-430B-9F6F-9BA109698248\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = RealTimeClockLib|DXE_CORE DXE_DRIVER UEFI_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION\r
+\r
+[Sources.common]\r
+  XenRealTimeClockLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  OvmfPkg/OvmfPkg.dec\r
+  EmbeddedPkg/EmbeddedPkg.dec\r
+\r
+[LibraryClasses]\r
+  UefiLib\r
+  DebugLib\r
+  DxeServicesTableLib\r
+  UefiRuntimeLib\r
+\r
+[Guids]\r
+  gEfiEventVirtualAddressChangeGuid\r