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
This commit is contained in:
lgao4 2008-05-06 05:38:06 +00:00
parent 65a18d1ac2
commit ec35e997ad
3 changed files with 45 additions and 4 deletions

View File

@ -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

View File

@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <PiDxe.h>
#include <Protocol/RealTimeClock.h>
#include <Guid/GenericPlatformVariable.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
@ -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;

View File

@ -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
gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid