From nobody Wed Oct 30 19:55:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+105217+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+105217+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1684917403; cv=none; d=zohomail.com; s=zohoarc; b=nfAX0TATmO4zlrG23Cz9DgU/9iEk0JoGbDgdCQHBUw5W/0M9lGbkwhTsjKvy/MV7aeeT7w20p6B700pnoFlr+p3SKKojeksYmDzHx946GHZK2+3J7OpUPBTKnyg1zlOXtCMwyZ4fhokLJQxRqDALPBfdcjzEALHc0ptc/LQMhdw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684917403; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ECOiT2ncCNv8xtpbLgiduD0Y7DRHo26H03LeXHwjUME=; b=Rr8DQgmIaDEhbNPRd1jdncpkZOrVqvi1vWZimIme1hTu1d/1+8E6aIoPIXATcdzFbT7Ue6ynENVMFBabUB5aMFRknqm31/MLOND7Lui/OOh/61o6jRBvCoTwu+8dadix7RMWqsl+9NkwE1kFM0Akgh3r8GErh94FeNAT4zAANc8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+105217+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1684917403377240.21943174750356; Wed, 24 May 2023 01:36:43 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id sSR4YY1788612xC4PWotRUAD; Wed, 24 May 2023 01:36:43 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.4245.1684917401785896357 for ; Wed, 24 May 2023 01:36:42 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="355856921" X-IronPort-AV: E=Sophos;i="6.00,188,1681196400"; d="scan'208";a="355856921" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 01:35:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="794097853" X-IronPort-AV: E=Sophos;i="6.00,188,1681196400"; d="scan'208";a="794097853" X-Received: from gguo-desk.gar.corp.intel.com ([10.5.215.23]) by FMSMGA003.fm.intel.com with ESMTP; 24 May 2023 01:35:24 -0700 From: "Guo, Gua" To: devel@edk2.groups.io Cc: gua.guo@intel.com, Ray Ni , Michael D Kinney Subject: [edk2-devel] [PATCH v3 1/1] PcAtChipsetPkg: RTC Runtime unable to get correct IO port by PCD Date: Wed, 24 May 2023 16:35:18 +0800 Message-Id: <20230524083518.1962-2-gua.guo@intel.com> In-Reply-To: <20230524083518.1962-1-gua.guo@intel.com> References: <20230524083518.1962-1-gua.guo@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,gua.guo@intel.com X-Gm-Message-State: AcuYwnpypbeU8zUf1fezVSd7x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1684917403; bh=EuVderAroFaMXQNEd2J1J0QMJ+nt6ZC25mgKgnUxY8A=; h=Cc:Date:From:Reply-To:Subject:To; b=iaPejFUKGpuT/L1tyd85Aa8Z6Vm4WXH3YcB1LbY/Uko80Tcw9Z9MewyDrZ+vdi4i8cI rvzSg49IVzrs326u7ypl+zsy7J185eS7oSMmMwwra6jF5oYaqKG3FrXl1LU1RJ48D0JLh 2282Mrlc3X/6SYsTqb3HEIQ58+EuNuUO7wM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1684917403928100002 Content-Type: text/plain; charset="utf-8" From: Gua Guo RTC runtime is unable to get dynamic PCD value after booting to OS using runtime services. Resolution: Cache the dynamic PCD value in RTC driver entry point Cc: Ray Ni Cc: Michael D Kinney Signed-off-by: Gua Guo --- .../PcatRealTimeClockRuntimeDxe/PcRtc.c | 38 ++++++++++--------- .../PcatRealTimeClockRuntimeDxe/PcRtcEntry.c | 16 +++++++- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChips= etPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c index d8b9fa8376..f8a1af85fc 100644 --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c @@ -11,9 +11,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #include "PcRtc.h" =20 -extern UINTN mRtcIndexRegister; -extern UINTN mRtcTargetRegister; - +extern UINTN mRtcIndexRegister; +extern UINTN mRtcTargetRegister; +extern UINT8 mRtcIndexRegisterIo; +extern UINT8 mRtcTargetRegisterIo; +extern UINT16 mRtcDefaultYear; +extern UINT16 mMinimalValidYear; +extern UINT16 mMaximalValidYear; // // Days of month. // @@ -72,10 +76,10 @@ IoRtcRead ( ) { IoWrite8 ( - PcdGet8 (PcdRtcIndexRegister), - (UINT8)(Address | (UINT8)(IoRead8 (PcdGet8 (PcdRtcIndexRegister)) & 0x= 80)) + mRtcIndexRegisterIo, + (UINT8)(Address | (UINT8)(IoRead8 (mRtcIndexRegisterIo) & 0x80)) ); - return IoRead8 (PcdGet8 (PcdRtcTargetRegister)); + return IoRead8 (mRtcTargetRegisterIo); } =20 /** @@ -94,10 +98,10 @@ IoRtcWrite ( ) { IoWrite8 ( - PcdGet8 (PcdRtcIndexRegister), - (UINT8)(Address | (UINT8)(IoRead8 (PcdGet8 (PcdRtcIndexRegister)) & 0x= 80)) + mRtcIndexRegisterIo, + (UINT8)(Address | (UINT8)(IoRead8 (mRtcIndexRegisterIo) & 0x80)) ); - IoWrite8 (PcdGet8 (PcdRtcTargetRegister), Data); + IoWrite8 (mRtcTargetRegisterIo, Data); } =20 /** @@ -317,8 +321,8 @@ PcRtcInit ( Time.Hour =3D RTC_INIT_HOUR; Time.Day =3D RTC_INIT_DAY; Time.Month =3D RTC_INIT_MONTH; - Time.Year =3D MAX (PcdGet16 (PcdRtcDefaultYear), PcdGet16 (PcdMi= nimalValidYear)); - Time.Year =3D MIN (Time.Year, PcdGet16 (PcdMaximalValidYear)); + Time.Year =3D MAX (mRtcDefaultYear, mMinimalValidYear); + Time.Year =3D MIN (Time.Year, mMaximalValidYear); Time.Nanosecond =3D 0; Time.TimeZone =3D EFI_UNSPECIFIED_TIMEZONE; Time.Daylight =3D 0; @@ -358,8 +362,8 @@ PcRtcInit ( Time.Hour =3D RTC_INIT_HOUR; Time.Day =3D RTC_INIT_DAY; Time.Month =3D RTC_INIT_MONTH; - Time.Year =3D MAX (PcdGet16 (PcdRtcDefaultYear), PcdGet16 (PcdMini= malValidYear)); - Time.Year =3D MIN (Time.Year, PcdGet16 (PcdMaximalValidYear)); + Time.Year =3D MAX (mRtcDefaultYear, mMinimalValidYear); + Time.Year =3D MIN (Time.Year, mMaximalValidYear); Time.Nanosecond =3D 0; Time.TimeZone =3D Global->SavedTimeZone; Time.Daylight =3D Global->Daylight; @@ -1031,8 +1035,8 @@ ConvertRtcTimeToEfiTime ( // 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 =3D (UINT8)(mMinimalValidYear / 100); + if (Time->Year < mMinimalValidYear % 100) { Century++; } =20 @@ -1114,8 +1118,8 @@ RtcTimeFieldsValid ( IN EFI_TIME *Time ) { - if ((Time->Year < PcdGet16 (PcdMinimalValidYear)) || - (Time->Year > PcdGet16 (PcdMaximalValidYear)) || + if ((Time->Year < mMinimalValidYear) || + (Time->Year > mMaximalValidYear) || (Time->Month < 1) || (Time->Month > 12) || (!DayValid (Time)) || diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c b/PcAt= ChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c index e6e9458d75..f8de12aef5 100644 --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c @@ -16,8 +16,13 @@ EFI_HANDLE mHandle =3D NULL; =20 STATIC EFI_EVENT mVirtualAddrChangeEvent; =20 -UINTN mRtcIndexRegister; -UINTN mRtcTargetRegister; +UINTN mRtcIndexRegister; +UINTN mRtcTargetRegister; +UINT8 mRtcIndexRegisterIo; +UINT8 mRtcTargetRegisterIo; +UINT16 mRtcDefaultYear; +UINT16 mMinimalValidYear; +UINT16 mMaximalValidYear; =20 /** Returns the current time and date information, and the time-keeping capa= bilities @@ -164,8 +169,15 @@ InitializePcRtc ( if (FeaturePcdGet (PcdRtcUseMmio)) { mRtcIndexRegister =3D (UINTN)PcdGet64 (PcdRtcIndexRegister64); mRtcTargetRegister =3D (UINTN)PcdGet64 (PcdRtcTargetRegister64); + } else { + mRtcIndexRegisterIo =3D (UINTN)PcdGet8 (PcdRtcIndexRegister); + mRtcTargetRegisterIo =3D (UINTN)PcdGet8 (PcdRtcTargetRegister); } =20 + mRtcDefaultYear =3D PcdGet16 (PcdRtcDefaultYear); + mMinimalValidYear =3D PcdGet16 (PcdMinimalValidYear); + mMaximalValidYear =3D PcdGet16 (PcdMaximalValidYear); + Status =3D PcRtcInit (&mModuleGlobal); ASSERT_EFI_ERROR (Status); =20 --=20 2.39.2.windows.1 -=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 (#105217): https://edk2.groups.io/g/devel/message/105217 Mute This Topic: https://groups.io/mt/99104597/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-