2 OVMF's instance of the PCI Host Bridge Library.
4 Copyright (C) 2016, Red Hat, Inc.
5 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #include <IndustryStandard/Pci.h>
13 #include <IndustryStandard/Q35MchIch9.h>
15 #include <Protocol/PciHostBridgeResourceAllocation.h>
16 #include <Protocol/PciRootBridgeIo.h>
18 #include <Library/BaseMemoryLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/MemoryAllocationLib.h>
21 #include <Library/PcdLib.h>
22 #include <Library/PciHostBridgeLib.h>
23 #include <Library/PciHostBridgeUtilityLib.h>
24 #include "PciHostBridge.h"
27 STATIC PCI_ROOT_BRIDGE_APERTURE mNonExistAperture
= { MAX_UINT64
, 0 };
31 Return all the root bridge instances in an array.
33 @param Count Return the count of root bridge instances.
35 @return All the root bridge instances in an array.
36 The array should be passed into PciHostBridgeFreeRootBridges()
41 PciHostBridgeGetRootBridges (
46 UINT64 AllocationAttributes
;
47 PCI_ROOT_BRIDGE_APERTURE Io
;
48 PCI_ROOT_BRIDGE_APERTURE Mem
;
49 PCI_ROOT_BRIDGE_APERTURE MemAbove4G
;
51 if (PcdGetBool (PcdPciDisableBusEnumeration
)) {
52 return ScanForRootBridges (Count
);
55 ZeroMem (&Io
, sizeof (Io
));
56 ZeroMem (&Mem
, sizeof (Mem
));
57 ZeroMem (&MemAbove4G
, sizeof (MemAbove4G
));
59 Attributes
= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO
|
60 EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO
|
61 EFI_PCI_ATTRIBUTE_ISA_IO_16
|
62 EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO
|
63 EFI_PCI_ATTRIBUTE_VGA_MEMORY
|
64 EFI_PCI_ATTRIBUTE_VGA_IO_16
|
65 EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16
;
67 AllocationAttributes
= EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM
;
68 if (PcdGet64 (PcdPciMmio64Size
) > 0) {
69 AllocationAttributes
|= EFI_PCI_HOST_BRIDGE_MEM64_DECODE
;
70 MemAbove4G
.Base
= PcdGet64 (PcdPciMmio64Base
);
71 MemAbove4G
.Limit
= PcdGet64 (PcdPciMmio64Base
) +
72 PcdGet64 (PcdPciMmio64Size
) - 1;
74 CopyMem (&MemAbove4G
, &mNonExistAperture
, sizeof (mNonExistAperture
));
77 Io
.Base
= PcdGet64 (PcdPciIoBase
);
78 Io
.Limit
= PcdGet64 (PcdPciIoBase
) + (PcdGet64 (PcdPciIoSize
) - 1);
79 Mem
.Base
= PcdGet64 (PcdPciMmio32Base
);
80 Mem
.Limit
= PcdGet64 (PcdPciMmio32Base
) + (PcdGet64 (PcdPciMmio32Size
) - 1);
82 return PciHostBridgeUtilityGetRootBridges (
87 PcdGet16 (PcdOvmfHostBridgePciDevId
) != INTEL_Q35_MCH_DEVICE_ID
,
98 Free the root bridge instances array returned from
99 PciHostBridgeGetRootBridges().
101 @param The root bridge instances array.
102 @param The count of the array.
106 PciHostBridgeFreeRootBridges (
107 PCI_ROOT_BRIDGE
*Bridges
,
111 PciHostBridgeUtilityFreeRootBridges (Bridges
, Count
);
116 Inform the platform that the resource conflict happens.
118 @param HostBridgeHandle Handle of the Host Bridge.
119 @param Configuration Pointer to PCI I/O and PCI memory resource
120 descriptors. The Configuration contains the resources
121 for all the root bridges. The resource for each root
122 bridge is terminated with END descriptor and an
123 additional END is appended indicating the end of the
124 entire resources. The resource descriptor field
125 values follow the description in
126 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
131 PciHostBridgeResourceConflict (
132 EFI_HANDLE HostBridgeHandle
,
136 PciHostBridgeUtilityResourceConflict (Configuration
);