/** @file\r
Provide services to access I/O Ports and MMIO registers.\r
\r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r
\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
/**\r
Macro that converts PCI Segment and I/O Port to an address that can be\r
passed to the I/O Library functions.\r
- \r
- Computes an address that is compatible with the I/O Library functions. \r
- The unused upper bits of Segment, and Port are stripped prior to the \r
+\r
+ Computes an address that is compatible with the I/O Library functions.\r
+ The unused upper bits of Segment, and Port are stripped prior to the\r
generation of the address.\r
- \r
+\r
@param Segment PCI Segment number. Range 0..65535.\r
@param Port I/O Port number. Range 0..65535.\r
- \r
+\r
@return An address that the I/o Library functions need.\r
\r
**/\r
);\r
\r
/**\r
- Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise \r
+ Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise\r
OR, and writes the result back to the 8-bit I/O port.\r
\r
Reads the 8-bit I/O port specified by Port, performs a bitwise AND between\r
\r
Writes Value to the bit field of the I/O register. The bit field is specified\r
by the StartBit and the EndBit. All other bits in the destination I/O\r
- register are preserved. The value written to the I/O port is returned. \r
+ register are preserved. The value written to the I/O port is returned.\r
\r
If 8-bit I/O port operations are not supported, then ASSERT().\r
If StartBit is greater than 7, then ASSERT().\r
\r
If 16-bit I/O port operations are not supported, then ASSERT().\r
If Port is not aligned on a 16-bit boundary, then ASSERT().\r
- \r
+\r
@param Port The I/O port to write.\r
@param Value The value to write to the I/O port.\r
\r
\r
If 16-bit I/O port operations are not supported, then ASSERT().\r
If Port is not aligned on a 16-bit boundary, then ASSERT().\r
- \r
+\r
@param Port The I/O port to write.\r
@param AndData The value to AND with the read value from the I/O port.\r
\r
);\r
\r
/**\r
- Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise \r
+ Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise\r
OR, and writes the result back to the 16-bit I/O port.\r
\r
Reads the 16-bit I/O port specified by Port, performs a bitwise AND between\r
\r
If 16-bit I/O port operations are not supported, then ASSERT().\r
If Port is not aligned on a 16-bit boundary, then ASSERT().\r
- \r
+\r
@param Port The I/O port to write.\r
@param AndData The value to AND with the read value from the I/O port.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
If 32-bit I/O port operations are not supported, then ASSERT().\r
If Port is not aligned on a 32-bit boundary, then ASSERT().\r
- \r
+\r
@param Port The I/O port to read.\r
\r
@return The value read.\r
\r
If 32-bit I/O port operations are not supported, then ASSERT().\r
If Port is not aligned on a 32-bit boundary, then ASSERT().\r
- \r
+\r
@param Port The I/O port to write.\r
@param Value The value to write to the I/O port.\r
\r
);\r
\r
/**\r
- Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise \r
+ Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise\r
OR, and writes the result back to the 32-bit I/O port.\r
\r
Reads the 32-bit I/O port specified by Port, performs a bitwise AND between\r
);\r
\r
/**\r
- Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise \r
+ Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise\r
OR, and writes the result back to the 64-bit I/O port.\r
\r
Reads the 64-bit I/O port specified by Port, performs a bitwise AND between\r
\r
@param Address The MMIO register to write.\r
@param Value The value to write to the MMIO register.\r
- \r
+\r
@return Value.\r
\r
**/\r
Reads an 8-bit MMIO register, performs a bitwise OR, and writes the\r
result back to the 8-bit MMIO register.\r
\r
- Reads the 8-bit MMIO register specified by Address, performs a bitwise \r
+ Reads the 8-bit MMIO register specified by Address, performs a bitwise\r
OR between the read result and the value specified by OrData, and\r
writes the result to the 8-bit MMIO register specified by Address. The value\r
written to the MMIO register is returned. This function must guarantee that\r
);\r
\r
/**\r
- Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise \r
+ Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise\r
OR, and writes the result back to the 8-bit MMIO register.\r
\r
Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r
Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and\r
writes the result back to the bit field in the 8-bit MMIO register.\r
\r
- Reads the 8-bit MMIO register specified by Address, performs a bitwise \r
+ Reads the 8-bit MMIO register specified by Address, performs a bitwise\r
OR between the read result and the value specified by OrData, and\r
writes the result to the 8-bit MMIO register specified by Address. The value\r
written to the MMIO register is returned. This function must guarantee that\r
\r
@param Address The MMIO register to write.\r
@param Value The value to write to the MMIO register.\r
- \r
+\r
@return Value.\r
\r
**/\r
Reads a 16-bit MMIO register, performs a bitwise OR, and writes the\r
result back to the 16-bit MMIO register.\r
\r
- Reads the 16-bit MMIO register specified by Address, performs a bitwise \r
+ Reads the 16-bit MMIO register specified by Address, performs a bitwise\r
OR between the read result and the value specified by OrData, and\r
writes the result to the 16-bit MMIO register specified by Address. The value\r
written to the MMIO register is returned. This function must guarantee that\r
);\r
\r
/**\r
- Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise \r
+ Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise\r
OR, and writes the result back to the 16-bit MMIO register.\r
\r
Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r
Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and\r
writes the result back to the bit field in the 16-bit MMIO register.\r
\r
- Reads the 16-bit MMIO register specified by Address, performs a bitwise \r
+ Reads the 16-bit MMIO register specified by Address, performs a bitwise\r
OR between the read result and the value specified by OrData, and\r
writes the result to the 16-bit MMIO register specified by Address. The value\r
written to the MMIO register is returned. This function must guarantee that\r
\r
@param Address The MMIO register to write.\r
@param Value The value to write to the MMIO register.\r
- \r
+\r
@return Value.\r
\r
**/\r
Reads a 32-bit MMIO register, performs a bitwise OR, and writes the\r
result back to the 32-bit MMIO register.\r
\r
- Reads the 32-bit MMIO register specified by Address, performs a bitwise \r
+ Reads the 32-bit MMIO register specified by Address, performs a bitwise\r
OR between the read result and the value specified by OrData, and\r
writes the result to the 32-bit MMIO register specified by Address. The value\r
written to the MMIO register is returned. This function must guarantee that\r
);\r
\r
/**\r
- Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise \r
+ Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise\r
OR, and writes the result back to the 32-bit MMIO register.\r
\r
Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r
Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and\r
writes the result back to the bit field in the 32-bit MMIO register.\r
\r
- Reads the 32-bit MMIO register specified by Address, performs a bitwise \r
+ Reads the 32-bit MMIO register specified by Address, performs a bitwise\r
OR between the read result and the value specified by OrData, and\r
writes the result to the 32-bit MMIO register specified by Address. The value\r
written to the MMIO register is returned. This function must guarantee that\r
Reads a 64-bit MMIO register, performs a bitwise OR, and writes the\r
result back to the 64-bit MMIO register.\r
\r
- Reads the 64-bit MMIO register specified by Address, performs a bitwise \r
+ Reads the 64-bit MMIO register specified by Address, performs a bitwise\r
OR between the read result and the value specified by OrData, and\r
writes the result to the 64-bit MMIO register specified by Address. The value\r
written to the MMIO register is returned. This function must guarantee that\r
);\r
\r
/**\r
- Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise \r
+ Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise\r
OR, and writes the result back to the 64-bit MMIO register.\r
\r
Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r
Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and\r
writes the result back to the bit field in the 64-bit MMIO register.\r
\r
- Reads the 64-bit MMIO register specified by Address, performs a bitwise \r
+ Reads the 64-bit MMIO register specified by Address, performs a bitwise\r
OR between the read result and the value specified by OrData, and\r
writes the result to the 64-bit MMIO register specified by Address. The value\r
written to the MMIO register is returned. This function must guarantee that\r
/**\r
Copy data from MMIO region to system memory by using 8-bit access.\r
\r
- Copy data from MMIO region specified by starting address StartAddress \r
- to system memory specified by Buffer by using 8-bit access. The total \r
+ Copy data from MMIO region specified by starting address StartAddress\r
+ to system memory specified by Buffer by using 8-bit access. The total\r
number of byte to be copied is specified by Length. Buffer is returned.\r
- \r
- If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). \r
+\r
+ If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().\r
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
\r
\r
/**\r
Copy data from MMIO region to system memory by using 16-bit access.\r
\r
- Copy data from MMIO region specified by starting address StartAddress \r
- to system memory specified by Buffer by using 16-bit access. The total \r
+ Copy data from MMIO region specified by starting address StartAddress\r
+ to system memory specified by Buffer by using 16-bit access. The total\r
number of byte to be copied is specified by Length. Buffer is returned.\r
- \r
+\r
If StartAddress is not aligned on a 16-bit boundary, then ASSERT().\r
\r
- If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). \r
+ If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().\r
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
\r
If Length is not aligned on a 16-bit boundary, then ASSERT().\r
/**\r
Copy data from MMIO region to system memory by using 32-bit access.\r
\r
- Copy data from MMIO region specified by starting address StartAddress \r
- to system memory specified by Buffer by using 32-bit access. The total \r
+ Copy data from MMIO region specified by starting address StartAddress\r
+ to system memory specified by Buffer by using 32-bit access. The total\r
number of byte to be copied is specified by Length. Buffer is returned.\r
- \r
+\r
If StartAddress is not aligned on a 32-bit boundary, then ASSERT().\r
\r
- If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). \r
+ If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().\r
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
\r
If Length is not aligned on a 32-bit boundary, then ASSERT().\r
/**\r
Copy data from MMIO region to system memory by using 64-bit access.\r
\r
- Copy data from MMIO region specified by starting address StartAddress \r
- to system memory specified by Buffer by using 64-bit access. The total \r
+ Copy data from MMIO region specified by starting address StartAddress\r
+ to system memory specified by Buffer by using 64-bit access. The total\r
number of byte to be copied is specified by Length. Buffer is returned.\r
- \r
+\r
If StartAddress is not aligned on a 64-bit boundary, then ASSERT().\r
\r
- If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). \r
+ If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().\r
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
\r
If Length is not aligned on a 64-bit boundary, then ASSERT().\r
/**\r
Copy data from system memory to MMIO region by using 8-bit access.\r
\r
- Copy data from system memory specified by Buffer to MMIO region specified \r
- by starting address StartAddress by using 8-bit access. The total number \r
+ Copy data from system memory specified by Buffer to MMIO region specified\r
+ by starting address StartAddress by using 8-bit access. The total number\r
of byte to be copied is specified by Length. Buffer is returned.\r
- \r
- If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). \r
+\r
+ If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().\r
If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().\r
\r
\r
/**\r
Copy data from system memory to MMIO region by using 16-bit access.\r
\r
- Copy data from system memory specified by Buffer to MMIO region specified \r
- by starting address StartAddress by using 16-bit access. The total number \r
+ Copy data from system memory specified by Buffer to MMIO region specified\r
+ by starting address StartAddress by using 16-bit access. The total number\r
of byte to be copied is specified by Length. Buffer is returned.\r
- \r
+\r
If StartAddress is not aligned on a 16-bit boundary, then ASSERT().\r
\r
- If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). \r
+ If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().\r
If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().\r
\r
If Length is not aligned on a 16-bit boundary, then ASSERT().\r
/**\r
Copy data from system memory to MMIO region by using 32-bit access.\r
\r
- Copy data from system memory specified by Buffer to MMIO region specified \r
- by starting address StartAddress by using 32-bit access. The total number \r
+ Copy data from system memory specified by Buffer to MMIO region specified\r
+ by starting address StartAddress by using 32-bit access. The total number\r
of byte to be copied is specified by Length. Buffer is returned.\r
- \r
+\r
If StartAddress is not aligned on a 32-bit boundary, then ASSERT().\r
\r
- If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). \r
+ If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().\r
If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().\r
\r
If Length is not aligned on a 32-bit boundary, then ASSERT().\r
/**\r
Copy data from system memory to MMIO region by using 64-bit access.\r
\r
- Copy data from system memory specified by Buffer to MMIO region specified \r
- by starting address StartAddress by using 64-bit access. The total number \r
+ Copy data from system memory specified by Buffer to MMIO region specified\r
+ by starting address StartAddress by using 64-bit access. The total number\r
of byte to be copied is specified by Length. Buffer is returned.\r
- \r
+\r
If StartAddress is not aligned on a 64-bit boundary, then ASSERT().\r
\r
- If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). \r
+ If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().\r
If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().\r
\r
If Length is not aligned on a 64-bit boundary, then ASSERT().\r