summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Vlv2TbltDevicePkg/PlatformDxe/Platform.c7
-rw-r--r--Vlv2TbltDevicePkg/PlatformDxe/PlatformDxe.h4
-rw-r--r--Vlv2TbltDevicePkg/PlatformDxe/PlatformDxe.inf5
-rw-r--r--Vlv2TbltDevicePkg/PlatformDxe/Rtc.c176
-rw-r--r--Vlv2TbltDevicePkg/PlatformPei/Platform.c7
-rw-r--r--Vlv2TbltDevicePkg/PlatformPei/PlatformPei.inf4
-rw-r--r--Vlv2TbltDevicePkg/PlatformPkg.dec2
-rw-r--r--Vlv2TbltDevicePkg/PlatformPkg.fdf3
-rw-r--r--Vlv2TbltDevicePkg/PlatformPkgGcc.fdf3
-rw-r--r--Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc5
-rw-r--r--Vlv2TbltDevicePkg/PlatformPkgIA32.dsc5
-rw-r--r--Vlv2TbltDevicePkg/PlatformPkgX64.dsc6
-rw-r--r--Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatformRtc.c137
-rw-r--r--Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatformRtc.h33
-rw-r--r--Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatformRtc.unibin0 -> 1906 bytes
-rw-r--r--Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatformRtcRuntimeDxe.inf60
-rw-r--r--Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatfromRtcExtra.unibin0 -> 1378 bytes
17 files changed, 376 insertions, 81 deletions
diff --git a/Vlv2TbltDevicePkg/PlatformDxe/Platform.c b/Vlv2TbltDevicePkg/PlatformDxe/Platform.c
index 6ddc305f3a..439b6d9229 100644
--- a/Vlv2TbltDevicePkg/PlatformDxe/Platform.c
+++ b/Vlv2TbltDevicePkg/PlatformDxe/Platform.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
@@ -996,12 +996,13 @@ InitializePlatform (
);
//
- // Adjust RTC deafult time to be BIOS-built time.
+ // This callback function adjusts RTC time to a value which was set by user in UEFI Shell or Setup browaser and which
+ // was also saved in UEFI variable. If no UEFI variable "SystemRtcTime" found, just set RTC time to BIOS built time.
//
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
TPL_CALLBACK,
- AdjustDefaultRtcTimeCallback,
+ AdjustRtcTimeCallback,
NULL,
&RtcEvent
);
diff --git a/Vlv2TbltDevicePkg/PlatformDxe/PlatformDxe.h b/Vlv2TbltDevicePkg/PlatformDxe/PlatformDxe.h
index ec69e617dc..33e3b1d6c3 100644
--- a/Vlv2TbltDevicePkg/PlatformDxe/PlatformDxe.h
+++ b/Vlv2TbltDevicePkg/PlatformDxe/PlatformDxe.h
@@ -1,6 +1,6 @@
/*++
- Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2004 - 2016, 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 that accompanies this distribution.
@@ -638,7 +638,7 @@ PciBusDriverHook();
VOID
EFIAPI
-AdjustDefaultRtcTimeCallback (
+AdjustRtcTimeCallback (
IN EFI_EVENT Event,
IN VOID *Context
);
diff --git a/Vlv2TbltDevicePkg/PlatformDxe/PlatformDxe.inf b/Vlv2TbltDevicePkg/PlatformDxe/PlatformDxe.inf
index 63ccf03029..8fa64a749e 100644
--- a/Vlv2TbltDevicePkg/PlatformDxe/PlatformDxe.inf
+++ b/Vlv2TbltDevicePkg/PlatformDxe/PlatformDxe.inf
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved
+# Copyright (c) 1999 - 2016, 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 that accompanies this distribution.
@@ -83,6 +83,7 @@
EfiRegTableLib
BiosIdLib
BaseCryptLib
+ PcdLib
[Guids]
gEfiBiosIdGuid
@@ -97,6 +98,7 @@
gEfiEventExitBootServicesGuid
gEfiVlv2VariableGuid
gEfiSecureBootEnableDisableGuid
+ gSystemRtcTimeVariableGuid
[Protocols]
gEfiPciRootBridgeIoProtocolGuid # CONSUMES ## GUID
@@ -141,6 +143,7 @@
gPlatformModuleTokenSpaceGuid.PcdFlashFvRecoveryBase
gPlatformModuleTokenSpaceGuid.PcdFlashFvRecoverySize
gFspWrapperTokenSpaceGuid.PcdFlashFvFspBase
+ gPlatformModuleTokenSpaceGuid.PcdRtcPowerFailure
[Depex]
diff --git a/Vlv2TbltDevicePkg/PlatformDxe/Rtc.c b/Vlv2TbltDevicePkg/PlatformDxe/Rtc.c
index 9415b7e2ad..d1467a8836 100644
--- a/Vlv2TbltDevicePkg/PlatformDxe/Rtc.c
+++ b/Vlv2TbltDevicePkg/PlatformDxe/Rtc.c
@@ -1,7 +1,7 @@
/** @file
Adjust Default System Time.
- Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2016, 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 that accompanies this distribution.
@@ -28,6 +28,8 @@
#define RTC_ADDRESS_REGISTER 0x70
#define RTC_DATA_REGISTER 0x71
+extern EFI_GUID gSystemRtcTimeVariableGuid;
+
CHAR16 mBiosReleaseDate[20];
@@ -91,86 +93,118 @@ CheckRtcTimeFields (
**/
VOID
EFIAPI
-AdjustDefaultRtcTimeCallback (
+AdjustRtcTimeCallback (
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_STATUS Status;
EFI_TIME EfiTime;
+ EFI_TIME RtcTime;
UINT8 Century;
CHAR16 BiosVersion[60];
- CHAR16 BiosReleaseTime[20];
- //
- // Get BIOS built time from Bios-ID.
- //
-
- SetMem(BiosVersion, sizeof(BiosVersion), 0);
- SetMem(mBiosReleaseDate, sizeof(mBiosReleaseDate), 0);
- SetMem(BiosReleaseTime, sizeof(BiosReleaseTime), 0);
-
- Status = GetBiosVersionDateTime (BiosVersion, mBiosReleaseDate, BiosReleaseTime);
- ASSERT_EFI_ERROR(Status);
- if (EFI_ERROR (Status)) {
- return;
- }
-
- //
- // Get current RTC time.
- //
- Status = gRT->GetTime (&EfiTime, NULL);
-
- //
- // Validate RTC time fields
- //
- Status = CheckRtcTimeFields (&EfiTime);
-
- if (EFI_ERROR (Status)) {
- //
- // Date such as Dec 28th of 2015
- //
- // Month
- // BiosReleaseDate[0] = '1';
- // BiosReleaseDate[1] = '2';
- //
- // Day
- // BiosReleaseDate[3] = '2';
- // BiosReleaseDate[4] = '8';
- //
- //
- // Year
- //
- // BiosReleaseDate[6] = '2';
- // BiosReleaseDate[7] = '0';
- // BiosReleaseDate[8] = '1'
- // BiosReleaseDate[9] = '5';
-
- EfiTime.Second = RTC_INIT_SECOND;
- EfiTime.Minute = RTC_INIT_MINUTE;
- EfiTime.Hour = RTC_INIT_HOUR;
- EfiTime.Day = (UINT8)(CharToUint(mBiosReleaseDate[3])*10 + CharToUint(mBiosReleaseDate[4]));
- EfiTime.Month = (UINT8)(CharToUint(mBiosReleaseDate[0])*10 + CharToUint(mBiosReleaseDate[1]));
- EfiTime.Year = (UINT16)(CharToUint(mBiosReleaseDate[8])*10 + CharToUint(mBiosReleaseDate[9]) + 2000);
- EfiTime.Nanosecond = 0;
- EfiTime.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
- EfiTime.Daylight = 1;
-
- DEBUG ((EFI_D_INFO, "Day:%d Month:%d Year:%d \n", (UINT32)EfiTime.Day, (UINT32)EfiTime.Month, (UINT32)EfiTime.Year));
-
- //
- // Reset time value according to new RTC configuration
- //
- Status = gRT->SetTime (&EfiTime);
- ASSERT_EFI_ERROR(Status);
+ CHAR16 BiosReleaseTime[20];
+ UINTN DataSize;
+ if (PcdGetBool(PcdRtcPowerFailure)) {
//
- // Set the RTC century in case that UEFI SetTime sevice does not set this register.
+ // If Rtc Power failure occured, get the valid RTC time from UEFI variable,
+ // which was saved by UEFI SetTime servie when user set system time in UEFI Shell
+ // or Setup browser.
//
- Century = DecimalToBcd8 ((UINT8) (EfiTime.Year / 100));
- IoWrite8 (RTC_ADDRESS_REGISTER, (UINT8) (RTC_ADDRESS_CENTURY | (UINT8) (IoRead8 (PCAT_RTC_ADDRESS_REGISTER) & 0x80)));
- IoWrite8 (RTC_DATA_REGISTER, Century);
-
+
+ PcdSetBool(PcdRtcPowerFailure, FALSE);
+
+ DataSize = sizeof (EFI_TIME);
+ Status = gRT->GetVariable(
+ L"SystemRtcTime",
+ &gSystemRtcTimeVariableGuid,
+ NULL,
+ &DataSize,
+ &RtcTime
+ );
+ if (!EFI_ERROR(Status)) {
+ DEBUG ((EFI_D_INFO, "Day:%d Month:%d Year:%d \n", (UINT32)RtcTime.Day, (UINT32)RtcTime.Month, (UINT32)RtcTime.Year));
+ DEBUG ((EFI_D_INFO, "Second:%d Minute:%d Hour:%d \n", (UINT32)RtcTime.Second, (UINT32)RtcTime.Minute, (UINT32)RtcTime.Hour));
+ Status = gRT->SetTime (&RtcTime);
+ //
+ // Set the RTC century in case that UEFI SetTime sevice does not set this register.
+ //
+ Century = DecimalToBcd8 ((UINT8) (RtcTime.Year / 100));
+ IoWrite8 (RTC_ADDRESS_REGISTER, (UINT8) (RTC_ADDRESS_CENTURY | (UINT8) (IoRead8 (PCAT_RTC_ADDRESS_REGISTER) & 0x80)));
+ IoWrite8 (RTC_DATA_REGISTER, Century);
+
+ } else {
+ //
+ // Get BIOS built time from Bios-ID.
+ //
+
+ SetMem(BiosVersion, sizeof(BiosVersion), 0);
+ SetMem(mBiosReleaseDate, sizeof(mBiosReleaseDate), 0);
+ SetMem(BiosReleaseTime, sizeof(BiosReleaseTime), 0);
+
+ Status = GetBiosVersionDateTime (BiosVersion, mBiosReleaseDate, BiosReleaseTime);
+ ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
+ //
+ // Get current RTC time.
+ //
+ Status = gRT->GetTime (&EfiTime, NULL);
+
+ //
+ // Validate RTC time fields
+ //
+ Status = CheckRtcTimeFields (&EfiTime);
+
+ if (EFI_ERROR (Status)) {
+ //
+ // Date such as Dec 28th of 2015
+ //
+ // Month
+ // BiosReleaseDate[0] = '1';
+ // BiosReleaseDate[1] = '2';
+ //
+ // Day
+ // BiosReleaseDate[3] = '2';
+ // BiosReleaseDate[4] = '8';
+ //
+ //
+ // Year
+ //
+ // BiosReleaseDate[6] = '2';
+ // BiosReleaseDate[7] = '0';
+ // BiosReleaseDate[8] = '1'
+ // BiosReleaseDate[9] = '5';
+
+ EfiTime.Second = RTC_INIT_SECOND;
+ EfiTime.Minute = RTC_INIT_MINUTE;
+ EfiTime.Hour = RTC_INIT_HOUR;
+ EfiTime.Day = (UINT8)(CharToUint(mBiosReleaseDate[3])*10 + CharToUint(mBiosReleaseDate[4]));
+ EfiTime.Month = (UINT8)(CharToUint(mBiosReleaseDate[0])*10 + CharToUint(mBiosReleaseDate[1]));
+ EfiTime.Year = (UINT16)(CharToUint(mBiosReleaseDate[8])*10 + CharToUint(mBiosReleaseDate[9]) + 2000);
+ EfiTime.Nanosecond = 0;
+ EfiTime.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
+ EfiTime.Daylight = 1;
+
+ DEBUG ((EFI_D_INFO, "Day:%d Month:%d Year:%d \n", (UINT32)EfiTime.Day, (UINT32)EfiTime.Month, (UINT32)EfiTime.Year));
+
+ //
+ // Reset time value according to new RTC configuration
+ //
+ Status = gRT->SetTime (&EfiTime);
+ ASSERT_EFI_ERROR(Status);
+
+ //
+ // Set the RTC century in case that UEFI SetTime sevice does not set this register.
+ //
+ Century = DecimalToBcd8 ((UINT8) (EfiTime.Year / 100));
+ IoWrite8 (RTC_ADDRESS_REGISTER, (UINT8) (RTC_ADDRESS_CENTURY | (UINT8) (IoRead8 (PCAT_RTC_ADDRESS_REGISTER) & 0x80)));
+ IoWrite8 (RTC_DATA_REGISTER, Century);
+ }
+ }
}
-
- return;
+ return;
}
diff --git a/Vlv2TbltDevicePkg/PlatformPei/Platform.c b/Vlv2TbltDevicePkg/PlatformPei/Platform.c
index 493c09679a..dcfb7f6251 100644
--- a/Vlv2TbltDevicePkg/PlatformPei/Platform.c
+++ b/Vlv2TbltDevicePkg/PlatformPei/Platform.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2004 - 2016, 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 that accompanies this distribution.
@@ -30,6 +30,7 @@ Module Name:
#include <Guid/Vlv2Variable.h>
#include <Ppi/fTPMPolicy.h>
#include <Library/PchPlatformLib.h>
+#include <Library/PcdLib.h>
//
// Start::Alpine Valley platform
@@ -475,6 +476,10 @@ RtcPowerFailureHandler (
//
if (DataUint16 & B_PCH_PMC_GEN_PMCON_RTC_PWR_STS) {
//
+ // Rtc Power failure occurs, save RtcPowerFailure Flag.
+ //
+ PcdSetBool(PcdRtcPowerFailure, TRUE);
+ //
// Set to invalid date in order to reset the time to
// BIOS build time later in the boot (SBRUN.c file).
//
diff --git a/Vlv2TbltDevicePkg/PlatformPei/PlatformPei.inf b/Vlv2TbltDevicePkg/PlatformPei/PlatformPei.inf
index 9b95a9b63a..97c8dfbef7 100644
--- a/Vlv2TbltDevicePkg/PlatformPei/PlatformPei.inf
+++ b/Vlv2TbltDevicePkg/PlatformPei/PlatformPei.inf
@@ -1,6 +1,6 @@
#
#
-# Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved
+# Copyright (c) 1999 - 2016, 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 that accompanies this distribution.
@@ -88,6 +88,7 @@
BaseCryptLib
PciLib
PchPlatformLib
+ PcdLib
[Ppis]
gEfiPeiStallPpiGuid
@@ -133,6 +134,7 @@
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
gPlatformModuleTokenSpaceGuid.PcdFlashAreaBaseAddress
gPlatformModuleTokenSpaceGuid.PcdFlashAreaSize
+ gPlatformModuleTokenSpaceGuid.PcdRtcPowerFailure
[Depex]
TRUE
diff --git a/Vlv2TbltDevicePkg/PlatformPkg.dec b/Vlv2TbltDevicePkg/PlatformPkg.dec
index ea84a93b1f..015a630533 100644
--- a/Vlv2TbltDevicePkg/PlatformPkg.dec
+++ b/Vlv2TbltDevicePkg/PlatformPkg.dec
@@ -66,6 +66,7 @@
gOsSelectionVariableGuid = { 0x86843f56, 0x675d, 0x40a5, { 0x95, 0x30, 0xbc, 0x85, 0x83, 0x72, 0xf1, 0x03 } }
gFMPSampleUpdateImageInfoGuid = { 0xb9847c4e, 0xf5b6, 0x42dc, { 0xb6, 0xf4, 0xed, 0x44, 0x7, 0xb0, 0x67, 0x4c }}
gSystemFwClassGuid = { 0x819b858e, 0xc52c, 0x402f, { 0x80, 0xe1, 0x5b, 0x31, 0x1b, 0x6c, 0x19, 0x59 } }
+ gSystemRtcTimeVariableGuid = { 0x64c9937c, 0x2c8f, 0x4bd7, { 0xbf, 0x25, 0x83, 0x22, 0x34, 0xa2, 0xaf, 0xa1 } }
[Protocols]
gEfiActiveBiosProtocolGuid = { 0xebbe2d1b, 0x1647, 0x4bda, { 0xab, 0x9a, 0x78, 0x63, 0xe3, 0x96, 0xd4, 0x1a } }
@@ -183,6 +184,7 @@
gPlatformModuleTokenSpaceGuid.PcdEnableWatchdogSwSmiInputValue|0|UINT8|0x80000003
## Indicates platform to sync ESRT repository from FMP instances
gPlatformModuleTokenSpaceGuid.PcdEsrtSyncFmp|TRUE|BOOLEAN|0x80000004
+ gPlatformModuleTokenSpaceGuid.PcdRtcPowerFailure|FALSE|BOOLEAN|0x80000005
#
#device firmware update support
diff --git a/Vlv2TbltDevicePkg/PlatformPkg.fdf b/Vlv2TbltDevicePkg/PlatformPkg.fdf
index 143164a0d6..907f88a96d 100644
--- a/Vlv2TbltDevicePkg/PlatformPkg.fdf
+++ b/Vlv2TbltDevicePkg/PlatformPkg.fdf
@@ -342,6 +342,7 @@ INF RuleOverride = BINARY $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET
INF MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf
INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
+INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
INF $(PLATFORM_PACKAGE)/PlatformPei/PlatformPei.inf
!if $(MINNOW2_FSP_BUILD) == FALSE
@@ -373,7 +374,6 @@ INF RuleOverride = BINARY $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET
INF RuleOverride = BINARY $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/MemoryInit.inf
!endif
-INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
[FV.FVMAIN]
BlockSize = $(FLASH_BLOCK_SIZE)
@@ -525,6 +525,7 @@ INF $(PLATFORM_PACKAGE)/PlatformSmm/PlatformSmm.inf
INF $(PLATFORM_PACKAGE)/PlatformInfoDxe/PlatformInfoDxe.inf
INF $(PLATFORM_PACKAGE)/PlatformCpuInfoDxe/PlatformCpuInfoDxe.inf
INF $(PLATFORM_PACKAGE)/PlatformDxe/PlatformDxe.inf
+INF $(PLATFORM_PACKAGE)/PlatformRtcRuntimeDxe/PlatformRtcRuntimeDxe.inf
INF $(PLATFORM_PACKAGE)/PciPlatform/PciPlatform.inf
INF $(PLATFORM_PACKAGE)/SaveMemoryConfig/SaveMemoryConfig.inf
INF RuleOverride = BINARY $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/$(DXE_ARCHITECTURE)/PlatformCpuPolicy.inf
diff --git a/Vlv2TbltDevicePkg/PlatformPkgGcc.fdf b/Vlv2TbltDevicePkg/PlatformPkgGcc.fdf
index 166d8beaed..935d1b40a8 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGcc.fdf
+++ b/Vlv2TbltDevicePkg/PlatformPkgGcc.fdf
@@ -299,6 +299,7 @@ INF RuleOverride = BINARY $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET
INF MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf
INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
+INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
INF $(PLATFORM_PACKAGE)/PlatformPei/PlatformPei.inf
!if $(MINNOW2_FSP_BUILD) == FALSE
@@ -326,7 +327,6 @@ INF RuleOverride = BINARY $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET
INF RuleOverride = BINARY $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/MemoryInit.inf
!endif
-INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
[FV.FVMAIN]
BlockSize = $(FLASH_BLOCK_SIZE)
@@ -478,6 +478,7 @@ INF $(PLATFORM_PACKAGE)/PlatformSmm/PlatformSmm.inf
INF $(PLATFORM_PACKAGE)/PlatformInfoDxe/PlatformInfoDxe.inf
INF $(PLATFORM_PACKAGE)/PlatformCpuInfoDxe/PlatformCpuInfoDxe.inf
INF $(PLATFORM_PACKAGE)/PlatformDxe/PlatformDxe.inf
+INF $(PLATFORM_PACKAGE)/PlatformRtcRuntimeDxe/PlatformRtcRuntimeDxe.inf
INF $(PLATFORM_PACKAGE)/PciPlatform/PciPlatform.inf
INF $(PLATFORM_PACKAGE)/SaveMemoryConfig/SaveMemoryConfig.inf
INF RuleOverride = BINARY $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/$(DXE_ARCHITECTURE)/PlatformCpuPolicy.inf
diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index bee20a8f57..8c45cb860c 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -878,6 +878,8 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdSystemRebootAfterCapsuleProcessFlag|0x0001
gEfiSecurityPkgTokenSpaceGuid.PcdTpmScrtmPolicy|1
!endif
+ gPlatformModuleTokenSpaceGuid.PcdRtcPowerFailure|FALSE
+
[PcdsDynamicExDefault.common.DEFAULT]
gEfiVLVTokenSpaceGuid.PcdTCSmbaIoBaseAddress|0x1040
gEfiVLVTokenSpaceGuid.PcdEmmcManufacturerId|0
@@ -965,6 +967,8 @@ $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fTPMInitPeim.inf
<PcdsFixedAtBuild>
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2E
!endif
+ <LibraryClasses>
+ PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
}
!endif
@@ -1327,6 +1331,7 @@ $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fTPMInitPeim.inf
$(PLATFORM_PACKAGE)/PlatformInfoDxe/PlatformInfoDxe.inf
$(PLATFORM_PACKAGE)/PlatformCpuInfoDxe/PlatformCpuInfoDxe.inf
$(PLATFORM_PACKAGE)/PlatformDxe/PlatformDxe.inf
+ $(PLATFORM_PACKAGE)/PlatformRtcRuntimeDxe/PlatformRtcRuntimeDxe.inf
$(PLATFORM_PACKAGE)/PciPlatform/PciPlatform.inf
$(PLATFORM_PACKAGE)/SaveMemoryConfig/SaveMemoryConfig.inf
diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index 70ff2e0654..433ea7f7cc 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -887,6 +887,8 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdSystemRebootAfterCapsuleProcessFlag|0x0001
gEfiSecurityPkgTokenSpaceGuid.PcdTpmScrtmPolicy|1
!endif
+ gPlatformModuleTokenSpaceGuid.PcdRtcPowerFailure|FALSE
+
[PcdsDynamicExDefault.common.DEFAULT]
gEfiVLVTokenSpaceGuid.PcdTCSmbaIoBaseAddress|0x1040
gEfiVLVTokenSpaceGuid.PcdEmmcManufacturerId|0
@@ -969,6 +971,8 @@ $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fTPMInitPeim.inf
<PcdsFixedAtBuild>
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2E
!endif
+ <LibraryClasses>
+ PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
}
!endif
@@ -1337,6 +1341,7 @@ $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fTPMInitPeim.inf
$(PLATFORM_PACKAGE)/PlatformInfoDxe/PlatformInfoDxe.inf
$(PLATFORM_PACKAGE)/PlatformCpuInfoDxe/PlatformCpuInfoDxe.inf
$(PLATFORM_PACKAGE)/PlatformDxe/PlatformDxe.inf
+ $(PLATFORM_PACKAGE)/PlatformRtcRuntimeDxe/PlatformRtcRuntimeDxe.inf
$(PLATFORM_PACKAGE)/PciPlatform/PciPlatform.inf
$(PLATFORM_PACKAGE)/SaveMemoryConfig/SaveMemoryConfig.inf
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index a0312081e8..1b6f31dddf 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -887,6 +887,8 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdSystemRebootAfterCapsuleProcessFlag|0x0001
gEfiSecurityPkgTokenSpaceGuid.PcdTpmScrtmPolicy|1
!endif
+ gPlatformModuleTokenSpaceGuid.PcdRtcPowerFailure|FALSE
+
[PcdsDynamicExDefault.common.DEFAULT]
gEfiVLVTokenSpaceGuid.PcdTCSmbaIoBaseAddress|0x1040
gEfiVLVTokenSpaceGuid.PcdEmmcManufacturerId|0
@@ -969,6 +971,8 @@ $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fTPMInitPeim.inf
<PcdsFixedAtBuild>
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2E
!endif
+ <LibraryClasses>
+ PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
}
!endif
@@ -1338,6 +1342,8 @@ $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fTPMInitPeim.inf
$(PLATFORM_PACKAGE)/PlatformInfoDxe/PlatformInfoDxe.inf
$(PLATFORM_PACKAGE)/PlatformCpuInfoDxe/PlatformCpuInfoDxe.inf
$(PLATFORM_PACKAGE)/PlatformDxe/PlatformDxe.inf
+ $(PLATFORM_PACKAGE)/PlatformRtcRuntimeDxe/PlatformRtcRuntimeDxe.inf
+
$(PLATFORM_PACKAGE)/PciPlatform/PciPlatform.inf
$(PLATFORM_PACKAGE)/SaveMemoryConfig/SaveMemoryConfig.inf
diff --git a/Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatformRtc.c b/Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatformRtc.c
new file mode 100644
index 0000000000..f38c4db2f6
--- /dev/null
+++ b/Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatformRtc.c
@@ -0,0 +1,137 @@
+/** @file
+ Platform Real Time Clock Set Time driver.
+
+ Copyright (c) 2016, 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
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "PlatformRtc.h"
+
+EFI_SET_TIME mOriginalSetTime;
+
+
+/**
+ Save RTC Time to UEFI variable, and Sets the current local time and date information.
+
+ @param Time A pointer to the current time.
+
+ @retval EFI_SUCCESS The operation completed successfully.
+
+**/
+EFI_STATUS
+PlatformRtcSetTime (
+ IN EFI_TIME *Time
+ )
+{
+ EFI_STATUS Status;
+ EFI_TIME RtcTime;
+ EFI_TIME RtcTime2;
+ UINTN DataSize;
+
+ if (Time == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ RtcTime = *Time;
+ //
+ // Save user setting time to variable.
+ //
+ if (RtcTime.Year != PcdGet16 (PcdMinimalValidYear)) {
+ DataSize = sizeof (EFI_TIME);
+ Status = gRT->GetVariable(
+ L"SystemRtcTime",
+ &gSystemRtcTimeVariableGuid,
+ NULL,
+ &DataSize,
+ &RtcTime2
+ );
+ if (EFI_ERROR(Status)) {
+ Status = EfiSetVariable (
+ SYSTEM_TIME_NAME,
+ &gSystemRtcTimeVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ sizeof (RtcTime),
+ &RtcTime
+ );
+ ASSERT(Status == EFI_SUCCESS);
+ } else {
+ if (~(((RtcTime.Year == RtcTime2.Year) && (RtcTime.Month == RtcTime2.Month) && (RtcTime.Day == RtcTime2.Day)) &&
+ ((RtcTime.Hour == RtcTime2.Hour) && (RtcTime.Minute == RtcTime2.Minute) && (RtcTime.Second == RtcTime2.Second)))) {
+ //
+ // If the time to be set is the same as the saved RTC time, we do not need save the RTC time again.
+ //
+ Status = EfiSetVariable (
+ SYSTEM_TIME_NAME,
+ &gSystemRtcTimeVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ sizeof (RtcTime),
+ &RtcTime
+ );
+ ASSERT(Status == EFI_SUCCESS);
+ }
+ }
+ }
+
+ return mOriginalSetTime(Time);
+}
+
+VOID
+EFIAPI
+PlatformRtcSetTimeVirtualAddressChangeEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ gRT->ConvertPointer (0, (VOID **) &mOriginalSetTime);
+}
+
+/**
+ The User Entry Point for Platform RTC module.
+
+ This is the entry point for Platform RTC module. It installs the UEFI runtime service
+ including Platform SetTime().
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The entry point is executed successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+InitializePlatformRtc (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_EVENT Event;
+
+ //
+ // Make sure we can handle virtual address changes.
+ //
+ Event = NULL;
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_NOTIFY,
+ PlatformRtcSetTimeVirtualAddressChangeEvent,
+ NULL,
+ &gEfiEventVirtualAddressChangeGuid,
+ &Event
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ mOriginalSetTime = gRT->SetTime;
+
+ gRT->SetTime = PlatformRtcSetTime;
+
+ return EFI_SUCCESS;
+}
+
diff --git a/Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatformRtc.h b/Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatformRtc.h
new file mode 100644
index 0000000000..b065c7a0de
--- /dev/null
+++ b/Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatformRtc.h
@@ -0,0 +1,33 @@
+/** @file
+ Header file for Platform Real Time Clock driver.
+
+ Copyright (c) 2016, 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
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+
+#ifndef _PLATFORM_RTC_H_
+#define _PLATFORM_RTC_H_
+
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/PcdLib.h>
+#include <Library/ReportStatusCodeLib.h>
+
+#define SYSTEM_TIME_NAME L"SystemRtcTime"
+
+#endif
diff --git a/Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatformRtc.uni b/Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatformRtc.uni
new file mode 100644
index 0000000000..935ab55fbb
--- /dev/null
+++ b/Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatformRtc.uni
Binary files differ
diff --git a/Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatformRtcRuntimeDxe.inf b/Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatformRtcRuntimeDxe.inf
new file mode 100644
index 0000000000..301ad534c2
--- /dev/null
+++ b/Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatformRtcRuntimeDxe.inf
@@ -0,0 +1,60 @@
+## @file
+# Platform RTC SetTime driver.
+#
+# This driver provides Platform SetTime services to Runtime Service Table.
+#
+# Copyright (c) 2016, 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
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PlatformRtc
+ MODULE_UNI_FILE = PlatformRtc.uni
+ FILE_GUID = 3C060B94-7E09-4c42-8DF4-7B0037FE8D33
+ MODULE_TYPE = DXE_RUNTIME_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = InitializePlatformRtc
+
+
+[Sources]
+ PlatformRtc.c
+ PlatformRtc.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ PcAtChipsetPkg/PcAtChipsetPkg.dec
+ Vlv2TbltDevicePkg/PlatformPkg.dec
+
+[LibraryClasses]
+ UefiRuntimeServicesTableLib
+ UefiRuntimeLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+ TimerLib
+ UefiLib
+ DebugLib
+ BaseLib
+ PcdLib
+ ReportStatusCodeLib
+
+[Guids]
+ gSystemRtcTimeVariableGuid
+
+[Protocols]
+
+[Depex]
+ gEfiRealTimeClockArchProtocolGuid
+
+[Pcd]
+ gPcAtChipsetPkgTokenSpaceGuid.PcdMinimalValidYear ## CONSUMES
+
+[UserExtensions.TianoCore."ExtraFiles"]
+ PlatformRtcExtra.uni
diff --git a/Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatfromRtcExtra.uni b/Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatfromRtcExtra.uni
new file mode 100644
index 0000000000..cc7e6d6660
--- /dev/null
+++ b/Vlv2TbltDevicePkg/PlatformRtcRuntimeDxe/PlatfromRtcExtra.uni
Binary files differ