From nobody Fri Apr 26 20:26:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56083+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56083+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1584933647; cv=none; d=zohomail.com; s=zohoarc; b=SNbx2fHuqPoYSx9GhfLVHIOV/4rnwK7KeEX8b0nTgCjjfBevkcXllLaYMXHDh5EUlcPiUOKAA2+vOiKBHeG2xPpJ1mTjtgrhDNxpj5GVA1aUKEkM8kMMJwweuW5RNm7xG0DpFE0x8inUunifMq5izgMo6bdgtGbfE0Y1cDVgOEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584933647; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=0kN1Ya3t6rUa9y99Ak+rAR+G4OVIk8DxzGbEEmGSnnM=; b=BijXtlwTeccpLfFE91IUe/MfY9SyfANJYHCpmCvT7OvaM9rYk9g6Sv8C9tBzEnamFdXqd8POxxCgA/qqoCCVDp+ZUGc/fWt5u8VFZlGfo1TPmRyw82rMRgQkCjh4RI4vWkzgxU9NjOgdHix+3cjSCOrLiXkw46bsNoqHGBFbhbk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56083+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 158493364743043.50955335810181; Sun, 22 Mar 2020 20:20:47 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id y0lbYY1788612xWuzh0V5TCH; Sun, 22 Mar 2020 20:20:47 -0700 X-Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by mx.groups.io with SMTP id smtpd.web10.5368.1584675752951389451 for ; Thu, 19 Mar 2020 20:42:33 -0700 X-Received: by mail-pl1-f194.google.com with SMTP id g6so1949579plt.2 for ; Thu, 19 Mar 2020 20:42:32 -0700 (PDT) X-Gm-Message-State: 47BChI1fAr5fvVnGqRMTB7Lbx1787277AA= X-Google-Smtp-Source: ADFU+vvaPHlrTQv+AXfl6MZa+OmJBvpGxmSBHCobxVLSgGa6Io+Yth2InFkYo88X0zXeZF/BMOhEKg== X-Received: by 2002:a17:90b:288:: with SMTP id az8mr7003791pjb.25.1584675752118; Thu, 19 Mar 2020 20:42:32 -0700 (PDT) X-Received: from kyaux-MOBL1.amr.corp.intel.com ([192.55.54.42]) by smtp.gmail.com with ESMTPSA id md20sm3064262pjb.15.2020.03.19.20.42.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Mar 2020 20:42:31 -0700 (PDT) From: Yau X-Google-Original-From: Yau To: devel@edk2.groups.io Cc: Yau Subject: [edk2-devel] [PATCH] PcAtChipsetPkg: Wrong System YEAR displayed in SETUP Date: Thu, 19 Mar 2020 23:42:26 -0400 Message-Id: <50102ef8b38c0e5287ab4d1cb8fc636213f67299.1584672719.git.kaix.yau@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kaiyau@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1584933647; bh=9fIuvLrVqJ1RDV9+F8Rs1d3O+kcgmdr3nmUQ7Pu3FNI=; h=Cc:Date:From:Reply-To:Subject:To; b=agffnRJVSH6NKX5C/wS5H/PifEopE2CxrcfhzejRQ1XO1jCSQhU7OZnRiFDVYwn1QOc uJUfqqLWQNhN/HA1VdiimLnbqO9lpwdJ0oVLzjFyELCjItV1gMbGLGv1Zs7fYXlzf2oqU KrL0U5y8R0I8eNpxMJXc6F/7r2cyJuuT/64= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Function ConvertRtcTimeToEfiTime() will reset to Century 19XX when the year= is set larger than the value of PcdMaximalValidYear outside SETUP. Signed-off-by: Yau --- PcAtChipsetPkg/PcAtChipsetPkg.dec | 7 +++--- .../PcatRealTimeClockRuntimeDxe/PcRtc.c | 25 +++++++++++-------- .../PcatRealTimeClockRuntimeDxe/PcRtc.h | 17 +++++++------ 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dec b/PcAtChipsetPkg/PcAtChipset= Pkg.dec index 88de5cceea..660cb5d52e 100644 --- a/PcAtChipsetPkg/PcAtChipsetPkg.dec +++ b/PcAtChipsetPkg/PcAtChipsetPkg.dec @@ -4,7 +4,7 @@ # This package is designed to public interfaces and implementation which f= ollows # PcAt defacto standard. # -# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
# Copyright (c) 2017, AMD Inc. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -61,12 +61,13 @@ =20 ## This PCD specifies the minimal valid year in RTC. # @Prompt Minimal valid year in RTC. - gPcAtChipsetPkgTokenSpaceGuid.PcdMinimalValidYear|1998|UINT16|0x0000000D + # @Expression 0x80000001 | gPcAtChipsetPkgTokenSpaceGuid.PcdMinimalValid= Year >=3D 2000 + gPcAtChipsetPkgTokenSpaceGuid.PcdMinimalValidYear|2000|UINT16|0x0000000D =20 ## This PCD specifies the maximal valid year in RTC. # @Prompt Maximal valid year in RTC. # @Expression 0x80000001 | gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValid= Year < gPcAtChipsetPkgTokenSpaceGuid.PcdMinimalValidYear + 100 - gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear|2097|UINT16|0x0000000E + gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear|2099|UINT16|0x0000000E =20 [PcdsFixedAtBuild, PcdsPatchableInModule] ## Defines the ACPI register set base address. diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChips= etPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c index 52af179417..38a3521dfc 100644 --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c @@ -1,7 +1,7 @@ /** @file RTC Architectural Protocol GUID as defined in DxeCis 0.96. =20 -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -441,8 +441,8 @@ PcRtcGetTime ( **/ EFI_STATUS PcRtcSetTime ( - IN EFI_TIME *Time, - IN PC_RTC_MODULE_GLOBALS *Global + IN EFI_TIME *Time, + IN OUT PC_RTC_MODULE_GLOBALS *Global ) { EFI_STATUS Status; @@ -525,6 +525,8 @@ PcRtcSetTime ( // if (Global->CenturyRtcAddress !=3D 0) { RtcWrite (Global->CenturyRtcAddress, DecimalToBcd8 ((UINT8) (RtcTime.Y= ear / 100))); + } else { + DEBUG ((EFI_D_INFO, "PcRtc: Century RTC Address is not found\n")); } =20 ConvertEfiTimeToRtcTime (&RtcTime, RegisterB); @@ -868,6 +870,9 @@ ConvertRtcTimeToEfiTime ( { BOOLEAN IsPM; UINT8 Century; + UINT8 CenturyRtcAddress; + + CenturyRtcAddress =3D GetCenturyRtcAddress (); =20 if ((Time->Hour & 0x80) !=3D 0) { IsPM =3D TRUE; @@ -891,14 +896,12 @@ ConvertRtcTimeToEfiTime ( return EFI_INVALID_PARAMETER; } =20 - // - // For minimal/maximum year range [1970, 2069], - // Century is 19 if RTC year >=3D 70, - // Century is 20 otherwise. - // - Century =3D (UINT8) (PcdGet16 (PcdMinimalValidYear) / 100); - if (Time->Year < PcdGet16 (PcdMinimalValidYear) % 100) { - Century++; + if (CenturyRtcAddress !=3D 0) { + Century =3D CheckAndConvertBcd8ToDecimal8 ((UINT8) (RtcRead (CenturyRt= cAddress))); + } else if ((PcdGet16 (PcdMinimalValidYear) / 100) =3D=3D (PcdGet16 (PcdM= aximalValidYear) / 100)) { + Century =3D (UINT8)(PcdGet16 (PcdMinimalValidYear) / 100); + } else { + Century =3D RTC_INIT_CENTURY; } Time->Year =3D (UINT16) (Century * 100 + Time->Year); =20 diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h b/PcAtChips= etPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h index 47293ce44c..94926fe73e 100644 --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h @@ -1,7 +1,7 @@ /** @file Header file for real time clock driver. =20 -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -62,11 +62,12 @@ extern PC_RTC_MODULE_GLOBALS mModuleGlobal; // Date and time initial values. // They are used if the RTC values are invalid during driver initialization // -#define RTC_INIT_SECOND 0 -#define RTC_INIT_MINUTE 0 -#define RTC_INIT_HOUR 0 -#define RTC_INIT_DAY 1 -#define RTC_INIT_MONTH 1 +#define RTC_INIT_SECOND 0 +#define RTC_INIT_MINUTE 0 +#define RTC_INIT_HOUR 0 +#define RTC_INIT_DAY 1 +#define RTC_INIT_MONTH 1 +#define RTC_INIT_CENTURY 20 =20 #pragma pack(1) // @@ -160,8 +161,8 @@ PcRtcInit ( **/ EFI_STATUS PcRtcSetTime ( - IN EFI_TIME *Time, - IN PC_RTC_MODULE_GLOBALS *Global + IN EFI_TIME *Time, + IN OUT PC_RTC_MODULE_GLOBALS *Global ); =20 /** --=20 2.17.1.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56083): https://edk2.groups.io/g/devel/message/56083 Mute This Topic: https://groups.io/mt/72484290/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-