59 PciDeviceNode->Parent = Bridge;
91 ASSERT (PciIoDevice !=
NULL);
95 if (PciIoDevice->ResourcePaddingDescriptors !=
NULL) {
96 FreePool (PciIoDevice->ResourcePaddingDescriptors);
99 if (PciIoDevice->DevicePath !=
NULL) {
103 if (PciIoDevice->BusNumberRanges !=
NULL) {
104 FreePool (PciIoDevice->BusNumberRanges);
126 CurrentLink = Bridge->ChildList.ForwardLink;
133 Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
164 CurrentLink = mPciDevicePool.ForwardLink;
166 while (CurrentLink !=
NULL && CurrentLink != &mPciDevicePool) {
167 Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
169 if (Temp->Handle == Controller) {
179 CurrentLink = CurrentLink->ForwardLink;
182 return EFI_NOT_FOUND;
208 VOID *PlatformOpRomBuffer;
209 UINTN PlatformOpRomSize;
217 Status =
gBS->InstallMultipleProtocolInterfaces (
218 &PciIoDevice->Handle,
219 &gEfiDevicePathProtocolGuid,
220 PciIoDevice->DevicePath,
221 &gEfiPciIoProtocolGuid,
225 if (EFI_ERROR (Status)) {
232 PciIo = &(PciIoDevice->PciIo);
234 PciIo->Pci.
Write (PciIo, EfiPciIoWidthUint8, 0x3C, 1, &Data8);
239 if (!PciIoDevice->AllOpRomProcessed) {
243 if (gPciPlatformProtocol !=
NULL) {
244 Status = gPciPlatformProtocol->
GetPciRom (
245 gPciPlatformProtocol,
247 &PlatformOpRomBuffer,
250 if (!EFI_ERROR (Status)) {
251 PciIoDevice->EmbeddedRom =
FALSE;
252 PciIoDevice->RomSize = (UINT32)PlatformOpRomSize;
253 PciIoDevice->PciIo.RomSize = PlatformOpRomSize;
254 PciIoDevice->PciIo.RomImage = PlatformOpRomBuffer;
261 PciIoDevice->PciRootBridgeIo->SegmentNumber,
262 PciIoDevice->BusNumber,
263 PciIoDevice->DeviceNumber,
264 PciIoDevice->FunctionNumber,
265 PciIoDevice->PciIo.RomImage,
266 PciIoDevice->PciIo.RomSize
269 }
else if (gPciOverrideProtocol !=
NULL) {
270 Status = gPciOverrideProtocol->
GetPciRom (
271 gPciOverrideProtocol,
273 &PlatformOpRomBuffer,
276 if (!EFI_ERROR (Status)) {
277 PciIoDevice->EmbeddedRom =
FALSE;
278 PciIoDevice->RomSize = (UINT32)PlatformOpRomSize;
279 PciIoDevice->PciIo.RomSize = PlatformOpRomSize;
280 PciIoDevice->PciIo.RomImage = PlatformOpRomBuffer;
287 PciIoDevice->PciRootBridgeIo->SegmentNumber,
288 PciIoDevice->BusNumber,
289 PciIoDevice->DeviceNumber,
290 PciIoDevice->FunctionNumber,
291 PciIoDevice->PciIo.RomImage,
292 PciIoDevice->PciIo.RomSize
301 HasEfiImage =
ContainEfiImage (PciIoDevice->PciIo.RomImage, PciIoDevice->PciIo.RomSize);
304 Status =
gBS->InstallMultipleProtocolInterfaces (
305 &PciIoDevice->Handle,
306 &gEfiLoadFile2ProtocolGuid,
307 &PciIoDevice->LoadFile2,
310 if (EFI_ERROR (Status)) {
311 gBS->UninstallMultipleProtocolInterfaces (
313 &gEfiDevicePathProtocolGuid,
314 PciIoDevice->DevicePath,
315 &gEfiPciIoProtocolGuid,
323 if (!PciIoDevice->AllOpRomProcessed) {
324 PciIoDevice->AllOpRomProcessed =
TRUE;
336 if (PciIoDevice->BusOverride) {
340 Status =
gBS->InstallMultipleProtocolInterfaces (
341 &PciIoDevice->Handle,
342 &gEfiBusSpecificDriverOverrideProtocolGuid,
343 &PciIoDevice->PciDriverOverride,
346 if (EFI_ERROR (Status)) {
347 gBS->UninstallMultipleProtocolInterfaces (
349 &gEfiDevicePathProtocolGuid,
350 PciIoDevice->DevicePath,
351 &gEfiPciIoProtocolGuid,
356 gBS->UninstallMultipleProtocolInterfaces (
358 &gEfiLoadFile2ProtocolGuid,
359 &PciIoDevice->LoadFile2,
368 Status =
gBS->OpenProtocol (
370 &gEfiPciRootBridgeIoProtocolGuid,
371 (VOID **)&(PciIoDevice->PciRootBridgeIo),
374 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
376 if (EFI_ERROR (Status)) {
380 if (Handle !=
NULL) {
381 *Handle = PciIoDevice->Handle;
387 PciIoDevice->Registered =
TRUE;
410 CurrentLink = Bridge->ChildList.ForwardLink;
411 Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
417 if (Temp->Registered) {
461 Status =
gBS->OpenProtocol (
463 &gEfiPciIoProtocolGuid,
467 EFI_OPEN_PROTOCOL_GET_PROTOCOL
469 if (!EFI_ERROR (Status)) {
470 PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (PciIo);
475 if (!PciIoDevice->Registered) {
484 CurrentLink = PciIoDevice->ChildList.ForwardLink;
486 while (CurrentLink !=
NULL && CurrentLink != &PciIoDevice->ChildList) {
487 Node = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
490 if (EFI_ERROR (Status)) {
494 CurrentLink = CurrentLink->ForwardLink;
501 Status =
gBS->CloseProtocol (
503 &gEfiPciRootBridgeIoProtocolGuid,
512 if (PciIoDevice->BusOverride) {
513 Status =
gBS->UninstallMultipleProtocolInterfaces (
515 &gEfiDevicePathProtocolGuid,
516 PciIoDevice->DevicePath,
517 &gEfiPciIoProtocolGuid,
519 &gEfiBusSpecificDriverOverrideProtocolGuid,
520 &PciIoDevice->PciDriverOverride,
524 Status =
gBS->UninstallMultipleProtocolInterfaces (
526 &gEfiDevicePathProtocolGuid,
527 PciIoDevice->DevicePath,
528 &gEfiPciIoProtocolGuid,
534 if (!EFI_ERROR (Status)) {
538 Status =
gBS->OpenProtocol (
540 &gEfiLoadFile2ProtocolGuid,
544 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
546 if (!EFI_ERROR (Status)) {
547 Status =
gBS->UninstallMultipleProtocolInterfaces (
549 &gEfiLoadFile2ProtocolGuid,
550 &PciIoDevice->LoadFile2,
561 if (EFI_ERROR (Status)) {
564 &gEfiPciRootBridgeIoProtocolGuid,
565 (VOID **)&PciRootBridgeIo,
568 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
578 PciIoDevice->Registered =
FALSE;
579 PciIoDevice->Handle =
NULL;
610 IN OUT UINT8 *NumberOfChildren,
623 CurrentLink = RootBridge->ChildList.ForwardLink;
625 while (CurrentLink !=
NULL && CurrentLink != &RootBridge->ChildList) {
626 PciIoDevice = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
627 if (RemainingDevicePath !=
NULL) {
628 Node.DevPath = RemainingDevicePath;
630 if ((Node.Pci->
Device != PciIoDevice->DeviceNumber) ||
631 (Node.Pci->
Function != PciIoDevice->FunctionNumber))
633 CurrentLink = CurrentLink->ForwardLink;
640 if (!PciIoDevice->Allocated) {
641 return EFI_NOT_READY;
648 if (!PciIoDevice->Registered) {
656 if ((NumberOfChildren !=
NULL) && (ChildHandleBuffer !=
NULL) && PciIoDevice->Registered) {
657 ChildHandleBuffer[*NumberOfChildren] = PciIoDevice->Handle;
658 (*NumberOfChildren)++;
681 PciIoDevice->PciIo.Attributes (
682 &(PciIoDevice->PciIo),
687 Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;
688 PciIoDevice->PciIo.Attributes (
689 &(PciIoDevice->PciIo),
700 return EFI_UNSUPPORTED;
707 if (!PciIoDevice->Registered && PciIoDevice->Allocated) {
715 if ((NumberOfChildren !=
NULL) && (ChildHandleBuffer !=
NULL) && PciIoDevice->Registered) {
716 ChildHandleBuffer[*NumberOfChildren] = PciIoDevice->Handle;
717 (*NumberOfChildren)++;
729 PciIoDevice->PciIo.Attributes (
730 &(PciIoDevice->PciIo),
735 Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;
736 PciIoDevice->PciIo.Attributes (
737 &(PciIoDevice->PciIo),
744 CurrentLink = CurrentLink->ForwardLink;
748 if (PciIoDevice ==
NULL) {
749 return EFI_NOT_FOUND;
775 ASSERT (RootBridge !=
NULL);
776 ThisHostBridge = RootBridge->PciRootBridgeIo->
ParentHandle;
778 CurrentLink = mPciDevicePool.ForwardLink;
780 while (CurrentLink !=
NULL && CurrentLink != &mPciDevicePool) {
781 RootBridge = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
785 if (RootBridge->PciRootBridgeIo->
ParentHandle == ThisHostBridge) {
795 CurrentLink = CurrentLink->ForwardLink;
825 Dev->Signature = PCI_IO_DEVICE_SIGNATURE;
826 Dev->Handle = RootBridgeHandle;
829 Status =
gBS->OpenProtocol (
831 &gEfiDevicePathProtocolGuid,
832 (VOID **)&ParentDevicePath,
835 EFI_OPEN_PROTOCOL_GET_PROTOCOL
838 if (EFI_ERROR (Status)) {
851 Status =
gBS->OpenProtocol (
853 &gEfiPciRootBridgeIoProtocolGuid,
854 (VOID **)&PciRootBridgeIo,
857 EFI_OPEN_PROTOCOL_GET_PROTOCOL
860 if (EFI_ERROR (Status)) {
865 Dev->PciRootBridgeIo = PciRootBridgeIo;
901 CurrentLink = mPciDevicePool.ForwardLink;
903 while (CurrentLink !=
NULL && CurrentLink != &mPciDevicePool) {
904 RootBridgeDev = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
905 if (RootBridgeDev->Handle == RootBridgeHandle) {
906 return RootBridgeDev;
909 CurrentLink = CurrentLink->ForwardLink;
934 CurrentLink = Bridge->ChildList.ForwardLink;
936 while (CurrentLink !=
NULL && CurrentLink != &Bridge->ChildList) {
937 Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
939 if (Temp == PciIoDevice) {
949 CurrentLink = CurrentLink->ForwardLink;
971 CurrentLink = mPciDevicePool.ForwardLink;
973 while (CurrentLink !=
NULL && CurrentLink != &mPciDevicePool) {
974 PciIoDevice = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
976 if (PciIoDevice->PciRootBridgeIo->
ParentHandle == HostBridgeHandle) {
979 if (PciIoDevice !=
NULL) {
984 CurrentLink = CurrentLink->ForwardLink;
1006 CurrentLink = Bridge->ChildList.ForwardLink;
1008 while (CurrentLink !=
NULL && CurrentLink != &Bridge->ChildList) {
1009 PciIoDevice = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
1012 ((PciIoDevice->Attributes &
1023 if (PciIoDevice !=
NULL) {
1028 CurrentLink = CurrentLink->ForwardLink;
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DuplicateDevicePath(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY
MEM cycles 0xA0000-0xBFFFF (24 bit decode)
#define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16
I/O cycles 0x3B0-0x3BB and 0x3C0-0x3DF (16 bit decode)
@ EfiPciIoAttributeOperationEnable
@ EfiPciIoAttributeOperationSupported
#define EFI_PCI_IO_ATTRIBUTE_VGA_IO
I/O cycles 0x3B0-0x3BB and 0x3C0-0x3DF (10 bit decode)
#define IS_PCI_BRIDGE(_p)
#define PCI_INT_LINE_UNKNOWN
EFI_STATUS DeRegisterPciDevice(IN EFI_HANDLE Controller, IN EFI_HANDLE Handle)
EFI_STATUS RegisterPciDevice(IN EFI_HANDLE Controller, IN PCI_IO_DEVICE *PciIoDevice, OUT EFI_HANDLE *Handle OPTIONAL)
PCI_IO_DEVICE * CreateRootBridge(IN EFI_HANDLE RootBridgeHandle)
VOID DestroyPciDeviceTree(IN PCI_IO_DEVICE *Bridge)
VOID DestroyRootBridge(IN PCI_IO_DEVICE *RootBridge)
EFI_STATUS DestroyRootBridgeByHandle(IN EFI_HANDLE Controller)
VOID InsertRootBridge(IN PCI_IO_DEVICE *RootBridge)
EFI_STATUS StartPciDevicesOnBridge(IN EFI_HANDLE Controller, IN PCI_IO_DEVICE *RootBridge, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath, IN OUT UINT8 *NumberOfChildren, IN OUT EFI_HANDLE *ChildHandleBuffer)
BOOLEAN PciDeviceExisted(IN PCI_IO_DEVICE *Bridge, IN PCI_IO_DEVICE *PciIoDevice)
VOID InitializePciDevicePool(VOID)
EFI_STATUS StartPciDevices(IN EFI_HANDLE Controller)
PCI_IO_DEVICE * GetRootBridgeByHandle(EFI_HANDLE RootBridgeHandle)
VOID FreePciDevice(IN PCI_IO_DEVICE *PciIoDevice)
PCI_IO_DEVICE * LocateVgaDevice(IN PCI_IO_DEVICE *Bridge)
VOID InsertPciDevice(IN PCI_IO_DEVICE *Bridge, IN PCI_IO_DEVICE *PciDeviceNode)
PCI_IO_DEVICE * LocateVgaDeviceOnHostBridge(IN EFI_HANDLE HostBridgeHandle)
VOID RemoveAllPciDeviceOnBridge(EFI_HANDLE RootBridgeHandle, PCI_IO_DEVICE *Bridge)
VOID InitializePciDriverOverrideInstance(IN OUT PCI_IO_DEVICE *PciIoDevice)
VOID InitializePciIoInstance(IN PCI_IO_DEVICE *PciIoDevice)
VOID InitializePciLoadFile2(IN PCI_IO_DEVICE *PciIoDevice)
BOOLEAN ContainEfiImage(IN VOID *RomImage, IN UINT64 RomSize)
EFI_STATUS ProcessOpRomImage(IN PCI_IO_DEVICE *PciDevice)
VOID PciRomAddImageMapping(IN EFI_HANDLE ImageHandle, IN UINTN Seg, IN UINT8 Bus, IN UINT8 Dev, IN UINT8 Func, IN VOID *RomImage, IN UINT64 RomSize)
EFI_HANDLE DriverBindingHandle
EFI_PCI_PLATFORM_GET_PCI_ROM GetPciRom
EFI_PCI_IO_PROTOCOL_CONFIG Write