PcAtChipsetPkg/PcRtc: Fix a Y2K bug
The original driver cannot handle the case when system time runs from 1999/12/31 23:59:59 to 2000/1/1 0:0:0. A simple test to set system time to 1999/12/31 23:59:59 can expose this bug. The patch limits the driver to only support year in 100 range and decide the century value based on the supporting range: Century either equals to PcdMinimalYear / 100 or equals to PcdMinimalYear / 100 + 1. The patch passed the Y2K test. However with year range [1998, 2097], when system time is 2097/12/31 23:59:59, the next second system time will become 1998/1/1 0:0:0. I think it's a acceptable limitation. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17624 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
Header file for real time clock driver.
|
||||
|
||||
Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2006 - 2015, 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
|
||||
@@ -61,7 +61,6 @@ typedef struct {
|
||||
#define RTC_ADDRESS_REGISTER_B 11 // R/W
|
||||
#define RTC_ADDRESS_REGISTER_C 12 // RO
|
||||
#define RTC_ADDRESS_REGISTER_D 13 // RO
|
||||
#define RTC_ADDRESS_CENTURY 50 // R/W Range 19..20 Bit 8 is R/W
|
||||
//
|
||||
// Date and time initial values.
|
||||
// They are used if the RTC values are invalid during driver initialization
|
||||
@@ -71,7 +70,6 @@ typedef struct {
|
||||
#define RTC_INIT_HOUR 0
|
||||
#define RTC_INIT_DAY 1
|
||||
#define RTC_INIT_MONTH 1
|
||||
#define RTC_INIT_YEAR 2001
|
||||
|
||||
//
|
||||
// Register initial values
|
||||
@@ -287,14 +285,11 @@ RtcTimeFieldsValid (
|
||||
@param Time On input, the time data read from UEFI to convert
|
||||
On output, the time converted to RTC format
|
||||
@param RegisterB Value of Register B of RTC, indicating data mode
|
||||
@param Century It is set according to EFI_TIME Time.
|
||||
|
||||
**/
|
||||
VOID
|
||||
ConvertEfiTimeToRtcTime (
|
||||
IN OUT EFI_TIME *Time,
|
||||
IN RTC_REGISTER_B RegisterB,
|
||||
OUT UINT8 *Century
|
||||
IN RTC_REGISTER_B RegisterB
|
||||
);
|
||||
|
||||
|
||||
@@ -308,7 +303,6 @@ ConvertEfiTimeToRtcTime (
|
||||
|
||||
@param Time On input, the time data read from RTC to convert
|
||||
On output, the time converted to UEFI format
|
||||
@param Century Value of century read from RTC.
|
||||
@param RegisterB Value of Register B of RTC, indicating data mode
|
||||
and hour format.
|
||||
|
||||
@@ -319,7 +313,6 @@ ConvertEfiTimeToRtcTime (
|
||||
EFI_STATUS
|
||||
ConvertRtcTimeToEfiTime (
|
||||
IN OUT EFI_TIME *Time,
|
||||
IN UINT8 Century,
|
||||
IN RTC_REGISTER_B RegisterB
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user