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