TianoCore EDK2 master
Loading...
Searching...
No Matches
PciHotPlugInit.c File Reference

Go to the source code of this file.

Data Structures

struct  RESOURCE_PADDING
 

Functions

STATIC VOID InitializeResourcePadding (OUT RESOURCE_PADDING *ResourcePadding)
 
STATIC VOID SetIoPadding (IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor, IN UINTN SizeExponent)
 
STATIC VOID SetMmioPadding (IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor, IN BOOLEAN Prefetchable, IN BOOLEAN ThirtyTwoBitOnly, IN UINTN SizeExponent)
 
STATIC INTN HighBitSetRoundUp32 (IN UINT32 Operand)
 
STATIC INTN HighBitSetRoundUp64 (IN UINT64 Operand)
 
STATIC EFI_STATUS QueryReservationHint (IN CONST EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS *HpcPciAddress, OUT QEMU_PCI_BRIDGE_CAPABILITY_RESOURCE_RESERVATION *ReservationHint)
 
STATIC EFI_STATUS EFIAPI GetRootHpcList (IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This, OUT UINTN *HpcCount, OUT EFI_HPC_LOCATION **HpcList)
 
STATIC EFI_STATUS EFIAPI InitializeRootHpc (IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath, IN UINT64 HpcPciAddress, IN EFI_EVENT Event OPTIONAL, OUT EFI_HPC_STATE *HpcState)
 
STATIC EFI_STATUS EFIAPI GetResourcePadding (IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath, IN UINT64 HpcPciAddress, OUT EFI_HPC_STATE *HpcState, OUT VOID **Padding, OUT EFI_HPC_PADDING_ATTRIBUTES *Attributes)
 
