X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=PcAtChipsetPkg%2FPcatRealTimeClockRuntimeDxe%2FPcRtc.c;h=857918df18b018fd712579678b09df33a45d5f3e;hp=acc70a67b71c72d759536ebd41061d2fbf56535c;hb=ea99ba10ff0392554c9f82307949e1349d17888a;hpb=bf46bd46188fd002b3bc7e15d8de50be23c1fd04 diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c index acc70a67b7..857918df18 100644 --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c @@ -487,7 +487,7 @@ PcRtcSetTime ( // // Write timezone and daylight to RTC variable // - if (Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE) { + if ((Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE) && (Time->Daylight == 0)) { Status = EfiSetVariable ( mTimeZoneVariableName, &gEfiCallerIdGuid, @@ -1230,6 +1230,11 @@ ScanTableInSDT ( // Table = 0; CopyMem (&Table, (VOID *) (EntryBase + Index * TablePointerSize), TablePointerSize); + + if (Table == NULL) { + continue; + } + if (Table->Signature == Signature) { return Table; } @@ -1239,63 +1244,86 @@ ScanTableInSDT ( } /** - Notification function of ACPI Table change. - - This is a notification function registered on ACPI Table change event. - It saves the Century address stored in ACPI FADT table. - - @param Event Event whose notification function is being invoked. - @param Context Pointer to the notification function's context. + Get the century RTC address from the ACPI FADT table. + @return The century RTC address or 0 if not found. **/ -VOID -EFIAPI -PcRtcAcpiTableChangeCallback ( - IN EFI_EVENT Event, - IN VOID *Context +UINT8 +GetCenturyRtcAddress ( + VOID ) { EFI_STATUS Status; EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp; - EFI_ACPI_DESCRIPTION_HEADER *Rsdt; - EFI_ACPI_DESCRIPTION_HEADER *Xsdt; EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt; - EFI_TIME Time; - UINT8 Century; Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **) &Rsdp); if (EFI_ERROR (Status)) { Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **) &Rsdp); } - if (EFI_ERROR (Status)) { - return; + if (EFI_ERROR (Status) || (Rsdp == NULL)) { + return 0; } - ASSERT (Rsdp != NULL); + Fadt = NULL; // // Find FADT in XSDT // - Fadt = NULL; - if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) { - Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress; - Fadt = ScanTableInSDT (Xsdt, EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, sizeof (UINT64)); + if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 0) { + Fadt = ScanTableInSDT ( + (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress, + EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, + sizeof (UINTN) + ); } - if (Fadt == NULL) { - // - // Find FADT in RSDT - // - Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress; - Fadt = ScanTableInSDT (Rsdt, EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, sizeof (UINT32)); + // + // Find FADT in RSDT + // + if (Fadt == NULL && Rsdp->RsdtAddress != 0) { + Fadt = ScanTableInSDT ( + (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress, + EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, + sizeof (UINT32) + ); } if ((Fadt != NULL) && - (Fadt->Century > RTC_ADDRESS_REGISTER_D) && (Fadt->Century < 0x80) && - (mModuleGlobal.CenturyRtcAddress != Fadt->Century) + (Fadt->Century > RTC_ADDRESS_REGISTER_D) && (Fadt->Century < 0x80) ) { - mModuleGlobal.CenturyRtcAddress = Fadt->Century; + return Fadt->Century; + } else { + return 0; + } +} + +/** + Notification function of ACPI Table change. + + This is a notification function registered on ACPI Table change event. + It saves the Century address stored in ACPI FADT table. + + @param Event Event whose notification function is being invoked. + @param Context Pointer to the notification function's context. + +**/ +VOID +EFIAPI +PcRtcAcpiTableChangeCallback ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EFI_TIME Time; + UINT8 CenturyRtcAddress; + UINT8 Century; + + CenturyRtcAddress = GetCenturyRtcAddress (); + if ((CenturyRtcAddress != 0) && (mModuleGlobal.CenturyRtcAddress != CenturyRtcAddress)) { + mModuleGlobal.CenturyRtcAddress = CenturyRtcAddress; Status = PcRtcGetTime (&Time, NULL, &mModuleGlobal); if (!EFI_ERROR (Status)) { Century = (UINT8) (Time.Year / 100);