MdePkg/SmmIoLibSmmCpuIo2: Add new Fifo routines in IoLib class

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Leo Duran  <leo.duran@amd.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
Leo Duran 2017-01-14 04:09:58 +08:00 committed by Liming Gao
parent 8553d217b6
commit 44564668d5
1 changed files with 216 additions and 0 deletions

View File

@ -4,6 +4,8 @@
are based on EFI_CPU_IO_PROTOCOL.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -366,6 +368,220 @@ IoWrite64 (
return IoWriteWorker (Port, SMM_IO_UINT64, Value);
}
/**
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
IoReadFifo8 (
IN UINTN Port,
IN UINTN Count,
OUT VOID *Buffer
)
{
UINT8 *Buffer8;
Buffer8 = (UINT8 *)Buffer;
while (Count--) {
*Buffer8++ = IoRead8 (Port);
}
}
/**
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
IoWriteFifo8 (
IN UINTN Port,
IN UINTN Count,
IN VOID *Buffer
)
{
UINT8 *Buffer8;
Buffer8 = (UINT8 *)Buffer;
while (Count--) {
IoWrite8 (Port, *Buffer8++);
}
}
/**
Reads a 16-bit I/O port fifo into a block of memory.
Reads the 16-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 16-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
IoReadFifo16 (
IN UINTN Port,
IN UINTN Count,
OUT VOID *Buffer
)
{
UINT16 *Buffer16;
//
// Make sure Port is aligned on a 16-bit boundary.
//
ASSERT ((Port & 1) == 0);
Buffer16 = (UINT16 *)Buffer;
while (Count--) {
*Buffer16++ = IoRead16 (Port);
}
}
/**
Writes a block of memory into a 16-bit I/O port fifo.
Writes the 16-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 16-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
IoWriteFifo16 (
IN UINTN Port,
IN UINTN Count,
IN VOID *Buffer
)
{
UINT16 *Buffer16;
//
// Make sure Port is aligned on a 16-bit boundary.
//
ASSERT ((Port & 1) == 0);
Buffer16 = (UINT16 *)Buffer;
while (Count--) {
IoWrite16 (Port, *Buffer16++);
}
}
/**
Reads a 32-bit I/O port fifo into a block of memory.
Reads the 32-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 32-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
IoReadFifo32 (
IN UINTN Port,
IN UINTN Count,
OUT VOID *Buffer
)
{
UINT32 *Buffer32;
//
// Make sure Port is aligned on a 32-bit boundary.
//
ASSERT ((Port & 3) == 0);
Buffer32 = (UINT32 *)Buffer;
while (Count--) {
*Buffer32++ = IoRead32 (Port);
}
}
/**
Writes a block of memory into a 32-bit I/O port fifo.
Writes the 32-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 32-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
IoWriteFifo32 (
IN UINTN Port,
IN UINTN Count,
IN VOID *Buffer
)
{
UINT32 *Buffer32;
//
// Make sure Port is aligned on a 32-bit boundary.
//
ASSERT ((Port & 3) == 0);
Buffer32 = (UINT32 *)Buffer;
while (Count--) {
IoWrite32 (Port, *Buffer32++);
}
}
/**
Reads an 8-bit MMIO register.