Add support for arbitrary sized MMCONF by introducing a new PCD.
Add a return value to point out invalid PCI addresses.
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Marcello Sylvester Bauer <marcello.bauer@9elements.com>
Cc: Patrick Rudolph <patrick.rudolph@9elements.com>
Cc: Christian Walter <christian.walter@9elements.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Provides services to access PCI Configuration Space using the MMIO PCI Express window.\r
\r
This library is identical to the PCI Library, except the access method for performing PCI\r
- configuration cycles must be through the 256 MB PCI Express MMIO window whose base address\r
- is defined by PcdPciExpressBaseAddress.\r
+ configuration cycles must be through the PCI Express MMIO window whose base address\r
+ is defined by PcdPciExpressBaseAddress and size defined by PcdPciExpressBaseSize.\r
+\r
\r
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
## @file\r
-# Instance of PCI Express Library using the 256 MB PCI Express MMIO window.\r
+# Instance of PCI Express Library using the variable size PCI Express MMIO window.\r
#\r
-# PCI Express Library that uses the 256 MB PCI Express MMIO window to perform\r
+# PCI Express Library that uses the variable size PCI Express MMIO window to perform\r
# PCI Configuration cycles. Layers on top of an I/O Library instance.\r
#\r
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
\r
[Pcd]\r
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress ## CONSUMES\r
-\r
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize ## CONSUMES\r
\r
/**\r
Assert the validity of a PCI address. A valid PCI address should contain 1's\r
- only in the low 28 bits.\r
+ only in the low 28 bits. PcdPciExpressBaseSize limits the size to the real\r
+ number of PCI busses in this segment.\r
\r
@param A The address to validate.\r
\r
return (VOID*)(UINTN) PcdGet64 (PcdPciExpressBaseAddress);\r
}\r
\r
+/**\r
+ Gets the size of PCI Express.\r
+\r
+ This internal functions retrieves PCI Express Base Size via a PCD entry\r
+ PcdPciExpressBaseSize.\r
+\r
+ @return The base size of PCI Express.\r
+\r
+**/\r
+STATIC\r
+UINTN\r
+PcdPciExpressBaseSize (\r
+ VOID\r
+ )\r
+{\r
+ return (UINTN) PcdGet64 (PcdPciExpressBaseSize);\r
+}\r
+\r
/**\r
Reads an 8-bit PCI configuration register.\r
\r
@param Address The address that encodes the PCI Bus, Device, Function and\r
Register.\r
\r
- @return The read value from the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The read value from the PCI configuration register.\r
\r
**/\r
UINT8\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioRead8 ((UINTN) GetPciExpressBaseAddress () + Address);\r
}\r
\r
Register.\r
@param Value The value to write.\r
\r
- @return The value written to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written to the PCI configuration register.\r
\r
**/\r
UINT8\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioWrite8 ((UINTN) GetPciExpressBaseAddress () + Address, Value);\r
}\r
\r
Register.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written to the PCI configuration register.\r
\r
**/\r
UINT8\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioOr8 ((UINTN) GetPciExpressBaseAddress () + Address, OrData);\r
}\r
\r
Register.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioAnd8 ((UINTN) GetPciExpressBaseAddress () + Address, AndData);\r
}\r
\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioAndThenOr8 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
AndData,\r
@param EndBit The ordinal of the most significant bit in the bit field.\r
Range 0..7.\r
\r
- @return The value of the bit field read from the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value of the bit field read from the PCI configuration\r
+ register.\r
\r
**/\r
UINT8\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioBitFieldRead8 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
StartBit,\r
Range 0..7.\r
@param Value The new value of the bit field.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioBitFieldWrite8 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
StartBit,\r
Range 0..7.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioBitFieldOr8 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
StartBit,\r
Range 0..7.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioBitFieldAnd8 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
StartBit,\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioBitFieldAndThenOr8 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
StartBit,\r
@param Address The address that encodes the PCI Bus, Device, Function and\r
Register.\r
\r
- @return The read value from the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The read value from the PCI configuration register.\r
\r
**/\r
UINT16\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioRead16 ((UINTN) GetPciExpressBaseAddress () + Address);\r
}\r
\r
Register.\r
@param Value The value to write.\r
\r
- @return The value written to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written to the PCI configuration register.\r
\r
**/\r
UINT16\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioWrite16 ((UINTN) GetPciExpressBaseAddress () + Address, Value);\r
}\r
\r
Register.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioOr16 ((UINTN) GetPciExpressBaseAddress () + Address, OrData);\r
}\r
\r
Register.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioAnd16 ((UINTN) GetPciExpressBaseAddress () + Address, AndData);\r
}\r
\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioAndThenOr16 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
AndData,\r
@param EndBit The ordinal of the most significant bit in the bit field.\r
Range 0..15.\r
\r
- @return The value of the bit field read from the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value of the bit field read from the PCI configuration\r
+ register.\r
\r
**/\r
UINT16\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioBitFieldRead16 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
StartBit,\r
Range 0..15.\r
@param Value The new value of the bit field.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioBitFieldWrite16 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
StartBit,\r
Range 0..15.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioBitFieldOr16 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
StartBit,\r
Range 0..15.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioBitFieldAnd16 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
StartBit,\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioBitFieldAndThenOr16 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
StartBit,\r
@param Address The address that encodes the PCI Bus, Device, Function and\r
Register.\r
\r
- @return The read value from the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The read value from the PCI configuration register.\r
\r
**/\r
UINT32\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioRead32 ((UINTN) GetPciExpressBaseAddress () + Address);\r
}\r
\r
Register.\r
@param Value The value to write.\r
\r
- @return The value written to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written to the PCI configuration register.\r
\r
**/\r
UINT32\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioWrite32 ((UINTN) GetPciExpressBaseAddress () + Address, Value);\r
}\r
\r
Register.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioOr32 ((UINTN) GetPciExpressBaseAddress () + Address, OrData);\r
}\r
\r
Register.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioAnd32 ((UINTN) GetPciExpressBaseAddress () + Address, AndData);\r
}\r
\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioAndThenOr32 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
AndData,\r
@param EndBit The ordinal of the most significant bit in the bit field.\r
Range 0..31.\r
\r
- @return The value of the bit field read from the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value of the bit field read from the PCI\r
+ configuration register.\r
\r
**/\r
UINT32\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioBitFieldRead32 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
StartBit,\r
Range 0..31.\r
@param Value The new value of the bit field.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioBitFieldWrite32 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
StartBit,\r
Range 0..31.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioBitFieldOr32 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
StartBit,\r
Range 0..31.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioBitFieldAnd32 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
StartBit,\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
)\r
{\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= PcdPciExpressBaseSize()) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioBitFieldAndThenOr32 (\r
(UINTN) GetPciExpressBaseAddress () + Address,\r
StartBit,\r
@param Size The size in bytes of the transfer.\r
@param Buffer The pointer to a buffer receiving the data read.\r
\r
- @return Size read data from StartAddress.\r
+ @retval (UINTN)-1 Invalid PCI address.\r
+ @retval other Size read data from StartAddress.\r
\r
**/\r
UINTN\r
UINTN ReturnValue;\r
\r
ASSERT_INVALID_PCI_ADDRESS (StartAddress);\r
+ if (StartAddress >= PcdPciExpressBaseSize()) {\r
+ return (UINTN) -1;\r
+ }\r
ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);\r
\r
if (Size == 0) {\r
@param Size The size in bytes of the transfer.\r
@param Buffer The pointer to a buffer containing the data to write.\r
\r
- @return Size written to StartAddress.\r
+ @retval (UINTN)-1 Invalid PCI address.\r
+ @retval other Size written to StartAddress.\r
\r
**/\r
UINTN\r
UINTN ReturnValue;\r
\r
ASSERT_INVALID_PCI_ADDRESS (StartAddress);\r
+ if (StartAddress >= PcdPciExpressBaseSize()) {\r
+ return (UINTN) -1;\r
+ }\r
ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);\r
\r
if (Size == 0) {\r
\r
[Pcd]\r
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress ## CONSUMES\r
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize ## CONSUMES\r
#include <Library/DxeServicesTableLib.h>\r
#include <Library/UefiRuntimeLib.h>\r
\r
+/**\r
+ Assert the validity of a PCI address. A valid PCI address should contain 1's\r
+ only in the low 28 bits.\r
+\r
+ @param A The address to validate.\r
+\r
+**/\r
+#define ASSERT_INVALID_PCI_ADDRESS(A) \\r
+ ASSERT (((A) & ~0xfffffff) == 0)\r
+\r
///\r
/// Define table for mapping PCI Express MMIO physical addresses to virtual addresses at OS runtime\r
///\r
EFI_EVENT mDxeRuntimePciExpressLibVirtualNotifyEvent = NULL;\r
\r
///\r
-/// Module global that contains the base physical address of the PCI Express MMIO range.\r
+/// Module global that contains the base physical address and size of the PCI Express MMIO range.\r
///\r
UINTN mDxeRuntimePciExpressLibPciExpressBaseAddress = 0;\r
+UINTN mDxeRuntimePciExpressLibPciExpressBaseSize = 0;\r
\r
///\r
/// The number of PCI devices that have been registered for runtime access.\r
// Cache the physical address of the PCI Express MMIO range into a module global variable\r
//\r
mDxeRuntimePciExpressLibPciExpressBaseAddress = (UINTN) PcdGet64 (PcdPciExpressBaseAddress);\r
+ mDxeRuntimePciExpressLibPciExpressBaseSize = (UINTN) PcdGet64 (PcdPciExpressBaseSize);\r
\r
//\r
// Register SetVirtualAddressMap () notify function\r
This internal functions retrieves PCI Express Base Address via a PCD entry\r
PcdPciExpressBaseAddress.\r
\r
- @param Address The address that encodes the PCI Bus, Device, Function and Register.\r
- @return The base address of PCI Express.\r
+ If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+ @param Address The address that encodes the PCI Bus, Device, Function and Register.\r
+\r
+ @retval (UINTN)-1 Invalid PCI address.\r
+ @retval other The base address of PCI Express.\r
\r
**/\r
UINTN\r
//\r
// Make sure Address is valid\r
//\r
- ASSERT (((Address) & ~0xfffffff) == 0);\r
+ ASSERT_INVALID_PCI_ADDRESS (Address);\r
+\r
+ //\r
+ // Make sure the Address is in MMCONF address space\r
+ //\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINTN) -1;\r
+ }\r
\r
//\r
// Convert Address to a physical address in the MMIO PCI Express range\r
//\r
// No match was found. This is a critical error at OS runtime, so ASSERT() and force a breakpoint.\r
//\r
- ASSERT (FALSE);\r
CpuBreakpoint();\r
\r
//\r
//\r
// Make sure Address is valid\r
//\r
- ASSERT (((Address) & ~0xfffffff) == 0);\r
+ ASSERT_INVALID_PCI_ADDRESS (Address);\r
+\r
+ //\r
+ // Make sure the Address is in MMCONF address space\r
+ //\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return RETURN_UNSUPPORTED;\r
+ }\r
\r
//\r
// Convert Address to a physical address in the MMIO PCI Express range\r
\r
@param Address The address that encodes the PCI Bus, Device, Function and\r
Register.\r
-\r
- @return The read value from the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The read value from the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINTN Address\r
)\r
{\r
+ ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioRead8 (GetPciExpressAddress (Address));\r
}\r
\r
Register.\r
@param Value The value to write.\r
\r
- @return The value written to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written to the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINT8 Value\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioWrite8 (GetPciExpressAddress (Address), Value);\r
}\r
\r
Register.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINT8 OrData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioOr8 (GetPciExpressAddress (Address), OrData);\r
}\r
\r
Register.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINT8 AndData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioAnd8 (GetPciExpressAddress (Address), AndData);\r
}\r
\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINT8 OrData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioAndThenOr8 (\r
GetPciExpressAddress (Address),\r
AndData,\r
@param EndBit The ordinal of the most significant bit in the bit field.\r
Range 0..7.\r
\r
- @return The value of the bit field read from the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value of the bit field read from the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINTN EndBit\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioBitFieldRead8 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..7.\r
@param Value The new value of the bit field.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINT8 Value\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioBitFieldWrite8 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..7.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINT8 OrData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioBitFieldOr8 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..7.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINT8 AndData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioBitFieldAnd8 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINT8 OrData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioBitFieldAndThenOr8 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
@param Address The address that encodes the PCI Bus, Device, Function and\r
Register.\r
\r
- @return The read value from the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The read value from the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINTN Address\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioRead16 (GetPciExpressAddress (Address));\r
}\r
\r
Register.\r
@param Value The value to write.\r
\r
- @return The value written to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written to the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINT16 Value\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioWrite16 (GetPciExpressAddress (Address), Value);\r
}\r
\r
Register.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINT16 OrData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioOr16 (GetPciExpressAddress (Address), OrData);\r
}\r
\r
Register.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINT16 AndData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioAnd16 (GetPciExpressAddress (Address), AndData);\r
}\r
\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINT16 OrData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioAndThenOr16 (\r
GetPciExpressAddress (Address),\r
AndData,\r
@param EndBit The ordinal of the most significant bit in the bit field.\r
Range 0..15.\r
\r
- @return The value of the bit field read from the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value of the bit field read from the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINTN EndBit\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioBitFieldRead16 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..15.\r
@param Value The new value of the bit field.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINT16 Value\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioBitFieldWrite16 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..15.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINT16 OrData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioBitFieldOr16 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..15.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINT16 AndData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioBitFieldAnd16 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINT16 OrData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioBitFieldAndThenOr16 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
@param Address The address that encodes the PCI Bus, Device, Function and\r
Register.\r
\r
- @return The read value from the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The read value from the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINTN Address\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioRead32 (GetPciExpressAddress (Address));\r
}\r
\r
Register.\r
@param Value The value to write.\r
\r
- @return The value written to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written to the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINT32 Value\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioWrite32 (GetPciExpressAddress (Address), Value);\r
}\r
\r
Register.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINT32 OrData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioOr32 (GetPciExpressAddress (Address), OrData);\r
}\r
\r
Register.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINT32 AndData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioAnd32 (GetPciExpressAddress (Address), AndData);\r
}\r
\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINT32 OrData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioAndThenOr32 (\r
GetPciExpressAddress (Address),\r
AndData,\r
@param EndBit The ordinal of the most significant bit in the bit field.\r
Range 0..31.\r
\r
- @return The value of the bit field read from the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value of the bit field read from the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINTN EndBit\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioBitFieldRead32 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..31.\r
@param Value The new value of the bit field.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINT32 Value\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioBitFieldWrite32 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..31.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINT32 OrData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioBitFieldOr32 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..31.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINT32 AndData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioBitFieldAnd32 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINT32 OrData\r
)\r
{\r
+ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioBitFieldAndThenOr32 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
@param Size The size in bytes of the transfer.\r
@param Buffer The pointer to a buffer receiving the data read.\r
\r
- @return Size read data from StartAddress.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other Size read data from StartAddress.\r
\r
**/\r
UINTN\r
//\r
// Make sure Address is valid\r
//\r
- ASSERT (((StartAddress) & ~0xfffffff) == 0);\r
+ ASSERT_INVALID_PCI_ADDRESS (StartAddress);\r
ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);\r
\r
+ //\r
+ // Make sure the Address is in MMCONF address space\r
+ //\r
+ if (StartAddress >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINTN) -1;\r
+ }\r
+\r
if (Size == 0) {\r
return Size;\r
}\r
@param Size The size in bytes of the transfer.\r
@param Buffer The pointer to a buffer containing the data to write.\r
\r
- @return Size written to StartAddress.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other Size written to StartAddress.\r
\r
**/\r
UINTN\r
//\r
// Make sure Address is valid\r
//\r
- ASSERT (((StartAddress) & ~0xfffffff) == 0);\r
+ ASSERT_INVALID_PCI_ADDRESS (StartAddress);\r
ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);\r
\r
+ //\r
+ // Make sure the Address is in MMCONF address space\r
+ //\r
+ if (StartAddress >= mDxeRuntimePciExpressLibPciExpressBaseSize) {\r
+ return (UINTN) -1;\r
+ }\r
+\r
if (Size == 0) {\r
return 0;\r
}\r
#include <Library/PcdLib.h>\r
\r
///\r
-/// Module global that contains the base physical address of the PCI Express MMIO range.\r
+/// Module global that contains the base physical address and size of the PCI Express MMIO range.\r
///\r
UINTN mSmmPciExpressLibPciExpressBaseAddress = 0;\r
+UINTN mSmmPciExpressLibPciExpressBaseSize = 0;\r
\r
/**\r
The constructor function caches the PCI Express Base Address\r
)\r
{\r
//\r
- // Cache the physical address of the PCI Express MMIO range into a module global variable\r
+ // Cache the physical address and size of the PCI Express MMIO range into a module global variable\r
//\r
mSmmPciExpressLibPciExpressBaseAddress = (UINTN) PcdGet64 (PcdPciExpressBaseAddress);\r
+ mSmmPciExpressLibPciExpressBaseSize = (UINTN) PcdGet64 (PcdPciExpressBaseSize);\r
\r
return EFI_SUCCESS;\r
}\r
mSmmPciExpressLibPciExpressBaseAddress is initialized in the library constructor from PCD entry\r
PcdPciExpressBaseAddress.\r
\r
+ If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
@param Address The address that encodes the PCI Bus, Device, Function and Register.\r
- @return MMIO address corresponding to Address.\r
+\r
+ @retval (UINTN)-1 Invalid PCI address.\r
+ @retval other MMIO address corresponding to Address.\r
\r
**/\r
UINTN\r
// Make sure Address is valid\r
//\r
ASSERT_INVALID_PCI_ADDRESS (Address);\r
+ //\r
+ // Make sure the Address is in MMCONF address space\r
+ //\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINTN) -1;\r
+ }\r
return mSmmPciExpressLibPciExpressBaseAddress + Address;\r
}\r
\r
@param Address The address that encodes the PCI Bus, Device, Function and\r
Register.\r
\r
- @return The read value from the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The read value from the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINTN Address\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioRead8 (GetPciExpressAddress (Address));\r
}\r
\r
Register.\r
@param Value The value to write.\r
\r
- @return The value written to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written to the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINT8 Value\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioWrite8 (GetPciExpressAddress (Address), Value);\r
}\r
\r
Register.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINT8 OrData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioOr8 (GetPciExpressAddress (Address), OrData);\r
}\r
\r
Register.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINT8 AndData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioAnd8 (GetPciExpressAddress (Address), AndData);\r
}\r
\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINT8 OrData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioAndThenOr8 (\r
GetPciExpressAddress (Address),\r
AndData,\r
@param EndBit The ordinal of the most significant bit in the bit field.\r
Range 0..7.\r
\r
- @return The value of the bit field read from the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value of the bit field read from the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINTN EndBit\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioBitFieldRead8 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..7.\r
@param Value The new value of the bit field.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINT8 Value\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioBitFieldWrite8 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..7.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINT8 OrData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioBitFieldOr8 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..7.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINT8 AndData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioBitFieldAnd8 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT8\r
IN UINT8 OrData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT8) -1;\r
+ }\r
return MmioBitFieldAndThenOr8 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
@param Address The address that encodes the PCI Bus, Device, Function and\r
Register.\r
\r
- @return The read value from the PCI configuration register.\r
+ @retval 0xFF Invalid PCI address.\r
+ @retval other The read value from the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINTN Address\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioRead16 (GetPciExpressAddress (Address));\r
}\r
\r
Register.\r
@param Value The value to write.\r
\r
- @return The value written to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written to the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINT16 Value\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioWrite16 (GetPciExpressAddress (Address), Value);\r
}\r
\r
Register.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINT16 OrData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioOr16 (GetPciExpressAddress (Address), OrData);\r
}\r
\r
Register.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINT16 AndData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioAnd16 (GetPciExpressAddress (Address), AndData);\r
}\r
\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINT16 OrData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioAndThenOr16 (\r
GetPciExpressAddress (Address),\r
AndData,\r
@param EndBit The ordinal of the most significant bit in the bit field.\r
Range 0..15.\r
\r
- @return The value of the bit field read from the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value of the bit field read from the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINTN EndBit\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioBitFieldRead16 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..15.\r
@param Value The new value of the bit field.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINT16 Value\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioBitFieldWrite16 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..15.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINT16 OrData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioBitFieldOr16 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..15.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINT16 AndData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioBitFieldAnd16 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT16\r
IN UINT16 OrData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT16) -1;\r
+ }\r
return MmioBitFieldAndThenOr16 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
@param Address The address that encodes the PCI Bus, Device, Function and\r
Register.\r
\r
- @return The read value from the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The read value from the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINTN Address\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioRead32 (GetPciExpressAddress (Address));\r
}\r
\r
Register.\r
@param Value The value to write.\r
\r
- @return The value written to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written to the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINT32 Value\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioWrite32 (GetPciExpressAddress (Address), Value);\r
}\r
\r
Register.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINT32 OrData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioOr32 (GetPciExpressAddress (Address), OrData);\r
}\r
\r
Register.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINT32 AndData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioAnd32 (GetPciExpressAddress (Address), AndData);\r
}\r
\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINT32 OrData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioAndThenOr32 (\r
GetPciExpressAddress (Address),\r
AndData,\r
@param EndBit The ordinal of the most significant bit in the bit field.\r
Range 0..31.\r
\r
- @return The value of the bit field read from the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value of the bit field read from the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINTN EndBit\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioBitFieldRead32 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..31.\r
@param Value The new value of the bit field.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINT32 Value\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioBitFieldWrite32 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..31.\r
@param OrData The value to OR with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINT32 OrData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioBitFieldOr32 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
Range 0..31.\r
@param AndData The value to AND with the PCI configuration register.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINT32 AndData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioBitFieldAnd32 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
@param AndData The value to AND with the PCI configuration register.\r
@param OrData The value to OR with the result of the AND operation.\r
\r
- @return The value written back to the PCI configuration register.\r
+ @retval 0xFFFFFFFF Invalid PCI address.\r
+ @retval other The value written back to the PCI configuration register.\r
\r
**/\r
UINT32\r
IN UINT32 OrData\r
)\r
{\r
+ if (Address >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINT32) -1;\r
+ }\r
return MmioBitFieldAndThenOr32 (\r
GetPciExpressAddress (Address),\r
StartBit,\r
@param Size The size in bytes of the transfer.\r
@param Buffer The pointer to a buffer receiving the data read.\r
\r
- @return Size read data from StartAddress.\r
+ @retval (UINTN)-1 Invalid PCI address.\r
+ @retval other Size read data from StartAddress.\r
\r
**/\r
UINTN\r
ASSERT_INVALID_PCI_ADDRESS (StartAddress);\r
ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);\r
\r
+ //\r
+ // Make sure the Address is in MMCONF address space\r
+ //\r
+ if (StartAddress >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINTN) -1;\r
+ }\r
+\r
if (Size == 0) {\r
return Size;\r
}\r
@param Size The size in bytes of the transfer.\r
@param Buffer The pointer to a buffer containing the data to write.\r
\r
- @return Size written to StartAddress.\r
+ @retval (UINTN)-1 Invalid PCI address.\r
+ @retval other Size written to StartAddress.\r
\r
**/\r
UINTN\r
ASSERT_INVALID_PCI_ADDRESS (StartAddress);\r
ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);\r
\r
+ //\r
+ // Make sure the Address is in MMCONF address space\r
+ //\r
+ if (StartAddress >= mSmmPciExpressLibPciExpressBaseSize) {\r
+ return (UINTN) -1;\r
+ }\r
+\r
\r
if (Size == 0) {\r
return 0;\r
\r
[Pcd]\r
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress ## CONSUMES\r
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize ## CONSUMES\r
# @Prompt PCI Express Base Address.\r
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000|UINT64|0x0000000a\r
\r
+ ## This value is used to set the size of PCI express hierarchy. The default is 256 MB.\r
+ # @Prompt PCI Express Base Size.\r
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize|0x10000000|UINT64|0x0000000f\r
+\r
## Default current ISO 639-2 language: English & French.\r
# @Prompt Default Value of LangCodes Variable.\r
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangCodes|"engfraengfra"|VOID*|0x0000001c\r