mirror of https://github.com/acidanthera/audk.git
PcAtChipsetPkg/Rtc: Don't unnecessarily create timezone variable.
When SetTime() is called with EFI_UNSPECIFIED_TIMEZONE, the code can optimally not create the private timezone variable because absence of timezone variable indicates the timezone is unspecified. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19783 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
39bbd1fbbf
commit
bf46bd4618
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
RTC Architectural Protocol GUID as defined in DxeCis 0.96.
|
RTC Architectural Protocol GUID as defined in DxeCis 0.96.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -14,6 +14,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
#include "PcRtc.h"
|
#include "PcRtc.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Days of month.
|
||||||
|
//
|
||||||
|
UINTN mDayOfMonth[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||||
|
|
||||||
|
//
|
||||||
|
// The name of NV variable to store the timezone and daylight saving information.
|
||||||
|
//
|
||||||
|
CHAR16 mTimeZoneVariableName[] = L"RTC";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Compare the Hour, Minute and Second of the From time and the To time.
|
Compare the Hour, Minute and Second of the From time and the To time.
|
||||||
|
|
||||||
|
@ -182,11 +192,11 @@ PcRtcInit (
|
||||||
//
|
//
|
||||||
DataSize = sizeof (UINT32);
|
DataSize = sizeof (UINT32);
|
||||||
Status = EfiGetVariable (
|
Status = EfiGetVariable (
|
||||||
L"RTC",
|
mTimeZoneVariableName,
|
||||||
&gEfiCallerIdGuid,
|
&gEfiCallerIdGuid,
|
||||||
NULL,
|
NULL,
|
||||||
&DataSize,
|
&DataSize,
|
||||||
(VOID *) &TimerVar
|
&TimerVar
|
||||||
);
|
);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
Time.TimeZone = (INT16) TimerVar;
|
Time.TimeZone = (INT16) TimerVar;
|
||||||
|
@ -477,15 +487,29 @@ PcRtcSetTime (
|
||||||
//
|
//
|
||||||
// Write timezone and daylight to RTC variable
|
// Write timezone and daylight to RTC variable
|
||||||
//
|
//
|
||||||
|
if (Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE) {
|
||||||
|
Status = EfiSetVariable (
|
||||||
|
mTimeZoneVariableName,
|
||||||
|
&gEfiCallerIdGuid,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
if (Status == EFI_NOT_FOUND) {
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
TimerVar = Time->Daylight;
|
TimerVar = Time->Daylight;
|
||||||
TimerVar = (UINT32) ((TimerVar << 16) | (UINT16)(Time->TimeZone));
|
TimerVar = (UINT32) ((TimerVar << 16) | (UINT16)(Time->TimeZone));
|
||||||
Status = EfiSetVariable (
|
Status = EfiSetVariable (
|
||||||
L"RTC",
|
mTimeZoneVariableName,
|
||||||
&gEfiCallerIdGuid,
|
&gEfiCallerIdGuid,
|
||||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||||
sizeof (TimerVar),
|
sizeof (TimerVar),
|
||||||
&TimerVar
|
&TimerVar
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
if (!EfiAtRuntime ()) {
|
if (!EfiAtRuntime ()) {
|
||||||
EfiReleaseLock (&Global->RtcLock);
|
EfiReleaseLock (&Global->RtcLock);
|
||||||
|
@ -987,28 +1011,13 @@ DayValid (
|
||||||
IN EFI_TIME *Time
|
IN EFI_TIME *Time
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
INTN DayOfMonth[12];
|
|
||||||
|
|
||||||
DayOfMonth[0] = 31;
|
|
||||||
DayOfMonth[1] = 29;
|
|
||||||
DayOfMonth[2] = 31;
|
|
||||||
DayOfMonth[3] = 30;
|
|
||||||
DayOfMonth[4] = 31;
|
|
||||||
DayOfMonth[5] = 30;
|
|
||||||
DayOfMonth[6] = 31;
|
|
||||||
DayOfMonth[7] = 31;
|
|
||||||
DayOfMonth[8] = 30;
|
|
||||||
DayOfMonth[9] = 31;
|
|
||||||
DayOfMonth[10] = 30;
|
|
||||||
DayOfMonth[11] = 31;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// The validity of Time->Month field should be checked before
|
// The validity of Time->Month field should be checked before
|
||||||
//
|
//
|
||||||
ASSERT (Time->Month >=1);
|
ASSERT (Time->Month >=1);
|
||||||
ASSERT (Time->Month <=12);
|
ASSERT (Time->Month <=12);
|
||||||
if (Time->Day < 1 ||
|
if (Time->Day < 1 ||
|
||||||
Time->Day > DayOfMonth[Time->Month - 1] ||
|
Time->Day > mDayOfMonth[Time->Month - 1] ||
|
||||||
(Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
|
(Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
|
||||||
) {
|
) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1144,22 +1153,8 @@ IsWithinOneDay (
|
||||||
IN EFI_TIME *To
|
IN EFI_TIME *To
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT8 DayOfMonth[12];
|
|
||||||
BOOLEAN Adjacent;
|
BOOLEAN Adjacent;
|
||||||
|
|
||||||
DayOfMonth[0] = 31;
|
|
||||||
DayOfMonth[1] = 29;
|
|
||||||
DayOfMonth[2] = 31;
|
|
||||||
DayOfMonth[3] = 30;
|
|
||||||
DayOfMonth[4] = 31;
|
|
||||||
DayOfMonth[5] = 30;
|
|
||||||
DayOfMonth[6] = 31;
|
|
||||||
DayOfMonth[7] = 31;
|
|
||||||
DayOfMonth[8] = 30;
|
|
||||||
DayOfMonth[9] = 31;
|
|
||||||
DayOfMonth[10] = 30;
|
|
||||||
DayOfMonth[11] = 31;
|
|
||||||
|
|
||||||
Adjacent = FALSE;
|
Adjacent = FALSE;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1186,7 +1181,7 @@ IsWithinOneDay (
|
||||||
Adjacent = TRUE;
|
Adjacent = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (From->Day == DayOfMonth[From->Month - 1]) {
|
} else if (From->Day == mDayOfMonth[From->Month - 1]) {
|
||||||
if ((CompareHMS(From, To) >= 0)) {
|
if ((CompareHMS(From, To) >= 0)) {
|
||||||
Adjacent = TRUE;
|
Adjacent = TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue