]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
ArmPlatformPkg/PL031RealTimeClockLib: Fixed the conditions in LibSetTime()
[mirror_edk2.git] / ArmPlatformPkg / Library / PL031RealTimeClockLib / PL031RealTimeClockLib.c
index b7dba087fcae3232b3b386345b3ae2a4d744bfdc..980f809b2c6ccbc5832030144906dc1bedbb6bc6 100644 (file)
@@ -181,7 +181,7 @@ EfiTimeToEpoch (
 \r
   JulianDate = Time->Day + ((153*m + 2)/5) + (365*y) + (y/4) - (y/100) + (y/400) - 32045;\r
 \r
-  ASSERT(JulianDate > EPOCH_JULIAN_DATE);\r
+  ASSERT (JulianDate >= EPOCH_JULIAN_DATE);\r
   EpochDays = JulianDate - EPOCH_JULIAN_DATE;\r
 \r
   EpochSeconds = (EpochDays * SEC_PER_DAY) + ((UINTN)Time->Hour * SEC_PER_HOUR) + (Time->Minute * SEC_PER_MIN) + Time->Second;\r
@@ -420,16 +420,9 @@ LibSetTime (
   EFI_STATUS  Status;\r
   UINTN       EpochSeconds;\r
 \r
-  // Because the PL031 is a 32-bit counter counting seconds,\r
-  // the maximum time span is just over 136 years.\r
-  // Time is stored in Unix Epoch format, so it starts in 1970,\r
-  // Therefore it can not exceed the year 2106.\r
-  // This is not a problem for UEFI, as the current spec limits the years\r
-  // to the range 1998 .. 2011\r
-\r
-  // Check the input parameters' range.\r
-  if ((Time->Year   < 1998) ||\r
-       (Time->Year   > 2099) ||\r
+  // Check the input parameters are within the range specified by UEFI\r
+  if ((Time->Year   < 1900) ||\r
+       (Time->Year   > 9999) ||\r
        (Time->Month  < 1   ) ||\r
        (Time->Month  > 12  ) ||\r
        (!DayValid (Time)    ) ||\r
@@ -444,6 +437,15 @@ LibSetTime (
     goto EXIT;\r
   }\r
 \r
+  // Because the PL031 is a 32-bit counter counting seconds,\r
+  // the maximum time span is just over 136 years.\r
+  // Time is stored in Unix Epoch format, so it starts in 1970,\r
+  // Therefore it can not exceed the year 2106.\r
+  if ((Time->Year < 1970) || (Time->Year >= 2106)) {\r
+    Status = EFI_UNSUPPORTED;\r
+    goto EXIT;\r
+  }\r
+\r
   // Initialize the hardware if not already done\r
   if (!mPL031Initialized) {\r
     Status = InitializePL031 ();\r