]> git.proxmox.com Git - mirror_edk2.git/blobdiff - DuetPkg/PcRtc/Ia32/RealTimeClock.c
Porting Duet module from EDKI to EDKII
[mirror_edk2.git] / DuetPkg / PcRtc / Ia32 / RealTimeClock.c
diff --git a/DuetPkg/PcRtc/Ia32/RealTimeClock.c b/DuetPkg/PcRtc/Ia32/RealTimeClock.c
new file mode 100644 (file)
index 0000000..dc2a79b
--- /dev/null
@@ -0,0 +1,170 @@
+/*++\r
+\r
+Copyright (c) 2005, 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
+Module Name:\r
+  Ia32PcRtc.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+#include "RealTimeClock.h"\r
+\r
+static PC_RTC_MODULE_GLOBALS  mModuleGlobal;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PcRtcEfiGetTime (\r
+  OUT EFI_TIME                *Time,\r
+  OUT  EFI_TIME_CAPABILITIES  *Capabilities\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Time          - TODO: add argument description\r
+  Capabilities  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  return PcRtcGetTime (Time, Capabilities, &mModuleGlobal);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PcRtcEfiSetTime (\r
+  IN EFI_TIME                *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Time  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  return PcRtcSetTime (Time, &mModuleGlobal);\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
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Enabled - TODO: add argument description\r
+  Pending - TODO: add argument description\r
+  Time    - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  return PcRtcGetWakeupTime (Enabled, Pending, Time, &mModuleGlobal);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PcRtcEfiSetWakeupTime (\r
+  IN BOOLEAN      Enabled,\r
+  OUT EFI_TIME    *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Enabled - TODO: add argument description\r
+  Time    - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  return PcRtcSetWakeupTime (Enabled, Time, &mModuleGlobal);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeRealTimeClock (\r
+  IN EFI_HANDLE                            ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                      *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Arguments:\r
+\r
+  \r
+\r
+Returns: \r
+--*/\r
+// TODO:    ImageHandle - add argument and description to function comment\r
+// TODO:    SystemTable - add argument and description to function comment\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  NewHandle;\r
+\r
+\r
+  EfiInitializeLock (&mModuleGlobal.RtcLock, TPL_HIGH_LEVEL);\r
+\r
+  Status = PcRtcInit (&mModuleGlobal);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  SystemTable->RuntimeServices->GetTime       = PcRtcEfiGetTime;\r
+  SystemTable->RuntimeServices->SetTime       = PcRtcEfiSetTime;\r
+  SystemTable->RuntimeServices->GetWakeupTime = PcRtcEfiGetWakeupTime;\r
+  SystemTable->RuntimeServices->SetWakeupTime = PcRtcEfiSetWakeupTime;\r
+\r
+  NewHandle = NULL;\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &NewHandle,\r
+                  &gEfiRealTimeClockArchProtocolGuid,\r
+                  NULL,\r
+                  NULL\r
+                  );\r
+\r
+  return Status;\r
+}\r