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(Unified Extensible Firmware Interface)是一种新一代的固件接口标准,用于替代传统的BIOS(Basic Input/Output System)。UEFI的引入使得计算机启动速度更快、性能更好,并且提供更多的扩展功能。 在UEFI中,PCI(Peripheral Component Interconnect)是一种计算机总线技术,用于连接外部设备,例如网络适配器、显卡等。PCI总线上的每个设备都有一个唯一的标识符,称为设备ID,用于识别设备并管理其操作。 在UEFI中,PCI设备的遍历是指系统固件或操作系统对机器上所有PCI设备进行枚举和初始化的过程。这个过程通常在计算机启动时进行,以确保所有PCI设备都能被正确地识别、配置和使用。 PCI设备的遍历过程一般分为以下几个步骤: 1. 初始化PCI总线控制器:UEFI固件首先初始化PCI总线控制器,以便与PCI总线上的设备进行通信。 2. 遍历PCI设备:UEFI固件通过PCI总线控制器逐个枚举PCI设备,根据设备ID识别每个设备,并获取设备的配置空间信息。 3. 配置PCI设备:UEFI固件根据设备的配置空间信息,为每个设备分配资源,例如内存地址、中断等。 4. 初始化PCI设备:UEFI固件对每个PCI设备进行初始化,例如加载设备的固件驱动程序、设置设备的状态等。 5. 注册PCI设备:UEFI固件将已经初始化的PCI设备注册到系统固件表中,以便操作系统能够识别和使用这些设备。 通过UEFIPCI遍历过程,计算机系统能够正确地识别和配置PCI设备,使其能够正常工作。这对于操作系统、驱动程序和应用程序的运行都非常重要。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值