UEFI PCI Bus Driver分析

草稿:等所有都写完会稍加完善, 未完待续....


1.The image handle is this driver's image

2.The Controller is the PCI root bridge device handle.

 

Take PCIBusDxe inAllPackagesDev\MdeModulePkg\Bus\Pci\PciBusDxe for example.

1.In the driverentry function PciBusEntryPoint (PciBus.c), it just install theEFI_DRIVER_BINDING_PROTOCOL to the image handle. This image handle is a driver handle? Device handle? (Preferdriver handle, and EFI_DRIVER_BINDING_PROTOCOL is installed to thedriver handle.)

 

2.In theEFI_DRIVER_BINDING_PROTOCOL.Supported function:

1.Itfirst check the RemainDevicePath info, it is not a PCI Device path type, returnerror. When the RemainDevicePathis not NULL, how to use this parameter???

2.Controller Handle??? When needto first use this controller handle, it must be a device handle.

1.Check whether this driver canused by this controller, so this is the first time this controller is used forthis driver.

2.Different drivers used for thiscontroller? Or different controller used by this driver? (Prefer differentdrivers used for this device)

3.Returnstatus from OpenProtocol, EFI_ALREADY_STARTED, Other errors, and success?What's the means?

 

3.In theEFI_DRIVER_BINDING_PROTOCOL.Start function:

1.Checkthe RemainDevicePath parameter, if it is a End Node, just return EFI_SUCCESS.Why this logic here? Why End node return SUCCESS? Which situation this casewill occur?

2.Getthe three high priority

protocol:gEfiIncompatiblePciDeviceSupportProtocolGuid

gEfiPciPlatformProtocolGuid

gEfiPciOverrideProtocolGuid

3.Checkwhether need to do full enumeration, call SearchHostBridgeHandle function todecide.

4.CallPciEnumerator function to do PCI enumerate.

5.CallStartPciDevices to start the device.

 

4.PciEnumeratorfunction:

1.Getthe gEfiPciRootBridgeIoProtocolGuid andgEfiPciHostBridgeResourceAllocationProtocolGuid protocol.

2.CallNotifyPhase function with EfiPciHostBridgeBeginEnumeration flag to Notify thepci bus enumeration is about to begin.

3.CallPciHostBridgeEnumerator function to Start the bus allocation phase. (Detail see5.)

4.CallPciHostBridgeResourceAllocator to submit the resource request.

5.CallNotifyPhase function with EfiPciHostBridgeEndEnumeration flag to Notify the pcibus enumeration is about to complete.

6.CallPciHostBridgeP2CProcess function to Process P2C.

7.CallPciHostBridgeDeviceAttribute to Process attributes for devices on this hostbridge

8.Installthe gEfiPciEnumerationCompleteProtocolGuid protocol to inform PCI enumerate hasfinished.

 

5.PciHostBridgeEnumeratorfunction.

1.CallNotifyPhase with EfiPciHostBridgeBeginBusAllocation flag to Notify the busallocation phase is about to start.

2.Sethe while circuit to enumerate all PCI root handle:

1.Callfunction CreateRootBridge to create Root Bridge Dev.

2.Callfunction PciRootBridgeEnumerator to Enumerate all the buses  under this root bridge. (Detail see 6.)

3.CallDestroyRootBridge to destroy this root bridge dev.

3.CallNotifyPhase with EfiPciHostBridgeEndBusAllocation flag to Notify the busallocation phase is finished for the first time.

 

4.CallNotifyPhase with EfiPciHostBridgeBeginResourceAllocation flag to Notify theresource allocation phase is to start.

5.Sethe while circuit to enumerate all PCI root handle:

1.Callfunction CreateRootBridge to create Root Bridge Dev.

2.CallStartManagingRootBridge function ...

3.Getthe Bus Range info by function PciGetBusRange.

4.Determineroot bridge attribute by calling interface of Pcihostbridge protocol infunction DetermineRootBridgeAttributes.

5.Callfunction PciPciDeviceInfoCollector ...

6.Savethis Root bridge by call InsertRootBridge function.

7.CallAddHostBridgeEnumerator ...

 

6.PciRootBridgeEnumeratorfunction:

1.CallEFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL->StartBusEnumeration to getBus Information.

2.Sortthe descriptors in ascending order.

3.Getthe bus number to start with, call ResetAllPpbBusNumber function to reset allassigned PCI bus number.


你可能感兴趣的:(UEFI PCI Bus Driver分析)