From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web10.20119.1684756834875252865 for ; Mon, 22 May 2023 05:00:36 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=O+MZdZrY; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: gua.guo@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684756836; x=1716292836; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RFPtL2s3ImrnlxuhNzIru5ewzOMfGbUGp9bVONUQMfw=; b=O+MZdZrYD5R0WvcV9pEgG2dl/XWfrokeggzzJq6fMHQT7RCv3eLAG23t sWDHOBtLuBHsQFPfwDbZrKwsYpbxkyEqeAjw8E93cgAqCv4PX48Z8rsPP HfFDiovnM24EO1FXtR9/7Su7NU8eciah/7Z9Q8XtK3h8Pd77AkqnifbzS MWp2U+15pFKo4KD58MeCVlI0/hjFIM7LzMDuZ9u2mwWrSJ2YINsXDwgXH 26AikQdEset+lXbqcSgBKgqCmhJEIBjaxn1JUT4dRrSzqVzawxbsZL91C /sixSVCSByQuK75Wl6WLRuNvpPh1PzmPk2vIU//X5Iscddsi1zwnyrJKl w==; X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="350409403" X-IronPort-AV: E=Sophos;i="6.00,184,1681196400"; d="scan'208";a="350409403" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2023 05:00:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="773333073" X-IronPort-AV: E=Sophos;i="6.00,184,1681196400"; d="scan'208";a="773333073" Received: from gguo-desk.gar.corp.intel.com ([10.5.215.23]) by fmsmga004.fm.intel.com with ESMTP; 22 May 2023 05:00:34 -0700 From: "Guo, Gua" To: devel@edk2.groups.io Cc: gua.guo@intel.com, Ray Ni , Michael D Kinney Subject: [PATCH v2 1/1] PcAtChipsetPkg: RTC Runtime unable to get correct IO port by PCD Date: Mon, 22 May 2023 20:00:29 +0800 Message-Id: <20230522120029.473-2-gua.guo@intel.com> X-Mailer: git-send-email 2.39.2.windows.1 In-Reply-To: <20230522120029.473-1-gua.guo@intel.com> References: <20230522120029.473-1-gua.guo@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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..795ec950a8 100644 --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c @@ -11,9 +11,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =0D #include "PcRtc.h"=0D =0D -extern UINTN mRtcIndexRegister;=0D -extern UINTN mRtcTargetRegister;=0D -=0D +extern UINTN mRtcIndexRegister;=0D +extern UINTN mRtcTargetRegister;=0D +extern UINTN mRtcIndexRegisterIo;=0D +extern UINTN mRtcTargetRegisterIo;=0D +extern UINT16 mRtcDefaultYear;=0D +extern UINT16 mMinimalValidYear;=0D +extern UINT16 mMaximalValidYear;=0D //=0D // Days of month.=0D //=0D @@ -72,10 +76,10 @@ IoRtcRead ( )=0D {=0D IoWrite8 (=0D - PcdGet8 (PcdRtcIndexRegister),=0D - (UINT8)(Address | (UINT8)(IoRead8 (PcdGet8 (PcdRtcIndexRegister)) & 0x= 80))=0D + mRtcIndexRegisterIo,=0D + (UINT8)(Address | (UINT8)(IoRead8 (mRtcIndexRegisterIo) & 0x80))=0D );=0D - return IoRead8 (PcdGet8 (PcdRtcTargetRegister));=0D + return IoRead8 (mRtcTargetRegisterIo);=0D }=0D =0D /**=0D @@ -94,10 +98,10 @@ IoRtcWrite ( )=0D {=0D IoWrite8 (=0D - PcdGet8 (PcdRtcIndexRegister),=0D - (UINT8)(Address | (UINT8)(IoRead8 (PcdGet8 (PcdRtcIndexRegister)) & 0x= 80))=0D + mRtcIndexRegisterIo,=0D + (UINT8)(Address | (UINT8)(IoRead8 (mRtcIndexRegisterIo) & 0x80))=0D );=0D - IoWrite8 (PcdGet8 (PcdRtcTargetRegister), Data);=0D + IoWrite8 (mRtcTargetRegisterIo, Data);=0D }=0D =0D /**=0D @@ -317,8 +321,8 @@ PcRtcInit ( Time.Hour =3D RTC_INIT_HOUR;=0D Time.Day =3D RTC_INIT_DAY;=0D Time.Month =3D RTC_INIT_MONTH;=0D - Time.Year =3D MAX (PcdGet16 (PcdRtcDefaultYear), PcdGet16 (PcdMi= nimalValidYear));=0D - Time.Year =3D MIN (Time.Year, PcdGet16 (PcdMaximalValidYear));=0D + Time.Year =3D MAX (mRtcDefaultYear, mMinimalValidYear);=0D + Time.Year =3D MIN (Time.Year, mMaximalValidYear);=0D Time.Nanosecond =3D 0;=0D Time.TimeZone =3D EFI_UNSPECIFIED_TIMEZONE;=0D Time.Daylight =3D 0;=0D @@ -358,8 +362,8 @@ PcRtcInit ( Time.Hour =3D RTC_INIT_HOUR;=0D Time.Day =3D RTC_INIT_DAY;=0D Time.Month =3D RTC_INIT_MONTH;=0D - Time.Year =3D MAX (PcdGet16 (PcdRtcDefaultYear), PcdGet16 (PcdMini= malValidYear));=0D - Time.Year =3D MIN (Time.Year, PcdGet16 (PcdMaximalValidYear));=0D + Time.Year =3D MAX (mRtcDefaultYear, mMinimalValidYear);=0D + Time.Year =3D MIN (Time.Year, mMaximalValidYear);=0D Time.Nanosecond =3D 0;=0D Time.TimeZone =3D Global->SavedTimeZone;=0D Time.Daylight =3D Global->Daylight;=0D @@ -1031,8 +1035,8 @@ ConvertRtcTimeToEfiTime ( // Century is 19 if RTC year >=3D 70,=0D // Century is 20 otherwise.=0D //=0D - Century =3D (UINT8)(PcdGet16 (PcdMinimalValidYear) / 100);=0D - if (Time->Year < PcdGet16 (PcdMinimalValidYear) % 100) {=0D + Century =3D (UINT8)(mMinimalValidYear / 100);=0D + if (Time->Year < mMinimalValidYear % 100) {=0D Century++;=0D }=0D =0D @@ -1114,8 +1118,8 @@ RtcTimeFieldsValid ( IN EFI_TIME *Time=0D )=0D {=0D - if ((Time->Year < PcdGet16 (PcdMinimalValidYear)) ||=0D - (Time->Year > PcdGet16 (PcdMaximalValidYear)) ||=0D + if ((Time->Year < mMinimalValidYear) ||=0D + (Time->Year > mMaximalValidYear) ||=0D (Time->Month < 1) ||=0D (Time->Month > 12) ||=0D (!DayValid (Time)) ||=0D diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c b/PcAt= ChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c index e6e9458d75..ba7e85cdfb 100644 --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c @@ -16,8 +16,13 @@ EFI_HANDLE mHandle =3D NULL; =0D STATIC EFI_EVENT mVirtualAddrChangeEvent;=0D =0D -UINTN mRtcIndexRegister;=0D -UINTN mRtcTargetRegister;=0D +UINTN mRtcIndexRegister;=0D +UINTN mRtcTargetRegister;=0D +UINTN mRtcIndexRegisterIo;=0D +UINTN mRtcTargetRegisterIo;=0D +UINT16 mRtcDefaultYear;=0D +UINT16 mMinimalValidYear;=0D +UINT16 mMaximalValidYear;=0D =0D /**=0D Returns the current time and date information, and the time-keeping capa= bilities=0D @@ -164,8 +169,15 @@ InitializePcRtc ( if (FeaturePcdGet (PcdRtcUseMmio)) {=0D mRtcIndexRegister =3D (UINTN)PcdGet64 (PcdRtcIndexRegister64);=0D mRtcTargetRegister =3D (UINTN)PcdGet64 (PcdRtcTargetRegister64);=0D + } else {=0D + mRtcIndexRegisterIo =3D (UINTN)PcdGet8 (PcdRtcIndexRegister);=0D + mRtcTargetRegisterIo =3D (UINTN)PcdGet8 (PcdRtcTargetRegister);=0D }=0D =0D + mRtcDefaultYear =3D PcdGet16 (PcdRtcDefaultYear);=0D + mMinimalValidYear =3D PcdGet16 (PcdMinimalValidYear);=0D + mMaximalValidYear =3D PcdGet16 (PcdMaximalValidYear);=0D +=0D Status =3D PcRtcInit (&mModuleGlobal);=0D ASSERT_EFI_ERROR (Status);=0D =0D --=20 2.39.2.windows.1