EFI_STATUS EFIAPI DriverInitialize (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

STATIC BOOLEAN mPciExtConfSpaceSupported
 
STATIC EFI_PCI_HOT_PLUG_INIT_PROTOCOL mPciHotPlugInit
 

Detailed Description

This driver implements EFI_PCI_HOT_PLUG_INIT_PROTOCOL, providing the PCI bus driver with resource padding information, for PCIe hotplug purposes.

Copyright (C) 2016, Red Hat, Inc.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file PciHotPlugInit.c.

Function Documentation

◆ DriverInitialize()

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

Entry point for this driver.

Parameters
[in]ImageHandleImage handle of this driver.
[in]SystemTablePointer to SystemTable.
Return values
EFI_SUCESSDriver has loaded successfully.
Returns
Error codes from lower level functions.

Definition at line 811 of file PciHotPlugInit.c.

◆ GetResourcePadding()

STATIC EFI_STATUS EFIAPI GetResourcePadding ( IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL This,
IN EFI_DEVICE_PATH_PROTOCOL HpcDevicePath,
IN UINT64  HpcPciAddress,
OUT EFI_HPC_STATE HpcState,
OUT VOID **  Padding,
OUT EFI_HPC_PADDING_ATTRIBUTES Attributes 
)

Returns the resource padding that is required by the PCI bus that is controlled by the specified Hot Plug Controller (HPC).

This function returns the resource padding that is required by the PCI bus that is controlled by the specified HPC. This member function is called for all the root HPCs and nonroot HPCs that are detected by the PCI bus enumerator. This function will be called before PCI resource allocation is completed. This function must be called after all the root HPCs, with the possible exception of a PCI-to-CardBus bridge, have completed initialization.

Parameters
[in]ThisPointer to the EFI_PCI_HOT_PLUG_INIT_PROTOCOL instance.
[in]HpcDevicePathThe device path to the HPC.
[in]HpcPciAddressThe address of the HPC function on the PCI bus.
[in]HpcStateThe state of the HPC hardware.
[out]PaddingThe amount of resource padding that is required by the PCI bus under the control of the specified HPC.
[out]AttributesDescribes how padding is accounted for. The padding is returned in the form of ACPI 2.0 resource descriptors.
Return values
EFI_SUCCESSThe resource padding was successfully returned.
EFI_UNSUPPORTEDThis instance of the EFI_PCI_HOT_PLUG_INIT_PROTOCOL does not support the specified HPC.
EFI_NOT_READYThis function was called before HPC initialization is complete.
EFI_INVALID_PARAMETERHpcState or Padding or Attributes is NULL.
EFI_OUT_OF_RESOURCESACPI 2.0 resource descriptors for Padding cannot be allocated due to insufficient resources.

Definition at line 547 of file PciHotPlugInit.c.

◆ GetRootHpcList()

STATIC EFI_STATUS EFIAPI GetRootHpcList ( IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL This,
OUT UINTN HpcCount,
OUT EFI_HPC_LOCATION **  HpcList 
)

Returns a list of root Hot Plug Controllers (HPCs) that require initialization during the boot process.

This procedure returns a list of root HPCs. The PCI bus driver must initialize these controllers during the boot process. The PCI bus driver may or may not be able to detect these HPCs. If the platform includes a PCI-to-CardBus bridge, it can be included in this list if it requires initialization. The HpcList must be self consistent. An HPC cannot control any of its parent buses. Only one HPC can control a PCI bus. Because this list includes only root HPCs, no HPC in the list can be a child of another HPC. This policy must be enforced by the EFI_PCI_HOT_PLUG_INIT_PROTOCOL. The PCI bus driver may not check for such invalid conditions. The callee allocates the buffer HpcList

Parameters
[in]ThisPointer to the EFI_PCI_HOT_PLUG_INIT_PROTOCOL instance.
[out]HpcCountThe number of root HPCs that were returned.
[out]HpcListThe list of root HPCs. HpcCount defines the number of elements in this list.
Return values
EFI_SUCCESSHpcList was returned.
EFI_OUT_OF_RESOURCESHpcList was not returned due to insufficient resources.
EFI_INVALID_PARAMETERHpcCount is NULL or HpcList is NULL.

Definition at line 430 of file PciHotPlugInit.c.

◆ HighBitSetRoundUp32()

STATIC INTN HighBitSetRoundUp32 ( IN UINT32  Operand)

Round up a positive 32-bit value to the next whole power of two, and return the bit position of the highest bit set in the result. Equivalent to ceil(log2(x)).

Parameters
[in]OperandThe 32-bit operand to evaluate.
Return values
-1Operand is zero.
-1Operand is positive, not a whole power of two, and rounding it up to the next power of two does not fit into 32 bits.
0..31Otherwise, return ceil(log2(Value)).

Definition at line 187 of file PciHotPlugInit.c.

◆ HighBitSetRoundUp64()

STATIC INTN HighBitSetRoundUp64 ( IN UINT64  Operand)

Round up a positive 64-bit value to the next whole power of two, and return the bit position of the highest bit set in the result. Equivalent to ceil(log2(x)).

Parameters
[in]OperandThe 64-bit operand to evaluate.
Return values
-1Operand is zero.
-1Operand is positive, not a whole power of two, and rounding it up to the next power of two does not fit into 64 bits.
0..63Otherwise, return ceil(log2(Value)).

Definition at line 227 of file PciHotPlugInit.c.

◆ InitializeResourcePadding()

STATIC VOID InitializeResourcePadding ( OUT RESOURCE_PADDING ResourcePadding)

Initialize a RESOURCE_PADDING object.

Parameters
[out]ResourcePaddingThe caller-allocated RESOURCE_PADDING object to initialize.

Definition at line 72 of file PciHotPlugInit.c.

◆ InitializeRootHpc()

STATIC EFI_STATUS EFIAPI InitializeRootHpc ( IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL This,
IN EFI_DEVICE_PATH_PROTOCOL HpcDevicePath,
IN UINT64  HpcPciAddress,
IN EFI_EVENT Event  OPTIONAL,
OUT EFI_HPC_STATE HpcState 
)

Initializes one root Hot Plug Controller (HPC). This process may causes initialization of its subordinate buses.

This function initializes the specified HPC. At the end of initialization, the hot-plug slots or sockets (controlled by this HPC) are powered and are connected to the bus. All the necessary registers in the HPC are set up. For a Standard (PCI) Hot Plug Controller (SHPC), the registers that must be set up are defined in the PCI Standard Hot Plug Controller and Subsystem Specification.

Parameters
[in]ThisPointer to the EFI_PCI_HOT_PLUG_INIT_PROTOCOL instance.
[in]HpcDevicePathThe device path to the HPC that is being initialized.
[in]HpcPciAddressThe address of the HPC function on the PCI bus.
[in]EventThe event that should be signaled when the HPC initialization is complete. Set to NULL if the caller wants to wait until the entire initialization process is complete.
[out]HpcStateThe state of the HPC hardware. The state is EFI_HPC_STATE_INITIALIZED or EFI_HPC_STATE_ENABLED.
Return values
EFI_SUCCESSIf Event is NULL, the specific HPC was successfully initialized. If Event is not NULL, Event will be signaled at a later time when initialization is complete.
EFI_UNSUPPORTEDThis instance of EFI_PCI_HOT_PLUG_INIT_PROTOCOL does not support the specified HPC.
EFI_OUT_OF_RESOURCESInitialization failed due to insufficient resources.
EFI_INVALID_PARAMETERHpcState is NULL.

Definition at line 487 of file PciHotPlugInit.c.

◆ QueryReservationHint()

Look up the QEMU-specific Resource Reservation capability in the conventional config space of a Hotplug Controller (that is, PCI Bridge).

On error, the contents of ReservationHint are indeterminate.

Parameters
[in]HpcPciAddressThe address of the PCI Bridge – Bus, Device, Function – in UEFI (not PciLib) encoding.
[out]ReservationHintThe caller-allocated capability structure to populate from the PCI Bridge's config space.
Return values
EFI_SUCCESSThe capability has been found, ReservationHint has been populated.
EFI_NOT_FOUNDThe capability is missing.
Returns
Error codes from PciCapPciSegmentLib and PciCapLib.

Definition at line 272 of file PciHotPlugInit.c.

◆ SetIoPadding()

STATIC VOID SetIoPadding ( IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR Descriptor,
IN UINTN  SizeExponent 
)

Set up a descriptor entry for reserving IO space.

Parameters
[in,out]DescriptorThe descriptor to configure. The caller shall have initialized Descriptor earlier, with InitializeResourcePadding().
[in]SizeExponentThe size and natural alignment of the reservation are determined by raising two to this power.

Definition at line 115 of file PciHotPlugInit.c.

◆ SetMmioPadding()

STATIC VOID SetMmioPadding ( IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR Descriptor,
IN BOOLEAN  Prefetchable,
IN BOOLEAN  ThirtyTwoBitOnly,
IN UINTN  SizeExponent 
)

Set up a descriptor entry for reserving MMIO space.

Parameters
[in,out]DescriptorThe descriptor to configure. The caller shall have initialized Descriptor earlier, with InitializeResourcePadding().
[in]PrefetchableTRUE if the descriptor should reserve prefetchable MMIO space. Pass FALSE for reserving non-prefetchable MMIO space.
[in]ThirtyTwoBitOnlyTRUE if the reservation should be limited to 32-bit address space. FALSE if the reservation can be satisfied from 64-bit address space. ThirtyTwoBitOnly is ignored if Prefetchable is FALSE; in that case ThirtyTwoBitOnly is always considered TRUE.
[in]SizeExponentThe size and natural alignment of the reservation are determined by raising two to this power.

Definition at line 149 of file PciHotPlugInit.c.

Variable Documentation

◆ mPciExtConfSpaceSupported

STATIC BOOLEAN mPciExtConfSpaceSupported

Definition at line 30 of file PciHotPlugInit.c.

◆ mPciHotPlugInit

Definition at line 38 of file PciHotPlugInit.c.