From nobody Mon Feb 9 02:13:40 2026 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+110184+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+110184+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1698385406; cv=none; d=zohomail.com; s=zohoarc; b=G1oDDNpe8W2htpw4c3gYeev5HCuO4KQkcUNOQ19fQm2F0uwzTS7qbi7+4xyIeGcB013yNjbtvjktb19CSETxweIt558ZswCotYkOtBMQXeiyf4oGKLMWkSGhH5hobg86o+dfM0iLPpI3zwLPXxncJGXFoDd2SdwpwgBDG4u4/wM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698385406; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=EtNoe2cNnK6aMjSyPxrtfikQ/JNvLmzI3EMEkesWD/Q=; b=hgnDKKPgTvr7efXPjrSzupQBPV56n+c2i/VHHOPDIsrcpByGwO9UHXRWrclE14klrHiZK+HWXvNZ1obTpjsNNkMBrZ+luZPbFsJV7VmW7et5ufqnWFGVP2BUC6LzJXbI+heoSU+jq1oKk088pYaGy9xwLUnJChUB3jxsmY5g1GU= 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+110184+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 1698385406456146.7147456725238; Thu, 26 Oct 2023 22:43:26 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=QRzw4bt24rBS3RieCaC2MxtvD0Nq0omwSXAXSvyK8A8=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1698385406; v=1; b=F95BGEBY0XqU4Rp9/Y22jdR+xXCA+rp3bODhmiScsd/7vXhYZXYW62i44HAKDCehe/9Ct4sL CBvEP9Nu3M3a9e/PDUDkQuej5ctWq+dWMtZ6Lv9i8J/FpcuqOgT7iZMuqtqyXab8ijyyWcgdHwS e6KiZNbnd0oofnL1UItrGk14= X-Received: by 127.0.0.2 with SMTP id yFSFYY1788612xSlcxlJpkDj; Thu, 26 Oct 2023 22:43:26 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.894.1698385395579600088 for ; Thu, 26 Oct 2023 22:43:25 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="391587827" X-IronPort-AV: E=Sophos;i="6.03,255,1694761200"; d="scan'208";a="391587827" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 22:43:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="763089408" X-IronPort-AV: E=Sophos;i="6.03,255,1694761200"; d="scan'208";a="763089408" X-Received: from shwdeopenlab702.ccr.corp.intel.com ([10.239.55.43]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 22:43:23 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Zhiguang Liu , Ray Ni Subject: [edk2-devel] [PATCH 3/7] MdePkg: simplify IoRead/WriteFifo in IoLibFifo.c Date: Fri, 27 Oct 2023 13:42:56 +0800 Message-Id: <20231027054300.1382-4-dun.tan@intel.com> In-Reply-To: <20231027054300.1382-1-dun.tan@intel.com> References: <20231027054300.1382-1-dun.tan@intel.com> MIME-Version: 1.0 Precedence: Bulk 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,dun.tan@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: I9GTGHklezXwQ0hDZWfC2dSlx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698385407030100001 Content-Type: text/plain; charset="utf-8" Simplify IoRead/WriteFifo implement in IoLibFifo.c by repeatedly calling IoRead/Write API in C code. This can avoid calling assembly code to use string I/O instructions and avoid checking if sev feature is enabled. Then the code flow is simplified. Signed-off-by: Dun Tan Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Ray Ni --- MdePkg/Library/BaseIoLibIntrinsic/IoLibFifo.c | 44 +++++++++++++++++++++++= ++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/MdePkg/Library/BaseIoLibIntrinsic/IoLibFifo.c b/MdePkg/Library= /BaseIoLibIntrinsic/IoLibFifo.c index 9a94bc6a05..adce1040f6 100644 --- a/MdePkg/Library/BaseIoLibIntrinsic/IoLibFifo.c +++ b/MdePkg/Library/BaseIoLibIntrinsic/IoLibFifo.c @@ -1,7 +1,7 @@ /** @file IoFifo read/write routines. =20 - Copyright (c) 2021, Intel Corporation. All rights reserved.
+ Copyright (c) 2021-2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -39,10 +39,15 @@ IoReadFifo8 ( OUT VOID *Buffer ) { + UINT8 *Buffer8; + if (IsTdxGuest ()) { TdIoReadFifo8 (Port, Count, Buffer); } else { - SevIoReadFifo8 (Port, Count, Buffer); + Buffer8 =3D (UINT8 *)Buffer; + while (Count-- > 0) { + *Buffer8++ =3D IoRead8 (Port); + } } } =20 @@ -73,10 +78,15 @@ IoWriteFifo8 ( IN VOID *Buffer ) { + UINT8 *Buffer8; + if (IsTdxGuest ()) { TdIoWriteFifo8 (Port, Count, Buffer); } else { - SevIoWriteFifo8 (Port, Count, Buffer); + Buffer8 =3D (UINT8 *)Buffer; + while (Count-- > 0) { + IoWrite8 (Port, *Buffer8++); + } } } =20 @@ -107,10 +117,15 @@ IoReadFifo16 ( OUT VOID *Buffer ) { + UINT16 *Buffer16; + if (IsTdxGuest ()) { TdIoReadFifo16 (Port, Count, Buffer); } else { - SevIoReadFifo16 (Port, Count, Buffer); + Buffer16 =3D (UINT16 *)Buffer; + while (Count-- > 0) { + *Buffer16++ =3D IoRead16 (Port); + } } } =20 @@ -141,10 +156,15 @@ IoWriteFifo16 ( IN VOID *Buffer ) { + UINT16 *Buffer16; + if (IsTdxGuest ()) { TdIoWriteFifo16 (Port, Count, Buffer); } else { - SevIoWriteFifo16 (Port, Count, Buffer); + Buffer16 =3D (UINT16 *)Buffer; + while (Count-- > 0) { + IoWrite16 (Port, *Buffer16++); + } } } =20 @@ -175,10 +195,15 @@ IoReadFifo32 ( OUT VOID *Buffer ) { + UINT32 *Buffer32; + if (IsTdxGuest ()) { TdIoReadFifo32 (Port, Count, Buffer); } else { - SevIoReadFifo32 (Port, Count, Buffer); + Buffer32 =3D (UINT32 *)Buffer; + while (Count-- > 0) { + *Buffer32++ =3D IoRead32 (Port); + } } } =20 @@ -209,9 +234,14 @@ IoWriteFifo32 ( IN VOID *Buffer ) { + UINT32 *Buffer32; + if (IsTdxGuest ()) { TdIoWriteFifo32 (Port, Count, Buffer); } else { - SevIoWriteFifo32 (Port, Count, Buffer); + Buffer32 =3D (UINT32 *)Buffer; + while (Count-- > 0) { + IoWrite32 (Port, *Buffer32++); + } } } --=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 (#110184): https://edk2.groups.io/g/devel/message/110184 Mute This Topic: https://groups.io/mt/102215664/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-