]> git.proxmox.com Git - mirror_edk2.git/blame - CorebootPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c
CorebootPayloadPkg: Fix various typos
[mirror_edk2.git] / CorebootPayloadPkg / Library / PciHostBridgeLib / PciHostBridgeSupport.c
CommitLineData
69787a9d
MM
1/** @file\r
2 Scan the entire PCI bus for root bridges to support coreboot UEFI payload.\r
3\r
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
5\r
6 This program and the accompanying materials are licensed and made available\r
7 under the terms and conditions of the BSD License which accompanies this\r
8 distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
12 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include <PiDxe.h>\r
17#include <IndustryStandard/Pci.h>\r
18#include <Protocol/PciHostBridgeResourceAllocation.h>\r
19#include <Protocol/PciRootBridgeIo.h>\r
20#include <Library/BaseMemoryLib.h>\r
21#include <Library/DebugLib.h>\r
22#include <Library/MemoryAllocationLib.h>\r
23#include <Library/PciHostBridgeLib.h>\r
24#include <Library/PciLib.h>\r
25#include "PciHostBridge.h"\r
26\r
27/**\r
28 Adjust the collected PCI resource.\r
29\r
30 @param[in] Io IO aperture.\r
31\r
32 @param[in] Mem MMIO aperture.\r
33\r
34 @param[in] MemAbove4G MMIO aperture above 4G.\r
35\r
36 @param[in] PMem Prefetchable MMIO aperture.\r
37\r
38 @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G.\r
39**/\r
40VOID\r
41AdjustRootBridgeResource (\r
42 IN PCI_ROOT_BRIDGE_APERTURE *Io,\r
43 IN PCI_ROOT_BRIDGE_APERTURE *Mem,\r
44 IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G,\r
45 IN PCI_ROOT_BRIDGE_APERTURE *PMem,\r
46 IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G\r
47)\r
48{\r
49 UINT64 Mask;\r
50\r
51 //\r
52 // For now try to downgrade everything into MEM32 since\r
53 // - coreboot does not assign resource above 4GB\r
54 // - coreboot might allocate interleaved MEM32 and PMEM32 resource\r
55 // in some cases\r
56 //\r
57 if (PMem->Base < Mem->Base) {\r
58 Mem->Base = PMem->Base;\r
59 }\r
60\r
61 if (PMem->Limit > Mem->Limit) {\r
62 Mem->Limit = PMem->Limit;\r
63 }\r
64\r
65 PMem->Base = MAX_UINT64;\r
66 PMem->Limit = 0;\r
67\r
68 if (MemAbove4G->Base < 0x100000000ULL) {\r
69 if (MemAbove4G->Base < Mem->Base) {\r
70 Mem->Base = MemAbove4G->Base;\r
71 }\r
72 if (MemAbove4G->Limit > Mem->Limit) {\r
73 Mem->Limit = MemAbove4G->Limit;\r
74 }\r
75 MemAbove4G->Base = MAX_UINT64;\r
76 MemAbove4G->Limit = 0;\r
77 }\r
78\r
79 if (PMemAbove4G->Base < 0x100000000ULL) {\r
80 if (PMemAbove4G->Base < Mem->Base) {\r
81 Mem->Base = PMemAbove4G->Base;\r
82 }\r
83 if (PMemAbove4G->Limit > Mem->Limit) {\r
84 Mem->Limit = PMemAbove4G->Limit;\r
85 }\r
86 PMemAbove4G->Base = MAX_UINT64;\r
87 PMemAbove4G->Limit = 0;\r
88 }\r
89\r
90 //\r
91 // Align IO resource at 4K boundary\r
92 //\r
93 Mask = 0xFFFULL;\r
0613ccbd 94 Io->Limit = ((Io->Limit + Mask) & ~Mask) - 1;\r
69787a9d
MM
95 if (Io->Base != MAX_UINT64) {\r
96 Io->Base &= ~Mask;\r
97 }\r
98\r
99 //\r
100 // Align MEM resource at 1MB boundary\r
101 //\r
102 Mask = 0xFFFFFULL;\r
0613ccbd 103 Mem->Limit = ((Mem->Limit + Mask) & ~Mask) - 1;\r
69787a9d
MM
104 if (Mem->Base != MAX_UINT64) {\r
105 Mem->Base &= ~Mask;\r
106 }\r
107}\r
108\r
109/**\r
110 Probe a bar is existed or not.\r
111\r
112 @param[in] Address PCI address for the BAR.\r
113 @param[out] OriginalValue The original bar value returned.\r
114 @param[out] Value The probed bar value returned.\r
115**/\r
116STATIC\r
117VOID\r
118PcatPciRootBridgeBarExisted (\r
119 IN UINT64 Address,\r
120 OUT UINT32 *OriginalValue,\r
121 OUT UINT32 *Value\r
122)\r
123{\r
124 UINTN PciAddress;\r
125\r
126 PciAddress = (UINTN)Address;\r
127\r
128 //\r
129 // Preserve the original value\r
130 //\r
131 *OriginalValue = PciRead32 (PciAddress);\r
132\r
133 //\r
134 // Disable timer interrupt while the BAR is probed\r
135 //\r
136 DisableInterrupts ();\r
137\r
138 PciWrite32 (PciAddress, 0xFFFFFFFF);\r
139 *Value = PciRead32 (PciAddress);\r
140 PciWrite32 (PciAddress, *OriginalValue);\r
141\r
142 //\r
143 // Enable interrupt\r
144 //\r
145 EnableInterrupts ();\r
146}\r
147\r
148/**\r
68f87b25 149 Parse PCI bar and collect the assigned PCI resource information.\r
69787a9d
MM
150\r
151 @param[in] Command Supported attributes.\r
152\r
153 @param[in] Bus PCI bus number.\r
154\r
155 @param[in] Device PCI device number.\r
156\r
157 @param[in] Function PCI function number.\r
158\r
159 @param[in] BarOffsetBase PCI bar start offset.\r
160\r
161 @param[in] BarOffsetEnd PCI bar end offset.\r
162\r
163 @param[in] Io IO aperture.\r
164\r
165 @param[in] Mem MMIO aperture.\r
166\r
167 @param[in] MemAbove4G MMIO aperture above 4G.\r
168\r
169 @param[in] PMem Prefetchable MMIO aperture.\r
170\r
171 @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G.\r
172**/\r
173STATIC\r
174VOID\r
175PcatPciRootBridgeParseBars (\r
176 IN UINT16 Command,\r
177 IN UINTN Bus,\r
178 IN UINTN Device,\r
179 IN UINTN Function,\r
180 IN UINTN BarOffsetBase,\r
181 IN UINTN BarOffsetEnd,\r
182 IN PCI_ROOT_BRIDGE_APERTURE *Io,\r
183 IN PCI_ROOT_BRIDGE_APERTURE *Mem,\r
184 IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G,\r
185 IN PCI_ROOT_BRIDGE_APERTURE *PMem,\r
186 IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G\r
187\r
188)\r
189{\r
190 UINT32 OriginalValue;\r
191 UINT32 Value;\r
192 UINT32 OriginalUpperValue;\r
193 UINT32 UpperValue;\r
194 UINT64 Mask;\r
195 UINTN Offset;\r
8a3a9781 196 UINTN LowBit;\r
69787a9d
MM
197 UINT64 Base;\r
198 UINT64 Length;\r
199 UINT64 Limit;\r
200 PCI_ROOT_BRIDGE_APERTURE *MemAperture;\r
201\r
202 for (Offset = BarOffsetBase; Offset < BarOffsetEnd; Offset += sizeof (UINT32)) {\r
203 PcatPciRootBridgeBarExisted (\r
204 PCI_LIB_ADDRESS (Bus, Device, Function, Offset),\r
205 &OriginalValue, &Value\r
206 );\r
207 if (Value == 0) {\r
208 continue;\r
209 }\r
210 if ((Value & BIT0) == BIT0) {\r
211 //\r
212 // IO Bar\r
213 //\r
214 if (Command & EFI_PCI_COMMAND_IO_SPACE) {\r
215 Mask = 0xfffffffc;\r
216 Base = OriginalValue & Mask;\r
217 Length = ((~(Value & Mask)) & Mask) + 0x04;\r
218 if (!(Value & 0xFFFF0000)) {\r
219 Length &= 0x0000FFFF;\r
220 }\r
221 Limit = Base + Length - 1;\r
222\r
223 if ((Base > 0) && (Base < Limit)) {\r
224 if (Io->Base > Base) {\r
225 Io->Base = Base;\r
226 }\r
227 if (Io->Limit < Limit) {\r
228 Io->Limit = Limit;\r
229 }\r
230 }\r
231 }\r
232 } else {\r
233 //\r
234 // Mem Bar\r
235 //\r
236 if (Command & EFI_PCI_COMMAND_MEMORY_SPACE) {\r
237\r
238 Mask = 0xfffffff0;\r
239 Base = OriginalValue & Mask;\r
240 Length = Value & Mask;\r
241\r
242 if ((Value & (BIT1 | BIT2)) == 0) {\r
243 //\r
244 // 32bit\r
245 //\r
246 Length = ((~Length) + 1) & 0xffffffff;\r
247\r
248 if ((Value & BIT3) == BIT3) {\r
249 MemAperture = PMem;\r
250 } else {\r
251 MemAperture = Mem;\r
252 }\r
253 } else {\r
254 //\r
255 // 64bit\r
256 //\r
257 Offset += 4;\r
258 PcatPciRootBridgeBarExisted (\r
259 PCI_LIB_ADDRESS (Bus, Device, Function, Offset),\r
260 &OriginalUpperValue,\r
261 &UpperValue\r
262 );\r
263\r
264 Base = Base | LShiftU64 ((UINT64) OriginalUpperValue, 32);\r
265 Length = Length | LShiftU64 ((UINT64) UpperValue, 32);\r
8a3a9781
MM
266 if (Length != 0) {\r
267 LowBit = LowBitSet64 (Length);\r
268 Length = LShiftU64 (1ULL, LowBit);\r
269 }\r
69787a9d
MM
270\r
271 if ((Value & BIT3) == BIT3) {\r
272 MemAperture = PMemAbove4G;\r
273 } else {\r
274 MemAperture = MemAbove4G;\r
275 }\r
276 }\r
277\r
278 Limit = Base + Length - 1;\r
279 if ((Base > 0) && (Base < Limit)) {\r
280 if (MemAperture->Base > Base) {\r
281 MemAperture->Base = Base;\r
282 }\r
283 if (MemAperture->Limit < Limit) {\r
284 MemAperture->Limit = Limit;\r
285 }\r
286 }\r
287 }\r
288 }\r
289 }\r
290}\r
291\r
292/**\r
293 Scan for all root bridges in platform.\r
294\r
295 @param[out] NumberOfRootBridges Number of root bridges detected\r
296\r
297 @retval Pointer to the allocated PCI_ROOT_BRIDGE structure array.\r
298**/\r
299PCI_ROOT_BRIDGE *\r
300ScanForRootBridges (\r
301 OUT UINTN *NumberOfRootBridges\r
302)\r
303{\r
304 UINTN PrimaryBus;\r
305 UINTN SubBus;\r
306 UINT8 Device;\r
307 UINT8 Function;\r
308 UINTN NumberOfDevices;\r
309 UINTN Address;\r
310 PCI_TYPE01 Pci;\r
311 UINT64 Attributes;\r
312 UINT64 Base;\r
313 UINT64 Limit;\r
314 UINT64 Value;\r
315 PCI_ROOT_BRIDGE_APERTURE Io, Mem, MemAbove4G, PMem, PMemAbove4G, *MemAperture;\r
316 PCI_ROOT_BRIDGE *RootBridges;\r
317 UINTN BarOffsetEnd;\r
318\r
319\r
320 *NumberOfRootBridges = 0;\r
321 RootBridges = NULL;\r
322\r
323 //\r
324 // After scanning all the PCI devices on the PCI root bridge's primary bus,\r
325 // update the Primary Bus Number for the next PCI root bridge to be this PCI\r
326 // root bridge's subordinate bus number + 1.\r
327 //\r
328 for (PrimaryBus = 0; PrimaryBus <= PCI_MAX_BUS; PrimaryBus = SubBus + 1) {\r
329 SubBus = PrimaryBus;\r
330 Attributes = 0;\r
6a9e59a1
HG
331\r
332 ZeroMem (&Io, sizeof (Io));\r
333 ZeroMem (&Mem, sizeof (Mem));\r
334 ZeroMem (&MemAbove4G, sizeof (MemAbove4G));\r
335 ZeroMem (&PMem, sizeof (PMem));\r
336 ZeroMem (&PMemAbove4G, sizeof (PMemAbove4G));\r
69787a9d 337 Io.Base = Mem.Base = MemAbove4G.Base = PMem.Base = PMemAbove4G.Base = MAX_UINT64;\r
69787a9d
MM
338 //\r
339 // Scan all the PCI devices on the primary bus of the PCI root bridge\r
340 //\r
341 for (Device = 0, NumberOfDevices = 0; Device <= PCI_MAX_DEVICE; Device++) {\r
342\r
343 for (Function = 0; Function <= PCI_MAX_FUNC; Function++) {\r
344\r
345 //\r
346 // Compute the PCI configuration address of the PCI device to probe\r
347 //\r
348 Address = PCI_LIB_ADDRESS (PrimaryBus, Device, Function, 0);\r
349\r
350 //\r
351 // Read the Vendor ID from the PCI Configuration Header\r
352 //\r
353 if (PciRead16 (Address) == MAX_UINT16) {\r
354 if (Function == 0) {\r
355 //\r
356 // If the PCI Configuration Read fails, or a PCI device does not\r
357 // exist, then skip this entire PCI device\r
358 //\r
359 break;\r
360 } else {\r
361 //\r
362 // If PCI function != 0, VendorId == 0xFFFF, we continue to search\r
363 // PCI function.\r
364 //\r
365 continue;\r
366 }\r
367 }\r
368\r
369 //\r
370 // Read the entire PCI Configuration Header\r
371 //\r
372 PciReadBuffer (Address, sizeof (Pci), &Pci);\r
373\r
374 //\r
375 // Increment the number of PCI device found on the primary bus of the\r
376 // PCI root bridge\r
377 //\r
378 NumberOfDevices++;\r
379\r
380 //\r
381 // Look for devices with the VGA Palette Snoop enabled in the COMMAND\r
382 // register of the PCI Config Header\r
383 //\r
384 if ((Pci.Hdr.Command & EFI_PCI_COMMAND_VGA_PALETTE_SNOOP) != 0) {\r
385 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;\r
386 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;\r
387 }\r
388\r
389 BarOffsetEnd = 0;\r
390\r
391 //\r
392 // PCI-PCI Bridge\r
393 //\r
394 if (IS_PCI_BRIDGE (&Pci)) {\r
395 //\r
396 // Get the Bus range that the PPB is decoding\r
397 //\r
398 if (Pci.Bridge.SubordinateBus > SubBus) {\r
399 //\r
68f87b25 400 // If the subordinate bus number of the PCI-PCI bridge is greater\r
69787a9d
MM
401 // than the PCI root bridge's current subordinate bus number,\r
402 // then update the PCI root bridge's subordinate bus number\r
403 //\r
404 SubBus = Pci.Bridge.SubordinateBus;\r
405 }\r
406\r
407 //\r
408 // Get the I/O range that the PPB is decoding\r
409 //\r
410 Value = Pci.Bridge.IoBase & 0x0f;\r
411 Base = ((UINT32) Pci.Bridge.IoBase & 0xf0) << 8;\r
412 Limit = (((UINT32) Pci.Bridge.IoLimit & 0xf0) << 8) | 0x0fff;\r
413 if (Value == BIT0) {\r
414 Base |= ((UINT32) Pci.Bridge.IoBaseUpper16 << 16);\r
415 Limit |= ((UINT32) Pci.Bridge.IoLimitUpper16 << 16);\r
416 }\r
417 if ((Base > 0) && (Base < Limit)) {\r
418 if (Io.Base > Base) {\r
419 Io.Base = Base;\r
420 }\r
421 if (Io.Limit < Limit) {\r
422 Io.Limit = Limit;\r
423 }\r
424 }\r
425\r
426 //\r
427 // Get the Memory range that the PPB is decoding\r
428 //\r
429 Base = ((UINT32) Pci.Bridge.MemoryBase & 0xfff0) << 16;\r
430 Limit = (((UINT32) Pci.Bridge.MemoryLimit & 0xfff0) << 16) | 0xfffff;\r
431 if ((Base > 0) && (Base < Limit)) {\r
432 if (Mem.Base > Base) {\r
433 Mem.Base = Base;\r
434 }\r
435 if (Mem.Limit < Limit) {\r
436 Mem.Limit = Limit;\r
437 }\r
438 }\r
439\r
440 //\r
441 // Get the Prefetchable Memory range that the PPB is decoding\r
442 //\r
443 Value = Pci.Bridge.PrefetchableMemoryBase & 0x0f;\r
444 Base = ((UINT32) Pci.Bridge.PrefetchableMemoryBase & 0xfff0) << 16;\r
445 Limit = (((UINT32) Pci.Bridge.PrefetchableMemoryLimit & 0xfff0)\r
446 << 16) | 0xfffff;\r
447 MemAperture = &PMem;\r
448 if (Value == BIT0) {\r
449 Base |= LShiftU64 (Pci.Bridge.PrefetchableBaseUpper32, 32);\r
450 Limit |= LShiftU64 (Pci.Bridge.PrefetchableLimitUpper32, 32);\r
451 MemAperture = &PMemAbove4G;\r
452 }\r
453 if ((Base > 0) && (Base < Limit)) {\r
454 if (MemAperture->Base > Base) {\r
455 MemAperture->Base = Base;\r
456 }\r
457 if (MemAperture->Limit < Limit) {\r
458 MemAperture->Limit = Limit;\r
459 }\r
460 }\r
461\r
462 //\r
463 // Look at the PPB Configuration for legacy decoding attributes\r
464 //\r
465 if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_ISA)\r
466 == EFI_PCI_BRIDGE_CONTROL_ISA) {\r
467 Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO;\r
468 Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16;\r
469 Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO;\r
470 }\r
471 if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_VGA)\r
472 == EFI_PCI_BRIDGE_CONTROL_VGA) {\r
473 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;\r
474 Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY;\r
475 Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO;\r
476 if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_VGA_16)\r
477 != 0) {\r
478 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;\r
479 Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO_16;\r
480 }\r
481 }\r
482\r
483 BarOffsetEnd = OFFSET_OF (PCI_TYPE01, Bridge.Bar[2]);\r
484 } else {\r
485 //\r
486 // Parse the BARs of the PCI device to get what I/O Ranges, Memory\r
487 // Ranges, and Prefetchable Memory Ranges the device is decoding\r
488 //\r
489 if ((Pci.Hdr.HeaderType & HEADER_LAYOUT_CODE) == HEADER_TYPE_DEVICE) {\r
490 BarOffsetEnd = OFFSET_OF (PCI_TYPE00, Device.Bar[6]);\r
491 }\r
492 }\r
493\r
494 PcatPciRootBridgeParseBars (\r
495 Pci.Hdr.Command,\r
496 PrimaryBus,\r
497 Device,\r
498 Function,\r
499 OFFSET_OF (PCI_TYPE00, Device.Bar),\r
500 BarOffsetEnd,\r
501 &Io,\r
502 &Mem, &MemAbove4G,\r
503 &PMem, &PMemAbove4G\r
504 );\r
505\r
506 //\r
507 // See if the PCI device is an IDE controller\r
508 //\r
509 if (IS_CLASS2 (&Pci, PCI_CLASS_MASS_STORAGE,\r
510 PCI_CLASS_MASS_STORAGE_IDE)) {\r
511 if (Pci.Hdr.ClassCode[0] & 0x80) {\r
512 Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO;\r
513 Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO;\r
514 }\r
515 if (Pci.Hdr.ClassCode[0] & 0x01) {\r
516 Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO;\r
517 }\r
518 if (Pci.Hdr.ClassCode[0] & 0x04) {\r
519 Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO;\r
520 }\r
521 }\r
522\r
523 //\r
524 // See if the PCI device is a legacy VGA controller or\r
525 // a standard VGA controller\r
526 //\r
527 if (IS_CLASS2 (&Pci, PCI_CLASS_OLD, PCI_CLASS_OLD_VGA) ||\r
528 IS_CLASS2 (&Pci, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA)\r
529 ) {\r
530 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;\r
531 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;\r
532 Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY;\r
533 Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO;\r
534 Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO_16;\r
535 }\r
536\r
537 //\r
538 // See if the PCI Device is a PCI - ISA or PCI - EISA\r
68f87b25 539 // or ISA_POSITIVE_DECODE Bridge device\r
69787a9d
MM
540 //\r
541 if (Pci.Hdr.ClassCode[2] == PCI_CLASS_BRIDGE) {\r
542 if (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA ||\r
543 Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_EISA ||\r
544 Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA_PDECODE) {\r
545 Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO;\r
546 Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16;\r
547 Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO;\r
548 }\r
549 }\r
550\r
551 //\r
552 // If this device is not a multi function device, then skip the rest\r
553 // of this PCI device\r
554 //\r
555 if (Function == 0 && !IS_PCI_MULTI_FUNC (&Pci)) {\r
556 break;\r
557 }\r
558 }\r
559 }\r
560\r
561 //\r
562 // If at least one PCI device was found on the primary bus of this PCI\r
563 // root bridge, then the PCI root bridge exists.\r
564 //\r
565 if (NumberOfDevices > 0) {\r
566 RootBridges = ReallocatePool (\r
567 (*NumberOfRootBridges) * sizeof (PCI_ROOT_BRIDGE),\r
568 (*NumberOfRootBridges + 1) * sizeof (PCI_ROOT_BRIDGE),\r
569 RootBridges\r
570 );\r
571 ASSERT (RootBridges != NULL);\r
572\r
573 AdjustRootBridgeResource (&Io, &Mem, &MemAbove4G, &PMem, &PMemAbove4G);\r
574\r
575 InitRootBridge (\r
576 Attributes, Attributes, 0,\r
577 (UINT8) PrimaryBus, (UINT8) SubBus,\r
578 &Io, &Mem, &MemAbove4G, &PMem, &PMemAbove4G,\r
579 &RootBridges[*NumberOfRootBridges]\r
580 );\r
581 RootBridges[*NumberOfRootBridges].ResourceAssigned = TRUE;\r
582 //\r
583 // Increment the index for the next PCI Root Bridge\r
584 //\r
585 (*NumberOfRootBridges)++;\r
586 }\r
587 }\r
588\r
589 return RootBridges;\r
590}\r