25PcatPciRootBridgeBarExisted (
27 OUT UINT32 *OriginalValue,
51#define PCI_COMMAND_DECODE ((UINT16)(EFI_PCI_COMMAND_IO_SPACE |\
52 EFI_PCI_COMMAND_MEMORY_SPACE))
55PcatPciRootBridgeDecodingDisable (
62 if (Value & PCI_COMMAND_DECODE) {
63 PciWrite16 (Address, Value & ~(UINT32)PCI_COMMAND_DECODE);
69PcatPciRootBridgeParseBars (
84 UINT32 OriginalUpperValue;
94 PcatPciRootBridgeDecodingDisable (
98 for (Offset = BarOffsetBase; Offset < BarOffsetEnd; Offset +=
sizeof (UINT32)) {
99 PcatPciRootBridgeBarExisted (
108 if ((Value & BIT0) == BIT0) {
114 Base = OriginalValue & Mask;
115 Length = ((~(Value & Mask)) & Mask) + 0x04;
116 if (!(Value & 0xFFFF0000)) {
117 Length &= 0x0000FFFF;
120 Limit = Base + Length - 1;
123 if (Io->Base > Base) {
127 if (Io->Limit < Limit) {
138 Base = OriginalValue & Mask;
139 Length = Value & Mask;
141 if ((Value & (BIT1 | BIT2)) == 0) {
145 Length = ((~Length) + 1) & 0xffffffff;
153 PcatPciRootBridgeBarExisted (
159 Base = Base |
LShiftU64 ((UINT64)OriginalUpperValue, 32);
160 Length = Length |
LShiftU64 ((UINT64)UpperValue, 32);
161 Length = (~Length) + 1;
163 if (Base < BASE_4GB) {
166 MemAperture = MemAbove4G;
170 Limit = Base + Length - 1;
172 if (MemAperture->Base > Base) {
173 MemAperture->Base = Base;
176 if (MemAperture->Limit < Limit) {
177 MemAperture->Limit = Limit;
189 UINTN *NumberOfRootBridges
196 UINTN NumberOfDevices;
207 *NumberOfRootBridges = 0;
215 for (PrimaryBus = 0; PrimaryBus <= PCI_MAX_BUS; PrimaryBus = SubBus + 1) {
221 ZeroMem (&MemAbove4G,
sizeof (MemAbove4G));
222 Io.Base = Mem.Base = MemAbove4G.Base = MAX_UINT64;
226 for (Device = 0, NumberOfDevices = 0; Device <= PCI_MAX_DEVICE; Device++) {
227 for (Function = 0; Function <= PCI_MAX_FUNC; Function++) {
268 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;
269 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
281 if (Pci.Bridge.SubordinateBus > SubBus) {
287 SubBus = Pci.Bridge.SubordinateBus;
293 Value = Pci.Bridge.IoBase & 0x0f;
294 Base = ((UINT32)Pci.Bridge.IoBase & 0xf0) << 8;
295 Limit = (((UINT32)Pci.Bridge.IoLimit & 0xf0) << 8) | 0x0fff;
297 Base |= ((UINT32)Pci.Bridge.IoBaseUpper16 << 16);
298 Limit |= ((UINT32)Pci.Bridge.IoLimitUpper16 << 16);
302 if (Io.Base > Base) {
306 if (Io.Limit < Limit) {
314 Base = ((UINT32)Pci.Bridge.MemoryBase & 0xfff0) << 16;
315 Limit = (((UINT32)Pci.Bridge.MemoryLimit & 0xfff0) << 16) | 0xfffff;
317 if (Mem.Base > Base) {
321 if (Mem.Limit < Limit) {
330 Value = Pci.Bridge.PrefetchableMemoryBase & 0x0f;
331 Base = ((UINT32)Pci.Bridge.PrefetchableMemoryBase & 0xfff0) << 16;
332 Limit = (((UINT32)Pci.Bridge.PrefetchableMemoryLimit & 0xfff0)
336 Base |=
LShiftU64 (Pci.Bridge.PrefetchableBaseUpper32, 32);
337 Limit |=
LShiftU64 (Pci.Bridge.PrefetchableLimitUpper32, 32);
338 MemAperture = &MemAbove4G;
342 if (MemAperture->Base > Base) {
343 MemAperture->Base = Base;
346 if (MemAperture->Limit < Limit) {
347 MemAperture->Limit = Limit;
357 Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO;
358 Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16;
359 Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO;
365 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;
366 Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY;
367 Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO;
371 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
372 Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO_16;
382 if ((Pci.Hdr.HeaderType & HEADER_LAYOUT_CODE) == HEADER_TYPE_DEVICE) {
387 PcatPciRootBridgeParseBars (
404 PCI_CLASS_MASS_STORAGE,
405 PCI_CLASS_MASS_STORAGE_IDE
408 if (Pci.Hdr.ClassCode[0] & 0x80) {
409 Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO;
410 Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO;
413 if (Pci.Hdr.ClassCode[0] & 0x01) {
414 Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO;
417 if (Pci.Hdr.ClassCode[0] & 0x04) {
418 Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO;
426 if (
IS_CLASS2 (&Pci, PCI_CLASS_OLD, PCI_CLASS_OLD_VGA) ||
427 IS_CLASS2 (&Pci, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA)
430 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;
431 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
432 Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY;
433 Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO;
434 Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO_16;
441 if (Pci.Hdr.ClassCode[2] == PCI_CLASS_BRIDGE) {
442 if ((Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA) ||
443 (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_EISA) ||
444 (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA_PDECODE))
446 Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO;
447 Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16;
448 Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO;
466 if (NumberOfDevices > 0) {
472 ASSERT (RootBridges !=
NULL);
486 &RootBridges[*NumberOfRootBridges]
492 (*NumberOfRootBridges)++;
VOID EFIAPI EnableInterrupts(VOID)
VOID EFIAPI DisableInterrupts(VOID)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI ReallocatePool(IN UINTN OldSize, IN UINTN NewSize, IN VOID *OldBuffer OPTIONAL)
#define OFFSET_OF(TYPE, Field)
UINT32 EFIAPI PciRead32(IN UINTN Address)
#define PCI_LIB_ADDRESS(Bus, Device, Function, Register)
UINT32 EFIAPI PciWrite32(IN UINTN Address, IN UINT32 Value)
UINT16 EFIAPI PciWrite16(IN UINTN Address, IN UINT16 Value)
UINTN EFIAPI PciReadBuffer(IN UINTN StartAddress, IN UINTN Size, OUT VOID *Buffer)
UINT16 EFIAPI PciRead16(IN UINTN Address)
#define EFI_PCI_BRIDGE_CONTROL_VGA_16
0x0010
#define IS_PCI_BRIDGE(_p)
#define EFI_PCI_BRIDGE_CONTROL_VGA
0x0008
#define EFI_PCI_COMMAND_MEMORY_SPACE
0x0002
#define IS_CLASS2(_p, c, s)
#define EFI_PCI_COMMAND_IO_SPACE
0x0001
#define IS_PCI_MULTI_FUNC(_p)
#define EFI_PCI_BRIDGE_CONTROL_ISA
0x0004
#define EFI_PCI_COMMAND_VGA_PALETTE_SNOOP
0x0020
EFI_STATUS EFIAPI PciHostBridgeUtilityInitRootBridge(IN UINT64 Supports, IN UINT64 Attributes, IN UINT64 AllocAttributes, IN BOOLEAN DmaAbove4G, IN BOOLEAN NoExtendedConfigSpace, IN UINT8 RootBusNumber, IN UINT8 MaxSubBusNumber, 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, OUT PCI_ROOT_BRIDGE *RootBus)