]> git.proxmox.com Git - mirror_edk2.git/blame - PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c
NetworkPkg: Clean up source files
[mirror_edk2.git] / PcAtChipsetPkg / PcatRealTimeClockRuntimeDxe / PcRtcEntry.c
CommitLineData
fb0b259e 1/** @file\r
2 Provides Set/Get time operations.\r
8cd4d17c 3\r
e38ab18a 4Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
95d48e82 5This program and the accompanying materials\r
3cfb790c 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
8cd4d17c 12\r
fb0b259e 13**/\r
8cd4d17c 14\r
15#include "PcRtc.h"\r
16\r
689b78c8 17PC_RTC_MODULE_GLOBALS mModuleGlobal;\r
8cd4d17c 18\r
8d85dc31 19EFI_HANDLE mHandle = NULL;\r
8cd4d17c 20\r
8d85dc31 21/**\r
22 Returns the current time and date information, and the time-keeping capabilities\r
23 of the hardware platform.\r
8cd4d17c 24\r
8d85dc31 25 @param Time A pointer to storage to receive a snapshot of the current time.\r
26 @param Capabilities An optional pointer to a buffer to receive the real time\r
27 clock device's capabilities.\r
8cd4d17c 28\r
8d85dc31 29 @retval EFI_SUCCESS The operation completed successfully.\r
30 @retval EFI_INVALID_PARAMETER Time is NULL.\r
31 @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.\r
8cd4d17c 32\r
8d85dc31 33**/\r
34EFI_STATUS\r
35EFIAPI\r
36PcRtcEfiGetTime (\r
37 OUT EFI_TIME *Time,\r
38 OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL\r
39 )\r
8cd4d17c 40{\r
41 return PcRtcGetTime (Time, Capabilities, &mModuleGlobal);\r
42}\r
43\r
8d85dc31 44/**\r
45 Sets the current local time and date information.\r
46\r
47 @param Time A pointer to the current time.\r
48\r
49 @retval EFI_SUCCESS The operation completed successfully.\r
50 @retval EFI_INVALID_PARAMETER A time field is out of range.\r
51 @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.\r
52\r
53**/\r
8cd4d17c 54EFI_STATUS\r
55EFIAPI\r
56PcRtcEfiSetTime (\r
57 IN EFI_TIME *Time\r
58 )\r
8cd4d17c 59{\r
60 return PcRtcSetTime (Time, &mModuleGlobal);\r
61}\r
62\r
8d85dc31 63/**\r
64 Returns the current wakeup alarm clock setting.\r
65\r
66 @param Enabled Indicates if the alarm is currently enabled or disabled.\r
67 @param Pending Indicates if the alarm signal is pending and requires acknowledgement.\r
68 @param Time The current alarm setting.\r
69\r
70 @retval EFI_SUCCESS The alarm settings were returned.\r
71 @retval EFI_INVALID_PARAMETER Enabled is NULL.\r
72 @retval EFI_INVALID_PARAMETER Pending is NULL.\r
73 @retval EFI_INVALID_PARAMETER Time is NULL.\r
74 @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.\r
75 @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.\r
76\r
77**/\r
8cd4d17c 78EFI_STATUS\r
79EFIAPI\r
80PcRtcEfiGetWakeupTime (\r
81 OUT BOOLEAN *Enabled,\r
82 OUT BOOLEAN *Pending,\r
83 OUT EFI_TIME *Time\r
84 )\r
8d85dc31 85{\r
86 return PcRtcGetWakeupTime (Enabled, Pending, Time, &mModuleGlobal);\r
87}\r
8cd4d17c 88\r
8cd4d17c 89\r
8d85dc31 90/**\r
91 Sets the system wakeup alarm clock time.\r
8cd4d17c 92\r
8d85dc31 93 @param Enabled Enable or disable the wakeup alarm.\r
94 @param Time If Enable is TRUE, the time to set the wakeup alarm for.\r
95 If Enable is FALSE, then this parameter is optional, and may be NULL.\r
8cd4d17c 96\r
8d85dc31 97 @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled.\r
98 If Enable is FALSE, then the wakeup alarm was disabled.\r
99 @retval EFI_INVALID_PARAMETER A time field is out of range.\r
100 @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.\r
101 @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.\r
8cd4d17c 102\r
8d85dc31 103**/\r
8cd4d17c 104EFI_STATUS\r
105EFIAPI\r
106PcRtcEfiSetWakeupTime (\r
107 IN BOOLEAN Enabled,\r
8d85dc31 108 IN EFI_TIME *Time OPTIONAL\r
8cd4d17c 109 )\r
8d85dc31 110{\r
111 return PcRtcSetWakeupTime (Enabled, Time, &mModuleGlobal);\r
112}\r
8cd4d17c 113\r
8d85dc31 114/**\r
115 The user Entry Point for PcRTC module.\r
8cd4d17c 116\r
8d85dc31 117 This is the entrhy point for PcRTC module. It installs the UEFI runtime service\r
118 including GetTime(),SetTime(),GetWakeupTime(),and SetWakeupTime().\r
8cd4d17c 119\r
8d85dc31 120 @param ImageHandle The firmware allocated handle for the EFI image.\r
121 @param SystemTable A pointer to the EFI System Table.\r
8cd4d17c 122\r
8d85dc31 123 @retval EFI_SUCCESS The entry point is executed successfully.\r
124 @retval Others Some error occurs when executing this entry point.\r
8cd4d17c 125\r
8d85dc31 126**/\r
8cd4d17c 127EFI_STATUS\r
128EFIAPI\r
129InitializePcRtc (\r
130 IN EFI_HANDLE ImageHandle,\r
131 IN EFI_SYSTEM_TABLE *SystemTable\r
132 )\r
8cd4d17c 133{\r
134 EFI_STATUS Status;\r
41628cbc 135 EFI_EVENT Event;\r
8cd4d17c 136\r
7018623c 137 EfiInitializeLock (&mModuleGlobal.RtcLock, TPL_CALLBACK);\r
e38ab18a 138 mModuleGlobal.CenturyRtcAddress = GetCenturyRtcAddress ();\r
8cd4d17c 139\r
140 Status = PcRtcInit (&mModuleGlobal);\r
6ff84d99 141 ASSERT_EFI_ERROR (Status);\r
41628cbc
RN
142 \r
143 Status = gBS->CreateEventEx (\r
144 EVT_NOTIFY_SIGNAL,\r
145 TPL_CALLBACK,\r
146 PcRtcAcpiTableChangeCallback,\r
147 NULL,\r
148 &gEfiAcpi10TableGuid,\r
149 &Event\r
150 );\r
151 ASSERT_EFI_ERROR (Status);\r
152 \r
153 Status = gBS->CreateEventEx (\r
154 EVT_NOTIFY_SIGNAL,\r
155 TPL_CALLBACK,\r
156 PcRtcAcpiTableChangeCallback,\r
157 NULL,\r
158 &gEfiAcpiTableGuid,\r
159 &Event\r
160 );\r
161 ASSERT_EFI_ERROR (Status);\r
8cd4d17c 162\r
163 gRT->GetTime = PcRtcEfiGetTime;\r
164 gRT->SetTime = PcRtcEfiSetTime;\r
165 gRT->GetWakeupTime = PcRtcEfiGetWakeupTime;\r
166 gRT->SetWakeupTime = PcRtcEfiSetWakeupTime;\r
167\r
8cd4d17c 168 Status = gBS->InstallMultipleProtocolInterfaces (\r
8d85dc31 169 &mHandle,\r
8cd4d17c 170 &gEfiRealTimeClockArchProtocolGuid,\r
171 NULL,\r
172 NULL\r
173 );\r
8d85dc31 174 ASSERT_EFI_ERROR (Status);\r
8cd4d17c 175\r
176 return Status;\r
177}\r