summaryrefslogtreecommitdiffstats
path: root/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe
diff options
context:
space:
mode:
authorerictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>2010-11-10 03:18:21 +0000
committererictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>2010-11-10 03:18:21 +0000
commit7018623cd400d69848b94acb6008bf223cb75204 (patch)
tree84502ff2043a7879701cb62521e7a9461fa2cf42 /PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe
parentf13f9683db63498c15dd147edc895c4f7358d8a2 (diff)
downloadedk2-7018623cd400d69848b94acb6008bf223cb75204.tar.gz
edk2-7018623cd400d69848b94acb6008bf223cb75204.tar.bz2
edk2-7018623cd400d69848b94acb6008bf223cb75204.zip
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
Diffstat (limited to 'PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe')
-rw-r--r--PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c88
-rw-r--r--PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c2
2 files changed, 64 insertions, 26 deletions
diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
index 6c7e0ca6d7..35eb60ade4 100644
--- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
+++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
@@ -1,7 +1,7 @@
/** @file
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
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
@@ -234,6 +234,7 @@ PcRtcInit (
**/
EFI_STATUS
+EFIAPI
PcRtcGetTime (
OUT EFI_TIME *Time,
OUT EFI_TIME_CAPABILITIES *Capabilities, OPTIONAL
@@ -338,6 +339,7 @@ PcRtcGetTime (
**/
EFI_STATUS
+EFIAPI
PcRtcSetTime (
IN EFI_TIME *Time,
IN PC_RTC_MODULE_GLOBALS *Global
@@ -455,6 +457,8 @@ PcRtcGetWakeupTime (
RTC_REGISTER_B RegisterB;
RTC_REGISTER_C RegisterC;
UINT8 Century;
+ EFI_TIME RtcTime;
+ UINTN DataSize;
//
// Check parameters for null pointers
@@ -489,36 +493,44 @@ PcRtcGetWakeupTime (
// Get the Time/Date/Daylight Savings values.
//
*Enabled = RegisterB.Bits.Aie;
- if (*Enabled) {
- Time->Second = RtcRead (RTC_ADDRESS_SECONDS_ALARM);
- Time->Minute = RtcRead (RTC_ADDRESS_MINUTES_ALARM);
- Time->Hour = RtcRead (RTC_ADDRESS_HOURS_ALARM);
- Time->Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
- Time->Month = RtcRead (RTC_ADDRESS_MONTH);
- Time->Year = RtcRead (RTC_ADDRESS_YEAR);
- } else {
- Time->Second = 0;
- 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);
- }
+ *Pending = RegisterC.Bits.Af;
+
+ Time->Second = RtcRead (RTC_ADDRESS_SECONDS_ALARM);
+ Time->Minute = RtcRead (RTC_ADDRESS_MINUTES_ALARM);
+ Time->Hour = RtcRead (RTC_ADDRESS_HOURS_ALARM);
+ Time->Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
+ Time->Month = RtcRead (RTC_ADDRESS_MONTH);
+ Time->Year = RtcRead (RTC_ADDRESS_YEAR);
+ Time->TimeZone = Global->SavedTimeZone;
+ Time->Daylight = Global->Daylight;
Century = RtcRead (RTC_ADDRESS_CENTURY);
-
+
//
- // Release RTC Lock.
+ // Get the alarm info from variable
//
- if (!EfiAtRuntime ()) {
- EfiReleaseLock (&Global->RtcLock);
+ 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;
}
//
- // Get the variable that contains the TimeZone and Daylight fields
+ // Release RTC Lock.
//
- Time->TimeZone = Global->SavedTimeZone;
- Time->Daylight = Global->Daylight;
+ if (!EfiAtRuntime ()) {
+ EfiReleaseLock (&Global->RtcLock);
+ }
//
// Make sure all field values are in correct range
@@ -531,8 +543,6 @@ PcRtcGetWakeupTime (
return EFI_DEVICE_ERROR;
}
- *Pending = RegisterC.Bits.Af;
-
return EFI_SUCCESS;
}
@@ -552,6 +562,7 @@ PcRtcGetWakeupTime (
**/
EFI_STATUS
+EFIAPI
PcRtcSetWakeupTime (
IN BOOLEAN Enable,
IN EFI_TIME *Time, OPTIONAL
@@ -564,6 +575,8 @@ PcRtcSetWakeupTime (
UINT8 Century;
EFI_TIME_CAPABILITIES Capabilities;
+ ZeroMem (RtcTime);
+
if (Enable) {
if (Time == NULL) {
@@ -631,6 +644,17 @@ PcRtcSetWakeupTime (
} else {
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
@@ -639,6 +663,20 @@ PcRtcSetWakeupTime (
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.
//
if (!EfiAtRuntime ()) {
diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c
index 03480830e2..16f74b83c9 100644
--- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c
+++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c
@@ -134,7 +134,7 @@ InitializePcRtc (
{
EFI_STATUS Status;
- EfiInitializeLock (&mModuleGlobal.RtcLock, TPL_HIGH_LEVEL);
+ EfiInitializeLock (&mModuleGlobal.RtcLock, TPL_CALLBACK);
Status = PcRtcInit (&mModuleGlobal);
if (EFI_ERROR (Status)) {