Revision: 16459
http://sourceforge.net/p/edk2/code/16459
Author: vanjeff
Date: 2014-12-01 08:40:59 +0000 (Mon, 01 Dec 2014)
Log Message:
-----------
Initialize alarm register in PcRtc module entrypoint to make UEFI SCT
GetWakeupTime pass.
(Sync patch r16425 from main trunk.)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Elvin Li <[email protected]>
Reviewed-by: Feng Tian <[email protected]>
Reviewed-by: Eric Jin <[email protected]>
Revision Links:
--------------
http://sourceforge.net/p/edk2/code/16425
Modified Paths:
--------------
branches/UDK2014.SP1/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
Modified:
branches/UDK2014.SP1/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
===================================================================
--- branches/UDK2014.SP1/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
2014-12-01 08:22:07 UTC (rev 16458)
+++ branches/UDK2014.SP1/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
2014-12-01 08:40:59 UTC (rev 16459)
@@ -104,6 +104,8 @@
EFI_TIME Time;
UINTN DataSize;
UINT32 TimerVar;
+ BOOLEAN Enabled;
+ BOOLEAN Pending;
//
// Acquire RTC Lock to make access to RTC atomic
@@ -226,11 +228,96 @@
// Reset time value according to new RTC configuration
//
Status = PcRtcSetTime (&Time, Global);
- if(!EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Reset wakeup time value to valid state when wakeup alarm is disabled and
wakeup time is invalid.
+ // Global variable has already had valid SavedTimeZone and Daylight,
+ // so we can use them to get and set wakeup time.
+ //
+ Status = PcRtcGetWakeupTime (&Enabled, &Pending, &Time, Global);
+ if ((Enabled) || (!EFI_ERROR (Status))) {
return EFI_SUCCESS;
- } else {
+ }
+
+ //
+ // When wakeup time is disabled and invalid, reset wakeup time register to
valid state
+ // but keep wakeup alarm disabled.
+ //
+ Time.Second = RTC_INIT_SECOND;
+ Time.Minute = RTC_INIT_MINUTE;
+ Time.Hour = RTC_INIT_HOUR;
+ Time.Day = RTC_INIT_DAY;
+ Time.Month = RTC_INIT_MONTH;
+ Time.Year = RTC_INIT_YEAR;
+ Time.Nanosecond = 0;
+ Time.TimeZone = Global->SavedTimeZone;
+ Time.Daylight = Global->Daylight;;
+
+ //
+ // Acquire RTC Lock to make access to RTC atomic
+ //
+ if (!EfiAtRuntime ()) {
+ EfiAcquireLock (&Global->RtcLock);
+ }
+ //
+ // Wait for up to 0.1 seconds for the RTC to be updated
+ //
+ Status = RtcWaitToUpdate (PcdGet32 (PcdRealTimeClockUpdateTimeout));
+ if (EFI_ERROR (Status)) {
+ if (!EfiAtRuntime ()) {
+ EfiReleaseLock (&Global->RtcLock);
+ }
return EFI_DEVICE_ERROR;
}
+
+ ConvertEfiTimeToRtcTime (&Time, RegisterB, &Century);
+
+ //
+ // 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 (Time),
+ &Time
+ );
+ 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);
+
+ //
+ // Set RTC alarm time registers
+ //
+ RtcWrite (RTC_ADDRESS_SECONDS_ALARM, Time.Second);
+ RtcWrite (RTC_ADDRESS_MINUTES_ALARM, Time.Minute);
+ RtcWrite (RTC_ADDRESS_HOURS_ALARM, Time.Hour);
+
+ //
+ // Allow updates of the RTC registers
+ //
+ RegisterB.Bits.Set = 0;
+ RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
+
+ //
+ // Release RTC Lock.
+ //
+ if (!EfiAtRuntime ()) {
+ EfiReleaseLock (&Global->RtcLock);
+ }
+ return EFI_SUCCESS;
}
/**
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits