TianoCore EDK2 master
Loading...
Searching...
No Matches
PcRtcEntry.c
Go to the documentation of this file.
1
11#include "PcRtc.h"
12
13PC_RTC_MODULE_GLOBALS mModuleGlobal;
14
16
17STATIC EFI_EVENT mVirtualAddrChangeEvent;
18
19UINTN mRtcIndexRegister;
20UINTN mRtcTargetRegister;
21UINT16 mRtcDefaultYear;
22UINT16 mMinimalValidYear;
23UINT16 mMaximalValidYear;
24
39EFIAPI
41 OUT EFI_TIME *Time,
42 OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
43 )
44{
45 return PcRtcGetTime (Time, Capabilities, &mModuleGlobal);
46}
47
59EFIAPI
61 IN EFI_TIME *Time
62 )
63{
64 return PcRtcSetTime (Time, &mModuleGlobal);
65}
66
83EFIAPI
85 OUT BOOLEAN *Enabled,
86 OUT BOOLEAN *Pending,
87 OUT EFI_TIME *Time
88 )
89{
90 return PcRtcGetWakeupTime (Enabled, Pending, Time, &mModuleGlobal);
91}
92
108EFIAPI
110 IN BOOLEAN Enabled,
111 IN EFI_TIME *Time OPTIONAL
112 )
113{
114 return PcRtcSetWakeupTime (Enabled, Time, &mModuleGlobal);
115}
116
125STATIC
126VOID
127EFIAPI
129 IN EFI_EVENT Event,
130 IN VOID *Context
131 )
132{
133 // Only needed if you are going to support the OS calling RTC functions in
134 // virtual mode. You will need to call EfiConvertPointer (). To convert any
135 // stored physical addresses to virtual address. After the OS transitions to
136 // calling in virtual mode, all future runtime calls will be made in virtual
137 // mode.
138 EfiConvertPointer (0x0, (VOID **)&mRtcIndexRegister);
139 EfiConvertPointer (0x0, (VOID **)&mRtcTargetRegister);
140}
141
156EFIAPI
158 IN EFI_HANDLE ImageHandle,
159 IN EFI_SYSTEM_TABLE *SystemTable
160 )
161{
162 EFI_STATUS Status;
163 EFI_EVENT Event;
164
165 EfiInitializeLock (&mModuleGlobal.RtcLock, TPL_CALLBACK);
166 mModuleGlobal.CenturyRtcAddress = GetCenturyRtcAddress ();
167
168 if (FeaturePcdGet (PcdRtcUseMmio)) {
169 mRtcIndexRegister = (UINTN)PcdGet64 (PcdRtcIndexRegister64);
170 mRtcTargetRegister = (UINTN)PcdGet64 (PcdRtcTargetRegister64);
171 } else {
172 mRtcIndexRegister = (UINTN)PcdGet8 (PcdRtcIndexRegister);
173 mRtcTargetRegister = (UINTN)PcdGet8 (PcdRtcTargetRegister);
174 }
175
176 mRtcDefaultYear = PcdGet16 (PcdRtcDefaultYear);
177 mMinimalValidYear = PcdGet16 (PcdMinimalValidYear);
178 mMaximalValidYear = PcdGet16 (PcdMaximalValidYear);
179
180 Status = PcRtcInit (&mModuleGlobal);
181 ASSERT_EFI_ERROR (Status);
182
183 Status = gBS->CreateEventEx (
184 EVT_NOTIFY_SIGNAL,
185 TPL_CALLBACK,
187 NULL,
188 &gEfiAcpi10TableGuid,
189 &Event
190 );
191 ASSERT_EFI_ERROR (Status);
192
193 Status = gBS->CreateEventEx (
194 EVT_NOTIFY_SIGNAL,
195 TPL_CALLBACK,
197 NULL,
198 &gEfiAcpiTableGuid,
199 &Event
200 );
201 ASSERT_EFI_ERROR (Status);
202
203 gRT->GetTime = PcRtcEfiGetTime;
204 gRT->SetTime = PcRtcEfiSetTime;
205 gRT->GetWakeupTime = PcRtcEfiGetWakeupTime;
206 gRT->SetWakeupTime = PcRtcEfiSetWakeupTime;
207
208 Status = gBS->InstallMultipleProtocolInterfaces (
209 &mHandle,
210 &gEfiRealTimeClockArchProtocolGuid,
211 NULL,
212 NULL
213 );
214 if (EFI_ERROR (Status)) {
215 ASSERT_EFI_ERROR (Status);
216 return Status;
217 }
218
219 if (FeaturePcdGet (PcdRtcUseMmio)) {
220 // Register for the virtual address change event
221 Status = gBS->CreateEventEx (
222 EVT_NOTIFY_SIGNAL,
223 TPL_NOTIFY,
225 NULL,
226 &gEfiEventVirtualAddressChangeGuid,
227 &mVirtualAddrChangeEvent
228 );
229 ASSERT_EFI_ERROR (Status);
230 }
231
232 return Status;
233}
UINT64 UINTN
EFI_RUNTIME_SERVICES * gRT
#define NULL
Definition: Base.h:319
#define STATIC
Definition: Base.h:264
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
UINT8 GetCenturyRtcAddress(VOID)
Definition: PcRtc.c:1404
EFI_STATUS PcRtcSetWakeupTime(IN BOOLEAN Enable, IN EFI_TIME *Time OPTIONAL, IN PC_RTC_MODULE_GLOBALS *Global)
Definition: PcRtc.c:868
EFI_STATUS PcRtcInit(IN PC_RTC_MODULE_GLOBALS *Global)
Definition: PcRtc.c:262
EFI_STATUS PcRtcGetWakeupTime(OUT BOOLEAN *Enabled, OUT BOOLEAN *Pending, OUT EFI_TIME *Time, IN PC_RTC_MODULE_GLOBALS *Global)
Definition: PcRtc.c:750
EFI_STATUS PcRtcGetTime(OUT EFI_TIME *Time, OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL, IN PC_RTC_MODULE_GLOBALS *Global)
Definition: PcRtc.c:527
EFI_STATUS PcRtcSetTime(IN EFI_TIME *Time, IN PC_RTC_MODULE_GLOBALS *Global)
Definition: PcRtc.c:632
VOID EFIAPI PcRtcAcpiTableChangeCallback(IN EFI_EVENT Event, IN VOID *Context)
Definition: PcRtc.c:1436
EFI_STATUS EFIAPI PcRtcEfiGetWakeupTime(OUT BOOLEAN *Enabled, OUT BOOLEAN *Pending, OUT EFI_TIME *Time)
Definition: PcRtcEntry.c:84
STATIC VOID EFIAPI VirtualNotifyEvent(IN EFI_EVENT Event, IN VOID *Context)
Definition: PcRtcEntry.c:128
EFI_STATUS EFIAPI PcRtcEfiSetTime(IN EFI_TIME *Time)
Definition: PcRtcEntry.c:60
EFI_STATUS EFIAPI InitializePcRtc(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: PcRtcEntry.c:157
EFI_STATUS EFIAPI PcRtcEfiGetTime(OUT EFI_TIME *Time, OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL)
Definition: PcRtcEntry.c:40
EFI_STATUS EFIAPI PcRtcEfiSetWakeupTime(IN BOOLEAN Enabled, IN EFI_TIME *Time OPTIONAL)
Definition: PcRtcEntry.c:109
EFI_HANDLE mHandle
Definition: PcRtcEntry.c:15
#define PcdGet16(TokenName)
Definition: PcdLib.h:349
#define PcdGet64(TokenName)
Definition: PcdLib.h:375
#define PcdGet8(TokenName)
Definition: PcdLib.h:336
#define FeaturePcdGet(TokenName)
Definition: PcdLib.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
EFI_BOOT_SERVICES * gBS
EFI_LOCK *EFIAPI EfiInitializeLock(IN OUT EFI_LOCK *Lock, IN EFI_TPL Priority)
Definition: UefiLib.c:405
EFI_STATUS EFIAPI EfiConvertPointer(IN UINTN DebugDisposition, IN OUT VOID **Address)
Definition: RuntimeLib.c:561