BaseIoLibIntrinsicInternal.h\r
IoHighLevel.c\r
IoLibTdx.h\r
+ IoLibSev.h\r
\r
[Sources.IA32]\r
IoLibGcc.c | GCC\r
IoLibMsc.c | MSFT\r
IoLib.c\r
IoLibInternalTdx.c\r
+ IoLibFifo.c\r
X64/IoFifoSev.nasm\r
\r
[Packages]\r
--- /dev/null
+/** @file\r
+ IoFifo read/write routines.\r
+\r
+ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include "BaseIoLibIntrinsicInternal.h"\r
+#include "IoLibSev.h"\r
+#include "IoLibTdx.h"\r
+#include <Uefi/UefiBaseType.h>\r
+#include <Library/TdxLib.h>\r
+\r
+/**\r
+ Reads an 8-bit I/O port fifo into a block of memory.\r
+\r
+ Reads the 8-bit I/O fifo port specified by Port.\r
+ The port is read Count times, and the read data is\r
+ stored in the provided Buffer.\r
+\r
+ This function must guarantee that all I/O read and write operations are\r
+ serialized.\r
+\r
+ If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+ In TDX a serial of TdIoRead8 is invoked to read the I/O port fifo.\r
+\r
+ @param Port The I/O port to read.\r
+ @param Count The number of times to read I/O port.\r
+ @param Buffer The buffer to store the read data into.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+IoReadFifo8 (\r
+ IN UINTN Port,\r
+ IN UINTN Count,\r
+ OUT VOID *Buffer\r
+ )\r
+{\r
+ if (IsTdxGuest ()) {\r
+ TdIoReadFifo8 (Port, Count, Buffer);\r
+ } else {\r
+ SevIoReadFifo8 (Port, Count, Buffer);\r
+ }\r
+}\r
+\r
+/**\r
+ Writes a block of memory into an 8-bit I/O port fifo.\r
+\r
+ Writes the 8-bit I/O fifo port specified by Port.\r
+ The port is written Count times, and the write data is\r
+ retrieved from the provided Buffer.\r
+\r
+ This function must guarantee that all I/O write and write operations are\r
+ serialized.\r
+\r
+ If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+ In TDX a serial of TdIoWrite8 is invoked to write data to the I/O port.\r
+\r
+ @param Port The I/O port to write.\r
+ @param Count The number of times to write I/O port.\r
+ @param Buffer The buffer to retrieve the write data from.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+IoWriteFifo8 (\r
+ IN UINTN Port,\r
+ IN UINTN Count,\r
+ IN VOID *Buffer\r
+ )\r
+{\r
+ if (IsTdxGuest ()) {\r
+ TdIoWriteFifo8 (Port, Count, Buffer);\r
+ } else {\r
+ SevIoWriteFifo8 (Port, Count, Buffer);\r
+ }\r
+}\r
+\r
+/**\r
+ Reads a 16-bit I/O port fifo into a block of memory.\r
+\r
+ Reads the 16-bit I/O fifo port specified by Port.\r
+ The port is read Count times, and the read data is\r
+ stored in the provided Buffer.\r
+\r
+ This function must guarantee that all I/O read and write operations are\r
+ serialized.\r
+\r
+ If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+ In TDX a serial of TdIoRead16 is invoked to read data from the I/O port.\r
+\r
+ @param Port The I/O port to read.\r
+ @param Count The number of times to read I/O port.\r
+ @param Buffer The buffer to store the read data into.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+IoReadFifo16 (\r
+ IN UINTN Port,\r
+ IN UINTN Count,\r
+ OUT VOID *Buffer\r
+ )\r
+{\r
+ if (IsTdxGuest ()) {\r
+ TdIoReadFifo16 (Port, Count, Buffer);\r
+ } else {\r
+ SevIoReadFifo16 (Port, Count, Buffer);\r
+ }\r
+}\r
+\r
+/**\r
+ Writes a block of memory into a 16-bit I/O port fifo.\r
+\r
+ Writes the 16-bit I/O fifo port specified by Port.\r
+ The port is written Count times, and the write data is\r
+ retrieved from the provided Buffer.\r
+\r
+ This function must guarantee that all I/O write and write operations are\r
+ serialized.\r
+\r
+ If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+ In TDX a serial of TdIoWrite16 is invoked to write data to the I/O port.\r
+\r
+ @param Port The I/O port to write.\r
+ @param Count The number of times to write I/O port.\r
+ @param Buffer The buffer to retrieve the write data from.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+IoWriteFifo16 (\r
+ IN UINTN Port,\r
+ IN UINTN Count,\r
+ IN VOID *Buffer\r
+ )\r
+{\r
+ if (IsTdxGuest ()) {\r
+ TdIoWriteFifo16 (Port, Count, Buffer);\r
+ } else {\r
+ SevIoWriteFifo16 (Port, Count, Buffer);\r
+ }\r
+}\r
+\r
+/**\r
+ Reads a 32-bit I/O port fifo into a block of memory.\r
+\r
+ Reads the 32-bit I/O fifo port specified by Port.\r
+ The port is read Count times, and the read data is\r
+ stored in the provided Buffer.\r
+\r
+ This function must guarantee that all I/O read and write operations are\r
+ serialized.\r
+\r
+ If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+ In TDX a serial of TdIoRead32 is invoked to read data from the I/O port.\r
+\r
+ @param Port The I/O port to read.\r
+ @param Count The number of times to read I/O port.\r
+ @param Buffer The buffer to store the read data into.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+IoReadFifo32 (\r
+ IN UINTN Port,\r
+ IN UINTN Count,\r
+ OUT VOID *Buffer\r
+ )\r
+{\r
+ if (IsTdxGuest ()) {\r
+ TdIoReadFifo32 (Port, Count, Buffer);\r
+ } else {\r
+ SevIoReadFifo32 (Port, Count, Buffer);\r
+ }\r
+}\r
+\r
+/**\r
+ Writes a block of memory into a 32-bit I/O port fifo.\r
+\r
+ Writes the 32-bit I/O fifo port specified by Port.\r
+ The port is written Count times, and the write data is\r
+ retrieved from the provided Buffer.\r
+\r
+ This function must guarantee that all I/O write and write operations are\r
+ serialized.\r
+\r
+ If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+ In TDX a serial of TdIoWrite32 is invoked to write data to the I/O port.\r
+\r
+ @param Port The I/O port to write.\r
+ @param Count The number of times to write I/O port.\r
+ @param Buffer The buffer to retrieve the write data from.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+IoWriteFifo32 (\r
+ IN UINTN Port,\r
+ IN UINTN Count,\r
+ IN VOID *Buffer\r
+ )\r
+{\r
+ if (IsTdxGuest ()) {\r
+ TdIoWriteFifo32 (Port, Count, Buffer);\r
+ } else {\r
+ SevIoWriteFifo32 (Port, Count, Buffer);\r
+ }\r
+}\r
--- /dev/null
+/** @file\r
+ Header file for SEV IO library.\r
+\r
+ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#ifndef IOLIB_SEV_H_\r
+#define IOLIB_SEV_H_\r
+\r
+#include <Base.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+/**\r
+ Reads an 8-bit I/O port fifo into a block of memory.\r
+\r
+ Reads the 8-bit I/O fifo port specified by Port.\r
+ The port is read Count times, and the read data is\r
+ stored in the provided Buffer.\r
+\r
+ This function must guarantee that all I/O read and write operations are\r
+ serialized.\r
+\r
+ If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+ @param Port The I/O port to read.\r
+ @param Count The number of times to read I/O port.\r
+ @param Buffer The buffer to store the read data into.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SevIoReadFifo8 (\r
+ IN UINTN Port,\r
+ IN UINTN Count,\r
+ OUT VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Writes a block of memory into an 8-bit I/O port fifo.\r
+\r
+ Writes the 8-bit I/O fifo port specified by Port.\r
+ The port is written Count times, and the write data is\r
+ retrieved from the provided Buffer.\r
+\r
+ This function must guarantee that all I/O write and write operations are\r
+ serialized.\r
+\r
+ If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+ @param Port The I/O port to write.\r
+ @param Count The number of times to write I/O port.\r
+ @param Buffer The buffer to retrieve the write data from.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SevIoWriteFifo8 (\r
+ IN UINTN Port,\r
+ IN UINTN Count,\r
+ IN VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Reads an 8-bit I/O port fifo into a block of memory.\r
+\r
+ Reads the 8-bit I/O fifo port specified by Port.\r
+ The port is read Count times, and the read data is\r
+ stored in the provided Buffer.\r
+\r
+ This function must guarantee that all I/O read and write operations are\r
+ serialized.\r
+\r
+ If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+ @param Port The I/O port to read.\r
+ @param Count The number of times to read I/O port.\r
+ @param Buffer The buffer to store the read data into.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SevIoReadFifo16 (\r
+ IN UINTN Port,\r
+ IN UINTN Count,\r
+ OUT VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Writes a block of memory into an 8-bit I/O port fifo.\r
+\r
+ Writes the 8-bit I/O fifo port specified by Port.\r
+ The port is written Count times, and the write data is\r
+ retrieved from the provided Buffer.\r
+\r
+ This function must guarantee that all I/O write and write operations are\r
+ serialized.\r
+\r
+ If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+ @param Port The I/O port to write.\r
+ @param Count The number of times to write I/O port.\r
+ @param Buffer The buffer to retrieve the write data from.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SevIoWriteFifo16 (\r
+ IN UINTN Port,\r
+ IN UINTN Count,\r
+ IN VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Reads an 8-bit I/O port fifo into a block of memory.\r
+\r
+ Reads the 8-bit I/O fifo port specified by Port.\r
+ The port is read Count times, and the read data is\r
+ stored in the provided Buffer.\r
+\r
+ This function must guarantee that all I/O read and write operations are\r
+ serialized.\r
+\r
+ If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+ @param Port The I/O port to read.\r
+ @param Count The number of times to read I/O port.\r
+ @param Buffer The buffer to store the read data into.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SevIoReadFifo32 (\r
+ IN UINTN Port,\r
+ IN UINTN Count,\r
+ OUT VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Writes a block of memory into an 8-bit I/O port fifo.\r
+\r
+ Writes the 8-bit I/O fifo port specified by Port.\r
+ The port is written Count times, and the write data is\r
+ retrieved from the provided Buffer.\r
+\r
+ This function must guarantee that all I/O write and write operations are\r
+ serialized.\r
+\r
+ If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+ @param Port The I/O port to write.\r
+ @param Count The number of times to write I/O port.\r
+ @param Buffer The buffer to retrieve the write data from.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SevIoWriteFifo32 (\r
+ IN UINTN Port,\r
+ IN UINTN Count,\r
+ IN VOID *Buffer\r
+ );\r
+\r
+#endif\r
;------------------------------------------------------------------------------\r
; VOID\r
; EFIAPI\r
-; IoReadFifo8 (\r
+; SevIoReadFifo8 (\r
; IN UINTN Port, // rcx\r
; IN UINTN Size, // rdx\r
; OUT VOID *Buffer // r8\r
; );\r
;------------------------------------------------------------------------------\r
-global ASM_PFX(IoReadFifo8)\r
-ASM_PFX(IoReadFifo8):\r
+global ASM_PFX(SevIoReadFifo8)\r
+ASM_PFX(SevIoReadFifo8):\r
xchg rcx, rdx\r
xchg rdi, r8 ; rdi: buffer address; r8: save rdi\r
\r
;------------------------------------------------------------------------------\r
; VOID\r
; EFIAPI\r
-; IoReadFifo16 (\r
+; SevIoReadFifo16 (\r
; IN UINTN Port, // rcx\r
; IN UINTN Size, // rdx\r
; OUT VOID *Buffer // r8\r
; );\r
;------------------------------------------------------------------------------\r
-global ASM_PFX(IoReadFifo16)\r
-ASM_PFX(IoReadFifo16):\r
+global ASM_PFX(SevIoReadFifo16)\r
+ASM_PFX(SevIoReadFifo16):\r
xchg rcx, rdx\r
xchg rdi, r8 ; rdi: buffer address; r8: save rdi\r
\r
;------------------------------------------------------------------------------\r
; VOID\r
; EFIAPI\r
-; IoReadFifo32 (\r
+; SevIoReadFifo32 (\r
; IN UINTN Port, // rcx\r
; IN UINTN Size, // rdx\r
; OUT VOID *Buffer // r8\r
; );\r
;------------------------------------------------------------------------------\r
-global ASM_PFX(IoReadFifo32)\r
-ASM_PFX(IoReadFifo32):\r
+global ASM_PFX(SevIoReadFifo32)\r
+ASM_PFX(SevIoReadFifo32):\r
xchg rcx, rdx\r
xchg rdi, r8 ; rdi: buffer address; r8: save rdi\r
\r
; IN VOID *Buffer // r8\r
; );\r
;------------------------------------------------------------------------------\r
-global ASM_PFX(IoWriteFifo8)\r
-ASM_PFX(IoWriteFifo8):\r
+global ASM_PFX(SevIoWriteFifo8)\r
+ASM_PFX(SevIoWriteFifo8):\r
xchg rcx, rdx\r
xchg rsi, r8 ; rsi: buffer address; r8: save rsi\r
\r
;------------------------------------------------------------------------------\r
; VOID\r
; EFIAPI\r
-; IoWriteFifo16 (\r
+; SevIoWriteFifo16 (\r
; IN UINTN Port, // rcx\r
; IN UINTN Size, // rdx\r
; IN VOID *Buffer // r8\r
; );\r
;------------------------------------------------------------------------------\r
-global ASM_PFX(IoWriteFifo16)\r
-ASM_PFX(IoWriteFifo16):\r
+global ASM_PFX(SevIoWriteFifo16)\r
+ASM_PFX(SevIoWriteFifo16):\r
xchg rcx, rdx\r
xchg rsi, r8 ; rsi: buffer address; r8: save rsi\r
\r
;------------------------------------------------------------------------------\r
; VOID\r
; EFIAPI\r
-; IoWriteFifo32 (\r
+; SevIoWriteFifo32 (\r
; IN UINTN Port, // rcx\r
; IN UINTN Size, // rdx\r
; IN VOID *Buffer // r8\r
; );\r
;------------------------------------------------------------------------------\r
-global ASM_PFX(IoWriteFifo32)\r
-ASM_PFX(IoWriteFifo32):\r
+global ASM_PFX(SevIoWriteFifo32)\r
+ASM_PFX(SevIoWriteFifo32):\r
xchg rcx, rdx\r
xchg rsi, r8 ; rsi: buffer address; r8: save rsi\r
\r