UEFI PCI Bus Driver分析

本文详细介绍了PCI总线在EFI环境下初始化的具体流程。从驱动入口函数开始,安装EFI_DRIVER_BINDING_PROTOCOL到映像句柄,并解释了句柄的用途。随后深入EFI_DRIVER_BINDING_PROTOCOL中的Supported与Start函数,阐述了如何通过不同协议来枚举PCI设备,包括资源分配及属性设置等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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


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.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值