]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c
PcAtChipsetPkg/Rtc: Fix a UEFI Win7 boot hang issue
[mirror_edk2.git] / PcAtChipsetPkg / PcatRealTimeClockRuntimeDxe / PcRtcEntry.c
... / ...
CommitLineData
1/** @file\r
2 Provides Set/Get time operations.\r
3\r
4Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
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
12\r
13**/\r
14\r
15#include "PcRtc.h"\r
16\r
17PC_RTC_MODULE_GLOBALS mModuleGlobal = { 0 };\r
18\r
19EFI_HANDLE mHandle = NULL;\r
20\r
21/**\r
22 Returns the current time and date information, and the time-keeping capabilities\r
23 of the hardware platform.\r
24\r
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
28\r
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
32\r
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
40{\r
41 return PcRtcGetTime (Time, Capabilities, &mModuleGlobal);\r
42}\r
43\r
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
54EFI_STATUS\r
55EFIAPI\r
56PcRtcEfiSetTime (\r
57 IN EFI_TIME *Time\r
58 )\r
59{\r
60 return PcRtcSetTime (Time, &mModuleGlobal);\r
61}\r
62\r
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
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
85{\r
86 return PcRtcGetWakeupTime (Enabled, Pending, Time, &mModuleGlobal);\r
87}\r
88\r
89\r
90/**\r
91 Sets the system wakeup alarm clock time.\r
92\r
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
96\r
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
102\r
103**/\r
104EFI_STATUS\r
105EFIAPI\r
106PcRtcEfiSetWakeupTime (\r
107 IN BOOLEAN Enabled,\r
108 IN EFI_TIME *Time OPTIONAL\r
109 )\r
110{\r
111 return PcRtcSetWakeupTime (Enabled, Time, &mModuleGlobal);\r
112}\r
113\r
114/**\r
115 The user Entry Point for PcRTC module.\r
116\r
117 This is the entrhy point for PcRTC module. It installs the UEFI runtime service\r
118 including GetTime(),SetTime(),GetWakeupTime(),and SetWakeupTime().\r
119\r
120 @param ImageHandle The firmware allocated handle for the EFI image.\r
121 @param SystemTable A pointer to the EFI System Table.\r
122\r
123 @retval EFI_SUCCESS The entry point is executed successfully.\r
124 @retval Others Some error occurs when executing this entry point.\r
125\r
126**/\r
127EFI_STATUS\r
128EFIAPI\r
129InitializePcRtc (\r
130 IN EFI_HANDLE ImageHandle,\r
131 IN EFI_SYSTEM_TABLE *SystemTable\r
132 )\r
133{\r
134 EFI_STATUS Status;\r
135 EFI_EVENT Event;\r
136\r
137 EfiInitializeLock (&mModuleGlobal.RtcLock, TPL_CALLBACK);\r
138\r
139 Status = PcRtcInit (&mModuleGlobal);\r
140 ASSERT_EFI_ERROR (Status);\r
141 \r
142 Status = gBS->CreateEventEx (\r
143 EVT_NOTIFY_SIGNAL,\r
144 TPL_CALLBACK,\r
145 PcRtcAcpiTableChangeCallback,\r
146 NULL,\r
147 &gEfiAcpi10TableGuid,\r
148 &Event\r
149 );\r
150 ASSERT_EFI_ERROR (Status);\r
151 \r
152 Status = gBS->CreateEventEx (\r
153 EVT_NOTIFY_SIGNAL,\r
154 TPL_CALLBACK,\r
155 PcRtcAcpiTableChangeCallback,\r
156 NULL,\r
157 &gEfiAcpiTableGuid,\r
158 &Event\r
159 );\r
160 ASSERT_EFI_ERROR (Status);\r
161\r
162 gRT->GetTime = PcRtcEfiGetTime;\r
163 gRT->SetTime = PcRtcEfiSetTime;\r
164 gRT->GetWakeupTime = PcRtcEfiGetWakeupTime;\r
165 gRT->SetWakeupTime = PcRtcEfiSetWakeupTime;\r
166\r
167 Status = gBS->InstallMultipleProtocolInterfaces (\r
168 &mHandle,\r
169 &gEfiRealTimeClockArchProtocolGuid,\r
170 NULL,\r
171 NULL\r
172 );\r
173 ASSERT_EFI_ERROR (Status);\r
174\r
175 return Status;\r
176}\r