RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 Previously IoFifo functions are in X64/IoFifoSev.nasm which supports both SEV guest and Legacy guest. IoLibFifo.c is introduced to support SEV/TDX/Legacy guest in one binary. It checks the guest type in runtime and call corresponding functions then. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang.liu@intel.com> Cc: Brijesh Singh <brijesh.singh@amd.com> Cc: Erdem Aktas <erdemaktas@google.com> Cc: James Bottomley <jejb@linux.ibm.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Signed-off-by: Min Xu <min.m.xu@intel.com>
		
			
				
	
	
		
			167 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			167 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /** @file
 | |
|   Header file for SEV IO library.
 | |
| 
 | |
|   Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
 | |
|    SPDX-License-Identifier: BSD-2-Clause-Patent
 | |
| **/
 | |
| 
 | |
| #ifndef IOLIB_SEV_H_
 | |
| #define IOLIB_SEV_H_
 | |
| 
 | |
| #include <Base.h>
 | |
| 
 | |
| #include <Library/BaseLib.h>
 | |
| #include <Library/DebugLib.h>
 | |
| 
 | |
| /**
 | |
|   Reads an 8-bit I/O port fifo into a block of memory.
 | |
| 
 | |
|   Reads the 8-bit I/O fifo port specified by Port.
 | |
|   The port is read Count times, and the read data is
 | |
|   stored in the provided Buffer.
 | |
| 
 | |
|   This function must guarantee that all I/O read and write operations are
 | |
|   serialized.
 | |
| 
 | |
|   If 8-bit I/O port operations are not supported, then ASSERT().
 | |
| 
 | |
|   @param  Port    The I/O port to read.
 | |
|   @param  Count   The number of times to read I/O port.
 | |
|   @param  Buffer  The buffer to store the read data into.
 | |
| 
 | |
| **/
 | |
| VOID
 | |
| EFIAPI
 | |
| SevIoReadFifo8 (
 | |
|   IN      UINTN  Port,
 | |
|   IN      UINTN  Count,
 | |
|   OUT     VOID   *Buffer
 | |
|   );
 | |
| 
 | |
| /**
 | |
|   Writes a block of memory into an 8-bit I/O port fifo.
 | |
| 
 | |
|   Writes the 8-bit I/O fifo port specified by Port.
 | |
|   The port is written Count times, and the write data is
 | |
|   retrieved from the provided Buffer.
 | |
| 
 | |
|   This function must guarantee that all I/O write and write operations are
 | |
|   serialized.
 | |
| 
 | |
|   If 8-bit I/O port operations are not supported, then ASSERT().
 | |
| 
 | |
|   @param  Port    The I/O port to write.
 | |
|   @param  Count   The number of times to write I/O port.
 | |
|   @param  Buffer  The buffer to retrieve the write data from.
 | |
| 
 | |
| **/
 | |
| VOID
 | |
| EFIAPI
 | |
| SevIoWriteFifo8 (
 | |
|   IN      UINTN  Port,
 | |
|   IN      UINTN  Count,
 | |
|   IN      VOID   *Buffer
 | |
|   );
 | |
| 
 | |
| /**
 | |
|   Reads an 8-bit I/O port fifo into a block of memory.
 | |
| 
 | |
|   Reads the 8-bit I/O fifo port specified by Port.
 | |
|   The port is read Count times, and the read data is
 | |
|   stored in the provided Buffer.
 | |
| 
 | |
|   This function must guarantee that all I/O read and write operations are
 | |
|   serialized.
 | |
| 
 | |
|   If 8-bit I/O port operations are not supported, then ASSERT().
 | |
| 
 | |
|   @param  Port    The I/O port to read.
 | |
|   @param  Count   The number of times to read I/O port.
 | |
|   @param  Buffer  The buffer to store the read data into.
 | |
| 
 | |
| **/
 | |
| VOID
 | |
| EFIAPI
 | |
| SevIoReadFifo16 (
 | |
|   IN      UINTN  Port,
 | |
|   IN      UINTN  Count,
 | |
|   OUT     VOID   *Buffer
 | |
|   );
 | |
| 
 | |
| /**
 | |
|   Writes a block of memory into an 8-bit I/O port fifo.
 | |
| 
 | |
|   Writes the 8-bit I/O fifo port specified by Port.
 | |
|   The port is written Count times, and the write data is
 | |
|   retrieved from the provided Buffer.
 | |
| 
 | |
|   This function must guarantee that all I/O write and write operations are
 | |
|   serialized.
 | |
| 
 | |
|   If 8-bit I/O port operations are not supported, then ASSERT().
 | |
| 
 | |
|   @param  Port    The I/O port to write.
 | |
|   @param  Count   The number of times to write I/O port.
 | |
|   @param  Buffer  The buffer to retrieve the write data from.
 | |
| 
 | |
| **/
 | |
| VOID
 | |
| EFIAPI
 | |
| SevIoWriteFifo16 (
 | |
|   IN      UINTN  Port,
 | |
|   IN      UINTN  Count,
 | |
|   IN      VOID   *Buffer
 | |
|   );
 | |
| 
 | |
| /**
 | |
|   Reads an 8-bit I/O port fifo into a block of memory.
 | |
| 
 | |
|   Reads the 8-bit I/O fifo port specified by Port.
 | |
|   The port is read Count times, and the read data is
 | |
|   stored in the provided Buffer.
 | |
| 
 | |
|   This function must guarantee that all I/O read and write operations are
 | |
|   serialized.
 | |
| 
 | |
|   If 8-bit I/O port operations are not supported, then ASSERT().
 | |
| 
 | |
|   @param  Port    The I/O port to read.
 | |
|   @param  Count   The number of times to read I/O port.
 | |
|   @param  Buffer  The buffer to store the read data into.
 | |
| 
 | |
| **/
 | |
| VOID
 | |
| EFIAPI
 | |
| SevIoReadFifo32 (
 | |
|   IN      UINTN  Port,
 | |
|   IN      UINTN  Count,
 | |
|   OUT     VOID   *Buffer
 | |
|   );
 | |
| 
 | |
| /**
 | |
|   Writes a block of memory into an 8-bit I/O port fifo.
 | |
| 
 | |
|   Writes the 8-bit I/O fifo port specified by Port.
 | |
|   The port is written Count times, and the write data is
 | |
|   retrieved from the provided Buffer.
 | |
| 
 | |
|   This function must guarantee that all I/O write and write operations are
 | |
|   serialized.
 | |
| 
 | |
|   If 8-bit I/O port operations are not supported, then ASSERT().
 | |
| 
 | |
|   @param  Port    The I/O port to write.
 | |
|   @param  Count   The number of times to write I/O port.
 | |
|   @param  Buffer  The buffer to retrieve the write data from.
 | |
| 
 | |
| **/
 | |
| VOID
 | |
| EFIAPI
 | |
| SevIoWriteFifo32 (
 | |
|   IN      UINTN  Port,
 | |
|   IN      UINTN  Count,
 | |
|   IN      VOID   *Buffer
 | |
|   );
 | |
| 
 | |
| #endif
 |