]> git.proxmox.com Git - mirror_edk2.git/blobdiff - PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
PcAtChipsetPkg/PcRtc: move ACPI parsing code to GetCenturyRtcAddress
[mirror_edk2.git] / PcAtChipsetPkg / PcatRealTimeClockRuntimeDxe / PcRtc.c
index 5143575e311f9e4d11d222e83e8c45f96afee4cf..b86c1f4beddc3f9c07257ac54362a0204ad9837c 100644 (file)
@@ -1239,20 +1239,13 @@ ScanTableInSDT (
 }\r
 \r
 /**\r
-  Notification function of ACPI Table change.\r
-\r
-  This is a notification function registered on ACPI Table change event.\r
-  It saves the Century address stored in ACPI FADT table.\r
-\r
-  @param  Event        Event whose notification function is being invoked.\r
-  @param  Context      Pointer to the notification function's context.\r
+  Get the century RTC address from the ACPI FADT table.\r
 \r
+  @return  The century RTC address or 0 if not found.\r
 **/\r
-VOID\r
-EFIAPI\r
-PcRtcAcpiTableChangeCallback (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
+UINT8\r
+GetCenturyRtcAddress (\r
+  VOID\r
   )\r
 {\r
   EFI_STATUS                                    Status;\r
@@ -1260,8 +1253,6 @@ PcRtcAcpiTableChangeCallback (
   EFI_ACPI_DESCRIPTION_HEADER                   *Rsdt;\r
   EFI_ACPI_DESCRIPTION_HEADER                   *Xsdt;\r
   EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE     *Fadt;\r
-  EFI_TIME                                      Time;\r
-  UINT8                                         Century;\r
 \r
   Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **) &Rsdp);\r
   if (EFI_ERROR (Status)) {\r
@@ -1269,7 +1260,7 @@ PcRtcAcpiTableChangeCallback (
   }\r
 \r
   if (EFI_ERROR (Status)) {\r
-    return;\r
+    return 0;\r
   }\r
 \r
   ASSERT (Rsdp != NULL);\r
@@ -1292,10 +1283,39 @@ PcRtcAcpiTableChangeCallback (
   }\r
 \r
   if ((Fadt != NULL) &&\r
-      (Fadt->Century > RTC_ADDRESS_REGISTER_D) && (Fadt->Century < 0x80) &&\r
-      (mModuleGlobal.CenturyRtcAddress != Fadt->Century)\r
+      (Fadt->Century > RTC_ADDRESS_REGISTER_D) && (Fadt->Century < 0x80)\r
       ) {\r
-    mModuleGlobal.CenturyRtcAddress = Fadt->Century;\r
+    return Fadt->Century;\r
+  } else {\r
+    return 0;\r
+  }\r
+}\r
+\r
+/**\r
+  Notification function of ACPI Table change.\r
+\r
+  This is a notification function registered on ACPI Table change event.\r
+  It saves the Century address stored in ACPI FADT table.\r
+\r
+  @param  Event        Event whose notification function is being invoked.\r
+  @param  Context      Pointer to the notification function's context.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PcRtcAcpiTableChangeCallback (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+{\r
+  EFI_STATUS          Status;\r
+  EFI_TIME            Time;\r
+  UINT8               CenturyRtcAddress;\r
+  UINT8               Century;\r
+\r
+  CenturyRtcAddress = GetCenturyRtcAddress ();\r
+  if ((CenturyRtcAddress != 0) && (mModuleGlobal.CenturyRtcAddress != CenturyRtcAddress)) {\r
+    mModuleGlobal.CenturyRtcAddress = CenturyRtcAddress;\r
     Status = PcRtcGetTime (&Time, NULL, &mModuleGlobal);\r
     if (!EFI_ERROR (Status)) {\r
       Century = (UINT8) (Time.Year / 100);\r