mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-23 13:44:33 +02:00
ArmPlatformPkg/PL031RealTimeClockLib: Set PL031_{TimeZone,Daylight} UEFI variables as local
PL031_TimeZone and PL031_Daylight are not global variables as defined by UEFI specification Signed-off-by: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14107 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
d5cd447b1f
commit
1e43cdfdd4
@ -34,9 +34,9 @@
|
|||||||
|
|
||||||
#include <ArmPlatform.h>
|
#include <ArmPlatform.h>
|
||||||
|
|
||||||
CHAR16 mTimeZoneVariableName[] = L"PL031_TimeZone";
|
STATIC CONST CHAR16 mTimeZoneVariableName[] = L"PL031RtcTimeZone";
|
||||||
CHAR16 mDaylightVariableName[] = L"PL031_Daylight";
|
STATIC CONST CHAR16 mDaylightVariableName[] = L"PL031RtcDaylight";
|
||||||
BOOLEAN mPL031Initialized = FALSE;
|
STATIC BOOLEAN mPL031Initialized = FALSE;
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
IdentifyPL031 (
|
IdentifyPL031 (
|
||||||
@ -129,10 +129,6 @@ EpochToEfiTime (
|
|||||||
UINTN ss;
|
UINTN ss;
|
||||||
UINTN J;
|
UINTN J;
|
||||||
|
|
||||||
if (Time->Daylight == TRUE) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
J = (EpochSeconds / 86400) + 2440588;
|
J = (EpochSeconds / 86400) + 2440588;
|
||||||
j = J + 32044;
|
j = J + 32044;
|
||||||
g = j / 146097;
|
g = j / 146097;
|
||||||
@ -241,6 +237,7 @@ DayValid (
|
|||||||
@retval EFI_SUCCESS The operation completed successfully.
|
@retval EFI_SUCCESS The operation completed successfully.
|
||||||
@retval EFI_INVALID_PARAMETER Time is NULL.
|
@retval EFI_INVALID_PARAMETER Time is NULL.
|
||||||
@retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.
|
@retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.
|
||||||
|
@retval EFI_SECURITY_VIOLATION The time could not be retrieved due to an authentication failure.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
@ -252,8 +249,9 @@ LibGetTime (
|
|||||||
{
|
{
|
||||||
EFI_STATUS Status = EFI_SUCCESS;
|
EFI_STATUS Status = EFI_SUCCESS;
|
||||||
UINT32 EpochSeconds;
|
UINT32 EpochSeconds;
|
||||||
INT16 *TimeZone = 0;
|
INT16 TimeZone;
|
||||||
UINTN *Daylight = 0;
|
UINT8 Daylight;
|
||||||
|
UINTN Size;
|
||||||
|
|
||||||
// Initialize the hardware if not already done
|
// Initialize the hardware if not already done
|
||||||
if (!mPL031Initialized) {
|
if (!mPL031Initialized) {
|
||||||
@ -287,27 +285,44 @@ LibGetTime (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the current time zone information from non-volatile storage
|
// Get the current time zone information from non-volatile storage
|
||||||
TimeZone = (INT16 *)GetVariable(mTimeZoneVariableName, &gEfiGlobalVariableGuid);
|
Size = sizeof (TimeZone);
|
||||||
|
Status = gRT->GetVariable (
|
||||||
|
(CHAR16 *)mTimeZoneVariableName,
|
||||||
|
&gEfiCallerIdGuid,
|
||||||
|
NULL,
|
||||||
|
&Size,
|
||||||
|
(VOID *)&TimeZone
|
||||||
|
);
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
ASSERT(Status != EFI_INVALID_PARAMETER);
|
||||||
|
ASSERT(Status != EFI_BUFFER_TOO_SMALL);
|
||||||
|
|
||||||
|
if (Status != EFI_NOT_FOUND)
|
||||||
|
goto EXIT;
|
||||||
|
|
||||||
if (TimeZone == NULL) {
|
|
||||||
// The time zone variable does not exist in non-volatile storage, so create it.
|
// The time zone variable does not exist in non-volatile storage, so create it.
|
||||||
Time->TimeZone = EFI_UNSPECIFIED_TIMEZONE;
|
Time->TimeZone = EFI_UNSPECIFIED_TIMEZONE;
|
||||||
// Store it
|
// Store it
|
||||||
Status = gRT->SetVariable (
|
Status = gRT->SetVariable (
|
||||||
mTimeZoneVariableName,
|
(CHAR16 *)mTimeZoneVariableName,
|
||||||
&gEfiGlobalVariableGuid,
|
&gEfiCallerIdGuid,
|
||||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||||
sizeof(Time->TimeZone),
|
Size,
|
||||||
&(Time->TimeZone)
|
(VOID *)&(Time->TimeZone)
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR,"LibGetTime: ERROR: TimeZone\n"));
|
DEBUG ((
|
||||||
|
EFI_D_ERROR,
|
||||||
|
"LibGetTime: Failed to save %s variable to non-volatile storage, Status = %r\n",
|
||||||
|
mTimeZoneVariableName,
|
||||||
|
Status
|
||||||
|
));
|
||||||
goto EXIT;
|
goto EXIT;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Got the time zone
|
// Got the time zone
|
||||||
Time->TimeZone = *TimeZone;
|
Time->TimeZone = TimeZone;
|
||||||
FreePool(TimeZone);
|
|
||||||
|
|
||||||
// Check TimeZone bounds: -1440 to 1440 or 2047
|
// Check TimeZone bounds: -1440 to 1440 or 2047
|
||||||
if (((Time->TimeZone < -1440) || (Time->TimeZone > 1440))
|
if (((Time->TimeZone < -1440) || (Time->TimeZone > 1440))
|
||||||
@ -322,27 +337,44 @@ LibGetTime (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the current daylight information from non-volatile storage
|
// Get the current daylight information from non-volatile storage
|
||||||
Daylight = (UINTN *)GetVariable(mDaylightVariableName, &gEfiGlobalVariableGuid);
|
Size = sizeof (Daylight);
|
||||||
|
Status = gRT->GetVariable (
|
||||||
|
(CHAR16 *)mDaylightVariableName,
|
||||||
|
&gEfiCallerIdGuid,
|
||||||
|
NULL,
|
||||||
|
&Size,
|
||||||
|
(VOID *)&Daylight
|
||||||
|
);
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
ASSERT(Status != EFI_INVALID_PARAMETER);
|
||||||
|
ASSERT(Status != EFI_BUFFER_TOO_SMALL);
|
||||||
|
|
||||||
|
if (Status != EFI_NOT_FOUND)
|
||||||
|
goto EXIT;
|
||||||
|
|
||||||
if (Daylight == NULL) {
|
|
||||||
// The daylight variable does not exist in non-volatile storage, so create it.
|
// The daylight variable does not exist in non-volatile storage, so create it.
|
||||||
Time->Daylight = 0;
|
Time->Daylight = 0;
|
||||||
// Store it
|
// Store it
|
||||||
Status = gRT->SetVariable (
|
Status = gRT->SetVariable (
|
||||||
mDaylightVariableName,
|
(CHAR16 *)mDaylightVariableName,
|
||||||
&gEfiGlobalVariableGuid,
|
&gEfiCallerIdGuid,
|
||||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||||
sizeof(Time->Daylight),
|
Size,
|
||||||
&(Time->Daylight)
|
(VOID *)&(Time->Daylight)
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR,"LibGetTime: ERROR: Daylight\n"));
|
DEBUG ((
|
||||||
|
EFI_D_ERROR,
|
||||||
|
"LibGetTime: Failed to save %s variable to non-volatile storage, Status = %r\n",
|
||||||
|
mDaylightVariableName,
|
||||||
|
Status
|
||||||
|
));
|
||||||
goto EXIT;
|
goto EXIT;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Got the daylight information
|
// Got the daylight information
|
||||||
Time->Daylight = *Daylight;
|
Time->Daylight = Daylight;
|
||||||
FreePool(Daylight);
|
|
||||||
|
|
||||||
// Adjust for the correct period
|
// Adjust for the correct period
|
||||||
if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) {
|
if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) {
|
||||||
@ -457,27 +489,37 @@ LibSetTime (
|
|||||||
|
|
||||||
// Save the current time zone information into non-volatile storage
|
// Save the current time zone information into non-volatile storage
|
||||||
Status = gRT->SetVariable (
|
Status = gRT->SetVariable (
|
||||||
mTimeZoneVariableName,
|
(CHAR16 *)mTimeZoneVariableName,
|
||||||
&gEfiGlobalVariableGuid,
|
&gEfiCallerIdGuid,
|
||||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||||
sizeof (Time->TimeZone),
|
sizeof (Time->TimeZone),
|
||||||
&(Time->TimeZone)
|
(VOID *)&(Time->TimeZone)
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR,"LibSetTime: ERROR: TimeZone\n"));
|
DEBUG ((
|
||||||
|
EFI_D_ERROR,
|
||||||
|
"LibSetTime: Failed to save %s variable to non-volatile storage, Status = %r\n",
|
||||||
|
mTimeZoneVariableName,
|
||||||
|
Status
|
||||||
|
));
|
||||||
goto EXIT;
|
goto EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the current daylight information into non-volatile storage
|
// Save the current daylight information into non-volatile storage
|
||||||
Status = gRT->SetVariable (
|
Status = gRT->SetVariable (
|
||||||
mDaylightVariableName,
|
(CHAR16 *)mDaylightVariableName,
|
||||||
&gEfiGlobalVariableGuid,
|
&gEfiCallerIdGuid,
|
||||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||||
sizeof(Time->Daylight),
|
sizeof(Time->Daylight),
|
||||||
&(Time->Daylight)
|
(VOID *)&(Time->Daylight)
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR,"LibSetTime: ERROR: Daylight\n"));
|
DEBUG ((
|
||||||
|
EFI_D_ERROR,
|
||||||
|
"LibSetTime: Failed to save %s variable to non-volatile storage, Status = %r\n",
|
||||||
|
mDaylightVariableName,
|
||||||
|
Status
|
||||||
|
));
|
||||||
goto EXIT;
|
goto EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#/** @file
|
#/** @file
|
||||||
# Memory Status Code Library for UEFI drivers
|
|
||||||
#
|
#
|
||||||
# Lib to provide memory journal status code reporting Routines
|
|
||||||
# Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
# Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
||||||
|
# Copyright (c) 2011-2013, ARM Ltd. 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
|
||||||
@ -25,7 +24,6 @@
|
|||||||
[Sources.common]
|
[Sources.common]
|
||||||
PL031RealTimeClockLib.c
|
PL031RealTimeClockLib.c
|
||||||
|
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
EmbeddedPkg/EmbeddedPkg.dec
|
EmbeddedPkg/EmbeddedPkg.dec
|
||||||
|
Loading…
x
Reference in New Issue
Block a user