Revision: 14794
          http://sourceforge.net/p/edk2/code/14794
Author:   oliviermartin
Date:     2013-10-21 11:12:21 +0000 (Mon, 21 Oct 2013)
Log Message:
-----------
ArmPlatformPkg/PL031RealTimeClockLib: Fixed the conditions in LibSetTime()

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <[email protected]>

Modified Paths:
--------------
    
trunk/edk2/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c

Modified: 
trunk/edk2/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
===================================================================
--- 
trunk/edk2/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c 
    2013-10-21 11:06:51 UTC (rev 14793)
+++ 
trunk/edk2/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c 
    2013-10-21 11:12:21 UTC (rev 14794)
@@ -181,7 +181,7 @@
 
   JulianDate = Time->Day + ((153*m + 2)/5) + (365*y) + (y/4) - (y/100) + 
(y/400) - 32045;
 
-  ASSERT(JulianDate > EPOCH_JULIAN_DATE);
+  ASSERT (JulianDate >= EPOCH_JULIAN_DATE);
   EpochDays = JulianDate - EPOCH_JULIAN_DATE;
 
   EpochSeconds = (EpochDays * SEC_PER_DAY) + ((UINTN)Time->Hour * 
SEC_PER_HOUR) + (Time->Minute * SEC_PER_MIN) + Time->Second;
@@ -420,16 +420,9 @@
   EFI_STATUS  Status;
   UINTN       EpochSeconds;
 
-  // Because the PL031 is a 32-bit counter counting seconds,
-  // the maximum time span is just over 136 years.
-  // Time is stored in Unix Epoch format, so it starts in 1970,
-  // Therefore it can not exceed the year 2106.
-  // This is not a problem for UEFI, as the current spec limits the years
-  // to the range 1998 .. 2011
-
-  // Check the input parameters' range.
-  if ((Time->Year   < 1998) ||
-       (Time->Year   > 2099) ||
+  // Check the input parameters are within the range specified by UEFI
+  if ((Time->Year   < 1900) ||
+       (Time->Year   > 9999) ||
        (Time->Month  < 1   ) ||
        (Time->Month  > 12  ) ||
        (!DayValid (Time)    ) ||
@@ -444,6 +437,15 @@
     goto EXIT;
   }
 
+  // Because the PL031 is a 32-bit counter counting seconds,
+  // the maximum time span is just over 136 years.
+  // Time is stored in Unix Epoch format, so it starts in 1970,
+  // Therefore it can not exceed the year 2106.
+  if ((Time->Year < 1970) || (Time->Year >= 2106)) {
+    Status = EFI_UNSUPPORTED;
+    goto EXIT;
+  }
+
   // Initialize the hardware if not already done
   if (!mPL031Initialized) {
     Status = InitializePL031 ();

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to