summaryrefslogtreecommitdiffstats
path: root/PcAtChipsetPkg
diff options
context:
space:
mode:
authorChao, Zhuoran <zhuoran.chao@intel.com>2022-05-07 17:39:37 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-05-09 02:45:01 +0000
commit29ae55a0b8194fef2e769f2882297aa601b4777a (patch)
tree9321710320c38ac84a31c44b28de26913e9292a5 /PcAtChipsetPkg
parent1a6c837638e4081b5154fd224666a80e1eda85fe (diff)
downloadedk2-29ae55a0b8194fef2e769f2882297aa601b4777a.tar.gz
edk2-29ae55a0b8194fef2e769f2882297aa601b4777a.tar.bz2
edk2-29ae55a0b8194fef2e769f2882297aa601b4777a.zip
PcAtChipsetPkg: Change the flow of PcRtcInit()
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3913 The original flow of PcRtcInit() is like: 1. Guarantee atomic accesses to the RTC time registers and read out the value. 2. Program RTC register B. (adopt 12h mode or 24h mode. Current bios code sets RTC to 24h mode by default). 3. Then function ConvertRtcTimeToEfiTime converts the RTC time value to their 24h mode by checking the hour format bit (1:24h mode,0:12h mode). And here lies the problem: Step3 will fail to adjust the value if Step2 already sets RTC to 24h mode. The hour value in 12h mode will not be converted to its 24h mode. The solution is to program RTC register B a little later when all the original RTC registers' value is retrieved, adjusted and validated. ConvertRtcTimeToEfiTime is modified to be more robust. Reviewed-by: Ray Ni <ray.ni@intel.com> Signed-off-by: Zhuoran Chao <zhuoran.chao@intel.com>
Diffstat (limited to 'PcAtChipsetPkg')
-rw-r--r--PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
index 0fbfa4bcee..9242a2e826 100644
--- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
+++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
@@ -270,13 +270,6 @@ PcRtcInit (
Time.Year = RtcRead (RTC_ADDRESS_YEAR);
//
- // Set RTC configuration after get original time
- // The value of bit AIE should be reserved.
- //
- RegisterB.Data = FixedPcdGet8 (PcdInitialValueRtcRegisterB) | (RegisterB.Data & BIT5);
- RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
-
- //
// Release RTC Lock.
//
if (!EfiAtRuntime ()) {
@@ -331,6 +324,13 @@ PcRtcInit (
}
//
+ // Set RTC configuration after get original time
+ // The value of bit AIE should be reserved.
+ //
+ RegisterB.Data = FixedPcdGet8 (PcdInitialValueRtcRegisterB) | (RegisterB.Data & BIT5);
+ RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
+
+ //
// Reset time value according to new RTC configuration
//
Status = PcRtcSetTime (&Time, Global);
@@ -995,13 +995,16 @@ ConvertRtcTimeToEfiTime (
BOOLEAN IsPM;
UINT8 Century;
- if ((Time->Hour & 0x80) != 0) {
- IsPM = TRUE;
- } else {
- IsPM = FALSE;
- }
+ // IsPM only makes sense for 12-hour format.
+ if (RegisterB.Bits.Mil == 0) {
+ if ((Time->Hour & 0x80) != 0) {
+ IsPM = TRUE;
+ } else {
+ IsPM = FALSE;
+ }
- Time->Hour = (UINT8)(Time->Hour & 0x7f);
+ Time->Hour = (UINT8)(Time->Hour & 0x7f);
+ }
if (RegisterB.Bits.Dm == 0) {
Time->Year = CheckAndConvertBcd8ToDecimal8 ((UINT8)Time->Year);