]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Provides Set/Get time operations.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include "PcRtc.h"\r | |
16 | \r | |
17 | PC_RTC_MODULE_GLOBALS mModuleGlobal;\r | |
18 | \r | |
19 | EFI_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 | |
34 | EFI_STATUS\r | |
35 | EFIAPI\r | |
36 | PcRtcEfiGetTime (\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 | |
54 | EFI_STATUS\r | |
55 | EFIAPI\r | |
56 | PcRtcEfiSetTime (\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 | |
78 | EFI_STATUS\r | |
79 | EFIAPI\r | |
80 | PcRtcEfiGetWakeupTime (\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 | |
104 | EFI_STATUS\r | |
105 | EFIAPI\r | |
106 | PcRtcEfiSetWakeupTime (\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 | |
127 | EFI_STATUS\r | |
128 | EFIAPI\r | |
129 | InitializePcRtc (\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 | mModuleGlobal.CenturyRtcAddress = GetCenturyRtcAddress ();\r | |
139 | \r | |
140 | Status = PcRtcInit (&mModuleGlobal);\r | |
141 | ASSERT_EFI_ERROR (Status);\r | |
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 | |
162 | \r | |
163 | gRT->GetTime = PcRtcEfiGetTime;\r | |
164 | gRT->SetTime = PcRtcEfiSetTime;\r | |
165 | gRT->GetWakeupTime = PcRtcEfiGetWakeupTime;\r | |
166 | gRT->SetWakeupTime = PcRtcEfiSetWakeupTime;\r | |
167 | \r | |
168 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
169 | &mHandle,\r | |
170 | &gEfiRealTimeClockArchProtocolGuid,\r | |
171 | NULL,\r | |
172 | NULL\r | |
173 | );\r | |
174 | ASSERT_EFI_ERROR (Status);\r | |
175 | \r | |
176 | return Status;\r | |
177 | }\r |