44 if ( (
MmioRead8 (mPL031RtcBase + PL031_RTC_PCELL_ID0) != 0x0D)
45 || (
MmioRead8 (mPL031RtcBase + PL031_RTC_PCELL_ID1) != 0xF0)
46 || (
MmioRead8 (mPL031RtcBase + PL031_RTC_PCELL_ID2) != 0x05)
47 || (
MmioRead8 (mPL031RtcBase + PL031_RTC_PCELL_ID3) != 0xB1))
49 Status = EFI_NOT_FOUND;
54 if ( (
MmioRead8 (mPL031RtcBase + PL031_RTC_PERIPH_ID0) != 0x31)
55 || (
MmioRead8 (mPL031RtcBase + PL031_RTC_PERIPH_ID1) != 0x10)
56 || ((
MmioRead8 (mPL031RtcBase + PL031_RTC_PERIPH_ID2) & 0xF) != 0x04)
57 || (
MmioRead8 (mPL031RtcBase + PL031_RTC_PERIPH_ID3) != 0x00))
59 Status = EFI_NOT_FOUND;
77 Status = IdentifyPL031 ();
78 if (EFI_ERROR (Status)) {
83 if ((
MmioRead32 (mPL031RtcBase + PL031_RTC_IMSC_IRQ_MASK_SET_CLEAR_REGISTER) & PL031_SET_IRQ_MASK) != 0) {
84 MmioWrite32 (mPL031RtcBase + PL031_RTC_IMSC_IRQ_MASK_SET_CLEAR_REGISTER, 0);
88 if ((
MmioRead32 (mPL031RtcBase + PL031_RTC_RIS_RAW_IRQ_STATUS_REGISTER) & PL031_IRQ_TRIGGERED) == PL031_IRQ_TRIGGERED) {
89 MmioOr32 (mPL031RtcBase + PL031_RTC_ICR_IRQ_CLEAR_REGISTER, PL031_CLEAR_IRQ);
93 if ((
MmioRead32 (mPL031RtcBase + PL031_RTC_CR_CONTROL_REGISTER) & PL031_RTC_ENABLED) != PL031_RTC_ENABLED) {
94 MmioOr32 (mPL031RtcBase + PL031_RTC_CR_CONTROL_REGISTER, PL031_RTC_ENABLED);
97 mPL031Initialized =
TRUE;
131 return EFI_INVALID_PARAMETER;
135 if (!mPL031Initialized) {
136 Status = InitializePL031 ();
137 if (EFI_ERROR (Status)) {
142 EpochSeconds =
MmioRead32 (mPL031RtcBase + PL031_RTC_DR_DATA_REGISTER);
147 EpochSeconds += Time->TimeZone * SEC_PER_MIN;
148 }
else if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) {
150 EpochSeconds += SEC_PER_HOUR;
157 if (Capabilities !=
NULL) {
159 Capabilities->Resolution = PL031_COUNTS_PER_SECOND;
161 Capabilities->Accuracy = (UINT32)
PcdGet32 (PcdPL031RtcPpmAccuracy);
163 Capabilities->SetsToZero =
FALSE;
195 if ((Time->Year < 1970) || (Time->Year >= 2106)) {
196 return EFI_UNSUPPORTED;
200 if (!mPL031Initialized) {
201 Status = InitializePL031 ();
202 if (EFI_ERROR (Status)) {
212 EpochSeconds -= Time->TimeZone * SEC_PER_MIN;
213 }
else if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) {
215 EpochSeconds -= SEC_PER_HOUR;
219 MmioWrite32 (mPL031RtcBase + PL031_RTC_LR_LOAD_REGISTER, EpochSeconds);
244 OUT BOOLEAN *Enabled,
245 OUT BOOLEAN *Pending,
250 return EFI_UNSUPPORTED;
278 return EFI_UNSUPPORTED;
327 mPL031RtcBase =
PcdGet32 (PcdPL031RtcBase);
330 Status =
gDS->AddMemorySpace (
334 EFI_MEMORY_UC | EFI_MEMORY_RUNTIME | EFI_MEMORY_XP
336 if (EFI_ERROR (Status)) {
340 Status =
gDS->SetMemorySpaceAttributes (mPL031RtcBase, SIZE_4KB, EFI_MEMORY_UC | EFI_MEMORY_RUNTIME | EFI_MEMORY_XP);
341 if (EFI_ERROR (Status)) {
348 Status =
gBS->CreateEventEx (
353 &gEfiEventVirtualAddressChangeGuid,
354 &mRtcVirtualAddrChangeEvent
UINT32 EFIAPI MmioOr32(IN UINTN Address, IN UINT32 OrData)
UINT8 EFIAPI MmioRead8(IN UINTN Address)
UINT32 EFIAPI MmioRead32(IN UINTN Address)
UINT32 EFIAPI MmioWrite32(IN UINTN Address, IN UINT32 Value)
#define ASSERT_EFI_ERROR(StatusParameter)
STATIC VOID EFIAPI VirtualNotifyEvent(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI LibSetWakeupTime(IN BOOLEAN Enabled, OUT EFI_TIME *Time)
EFI_STATUS EFIAPI LibRtcInitialize(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI LibGetWakeupTime(OUT BOOLEAN *Enabled, OUT BOOLEAN *Pending, OUT EFI_TIME *Time)
EFI_STATUS EFIAPI LibSetTime(IN EFI_TIME *Time)
EFI_STATUS EFIAPI LibGetTime(OUT EFI_TIME *Time, OUT EFI_TIME_CAPABILITIES *Capabilities)
#define PcdGet32(TokenName)
@ EfiGcdMemoryTypeMemoryMappedIo
UINTN EFIAPI EfiTimeToEpoch(IN EFI_TIME *Time)
VOID EFIAPI EpochToEfiTime(IN UINTN EpochSeconds, OUT EFI_TIME *Time)
EFI_STATUS EFIAPI EfiConvertPointer(IN UINTN DebugDisposition, IN OUT VOID **Address)
#define EFI_UNSPECIFIED_TIMEZONE