diff options
author | Elvin Li <elvin.li@intel.com> | 2014-03-19 02:42:36 +0000 |
---|---|---|
committer | li-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-03-19 02:42:36 +0000 |
commit | 0e991a2f87e6146a203dc7ed138a77a1b9796c74 (patch) | |
tree | cfe79a0477a421093dedb5b3598a015da9ee3ecc /PcAtChipsetPkg | |
parent | ef4defca7a2b8b3bab11c51e92c7a82f9ab1de84 (diff) | |
download | edk2-platforms-0e991a2f87e6146a203dc7ed138a77a1b9796c74.tar.xz |
Did proper error handling when SetVariable failed, and put RTC write operation at the behind of SetVariable, if SetVariable failed, RTC content could not be changed.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Elvin Li <elvin.li@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15338 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'PcAtChipsetPkg')
-rw-r--r-- | PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 84 |
1 files changed, 51 insertions, 33 deletions
diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c index ab4ea8206a..a77009a217 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 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2014, 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
@@ -392,6 +392,26 @@ PcRtcSetTime ( }
return Status;
}
+
+ //
+ // Write timezone and daylight to RTC variable
+ //
+ TimerVar = Time->Daylight;
+ TimerVar = (UINT32) ((TimerVar << 16) | (UINT16)(Time->TimeZone));
+ Status = EfiSetVariable (
+ L"RTC",
+ &gEfiCallerIdGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ sizeof (TimerVar),
+ &TimerVar
+ );
+ if (EFI_ERROR (Status)) {
+ if (!EfiAtRuntime ()) {
+ EfiReleaseLock (&Global->RtcLock);
+ }
+ return EFI_DEVICE_ERROR;
+ }
+
//
// Read Register B, and inhibit updates of the RTC
//
@@ -427,17 +447,6 @@ PcRtcSetTime ( Global->SavedTimeZone = Time->TimeZone;
Global->Daylight = Time->Daylight;
- TimerVar = Time->Daylight;
- TimerVar = (UINT32) ((TimerVar << 16) | (UINT16)(Time->TimeZone));
- Status = EfiSetVariable (
- L"RTC",
- &gEfiCallerIdGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- sizeof (TimerVar),
- &TimerVar
- );
- ASSERT_EFI_ERROR (Status);
-
return EFI_SUCCESS;
}
@@ -635,27 +644,13 @@ PcRtcSetWakeupTime ( return EFI_DEVICE_ERROR;
}
//
- // Read Register B, and inhibit updates of the RTC
+ // Read Register B
//
- RegisterB.Data = RtcRead (RTC_ADDRESS_REGISTER_B);
-
- RegisterB.Bits.Set = 1;
- RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
+ RegisterB.Data = RtcRead (RTC_ADDRESS_REGISTER_B);
if (Enable) {
ConvertEfiTimeToRtcTime (&RtcTime, RegisterB, &Century);
-
- //
- // Set RTC alarm time
- //
- RtcWrite (RTC_ADDRESS_SECONDS_ALARM, RtcTime.Second);
- RtcWrite (RTC_ADDRESS_MINUTES_ALARM, RtcTime.Minute);
- RtcWrite (RTC_ADDRESS_HOURS_ALARM, RtcTime.Hour);
-
- RegisterB.Bits.Aie = 1;
-
} else {
- RegisterB.Bits.Aie = 0;
//
// if the alarm is disable, record the current setting.
//
@@ -668,11 +663,6 @@ PcRtcSetWakeupTime ( RtcTime.TimeZone = Global->SavedTimeZone;
RtcTime.Daylight = Global->Daylight;
}
- //
- // Allow updates of the RTC registers
- //
- RegisterB.Bits.Set = 0;
- RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
//
// Set the Y/M/D info to variable as it has no corresponding hw registers.
@@ -685,8 +675,36 @@ PcRtcSetWakeupTime ( &RtcTime
);
if (EFI_ERROR (Status)) {
+ if (!EfiAtRuntime ()) {
+ EfiReleaseLock (&Global->RtcLock);
+ }
return EFI_DEVICE_ERROR;
}
+
+ //
+ // Inhibit updates of the RTC
+ //
+ RegisterB.Bits.Set = 1;
+ RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
+
+ if (Enable) {
+ //
+ // Set RTC alarm time
+ //
+ RtcWrite (RTC_ADDRESS_SECONDS_ALARM, RtcTime.Second);
+ RtcWrite (RTC_ADDRESS_MINUTES_ALARM, RtcTime.Minute);
+ RtcWrite (RTC_ADDRESS_HOURS_ALARM, RtcTime.Hour);
+
+ RegisterB.Bits.Aie = 1;
+
+ } else {
+ RegisterB.Bits.Aie = 0;
+ }
+ //
+ // Allow updates of the RTC registers
+ //
+ RegisterB.Bits.Set = 0;
+ RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
//
// Release RTC Lock.
|