\r
The PCI Root Bridge header file.\r
\r
-Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved.<BR>\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
+Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
//\r
// Driver Consumed Protocol Prototypes\r
//\r
-#include <Protocol/Metronome.h>\r
#include <Protocol/CpuIo2.h>\r
#include <Protocol/DevicePath.h>\r
#include <Protocol/PciRootBridgeIo.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
#include <Library/BaseLib.h>\r
#include <Library/PciSegmentLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/TimerLib.h>\r
#include "PciHostResource.h"\r
\r
-\r
typedef enum {\r
IoOperation,\r
MemOperation,\r
\r
#define MAP_INFO_SIGNATURE SIGNATURE_32 ('_', 'm', 'a', 'p')\r
typedef struct {\r
- UINT32 Signature;\r
- LIST_ENTRY Link;\r
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation;\r
- UINTN NumberOfBytes;\r
- UINTN NumberOfPages;\r
- EFI_PHYSICAL_ADDRESS HostAddress;\r
- EFI_PHYSICAL_ADDRESS MappedHostAddress;\r
+ UINT32 Signature;\r
+ LIST_ENTRY Link;\r
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation;\r
+ UINTN NumberOfBytes;\r
+ UINTN NumberOfPages;\r
+ EFI_PHYSICAL_ADDRESS HostAddress;\r
+ EFI_PHYSICAL_ADDRESS MappedHostAddress;\r
} MAP_INFO;\r
-#define MAP_INFO_FROM_LINK(a) CR (a, MAP_INFO, Link, MAP_INFO_SIGNATURE)\r
+#define MAP_INFO_FROM_LINK(a) CR (a, MAP_INFO, Link, MAP_INFO_SIGNATURE)\r
\r
-#define PCI_ROOT_BRIDGE_SIGNATURE SIGNATURE_32 ('_', 'p', 'r', 'b')\r
+#define PCI_ROOT_BRIDGE_SIGNATURE SIGNATURE_32 ('_', 'p', 'r', 'b')\r
\r
typedef struct {\r
- UINT32 Signature;\r
- LIST_ENTRY Link;\r
- EFI_HANDLE Handle;\r
- UINT64 AllocationAttributes;\r
- UINT64 Attributes;\r
- UINT64 Supports;\r
- PCI_RES_NODE ResAllocNode[TypeMax];\r
- PCI_ROOT_BRIDGE_APERTURE Bus;\r
- PCI_ROOT_BRIDGE_APERTURE Io;\r
- PCI_ROOT_BRIDGE_APERTURE Mem;\r
- PCI_ROOT_BRIDGE_APERTURE PMem;\r
- PCI_ROOT_BRIDGE_APERTURE MemAbove4G;\r
- PCI_ROOT_BRIDGE_APERTURE PMemAbove4G;\r
- BOOLEAN DmaAbove4G;\r
- VOID *ConfigBuffer;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- CHAR16 *DevicePathStr;\r
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL RootBridgeIo;\r
-\r
- BOOLEAN ResourceSubmitted;\r
- LIST_ENTRY Maps;\r
+ UINT32 Signature;\r
+ LIST_ENTRY Link;\r
+ EFI_HANDLE Handle;\r
+ UINT64 AllocationAttributes;\r
+ UINT64 Attributes;\r
+ UINT64 Supports;\r
+ PCI_RES_NODE ResAllocNode[TypeMax];\r
+ PCI_ROOT_BRIDGE_APERTURE Bus;\r
+ PCI_ROOT_BRIDGE_APERTURE Io;\r
+ PCI_ROOT_BRIDGE_APERTURE Mem;\r
+ PCI_ROOT_BRIDGE_APERTURE PMem;\r
+ PCI_ROOT_BRIDGE_APERTURE MemAbove4G;\r
+ PCI_ROOT_BRIDGE_APERTURE PMemAbove4G;\r
+ BOOLEAN DmaAbove4G;\r
+ BOOLEAN NoExtendedConfigSpace;\r
+ VOID *ConfigBuffer;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ CHAR16 *DevicePathStr;\r
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL RootBridgeIo;\r
+\r
+ BOOLEAN ResourceSubmitted;\r
+ LIST_ENTRY Maps;\r
} PCI_ROOT_BRIDGE_INSTANCE;\r
\r
-#define ROOT_BRIDGE_FROM_THIS(a) CR (a, PCI_ROOT_BRIDGE_INSTANCE, RootBridgeIo, PCI_ROOT_BRIDGE_SIGNATURE)\r
+#define ROOT_BRIDGE_FROM_THIS(a) CR (a, PCI_ROOT_BRIDGE_INSTANCE, RootBridgeIo, PCI_ROOT_BRIDGE_SIGNATURE)\r
\r
-#define ROOT_BRIDGE_FROM_LINK(a) CR (a, PCI_ROOT_BRIDGE_INSTANCE, Link, PCI_ROOT_BRIDGE_SIGNATURE)\r
+#define ROOT_BRIDGE_FROM_LINK(a) CR (a, PCI_ROOT_BRIDGE_INSTANCE, Link, PCI_ROOT_BRIDGE_SIGNATURE)\r
\r
/**\r
+ Construct the Pci Root Bridge instance.\r
\r
- Construct the Pci Root Bridge Io protocol.\r
-\r
- @param Protocol - Protocol to initialize.\r
- @param HostBridgeHandle - Handle to the HostBridge.\r
-\r
- @retval EFI_SUCCESS - Success.\r
- @retval Others - Fail.\r
+ @param Bridge The root bridge instance.\r
\r
+ @return The pointer to PCI_ROOT_BRIDGE_INSTANCE just created\r
+ or NULL if creation fails.\r
**/\r
PCI_ROOT_BRIDGE_INSTANCE *\r
CreateRootBridge (\r
- IN PCI_ROOT_BRIDGE *Bridge,\r
- IN EFI_HANDLE HostBridgeHandle\r
+ IN PCI_ROOT_BRIDGE *Bridge\r
);\r
\r
//\r
// Protocol Member Function Prototypes\r
//\r
+\r
/**\r
\r
Poll an address in memory mapped space until an exit condition is met\r
EFI_STATUS\r
EFIAPI\r
RootBridgeIoCopyMem (\r
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r
- IN UINT64 DestAddress,\r
- IN UINT64 SrcAddress,\r
- IN UINTN Count\r
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r
+ IN UINT64 DestAddress,\r
+ IN UINT64 SrcAddress,\r
+ IN UINTN Count\r
)\r
;\r
\r
;\r
\r
/**\r
-\r
Provides the PCI controller-specific address needed to access\r
system memory for DMA.\r
\r
- @param This - A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
- @param Operation - Indicate if the bus master is going to read or write\r
- to system memory.\r
- @param HostAddress - The system memory address to map on the PCI controller.\r
- @param NumberOfBytes - On input the number of bytes to map.\r
- On output the number of bytes that were mapped.\r
- @param DeviceAddress - The resulting map address for the bus master PCI\r
- controller to use to access the system memory's HostAddress.\r
- @param Mapping - The value to pass to Unmap() when the bus master DMA\r
- operation is complete.\r
-\r
- @retval EFI_SUCCESS - Success.\r
- @retval EFI_INVALID_PARAMETER - Invalid parameters found.\r
- @retval EFI_UNSUPPORTED - The HostAddress cannot be mapped as a common\r
- @retval buffer.\r
- @retval EFI_DEVICE_ERROR - The System hardware could not map the requested\r
- @retval address.\r
- @retval EFI_OUT_OF_RESOURCES - The request could not be completed due to\r
- @retval lack of resources.\r
-\r
+ @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
+ @param Operation Indicate if the bus master is going to read or write\r
+ to system memory.\r
+ @param HostAddress The system memory address to map on the PCI controller.\r
+ @param NumberOfBytes On input the number of bytes to map.\r
+ On output the number of bytes that were mapped.\r
+ @param DeviceAddress The resulting map address for the bus master PCI\r
+ controller to use to access the system memory's HostAddress.\r
+ @param Mapping The value to pass to Unmap() when the bus master DMA\r
+ operation is complete.\r
+\r
+ @retval EFI_SUCCESS Success.\r
+ @retval EFI_INVALID_PARAMETER Invalid parameters found.\r
+ @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.\r
+ @retval EFI_DEVICE_ERROR The System hardware could not map the requested address.\r
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to lack of resources.\r
**/\r
EFI_STATUS\r
EFIAPI\r
;\r
\r
/**\r
-\r
Completes the Map() operation and releases any corresponding resources.\r
\r
- @param This - Pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL instance.\r
- Mapping - The value returned from Map() operation.\r
+ The Unmap() function completes the Map() operation and releases any\r
+ corresponding resources.\r
+ If the operation was an EfiPciOperationBusMasterWrite or\r
+ EfiPciOperationBusMasterWrite64, the data is committed to the target system\r
+ memory.\r
+ Any resources used for the mapping are freed.\r
\r
- @retval EFI_SUCCESS - The range was unmapped successfully.\r
- @retval EFI_INVALID_PARAMETER - Mapping is not a value that was returned\r
- @retval by Map operation.\r
- @retval EFI_DEVICE_ERROR - The data was not committed to the target\r
- @retval system memory.\r
+ @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
+ @param[in] Mapping The mapping value returned from Map().\r
\r
+ @retval EFI_SUCCESS The range was unmapped.\r
+ @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by Map().\r
+ @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.\r
**/\r
EFI_STATUS\r
EFIAPI\r
;\r
\r
/**\r
-\r
- Allocates pages that are suitable for a common buffer mapping.\r
-\r
- @param This - Pointer to EFI_ROOT_BRIDGE_IO_PROTOCOL instance.\r
- @param Type - Not used and can be ignored.\r
- @param MemoryType - Type of memory to allocate.\r
- @param Pages - Number of pages to allocate.\r
- @param HostAddress - Pointer to store the base system memory address\r
- of the allocated range.\r
- @param Attributes - Requested bit mask of attributes of the allocated\r
- range.\r
-\r
- @retval EFI_SUCCESS - The requested memory range were allocated.\r
- @retval EFI_INVALID_PARAMETER - Invalid parameter found.\r
- @retval EFI_UNSUPPORTED - Attributes is unsupported.\r
-\r
+ Allocates pages that are suitable for an EfiPciOperationBusMasterCommonBuffer\r
+ or EfiPciOperationBusMasterCommonBuffer64 mapping.\r
+\r
+ @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
+ @param Type This parameter is not used and must be ignored.\r
+ @param MemoryType The type of memory to allocate, EfiBootServicesData or\r
+ EfiRuntimeServicesData.\r
+ @param Pages The number of pages to allocate.\r
+ @param HostAddress A pointer to store the base system memory address of the\r
+ allocated range.\r
+ @param Attributes The requested bit mask of attributes for the allocated\r
+ range. Only the attributes\r
+ EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE,\r
+ EFI_PCI_ATTRIBUTE_MEMORY_CACHED, and\r
+ EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE may be used with this\r
+ function.\r
+\r
+ @retval EFI_SUCCESS The requested memory pages were allocated.\r
+ @retval EFI_INVALID_PARAMETER MemoryType is invalid.\r
+ @retval EFI_INVALID_PARAMETER HostAddress is NULL.\r
+ @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal\r
+ attribute bits are MEMORY_WRITE_COMBINE,\r
+ MEMORY_CACHED, and DUAL_ADDRESS_CYCLE.\r
+ @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.\r
**/\r
EFI_STATUS\r
EFIAPI\r
;\r
\r
/**\r
-\r
- Get the attributes that a PCI root bridge supports and\r
- the attributes the PCI root bridge is currently using.\r
-\r
- @param This - Pointer to EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL\r
- instance.\r
- @param Supports - A pointer to the mask of attributes that\r
- this PCI root bridge supports.\r
- @param Attributes - A pointer to the mask of attributes that\r
- this PCI root bridge is currently using.\r
- @retval EFI_SUCCESS - Success.\r
- @retval EFI_INVALID_PARAMETER - Invalid parameter found.\r
-\r
+ Gets the attributes that a PCI root bridge supports setting with\r
+ SetAttributes(), and the attributes that a PCI root bridge is currently\r
+ using.\r
+\r
+ The GetAttributes() function returns the mask of attributes that this PCI\r
+ root bridge supports and the mask of attributes that the PCI root bridge is\r
+ currently using.\r
+\r
+ @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
+ @param Supported A pointer to the mask of attributes that this PCI root\r
+ bridge supports setting with SetAttributes().\r
+ @param Attributes A pointer to the mask of attributes that this PCI root\r
+ bridge is currently using.\r
+\r
+ @retval EFI_SUCCESS If Supports is not NULL, then the attributes\r
+ that the PCI root bridge supports is returned\r
+ in Supports. If Attributes is not NULL, then\r
+ the attributes that the PCI root bridge is\r
+ currently using is returned in Attributes.\r
+ @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL.\r
**/\r
EFI_STATUS\r
EFIAPI\r
/**\r
\r
Retrieves the current resource settings of this PCI root bridge\r
- in the form of a set of ACPI 2.0 resource descriptor.\r
+ in the form of a set of ACPI resource descriptor.\r
\r
@param This - Pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL instance.\r
- @param Resources - Pointer to the ACPI 2.0 resource descriptor that\r
+ @param Resources - Pointer to the resource descriptor that\r
describe the current configuration of this PCI root\r
bridge.\r
\r
)\r
;\r
\r
-\r
-extern EFI_METRONOME_ARCH_PROTOCOL *mMetronome;\r
-extern EFI_CPU_IO2_PROTOCOL *mCpuIo;\r
+extern EFI_CPU_IO2_PROTOCOL *mCpuIo;\r
#endif\r