From: "Guo, Gua" <gua.guo@intel.com>
To: devel@edk2.groups.io
Cc: gua.guo@intel.com, Ray Ni <ray.ni@intel.com>,
Michael D Kinney <michael.d.kinney@intel.com>
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 [thread overview]
Message-ID: <20230522120029.473-2-gua.guo@intel.com> (raw)
In-Reply-To: <20230522120029.473-1-gua.guo@intel.com>
From: Gua Guo <gua.guo@intel.com>
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 <ray.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
---
.../PcatRealTimeClockRuntimeDxe/PcRtc.c | 38 ++++++++++---------
.../PcatRealTimeClockRuntimeDxe/PcRtcEntry.c | 16 +++++++-
2 files changed, 35 insertions(+), 19 deletions(-)
diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChipsetPkg/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
#include "PcRtc.h"
-extern UINTN mRtcIndexRegister;
-extern UINTN mRtcTargetRegister;
-
+extern UINTN mRtcIndexRegister;
+extern UINTN mRtcTargetRegister;
+extern UINTN mRtcIndexRegisterIo;
+extern UINTN 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)) & 0x80))
+ mRtcIndexRegisterIo,
+ (UINT8)(Address | (UINT8)(IoRead8 (mRtcIndexRegisterIo) & 0x80))
);
- return IoRead8 (PcdGet8 (PcdRtcTargetRegister));
+ return IoRead8 (mRtcTargetRegisterIo);
}
/**
@@ -94,10 +98,10 @@ IoRtcWrite (
)
{
IoWrite8 (
- PcdGet8 (PcdRtcIndexRegister),
- (UINT8)(Address | (UINT8)(IoRead8 (PcdGet8 (PcdRtcIndexRegister)) & 0x80))
+ mRtcIndexRegisterIo,
+ (UINT8)(Address | (UINT8)(IoRead8 (mRtcIndexRegisterIo) & 0x80))
);
- IoWrite8 (PcdGet8 (PcdRtcTargetRegister), Data);
+ IoWrite8 (mRtcTargetRegisterIo, Data);
}
/**
@@ -317,8 +321,8 @@ PcRtcInit (
Time.Hour = RTC_INIT_HOUR;
Time.Day = RTC_INIT_DAY;
Time.Month = RTC_INIT_MONTH;
- Time.Year = MAX (PcdGet16 (PcdRtcDefaultYear), PcdGet16 (PcdMinimalValidYear));
- Time.Year = MIN (Time.Year, PcdGet16 (PcdMaximalValidYear));
+ Time.Year = MAX (mRtcDefaultYear, mMinimalValidYear);
+ Time.Year = MIN (Time.Year, mMaximalValidYear);
Time.Nanosecond = 0;
Time.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
Time.Daylight = 0;
@@ -358,8 +362,8 @@ PcRtcInit (
Time.Hour = RTC_INIT_HOUR;
Time.Day = RTC_INIT_DAY;
Time.Month = RTC_INIT_MONTH;
- Time.Year = MAX (PcdGet16 (PcdRtcDefaultYear), PcdGet16 (PcdMinimalValidYear));
- Time.Year = MIN (Time.Year, PcdGet16 (PcdMaximalValidYear));
+ Time.Year = MAX (mRtcDefaultYear, mMinimalValidYear);
+ Time.Year = MIN (Time.Year, mMaximalValidYear);
Time.Nanosecond = 0;
Time.TimeZone = Global->SavedTimeZone;
Time.Daylight = Global->Daylight;
@@ -1031,8 +1035,8 @@ ConvertRtcTimeToEfiTime (
// Century is 19 if RTC year >= 70,
// Century is 20 otherwise.
//
- Century = (UINT8)(PcdGet16 (PcdMinimalValidYear) / 100);
- if (Time->Year < PcdGet16 (PcdMinimalValidYear) % 100) {
+ Century = (UINT8)(mMinimalValidYear / 100);
+ if (Time->Year < mMinimalValidYear % 100) {
Century++;
}
@@ -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/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c
index e6e9458d75..ba7e85cdfb 100644
--- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c
+++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c
@@ -16,8 +16,13 @@ EFI_HANDLE mHandle = NULL;
STATIC EFI_EVENT mVirtualAddrChangeEvent;
-UINTN mRtcIndexRegister;
-UINTN mRtcTargetRegister;
+UINTN mRtcIndexRegister;
+UINTN mRtcTargetRegister;
+UINTN mRtcIndexRegisterIo;
+UINTN mRtcTargetRegisterIo;
+UINT16 mRtcDefaultYear;
+UINT16 mMinimalValidYear;
+UINT16 mMaximalValidYear;
/**
Returns the current time and date information, and the time-keeping capabilities
@@ -164,8 +169,15 @@ InitializePcRtc (
if (FeaturePcdGet (PcdRtcUseMmio)) {
mRtcIndexRegister = (UINTN)PcdGet64 (PcdRtcIndexRegister64);
mRtcTargetRegister = (UINTN)PcdGet64 (PcdRtcTargetRegister64);
+ } else {
+ mRtcIndexRegisterIo = (UINTN)PcdGet8 (PcdRtcIndexRegister);
+ mRtcTargetRegisterIo = (UINTN)PcdGet8 (PcdRtcTargetRegister);
}
+ mRtcDefaultYear = PcdGet16 (PcdRtcDefaultYear);
+ mMinimalValidYear = PcdGet16 (PcdMinimalValidYear);
+ mMaximalValidYear = PcdGet16 (PcdMaximalValidYear);
+
Status = PcRtcInit (&mModuleGlobal);
ASSERT_EFI_ERROR (Status);
--
2.39.2.windows.1
next prev parent reply other threads:[~2023-05-22 12:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-22 12:00 [PATCH v2 0/1] PcAtChipsetPkg: RTC Runtime unable to get correct IO port by PCD Guo, Gua
2023-05-22 12:00 ` Guo, Gua [this message]
2023-05-24 8:13 ` [edk2-devel] [PATCH v2 1/1] " Ni, Ray
2023-05-24 8:37 ` Guo, Gua
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230522120029.473-2-gua.guo@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox