32 OUT UINT32 *OriginalValue,
98 UINT32 OriginalUpperValue;
108 for (Offset = BarOffsetBase; Offset < BarOffsetEnd; Offset +=
sizeof (UINT32)) {
118 if ((Value & BIT0) == BIT0) {
124 Base = OriginalValue & Mask;
125 Length = ((~(Value & Mask)) & Mask) + 0x04;
126 if (!(Value & 0xFFFF0000)) {
127 Length &= 0x0000FFFF;
130 Limit = Base + Length - 1;
132 if ((Base > 0) && (Base < Limit)) {
133 if (Io->Base > Base) {
137 if (Io->Limit < Limit) {
148 Base = OriginalValue & Mask;
149 Length = Value & Mask;
151 if ((Value & (BIT1 | BIT2)) == 0) {
155 Length = ((~Length) + 1) & 0xffffffff;
169 Base = Base |
LShiftU64 ((UINT64)OriginalUpperValue, 32);
170 Length = Length |
LShiftU64 ((UINT64)UpperValue, 32);
176 if (Base < BASE_4GB) {
179 MemAperture = MemAbove4G;
183 Limit = Base + Length - 1;
184 if ((Base > 0) && (Base < Limit)) {
185 if (MemAperture->Base > Base) {
186 MemAperture->Base = Base;
189 if (MemAperture->Limit < Limit) {
190 MemAperture->Limit = Limit;
216 UINTN NumberOfDevices;
230 *NumberOfRootBridges = 0;
238 for (PrimaryBus = 0; PrimaryBus <= PCI_MAX_BUS; PrimaryBus = SubBus + 1) {
244 ZeroMem (&MemAbove4G,
sizeof (MemAbove4G));
245 Io.Base = Mem.Base = MemAbove4G.Base = MAX_UINT64;
249 for (Device = 0, NumberOfDevices = 0; Device <= PCI_MAX_DEVICE; Device++) {
250 for (Function = 0; Function <= PCI_MAX_FUNC; Function++) {
291 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;
292 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
304 if (Pci.Bridge.SubordinateBus > SubBus) {
310 SubBus = Pci.Bridge.SubordinateBus;
316 Value = Pci.Bridge.IoBase & 0x0f;
317 Base = ((UINT32)Pci.Bridge.IoBase & 0xf0) << 8;
318 Limit = (((UINT32)Pci.Bridge.IoLimit & 0xf0) << 8) | 0x0fff;
320 Base |= ((UINT32)Pci.Bridge.IoBaseUpper16 << 16);
321 Limit |= ((UINT32)Pci.Bridge.IoLimitUpper16 << 16);
324 if ((Base > 0) && (Base < Limit)) {
325 if (Io.Base > Base) {
329 if (Io.Limit < Limit) {
337 Base = ((UINT32)Pci.Bridge.MemoryBase & 0xfff0) << 16;
338 Limit = (((UINT32)Pci.Bridge.MemoryLimit & 0xfff0) << 16) | 0xfffff;
339 if ((Base > 0) && (Base < Limit)) {
340 if (Mem.Base > Base) {
344 if (Mem.Limit < Limit) {
353 Value = Pci.Bridge.PrefetchableMemoryBase & 0x0f;
354 Base = ((UINT32)Pci.Bridge.PrefetchableMemoryBase & 0xfff0) << 16;
355 Limit = (((UINT32)Pci.Bridge.PrefetchableMemoryLimit & 0xfff0)
359 Base |=
LShiftU64 (Pci.Bridge.PrefetchableBaseUpper32, 32);
360 Limit |=
LShiftU64 (Pci.Bridge.PrefetchableLimitUpper32, 32);
363 if ((Base > 0) && (Base < Limit)) {
364 if (Base < BASE_4GB) {
367 MemAperture = &MemAbove4G;
370 if (MemAperture->Base > Base) {
371 MemAperture->Base = Base;
374 if (MemAperture->Limit < Limit) {
375 MemAperture->Limit = Limit;
385 Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO;
386 Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16;
387 Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO;
393 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;
394 Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY;
395 Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO;
399 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
400 Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO_16;
410 if ((Pci.Hdr.HeaderType & HEADER_LAYOUT_CODE) == HEADER_TYPE_DEVICE) {
432 PCI_CLASS_MASS_STORAGE,
433 PCI_CLASS_MASS_STORAGE_IDE
436 if (Pci.Hdr.ClassCode[0] & 0x80) {
437 Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO;
438 Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO;
441 if (Pci.Hdr.ClassCode[0] & 0x01) {
442 Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO;
445 if (Pci.Hdr.ClassCode[0] & 0x04) {
446 Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO;
454 if (
IS_CLASS2 (&Pci, PCI_CLASS_OLD, PCI_CLASS_OLD_VGA) ||
455 IS_CLASS2 (&Pci, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA)
458 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;
459 Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
460 Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY;
461 Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO;
462 Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO_16;
469 if (Pci.Hdr.ClassCode[2] == PCI_CLASS_BRIDGE) {
470 if ((Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA) ||
471 (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_EISA) ||
472 (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA_PDECODE))
474 Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO;
475 Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16;
476 Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO;
494 if (NumberOfDevices > 0) {
500 ASSERT (RootBridges !=
NULL);
513 &RootBridges[*NumberOfRootBridges]
519 (*NumberOfRootBridges)++;
545 ASSERT (PciRootBridgeInfo !=
NULL);
546 ASSERT (NumberOfRootBridges !=
NULL);
547 if (PciRootBridgeInfo ==
NULL) {
551 if (PciRootBridgeInfo->Count == 0) {
558 ASSERT (PciRootBridges !=
NULL);
559 if (PciRootBridges ==
NULL) {
568 for (Index = 0; Index < PciRootBridgeInfo->Count; Index++) {
569 PciRootBridges[Index].
Segment = PciRootBridgeInfo->RootBridge[Index].Segment;
570 PciRootBridges[Index].
Supports = PciRootBridgeInfo->RootBridge[Index].Supports;
571 PciRootBridges[Index].
Attributes = PciRootBridgeInfo->RootBridge[Index].Attributes;
572 PciRootBridges[Index].
DmaAbove4G = PciRootBridgeInfo->RootBridge[Index].DmaAbove4G;
573 PciRootBridges[Index].
NoExtendedConfigSpace = PciRootBridgeInfo->RootBridge[Index].NoExtendedConfigSpace;
574 PciRootBridges[Index].
ResourceAssigned = PciRootBridgeInfo->ResourceAssigned;
575 PciRootBridges[Index].
AllocationAttributes = PciRootBridgeInfo->RootBridge[Index].AllocationAttributes;
585 *NumberOfRootBridges = PciRootBridgeInfo->Count;
590 if (PciRootBridgeInfo->ResourceAssigned) {
593 DEBUG ((DEBUG_INFO,
"There is root bridge whose ResourceAssigned is FALSE\n"));
597 return PciRootBridges;
VOID EFIAPI EnableInterrupts(VOID)
VOID EFIAPI DisableInterrupts(VOID)
INTN EFIAPI LowBitSet64(IN UINT64 Operand)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
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)
#define DEBUG(Expression)
UINT32 EFIAPI PciRead32(IN UINTN Address)
#define PCI_LIB_ADDRESS(Bus, Device, Function, Register)
UINT32 EFIAPI PciWrite32(IN UINTN Address, IN UINT32 Value)
UINTN EFIAPI PciReadBuffer(IN UINTN StartAddress, IN UINTN Size, OUT VOID *Buffer)
UINT16 EFIAPI PciRead16(IN UINTN Address)
#define PcdSetBoolS(TokenName, Value)
#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
PCI_ROOT_BRIDGE * RetrieveRootBridgeInfoFromHob(IN UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridgeInfo, OUT UINTN *NumberOfRootBridges)
PCI_ROOT_BRIDGE * ScanForRootBridges(OUT UINTN *NumberOfRootBridges)
STATIC VOID PcatPciRootBridgeParseBars(IN UINT16 Command, IN UINTN Bus, IN UINTN Device, IN UINTN Function, IN UINTN BarOffsetBase, IN UINTN BarOffsetEnd, IN PCI_ROOT_BRIDGE_APERTURE *Io, IN PCI_ROOT_BRIDGE_APERTURE *Mem, IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G)
STATIC VOID PcatPciRootBridgeBarExisted(IN UINTN Address, OUT UINT32 *OriginalValue, OUT UINT32 *Value)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_DEVICE_PATH_PROTOCOL * CreateRootBridgeDevicePath(IN UINT32 HID, IN UINT32 UID)
EFI_STATUS InitRootBridge(IN UINT64 Supports, IN UINT64 Attributes, IN UINT64 AllocAttributes, 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)
PCI_ROOT_BRIDGE_APERTURE Io
IO aperture which can be used by the root bridge.
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