TianoCore EDK2 master
Loading...
Searching...
No Matches
ArmVirtPciHostBridgeUtilityLib.c
Go to the documentation of this file.
1
13#include <Library/DebugLib.h>
18#include <Library/PciLib.h>
19
20#pragma pack(1)
21typedef struct {
22 ACPI_HID_DEVICE_PATH AcpiDevicePath;
23 EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
25#pragma pack ()
26
28CHAR16 *mPciHostBridgeAcpiAddressSpaceTypeStr[] = {
29 L"Mem",
30 L"I/O",
31 L"Bus"
32};
33
34STATIC CONST EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath = {
35 {
36 {
38 ACPI_DP,
39 {
40 (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)),
41 (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)
42 }
43 },
44 EISA_PNP_ID (0x0A03), // HID
45 0 // UID
46 },
47
48 {
49 END_DEVICE_PATH_TYPE,
50 END_ENTIRE_DEVICE_PATH_SUBTYPE,
51 {
52 END_DEVICE_PATH_LENGTH,
53 0
54 }
55 }
56};
57
59CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = {
60 L"Mem", L"I/O", L"Bus"
61};
62
63STATIC PCI_ROOT_BRIDGE mRootBridge;
64
84EFIAPI
86 OUT UINTN *Count,
87 IN UINT64 Attributes,
88 IN UINT64 AllocationAttributes,
89 IN BOOLEAN DmaAbove4G,
90 IN BOOLEAN NoExtendedConfigSpace,
91 IN UINTN BusMin,
92 IN UINTN BusMax,
95 IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G,
97 IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G
98 )
99{
100 if ((Count == NULL) ||
101 (Io == NULL) ||
102 (Mem == NULL) ||
103 (MemAbove4G == NULL) ||
104 (PMem == NULL) ||
105 (PMemAbove4G == NULL))
106 {
107 return NULL;
108 }
109
110 *Count = 1;
111
112 mRootBridge.Segment = 0;
113 mRootBridge.Supports = Attributes;
114 mRootBridge.Attributes = Attributes;
115
116 mRootBridge.DmaAbove4G = DmaAbove4G;
117 mRootBridge.NoExtendedConfigSpace = NoExtendedConfigSpace;
118 mRootBridge.ResourceAssigned = FALSE;
119
120 mRootBridge.AllocationAttributes = AllocationAttributes;
121
122 mRootBridge.Bus.Base = BusMin;
123 mRootBridge.Bus.Limit = BusMax;
124 mRootBridge.Io.Base = Io->Base;
125 mRootBridge.Io.Limit = Io->Limit;
126 mRootBridge.Mem.Base = Mem->Base;
127 mRootBridge.Mem.Limit = Mem->Limit;
128 mRootBridge.MemAbove4G.Base = MemAbove4G->Base;
129 mRootBridge.MemAbove4G.Limit = MemAbove4G->Limit;
130 mRootBridge.PMem.Base = PMem->Base;
131 mRootBridge.PMem.Limit = PMem->Limit;
132 mRootBridge.PMemAbove4G.Base = PMemAbove4G->Base;
133 mRootBridge.PMemAbove4G.Limit = PMemAbove4G->Limit;
134
135 mRootBridge.DevicePath =
136 (EFI_DEVICE_PATH_PROTOCOL *)&mEfiPciRootBridgeDevicePath;
137
138 return &mRootBridge;
139}
140
148VOID
149EFIAPI
151 IN PCI_ROOT_BRIDGE *Bridges,
152 IN UINTN Count
153 )
154{
155 // Nothing to do here.
156}
157
172VOID
173EFIAPI
175 IN VOID *Configuration
176 )
177{
179 UINTN RootBridgeIndex;
180
181 DEBUG ((DEBUG_ERROR, "PciHostBridge: Resource conflict happens!\n"));
182
183 RootBridgeIndex = 0;
184 Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Configuration;
185 while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {
186 DEBUG ((DEBUG_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++));
187 for ( ; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {
188 ASSERT (
189 Descriptor->ResType <
190 ARRAY_SIZE (mPciHostBridgeAcpiAddressSpaceTypeStr)
191 );
192 DEBUG ((
193 DEBUG_ERROR,
194 " %s: Length/Alignment = 0x%lx / 0x%lx\n",
195 mPciHostBridgeAcpiAddressSpaceTypeStr[Descriptor->ResType],
196 Descriptor->AddrLen,
197 Descriptor->AddrRangeMax
198 ));
199 if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {
200 DEBUG ((
201 DEBUG_ERROR,
202 " Granularity/SpecificFlag = %ld / %02x%s\n",
203 Descriptor->AddrSpaceGranularity,
204 Descriptor->SpecificFlag,
205 ((Descriptor->SpecificFlag &
206 EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE
207 ) != 0) ? L" (Prefetchable)" : L""
208 ));
209 }
210 }
211
212 //
213 // Skip the END descriptor for root bridge
214 //
215 ASSERT (Descriptor->Desc == ACPI_END_TAG_DESCRIPTOR);
216 Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)(
217 (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1
218 );
219 }
220}
UINT64 UINTN
PACKED struct @89 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
VOID EFIAPI PciHostBridgeUtilityFreeRootBridges(IN PCI_ROOT_BRIDGE *Bridges, IN UINTN Count)
PCI_ROOT_BRIDGE *EFIAPI PciHostBridgeUtilityGetRootBridges(OUT UINTN *Count, IN UINT64 Attributes, IN UINT64 AllocationAttributes, IN BOOLEAN DmaAbove4G, IN BOOLEAN NoExtendedConfigSpace, IN UINTN BusMin, IN UINTN BusMax, IN PCI_ROOT_BRIDGE_APERTURE *Io, IN PCI_ROOT_BRIDGE_APERTURE *Mem, IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, IN PCI_ROOT_BRIDGE_APERTURE *PMem, IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G)
VOID EFIAPI PciHostBridgeUtilityResourceConflict(IN VOID *Configuration)
#define ACPI_DEVICE_PATH
Definition: DevicePath.h:190
#define ACPI_DP
Definition: DevicePath.h:195
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define FALSE
Definition: Base.h:307
#define ARRAY_SIZE(Array)
Definition: Base.h:1393
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define GLOBAL_REMOVE_IF_UNREFERENCED
Definition: Base.h:48
#define DEBUG(Expression)
Definition: DebugLib.h:434
PCI_ROOT_BRIDGE_APERTURE Io
IO aperture which can be used by the root bridge.
BOOLEAN ResourceAssigned
PCI_ROOT_BRIDGE_APERTURE PMem
Prefetchable MMIO aperture below 4GB which can be used by the root bridge.
BOOLEAN NoExtendedConfigSpace
UINT32 Segment
Segment number.
EFI_DEVICE_PATH_PROTOCOL * DevicePath
Device path.
PCI_ROOT_BRIDGE_APERTURE Mem
MMIO aperture below 4GB which can be used by the root bridge.
PCI_ROOT_BRIDGE_APERTURE PMemAbove4G
Prefetchable MMIO aperture above 4GB which can be used by the root bridge.
PCI_ROOT_BRIDGE_APERTURE MemAbove4G
MMIO aperture above 4GB which can be used by the root bridge.
PCI_ROOT_BRIDGE_APERTURE Bus
Bus aperture which can be used by the root bridge.
UINT64 AllocationAttributes