From 8fc71decbe7ada34f96f04261e680265ce916a51 Mon Sep 17 00:00:00 2001 From: mdkinney Date: Thu, 14 Jan 2010 04:20:04 +0000 Subject: Change SMM CPU I/O to SMM CPU I/O 2 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9735 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Include/Pi/PiSmmCis.h | 6 +- MdePkg/Include/Protocol/SmmCpuIo.h | 96 - MdePkg/Include/Protocol/SmmCpuIo2.h | 105 + MdePkg/Library/SmmIoLibCpuIo/IoHighLevel.c | 2275 -------------------- MdePkg/Library/SmmIoLibCpuIo/IoLib.c | 642 ------ MdePkg/Library/SmmIoLibCpuIo/IoLibMmioBuffer.c | 416 ---- MdePkg/Library/SmmIoLibCpuIo/SmmCpuIoLibInternal.h | 121 -- MdePkg/Library/SmmIoLibCpuIo/SmmIoLibCpuIo.inf | 56 - MdePkg/Library/SmmIoLibSmmCpuIo2/IoHighLevel.c | 2272 +++++++++++++++++++ MdePkg/Library/SmmIoLibSmmCpuIo2/IoLib.c | 619 ++++++ MdePkg/Library/SmmIoLibSmmCpuIo2/IoLibMmioBuffer.c | 413 ++++ .../SmmIoLibSmmCpuIo2/SmmCpuIoLibInternal.h | 118 + .../SmmIoLibSmmCpuIo2/SmmIoLibSmmCpuIo2.inf | 51 + MdePkg/MdePkg.dec | 6 +- MdePkg/MdePkg.dsc | 2 +- 15 files changed, 3585 insertions(+), 3613 deletions(-) delete mode 100644 MdePkg/Include/Protocol/SmmCpuIo.h create mode 100644 MdePkg/Include/Protocol/SmmCpuIo2.h delete mode 100644 MdePkg/Library/SmmIoLibCpuIo/IoHighLevel.c delete mode 100644 MdePkg/Library/SmmIoLibCpuIo/IoLib.c delete mode 100644 MdePkg/Library/SmmIoLibCpuIo/IoLibMmioBuffer.c delete mode 100644 MdePkg/Library/SmmIoLibCpuIo/SmmCpuIoLibInternal.h delete mode 100644 MdePkg/Library/SmmIoLibCpuIo/SmmIoLibCpuIo.inf create mode 100644 MdePkg/Library/SmmIoLibSmmCpuIo2/IoHighLevel.c create mode 100644 MdePkg/Library/SmmIoLibSmmCpuIo2/IoLib.c create mode 100644 MdePkg/Library/SmmIoLibSmmCpuIo2/IoLibMmioBuffer.c create mode 100644 MdePkg/Library/SmmIoLibSmmCpuIo2/SmmCpuIoLibInternal.h create mode 100644 MdePkg/Library/SmmIoLibSmmCpuIo2/SmmIoLibSmmCpuIo2.inf diff --git a/MdePkg/Include/Pi/PiSmmCis.h b/MdePkg/Include/Pi/PiSmmCis.h index 52eaea560d..597eeb9086 100644 --- a/MdePkg/Include/Pi/PiSmmCis.h +++ b/MdePkg/Include/Pi/PiSmmCis.h @@ -2,7 +2,7 @@ Common definitions in the Platform Initialization Specification version 1.2 VOLUME 4 System Management Mode Core Interface version. - Copyright (c) 2009, Intel Corporation + Copyright (c) 2009 - 2010, Intel Corporation All rights reserved. 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 @@ -17,7 +17,7 @@ #define _PI_SMMCIS_H_ #include -#include +#include /// /// Note: @@ -280,7 +280,7 @@ struct _EFI_SMM_SYSTEM_TABLE2 { /// /// I/O Service /// - EFI_SMM_CPU_IO_PROTOCOL SmmIo; + EFI_SMM_CPU_IO2_PROTOCOL SmmIo; /// /// Runtime memory services diff --git a/MdePkg/Include/Protocol/SmmCpuIo.h b/MdePkg/Include/Protocol/SmmCpuIo.h deleted file mode 100644 index 3418d43c79..0000000000 --- a/MdePkg/Include/Protocol/SmmCpuIo.h +++ /dev/null @@ -1,96 +0,0 @@ -/** @file - SMM CPU I/O protocol as defined in the PI 1.2 specification. - - This protocol provides CPU I/O and memory access within SMM. - - Copyright (c) 2009, Intel Corporation - All rights reserved. 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 - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _SMM_CPU_IO_H_ -#define _SMM_CPU_IO_H_ - -/// -/// Note: -/// To avoid name conflict between PI and Framework SMM spec, the following names defined -/// in PI 1.2 SMM spec are renamed. These renamings are not yet in a public PI spec and errta. -/// -/// EFI_SMM_CPU_IO -> EFI_SMM_CPU_IO2 -/// EFI_SMM_IO_ACCESS -> EFI_SMM_IO_ACCESS2 -/// - -#define EFI_SMM_CPU_IO_PROTOCOL_GUID \ - { \ - 0x3242A9D8, 0xCE70, 0x4AA0, { 0x95, 0x5D, 0x5E, 0x7B, 0x14, 0x0D, 0xE4, 0xD2 } \ - } - -typedef struct _EFI_SMM_CPU_IO_PROTOCOL EFI_SMM_CPU_IO_PROTOCOL; - -/// -/// Width of the SMM CPU I/O operations -/// -typedef enum { - SMM_IO_UINT8 = 0, - SMM_IO_UINT16 = 1, - SMM_IO_UINT32 = 2, - SMM_IO_UINT64 = 3 -} EFI_SMM_IO_WIDTH; - -/** - Provides the basic memory and I/O interfaces used toabstract accesses to devices. - - The I/O operations are carried out exactly as requested. The caller is responsible for any alignment - and I/O width issues that the bus, device, platform, or type of I/O might require. - - @param[in] This The EFI_SMM_CPU_IO_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O operations. - @param[in] Address The base address of the I/O operations. - The caller is responsible for aligning the Address if required. - @param[in] Count The number of I/O operations to perform. - @param[in,out] Buffer For read operations, the destination buffer to store the results. - For write operations, the source buffer from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the device. - @retval EFI_UNSUPPORTED The Address is not valid for this system. - @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_SMM_CPU_IO2)( - IN CONST EFI_SMM_CPU_IO_PROTOCOL *This, - IN EFI_SMM_IO_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN OUT VOID *Buffer - ); - -typedef struct { - /// - /// This service provides the various modalities of memory and I/O read. - /// - EFI_SMM_CPU_IO2 Read; - /// - /// This service provides the various modalities of memory and I/O write. - /// - EFI_SMM_CPU_IO2 Write; -} EFI_SMM_IO_ACCESS2; - -/// -/// SMM CPU I/O Protocol provides CPU I/O and memory access within SMM. -/// -struct _EFI_SMM_CPU_IO_PROTOCOL { - EFI_SMM_IO_ACCESS2 Mem; ///< Allows reads and writes to memory-mapped I/O space. - EFI_SMM_IO_ACCESS2 Io; ///< Allows reads and writes to I/O space. -}; - -extern EFI_GUID gEfiSmmCpuIoProtocolGuid; - -#endif diff --git a/MdePkg/Include/Protocol/SmmCpuIo2.h b/MdePkg/Include/Protocol/SmmCpuIo2.h new file mode 100644 index 0000000000..580a8b6eac --- /dev/null +++ b/MdePkg/Include/Protocol/SmmCpuIo2.h @@ -0,0 +1,105 @@ +/** @file + SMM CPU I/O 2 protocol as defined in the PI 1.2 specification. + + This protocol provides CPU I/O and memory access within SMM. + + Copyright (c) 2009 - 2010, Intel Corporation + All rights reserved. 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _SMM_CPU_IO2_H_ +#define _SMM_CPU_IO2_H_ + +/// +/// Note: +/// To avoid name conflict between PI and Framework SMM spec, the following names defined +/// in PI 1.2 SMM spec are renamed. +/// +/// *EFI_SMM_CPU_IO* -> *EFI_SMM_CPU_IO2* +/// *EFI_SMM_IO_ACCESS* -> *EFI_SMM_IO_ACCESS2* +/// + +#define EFI_SMM_CPU_IO2_PROTOCOL_GUID \ + { \ + 0x3242A9D8, 0xCE70, 0x4AA0, { 0x95, 0x5D, 0x5E, 0x7B, 0x14, 0x0D, 0xE4, 0xD2 } \ + } + +typedef struct _EFI_SMM_CPU_IO2_PROTOCOL EFI_SMM_CPU_IO2_PROTOCOL; + +/// +/// Width of the SMM CPU I/O operations +/// +typedef enum { + SMM_IO_UINT8 = 0, + SMM_IO_UINT16 = 1, + SMM_IO_UINT32 = 2, + SMM_IO_UINT64 = 3 +} EFI_SMM_IO_WIDTH; + +/** + Provides the basic memory and I/O interfaces used toabstract accesses to devices. + + The I/O operations are carried out exactly as requested. The caller is + responsible for any alignment and I/O width issues that the bus, device, + platform, or type of I/O might require. + + @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O operations. + @param[in] Address The base address of the I/O operations. The caller is + responsible for aligning the Address if required. + @param[in] Count The number of I/O operations to perform. + @param[in,out] Buffer For read operations, the destination buffer to store + the results. For write operations, the source buffer + from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the device. + @retval EFI_UNSUPPORTED The Address is not valid for this system. + @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack + of resources. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_CPU_IO2)( + IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, + IN EFI_SMM_IO_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ); + +typedef struct { + /// + /// This service provides the various modalities of memory and I/O read. + /// + EFI_SMM_CPU_IO2 Read; + /// + /// This service provides the various modalities of memory and I/O write. + /// + EFI_SMM_CPU_IO2 Write; +} EFI_SMM_IO_ACCESS2; + +/// +/// SMM CPU I/O Protocol provides CPU I/O and memory access within SMM. +/// +struct _EFI_SMM_CPU_IO2_PROTOCOL { + /// + /// Allows reads and writes to memory-mapped I/O space. + /// + EFI_SMM_IO_ACCESS2 Mem; + /// + /// Allows reads and writes to I/O space. + /// + EFI_SMM_IO_ACCESS2 Io; +}; + +extern EFI_GUID gEfiSmmCpuIo2ProtocolGuid; + +#endif diff --git a/MdePkg/Library/SmmIoLibCpuIo/IoHighLevel.c b/MdePkg/Library/SmmIoLibCpuIo/IoHighLevel.c deleted file mode 100644 index 72ea425663..0000000000 --- a/MdePkg/Library/SmmIoLibCpuIo/IoHighLevel.c +++ /dev/null @@ -1,2275 +0,0 @@ -/** @file - High-level Io/Mmio functions. - - All assertions for bit field operations are handled bit field functions in the - Base Library. - - Copyright (c) 2009, Intel Corporation
- All rights reserved. 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 - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - Module Name: IoHighLevel.c - - The following IoLib instances share the same version of this file: - - BaseIoLibIntrinsic - DxeIoLibCpuIo - PeiIoLibCpuIo - SmmIoLibCpuIo -**/ - - -#include "SmmCpuIoLibInternal.h" - -/** - Reads an 8-bit I/O port, performs a bitwise OR, and writes the - result back to the 8-bit I/O port. - - Reads the 8-bit I/O port specified by Port, performs a bitwise OR - between the read result and the value specified by OrData, and writes the - result to the 8-bit I/O port specified by Port. The value written to the I/O - port is returned. 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 write. - @param OrData The value to OR with the read value from the I/O port. - - @return The value written back to the I/O port. - -**/ -UINT8 -EFIAPI -IoOr8 ( - IN UINTN Port, - IN UINT8 OrData - ) -{ - return IoWrite8 (Port, (UINT8) (IoRead8 (Port) | OrData)); -} - -/** - Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back - to the 8-bit I/O port. - - Reads the 8-bit I/O port specified by Port, performs a bitwise AND between - the read result and the value specified by AndData, and writes the result to - the 8-bit I/O port specified by Port. The value written to the I/O port is - returned. 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 write. - @param AndData The value to AND with the read value from the I/O port. - - @return The value written back to the I/O port. - -**/ -UINT8 -EFIAPI -IoAnd8 ( - IN UINTN Port, - IN UINT8 AndData - ) -{ - return IoWrite8 (Port, (UINT8) (IoRead8 (Port) & AndData)); -} - -/** - Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise - inclusive OR, and writes the result back to the 8-bit I/O port. - - Reads the 8-bit I/O port specified by Port, performs a bitwise AND between - the read result and the value specified by AndData, performs a bitwise OR - between the result of the AND operation and the value specified by OrData, - and writes the result to the 8-bit I/O port specified by Port. The value - written to the I/O port is returned. 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 write. - @param AndData The value to AND with the read value from the I/O port. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the I/O port. - -**/ -UINT8 -EFIAPI -IoAndThenOr8 ( - IN UINTN Port, - IN UINT8 AndData, - IN UINT8 OrData - ) -{ - return IoWrite8 (Port, (UINT8) ((IoRead8 (Port) & AndData) | OrData)); -} - -/** - Reads a bit field of an I/O register. - - Reads the bit field in an 8-bit I/O register. The bit field is specified by - the StartBit and the EndBit. The value of the bit field is returned. - - If 8-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to read. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..7. - - @return The value read. - -**/ -UINT8 -EFIAPI -IoBitFieldRead8 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit - ) -{ - return BitFieldRead8 (IoRead8 (Port), StartBit, EndBit); -} - -/** - Writes a bit field to an I/O register. - - Writes Value to the bit field of the I/O register. The bit field is specified - by the StartBit and the EndBit. All other bits in the destination I/O - register are preserved. The value written to the I/O port is returned. Extra - left bits in Value are stripped. - - If 8-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..7. - @param Value New value of the bit field. - - @return The value written back to the I/O port. - -**/ -UINT8 -EFIAPI -IoBitFieldWrite8 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT8 Value - ) -{ - return IoWrite8 ( - Port, - BitFieldWrite8 (IoRead8 (Port), StartBit, EndBit, Value) - ); -} - -/** - Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the - result back to the bit field in the 8-bit port. - - Reads the 8-bit I/O port specified by Port, performs a bitwise OR - between the read result and the value specified by OrData, and writes the - result to the 8-bit I/O port specified by Port. The value written to the I/O - port is returned. This function must guarantee that all I/O read and write - operations are serialized. Extra left bits in OrData are stripped. - - If 8-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..7. - @param OrData The value to OR with the read value from the I/O port. - - @return The value written back to the I/O port. - -**/ -UINT8 -EFIAPI -IoBitFieldOr8 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT8 OrData - ) -{ - return IoWrite8 ( - Port, - BitFieldOr8 (IoRead8 (Port), StartBit, EndBit, OrData) - ); -} - -/** - Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the - result back to the bit field in the 8-bit port. - - Reads the 8-bit I/O port specified by Port, performs a bitwise AND between - the read result and the value specified by AndData, and writes the result to - the 8-bit I/O port specified by Port. The value written to the I/O port is - returned. This function must guarantee that all I/O read and write operations - are serialized. Extra left bits in AndData are stripped. - - If 8-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..7. - @param AndData The value to AND with the read value from the I/O port. - - @return The value written back to the I/O port. - -**/ -UINT8 -EFIAPI -IoBitFieldAnd8 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT8 AndData - ) -{ - return IoWrite8 ( - Port, - BitFieldAnd8 (IoRead8 (Port), StartBit, EndBit, AndData) - ); -} - -/** - Reads a bit field in an 8-bit port, performs a bitwise AND followed by a - bitwise OR, and writes the result back to the bit field in the - 8-bit port. - - Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed - by a bitwise OR between the read result and the value specified by - AndData, and writes the result to the 8-bit I/O port specified by Port. The - value written to the I/O port is returned. This function must guarantee that - all I/O read and write operations are serialized. Extra left bits in both - AndData and OrData are stripped. - - If 8-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..7. - @param AndData The value to AND with the read value from the I/O port. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the I/O port. - -**/ -UINT8 -EFIAPI -IoBitFieldAndThenOr8 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT8 AndData, - IN UINT8 OrData - ) -{ - return IoWrite8 ( - Port, - BitFieldAndThenOr8 (IoRead8 (Port), StartBit, EndBit, AndData, OrData) - ); -} - -/** - Reads a 16-bit I/O port, performs a bitwise OR, and writes the - result back to the 16-bit I/O port. - - Reads the 16-bit I/O port specified by Port, performs a bitwise OR - between the read result and the value specified by OrData, and writes the - result to the 16-bit I/O port specified by Port. The value written to the I/O - port is returned. 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 write. - @param OrData The value to OR with the read value from the I/O port. - - @return The value written back to the I/O port. - -**/ -UINT16 -EFIAPI -IoOr16 ( - IN UINTN Port, - IN UINT16 OrData - ) -{ - return IoWrite16 (Port, (UINT16) (IoRead16 (Port) | OrData)); -} - -/** - Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back - to the 16-bit I/O port. - - Reads the 16-bit I/O port specified by Port, performs a bitwise AND between - the read result and the value specified by AndData, and writes the result to - the 16-bit I/O port specified by Port. The value written to the I/O port is - returned. 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 write. - @param AndData The value to AND with the read value from the I/O port. - - @return The value written back to the I/O port. - -**/ -UINT16 -EFIAPI -IoAnd16 ( - IN UINTN Port, - IN UINT16 AndData - ) -{ - return IoWrite16 (Port, (UINT16) (IoRead16 (Port) & AndData)); -} - -/** - Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise - inclusive OR, and writes the result back to the 16-bit I/O port. - - Reads the 16-bit I/O port specified by Port, performs a bitwise AND between - the read result and the value specified by AndData, performs a bitwise OR - between the result of the AND operation and the value specified by OrData, - and writes the result to the 16-bit I/O port specified by Port. The value - written to the I/O port is returned. 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 write. - @param AndData The value to AND with the read value from the I/O port. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the I/O port. - -**/ -UINT16 -EFIAPI -IoAndThenOr16 ( - IN UINTN Port, - IN UINT16 AndData, - IN UINT16 OrData - ) -{ - return IoWrite16 (Port, (UINT16) ((IoRead16 (Port) & AndData) | OrData)); -} - -/** - Reads a bit field of an I/O register. - - Reads the bit field in a 16-bit I/O register. The bit field is specified by - the StartBit and the EndBit. The value of the bit field is returned. - - If 16-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to read. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..15. - - @return The value read. - -**/ -UINT16 -EFIAPI -IoBitFieldRead16 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit - ) -{ - return BitFieldRead16 (IoRead16 (Port), StartBit, EndBit); -} - -/** - Writes a bit field to an I/O register. - - Writes Value to the bit field of the I/O register. The bit field is specified - by the StartBit and the EndBit. All other bits in the destination I/O - register are preserved. The value written to the I/O port is returned. Extra - left bits in Value are stripped. - - If 16-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..15. - @param Value New value of the bit field. - - @return The value written back to the I/O port. - -**/ -UINT16 -EFIAPI -IoBitFieldWrite16 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT16 Value - ) -{ - return IoWrite16 ( - Port, - BitFieldWrite16 (IoRead16 (Port), StartBit, EndBit, Value) - ); -} - -/** - Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the - result back to the bit field in the 16-bit port. - - Reads the 16-bit I/O port specified by Port, performs a bitwise OR - between the read result and the value specified by OrData, and writes the - result to the 16-bit I/O port specified by Port. The value written to the I/O - port is returned. This function must guarantee that all I/O read and write - operations are serialized. Extra left bits in OrData are stripped. - - If 16-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..15. - @param OrData The value to OR with the read value from the I/O port. - - @return The value written back to the I/O port. - -**/ -UINT16 -EFIAPI -IoBitFieldOr16 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT16 OrData - ) -{ - return IoWrite16 ( - Port, - BitFieldOr16 (IoRead16 (Port), StartBit, EndBit, OrData) - ); -} - -/** - Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the - result back to the bit field in the 16-bit port. - - Reads the 16-bit I/O port specified by Port, performs a bitwise AND between - the read result and the value specified by AndData, and writes the result to - the 16-bit I/O port specified by Port. The value written to the I/O port is - returned. This function must guarantee that all I/O read and write operations - are serialized. Extra left bits in AndData are stripped. - - If 16-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..15. - @param AndData The value to AND with the read value from the I/O port. - - @return The value written back to the I/O port. - -**/ -UINT16 -EFIAPI -IoBitFieldAnd16 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT16 AndData - ) -{ - return IoWrite16 ( - Port, - BitFieldAnd16 (IoRead16 (Port), StartBit, EndBit, AndData) - ); -} - -/** - Reads a bit field in a 16-bit port, performs a bitwise AND followed by a - bitwise OR, and writes the result back to the bit field in the - 16-bit port. - - Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed - by a bitwise OR between the read result and the value specified by - AndData, and writes the result to the 16-bit I/O port specified by Port. The - value written to the I/O port is returned. This function must guarantee that - all I/O read and write operations are serialized. Extra left bits in both - AndData and OrData are stripped. - - If 16-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..15. - @param AndData The value to AND with the read value from the I/O port. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the I/O port. - -**/ -UINT16 -EFIAPI -IoBitFieldAndThenOr16 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT16 AndData, - IN UINT16 OrData - ) -{ - return IoWrite16 ( - Port, - BitFieldAndThenOr16 (IoRead16 (Port), StartBit, EndBit, AndData, OrData) - ); -} - -/** - Reads a 32-bit I/O port, performs a bitwise OR, and writes the - result back to the 32-bit I/O port. - - Reads the 32-bit I/O port specified by Port, performs a bitwise OR - between the read result and the value specified by OrData, and writes the - result to the 32-bit I/O port specified by Port. The value written to the I/O - port is returned. 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 write. - @param OrData The value to OR with the read value from the I/O port. - - @return The value written back to the I/O port. - -**/ -UINT32 -EFIAPI -IoOr32 ( - IN UINTN Port, - IN UINT32 OrData - ) -{ - return IoWrite32 (Port, IoRead32 (Port) | OrData); -} - -/** - Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back - to the 32-bit I/O port. - - Reads the 32-bit I/O port specified by Port, performs a bitwise AND between - the read result and the value specified by AndData, and writes the result to - the 32-bit I/O port specified by Port. The value written to the I/O port is - returned. 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 write. - @param AndData The value to AND with the read value from the I/O port. - - @return The value written back to the I/O port. - -**/ -UINT32 -EFIAPI -IoAnd32 ( - IN UINTN Port, - IN UINT32 AndData - ) -{ - return IoWrite32 (Port, IoRead32 (Port) & AndData); -} - -/** - Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise - inclusive OR, and writes the result back to the 32-bit I/O port. - - Reads the 32-bit I/O port specified by Port, performs a bitwise AND between - the read result and the value specified by AndData, performs a bitwise OR - between the result of the AND operation and the value specified by OrData, - and writes the result to the 32-bit I/O port specified by Port. The value - written to the I/O port is returned. 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 write. - @param AndData The value to AND with the read value from the I/O port. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the I/O port. - -**/ -UINT32 -EFIAPI -IoAndThenOr32 ( - IN UINTN Port, - IN UINT32 AndData, - IN UINT32 OrData - ) -{ - return IoWrite32 (Port, (IoRead32 (Port) & AndData) | OrData); -} - -/** - Reads a bit field of an I/O register. - - Reads the bit field in a 32-bit I/O register. The bit field is specified by - the StartBit and the EndBit. The value of the bit field is returned. - - If 32-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to read. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - - @return The value read. - -**/ -UINT32 -EFIAPI -IoBitFieldRead32 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit - ) -{ - return BitFieldRead32 (IoRead32 (Port), StartBit, EndBit); -} - -/** - Writes a bit field to an I/O register. - - Writes Value to the bit field of the I/O register. The bit field is specified - by the StartBit and the EndBit. All other bits in the destination I/O - register are preserved. The value written to the I/O port is returned. Extra - left bits in Value are stripped. - - If 32-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - @param Value New value of the bit field. - - @return The value written back to the I/O port. - -**/ -UINT32 -EFIAPI -IoBitFieldWrite32 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 Value - ) -{ - return IoWrite32 ( - Port, - BitFieldWrite32 (IoRead32 (Port), StartBit, EndBit, Value) - ); -} - -/** - Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the - result back to the bit field in the 32-bit port. - - Reads the 32-bit I/O port specified by Port, performs a bitwise OR - between the read result and the value specified by OrData, and writes the - result to the 32-bit I/O port specified by Port. The value written to the I/O - port is returned. This function must guarantee that all I/O read and write - operations are serialized. Extra left bits in OrData are stripped. - - If 32-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - @param OrData The value to OR with the read value from the I/O port. - - @return The value written back to the I/O port. - -**/ -UINT32 -EFIAPI -IoBitFieldOr32 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 OrData - ) -{ - return IoWrite32 ( - Port, - BitFieldOr32 (IoRead32 (Port), StartBit, EndBit, OrData) - ); -} - -/** - Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the - result back to the bit field in the 32-bit port. - - Reads the 32-bit I/O port specified by Port, performs a bitwise AND between - the read result and the value specified by AndData, and writes the result to - the 32-bit I/O port specified by Port. The value written to the I/O port is - returned. This function must guarantee that all I/O read and write operations - are serialized. Extra left bits in AndData are stripped. - - If 32-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - @param AndData The value to AND with the read value from the I/O port. - - @return The value written back to the I/O port. - -**/ -UINT32 -EFIAPI -IoBitFieldAnd32 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 AndData - ) -{ - return IoWrite32 ( - Port, - BitFieldAnd32 (IoRead32 (Port), StartBit, EndBit, AndData) - ); -} - -/** - Reads a bit field in a 32-bit port, performs a bitwise AND followed by a - bitwise OR, and writes the result back to the bit field in the - 32-bit port. - - Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed - by a bitwise OR between the read result and the value specified by - AndData, and writes the result to the 32-bit I/O port specified by Port. The - value written to the I/O port is returned. This function must guarantee that - all I/O read and write operations are serialized. Extra left bits in both - AndData and OrData are stripped. - - If 32-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - @param AndData The value to AND with the read value from the I/O port. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the I/O port. - -**/ -UINT32 -EFIAPI -IoBitFieldAndThenOr32 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 AndData, - IN UINT32 OrData - ) -{ - return IoWrite32 ( - Port, - BitFieldAndThenOr32 (IoRead32 (Port), StartBit, EndBit, AndData, OrData) - ); -} - -/** - Reads a 64-bit I/O port, performs a bitwise OR, and writes the - result back to the 64-bit I/O port. - - Reads the 64-bit I/O port specified by Port, performs a bitwise OR - between the read result and the value specified by OrData, and writes the - result to the 64-bit I/O port specified by Port. The value written to the I/O - port is returned. This function must guarantee that all I/O read and write - operations are serialized. - - If 64-bit I/O port operations are not supported, then ASSERT(). - - @param Port The I/O port to write. - @param OrData The value to OR with the read value from the I/O port. - - @return The value written back to the I/O port. - -**/ -UINT64 -EFIAPI -IoOr64 ( - IN UINTN Port, - IN UINT64 OrData - ) -{ - return IoWrite64 (Port, IoRead64 (Port) | OrData); -} - -/** - Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back - to the 64-bit I/O port. - - Reads the 64-bit I/O port specified by Port, performs a bitwise AND between - the read result and the value specified by AndData, and writes the result to - the 64-bit I/O port specified by Port. The value written to the I/O port is - returned. This function must guarantee that all I/O read and write operations - are serialized. - - If 64-bit I/O port operations are not supported, then ASSERT(). - - @param Port The I/O port to write. - @param AndData The value to AND with the read value from the I/O port. - - @return The value written back to the I/O port. - -**/ -UINT64 -EFIAPI -IoAnd64 ( - IN UINTN Port, - IN UINT64 AndData - ) -{ - return IoWrite64 (Port, IoRead64 (Port) & AndData); -} - -/** - Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise - inclusive OR, and writes the result back to the 64-bit I/O port. - - Reads the 64-bit I/O port specified by Port, performs a bitwise AND between - the read result and the value specified by AndData, performs a bitwise OR - between the result of the AND operation and the value specified by OrData, - and writes the result to the 64-bit I/O port specified by Port. The value - written to the I/O port is returned. This function must guarantee that all - I/O read and write operations are serialized. - - If 64-bit I/O port operations are not supported, then ASSERT(). - - @param Port The I/O port to write. - @param AndData The value to AND with the read value from the I/O port. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the I/O port. - -**/ -UINT64 -EFIAPI -IoAndThenOr64 ( - IN UINTN Port, - IN UINT64 AndData, - IN UINT64 OrData - ) -{ - return IoWrite64 (Port, (IoRead64 (Port) & AndData) | OrData); -} - -/** - Reads a bit field of an I/O register. - - Reads the bit field in a 64-bit I/O register. The bit field is specified by - the StartBit and the EndBit. The value of the bit field is returned. - - If 64-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 63, then ASSERT(). - If EndBit is greater than 63, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to read. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..63. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..63. - - @return The value read. - -**/ -UINT64 -EFIAPI -IoBitFieldRead64 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit - ) -{ - return BitFieldRead64 (IoRead64 (Port), StartBit, EndBit); -} - -/** - Writes a bit field to an I/O register. - - Writes Value to the bit field of the I/O register. The bit field is specified - by the StartBit and the EndBit. All other bits in the destination I/O - register are preserved. The value written to the I/O port is returned. Extra - left bits in Value are stripped. - - If 64-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 63, then ASSERT(). - If EndBit is greater than 63, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..63. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..63. - @param Value New value of the bit field. - - @return The value written back to the I/O port. - -**/ -UINT64 -EFIAPI -IoBitFieldWrite64 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT64 Value - ) -{ - return IoWrite64 ( - Port, - BitFieldWrite64 (IoRead64 (Port), StartBit, EndBit, Value) - ); -} - -/** - Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the - result back to the bit field in the 64-bit port. - - Reads the 64-bit I/O port specified by Port, performs a bitwise OR - between the read result and the value specified by OrData, and writes the - result to the 64-bit I/O port specified by Port. The value written to the I/O - port is returned. This function must guarantee that all I/O read and write - operations are serialized. Extra left bits in OrData are stripped. - - If 64-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 63, then ASSERT(). - If EndBit is greater than 63, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..63. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..63. - @param OrData The value to OR with the read value from the I/O port. - - @return The value written back to the I/O port. - -**/ -UINT64 -EFIAPI -IoBitFieldOr64 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT64 OrData - ) -{ - return IoWrite64 ( - Port, - BitFieldOr64 (IoRead64 (Port), StartBit, EndBit, OrData) - ); -} - -/** - Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the - result back to the bit field in the 64-bit port. - - Reads the 64-bit I/O port specified by Port, performs a bitwise AND between - the read result and the value specified by AndData, and writes the result to - the 64-bit I/O port specified by Port. The value written to the I/O port is - returned. This function must guarantee that all I/O read and write operations - are serialized. Extra left bits in AndData are stripped. - - If 64-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 63, then ASSERT(). - If EndBit is greater than 63, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..63. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..63. - @param AndData The value to AND with the read value from the I/O port. - - @return The value written back to the I/O port. - -**/ -UINT64 -EFIAPI -IoBitFieldAnd64 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT64 AndData - ) -{ - return IoWrite64 ( - Port, - BitFieldAnd64 (IoRead64 (Port), StartBit, EndBit, AndData) - ); -} - -/** - Reads a bit field in a 64-bit port, performs a bitwise AND followed by a - bitwise OR, and writes the result back to the bit field in the - 64-bit port. - - Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed - by a bitwise OR between the read result and the value specified by - AndData, and writes the result to the 64-bit I/O port specified by Port. The - value written to the I/O port is returned. This function must guarantee that - all I/O read and write operations are serialized. Extra left bits in both - AndData and OrData are stripped. - - If 64-bit I/O port operations are not supported, then ASSERT(). - If StartBit is greater than 63, then ASSERT(). - If EndBit is greater than 63, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Port The I/O port to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..63. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..63. - @param AndData The value to AND with the read value from the I/O port. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the I/O port. - -**/ -UINT64 -EFIAPI -IoBitFieldAndThenOr64 ( - IN UINTN Port, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT64 AndData, - IN UINT64 OrData - ) -{ - return IoWrite64 ( - Port, - BitFieldAndThenOr64 (IoRead64 (Port), StartBit, EndBit, AndData, OrData) - ); -} - -/** - Reads an 8-bit MMIO register, performs a bitwise OR, and writes the - result back to the 8-bit MMIO register. - - Reads the 8-bit MMIO register specified by Address, performs a bitwise - inclusive OR between the read result and the value specified by OrData, and - writes the result to the 8-bit MMIO register specified by Address. The value - written to the MMIO register is returned. This function must guarantee that - all MMIO read and write operations are serialized. - - If 8-bit MMIO register operations are not supported, then ASSERT(). - - @param Address The MMIO register to write. - @param OrData The value to OR with the read value from the MMIO register. - - @return The value written back to the MMIO register. - -**/ -UINT8 -EFIAPI -MmioOr8 ( - IN UINTN Address, - IN UINT8 OrData - ) -{ - return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) | OrData)); -} - -/** - Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result - back to the 8-bit MMIO register. - - Reads the 8-bit MMIO register specified by Address, performs a bitwise AND - between the read result and the value specified by AndData, and writes the - result to the 8-bit MMIO register specified by Address. The value written to - the MMIO register is returned. This function must guarantee that all MMIO - read and write operations are serialized. - - If 8-bit MMIO register operations are not supported, then ASSERT(). - - @param Address The MMIO register to write. - @param AndData The value to AND with the read value from the MMIO register. - - @return The value written back to the MMIO register. - -**/ -UINT8 -EFIAPI -MmioAnd8 ( - IN UINTN Address, - IN UINT8 AndData - ) -{ - return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) & AndData)); -} - -/** - Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise - inclusive OR, and writes the result back to the 8-bit MMIO register. - - Reads the 8-bit MMIO register specified by Address, performs a bitwise AND - between the read result and the value specified by AndData, performs a - bitwise OR between the result of the AND operation and the value specified by - OrData, and writes the result to the 8-bit MMIO register specified by - Address. The value written to the MMIO register is returned. This function - must guarantee that all MMIO read and write operations are serialized. - - If 8-bit MMIO register operations are not supported, then ASSERT(). - - - @param Address The MMIO register to write. - @param AndData The value to AND with the read value from the MMIO register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the MMIO register. - -**/ -UINT8 -EFIAPI -MmioAndThenOr8 ( - IN UINTN Address, - IN UINT8 AndData, - IN UINT8 OrData - ) -{ - return MmioWrite8 (Address, (UINT8) ((MmioRead8 (Address) & AndData) | OrData)); -} - -/** - Reads a bit field of a MMIO register. - - Reads the bit field in an 8-bit MMIO register. The bit field is specified by - the StartBit and the EndBit. The value of the bit field is returned. - - If 8-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to read. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..7. - - @return The value read. - -**/ -UINT8 -EFIAPI -MmioBitFieldRead8 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit - ) -{ - return BitFieldRead8 (MmioRead8 (Address), StartBit, EndBit); -} - -/** - Writes a bit field to a MMIO register. - - Writes Value to the bit field of the MMIO register. The bit field is - specified by the StartBit and the EndBit. All other bits in the destination - MMIO register are preserved. The new value of the 8-bit register is returned. - - If 8-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..7. - @param Value New value of the bit field. - - @return The value written back to the MMIO register. - -**/ -UINT8 -EFIAPI -MmioBitFieldWrite8 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT8 Value - ) -{ - return MmioWrite8 ( - Address, - BitFieldWrite8 (MmioRead8 (Address), StartBit, EndBit, Value) - ); -} - -/** - Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and - writes the result back to the bit field in the 8-bit MMIO register. - - Reads the 8-bit MMIO register specified by Address, performs a bitwise - inclusive OR between the read result and the value specified by OrData, and - writes the result to the 8-bit MMIO register specified by Address. The value - written to the MMIO register is returned. This function must guarantee that - all MMIO read and write operations are serialized. Extra left bits in OrData - are stripped. - - If 8-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..7. - @param OrData The value to OR with read value from the MMIO register. - - @return The value written back to the MMIO register. - -**/ -UINT8 -EFIAPI -MmioBitFieldOr8 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT8 OrData - ) -{ - return MmioWrite8 ( - Address, - BitFieldOr8 (MmioRead8 (Address), StartBit, EndBit, OrData) - ); -} - -/** - Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and - writes the result back to the bit field in the 8-bit MMIO register. - - Reads the 8-bit MMIO register specified by Address, performs a bitwise AND - between the read result and the value specified by AndData, and writes the - result to the 8-bit MMIO register specified by Address. The value written to - the MMIO register is returned. This function must guarantee that all MMIO - read and write operations are serialized. Extra left bits in AndData are - stripped. - - If 8-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..7. - @param AndData The value to AND with read value from the MMIO register. - - @return The value written back to the MMIO register. - -**/ -UINT8 -EFIAPI -MmioBitFieldAnd8 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT8 AndData - ) -{ - return MmioWrite8 ( - Address, - BitFieldAnd8 (MmioRead8 (Address), StartBit, EndBit, AndData) - ); -} - -/** - Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed - by a bitwise OR, and writes the result back to the bit field in the - 8-bit MMIO register. - - Reads the 8-bit MMIO register specified by Address, performs a bitwise AND - followed by a bitwise OR between the read result and the value - specified by AndData, and writes the result to the 8-bit MMIO register - specified by Address. The value written to the MMIO register is returned. - This function must guarantee that all MMIO read and write operations are - serialized. Extra left bits in both AndData and OrData are stripped. - - If 8-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..7. - @param AndData The value to AND with read value from the MMIO register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the MMIO register. - -**/ -UINT8 -EFIAPI -MmioBitFieldAndThenOr8 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT8 AndData, - IN UINT8 OrData - ) -{ - return MmioWrite8 ( - Address, - BitFieldAndThenOr8 (MmioRead8 (Address), StartBit, EndBit, AndData, OrData) - ); -} - -/** - Reads a 16-bit MMIO register, performs a bitwise OR, and writes the - result back to the 16-bit MMIO register. - - Reads the 16-bit MMIO register specified by Address, performs a bitwise - inclusive OR between the read result and the value specified by OrData, and - writes the result to the 16-bit MMIO register specified by Address. The value - written to the MMIO register is returned. This function must guarantee that - all MMIO read and write operations are serialized. - - If 16-bit MMIO register operations are not supported, then ASSERT(). - - @param Address The MMIO register to write. - @param OrData The value to OR with the read value from the MMIO register. - - @return The value written back to the MMIO register. - -**/ -UINT16 -EFIAPI -MmioOr16 ( - IN UINTN Address, - IN UINT16 OrData - ) -{ - return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) | OrData)); -} - -/** - Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result - back to the 16-bit MMIO register. - - Reads the 16-bit MMIO register specified by Address, performs a bitwise AND - between the read result and the value specified by AndData, and writes the - result to the 16-bit MMIO register specified by Address. The value written to - the MMIO register is returned. This function must guarantee that all MMIO - read and write operations are serialized. - - If 16-bit MMIO register operations are not supported, then ASSERT(). - - @param Address The MMIO register to write. - @param AndData The value to AND with the read value from the MMIO register. - - @return The value written back to the MMIO register. - -**/ -UINT16 -EFIAPI -MmioAnd16 ( - IN UINTN Address, - IN UINT16 AndData - ) -{ - return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) & AndData)); -} - -/** - Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise - inclusive OR, and writes the result back to the 16-bit MMIO register. - - Reads the 16-bit MMIO register specified by Address, performs a bitwise AND - between the read result and the value specified by AndData, performs a - bitwise OR between the result of the AND operation and the value specified by - OrData, and writes the result to the 16-bit MMIO register specified by - Address. The value written to the MMIO register is returned. This function - must guarantee that all MMIO read and write operations are serialized. - - If 16-bit MMIO register operations are not supported, then ASSERT(). - - - @param Address The MMIO register to write. - @param AndData The value to AND with the read value from the MMIO register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the MMIO register. - -**/ -UINT16 -EFIAPI -MmioAndThenOr16 ( - IN UINTN Address, - IN UINT16 AndData, - IN UINT16 OrData - ) -{ - return MmioWrite16 (Address, (UINT16) ((MmioRead16 (Address) & AndData) | OrData)); -} - -/** - Reads a bit field of a MMIO register. - - Reads the bit field in a 16-bit MMIO register. The bit field is specified by - the StartBit and the EndBit. The value of the bit field is returned. - - If 16-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to read. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..15. - - @return The value read. - -**/ -UINT16 -EFIAPI -MmioBitFieldRead16 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit - ) -{ - return BitFieldRead16 (MmioRead16 (Address), StartBit, EndBit); -} - -/** - Writes a bit field to a MMIO register. - - Writes Value to the bit field of the MMIO register. The bit field is - specified by the StartBit and the EndBit. All other bits in the destination - MMIO register are preserved. The new value of the 16-bit register is returned. - - If 16-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..15. - @param Value New value of the bit field. - - @return The value written back to the MMIO register. - -**/ -UINT16 -EFIAPI -MmioBitFieldWrite16 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT16 Value - ) -{ - return MmioWrite16 ( - Address, - BitFieldWrite16 (MmioRead16 (Address), StartBit, EndBit, Value) - ); -} - -/** - Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and - writes the result back to the bit field in the 16-bit MMIO register. - - Reads the 16-bit MMIO register specified by Address, performs a bitwise - inclusive OR between the read result and the value specified by OrData, and - writes the result to the 16-bit MMIO register specified by Address. The value - written to the MMIO register is returned. This function must guarantee that - all MMIO read and write operations are serialized. Extra left bits in OrData - are stripped. - - If 16-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..15. - @param OrData The value to OR with read value from the MMIO register. - - @return The value written back to the MMIO register. - -**/ -UINT16 -EFIAPI -MmioBitFieldOr16 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT16 OrData - ) -{ - return MmioWrite16 ( - Address, - BitFieldOr16 (MmioRead16 (Address), StartBit, EndBit, OrData) - ); -} - -/** - Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and - writes the result back to the bit field in the 16-bit MMIO register. - - Reads the 16-bit MMIO register specified by Address, performs a bitwise AND - between the read result and the value specified by AndData, and writes the - result to the 16-bit MMIO register specified by Address. The value written to - the MMIO register is returned. This function must guarantee that all MMIO - read and write operations are serialized. Extra left bits in AndData are - stripped. - - If 16-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..15. - @param AndData The value to AND with read value from the MMIO register. - - @return The value written back to the MMIO register. - -**/ -UINT16 -EFIAPI -MmioBitFieldAnd16 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT16 AndData - ) -{ - return MmioWrite16 ( - Address, - BitFieldAnd16 (MmioRead16 (Address), StartBit, EndBit, AndData) - ); -} - -/** - Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed - by a bitwise OR, and writes the result back to the bit field in the - 16-bit MMIO register. - - Reads the 16-bit MMIO register specified by Address, performs a bitwise AND - followed by a bitwise OR between the read result and the value - specified by AndData, and writes the result to the 16-bit MMIO register - specified by Address. The value written to the MMIO register is returned. - This function must guarantee that all MMIO read and write operations are - serialized. Extra left bits in both AndData and OrData are stripped. - - If 16-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..15. - @param AndData The value to AND with read value from the MMIO register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the MMIO register. - -**/ -UINT16 -EFIAPI -MmioBitFieldAndThenOr16 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT16 AndData, - IN UINT16 OrData - ) -{ - return MmioWrite16 ( - Address, - BitFieldAndThenOr16 (MmioRead16 (Address), StartBit, EndBit, AndData, OrData) - ); -} - -/** - Reads a 32-bit MMIO register, performs a bitwise OR, and writes the - result back to the 32-bit MMIO register. - - Reads the 32-bit MMIO register specified by Address, performs a bitwise - inclusive OR between the read result and the value specified by OrData, and - writes the result to the 32-bit MMIO register specified by Address. The value - written to the MMIO register is returned. This function must guarantee that - all MMIO read and write operations are serialized. - - If 32-bit MMIO register operations are not supported, then ASSERT(). - - @param Address The MMIO register to write. - @param OrData The value to OR with the read value from the MMIO register. - - @return The value written back to the MMIO register. - -**/ -UINT32 -EFIAPI -MmioOr32 ( - IN UINTN Address, - IN UINT32 OrData - ) -{ - return MmioWrite32 (Address, MmioRead32 (Address) | OrData); -} - -/** - Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result - back to the 32-bit MMIO register. - - Reads the 32-bit MMIO register specified by Address, performs a bitwise AND - between the read result and the value specified by AndData, and writes the - result to the 32-bit MMIO register specified by Address. The value written to - the MMIO register is returned. This function must guarantee that all MMIO - read and write operations are serialized. - - If 32-bit MMIO register operations are not supported, then ASSERT(). - - @param Address The MMIO register to write. - @param AndData The value to AND with the read value from the MMIO register. - - @return The value written back to the MMIO register. - -**/ -UINT32 -EFIAPI -MmioAnd32 ( - IN UINTN Address, - IN UINT32 AndData - ) -{ - return MmioWrite32 (Address, MmioRead32 (Address) & AndData); -} - -/** - Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise - inclusive OR, and writes the result back to the 32-bit MMIO register. - - Reads the 32-bit MMIO register specified by Address, performs a bitwise AND - between the read result and the value specified by AndData, performs a - bitwise OR between the result of the AND operation and the value specified by - OrData, and writes the result to the 32-bit MMIO register specified by - Address. The value written to the MMIO register is returned. This function - must guarantee that all MMIO read and write operations are serialized. - - If 32-bit MMIO register operations are not supported, then ASSERT(). - - - @param Address The MMIO register to write. - @param AndData The value to AND with the read value from the MMIO register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the MMIO register. - -**/ -UINT32 -EFIAPI -MmioAndThenOr32 ( - IN UINTN Address, - IN UINT32 AndData, - IN UINT32 OrData - ) -{ - return MmioWrite32 (Address, (MmioRead32 (Address) & AndData) | OrData); -} - -/** - Reads a bit field of a MMIO register. - - Reads the bit field in a 32-bit MMIO register. The bit field is specified by - the StartBit and the EndBit. The value of the bit field is returned. - - If 32-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to read. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - - @return The value read. - -**/ -UINT32 -EFIAPI -MmioBitFieldRead32 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit - ) -{ - return BitFieldRead32 (MmioRead32 (Address), StartBit, EndBit); -} - -/** - Writes a bit field to a MMIO register. - - Writes Value to the bit field of the MMIO register. The bit field is - specified by the StartBit and the EndBit. All other bits in the destination - MMIO register are preserved. The new value of the 32-bit register is returned. - - If 32-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - @param Value New value of the bit field. - - @return The value written back to the MMIO register. - -**/ -UINT32 -EFIAPI -MmioBitFieldWrite32 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 Value - ) -{ - return MmioWrite32 ( - Address, - BitFieldWrite32 (MmioRead32 (Address), StartBit, EndBit, Value) - ); -} - -/** - Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and - writes the result back to the bit field in the 32-bit MMIO register. - - Reads the 32-bit MMIO register specified by Address, performs a bitwise - inclusive OR between the read result and the value specified by OrData, and - writes the result to the 32-bit MMIO register specified by Address. The value - written to the MMIO register is returned. This function must guarantee that - all MMIO read and write operations are serialized. Extra left bits in OrData - are stripped. - - If 32-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - @param OrData The value to OR with read value from the MMIO register. - - @return The value written back to the MMIO register. - -**/ -UINT32 -EFIAPI -MmioBitFieldOr32 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 OrData - ) -{ - return MmioWrite32 ( - Address, - BitFieldOr32 (MmioRead32 (Address), StartBit, EndBit, OrData) - ); -} - -/** - Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and - writes the result back to the bit field in the 32-bit MMIO register. - - Reads the 32-bit MMIO register specified by Address, performs a bitwise AND - between the read result and the value specified by AndData, and writes the - result to the 32-bit MMIO register specified by Address. The value written to - the MMIO register is returned. This function must guarantee that all MMIO - read and write operations are serialized. Extra left bits in AndData are - stripped. - - If 32-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - @param AndData The value to AND with read value from the MMIO register. - - @return The value written back to the MMIO register. - -**/ -UINT32 -EFIAPI -MmioBitFieldAnd32 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 AndData - ) -{ - return MmioWrite32 ( - Address, - BitFieldAnd32 (MmioRead32 (Address), StartBit, EndBit, AndData) - ); -} - -/** - Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed - by a bitwise OR, and writes the result back to the bit field in the - 32-bit MMIO register. - - Reads the 32-bit MMIO register specified by Address, performs a bitwise AND - followed by a bitwise OR between the read result and the value - specified by AndData, and writes the result to the 32-bit MMIO register - specified by Address. The value written to the MMIO register is returned. - This function must guarantee that all MMIO read and write operations are - serialized. Extra left bits in both AndData and OrData are stripped. - - If 32-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - @param AndData The value to AND with read value from the MMIO register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the MMIO register. - -**/ -UINT32 -EFIAPI -MmioBitFieldAndThenOr32 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 AndData, - IN UINT32 OrData - ) -{ - return MmioWrite32 ( - Address, - BitFieldAndThenOr32 (MmioRead32 (Address), StartBit, EndBit, AndData, OrData) - ); -} - -/** - Reads a 64-bit MMIO register, performs a bitwise OR, and writes the - result back to the 64-bit MMIO register. - - Reads the 64-bit MMIO register specified by Address, performs a bitwise - inclusive OR between the read result and the value specified by OrData, and - writes the result to the 64-bit MMIO register specified by Address. The value - written to the MMIO register is returned. This function must guarantee that - all MMIO read and write operations are serialized. - - If 64-bit MMIO register operations are not supported, then ASSERT(). - - @param Address The MMIO register to write. - @param OrData The value to OR with the read value from the MMIO register. - - @return The value written back to the MMIO register. - -**/ -UINT64 -EFIAPI -MmioOr64 ( - IN UINTN Address, - IN UINT64 OrData - ) -{ - return MmioWrite64 (Address, MmioRead64 (Address) | OrData); -} - -/** - Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result - back to the 64-bit MMIO register. - - Reads the 64-bit MMIO register specified by Address, performs a bitwise AND - between the read result and the value specified by AndData, and writes the - result to the 64-bit MMIO register specified by Address. The value written to - the MMIO register is returned. This function must guarantee that all MMIO - read and write operations are serialized. - - If 64-bit MMIO register operations are not supported, then ASSERT(). - - @param Address The MMIO register to write. - @param AndData The value to AND with the read value from the MMIO register. - - @return The value written back to the MMIO register. - -**/ -UINT64 -EFIAPI -MmioAnd64 ( - IN UINTN Address, - IN UINT64 AndData - ) -{ - return MmioWrite64 (Address, MmioRead64 (Address) & AndData); -} - -/** - Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise - inclusive OR, and writes the result back to the 64-bit MMIO register. - - Reads the 64-bit MMIO register specified by Address, performs a bitwise AND - between the read result and the value specified by AndData, performs a - bitwise OR between the result of the AND operation and the value specified by - OrData, and writes the result to the 64-bit MMIO register specified by - Address. The value written to the MMIO register is returned. This function - must guarantee that all MMIO read and write operations are serialized. - - If 64-bit MMIO register operations are not supported, then ASSERT(). - - - @param Address The MMIO register to write. - @param AndData The value to AND with the read value from the MMIO register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the MMIO register. - -**/ -UINT64 -EFIAPI -MmioAndThenOr64 ( - IN UINTN Address, - IN UINT64 AndData, - IN UINT64 OrData - ) -{ - return MmioWrite64 (Address, (MmioRead64 (Address) & AndData) | OrData); -} - -/** - Reads a bit field of a MMIO register. - - Reads the bit field in a 64-bit MMIO register. The bit field is specified by - the StartBit and the EndBit. The value of the bit field is returned. - - If 64-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 63, then ASSERT(). - If EndBit is greater than 63, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to read. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..63. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..63. - - @return The value read. - -**/ -UINT64 -EFIAPI -MmioBitFieldRead64 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit - ) -{ - return BitFieldRead64 (MmioRead64 (Address), StartBit, EndBit); -} - -/** - Writes a bit field to a MMIO register. - - Writes Value to the bit field of the MMIO register. The bit field is - specified by the StartBit and the EndBit. All other bits in the destination - MMIO register are preserved. The new value of the 64-bit register is returned. - - If 64-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 63, then ASSERT(). - If EndBit is greater than 63, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..63. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..63. - @param Value New value of the bit field. - - @return The value written back to the MMIO register. - -**/ -UINT64 -EFIAPI -MmioBitFieldWrite64 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT64 Value - ) -{ - return MmioWrite64 ( - Address, - BitFieldWrite64 (MmioRead64 (Address), StartBit, EndBit, Value) - ); -} - -/** - Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and - writes the result back to the bit field in the 64-bit MMIO register. - - Reads the 64-bit MMIO register specified by Address, performs a bitwise - inclusive OR between the read result and the value specified by OrData, and - writes the result to the 64-bit MMIO register specified by Address. The value - written to the MMIO register is returned. This function must guarantee that - all MMIO read and write operations are serialized. Extra left bits in OrData - are stripped. - - If 64-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 63, then ASSERT(). - If EndBit is greater than 63, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..63. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..63. - @param OrData The value to OR with read value from the MMIO register. - - @return The value written back to the MMIO register. - -**/ -UINT64 -EFIAPI -MmioBitFieldOr64 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT64 OrData - ) -{ - return MmioWrite64 ( - Address, - BitFieldOr64 (MmioRead64 (Address), StartBit, EndBit, OrData) - ); -} - -/** - Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and - writes the result back to the bit field in the 64-bit MMIO register. - - Reads the 64-bit MMIO register specified by Address, performs a bitwise AND - between the read result and the value specified by AndData, and writes the - result to the 64-bit MMIO register specified by Address. The value written to - the MMIO register is returned. This function must guarantee that all MMIO - read and write operations are serialized. Extra left bits in AndData are - stripped. - - If 64-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 63, then ASSERT(). - If EndBit is greater than 63, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..63. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..63. - @param AndData The value to AND with read value from the MMIO register. - - @return The value written back to the MMIO register. - -**/ -UINT64 -EFIAPI -MmioBitFieldAnd64 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT64 AndData - ) -{ - return MmioWrite64 ( - Address, - BitFieldAnd64 (MmioRead64 (Address), StartBit, EndBit, AndData) - ); -} - -/** - Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed - by a bitwise OR, and writes the result back to the bit field in the - 64-bit MMIO register. - - Reads the 64-bit MMIO register specified by Address, performs a bitwise AND - followed by a bitwise OR between the read result and the value - specified by AndData, and writes the result to the 64-bit MMIO register - specified by Address. The value written to the MMIO register is returned. - This function must guarantee that all MMIO read and write operations are - serialized. Extra left bits in both AndData and OrData are stripped. - - If 64-bit MMIO register operations are not supported, then ASSERT(). - If StartBit is greater than 63, then ASSERT(). - If EndBit is greater than 63, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address MMIO register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..63. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..63. - @param AndData The value to AND with read value from the MMIO register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the MMIO register. - -**/ -UINT64 -EFIAPI -MmioBitFieldAndThenOr64 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT64 AndData, - IN UINT64 OrData - ) -{ - return MmioWrite64 ( - Address, - BitFieldAndThenOr64 (MmioRead64 (Address), StartBit, EndBit, AndData, OrData) - ); -} diff --git a/MdePkg/Library/SmmIoLibCpuIo/IoLib.c b/MdePkg/Library/SmmIoLibCpuIo/IoLib.c deleted file mode 100644 index 4b74e9c222..0000000000 --- a/MdePkg/Library/SmmIoLibCpuIo/IoLib.c +++ /dev/null @@ -1,642 +0,0 @@ -/** @file - I/O Library. - The implementation of I/O operation for this library instance - are based on EFI_CPU_IO_PROTOCOL. - - Copyright (c) 2009, Intel Corporation
- All rights reserved. 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 - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - Module Name: IoLib.c - -**/ - - -#include "SmmCpuIoLibInternal.h" - -// -// Globle varible to cache pointer to CpuIo protocol. -// -EFI_SMM_CPU_IO_PROTOCOL *mCpuIo = NULL; -EFI_SMM_PCI_ROOT_BRIDGE_IO_PROTOCOL *mPciRootBridgeIo = NULL; - -/** - The constructor function caches the pointer to CpuIo protocol. - - The constructor function locates CpuIo protocol from protocol database. - It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. - - @param ImageHandle The firmware allocated handle for the EFI image. - @param SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. - -**/ -EFI_STATUS -EFIAPI -IoLibConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - Status = gSmst->SmmLocateProtocol (&gEfiSmmPciRootBridgeIoProtocolGuid, NULL, (VOID **) &mPciRootBridgeIo); - if (EFI_ERROR (Status)) { - Status = gSmst->SmmLocateProtocol (&gEfiSmmCpuIoProtocolGuid, NULL, (VOID **) &mCpuIo); - } - ASSERT_EFI_ERROR (Status); - - return Status; -} - -/** - Reads registers in the EFI CPU I/O space. - - Reads the I/O port specified by Port with registers width specified by Width. - The read value is returned. If such operations are not supported, then ASSERT(). - This function must guarantee that all I/O read and write operations are serialized. - - @param Port The base address of the I/O operation. - The caller is responsible for aligning the Address if required. - @param Width The width of the I/O operation. - - @return Data read from registers in the EFI CPU I/O space. - -**/ -UINT64 -EFIAPI -IoReadWorker ( - IN UINTN Port, - IN EFI_SMM_IO_WIDTH Width - ) -{ - EFI_STATUS Status; - UINT64 Data; - - if (mPciRootBridgeIo != NULL) { - Status = mPciRootBridgeIo->Io.Read (mPciRootBridgeIo, (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width, Port, 1, &Data); - } else { - Status = mCpuIo->Io.Read (mCpuIo, Width, Port, 1, &Data); - } - ASSERT_EFI_ERROR (Status); - - return Data; -} - -/** - Writes registers in the EFI CPU I/O space. - - Writes the I/O port specified by Port with registers width and value specified by Width - and Data respectively. Data is returned. If such operations are not supported, then ASSERT(). - This function must guarantee that all I/O read and write operations are serialized. - - @param Port The base address of the I/O operation. - The caller is responsible for aligning the Address if required. - @param Width The width of the I/O operation. - @param Data The value to write to the I/O port. - - @return The paramter of Data. - -**/ -UINT64 -EFIAPI -IoWriteWorker ( - IN UINTN Port, - IN EFI_SMM_IO_WIDTH Width, - IN UINT64 Data - ) -{ - EFI_STATUS Status; - - if (mPciRootBridgeIo != NULL) { - Status = mPciRootBridgeIo->Io.Write (mPciRootBridgeIo, (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width, Port, 1, &Data); - } else { - Status = mCpuIo->Io.Write (mCpuIo, Width, Port, 1, &Data); - } - ASSERT_EFI_ERROR (Status); - - return Data; -} - -/** - Reads memory-mapped registers in the EFI system memory space. - - Reads the MMIO registers specified by Address with registers width specified by Width. - The read value is returned. If such operations are not supported, then ASSERT(). - This function must guarantee that all MMIO read and write operations are serialized. - - @param Address The MMIO register to read. - The caller is responsible for aligning the Address if required. - @param Width The width of the I/O operation. - - @return Data read from registers in the EFI system memory space. - -**/ -UINT64 -EFIAPI -MmioReadWorker ( - IN UINTN Address, - IN EFI_SMM_IO_WIDTH Width - ) -{ - EFI_STATUS Status; - UINT64 Data; - - if (mPciRootBridgeIo != NULL) { - Status = mPciRootBridgeIo->Mem.Read (mPciRootBridgeIo, (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width, Address, 1, &Data); - } else { - Status = mCpuIo->Mem.Read (mCpuIo, Width, Address, 1, &Data); - } - ASSERT_EFI_ERROR (Status); - - return Data; -} - -/** - Writes memory-mapped registers in the EFI system memory space. - - Writes the MMIO registers specified by Address with registers width and value specified by Width - and Data respectively. Data is returned. If such operations are not supported, then ASSERT(). - This function must guarantee that all MMIO read and write operations are serialized. - - @param Address The MMIO register to read. - The caller is responsible for aligning the Address if required. - @param Width The width of the I/O operation. - @param Data The value to write to the I/O port. - - @return Data read from registers in the EFI system memory space. - -**/ -UINT64 -EFIAPI -MmioWriteWorker ( - IN UINTN Address, - IN EFI_SMM_IO_WIDTH Width, - IN UINT64 Data - ) -{ - EFI_STATUS Status; - - if (mPciRootBridgeIo != NULL) { - Status = mPciRootBridgeIo->Mem.Write (mPciRootBridgeIo, (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width, Address, 1, &Data); - } else { - Status = mCpuIo->Mem.Write (mCpuIo, Width, Address, 1, &Data); - } - ASSERT_EFI_ERROR (Status); - - return Data; -} - -/** - Reads an 8-bit I/O port. - - Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned. - 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. - - @return The value read. - -**/ -UINT8 -EFIAPI -IoRead8 ( - IN UINTN Port - ) -{ - return (UINT8)IoReadWorker (Port, SMM_IO_UINT8); -} - -/** - Writes an 8-bit I/O port. - - Writes the 8-bit I/O port specified by Port with the value specified by Value - and returns Value. 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 write. - @param Value The value to write to the I/O port. - - @return The value written the I/O port. - -**/ -UINT8 -EFIAPI -IoWrite8 ( - IN UINTN Port, - IN UINT8 Value - ) -{ - return (UINT8)IoWriteWorker (Port, SMM_IO_UINT8, Value); -} - -/** - Reads a 16-bit I/O port. - - Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned. - This function must guarantee that all I/O read and write operations are - serialized. - - If Port is not aligned on a 16-bit boundary, then ASSERT(). - - If 16-bit I/O port operations are not supported, then ASSERT(). - - @param Port The I/O port to read. - - @return The value read. - -**/ -UINT16 -EFIAPI -IoRead16 ( - IN UINTN Port - ) -{ - // - // Make sure Port is aligned on a 16-bit boundary. - // - ASSERT ((Port & 1) == 0); - return (UINT16)IoReadWorker (Port, SMM_IO_UINT16); -} - -/** - Writes a 16-bit I/O port. - - Writes the 16-bit I/O port specified by Port with the value specified by Value - and returns Value. This function must guarantee that all I/O read and write - operations are serialized. - - If Port is not aligned on a 16-bit boundary, then ASSERT(). - - If 16-bit I/O port operations are not supported, then ASSERT(). - - @param Port The I/O port to write. - @param Value The value to write to the I/O port. - - @return The value written the I/O port. - -**/ -UINT16 -EFIAPI -IoWrite16 ( - IN UINTN Port, - IN UINT16 Value - ) -{ - // - // Make sure Port is aligned on a 16-bit boundary. - // - ASSERT ((Port & 1) == 0); - return (UINT16)IoWriteWorker (Port, SMM_IO_UINT16, Value); -} - -/** - Reads a 32-bit I/O port. - - Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned. - This function must guarantee that all I/O read and write operations are - serialized. - - If Port is not aligned on a 32-bit boundary, then ASSERT(). - - If 32-bit I/O port operations are not supported, then ASSERT(). - - @param Port The I/O port to read. - - @return The value read. - -**/ -UINT32 -EFIAPI -IoRead32 ( - IN UINTN Port - ) -{ - // - // Make sure Port is aligned on a 32-bit boundary. - // - ASSERT ((Port & 3) == 0); - return (UINT32)IoReadWorker (Port, SMM_IO_UINT32); -} - -/** - Writes a 32-bit I/O port. - - Writes the 32-bit I/O port specified by Port with the value specified by Value - and returns Value. This function must guarantee that all I/O read and write - operations are serialized. - - If Port is not aligned on a 32-bit boundary, then ASSERT(). - - If 32-bit I/O port operations are not supported, then ASSERT(). - - @param Port The I/O port to write. - @param Value The value to write to the I/O port. - - @return The value written the I/O port. - -**/ -UINT32 -EFIAPI -IoWrite32 ( - IN UINTN Port, - IN UINT32 Value - ) -{ - // - // Make sure Port is aligned on a 32-bit boundary. - // - ASSERT ((Port & 3) == 0); - return (UINT32)IoWriteWorker (Port, SMM_IO_UINT32, Value); -} - -/** - Reads a 64-bit I/O port. - - Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned. - This function must guarantee that all I/O read and write operations are - serialized. - - If Port is not aligned on a 64-bit boundary, then ASSERT(). - - If 64-bit I/O port operations are not supported, then ASSERT(). - - @param Port The I/O port to read. - - @return The value read. - -**/ -UINT64 -EFIAPI -IoRead64 ( - IN UINTN Port - ) -{ - // - // Make sure Port is aligned on a 64-bit boundary. - // - ASSERT ((Port & 7) == 0); - return IoReadWorker (Port, SMM_IO_UINT64); -} - -/** - Writes a 64-bit I/O port. - - Writes the 64-bit I/O port specified by Port with the value specified by Value - and returns Value. This function must guarantee that all I/O read and write - operations are serialized. - - If Port is not aligned on a 64-bit boundary, then ASSERT(). - - If 64-bit I/O port operations are not supported, then ASSERT(). - - @param Port The I/O port to write. - @param Value The value to write to the I/O port. - - @return The value written the I/O port. - -**/ -UINT64 -EFIAPI -IoWrite64 ( - IN UINTN Port, - IN UINT64 Value - ) -{ - // - // Make sure Port is aligned on a 64-bit boundary. - // - ASSERT ((Port & 7) == 0); - return IoWriteWorker (Port, SMM_IO_UINT64, Value); -} - -/** - Reads an 8-bit MMIO register. - - Reads the 8-bit MMIO register specified by Address. The 8-bit read value is - returned. This function must guarantee that all MMIO read and write - operations are serialized. - - If 8-bit MMIO register operations are not supported, then ASSERT(). - - @param Address The MMIO register to read. - - @return The value read. - -**/ -UINT8 -EFIAPI -MmioRead8 ( - IN UINTN Address - ) -{ - return (UINT8)MmioReadWorker (Address, SMM_IO_UINT8); -} - -/** - Writes an 8-bit MMIO register. - - Writes the 8-bit MMIO register specified by Address with the value specified - by Value and returns Value. This function must guarantee that all MMIO read - and write operations are serialized. - - If 8-bit MMIO register operations are not supported, then ASSERT(). - - @param Address The MMIO register to write. - @param Value The value to write to the MMIO register. - -**/ -UINT8 -EFIAPI -MmioWrite8 ( - IN UINTN Address, - IN UINT8 Value - ) -{ - return (UINT8)MmioWriteWorker (Address, SMM_IO_UINT8, Value); -} - -/** - Reads a 16-bit MMIO register. - - Reads the 16-bit MMIO register specified by Address. The 16-bit read value is - returned. This function must guarantee that all MMIO read and write - operations are serialized. - - If Address is not aligned on a 16-bit boundary, then ASSERT(). - - If 16-bit MMIO register operations are not supported, then ASSERT(). - - @param Address The MMIO register to read. - - @return The value read. - -**/ -UINT16 -EFIAPI -MmioRead16 ( - IN UINTN Address - ) -{ - // - // Make sure Address is aligned on a 16-bit boundary. - // - ASSERT ((Address & 1) == 0); - return (UINT16)MmioReadWorker (Address, SMM_IO_UINT16); -} - -/** - Writes a 16-bit MMIO register. - - Writes the 16-bit MMIO register specified by Address with the value specified - by Value and returns Value. This function must guarantee that all MMIO read - and write operations are serialized. - - If Address is not aligned on a 16-bit boundary, then ASSERT(). - - If 16-bit MMIO register operations are not supported, then ASSERT(). - - @param Address The MMIO register to write. - @param Value The value to write to the MMIO register. - -**/ -UINT16 -EFIAPI -MmioWrite16 ( - IN UINTN Address, - IN UINT16 Value - ) -{ - // - // Make sure Address is aligned on a 16-bit boundary. - // - ASSERT ((Address & 1) == 0); - return (UINT16)MmioWriteWorker (Address, SMM_IO_UINT16, Value); -} - -/** - Reads a 32-bit MMIO register. - - Reads the 32-bit MMIO register specified by Address. The 32-bit read value is - returned. This function must guarantee that all MMIO read and write - operations are serialized. - - If Address is not aligned on a 32-bit boundary, then ASSERT(). - - If 32-bit MMIO register operations are not supported, then ASSERT(). - - @param Address The MMIO register to read. - - @return The value read. - -**/ -UINT32 -EFIAPI -MmioRead32 ( - IN UINTN Address - ) -{ - // - // Make sure Address is aligned on a 32-bit boundary. - // - ASSERT ((Address & 3) == 0); - return (UINT32)MmioReadWorker (Address, SMM_IO_UINT32); -} - -/** - Writes a 32-bit MMIO register. - - Writes the 32-bit MMIO register specified by Address with the value specified - by Value and returns Value. This function must guarantee that all MMIO read - and write operations are serialized. - - If Address is not aligned on a 32-bit boundary, then ASSERT(). - - If 32-bit MMIO register operations are not supported, then ASSERT(). - - @param Address The MMIO register to write. - @param Value The value to write to the MMIO register. - -**/ -UINT32 -EFIAPI -MmioWrite32 ( - IN UINTN Address, - IN UINT32 Value - ) -{ - // - // Make sure Address is aligned on a 32-bit boundary. - // - ASSERT ((Address & 3) == 0); - return (UINT32)MmioWriteWorker (Address, SMM_IO_UINT32, Value); -} - -/** - Reads a 64-bit MMIO register. - - Reads the 64-bit MMIO register specified by Address. The 64-bit read value is - returned. This function must guarantee that all MMIO read and write - operations are serialized. - - If Address is not aligned on a 64-bit boundary, then ASSERT(). - - If 64-bit MMIO register operations are not supported, then ASSERT(). - - @param Address The MMIO register to read. - - @return The value read. - -**/ -UINT64 -EFIAPI -MmioRead64 ( - IN UINTN Address - ) -{ - // - // Make sure Address is aligned on a 64-bit boundary. - // - ASSERT ((Address & 7) == 0); - return (UINT64)MmioReadWorker (Address, SMM_IO_UINT64); -} - -/** - Writes a 64-bit MMIO register. - - Writes the 64-bit MMIO register specified by Address with the value specified - by Value and returns Value. This function must guarantee that all MMIO read - and write operations are serialized. - - If Address is not aligned on a 64-bit boundary, then ASSERT(). - - If 64-bit MMIO register operations are not supported, then ASSERT(). - - @param Address The MMIO register to write. - @param Value The value to write to the MMIO register. - -**/ -UINT64 -EFIAPI -MmioWrite64 ( - IN UINTN Address, - IN UINT64 Value - ) -{ - // - // Make sure Address is aligned on a 64-bit boundary. - // - ASSERT ((Address & 7) == 0); - return (UINT64)MmioWriteWorker (Address, SMM_IO_UINT64, Value); -} diff --git a/MdePkg/Library/SmmIoLibCpuIo/IoLibMmioBuffer.c b/MdePkg/Library/SmmIoLibCpuIo/IoLibMmioBuffer.c deleted file mode 100644 index e4effa9602..0000000000 --- a/MdePkg/Library/SmmIoLibCpuIo/IoLibMmioBuffer.c +++ /dev/null @@ -1,416 +0,0 @@ -/** @file - I/O Library MMIO Buffer Functions. - - Copyright (c) 2009, Intel Corporation
- All rights reserved. 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 - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - Module Name: IoLibMmioBuffer.c - -**/ - - -#include "SmmCpuIoLibInternal.h" - -/** - Copy data from MMIO region to system memory by using 8-bit access. - - Copy data from MMIO region specified by starting address StartAddress - to system memory specified by Buffer by using 8-bit access. The total - number of byte to be copied is specified by Length. Buffer is returned. - - If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). - If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). - - - @param StartAddress Starting address for the MMIO region to be copied from. - @param Length Size in bytes of the copy. - @param Buffer Pointer to a system memory buffer receiving the data read. - - @return Buffer - -**/ -UINT8 * -EFIAPI -MmioReadBuffer8 ( - IN UINTN StartAddress, - IN UINTN Length, - OUT UINT8 *Buffer - ) -{ - UINT8 *ReturnBuffer; - - ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); - ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer)); - - ReturnBuffer = Buffer; - - while (Length-- > 0) { - *(Buffer++) = MmioRead8 (StartAddress++); - } - - return ReturnBuffer; -} - -/** - Copy data from MMIO region to system memory by using 16-bit access. - - Copy data from MMIO region specified by starting address StartAddress - to system memory specified by Buffer by using 16-bit access. The total - number of byte to be copied is specified by Length. Buffer is returned. - - If StartAddress is not aligned on a 16-bit boundary, then ASSERT(). - - If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). - If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). - - If Length is not aligned on a 16-bit boundary, then ASSERT(). - - If Buffer is not aligned on a 16-bit boundary, then ASSERT(). - - @param StartAddress Starting address for the MMIO region to be copied from. - @param Length Size in bytes of the copy. - @param Buffer Pointer to a system memory buffer receiving the data read. - - @return Buffer - -**/ -UINT16 * -EFIAPI -MmioReadBuffer16 ( - IN UINTN StartAddress, - IN UINTN Length, - OUT UINT16 *Buffer - ) -{ - UINT16 *ReturnBuffer; - - ASSERT ((StartAddress & (sizeof (UINT16) - 1)) == 0); - - ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); - ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer)); - - ASSERT ((Length & (sizeof (UINT16) - 1)) == 0); - ASSERT (((UINTN) Buffer & (sizeof (UINT16) - 1)) == 0); - - ReturnBuffer = Buffer; - - while (Length > 0) { - *(Buffer++) = MmioRead16 (StartAddress); - StartAddress += sizeof (UINT16); - Length -= sizeof (UINT16); - } - - return ReturnBuffer; -} - -/** - Copy data from MMIO region to system memory by using 32-bit access. - - Copy data from MMIO region specified by starting address StartAddress - to system memory specified by Buffer by using 32-bit access. The total - number of byte to be copied is specified by Length. Buffer is returned. - - If StartAddress is not aligned on a 32-bit boundary, then ASSERT(). - - If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). - If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). - - If Length is not aligned on a 32-bit boundary, then ASSERT(). - If Buffer is not aligned on a 32-bit boundary, then ASSERT(). - - @param StartAddress Starting address for the MMIO region to be copied from. - @param Length Size in bytes of the copy. - @param Buffer Pointer to a system memory buffer receiving the data read. - - @return Buffer - -**/ -UINT32 * -EFIAPI -MmioReadBuffer32 ( - IN UINTN StartAddress, - IN UINTN Length, - OUT UINT32 *Buffer - ) -{ - UINT32 *ReturnBuffer; - - ASSERT ((StartAddress & (sizeof (UINT32) - 1)) == 0); - - ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); - ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer)); - - ASSERT ((Length & (sizeof (UINT32) - 1)) == 0); - ASSERT (((UINTN) Buffer & (sizeof (UINT32) - 1)) == 0); - - ReturnBuffer = Buffer; - - while (Length > 0) { - *(Buffer++) = MmioRead32 (StartAddress); - StartAddress += sizeof (UINT32); - Length -= sizeof (UINT32); - } - - return ReturnBuffer; -} - -/** - Copy data from MMIO region to system memory by using 64-bit access. - - Copy data from MMIO region specified by starting address StartAddress - to system memory specified by Buffer by using 64-bit access. The total - number of byte to be copied is specified by Length. Buffer is returned. - - If StartAddress is not aligned on a 64-bit boundary, then ASSERT(). - - If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). - If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). - - If Length is not aligned on a 64-bit boundary, then ASSERT(). - - If Buffer is not aligned on a 64-bit boundary, then ASSERT(). - - @param StartAddress Starting address for the MMIO region to be copied from. - @param Length Size in bytes of the copy. - @param Buffer Pointer to a system memory buffer receiving the data read. - - @return Buffer - -**/ -UINT64 * -EFIAPI -MmioReadBuffer64 ( - IN UINTN StartAddress, - IN UINTN Length, - OUT UINT64 *Buffer - ) -{ - UINT64 *ReturnBuffer; - - ASSERT ((StartAddress & (sizeof (UINT64) - 1)) == 0); - - ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); - ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer)); - - ASSERT ((Length & (sizeof (UINT64) - 1)) == 0); - ASSERT (((UINTN) Buffer & (sizeof (UINT64) - 1)) == 0); - - ReturnBuffer = Buffer; - - while (Length > 0) { - *(Buffer++) = MmioRead64 (StartAddress); - StartAddress += sizeof (UINT64); - Length -= sizeof (UINT64); - } - - return ReturnBuffer; -} - - -/** - Copy data from system memory to MMIO region by using 8-bit access. - - Copy data from system memory specified by Buffer to MMIO region specified - by starting address StartAddress by using 8-bit access. The total number - of byte to be copied is specified by Length. Buffer is returned. - - If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). - If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). - - - @param StartAddress Starting address for the MMIO region to be copied to. - @param Length Size in bytes of the copy. - @param Buffer Pointer to a system memory buffer containing the data to write. - - @return Buffer - -**/ -UINT8 * -EFIAPI -MmioWriteBuffer8 ( - IN UINTN StartAddress, - IN UINTN Length, - IN CONST UINT8 *Buffer - ) -{ - VOID* ReturnBuffer; - - ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); - ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer)); - - ReturnBuffer = (UINT8 *) Buffer; - - while (Length-- > 0) { - MmioWrite8 (StartAddress++, *(Buffer++)); - } - - return ReturnBuffer; - -} - -/** - Copy data from system memory to MMIO region by using 16-bit access. - - Copy data from system memory specified by Buffer to MMIO region specified - by starting address StartAddress by using 16-bit access. The total number - of byte to be copied is specified by Length. Buffer is returned. - - If StartAddress is not aligned on a 16-bit boundary, then ASSERT(). - - If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). - If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). - - If Length is not aligned on a 16-bit boundary, then ASSERT(). - - If Buffer is not aligned on a 16-bit boundary, then ASSERT(). - - @param StartAddress Starting address for the MMIO region to be copied to. - @param Length Size in bytes of the copy. - @param Buffer Pointer to a system memory buffer containing the data to write. - - @return Buffer - -**/ -UINT16 * -EFIAPI -MmioWriteBuffer16 ( - IN UINTN StartAddress, - IN UINTN Length, - IN CONST UINT16 *Buffer - ) -{ - UINT16 *ReturnBuffer; - - ASSERT ((StartAddress & (sizeof (UINT16) - 1)) == 0); - - ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); - ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer)); - - ASSERT ((Length & (sizeof (UINT16) - 1)) == 0); - ASSERT (((UINTN) Buffer & (sizeof (UINT16) - 1)) == 0); - - ReturnBuffer = (UINT16 *) Buffer; - - while (Length > 0) { - MmioWrite16 (StartAddress, *(Buffer++)); - - StartAddress += sizeof (UINT16); - Length -= sizeof (UINT16); - } - - return ReturnBuffer; -} - - -/** - Copy data from system memory to MMIO region by using 32-bit access. - - Copy data from system memory specified by Buffer to MMIO region specified - by starting address StartAddress by using 32-bit access. The total number - of byte to be copied is specified by Length. Buffer is returned. - - If StartAddress is not aligned on a 32-bit boundary, then ASSERT(). - - If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). - If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). - - If Length is not aligned on a 32-bit boundary, then ASSERT(). - - If Buffer is not aligned on a 32-bit boundary, then ASSERT(). - - @param StartAddress Starting address for the MMIO region to be copied to. - @param Length Size in bytes of the copy. - @param Buffer Pointer to a system memory buffer containing the data to write. - - @return Buffer - -**/ -UINT32 * -EFIAPI -MmioWriteBuffer32 ( - IN UINTN StartAddress, - IN UINTN Length, - IN CONST UINT32 *Buffer - ) -{ - UINT32 *ReturnBuffer; - - ASSERT ((StartAddress & (sizeof (UINT32) - 1)) == 0); - - ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); - ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer)); - - ASSERT ((Length & (sizeof (UINT32) - 1)) == 0); - ASSERT (((UINTN) Buffer & (sizeof (UINT32) - 1)) == 0); - - ReturnBuffer = (UINT32 *) Buffer; - - while (Length > 0) { - MmioWrite32 (StartAddress, *(Buffer++)); - - StartAddress += sizeof (UINT32); - Length -= sizeof (UINT32); - } - - return ReturnBuffer; -} - -/** - Copy data from system memory to MMIO region by using 64-bit access. - - Copy data from system memory specified by Buffer to MMIO region specified - by starting address StartAddress by using 64-bit access. The total number - of byte to be copied is specified by Length. Buffer is returned. - - If StartAddress is not aligned on a 64-bit boundary, then ASSERT(). - - If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). - If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). - - If Length is not aligned on a 64-bit boundary, then ASSERT(). - - If Buffer is not aligned on a 64-bit boundary, then ASSERT(). - - @param StartAddress Starting address for the MMIO region to be copied to. - @param Length Size in bytes of the copy. - @param Buffer Pointer to a system memory buffer containing the data to write. - - @return Buffer - -**/ -UINT64 * -EFIAPI -MmioWriteBuffer64 ( - IN UINTN StartAddress, - IN UINTN Length, - IN CONST UINT64 *Buffer - ) -{ - UINT64 *ReturnBuffer; - - ASSERT ((StartAddress & (sizeof (UINT64) - 1)) == 0); - - ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); - ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer)); - - ASSERT ((Length & (sizeof (UINT64) - 1)) == 0); - ASSERT (((UINTN) Buffer & (sizeof (UINT64) - 1)) == 0); - - ReturnBuffer = (UINT64 *) Buffer; - - while (Length > 0) { - MmioWrite64 (StartAddress, *(Buffer++)); - - StartAddress += sizeof (UINT64); - Length -= sizeof (UINT64); - } - - return ReturnBuffer; -} - diff --git a/MdePkg/Library/SmmIoLibCpuIo/SmmCpuIoLibInternal.h b/MdePkg/Library/SmmIoLibCpuIo/SmmCpuIoLibInternal.h deleted file mode 100644 index e221bc8d9e..0000000000 --- a/MdePkg/Library/SmmIoLibCpuIo/SmmCpuIoLibInternal.h +++ /dev/null @@ -1,121 +0,0 @@ -/** @file - Internal include file of SMM CPU IO Library. - It includes all necessary protocol/library class's header file - for implementation of IoLib library instance. It is included - all source code of this library instance. - - Copyright (c) 2009, Intel Corporation - All rights reserved. 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 - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - Module Name: DxeCpuIoLibInternal.h - -**/ - -#ifndef _SMM_CPUIO_LIB_INTERNAL_H_ -#define _SMM_CPUIO_LIB_INTERNAL_H_ - - -#include -#include -#include -#include -#include -#include -#include - - -/** - Reads registers in the EFI CPU I/O space. - - Reads the I/O port specified by Port with registers width specified by Width. - The read value is returned. If such operations are not supported, then ASSERT(). - This function must guarantee that all I/O read and write operations are serialized. - - @param Port The base address of the I/O operation. - The caller is responsible for aligning the Address if required. - @param Width The width of the I/O operation. - - @return Data read from registers in the EFI CPU I/O space. - -**/ -UINT64 -EFIAPI -IoReadWorker ( - IN UINTN Port, - IN EFI_SMM_IO_WIDTH Width - ); - -/** - Writes registers in the EFI CPU I/O space. - - Writes the I/O port specified by Port with registers width and value specified by Width - and Data respectively. Data is returned. If such operations are not supported, then ASSERT(). - This function must guarantee that all I/O read and write operations are serialized. - - @param Port The base address of the I/O operation. - The caller is responsible for aligning the Address if required. - @param Width The width of the I/O operation. - @param Data The value to write to the I/O port. - - @return The paramter of Data. - -**/ -UINT64 -EFIAPI -IoWriteWorker ( - IN UINTN Port, - IN EFI_SMM_IO_WIDTH Width, - IN UINT64 Data - ); - -/** - Reads memory-mapped registers in the EFI system memory space. - - Reads the MMIO registers specified by Address with registers width specified by Width. - The read value is returned. If such operations are not supported, then ASSERT(). - This function must guarantee that all MMIO read and write operations are serialized. - - @param Address The MMIO register to read. - The caller is responsible for aligning the Address if required. - @param Width The width of the I/O operation. - - @return Data read from registers in the EFI system memory space. - -**/ -UINT64 -EFIAPI -MmioReadWorker ( - IN UINTN Address, - IN EFI_SMM_IO_WIDTH Width - ); - -/** - Writes memory-mapped registers in the EFI system memory space. - - Writes the MMIO registers specified by Address with registers width and value specified by Width - and Data respectively. Data is returned. If such operations are not supported, then ASSERT(). - This function must guarantee that all MMIO read and write operations are serialized. - - @param Address The MMIO register to read. - The caller is responsible for aligning the Address if required. - @param Width The width of the I/O operation. - @param Data The value to write to the I/O port. - - @return Data read from registers in the EFI system memory space. - -**/ -UINT64 -EFIAPI -MmioWriteWorker ( - IN UINTN Address, - IN EFI_SMM_IO_WIDTH Width, - IN UINT64 Data - ); - -#endif diff --git a/MdePkg/Library/SmmIoLibCpuIo/SmmIoLibCpuIo.inf b/MdePkg/Library/SmmIoLibCpuIo/SmmIoLibCpuIo.inf deleted file mode 100644 index 7be09dc878..0000000000 --- a/MdePkg/Library/SmmIoLibCpuIo/SmmIoLibCpuIo.inf +++ /dev/null @@ -1,56 +0,0 @@ -#/** @file -# Component description file for Cpu Io SMM Io Library. -# -# I/O Library implementation that uses the CPU I/O Protocol for I/O -# and MMIO operations. -# Copyright (c) 2009, Intel Corporation. -# -# All rights reserved. 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 -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# -#**/ - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = SmmIoLibCpuIo - FILE_GUID = DEEEA15E-4A77-4513-BA75-71D26FEF78A1 - MODULE_TYPE = DXE_SMM_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = IoLib|DXE_SMM_DRIVER SMM_CORE - EFI_SPECIFICATION_VERSION = 0x00020000 - PI_SPECIFICATION_VERSION = 0x0001000A - - CONSTRUCTOR = IoLibConstructor - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources.common] - IoLibMmioBuffer.c - SmmCpuIoLibInternal.h - IoHighLevel.c - IoLib.c - - -[Packages] - MdePkg/MdePkg.dec - -[LibraryClasses] - BaseLib - DebugLib - SmmServicesTableLib - -[Protocols] - gEfiSmmCpuIoProtocolGuid ## CONSUMES - gEfiSmmPciRootBridgeIoProtocolGuid ## CONSUMES - -[Depex] - gEfiSmmCpuIoProtocolGuid OR gEfiSmmPciRootBridgeIoProtocolGuid \ No newline at end of file diff --git a/MdePkg/Library/SmmIoLibSmmCpuIo2/IoHighLevel.c b/MdePkg/Library/SmmIoLibSmmCpuIo2/IoHighLevel.c new file mode 100644 index 0000000000..ae772b81bc --- /dev/null +++ b/MdePkg/Library/SmmIoLibSmmCpuIo2/IoHighLevel.c @@ -0,0 +1,2272 @@ +/** @file + High-level Io/Mmio functions. + + All assertions for bit field operations are handled bit field functions in the + Base Library. + + Copyright (c) 2009 - 2010, Intel Corporation
+ All rights reserved. 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + The following IoLib instances share the same version of this file: + + BaseIoLibIntrinsic + DxeIoLibCpuIo + PeiIoLibCpuIo + SmmIoLibCpuIo +**/ + +#include "SmmCpuIoLibInternal.h" + +/** + Reads an 8-bit I/O port, performs a bitwise OR, and writes the + result back to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise OR + between the read result and the value specified by OrData, and writes the + result to the 8-bit I/O port specified by Port. The value written to the I/O + port is returned. 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 write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoOr8 ( + IN UINTN Port, + IN UINT8 OrData + ) +{ + return IoWrite8 (Port, (UINT8) (IoRead8 (Port) | OrData)); +} + +/** + Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back + to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 8-bit I/O port specified by Port. The value written to the I/O port is + returned. 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 write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoAnd8 ( + IN UINTN Port, + IN UINT8 AndData + ) +{ + return IoWrite8 (Port, (UINT8) (IoRead8 (Port) & AndData)); +} + +/** + Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 8-bit I/O port specified by Port. The value + written to the I/O port is returned. 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 write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoAndThenOr8 ( + IN UINTN Port, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return IoWrite8 (Port, (UINT8) ((IoRead8 (Port) & AndData) | OrData)); +} + +/** + Reads a bit field of an I/O register. + + Reads the bit field in an 8-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value read. + +**/ +UINT8 +EFIAPI +IoBitFieldRead8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead8 (IoRead8 (Port), StartBit, EndBit); +} + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldWrite8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + return IoWrite8 ( + Port, + BitFieldWrite8 (IoRead8 (Port), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise OR + between the read result and the value specified by OrData, and writes the + result to the 8-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldOr8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + return IoWrite8 ( + Port, + BitFieldOr8 (IoRead8 (Port), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 8-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldAnd8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + return IoWrite8 ( + Port, + BitFieldAnd8 (IoRead8 (Port), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise OR between the read result and the value specified by + AndData, and writes the result to the 8-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldAndThenOr8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return IoWrite8 ( + Port, + BitFieldAndThenOr8 (IoRead8 (Port), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 16-bit I/O port, performs a bitwise OR, and writes the + result back to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise OR + between the read result and the value specified by OrData, and writes the + result to the 16-bit I/O port specified by Port. The value written to the I/O + port is returned. 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 write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoOr16 ( + IN UINTN Port, + IN UINT16 OrData + ) +{ + return IoWrite16 (Port, (UINT16) (IoRead16 (Port) | OrData)); +} + +/** + Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back + to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 16-bit I/O port specified by Port. The value written to the I/O port is + returned. 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 write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoAnd16 ( + IN UINTN Port, + IN UINT16 AndData + ) +{ + return IoWrite16 (Port, (UINT16) (IoRead16 (Port) & AndData)); +} + +/** + Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 16-bit I/O port specified by Port. The value + written to the I/O port is returned. 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 write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoAndThenOr16 ( + IN UINTN Port, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return IoWrite16 (Port, (UINT16) ((IoRead16 (Port) & AndData) | OrData)); +} + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 16-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value read. + +**/ +UINT16 +EFIAPI +IoBitFieldRead16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead16 (IoRead16 (Port), StartBit, EndBit); +} + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldWrite16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + return IoWrite16 ( + Port, + BitFieldWrite16 (IoRead16 (Port), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise OR + between the read result and the value specified by OrData, and writes the + result to the 16-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldOr16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + return IoWrite16 ( + Port, + BitFieldOr16 (IoRead16 (Port), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 16-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldAnd16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + return IoWrite16 ( + Port, + BitFieldAnd16 (IoRead16 (Port), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise OR between the read result and the value specified by + AndData, and writes the result to the 16-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldAndThenOr16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return IoWrite16 ( + Port, + BitFieldAndThenOr16 (IoRead16 (Port), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 32-bit I/O port, performs a bitwise OR, and writes the + result back to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise OR + between the read result and the value specified by OrData, and writes the + result to the 32-bit I/O port specified by Port. The value written to the I/O + port is returned. 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 write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoOr32 ( + IN UINTN Port, + IN UINT32 OrData + ) +{ + return IoWrite32 (Port, IoRead32 (Port) | OrData); +} + +/** + Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back + to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 32-bit I/O port specified by Port. The value written to the I/O port is + returned. 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 write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoAnd32 ( + IN UINTN Port, + IN UINT32 AndData + ) +{ + return IoWrite32 (Port, IoRead32 (Port) & AndData); +} + +/** + Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 32-bit I/O port specified by Port. The value + written to the I/O port is returned. 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 write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoAndThenOr32 ( + IN UINTN Port, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return IoWrite32 (Port, (IoRead32 (Port) & AndData) | OrData); +} + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 32-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value read. + +**/ +UINT32 +EFIAPI +IoBitFieldRead32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead32 (IoRead32 (Port), StartBit, EndBit); +} + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldWrite32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + return IoWrite32 ( + Port, + BitFieldWrite32 (IoRead32 (Port), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise OR + between the read result and the value specified by OrData, and writes the + result to the 32-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldOr32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + return IoWrite32 ( + Port, + BitFieldOr32 (IoRead32 (Port), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 32-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldAnd32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + return IoWrite32 ( + Port, + BitFieldAnd32 (IoRead32 (Port), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise OR between the read result and the value specified by + AndData, and writes the result to the 32-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldAndThenOr32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return IoWrite32 ( + Port, + BitFieldAndThenOr32 (IoRead32 (Port), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 64-bit I/O port, performs a bitwise OR, and writes the + result back to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoOr64 ( + IN UINTN Port, + IN UINT64 OrData + ) +{ + return IoWrite64 (Port, IoRead64 (Port) | OrData); +} + +/** + Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back + to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 64-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoAnd64 ( + IN UINTN Port, + IN UINT64 AndData + ) +{ + return IoWrite64 (Port, IoRead64 (Port) & AndData); +} + +/** + Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 64-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoAndThenOr64 ( + IN UINTN Port, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return IoWrite64 (Port, (IoRead64 (Port) & AndData) | OrData); +} + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 64-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value read. + +**/ +UINT64 +EFIAPI +IoBitFieldRead64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead64 (IoRead64 (Port), StartBit, EndBit); +} + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldWrite64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ) +{ + return IoWrite64 ( + Port, + BitFieldWrite64 (IoRead64 (Port), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldOr64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ) +{ + return IoWrite64 ( + Port, + BitFieldOr64 (IoRead64 (Port), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 64-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldAnd64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ) +{ + return IoWrite64 ( + Port, + BitFieldAnd64 (IoRead64 (Port), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 64-bit port, performs a bitwise AND followed by a + bitwise OR, and writes the result back to the bit field in the + 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise OR between the read result and the value specified by + AndData, and writes the result to the 64-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldAndThenOr64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return IoWrite64 ( + Port, + BitFieldAndThenOr64 (IoRead64 (Port), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads an 8-bit MMIO register, performs a bitwise OR, and writes the + result back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 8-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioOr8 ( + IN UINTN Address, + IN UINT8 OrData + ) +{ + return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) | OrData)); +} + +/** + Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result + back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 8-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioAnd8 ( + IN UINTN Address, + IN UINT8 AndData + ) +{ + return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) & AndData)); +} + +/** + Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 8-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioAndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return MmioWrite8 (Address, (UINT8) ((MmioRead8 (Address) & AndData) | OrData)); +} + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in an 8-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value read. + +**/ +UINT8 +EFIAPI +MmioBitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead8 (MmioRead8 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 8-bit register is returned. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + return MmioWrite8 ( + Address, + BitFieldWrite8 (MmioRead8 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 8-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + return MmioWrite8 ( + Address, + BitFieldOr8 (MmioRead8 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 8-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + return MmioWrite8 ( + Address, + BitFieldAnd8 (MmioRead8 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed + by a bitwise OR, and writes the result back to the bit field in the + 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise OR between the read result and the value + specified by AndData, and writes the result to the 8-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return MmioWrite8 ( + Address, + BitFieldAndThenOr8 (MmioRead8 (Address), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 16-bit MMIO register, performs a bitwise OR, and writes the + result back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 16-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioOr16 ( + IN UINTN Address, + IN UINT16 OrData + ) +{ + return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) | OrData)); +} + +/** + Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result + back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 16-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioAnd16 ( + IN UINTN Address, + IN UINT16 AndData + ) +{ + return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) & AndData)); +} + +/** + Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 16-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioAndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return MmioWrite16 (Address, (UINT16) ((MmioRead16 (Address) & AndData) | OrData)); +} + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 16-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value read. + +**/ +UINT16 +EFIAPI +MmioBitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead16 (MmioRead16 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 16-bit register is returned. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + return MmioWrite16 ( + Address, + BitFieldWrite16 (MmioRead16 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 16-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + return MmioWrite16 ( + Address, + BitFieldOr16 (MmioRead16 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 16-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + return MmioWrite16 ( + Address, + BitFieldAnd16 (MmioRead16 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed + by a bitwise OR, and writes the result back to the bit field in the + 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise OR between the read result and the value + specified by AndData, and writes the result to the 16-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return MmioWrite16 ( + Address, + BitFieldAndThenOr16 (MmioRead16 (Address), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 32-bit MMIO register, performs a bitwise OR, and writes the + result back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 32-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioOr32 ( + IN UINTN Address, + IN UINT32 OrData + ) +{ + return MmioWrite32 (Address, MmioRead32 (Address) | OrData); +} + +/** + Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result + back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 32-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioAnd32 ( + IN UINTN Address, + IN UINT32 AndData + ) +{ + return MmioWrite32 (Address, MmioRead32 (Address) & AndData); +} + +/** + Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 32-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioAndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return MmioWrite32 (Address, (MmioRead32 (Address) & AndData) | OrData); +} + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 32-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value read. + +**/ +UINT32 +EFIAPI +MmioBitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead32 (MmioRead32 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 32-bit register is returned. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + return MmioWrite32 ( + Address, + BitFieldWrite32 (MmioRead32 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 32-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + return MmioWrite32 ( + Address, + BitFieldOr32 (MmioRead32 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 32-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + return MmioWrite32 ( + Address, + BitFieldAnd32 (MmioRead32 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed + by a bitwise OR, and writes the result back to the bit field in the + 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise OR between the read result and the value + specified by AndData, and writes the result to the 32-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return MmioWrite32 ( + Address, + BitFieldAndThenOr32 (MmioRead32 (Address), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 64-bit MMIO register, performs a bitwise OR, and writes the + result back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 64-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioOr64 ( + IN UINTN Address, + IN UINT64 OrData + ) +{ + return MmioWrite64 (Address, MmioRead64 (Address) | OrData); +} + +/** + Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result + back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 64-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioAnd64 ( + IN UINTN Address, + IN UINT64 AndData + ) +{ + return MmioWrite64 (Address, MmioRead64 (Address) & AndData); +} + +/** + Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 64-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioAndThenOr64 ( + IN UINTN Address, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return MmioWrite64 (Address, (MmioRead64 (Address) & AndData) | OrData); +} + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 64-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value read. + +**/ +UINT64 +EFIAPI +MmioBitFieldRead64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead64 (MmioRead64 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 64-bit register is returned. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldWrite64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ) +{ + return MmioWrite64 ( + Address, + BitFieldWrite64 (MmioRead64 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 64-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldOr64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ) +{ + return MmioWrite64 ( + Address, + BitFieldOr64 (MmioRead64 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 64-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldAnd64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ) +{ + return MmioWrite64 ( + Address, + BitFieldAnd64 (MmioRead64 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed + by a bitwise OR, and writes the result back to the bit field in the + 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise OR between the read result and the value + specified by AndData, and writes the result to the 64-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldAndThenOr64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return MmioWrite64 ( + Address, + BitFieldAndThenOr64 (MmioRead64 (Address), StartBit, EndBit, AndData, OrData) + ); +} diff --git a/MdePkg/Library/SmmIoLibSmmCpuIo2/IoLib.c b/MdePkg/Library/SmmIoLibSmmCpuIo2/IoLib.c new file mode 100644 index 0000000000..53003d123d --- /dev/null +++ b/MdePkg/Library/SmmIoLibSmmCpuIo2/IoLib.c @@ -0,0 +1,619 @@ +/** @file + I/O Library. + The implementation of I/O operation for this library instance + are based on EFI_CPU_IO_PROTOCOL. + + Copyright (c) 2009 - 2010, Intel Corporation
+ All rights reserved. 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "SmmCpuIoLibInternal.h" + +// +// Globle varible to cache pointer to CpuIo protocol. +// +EFI_SMM_CPU_IO2_PROTOCOL *mCpuIo2 = NULL; + +/** + The constructor function caches the pointer to CpuIo protocol. + + The constructor function locates CpuIo protocol from protocol database. + It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +IoLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status = gSmst->SmmLocateProtocol (&gEfiSmmCpuIo2ProtocolGuid, NULL, (VOID **) &mCpuIo2); + ASSERT_EFI_ERROR (Status); + + return Status; +} + +/** + Reads registers in the EFI CPU I/O space. + + Reads the I/O port specified by Port with registers width specified by Width. + The read value is returned. If such operations are not supported, then ASSERT(). + This function must guarantee that all I/O read and write operations are serialized. + + @param Port The base address of the I/O operation. + The caller is responsible for aligning the Address if required. + @param Width The width of the I/O operation. + + @return Data read from registers in the EFI CPU I/O space. + +**/ +UINT64 +EFIAPI +IoReadWorker ( + IN UINTN Port, + IN EFI_SMM_IO_WIDTH Width + ) +{ + EFI_STATUS Status; + UINT64 Data; + + Status = mCpuIo2->Io.Read (mCpuIo2, Width, Port, 1, &Data); + ASSERT_EFI_ERROR (Status); + + return Data; +} + +/** + Writes registers in the EFI CPU I/O space. + + Writes the I/O port specified by Port with registers width and value specified by Width + and Data respectively. Data is returned. If such operations are not supported, then ASSERT(). + This function must guarantee that all I/O read and write operations are serialized. + + @param Port The base address of the I/O operation. + The caller is responsible for aligning the Address if required. + @param Width The width of the I/O operation. + @param Data The value to write to the I/O port. + + @return The paramter of Data. + +**/ +UINT64 +EFIAPI +IoWriteWorker ( + IN UINTN Port, + IN EFI_SMM_IO_WIDTH Width, + IN UINT64 Data + ) +{ + EFI_STATUS Status; + + Status = mCpuIo2->Io.Write (mCpuIo2, Width, Port, 1, &Data); + ASSERT_EFI_ERROR (Status); + + return Data; +} + +/** + Reads memory-mapped registers in the EFI system memory space. + + Reads the MMIO registers specified by Address with registers width specified by Width. + The read value is returned. If such operations are not supported, then ASSERT(). + This function must guarantee that all MMIO read and write operations are serialized. + + @param Address The MMIO register to read. + The caller is responsible for aligning the Address if required. + @param Width The width of the I/O operation. + + @return Data read from registers in the EFI system memory space. + +**/ +UINT64 +EFIAPI +MmioReadWorker ( + IN UINTN Address, + IN EFI_SMM_IO_WIDTH Width + ) +{ + EFI_STATUS Status; + UINT64 Data; + + Status = mCpuIo2->Mem.Read (mCpuIo2, Width, Address, 1, &Data); + ASSERT_EFI_ERROR (Status); + + return Data; +} + +/** + Writes memory-mapped registers in the EFI system memory space. + + Writes the MMIO registers specified by Address with registers width and value specified by Width + and Data respectively. Data is returned. If such operations are not supported, then ASSERT(). + This function must guarantee that all MMIO read and write operations are serialized. + + @param Address The MMIO register to read. + The caller is responsible for aligning the Address if required. + @param Width The width of the I/O operation. + @param Data The value to write to the I/O port. + + @return Data read from registers in the EFI system memory space. + +**/ +UINT64 +EFIAPI +MmioWriteWorker ( + IN UINTN Address, + IN EFI_SMM_IO_WIDTH Width, + IN UINT64 Data + ) +{ + EFI_STATUS Status; + + Status = mCpuIo2->Mem.Write (mCpuIo2, Width, Address, 1, &Data); + ASSERT_EFI_ERROR (Status); + + return Data; +} + +/** + Reads an 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned. + 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. + + @return The value read. + +**/ +UINT8 +EFIAPI +IoRead8 ( + IN UINTN Port + ) +{ + return (UINT8)IoReadWorker (Port, SMM_IO_UINT8); +} + +/** + Writes an 8-bit I/O port. + + Writes the 8-bit I/O port specified by Port with the value specified by Value + and returns Value. 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 write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT8 +EFIAPI +IoWrite8 ( + IN UINTN Port, + IN UINT8 Value + ) +{ + return (UINT8)IoWriteWorker (Port, SMM_IO_UINT8, Value); +} + +/** + Reads a 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If Port is not aligned on a 16-bit boundary, then ASSERT(). + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT16 +EFIAPI +IoRead16 ( + IN UINTN Port + ) +{ + // + // Make sure Port is aligned on a 16-bit boundary. + // + ASSERT ((Port & 1) == 0); + return (UINT16)IoReadWorker (Port, SMM_IO_UINT16); +} + +/** + Writes a 16-bit I/O port. + + Writes the 16-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If Port is not aligned on a 16-bit boundary, then ASSERT(). + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT16 +EFIAPI +IoWrite16 ( + IN UINTN Port, + IN UINT16 Value + ) +{ + // + // Make sure Port is aligned on a 16-bit boundary. + // + ASSERT ((Port & 1) == 0); + return (UINT16)IoWriteWorker (Port, SMM_IO_UINT16, Value); +} + +/** + Reads a 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If Port is not aligned on a 32-bit boundary, then ASSERT(). + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT32 +EFIAPI +IoRead32 ( + IN UINTN Port + ) +{ + // + // Make sure Port is aligned on a 32-bit boundary. + // + ASSERT ((Port & 3) == 0); + return (UINT32)IoReadWorker (Port, SMM_IO_UINT32); +} + +/** + Writes a 32-bit I/O port. + + Writes the 32-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If Port is not aligned on a 32-bit boundary, then ASSERT(). + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT32 +EFIAPI +IoWrite32 ( + IN UINTN Port, + IN UINT32 Value + ) +{ + // + // Make sure Port is aligned on a 32-bit boundary. + // + ASSERT ((Port & 3) == 0); + return (UINT32)IoWriteWorker (Port, SMM_IO_UINT32, Value); +} + +/** + Reads a 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If Port is not aligned on a 64-bit boundary, then ASSERT(). + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT64 +EFIAPI +IoRead64 ( + IN UINTN Port + ) +{ + // + // Make sure Port is aligned on a 64-bit boundary. + // + ASSERT ((Port & 7) == 0); + return IoReadWorker (Port, SMM_IO_UINT64); +} + +/** + Writes a 64-bit I/O port. + + Writes the 64-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If Port is not aligned on a 64-bit boundary, then ASSERT(). + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT64 +EFIAPI +IoWrite64 ( + IN UINTN Port, + IN UINT64 Value + ) +{ + // + // Make sure Port is aligned on a 64-bit boundary. + // + ASSERT ((Port & 7) == 0); + return IoWriteWorker (Port, SMM_IO_UINT64, Value); +} + +/** + Reads an 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address. The 8-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT8 +EFIAPI +MmioRead8 ( + IN UINTN Address + ) +{ + return (UINT8)MmioReadWorker (Address, SMM_IO_UINT8); +} + +/** + Writes an 8-bit MMIO register. + + Writes the 8-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioWrite8 ( + IN UINTN Address, + IN UINT8 Value + ) +{ + return (UINT8)MmioWriteWorker (Address, SMM_IO_UINT8, Value); +} + +/** + Reads a 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address. The 16-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT16 +EFIAPI +MmioRead16 ( + IN UINTN Address + ) +{ + // + // Make sure Address is aligned on a 16-bit boundary. + // + ASSERT ((Address & 1) == 0); + return (UINT16)MmioReadWorker (Address, SMM_IO_UINT16); +} + +/** + Writes a 16-bit MMIO register. + + Writes the 16-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioWrite16 ( + IN UINTN Address, + IN UINT16 Value + ) +{ + // + // Make sure Address is aligned on a 16-bit boundary. + // + ASSERT ((Address & 1) == 0); + return (UINT16)MmioWriteWorker (Address, SMM_IO_UINT16, Value); +} + +/** + Reads a 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address. The 32-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT32 +EFIAPI +MmioRead32 ( + IN UINTN Address + ) +{ + // + // Make sure Address is aligned on a 32-bit boundary. + // + ASSERT ((Address & 3) == 0); + return (UINT32)MmioReadWorker (Address, SMM_IO_UINT32); +} + +/** + Writes a 32-bit MMIO register. + + Writes the 32-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioWrite32 ( + IN UINTN Address, + IN UINT32 Value + ) +{ + // + // Make sure Address is aligned on a 32-bit boundary. + // + ASSERT ((Address & 3) == 0); + return (UINT32)MmioWriteWorker (Address, SMM_IO_UINT32, Value); +} + +/** + Reads a 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address. The 64-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If Address is not aligned on a 64-bit boundary, then ASSERT(). + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT64 +EFIAPI +MmioRead64 ( + IN UINTN Address + ) +{ + // + // Make sure Address is aligned on a 64-bit boundary. + // + ASSERT ((Address & 7) == 0); + return (UINT64)MmioReadWorker (Address, SMM_IO_UINT64); +} + +/** + Writes a 64-bit MMIO register. + + Writes the 64-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If Address is not aligned on a 64-bit boundary, then ASSERT(). + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioWrite64 ( + IN UINTN Address, + IN UINT64 Value + ) +{ + // + // Make sure Address is aligned on a 64-bit boundary. + // + ASSERT ((Address & 7) == 0); + return (UINT64)MmioWriteWorker (Address, SMM_IO_UINT64, Value); +} diff --git a/MdePkg/Library/SmmIoLibSmmCpuIo2/IoLibMmioBuffer.c b/MdePkg/Library/SmmIoLibSmmCpuIo2/IoLibMmioBuffer.c new file mode 100644 index 0000000000..35b6c0a8a7 --- /dev/null +++ b/MdePkg/Library/SmmIoLibSmmCpuIo2/IoLibMmioBuffer.c @@ -0,0 +1,413 @@ +/** @file + I/O Library MMIO Buffer Functions. + + Copyright (c) 2009 - 2010, Intel Corporation
+ All rights reserved. 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "SmmCpuIoLibInternal.h" + +/** + Copy data from MMIO region to system memory by using 8-bit access. + + Copy data from MMIO region specified by starting address StartAddress + to system memory specified by Buffer by using 8-bit access. The total + number of byte to be copied is specified by Length. Buffer is returned. + + If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + + @param StartAddress Starting address for the MMIO region to be copied from. + @param Length Size in bytes of the copy. + @param Buffer Pointer to a system memory buffer receiving the data read. + + @return Buffer + +**/ +UINT8 * +EFIAPI +MmioReadBuffer8 ( + IN UINTN StartAddress, + IN UINTN Length, + OUT UINT8 *Buffer + ) +{ + UINT8 *ReturnBuffer; + + ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer)); + + ReturnBuffer = Buffer; + + while (Length-- > 0) { + *(Buffer++) = MmioRead8 (StartAddress++); + } + + return ReturnBuffer; +} + +/** + Copy data from MMIO region to system memory by using 16-bit access. + + Copy data from MMIO region specified by starting address StartAddress + to system memory specified by Buffer by using 16-bit access. The total + number of byte to be copied is specified by Length. Buffer is returned. + + If StartAddress is not aligned on a 16-bit boundary, then ASSERT(). + + If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + If Length is not aligned on a 16-bit boundary, then ASSERT(). + + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + + @param StartAddress Starting address for the MMIO region to be copied from. + @param Length Size in bytes of the copy. + @param Buffer Pointer to a system memory buffer receiving the data read. + + @return Buffer + +**/ +UINT16 * +EFIAPI +MmioReadBuffer16 ( + IN UINTN StartAddress, + IN UINTN Length, + OUT UINT16 *Buffer + ) +{ + UINT16 *ReturnBuffer; + + ASSERT ((StartAddress & (sizeof (UINT16) - 1)) == 0); + + ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer)); + + ASSERT ((Length & (sizeof (UINT16) - 1)) == 0); + ASSERT (((UINTN) Buffer & (sizeof (UINT16) - 1)) == 0); + + ReturnBuffer = Buffer; + + while (Length > 0) { + *(Buffer++) = MmioRead16 (StartAddress); + StartAddress += sizeof (UINT16); + Length -= sizeof (UINT16); + } + + return ReturnBuffer; +} + +/** + Copy data from MMIO region to system memory by using 32-bit access. + + Copy data from MMIO region specified by starting address StartAddress + to system memory specified by Buffer by using 32-bit access. The total + number of byte to be copied is specified by Length. Buffer is returned. + + If StartAddress is not aligned on a 32-bit boundary, then ASSERT(). + + If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + If Length is not aligned on a 32-bit boundary, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + + @param StartAddress Starting address for the MMIO region to be copied from. + @param Length Size in bytes of the copy. + @param Buffer Pointer to a system memory buffer receiving the data read. + + @return Buffer + +**/ +UINT32 * +EFIAPI +MmioReadBuffer32 ( + IN UINTN StartAddress, + IN UINTN Length, + OUT UINT32 *Buffer + ) +{ + UINT32 *ReturnBuffer; + + ASSERT ((StartAddress & (sizeof (UINT32) - 1)) == 0); + + ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer)); + + ASSERT ((Length & (sizeof (UINT32) - 1)) == 0); + ASSERT (((UINTN) Buffer & (sizeof (UINT32) - 1)) == 0); + + ReturnBuffer = Buffer; + + while (Length > 0) { + *(Buffer++) = MmioRead32 (StartAddress); + StartAddress += sizeof (UINT32); + Length -= sizeof (UINT32); + } + + return ReturnBuffer; +} + +/** + Copy data from MMIO region to system memory by using 64-bit access. + + Copy data from MMIO region specified by starting address StartAddress + to system memory specified by Buffer by using 64-bit access. The total + number of byte to be copied is specified by Length. Buffer is returned. + + If StartAddress is not aligned on a 64-bit boundary, then ASSERT(). + + If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + If Length is not aligned on a 64-bit boundary, then ASSERT(). + + If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + + @param StartAddress Starting address for the MMIO region to be copied from. + @param Length Size in bytes of the copy. + @param Buffer Pointer to a system memory buffer receiving the data read. + + @return Buffer + +**/ +UINT64 * +EFIAPI +MmioReadBuffer64 ( + IN UINTN StartAddress, + IN UINTN Length, + OUT UINT64 *Buffer + ) +{ + UINT64 *ReturnBuffer; + + ASSERT ((StartAddress & (sizeof (UINT64) - 1)) == 0); + + ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer)); + + ASSERT ((Length & (sizeof (UINT64) - 1)) == 0); + ASSERT (((UINTN) Buffer & (sizeof (UINT64) - 1)) == 0); + + ReturnBuffer = Buffer; + + while (Length > 0) { + *(Buffer++) = MmioRead64 (StartAddress); + StartAddress += sizeof (UINT64); + Length -= sizeof (UINT64); + } + + return ReturnBuffer; +} + + +/** + Copy data from system memory to MMIO region by using 8-bit access. + + Copy data from system memory specified by Buffer to MMIO region specified + by starting address StartAddress by using 8-bit access. The total number + of byte to be copied is specified by Length. Buffer is returned. + + If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). + + + @param StartAddress Starting address for the MMIO region to be copied to. + @param Length Size in bytes of the copy. + @param Buffer Pointer to a system memory buffer containing the data to write. + + @return Buffer + +**/ +UINT8 * +EFIAPI +MmioWriteBuffer8 ( + IN UINTN StartAddress, + IN UINTN Length, + IN CONST UINT8 *Buffer + ) +{ + VOID* ReturnBuffer; + + ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer)); + + ReturnBuffer = (UINT8 *) Buffer; + + while (Length-- > 0) { + MmioWrite8 (StartAddress++, *(Buffer++)); + } + + return ReturnBuffer; + +} + +/** + Copy data from system memory to MMIO region by using 16-bit access. + + Copy data from system memory specified by Buffer to MMIO region specified + by starting address StartAddress by using 16-bit access. The total number + of byte to be copied is specified by Length. Buffer is returned. + + If StartAddress is not aligned on a 16-bit boundary, then ASSERT(). + + If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). + + If Length is not aligned on a 16-bit boundary, then ASSERT(). + + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + + @param StartAddress Starting address for the MMIO region to be copied to. + @param Length Size in bytes of the copy. + @param Buffer Pointer to a system memory buffer containing the data to write. + + @return Buffer + +**/ +UINT16 * +EFIAPI +MmioWriteBuffer16 ( + IN UINTN StartAddress, + IN UINTN Length, + IN CONST UINT16 *Buffer + ) +{ + UINT16 *ReturnBuffer; + + ASSERT ((StartAddress & (sizeof (UINT16) - 1)) == 0); + + ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer)); + + ASSERT ((Length & (sizeof (UINT16) - 1)) == 0); + ASSERT (((UINTN) Buffer & (sizeof (UINT16) - 1)) == 0); + + ReturnBuffer = (UINT16 *) Buffer; + + while (Length > 0) { + MmioWrite16 (StartAddress, *(Buffer++)); + + StartAddress += sizeof (UINT16); + Length -= sizeof (UINT16); + } + + return ReturnBuffer; +} + + +/** + Copy data from system memory to MMIO region by using 32-bit access. + + Copy data from system memory specified by Buffer to MMIO region specified + by starting address StartAddress by using 32-bit access. The total number + of byte to be copied is specified by Length. Buffer is returned. + + If StartAddress is not aligned on a 32-bit boundary, then ASSERT(). + + If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). + + If Length is not aligned on a 32-bit boundary, then ASSERT(). + + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + + @param StartAddress Starting address for the MMIO region to be copied to. + @param Length Size in bytes of the copy. + @param Buffer Pointer to a system memory buffer containing the data to write. + + @return Buffer + +**/ +UINT32 * +EFIAPI +MmioWriteBuffer32 ( + IN UINTN StartAddress, + IN UINTN Length, + IN CONST UINT32 *Buffer + ) +{ + UINT32 *ReturnBuffer; + + ASSERT ((StartAddress & (sizeof (UINT32) - 1)) == 0); + + ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer)); + + ASSERT ((Length & (sizeof (UINT32) - 1)) == 0); + ASSERT (((UINTN) Buffer & (sizeof (UINT32) - 1)) == 0); + + ReturnBuffer = (UINT32 *) Buffer; + + while (Length > 0) { + MmioWrite32 (StartAddress, *(Buffer++)); + + StartAddress += sizeof (UINT32); + Length -= sizeof (UINT32); + } + + return ReturnBuffer; +} + +/** + Copy data from system memory to MMIO region by using 64-bit access. + + Copy data from system memory specified by Buffer to MMIO region specified + by starting address StartAddress by using 64-bit access. The total number + of byte to be copied is specified by Length. Buffer is returned. + + If StartAddress is not aligned on a 64-bit boundary, then ASSERT(). + + If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). + + If Length is not aligned on a 64-bit boundary, then ASSERT(). + + If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + + @param StartAddress Starting address for the MMIO region to be copied to. + @param Length Size in bytes of the copy. + @param Buffer Pointer to a system memory buffer containing the data to write. + + @return Buffer + +**/ +UINT64 * +EFIAPI +MmioWriteBuffer64 ( + IN UINTN StartAddress, + IN UINTN Length, + IN CONST UINT64 *Buffer + ) +{ + UINT64 *ReturnBuffer; + + ASSERT ((StartAddress & (sizeof (UINT64) - 1)) == 0); + + ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer)); + + ASSERT ((Length & (sizeof (UINT64) - 1)) == 0); + ASSERT (((UINTN) Buffer & (sizeof (UINT64) - 1)) == 0); + + ReturnBuffer = (UINT64 *) Buffer; + + while (Length > 0) { + MmioWrite64 (StartAddress, *(Buffer++)); + + StartAddress += sizeof (UINT64); + Length -= sizeof (UINT64); + } + + return ReturnBuffer; +} + diff --git a/MdePkg/Library/SmmIoLibSmmCpuIo2/SmmCpuIoLibInternal.h b/MdePkg/Library/SmmIoLibSmmCpuIo2/SmmCpuIoLibInternal.h new file mode 100644 index 0000000000..70295af4e1 --- /dev/null +++ b/MdePkg/Library/SmmIoLibSmmCpuIo2/SmmCpuIoLibInternal.h @@ -0,0 +1,118 @@ +/** @file + Internal include file of SMM CPU IO Library. + It includes all necessary protocol/library class's header file + for implementation of IoLib library instance. It is included + all source code of this library instance. + + Copyright (c) 2009 - 2010, Intel Corporation + All rights reserved. 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _SMM_CPUIO_LIB_INTERNAL_H_ +#define _SMM_CPUIO_LIB_INTERNAL_H_ + +#include +#include +#include +#include +#include +#include +#include + + +/** + Reads registers in the EFI CPU I/O space. + + Reads the I/O port specified by Port with registers width specified by Width. + The read value is returned. If such operations are not supported, then ASSERT(). + This function must guarantee that all I/O read and write operations are serialized. + + @param Port The base address of the I/O operation. + The caller is responsible for aligning the Address if required. + @param Width The width of the I/O operation. + + @return Data read from registers in the EFI CPU I/O space. + +**/ +UINT64 +EFIAPI +IoReadWorker ( + IN UINTN Port, + IN EFI_SMM_IO_WIDTH Width + ); + +/** + Writes registers in the EFI CPU I/O space. + + Writes the I/O port specified by Port with registers width and value specified by Width + and Data respectively. Data is returned. If such operations are not supported, then ASSERT(). + This function must guarantee that all I/O read and write operations are serialized. + + @param Port The base address of the I/O operation. + The caller is responsible for aligning the Address if required. + @param Width The width of the I/O operation. + @param Data The value to write to the I/O port. + + @return The paramter of Data. + +**/ +UINT64 +EFIAPI +IoWriteWorker ( + IN UINTN Port, + IN EFI_SMM_IO_WIDTH Width, + IN UINT64 Data + ); + +/** + Reads memory-mapped registers in the EFI system memory space. + + Reads the MMIO registers specified by Address with registers width specified by Width. + The read value is returned. If such operations are not supported, then ASSERT(). + This function must guarantee that all MMIO read and write operations are serialized. + + @param Address The MMIO register to read. + The caller is responsible for aligning the Address if required. + @param Width The width of the I/O operation. + + @return Data read from registers in the EFI system memory space. + +**/ +UINT64 +EFIAPI +MmioReadWorker ( + IN UINTN Address, + IN EFI_SMM_IO_WIDTH Width + ); + +/** + Writes memory-mapped registers in the EFI system memory space. + + Writes the MMIO registers specified by Address with registers width and value specified by Width + and Data respectively. Data is returned. If such operations are not supported, then ASSERT(). + This function must guarantee that all MMIO read and write operations are serialized. + + @param Address The MMIO register to read. + The caller is responsible for aligning the Address if required. + @param Width The width of the I/O operation. + @param Data The value to write to the I/O port. + + @return Data read from registers in the EFI system memory space. + +**/ +UINT64 +EFIAPI +MmioWriteWorker ( + IN UINTN Address, + IN EFI_SMM_IO_WIDTH Width, + IN UINT64 Data + ); + +#endif diff --git a/MdePkg/Library/SmmIoLibSmmCpuIo2/SmmIoLibSmmCpuIo2.inf b/MdePkg/Library/SmmIoLibSmmCpuIo2/SmmIoLibSmmCpuIo2.inf new file mode 100644 index 0000000000..b9a34a40ee --- /dev/null +++ b/MdePkg/Library/SmmIoLibSmmCpuIo2/SmmIoLibSmmCpuIo2.inf @@ -0,0 +1,51 @@ +#/** @file +# Component description file for Cpu Io SMM Io Library. +# +# I/O Library implementation that uses the CPU I/O Protocol for I/O +# and MMIO operations. +# Copyright (c) 2009 - 2010, Intel Corporation. +# +# All rights reserved. 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 +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +#**/ + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = SmmIoLibSmmCpuIo2 + FILE_GUID = DEEEA15E-4A77-4513-BA75-71D26FEF78A1 + MODULE_TYPE = DXE_SMM_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = IoLib|DXE_SMM_DRIVER SMM_CORE + PI_SPECIFICATION_VERSION = 0x0001000A + CONSTRUCTOR = IoLibConstructor + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + IoLibMmioBuffer.c + SmmCpuIoLibInternal.h + IoHighLevel.c + IoLib.c + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib + DebugLib + SmmServicesTableLib + +[Protocols] + gEfiSmmCpuIo2ProtocolGuid ## CONSUMES + +[Depex] + gEfiSmmCpuIo2ProtocolGuid \ No newline at end of file diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 7fe6daa461..683eefedfe 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -5,7 +5,7 @@ # It also provides the definitions(including PPIs/PROTOCOLs/GUIDs) of # EFI1.10/UEFI2.0/UEFI2.1/PI1.0 and some Industry Standards. # -# Copyright (c) 2007 - 2009, Intel Corporation.
+# Copyright (c) 2007 - 2010, Intel Corporation.
# Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.
# # All rights reserved. @@ -661,8 +661,8 @@ ## Include/Protocol/SuperIo.h gEfiSioProtocolGuid = { 0x215fdd18, 0xbd50, 0x4feb, { 0x89, 0xb, 0x58, 0xca, 0xb, 0x47, 0x39, 0xe9 }} - ## Include/Protocol/SmmCpuIo.h - gEfiSmmCpuIoProtocolGuid = { 0x3242a9d8, 0xce70, 0x4aa0, { 0x95, 0x5d, 0x5e, 0x7b, 0x14, 0x0d, 0xe4, 0xd2 }} + ## Include/Protocol/SmmCpuIo2.h + gEfiSmmCpuIo2ProtocolGuid = { 0x3242a9d8, 0xce70, 0x4aa0, { 0x95, 0x5d, 0x5e, 0x7b, 0x14, 0x0d, 0xe4, 0xd2 }} ## Include/Protocol/SmmBase2.h gEfiSmmBase2ProtocolGuid = { 0xf4ccbfb7, 0xf6e0, 0x47fd, { 0x9d, 0xd4, 0x10, 0xa8, 0xf1, 0x50, 0xc1, 0x91 }} diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index 87f2ae2120..30298803d9 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -148,7 +148,7 @@ MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf - MdePkg/Library/SmmIoLibCpuIo/SmmIoLibCpuIo.inf + MdePkg/Library/SmmIoLibSmmCpuIo2/SmmIoLibSmmCpuIo2.inf MdePkg/Library/SmmPciLibPciRootBridgeIo/SmmPciLibPciRootBridgeIo.inf MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf -- cgit v1.2.3