mirror of https://github.com/acidanthera/audk.git
store Year/Month/Day to variable in SetWakeupTime() because PCAT RTC Alarm registers has not corresponding Y/M/D alarm register.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11021 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
f13f9683db
commit
7018623cd4
|
@ -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 - 2007, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2010, 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
|
||||||
|
@ -234,6 +234,7 @@ PcRtcInit (
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
PcRtcGetTime (
|
PcRtcGetTime (
|
||||||
OUT EFI_TIME *Time,
|
OUT EFI_TIME *Time,
|
||||||
OUT EFI_TIME_CAPABILITIES *Capabilities, OPTIONAL
|
OUT EFI_TIME_CAPABILITIES *Capabilities, OPTIONAL
|
||||||
|
@ -338,6 +339,7 @@ PcRtcGetTime (
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
PcRtcSetTime (
|
PcRtcSetTime (
|
||||||
IN EFI_TIME *Time,
|
IN EFI_TIME *Time,
|
||||||
IN PC_RTC_MODULE_GLOBALS *Global
|
IN PC_RTC_MODULE_GLOBALS *Global
|
||||||
|
@ -455,6 +457,8 @@ PcRtcGetWakeupTime (
|
||||||
RTC_REGISTER_B RegisterB;
|
RTC_REGISTER_B RegisterB;
|
||||||
RTC_REGISTER_C RegisterC;
|
RTC_REGISTER_C RegisterC;
|
||||||
UINT8 Century;
|
UINT8 Century;
|
||||||
|
EFI_TIME RtcTime;
|
||||||
|
UINTN DataSize;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check parameters for null pointers
|
// Check parameters for null pointers
|
||||||
|
@ -489,24 +493,38 @@ PcRtcGetWakeupTime (
|
||||||
// Get the Time/Date/Daylight Savings values.
|
// Get the Time/Date/Daylight Savings values.
|
||||||
//
|
//
|
||||||
*Enabled = RegisterB.Bits.Aie;
|
*Enabled = RegisterB.Bits.Aie;
|
||||||
if (*Enabled) {
|
*Pending = RegisterC.Bits.Af;
|
||||||
|
|
||||||
Time->Second = RtcRead (RTC_ADDRESS_SECONDS_ALARM);
|
Time->Second = RtcRead (RTC_ADDRESS_SECONDS_ALARM);
|
||||||
Time->Minute = RtcRead (RTC_ADDRESS_MINUTES_ALARM);
|
Time->Minute = RtcRead (RTC_ADDRESS_MINUTES_ALARM);
|
||||||
Time->Hour = RtcRead (RTC_ADDRESS_HOURS_ALARM);
|
Time->Hour = RtcRead (RTC_ADDRESS_HOURS_ALARM);
|
||||||
Time->Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
|
Time->Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
|
||||||
Time->Month = RtcRead (RTC_ADDRESS_MONTH);
|
Time->Month = RtcRead (RTC_ADDRESS_MONTH);
|
||||||
Time->Year = RtcRead (RTC_ADDRESS_YEAR);
|
Time->Year = RtcRead (RTC_ADDRESS_YEAR);
|
||||||
} else {
|
Time->TimeZone = Global->SavedTimeZone;
|
||||||
Time->Second = 0;
|
Time->Daylight = Global->Daylight;
|
||||||
Time->Minute = 0;
|
|
||||||
Time->Hour = 0;
|
|
||||||
Time->Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
|
|
||||||
Time->Month = RtcRead (RTC_ADDRESS_MONTH);
|
|
||||||
Time->Year = RtcRead (RTC_ADDRESS_YEAR);
|
|
||||||
}
|
|
||||||
|
|
||||||
Century = RtcRead (RTC_ADDRESS_CENTURY);
|
Century = RtcRead (RTC_ADDRESS_CENTURY);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get the alarm info from variable
|
||||||
|
//
|
||||||
|
Status = EfiGetVariable (
|
||||||
|
L"RTCALARM",
|
||||||
|
&gEfiCallerIdGuid,
|
||||||
|
NULL,
|
||||||
|
&DataSize,
|
||||||
|
&RtcTime
|
||||||
|
);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
//
|
||||||
|
// The alarm variable exists. In this case, we read variable to get info.
|
||||||
|
//
|
||||||
|
Time->Day = RtcTime.Day;
|
||||||
|
Time->Month = RtcTime.Month;
|
||||||
|
Time->Year = RtcTime.Year;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Release RTC Lock.
|
// Release RTC Lock.
|
||||||
//
|
//
|
||||||
|
@ -514,12 +532,6 @@ PcRtcGetWakeupTime (
|
||||||
EfiReleaseLock (&Global->RtcLock);
|
EfiReleaseLock (&Global->RtcLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Get the variable that contains the TimeZone and Daylight fields
|
|
||||||
//
|
|
||||||
Time->TimeZone = Global->SavedTimeZone;
|
|
||||||
Time->Daylight = Global->Daylight;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Make sure all field values are in correct range
|
// Make sure all field values are in correct range
|
||||||
//
|
//
|
||||||
|
@ -531,8 +543,6 @@ PcRtcGetWakeupTime (
|
||||||
return EFI_DEVICE_ERROR;
|
return EFI_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
*Pending = RegisterC.Bits.Af;
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,6 +562,7 @@ PcRtcGetWakeupTime (
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
PcRtcSetWakeupTime (
|
PcRtcSetWakeupTime (
|
||||||
IN BOOLEAN Enable,
|
IN BOOLEAN Enable,
|
||||||
IN EFI_TIME *Time, OPTIONAL
|
IN EFI_TIME *Time, OPTIONAL
|
||||||
|
@ -564,6 +575,8 @@ PcRtcSetWakeupTime (
|
||||||
UINT8 Century;
|
UINT8 Century;
|
||||||
EFI_TIME_CAPABILITIES Capabilities;
|
EFI_TIME_CAPABILITIES Capabilities;
|
||||||
|
|
||||||
|
ZeroMem (RtcTime);
|
||||||
|
|
||||||
if (Enable) {
|
if (Enable) {
|
||||||
|
|
||||||
if (Time == NULL) {
|
if (Time == NULL) {
|
||||||
|
@ -631,6 +644,17 @@ PcRtcSetWakeupTime (
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
RegisterB.Bits.Aie = 0;
|
RegisterB.Bits.Aie = 0;
|
||||||
|
//
|
||||||
|
// if the alarm is disable, record the current setting.
|
||||||
|
//
|
||||||
|
RtcTime.Second = RtcRead (RTC_ADDRESS_SECONDS_ALARM);
|
||||||
|
RtcTime.Minute = RtcRead (RTC_ADDRESS_MINUTES_ALARM);
|
||||||
|
RtcTime.Hour = RtcRead (RTC_ADDRESS_HOURS_ALARM);
|
||||||
|
RtcTime.Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
|
||||||
|
RtcTime.Month = RtcRead (RTC_ADDRESS_MONTH);
|
||||||
|
RtcTime.Year = RtcRead (RTC_ADDRESS_YEAR);
|
||||||
|
RtcTime.TimeZone = Global->SavedTimeZone;
|
||||||
|
RtcTime.Daylight = Global->Daylight;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Allow updates of the RTC registers
|
// Allow updates of the RTC registers
|
||||||
|
@ -638,6 +662,20 @@ PcRtcSetWakeupTime (
|
||||||
RegisterB.Bits.Set = 0;
|
RegisterB.Bits.Set = 0;
|
||||||
RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
|
RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set the Y/M/D info to variable as it has no corresponding hw registers.
|
||||||
|
//
|
||||||
|
Status = EfiSetVariable (
|
||||||
|
L"RTCALARM",
|
||||||
|
&gEfiCallerIdGuid,
|
||||||
|
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||||
|
sizeof (RtcTime),
|
||||||
|
&RtcTime
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Release RTC Lock.
|
// Release RTC Lock.
|
||||||
//
|
//
|
||||||
|
|
|
@ -134,7 +134,7 @@ InitializePcRtc (
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
EfiInitializeLock (&mModuleGlobal.RtcLock, TPL_HIGH_LEVEL);
|
EfiInitializeLock (&mModuleGlobal.RtcLock, TPL_CALLBACK);
|
||||||
|
|
||||||
Status = PcRtcInit (&mModuleGlobal);
|
Status = PcRtcInit (&mModuleGlobal);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
|
|
Loading…
Reference in New Issue