30STATIC BOOLEAN mPciExtConfSpaceSupported;
78 ZeroMem (ResourcePadding,
sizeof *ResourcePadding);
83 for (Index = 0; Index <
ARRAY_SIZE (ResourcePadding->Padding); ++Index) {
86 Descriptor = ResourcePadding->Padding + Index;
87 Descriptor->Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR;
88 Descriptor->Len = (UINT16)(
100 ResourcePadding->EndDesc.Desc = ACPI_END_TAG_DESCRIPTOR;
120 Descriptor->ResType = ACPI_ADDRESS_SPACE_TYPE_IO;
121 Descriptor->AddrLen =
LShiftU64 (1, SizeExponent);
122 Descriptor->AddrRangeMax = Descriptor->AddrLen - 1;
151 IN BOOLEAN Prefetchable,
152 IN BOOLEAN ThirtyTwoBitOnly,
156 Descriptor->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM;
158 Descriptor->SpecificFlag =
159 EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE;
160 Descriptor->AddrSpaceGranularity = ThirtyTwoBitOnly ? 32 : 64;
162 Descriptor->SpecificFlag =
163 EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_NON_CACHEABLE;
164 Descriptor->AddrSpaceGranularity = 32;
167 Descriptor->AddrLen =
LShiftU64 (1, SizeExponent);
168 Descriptor->AddrRangeMax = Descriptor->AddrLen - 1;
201 if ((Operand & (Operand - 1)) != 0) {
208 return (HighBit < 32) ? HighBit : -1;
241 if ((Operand & (Operand - 1)) != 0) {
248 return (HighBit < 64) ? HighBit : -1;
281 UINT16 VendorInstance;
290 HpcPciAddress->Device,
291 HpcPciAddress->Function,
295 if (PciVendorId != QEMU_PCI_BRIDGE_VENDOR_ID_REDHAT) {
296 return EFI_NOT_FOUND;
303 mPciExtConfSpaceSupported ? PciCapExtended : PciCapNormal,
306 HpcPciAddress->Device,
307 HpcPciAddress->Function,
310 if (EFI_ERROR (Status)) {
315 if (EFI_ERROR (Status)) {
316 goto UninitPciDevice;
331 EFI_PCI_CAPABILITY_ID_VENDOR,
335 if (EFI_ERROR (Status)) {
349 if (EFI_ERROR (Status)) {
353 if (VendorLength !=
sizeof *ReservationHint) {
367 if (EFI_ERROR (Status)) {
372 QEMU_PCI_BRIDGE_CAPABILITY_TYPE_RESOURCE_RESERVATION)
389 sizeof *ReservationHint
436 if ((HpcCount ==
NULL) || (HpcList ==
NULL)) {
437 return EFI_INVALID_PARAMETER;
490 IN UINT64 HpcPciAddress,
501 if (HpcState ==
NULL) {
502 return EFI_INVALID_PARAMETER;
505 return EFI_UNSUPPORTED;
550 IN UINT64 HpcPciAddress,
559 BOOLEAN DefaultPrefMmio;
568 CHAR16 *DevicePathString;
574 "%a: Address=%02x:%02x.%x DevicePath=%s\n",
579 (DevicePathString ==
NULL) ? L
"<unavailable>" : DevicePathString
582 if (DevicePathString !=
NULL) {
588 if ((HpcState ==
NULL) || (Padding ==
NULL) || (Attributes ==
NULL)) {
589 return EFI_INVALID_PARAMETER;
594 DefaultPrefMmio =
TRUE;
602 FirstResource = ReservationRequest.Padding +
609 if (!EFI_ERROR (ReservationHintStatus)) {
614 "%a: BusNumbers=0x%x Io=0x%Lx NonPrefetchable32BitMmio=0x%x\n"
615 "%a: Prefetchable32BitMmio=0x%x Prefetchable64BitMmio=0x%Lx\n",
617 ReservationHint.BusNumbers,
619 ReservationHint.NonPrefetchable32BitMmio,
621 ReservationHint.Prefetchable32BitMmio,
622 ReservationHint.Prefetchable64BitMmio
628 switch (ReservationHint.BusNumbers) {
644 FirstResource->ResType = ACPI_ADDRESS_SPACE_TYPE_BUS;
645 FirstResource->AddrLen = ReservationHint.BusNumbers;
652 switch (ReservationHint.Io) {
682 switch (ReservationHint.NonPrefetchable32BitMmio) {
721 if ((ReservationHint.Prefetchable32BitMmio > 0) &&
722 (ReservationHint.Prefetchable32BitMmio < MAX_UINT32))
727 DefaultPrefMmio =
FALSE;
729 }
else if ((ReservationHint.Prefetchable64BitMmio > 0) &&
730 (ReservationHint.Prefetchable64BitMmio < MAX_UINT64))
735 DefaultPrefMmio =
FALSE;
759 if (DefaultPrefMmio) {
760 UINT64 Pci64Size =
PcdGet64 (PcdPciMmio64Size);
762 if (Pci64Size > SIZE_32GB) {
779 (UINT8 *)(&ReservationRequest + 1) - (UINT8 *)FirstResource,
782 if (*Padding ==
NULL) {
783 return EFI_OUT_OF_RESOURCES;
818 mPciExtConfSpaceSupported = (
PcdGet16 (PcdOvmfHostBridgePciDevId) ==
819 INTEL_Q35_MCH_DEVICE_ID);
823 Status =
gBS->InstallMultipleProtocolInterfaces (
825 &gEfiPciHotPlugInitProtocolGuid,
PACKED struct @89 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
UINT64 EFIAPI RShiftU64(IN UINT64 Operand, IN UINTN Count)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
INTN EFIAPI HighBitSet64(IN UINT64 Operand)
INTN EFIAPI HighBitSet32(IN UINT32 Operand)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
CHAR16 *EFIAPI ConvertDevicePathToText(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
#define ARRAY_SIZE(Array)
#define OFFSET_OF(TYPE, Field)
#define DEBUG_CODE_BEGIN()
#define DEBUG(Expression)
#define PCI_LIB_ADDRESS(Bus, Device, Function, Register)
UINT16 EFIAPI PciRead16(IN UINTN Address)
#define PcdGet16(TokenName)
#define PcdGet64(TokenName)
VOID EFIAPI PciCapListUninit(IN PCI_CAP_LIST *CapList)
RETURN_STATUS EFIAPI PciCapListInit(IN PCI_CAP_DEV *PciDevice, OUT PCI_CAP_LIST **CapList)
RETURN_STATUS EFIAPI PciCapRead(IN PCI_CAP_DEV *PciDevice, IN PCI_CAP *Cap, IN UINT16 SourceOffsetInCap, OUT VOID *DestinationBuffer, IN UINT16 Size)
RETURN_STATUS EFIAPI PciCapListFindCap(IN PCI_CAP_LIST *CapList, IN PCI_CAP_DOMAIN Domain, IN UINT16 CapId, IN UINT16 Instance, OUT PCI_CAP **Cap OPTIONAL)
VOID EFIAPI PciCapPciSegmentDeviceUninit(IN PCI_CAP_DEV *PciDevice)
RETURN_STATUS EFIAPI PciCapPciSegmentDeviceInit(IN PCI_CAP_DOMAIN MaxDomain, IN UINT16 Segment, IN UINT8 Bus, IN UINT8 Device, IN UINT8 Function, OUT PCI_CAP_DEV **PciDevice)
STATIC INTN HighBitSetRoundUp64(IN UINT64 Operand)
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 VOID SetIoPadding(IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor, IN UINTN SizeExponent)
EFI_STATUS EFIAPI DriverInitialize(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
STATIC EFI_STATUS QueryReservationHint(IN CONST EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS *HpcPciAddress, OUT QEMU_PCI_BRIDGE_CAPABILITY_RESOURCE_RESERVATION *ReservationHint)
STATIC INTN HighBitSetRoundUp32(IN UINT32 Operand)
STATIC VOID SetMmioPadding(IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor, IN BOOLEAN Prefetchable, IN BOOLEAN ThirtyTwoBitOnly, IN UINTN SizeExponent)
STATIC VOID InitializeResourcePadding(OUT RESOURCE_PADDING *ResourcePadding)
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 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)
#define EFI_HPC_STATE_ENABLED
EFI_HPC_PADDING_ATTRIBUTES
#define EFI_HPC_STATE_INITIALIZED
EFI_INITIALIZE_ROOT_HPC InitializeRootHpc
EFI_GET_ROOT_HPC_LIST GetRootHpcList
EFI_GET_HOT_PLUG_PADDING GetResourcePadding