From nobody Sat Apr 27 02:52:20 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+89574+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+89574+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1651916388; cv=none; d=zohomail.com; s=zohoarc; b=lmUZIGV1BCs4LBC+nGj2+AUJIGWvUM+F48BvN/KskcyMvzcII9IzhF1A0TKmSytIcgDfrqXYVb+8vruySAcHUlZeGV9Ng+ndlmkUb/NxQ6Lvpy4Bs+W1X0nrjCY22tvIov5wOzcmVpFp6TVIo0m1rvqNxqlSVFpY2YKvCfbhQ1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651916388; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=oJp1DkvU26mUdvDEeJZnLAkbwJk75ptRjDJyWVbIQSQ=; b=Wg2XE8xEegAbdb/FHJH0N32oIcHTbKlFs7sw4KZPHFEdYFHAcs5HwkSjC44RcRZ972yYQ/hKFa9c1jUM+WzpdEsHFqV9Ob0VNO5UxXjwIse5ZsUYelplcti1cFYcf8RWZ8U+mcD2sfT0L9Fgp2GJB9QW9A3VJG/OvRg85g7/i8w= 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+89574+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 1651916388223103.99341490729955; Sat, 7 May 2022 02:39:48 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vTRWYY1788612xCIZapDtWTV; Sat, 07 May 2022 02:39:47 -0700 X-Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web08.8181.1651916386219383154 for ; Sat, 07 May 2022 02:39:47 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10339"; a="266275632" X-IronPort-AV: E=Sophos;i="5.91,206,1647327600"; d="scan'208";a="266275632" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2022 02:39:45 -0700 X-IronPort-AV: E=Sophos;i="5.91,206,1647327600"; d="scan'208";a="586441587" X-Received: from zchao-mobl1.ccr.corp.intel.com ([10.249.172.67]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2022 02:39:43 -0700 From: "Zhuoran Chao" To: devel@edk2.groups.io Cc: Zhuoran Chao , Ray Ni Subject: [edk2-devel] [PATCH v3] PcAtChipsetPkg: Change the flow of PcRtcInit() Date: Sat, 7 May 2022 17:39:37 +0800 Message-Id: <1d9ab6d031b853fb580366834fd1809c84d321fd.1651915058.git.zhuoran.chao@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,zhuoran.chao@intel.com X-Gm-Message-State: kL9YC0nZ3yQm4uRyJEQldc6Wx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1651916387; bh=panxN4ZLxx2DS+mM2X84kMKhTv8CoayQu3ucJOnxoCw=; h=Cc:Date:From:Reply-To:Subject:To; b=cM41/u8WiLbO9KlZwEJ5UpwqwAcTMr9GMdJ+110UVeZxBpyHSnk1TOJA42QPBiYa/ds Ghg4dGAePb6XkYFk/ZUIRYsYv37UEHxlBDDuGh3tE/rXg2QSVWXuCDUacMtvVaeTwYBhO iLfkWSQXN9anZm8FK7rQ29tt/eZh0Q66A/4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1651916389013100001 Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3913 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. Cc: Ray Ni Signed-off-by: Zhuoran Chao Reviewed-by: Ray Ni --- .../PcatRealTimeClockRuntimeDxe/PcRtc.c | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChips= etPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c index 0fbfa4bcee..9242a2e826 100644 --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c @@ -269,13 +269,6 @@ PcRtcInit ( Time.Month =3D RtcRead (RTC_ADDRESS_MONTH); Time.Year =3D RtcRead (RTC_ADDRESS_YEAR); =20 - // - // Set RTC configuration after get original time - // The value of bit AIE should be reserved. - // - RegisterB.Data =3D FixedPcdGet8 (PcdInitialValueRtcRegisterB) | (Registe= rB.Data & BIT5); - RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data); - // // Release RTC Lock. // @@ -330,6 +323,13 @@ PcRtcInit ( Time.Daylight =3D 0; } =20 + // + // Set RTC configuration after get original time + // The value of bit AIE should be reserved. + // + RegisterB.Data =3D FixedPcdGet8 (PcdInitialValueRtcRegisterB) | (Registe= rB.Data & BIT5); + RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data); + // // Reset time value according to new RTC configuration // @@ -995,13 +995,16 @@ ConvertRtcTimeToEfiTime ( BOOLEAN IsPM; UINT8 Century; =20 - if ((Time->Hour & 0x80) !=3D 0) { - IsPM =3D TRUE; - } else { - IsPM =3D FALSE; - } + // IsPM only makes sense for 12-hour format. + if (RegisterB.Bits.Mil =3D=3D 0) { + if ((Time->Hour & 0x80) !=3D 0) { + IsPM =3D TRUE; + } else { + IsPM =3D FALSE; + } =20 - Time->Hour =3D (UINT8)(Time->Hour & 0x7f); + Time->Hour =3D (UINT8)(Time->Hour & 0x7f); + } =20 if (RegisterB.Bits.Dm =3D=3D 0) { Time->Year =3D CheckAndConvertBcd8ToDecimal8 ((UINT8)Time->Year); --=20 2.31.1.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 (#89574): https://edk2.groups.io/g/devel/message/89574 Mute This Topic: https://groups.io/mt/90950219/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-