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
10 #include <IndustryStandard/Pci.h> // PCI_MAX_BUS
11 #include <IndustryStandard/Q35MchIch9.h> // INTEL_Q35_MCH_DEVIC...
12 #include <Library/BaseMemoryLib.h> // ZeroMem()
13 #include <Library/PcdLib.h> // PcdGet64()
14 #include <Library/PciHostBridgeLib.h> // PCI_ROOT_BRIDGE_APE...
15 #include <Library/PciHostBridgeUtilityLib.h> // PciHostBridgeUtilit...
16 #include <Protocol/PciHostBridgeResourceAllocation.h> // EFI_PCI_HOST_BRIDGE...
17 #include <Protocol/PciRootBridgeIo.h> // EFI_PCI_ATTRIBUTE_I...
19 #include "PciHostBridge.h"
21 STATIC PCI_ROOT_BRIDGE_APERTURE mNonExistAperture
= { MAX_UINT64
, 0 };
25 Return all the root bridge instances in an array.
27 @param Count Return the count of root bridge instances.
29 @return All the root bridge instances in an array.
30 The array should be passed into PciHostBridgeFreeRootBridges()
35 PciHostBridgeGetRootBridges (
40 UINT64 AllocationAttributes
;
41 PCI_ROOT_BRIDGE_APERTURE Io
;
42 PCI_ROOT_BRIDGE_APERTURE Mem
;
43 PCI_ROOT_BRIDGE_APERTURE MemAbove4G
;
45 if (PcdGetBool (PcdPciDisableBusEnumeration
)) {
46 return ScanForRootBridges (Count
);
49 ZeroMem (&Io
, sizeof (Io
));
50 ZeroMem (&Mem
, sizeof (Mem
));
51 ZeroMem (&MemAbove4G
, sizeof (MemAbove4G
));
53 Attributes
= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO
|
54 EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO
|
55 EFI_PCI_ATTRIBUTE_ISA_IO_16
|
56 EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO
|
57 EFI_PCI_ATTRIBUTE_VGA_MEMORY
|
58 EFI_PCI_ATTRIBUTE_VGA_IO_16
|
59 EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16
;
61 AllocationAttributes
= EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM
;
62 if (PcdGet64 (PcdPciMmio64Size
) > 0) {
63 AllocationAttributes
|= EFI_PCI_HOST_BRIDGE_MEM64_DECODE
;
64 MemAbove4G
.Base
= PcdGet64 (PcdPciMmio64Base
);
65 MemAbove4G
.Limit
= PcdGet64 (PcdPciMmio64Base
) +
66 PcdGet64 (PcdPciMmio64Size
) - 1;
68 CopyMem (&MemAbove4G
, &mNonExistAperture
, sizeof (mNonExistAperture
));
71 Io
.Base
= PcdGet64 (PcdPciIoBase
);
72 Io
.Limit
= PcdGet64 (PcdPciIoBase
) + (PcdGet64 (PcdPciIoSize
) - 1);
73 Mem
.Base
= PcdGet64 (PcdPciMmio32Base
);
74 Mem
.Limit
= PcdGet64 (PcdPciMmio32Base
) + (PcdGet64 (PcdPciMmio32Size
) - 1);
76 return PciHostBridgeUtilityGetRootBridges (
81 PcdGet16 (PcdOvmfHostBridgePciDevId
) != INTEL_Q35_MCH_DEVICE_ID
,
94 Free the root bridge instances array returned from
95 PciHostBridgeGetRootBridges().
97 @param The root bridge instances array.
98 @param The count of the array.
102 PciHostBridgeFreeRootBridges (
103 PCI_ROOT_BRIDGE
*Bridges
,
107 PciHostBridgeUtilityFreeRootBridges (Bridges
, Count
);
112 Inform the platform that the resource conflict happens.
114 @param HostBridgeHandle Handle of the Host Bridge.
115 @param Configuration Pointer to PCI I/O and PCI memory resource
116 descriptors. The Configuration contains the resources
117 for all the root bridges. The resource for each root
118 bridge is terminated with END descriptor and an
119 additional END is appended indicating the end of the
120 entire resources. The resource descriptor field
121 values follow the description in
122 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
127 PciHostBridgeResourceConflict (
128 EFI_HANDLE HostBridgeHandle
,
132 PciHostBridgeUtilityResourceConflict (Configuration
);