#include <Library/RealTimeClockLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
#include <Library/PcdLib.h>\r
-#include <Library/ArmPlatformSysConfigLib.h>\r
#include <Library/DxeServicesTableLib.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
#include <Library/UefiRuntimeServicesTableLib.h>\r
\r
#include <Library/TimeBaseLib.h>\r
\r
-#include <ArmPlatform.h>\r
-\r
STATIC BOOLEAN mPL031Initialized = FALSE;\r
STATIC EFI_EVENT mRtcVirtualAddrChangeEvent;\r
STATIC UINTN mPL031RtcBase;\r
EFI_STATUS Status = EFI_SUCCESS;\r
UINT32 EpochSeconds;\r
\r
+ // Ensure Time is a valid pointer\r
+ if (Time == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
// Initialize the hardware if not already done\r
if (!mPL031Initialized) {\r
Status = InitializePL031 ();\r
}\r
}\r
\r
- // Snapshot the time as early in the function call as possible\r
- // On some platforms we may have access to a battery backed up hardware clock.\r
- // If such RTC exists try to use it first.\r
- Status = ArmPlatformSysConfigGet (SYS_CFG_RTC, &EpochSeconds);\r
- if (Status == EFI_UNSUPPORTED) {\r
- // Battery backed up hardware RTC does not exist, revert to PL031\r
- EpochSeconds = MmioRead32 (mPL031RtcBase + PL031_RTC_DR_DATA_REGISTER);\r
- Status = EFI_SUCCESS;\r
- } else if (EFI_ERROR (Status)) {\r
- // Battery backed up hardware RTC exists but could not be read due to error. Abort.\r
- return Status;\r
- } else {\r
- // Battery backed up hardware RTC exists and we read the time correctly from it.\r
- // Now sync the PL031 to the new time.\r
- MmioWrite32 (mPL031RtcBase + PL031_RTC_LR_LOAD_REGISTER, EpochSeconds);\r
- }\r
-\r
- // Ensure Time is a valid pointer\r
- if (Time == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
+ EpochSeconds = MmioRead32 (mPL031RtcBase + PL031_RTC_DR_DATA_REGISTER);\r
\r
// Adjust for the correct time zone\r
// The timezone setting also reflects the DST setting of the clock\r
EpochSeconds -= SEC_PER_HOUR;\r
}\r
\r
- // On some platforms we may have access to a battery backed up hardware clock.\r
- //\r
- // If such RTC exists then it must be updated first, before the PL031,\r
- // to minimise any time drift. This is important because the battery backed-up\r
- // RTC maintains the master time for the platform across reboots.\r
- //\r
- // If such RTC does not exist then the following function returns UNSUPPORTED.\r
- Status = ArmPlatformSysConfigSet (SYS_CFG_RTC, EpochSeconds);\r
- if ((EFI_ERROR (Status)) && (Status != EFI_UNSUPPORTED)){\r
- // Any status message except SUCCESS and UNSUPPORTED indicates a hardware failure.\r
- return Status;\r
- }\r
-\r
// Set the PL031\r
MmioWrite32 (mPL031RtcBase + PL031_RTC_LR_LOAD_REGISTER, EpochSeconds);\r
\r