]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcRtc.c
Fix PcRtc Year calculation bug.
[mirror_edk2.git] / MdeModulePkg / Universal / PcatRealTimeClockRuntimeDxe / PcRtc.c
index e9367fb737e5bb22da572496f078088c21b8a310..d26e92360584ed3ecb4058eaa1b2e7e8c12e955c 100644 (file)
@@ -158,12 +158,8 @@ PcRtcInit (
   Time.Month  = RtcRead (RTC_ADDRESS_MONTH);\r
   Time.Year   = RtcRead (RTC_ADDRESS_YEAR);\r
 \r
-  if (RtcTestCenturyRegister () == EFI_SUCCESS) {\r
-    Century = (UINT8) (RtcRead (RTC_ADDRESS_CENTURY) & 0x7f);\r
-  } else {\r
-    Century = RtcRead (RTC_ADDRESS_CENTURY);\r
-  }\r
-\r
+  Century = RtcRead (RTC_ADDRESS_CENTURY);\r
+  \r
   //\r
   // Set RTC configuration after get original time\r
   // The value of bit AIE should be reserved.\r
@@ -285,12 +281,8 @@ PcRtcGetTime (
   Time->Month   = RtcRead (RTC_ADDRESS_MONTH);\r
   Time->Year    = RtcRead (RTC_ADDRESS_YEAR);\r
 \r
-  if (RtcTestCenturyRegister () == EFI_SUCCESS) {\r
-    Century = (UINT8) (RtcRead (RTC_ADDRESS_CENTURY) & 0x7f);\r
-  } else {\r
-    Century = RtcRead (RTC_ADDRESS_CENTURY);\r
-  }\r
-\r
+  Century = RtcRead (RTC_ADDRESS_CENTURY);\r
+  \r
   //\r
   // Release RTC Lock.\r
   //\r
@@ -401,10 +393,6 @@ PcRtcSetTime (
   RtcWrite (RTC_ADDRESS_DAY_OF_THE_MONTH, RtcTime.Day);\r
   RtcWrite (RTC_ADDRESS_MONTH, RtcTime.Month);\r
   RtcWrite (RTC_ADDRESS_YEAR, (UINT8) RtcTime.Year);\r
-  if (RtcTestCenturyRegister () == EFI_SUCCESS) {\r
-    Century = (UINT8) ((Century & 0x7f) | (RtcRead (RTC_ADDRESS_CENTURY) & 0x80));\r
-  }\r
-\r
   RtcWrite (RTC_ADDRESS_CENTURY, Century);\r
 \r
   //\r
@@ -520,12 +508,8 @@ PcRtcGetWakeupTime (
     Time->Year    = RtcRead (RTC_ADDRESS_YEAR);\r
   }\r
 \r
-  if (RtcTestCenturyRegister () == EFI_SUCCESS) {\r
-    Century = (UINT8) (RtcRead (RTC_ADDRESS_CENTURY) & 0x7f);\r
-  } else {\r
-    Century = RtcRead (RTC_ADDRESS_CENTURY);\r
-  }\r
-\r
+  Century = RtcRead (RTC_ADDRESS_CENTURY);\r
+  \r
   //\r
   // Release RTC Lock.\r
   //\r
@@ -663,29 +647,6 @@ PcRtcSetWakeupTime (
   return EFI_SUCCESS;\r
 }\r
 \r
-/**\r
-  See if century register of RTC is valid.\r
-\r
-  @retval  EFI_SUCCESS       Century register is valid.\r
-  @retval  EFI_DEVICE_ERROR  Century register is NOT valid.\r
-**/\r
-EFI_STATUS\r
-RtcTestCenturyRegister (\r
-  VOID\r
-  )\r
-{\r
-  UINT8 Century;\r
-  UINT8 Temp;\r
-\r
-  Century = RtcRead (RTC_ADDRESS_CENTURY);\r
-  Temp = (UINT8) (RtcRead (RTC_ADDRESS_CENTURY) & 0x7f);\r
-  RtcWrite (RTC_ADDRESS_CENTURY, Century);\r
-  if (Temp == 0x19 || Temp == 0x20) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  return EFI_DEVICE_ERROR;\r
-}\r
 \r
 /**\r
   Checks an 8-bit BCD value, and converts to an 8-bit value if valid.\r
@@ -753,8 +714,8 @@ ConvertRtcTimeToEfiTime (
     Time->Hour    = CheckAndConvertBcd8ToDecimal8 (Time->Hour);\r
     Time->Minute  = CheckAndConvertBcd8ToDecimal8 (Time->Minute);\r
     Time->Second  = CheckAndConvertBcd8ToDecimal8 (Time->Second);\r
-    Century       = CheckAndConvertBcd8ToDecimal8 (Century);\r
   }\r
+  Century       = CheckAndConvertBcd8ToDecimal8 (Century);\r
 \r
   if (Time->Year == 0xff || Time->Month == 0xff || Time->Day == 0xff ||\r
       Time->Hour == 0xff || Time->Minute == 0xff || Time->Second == 0xff ||\r