]> git.proxmox.com Git - mirror_edk2.git/blobdiff - PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / PcAtChipsetPkg / PcatRealTimeClockRuntimeDxe / PcRtc.c
index 0fbfa4bcee934173a9f51cb2f34e6510d7ddb43c..9242a2e82600122620dffceb546bdb5e536a9368 100644 (file)
@@ -269,13 +269,6 @@ PcRtcInit (
   Time.Month  = RtcRead (RTC_ADDRESS_MONTH);\r
   Time.Year   = RtcRead (RTC_ADDRESS_YEAR);\r
 \r
-  //\r
-  // Set RTC configuration after get original time\r
-  // The value of bit AIE should be reserved.\r
-  //\r
-  RegisterB.Data = FixedPcdGet8 (PcdInitialValueRtcRegisterB) | (RegisterB.Data & BIT5);\r
-  RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);\r
-\r
   //\r
   // Release RTC Lock.\r
   //\r
@@ -330,6 +323,13 @@ PcRtcInit (
     Time.Daylight   = 0;\r
   }\r
 \r
+  //\r
+  // Set RTC configuration after get original time\r
+  // The value of bit AIE should be reserved.\r
+  //\r
+  RegisterB.Data = FixedPcdGet8 (PcdInitialValueRtcRegisterB) | (RegisterB.Data & BIT5);\r
+  RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);\r
+\r
   //\r
   // Reset time value according to new RTC configuration\r
   //\r
@@ -995,13 +995,16 @@ ConvertRtcTimeToEfiTime (
   BOOLEAN  IsPM;\r
   UINT8    Century;\r
 \r
-  if ((Time->Hour & 0x80) != 0) {\r
-    IsPM = TRUE;\r
-  } else {\r
-    IsPM = FALSE;\r
-  }\r
+  // IsPM only makes sense for 12-hour format.\r
+  if (RegisterB.Bits.Mil == 0) {\r
+    if ((Time->Hour & 0x80) != 0) {\r
+      IsPM = TRUE;\r
+    } else {\r
+      IsPM = FALSE;\r
+    }\r
 \r
-  Time->Hour = (UINT8)(Time->Hour & 0x7f);\r
+    Time->Hour = (UINT8)(Time->Hour & 0x7f);\r
+  }\r
 \r
   if (RegisterB.Bits.Dm == 0) {\r
     Time->Year   = CheckAndConvertBcd8ToDecimal8 ((UINT8)Time->Year);\r