From: "duntan" <dun.tan@intel.com>
To: devel@edk2.groups.io
Cc: Michael D Kinney <michael.d.kinney@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>,
Zhiguang Liu <zhiguang.liu@intel.com>, Ray Ni <ray.ni@intel.com>
Subject: [edk2-devel] [PATCH 3/7] MdePkg: simplify IoRead/WriteFifo in IoLibFifo.c
Date: Fri, 27 Oct 2023 13:42:56 +0800 [thread overview]
Message-ID: <20231027054300.1382-4-dun.tan@intel.com> (raw)
In-Reply-To: <20231027054300.1382-1-dun.tan@intel.com>
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 <dun.tan@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
---
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.
- Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021-2023, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -39,10 +39,15 @@ IoReadFifo8 (
OUT VOID *Buffer
)
{
+ UINT8 *Buffer8;
+
if (IsTdxGuest ()) {
TdIoReadFifo8 (Port, Count, Buffer);
} else {
- SevIoReadFifo8 (Port, Count, Buffer);
+ Buffer8 = (UINT8 *)Buffer;
+ while (Count-- > 0) {
+ *Buffer8++ = IoRead8 (Port);
+ }
}
}
@@ -73,10 +78,15 @@ IoWriteFifo8 (
IN VOID *Buffer
)
{
+ UINT8 *Buffer8;
+
if (IsTdxGuest ()) {
TdIoWriteFifo8 (Port, Count, Buffer);
} else {
- SevIoWriteFifo8 (Port, Count, Buffer);
+ Buffer8 = (UINT8 *)Buffer;
+ while (Count-- > 0) {
+ IoWrite8 (Port, *Buffer8++);
+ }
}
}
@@ -107,10 +117,15 @@ IoReadFifo16 (
OUT VOID *Buffer
)
{
+ UINT16 *Buffer16;
+
if (IsTdxGuest ()) {
TdIoReadFifo16 (Port, Count, Buffer);
} else {
- SevIoReadFifo16 (Port, Count, Buffer);
+ Buffer16 = (UINT16 *)Buffer;
+ while (Count-- > 0) {
+ *Buffer16++ = IoRead16 (Port);
+ }
}
}
@@ -141,10 +156,15 @@ IoWriteFifo16 (
IN VOID *Buffer
)
{
+ UINT16 *Buffer16;
+
if (IsTdxGuest ()) {
TdIoWriteFifo16 (Port, Count, Buffer);
} else {
- SevIoWriteFifo16 (Port, Count, Buffer);
+ Buffer16 = (UINT16 *)Buffer;
+ while (Count-- > 0) {
+ IoWrite16 (Port, *Buffer16++);
+ }
}
}
@@ -175,10 +195,15 @@ IoReadFifo32 (
OUT VOID *Buffer
)
{
+ UINT32 *Buffer32;
+
if (IsTdxGuest ()) {
TdIoReadFifo32 (Port, Count, Buffer);
} else {
- SevIoReadFifo32 (Port, Count, Buffer);
+ Buffer32 = (UINT32 *)Buffer;
+ while (Count-- > 0) {
+ *Buffer32++ = IoRead32 (Port);
+ }
}
}
@@ -209,9 +234,14 @@ IoWriteFifo32 (
IN VOID *Buffer
)
{
+ UINT32 *Buffer32;
+
if (IsTdxGuest ()) {
TdIoWriteFifo32 (Port, Count, Buffer);
} else {
- SevIoWriteFifo32 (Port, Count, Buffer);
+ Buffer32 = (UINT32 *)Buffer;
+ while (Count-- > 0) {
+ IoWrite32 (Port, *Buffer32++);
+ }
}
}
--
2.31.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
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/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2023-10-27 5:43 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-27 5:42 [edk2-devel] [PATCH 0/7] Support Tdx and sev in BaseIoLibIntrinsic and remove BaseIoLibIntrinsicSev duntan
2023-10-27 5:42 ` [edk2-devel] [PATCH 1/7] MdePkg: Create TdxLibNull.inf instance duntan
2023-10-27 5:54 ` Ni, Ray
2023-10-27 5:56 ` Ni, Ray
2023-10-27 6:32 ` duntan
2023-10-27 5:42 ` [edk2-devel] [PATCH 2/7] MdePkg: Add CcProbeLibNull and TdxLibNull implement duntan
2023-10-27 5:42 ` duntan [this message]
2023-10-27 5:42 ` [edk2-devel] [PATCH 4/7] MdePkg:support Tdx and sev in BaseIoLibIntrinsic duntan
2023-10-27 5:42 ` [edk2-devel] [PATCH 5/7] OvmfPkg: Add CcProbeLib in PlatformInitLib.inf duntan
2023-10-30 14:37 ` Ard Biesheuvel
2023-10-27 5:42 ` [edk2-devel] [PATCH 6/7] OvmfPkg: use BaseIoLibIntrinsic.inf in dsc files duntan
2023-10-30 14:36 ` Ard Biesheuvel
2023-10-31 12:30 ` Laszlo Ersek
2023-10-31 13:19 ` Ard Biesheuvel
2023-10-27 5:43 ` [edk2-devel] [PATCH 7/7] MdePkg:remove BaseIoLibIntrinsicSev related code duntan
2023-10-27 5:49 ` [edk2-devel] [PATCH 0/7] Support Tdx and sev in BaseIoLibIntrinsic and remove BaseIoLibIntrinsicSev Yao, Jiewen
2023-10-27 6:31 ` duntan
2023-10-27 7:06 ` Yao, Jiewen
2023-10-27 7:34 ` duntan
2023-10-27 8:05 ` duntan
2023-10-27 21:31 ` Lendacky, Thomas via groups.io
2023-10-28 11:40 ` Laszlo Ersek
2023-10-31 9:56 ` duntan
2023-10-31 17:06 ` Laszlo Ersek
2023-10-31 22:36 ` Laszlo Ersek
2023-11-02 8:49 ` duntan
2023-11-02 10:42 ` Laszlo Ersek
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=20231027054300.1382-4-dun.tan@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