]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c
Move Ia32PcRtc.c from IA-32 sub-directory and rename to PcRtcEntry.c since IPF is...
[mirror_edk2.git] / MdeModulePkg / Universal / PcatRealTimeClockRuntimeDxe / PcRtcEntry.c
diff --git a/MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c b/MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c
new file mode 100644 (file)
index 0000000..ce3fa90
--- /dev/null
@@ -0,0 +1,158 @@
+/** @file\r
+  Provides Set/Get time operations.\r
+\r
+Copyright (c) 2006 - 2008, Intel Corporation\r
+All rights reserved. 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
+\r
+**/\r
+\r
+#include "PcRtc.h"\r
+\r
+PC_RTC_MODULE_GLOBALS  mModuleGlobal;\r
+\r
+EFI_HANDLE             mHandle = NULL;\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\r
+                        clock 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
+PcRtcEfiGetTime (\r
+  OUT EFI_TIME                *Time,\r
+  OUT EFI_TIME_CAPABILITIES   *Capabilities  OPTIONAL\r
+  )\r
+{\r
+  return PcRtcGetTime (Time, Capabilities, &mModuleGlobal);\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
+PcRtcEfiSetTime (\r
+  IN EFI_TIME                *Time\r
+  )\r
+{\r
+  return PcRtcSetTime (Time, &mModuleGlobal);\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 Enabled is NULL.\r
+  @retval EFI_INVALID_PARAMETER Pending is NULL.\r
+  @retval EFI_INVALID_PARAMETER Time 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
+PcRtcEfiGetWakeupTime (\r
+  OUT BOOLEAN     *Enabled,\r
+  OUT BOOLEAN     *Pending,\r
+  OUT EFI_TIME    *Time\r
+  )\r
+{\r
+  return PcRtcGetWakeupTime (Enabled, Pending, Time, &mModuleGlobal);\r
+}\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
+                   If Enable is FALSE, then this parameter is optional, and may be NULL.\r
+\r
+  @retval EFI_SUCCESS            If Enable is TRUE, then the wakeup alarm was enabled.\r
+                                 If 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
+PcRtcEfiSetWakeupTime (\r
+  IN BOOLEAN      Enabled,\r
+  IN EFI_TIME    *Time       OPTIONAL\r
+  )\r
+{\r
+  return PcRtcSetWakeupTime (Enabled, Time, &mModuleGlobal);\r
+}\r
+\r
+/**\r
+  The user Entry Point for PcRTC module.\r
+\r
+  This is the entrhy point for PcRTC module. It installs the UEFI runtime service\r
+  including GetTime(),SetTime(),GetWakeupTime(),and SetWakeupTime().\r
+\r
+  @param  ImageHandle    The firmware allocated handle for the EFI image.\r
+  @param  SystemTable    A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS    The entry point is executed successfully.\r
+  @retval Others         Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializePcRtc (\r
+  IN EFI_HANDLE                            ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                      *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  EfiInitializeLock (&mModuleGlobal.RtcLock, TPL_HIGH_LEVEL);\r
+\r
+  Status = PcRtcInit (&mModuleGlobal);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  gRT->GetTime       = PcRtcEfiGetTime;\r
+  gRT->SetTime       = PcRtcEfiSetTime;\r
+  gRT->GetWakeupTime = PcRtcEfiGetWakeupTime;\r
+  gRT->SetWakeupTime = PcRtcEfiSetWakeupTime;\r
+\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &mHandle,\r
+                  &gEfiRealTimeClockArchProtocolGuid,\r
+                  NULL,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r