TianoCore EDK2 master
Loading...
Searching...
No Matches
PciHostBridge.c File Reference
#include "PciHostBridge.h"
#include "PciRootBridge.h"
#include "PciHostResource.h"

Go to the source code of this file.

Functions

UINT64 GetTranslationByResourceType (IN PCI_ROOT_BRIDGE_INSTANCE *RootBridge, IN PCI_RESOURCE_TYPE ResourceType)
 
EFI_STATUS IntersectIoDescriptor (IN UINT64 Base, IN UINT64 Length, IN CONST EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor)
 
EFI_STATUS AddIoSpace (IN UINT64 Base, IN UINT64 Length)
 
EFI_STATUS IntersectMemoryDescriptor (IN UINT64 Base, IN UINT64 Length, IN UINT64 Capabilities, IN CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor)
 
EFI_STATUS AddMemoryMappedIoSpace (IN UINT64 Base, IN UINT64 Length, IN UINT64 Capabilities)
 
VOID EFIAPI IoMmuProtocolCallback (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS EFIAPI InitializePciHostBridge (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
VOID ResourceConflict (IN PCI_HOST_BRIDGE_INSTANCE *HostBridge)
 
UINT64 AllocateResource (BOOLEAN Mmio, UINT64 Length, UINTN BitsOfAlignment, UINT64 BaseAddress, UINT64 Limit)
 
EFI_STATUS EFIAPI NotifyPhase (IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase)
 
EFI_STATUS EFIAPI GetNextRootBridge (IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, IN OUT EFI_HANDLE *RootBridgeHandle)
 
EFI_STATUS EFIAPI GetAttributes (IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, IN EFI_HANDLE RootBridgeHandle, OUT UINT64 *Attributes)
 
EFI_STATUS EFIAPI StartBusEnumeration (IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, IN EFI_HANDLE RootBridgeHandle, OUT VOID **Configuration)
 
EFI_STATUS EFIAPI SetBusNumbers (IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, IN EFI_HANDLE RootBridgeHandle, IN VOID *Configuration)
 
EFI_STATUS EFIAPI SubmitResources (IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, IN EFI_HANDLE RootBridgeHandle, IN VOID *Configuration)
 
EFI_STATUS EFIAPI GetProposedResources (IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, IN EFI_HANDLE RootBridgeHandle, OUT VOID **Configuration)
 
EFI_STATUS EFIAPI PreprocessController (IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, IN EFI_HANDLE RootBridgeHandle, IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress, IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase)
 

Variables

EFI_CPU_IO2_PROTOCOLmCpuIo
 
GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 * mAcpiAddressSpaceTypeStr []
 
GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 * mPciResourceTypeStr []
 
EDKII_IOMMU_PROTOCOLmIoMmu
 
EFI_EVENT mIoMmuEvent
 
VOID * mIoMmuRegistration
 

Detailed Description

Provides the basic interfaces to abstract a PCI Host Bridge Resource Allocation.

Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file PciHostBridge.c.

Function Documentation

◆ AddIoSpace()

EFI_STATUS AddIoSpace ( IN UINT64  Base,
IN UINT64  Length 
)

Add IO space to GCD. The routine checks the GCD database and only adds those which are not added in the specified range to GCD.

Parameters
BaseBase address of the IO space.
LengthLength of the IO space.
Return values
EFI_SUCCESThe IO space was added successfully.

Definition at line 165 of file PciHostBridge.c.

◆ AddMemoryMappedIoSpace()

EFI_STATUS AddMemoryMappedIoSpace ( IN UINT64  Base,
IN UINT64  Length,
IN UINT64  Capabilities 
)

Add MMIO space to GCD. The routine checks the GCD database and only adds those which are not added in the specified range to GCD.

Parameters
BaseBase address of the MMIO space.
LengthLength of the MMIO space.
CapabilitiesCapabilities of the MMIO space.
Return values
EFI_SUCCESThe MMIO space was added successfully.

Definition at line 339 of file PciHostBridge.c.

◆ AllocateResource()

UINT64 AllocateResource ( BOOLEAN  Mmio,
UINT64  Length,
UINTN  BitsOfAlignment,
UINT64  BaseAddress,
UINT64  Limit 
)

Allocate Length of MMIO or IO resource with alignment BitsOfAlignment from GCD range [BaseAddress, Limit).

Parameters
MmioTRUE for MMIO and FALSE for IO.
LengthLength of the resource to allocate.
BitsOfAlignmentAlignment of the resource to allocate.
BaseAddressThe starting address the allocation is from.
LimitThe ending address the allocation is to.
Return values
Thebase address of the allocated resource or MAX_UINT64 if allocation fails.

Definition at line 753 of file PciHostBridge.c.

◆ GetAttributes()

EFI_STATUS EFIAPI GetAttributes ( IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL This,
IN EFI_HANDLE  RootBridgeHandle,
OUT UINT64 *  Attributes 
)

Returns the attributes of a PCI Root Bridge.

Parameters
ThisThe EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
RootBridgeHandleThe device handle of the PCI Root Bridge that the caller is interested in.
AttributesThe pointer to attributes of the PCI Root Bridge.
Return values
EFI_SUCCESSSucceed.
EFI_INVALID_PARAMETERAttributes parameter passed in is NULL or RootBridgeHandle is not an EFI_HANDLE that was returned on a previous call to GetNextRootBridge().

Definition at line 1271 of file PciHostBridge.c.

◆ GetNextRootBridge()

EFI_STATUS EFIAPI GetNextRootBridge ( IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL This,
IN OUT EFI_HANDLE RootBridgeHandle 
)

Return the device handle of the next PCI root bridge that is associated with this Host Bridge.

Parameters
ThisThe EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
RootBridgeHandleReturns the device handle of the next PCI Root Bridge. On input, it holds the RootBridgeHandle returned by the most recent call to GetNextRootBridge().The handle for the first PCI Root Bridge is returned if RootBridgeHandle is NULL on input.
Return values
EFI_SUCCESSSucceed.
EFI_NOT_FOUNDNext PCI root bridge not found.
EFI_INVALID_PARAMETERWrong parameter passed in.

Definition at line 1214 of file PciHostBridge.c.

◆ GetProposedResources()

EFI_STATUS EFIAPI GetProposedResources ( IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL This,
IN EFI_HANDLE  RootBridgeHandle,
OUT VOID **  Configuration 
)

This function returns the proposed resource settings for the specified PCI Root Bridge.

Parameters
ThisThe EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
RootBridgeHandleThe PCI Root Bridge handle.
ConfigurationThe pointer to the pointer to the PCI I/O and memory resource descriptor.
Return values
EFI_SUCCESSSucceed.
EFI_OUT_OF_RESOURCESNot enough pool to be allocated.
EFI_INVALID_PARAMETERRootBridgeHandle is not a valid handle.

Definition at line 1599 of file PciHostBridge.c.

◆ GetTranslationByResourceType()

UINT64 GetTranslationByResourceType ( IN PCI_ROOT_BRIDGE_INSTANCE RootBridge,
IN PCI_RESOURCE_TYPE  ResourceType 
)

This routine gets translation offset from a root bridge instance by resource type.

Parameters
RootBridgeThe Root Bridge Instance for the resources.
ResourceTypeThe Resource Type of the translation offset.
Return values
TheTranslation Offset of the specified resource.

Definition at line 36 of file PciHostBridge.c.

◆ InitializePciHostBridge()

EFI_STATUS EFIAPI InitializePciHostBridge ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Entry point of this driver.

Parameters
ImageHandleImage handle of this driver.
SystemTablePointer to standard EFI system table.
Return values
EFI_SUCCESSSucceed.
EFI_DEVICE_ERRORFail to install PCI_ROOT_BRIDGE_IO protocol.

Definition at line 437 of file PciHostBridge.c.

◆ IntersectIoDescriptor()

EFI_STATUS IntersectIoDescriptor ( IN UINT64  Base,
IN UINT64  Length,
IN CONST EFI_GCD_IO_SPACE_DESCRIPTOR Descriptor 
)

Ensure the compatibility of an IO space descriptor with the IO aperture.

The IO space descriptor can come from the GCD IO space map, or it can represent a gap between two neighboring IO space descriptors. In the latter case, the GcdIoType field is expected to be EfiGcdIoTypeNonExistent.

If the IO space descriptor already has type EfiGcdIoTypeIo, then no action is taken – it is by definition compatible with the aperture.

Otherwise, the intersection of the IO space descriptor is calculated with the aperture. If the intersection is the empty set (no overlap), no action is taken; the IO space descriptor is compatible with the aperture.

Otherwise, the type of the descriptor is investigated again. If the type is EfiGcdIoTypeNonExistent (representing a gap, or a genuine descriptor with such a type), then an attempt is made to add the intersection as IO space to the GCD IO space map. This ensures continuity for the aperture, and the descriptor is deemed compatible with the aperture.

Otherwise, the IO space descriptor is incompatible with the IO aperture.

Parameters
[in]BaseBase address of the aperture.
[in]LengthLength of the aperture.
[in]DescriptorThe descriptor to ensure compatibility with the aperture for.
Return values
EFI_SUCCESSThe descriptor is compatible. The GCD IO space map may have been updated, for continuity within the aperture.
EFI_INVALID_PARAMETERThe descriptor is incompatible.
Returns
Error codes from gDS->AddIoSpace().

Definition at line 94 of file PciHostBridge.c.

◆ IntersectMemoryDescriptor()

EFI_STATUS IntersectMemoryDescriptor ( IN UINT64  Base,
IN UINT64  Length,
IN UINT64  Capabilities,
IN CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor 
)

Ensure the compatibility of a memory space descriptor with the MMIO aperture.

The memory space descriptor can come from the GCD memory space map, or it can represent a gap between two neighboring memory space descriptors. In the latter case, the GcdMemoryType field is expected to be EfiGcdMemoryTypeNonExistent.

If the memory space descriptor already has type EfiGcdMemoryTypeMemoryMappedIo, and its capabilities are a superset of the required capabilities, then no action is taken – it is by definition compatible with the aperture.

Otherwise, the intersection of the memory space descriptor is calculated with the aperture. If the intersection is the empty set (no overlap), no action is taken; the memory space descriptor is compatible with the aperture.

Otherwise, the type of the descriptor is investigated again. If the type is EfiGcdMemoryTypeNonExistent (representing a gap, or a genuine descriptor with such a type), then an attempt is made to add the intersection as MMIO space to the GCD memory space map, with the specified capabilities. This ensures continuity for the aperture, and the descriptor is deemed compatible with the aperture.

Otherwise, the memory space descriptor is incompatible with the MMIO aperture.

Parameters
[in]BaseBase address of the aperture.
[in]LengthLength of the aperture.
[in]CapabilitiesCapabilities required by the aperture.
[in]DescriptorThe descriptor to ensure compatibility with the aperture for.
Return values
EFI_SUCCESSThe descriptor is compatible. The GCD memory space map may have been updated, for continuity within the aperture.
EFI_INVALID_PARAMETERThe descriptor is incompatible.
Returns
Error codes from gDS->AddMemorySpace().

Definition at line 261 of file PciHostBridge.c.

◆ IoMmuProtocolCallback()

VOID EFIAPI IoMmuProtocolCallback ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Event notification that is fired when IOMMU protocol is installed.

Parameters
EventThe Event that is being processed.
ContextEvent Context.

Definition at line 411 of file PciHostBridge.c.

◆ NotifyPhase()

Enter a certain phase of the PCI enumeration process.

Parameters
ThisThe EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.
PhaseThe phase during enumeration.
Return values
EFI_SUCCESSSucceed.
EFI_INVALID_PARAMETERWrong phase parameter passed in.
EFI_NOT_READYResources have not been submitted yet.

Definition at line 822 of file PciHostBridge.c.

◆ PreprocessController()

This function is called for all the PCI controllers that the PCI bus driver finds. Can be used to Preprogram the controller.

Parameters
ThisThe EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
RootBridgeHandleThe PCI Root Bridge handle.
PciAddressAddress of the controller on the PCI bus.
PhaseThe Phase during resource allocation.
Return values
EFI_SUCCESSSucceed.
EFI_INVALID_PARAMETERRootBridgeHandle is not a valid handle.

Definition at line 1708 of file PciHostBridge.c.

◆ ResourceConflict()

VOID ResourceConflict ( IN PCI_HOST_BRIDGE_INSTANCE HostBridge)

This routine constructs the resource descriptors for all root bridges and call PciHostBridgeResourceConflict().

Parameters
HostBridgeThe Host Bridge Instance where the resource adjustment happens.

Definition at line 644 of file PciHostBridge.c.

◆ SetBusNumbers()

EFI_STATUS EFIAPI SetBusNumbers ( IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL This,
IN EFI_HANDLE  RootBridgeHandle,
IN VOID *  Configuration 
)

This function programs the PCI Root Bridge hardware so that it decodes the specified PCI bus range.

Parameters
ThisThe EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
RootBridgeHandleThe PCI Root Bridge whose bus range is to be programmed.
ConfigurationThe pointer to the PCI bus resource descriptor.
Return values
EFI_SUCCESSSucceed.
EFI_INVALID_PARAMETERWrong parameters passed in.

Definition at line 1384 of file PciHostBridge.c.

◆ StartBusEnumeration()

EFI_STATUS EFIAPI StartBusEnumeration ( IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL This,
IN EFI_HANDLE  RootBridgeHandle,
OUT VOID **  Configuration 
)

This is the request from the PCI enumerator to set up the specified PCI Root Bridge for bus enumeration process.

Parameters
ThisThe EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
RootBridgeHandleThe PCI Root Bridge to be set up.
ConfigurationPointer to the pointer to the PCI bus resource descriptor.
Return values
EFI_SUCCESSSucceed.
EFI_OUT_OF_RESOURCESNot enough pool to be allocated.
EFI_INVALID_PARAMETERRootBridgeHandle is not a valid handle.

Definition at line 1317 of file PciHostBridge.c.

◆ SubmitResources()

EFI_STATUS EFIAPI SubmitResources ( IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL This,
IN EFI_HANDLE  RootBridgeHandle,
IN VOID *  Configuration 
)

Submits the I/O and memory resource requirements for the specified PCI Root Bridge.

Parameters
ThisThe EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
RootBridgeHandleThe PCI Root Bridge whose I/O and memory resource requirements. are being submitted.
ConfigurationThe pointer to the PCI I/O and PCI memory resource descriptor.
Return values
EFI_SUCCESSSucceed.
EFI_INVALID_PARAMETERWrong parameters passed in.

Definition at line 1460 of file PciHostBridge.c.

Variable Documentation

◆ mAcpiAddressSpaceTypeStr

GLOBAL_REMOVE_IF_UNREFERENCED CHAR16* mAcpiAddressSpaceTypeStr[]
Initial value:
= {
L"Mem", L"I/O", L"Bus"
}

Definition at line 16 of file PciHostBridge.c.

◆ mCpuIo

Definition at line 14 of file PciHostBridge.c.

◆ mIoMmu

Definition at line 23 of file PciHostBridge.c.

◆ mIoMmuEvent

EFI_EVENT mIoMmuEvent

Definition at line 24 of file PciHostBridge.c.

◆ mIoMmuRegistration

VOID* mIoMmuRegistration

Definition at line 25 of file PciHostBridge.c.

◆ mPciResourceTypeStr

GLOBAL_REMOVE_IF_UNREFERENCED CHAR16* mPciResourceTypeStr[]
Initial value:
= {
L"I/O", L"Mem", L"PMem", L"Mem64", L"PMem64", L"Bus"
}

Definition at line 19 of file PciHostBridge.c.