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.web12.31421.1650901612443854543 for ; Mon, 25 Apr 2022 08:46:53 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=QR2Z23jd; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: zhuoran.chao@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650901612; x=1682437612; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=rQqgUnc3TvvyIUqky9lAFlDb593dVyauNuL3UdhmpEc=; b=QR2Z23jdLi6hKaTFNQ3pRmo8YwpDH11jEKT/xmDQJHKEhydT0zXgiotP x3ndqha9YiPMrigwiPsmGlmyqXPqWCK/4MiV5M/GanPE5Ac/94ZFyeGu+ 4LZv4BTdJ33rGabX7UNiCfWTMqdin4HcEwtXjDDd75g3ejpzJ6kW9r9gs euRJyo3rWdbvPNVRG++asvcAlCmG78qQG7RZjD9DFx8nbhopl/QqkTTzp 4vngcC4K5PLNLF4kZxyxoQpIv4RtBi4/P55e4HFnKDYh/XNiNdu3WKoig 9bQ4J8A/DRMhU8x3Ps6LvvSNHcYdWMGW1c3Gi+NpgCECpsnT4sjG3t98I Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10328"; a="262882017" X-IronPort-AV: E=Sophos;i="5.90,288,1643702400"; d="scan'208";a="262882017" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2022 08:46:51 -0700 X-IronPort-AV: E=Sophos;i="5.90,288,1643702400"; d="scan'208";a="532177581" Received: from zchao-mobl1.ccr.corp.intel.com ([10.255.28.244]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2022 08:46:50 -0700 From: zhuoran.chao@intel.com To: devel@edk2.groups.io Cc: Zhuoran Chao , Ray Ni Subject: [PATCH] PcAtChipsetPkg: Change the flow of PcRtcInit() Date: Mon, 25 Apr 2022 23:46:35 +0800 Message-Id: <06d8bbd206495c31f5e7aaebc979b338af4264dd.1650900008.git.zhuoran.chao@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Cc: Ray Ni Signed-off-by: Zhuoran Chao --- PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c index 0fbfa4bcee..ea56a66267 100644 --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c @@ -269,13 +269,6 @@ PcRtcInit ( Time.Month = RtcRead (RTC_ADDRESS_MONTH); 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. // @@ -330,6 +323,13 @@ PcRtcInit ( Time.Daylight = 0; } + // + // 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 // -- 2.31.1.windows.1