X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=PcAtChipsetPkg%2FPcatRealTimeClockRuntimeDxe%2FPcRtc.c;h=659c01e57a7f0a464c2e872c81812e5d81bd7da9;hp=d26e92360584ed3ecb4058eaa1b2e7e8c12e955c;hb=2b649f74775d0efd1e75c91f77c3045ae6249cb4;hpb=345e5a65561472092378597fbd7e5d1e55e79c44 diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c index d26e923605..659c01e57a 100644 --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c @@ -1,8 +1,8 @@ /** @file RTC Architectural Protocol GUID as defined in DxeCis 0.96. -Copyright (c) 2006 - 2007, Intel Corporation -All rights reserved. This program and the accompanying materials +Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.
+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 http://opensource.org/licenses/bsd-license.php @@ -108,7 +108,6 @@ PcRtcInit ( // // Acquire RTC Lock to make access to RTC atomic // - //Code here doesn't consider the runtime environment. if (!EfiAtRuntime ()) { EfiAcquireLock (&Global->RtcLock); } @@ -142,7 +141,6 @@ PcRtcInit ( // Status = RtcWaitToUpdate (PcdGet32 (PcdRealTimeClockUpdateTimeout)); if (EFI_ERROR (Status)) { - //Code here doesn't consider the runtime environment. if (!EfiAtRuntime ()) { EfiReleaseLock (&Global->RtcLock); } @@ -169,11 +167,30 @@ PcRtcInit ( // // Release RTC Lock. // - //Code here doesn't consider the runtime environment. if (!EfiAtRuntime ()) { EfiReleaseLock (&Global->RtcLock); } + // + // Get the data of Daylight saving and time zone, if they have been + // stored in NV variable during previous boot. + // + DataSize = sizeof (UINT32); + Status = EfiGetVariable ( + L"RTC", + &gEfiCallerIdGuid, + NULL, + &DataSize, + (VOID *) &TimerVar + ); + if (!EFI_ERROR (Status)) { + Time.TimeZone = (INT16) TimerVar; + Time.Daylight = (UINT8) (TimerVar >> 16); + } else { + Time.TimeZone = EFI_UNSPECIFIED_TIMEZONE; + Time.Daylight = 0; + } + // // Validate time fields // @@ -188,32 +205,18 @@ PcRtcInit ( Time.Day = RTC_INIT_DAY; Time.Month = RTC_INIT_MONTH; Time.Year = RTC_INIT_YEAR; + Time.Nanosecond = 0; } - // - // Get the data of Daylight saving and time zone, if they have been - // stored in NV variable during previous boot. - // - DataSize = sizeof (UINT32); - Status = EfiGetVariable ( - L"RTC", - &gEfiCallerIdGuid, - NULL, - &DataSize, - (VOID *) &TimerVar - ); - if (!EFI_ERROR (Status)) { - Global->SavedTimeZone = (INT16) TimerVar; - Global->Daylight = (UINT8) (TimerVar >> 16); - Time.TimeZone = Global->SavedTimeZone; - Time.Daylight = Global->Daylight; - } // // Reset time value according to new RTC configuration // - PcRtcSetTime (&Time, Global); - - return EFI_SUCCESS; + Status = PcRtcSetTime (&Time, Global); + if(!EFI_ERROR (Status)) { + return EFI_SUCCESS; + } else { + return EFI_DEVICE_ERROR; + } } /** @@ -251,7 +254,6 @@ PcRtcGetTime ( // // Acquire RTC Lock to make access to RTC atomic // - //Code here doesn't consider the runtime environment. if (!EfiAtRuntime ()) { EfiAcquireLock (&Global->RtcLock); } @@ -260,7 +262,6 @@ PcRtcGetTime ( // Status = RtcWaitToUpdate (PcdGet32 (PcdRealTimeClockUpdateTimeout)); if (EFI_ERROR (Status)) { - //Code here doesn't consider the runtime environment. if (!EfiAtRuntime ()) { EfiReleaseLock (&Global->RtcLock); } @@ -286,10 +287,10 @@ PcRtcGetTime ( // // Release RTC Lock. // - //Code here doesn't consider the runtime environment. if (!EfiAtRuntime ()) { EfiReleaseLock (&Global->RtcLock); } + // // Get the variable that contains the TimeZone and Daylight fields // @@ -306,6 +307,7 @@ PcRtcGetTime ( if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } + // // Fill in Capabilities if it was passed in // @@ -363,7 +365,6 @@ PcRtcSetTime ( // // Acquire RTC Lock to make access to RTC atomic // - //Code here doesn't consider the runtime environment. if (!EfiAtRuntime ()) { EfiAcquireLock (&Global->RtcLock); } @@ -372,7 +373,6 @@ PcRtcSetTime ( // Status = RtcWaitToUpdate (PcdGet32 (PcdRealTimeClockUpdateTimeout)); if (EFI_ERROR (Status)) { - //Code here doesn't consider the runtime environment. if (!EfiAtRuntime ()) { EfiReleaseLock (&Global->RtcLock); } @@ -404,7 +404,6 @@ PcRtcSetTime ( // // Release RTC Lock. // - //Code here doesn't consider the runtime environment. if (!EfiAtRuntime ()) { EfiReleaseLock (&Global->RtcLock); } @@ -467,7 +466,6 @@ PcRtcGetWakeupTime ( // // Acquire RTC Lock to make access to RTC atomic // - //Code here doesn't consider the runtime environment. if (!EfiAtRuntime ()) { EfiAcquireLock (&Global->RtcLock); } @@ -476,7 +474,6 @@ PcRtcGetWakeupTime ( // Status = RtcWaitToUpdate (PcdGet32 (PcdRealTimeClockUpdateTimeout)); if (EFI_ERROR (Status)) { - //Code here doesn't consider the runtime environment. if (!EfiAtRuntime ()) { EfiReleaseLock (&Global->RtcLock); } @@ -513,10 +510,16 @@ PcRtcGetWakeupTime ( // // Release RTC Lock. // - //Code here doesn't consider the runtime environment. if (!EfiAtRuntime ()) { 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 // @@ -593,7 +596,6 @@ PcRtcSetWakeupTime ( // // Acquire RTC Lock to make access to RTC atomic // - //Code here doesn't consider the runtime environment. if (!EfiAtRuntime ()) { EfiAcquireLock (&Global->RtcLock); } @@ -602,7 +604,6 @@ PcRtcSetWakeupTime ( // Status = RtcWaitToUpdate (PcdGet32 (PcdRealTimeClockUpdateTimeout)); if (EFI_ERROR (Status)) { - //Code here doesn't consider the runtime environment. if (!EfiAtRuntime ()) { EfiReleaseLock (&Global->RtcLock); } @@ -640,7 +641,6 @@ PcRtcSetWakeupTime ( // // Release RTC Lock. // - //Code here doesn't consider the runtime environment. if (!EfiAtRuntime ()) { EfiReleaseLock (&Global->RtcLock); } @@ -739,8 +739,6 @@ ConvertRtcTimeToEfiTime ( } Time->Nanosecond = 0; - Time->TimeZone = EFI_UNSPECIFIED_TIMEZONE; - Time->Daylight = 0; return EFI_SUCCESS; } @@ -806,16 +804,14 @@ RtcTimeFieldsValid ( Time->Year > 2099 || Time->Month < 1 || Time->Month > 12 || + (!DayValid (Time)) || Time->Hour > 23 || Time->Minute > 59 || Time->Second > 59 || Time->Nanosecond > 999999999 || (!(Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE || (Time->TimeZone >= -1440 && Time->TimeZone <= 1440))) || - ((Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT))) != 0) - ) { - if (!DayValid (Time)) { - return EFI_INVALID_PARAMETER; - } + ((Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT))) != 0)) { + return EFI_INVALID_PARAMETER; } return EFI_SUCCESS;