最近一时兴起,想借助学习UEFI下的PCI bus driver,顺带 学习下PCI bus,UEFIDriver Model的相关内容。准备写上几篇文章来详细的分析一下UEFI下PCI驱动的实现。这里就以Open source的EDKII code base为例,相关的代码可以从如下链接 https://svn.code.sf.net/p/edk2/code/trunk/edk2 获得。可以用SVN工具来下载所有的source code。
首先PciHostBridgeDriver在PcAtChipsetPkg\PciHostBridgeDxe。
1.InitializePciHostBridge function:
1.TheDriver Entry point for PciHostBridgeDriver in PciHostBridge.c file.
2.it Create instances for PciHostBridge based on the HOST_BRIDGE_NUMBER, also it create Root Bridges base on the input RootBridgeNumber, the platform owner knows how to setthese number, it decided by the hardware. Save the Root bridge to HostBridge->Head.
3.Themost important protocol installed in PCI host bridge is Pci Host BridgeResource Allocation Protocol (gEfiPciHostBridgeResourceAllocationProtocolGuid)
4.Thedevice path for PCI root bridge is mEfiPciRootBridgeDevicePath, it only has aACPI_DEVICE_PATH device path node.
2.In theNotifyPhase:
1.ForEfiPciHostBridgeBeginEnumeration case:
1.Resetthe Each Root Bridge , clean the RootBridgeInstance->ResAllocNode list,reset the HostBridgeInstance->ResourceSubmited andHostBridgeInstance->CanRestarted flag.
2.ForEfiPciHostBridgeBeginBusAllocation case:
Justset HostBridgeInstance->CanRestarted to FALSE.
3.ForGetNextRootBridge function:
1.Ifthe input RootBridgeHandle is NULL, just return the first handle inHostBridgeInstance->Head.
2.Ifthe input RootBridgeHandle is not NULL, just return the next member inHostBridgeInstance->Head, if already at the end, return NULL.
4.StartBusEnumerationFunction:
1.Justreturn the EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR structure base on the currentinfo.
未完待续...