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