| 1 | /** @file\r |
| 2 | Implement EFI RealTimeClock runtime services via RTC Lib.\r |
| 3 | \r |
| 4 | Currently this driver does not support runtime virtual calling.\r |
| 5 | \r |
| 6 | \r |
| 7 | Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r |
| 8 | \r |
| 9 | This program and the accompanying materials\r |
| 10 | are licensed and made available under the terms and conditions of the BSD License\r |
| 11 | which accompanies this distribution. The full text of the license may be found at\r |
| 12 | http://opensource.org/licenses/bsd-license.php\r |
| 13 | \r |
| 14 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
| 15 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r |
| 16 | \r |
| 17 | **/\r |
| 18 | \r |
| 19 | #include <PiDxe.h>\r |
| 20 | #include <Library/UefiLib.h>\r |
| 21 | #include <Library/UefiBootServicesTableLib.h>\r |
| 22 | #include <Library/RealTimeClockLib.h>\r |
| 23 | #include <Protocol/RealTimeClock.h>\r |
| 24 | \r |
| 25 | EFI_HANDLE mHandle = NULL;\r |
| 26 | \r |
| 27 | \r |
| 28 | \r |
| 29 | /**\r |
| 30 | Returns the current time and date information, and the time-keeping capabilities\r |
| 31 | of the hardware platform.\r |
| 32 | \r |
| 33 | @param Time A pointer to storage to receive a snapshot of the current time.\r |
| 34 | @param Capabilities An optional pointer to a buffer to receive the real time clock\r |
| 35 | device's capabilities.\r |
| 36 | \r |
| 37 | @retval EFI_SUCCESS The operation completed successfully.\r |
| 38 | @retval EFI_INVALID_PARAMETER Time is NULL.\r |
| 39 | @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.\r |
| 40 | \r |
| 41 | **/\r |
| 42 | EFI_STATUS\r |
| 43 | EFIAPI\r |
| 44 | GetTime (\r |
| 45 | OUT EFI_TIME *Time,\r |
| 46 | OUT EFI_TIME_CAPABILITIES *Capabilities\r |
| 47 | )\r |
| 48 | {\r |
| 49 | return LibGetTime (Time, Capabilities);\r |
| 50 | }\r |
| 51 | \r |
| 52 | \r |
| 53 | \r |
| 54 | /**\r |
| 55 | Sets the current local time and date information.\r |
| 56 | \r |
| 57 | @param Time A pointer to the current time.\r |
| 58 | \r |
| 59 | @retval EFI_SUCCESS The operation completed successfully.\r |
| 60 | @retval EFI_INVALID_PARAMETER A time field is out of range.\r |
| 61 | @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.\r |
| 62 | \r |
| 63 | **/\r |
| 64 | EFI_STATUS\r |
| 65 | EFIAPI\r |
| 66 | SetTime (\r |
| 67 | IN EFI_TIME *Time\r |
| 68 | )\r |
| 69 | {\r |
| 70 | return LibSetTime (Time);\r |
| 71 | }\r |
| 72 | \r |
| 73 | \r |
| 74 | /**\r |
| 75 | Returns the current wakeup alarm clock setting.\r |
| 76 | \r |
| 77 | @param Enabled Indicates if the alarm is currently enabled or disabled.\r |
| 78 | @param Pending Indicates if the alarm signal is pending and requires acknowledgement.\r |
| 79 | @param Time The current alarm setting.\r |
| 80 | \r |
| 81 | @retval EFI_SUCCESS The alarm settings were returned.\r |
| 82 | @retval EFI_INVALID_PARAMETER Any parameter is NULL.\r |
| 83 | @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.\r |
| 84 | \r |
| 85 | **/\r |
| 86 | EFI_STATUS\r |
| 87 | EFIAPI\r |
| 88 | GetWakeupTime (\r |
| 89 | OUT BOOLEAN *Enabled,\r |
| 90 | OUT BOOLEAN *Pending,\r |
| 91 | OUT EFI_TIME *Time\r |
| 92 | )\r |
| 93 | {\r |
| 94 | return LibGetWakeupTime (Enabled, Pending, Time);\r |
| 95 | }\r |
| 96 | \r |
| 97 | \r |
| 98 | /**\r |
| 99 | Sets the system wakeup alarm clock time.\r |
| 100 | \r |
| 101 | @param Enabled Enable or disable the wakeup alarm.\r |
| 102 | @param Time If Enable is TRUE, the time to set the wakeup alarm for.\r |
| 103 | \r |
| 104 | @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled. If\r |
| 105 | Enable is FALSE, then the wakeup alarm was disabled.\r |
| 106 | @retval EFI_INVALID_PARAMETER A time field is out of range.\r |
| 107 | @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.\r |
| 108 | @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.\r |
| 109 | \r |
| 110 | **/\r |
| 111 | EFI_STATUS\r |
| 112 | EFIAPI\r |
| 113 | SetWakeupTime (\r |
| 114 | IN BOOLEAN Enabled,\r |
| 115 | OUT EFI_TIME *Time\r |
| 116 | )\r |
| 117 | {\r |
| 118 | return LibSetWakeupTime (Enabled, Time);\r |
| 119 | }\r |
| 120 | \r |
| 121 | \r |
| 122 | \r |
| 123 | /**\r |
| 124 | This is the declaration of an EFI image entry point. This can be the entry point to an application\r |
| 125 | written to this specification, an EFI boot service driver, or an EFI runtime driver.\r |
| 126 | \r |
| 127 | @param ImageHandle Handle that identifies the loaded image.\r |
| 128 | @param SystemTable System Table for this image.\r |
| 129 | \r |
| 130 | @retval EFI_SUCCESS The operation completed successfully.\r |
| 131 | \r |
| 132 | **/\r |
| 133 | EFI_STATUS\r |
| 134 | EFIAPI\r |
| 135 | InitializeRealTimeClock (\r |
| 136 | IN EFI_HANDLE ImageHandle,\r |
| 137 | IN EFI_SYSTEM_TABLE *SystemTable\r |
| 138 | )\r |
| 139 | {\r |
| 140 | EFI_STATUS Status;\r |
| 141 | \r |
| 142 | Status = LibRtcInitialize (ImageHandle, SystemTable);\r |
| 143 | if (EFI_ERROR (Status)) {\r |
| 144 | return Status;\r |
| 145 | }\r |
| 146 | \r |
| 147 | SystemTable->RuntimeServices->GetTime = GetTime;\r |
| 148 | SystemTable->RuntimeServices->SetTime = SetTime;\r |
| 149 | SystemTable->RuntimeServices->GetWakeupTime = GetWakeupTime;\r |
| 150 | SystemTable->RuntimeServices->SetWakeupTime = SetWakeupTime;\r |
| 151 | \r |
| 152 | Status = gBS->InstallMultipleProtocolInterfaces (\r |
| 153 | &mHandle,\r |
| 154 | &gEfiRealTimeClockArchProtocolGuid,\r |
| 155 | NULL,\r |
| 156 | NULL\r |
| 157 | );\r |
| 158 | \r |
| 159 | return Status;\r |
| 160 | }\r |
| 161 | \r |