From ec35e997ad836c2ac95ae5c43f2e8f883062081e Mon Sep 17 00:00:00 2001 From: lgao4 Date: Tue, 6 May 2008 05:38:06 +0000 Subject: [PATCH] Enable storage of daylight saving and time zone data of SetTime() service, and fix bug of SetWakeupTime() service. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5168 6f19259b-4bc3-4df7-8a09-765794883524 --- .../PcatRealTimeClockRuntimeDxe/PcRtc.c | 39 ++++++++++++++++++- .../PcatRealTimeClockRuntimeDxe/PcRtc.h | 3 +- .../PcatRealTimeClockRuntimeDxe.inf | 7 +++- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcRtc.c b/MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcRtc.c index f97a2b7e7b..a007bd0595 100644 --- a/MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcRtc.c +++ b/MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcRtc.c @@ -107,6 +107,8 @@ Returns: RTC_REGISTER_D RegisterD; UINT8 Century; EFI_TIME Time; + UINTN DataSize; + UINT32 TimerVar; // // Acquire RTC Lock to make access to RTC atomic @@ -175,8 +177,9 @@ Returns: // // Set RTC configuration after get original time + // The value of bit AIE should be reserved. // - RtcWrite (RTC_ADDRESS_REGISTER_B, RTC_INIT_REGISTER_B); + RtcWrite (RTC_ADDRESS_REGISTER_B, RTC_INIT_REGISTER_B | (RegisterB.Data & BIT5)); // // Release RTC Lock. @@ -199,6 +202,25 @@ Returns: Time.Year = RTC_INIT_YEAR; } // + // Get the data of Daylight saving and time zone, if they have been + // stored in NV variable during previous boot. + // + DataSize = sizeof (UINT32); + Status = EfiGetVariable ( + L"TimerVar", + &gEfiGenericPlatformVariableGuid, + NULL, + &DataSize, + (VOID *) &TimerVar + ); + if (!EFI_ERROR (Status)) { + Global->SavedTimeZone = (INT16) TimerVar; + Global->Daylight = (UINT8) (TimerVar >> 16); + + Time.TimeZone = Global->SavedTimeZone; + Time.Daylight = Global->Daylight; + } + // // Reset time value according to new RTC configuration // PcRtcSetTime (&Time, Global); @@ -343,6 +365,7 @@ Routine Description: EFI_TIME RtcTime; RTC_REGISTER_B RegisterB; UINT8 Century; + UINT32 TimerVar; if (Time == NULL) { return EFI_INVALID_PARAMETER; @@ -417,7 +440,19 @@ Routine Description: // Global->SavedTimeZone = Time->TimeZone; Global->Daylight = Time->Daylight; - return Status; + + TimerVar = Time->Daylight; + TimerVar = (UINT32) ((TimerVar << 16) | Time->TimeZone); + Status = EfiSetVariable ( + L"TimerVar", + &gEfiGenericPlatformVariableGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, + sizeof (TimerVar), + &TimerVar + ); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; } EFI_STATUS diff --git a/MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcRtc.h b/MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcRtc.h index b120d09819..c44731a2f8 100644 --- a/MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcRtc.h +++ b/MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcRtc.h @@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +#include #include #include @@ -35,7 +36,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. typedef struct { EFI_LOCK RtcLock; - UINT16 SavedTimeZone; + INT16 SavedTimeZone; UINT8 Daylight; } PC_RTC_MODULE_GLOBALS; diff --git a/MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf b/MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf index d50129fd52..f464369bd1 100644 --- a/MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf +++ b/MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf @@ -40,6 +40,7 @@ [Packages] MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec [LibraryClasses] UefiRuntimeServicesTableLib @@ -53,8 +54,12 @@ DebugLib BaseLib +[Guids] + gEfiGenericPlatformVariableGuid # ALWAYS_CONSUMED + [Protocols] gEfiRealTimeClockArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED [Depex] - TRUE \ No newline at end of file + gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid + \ No newline at end of file