是否可以在 BDS 阶段之前自动加载和执行 EFI 应用程序,就在加载所有 DXE 驱动程序之后?如果我在 DXE 驱动程序之后将应用程序包含在 .fdf 文件中,它会自动加载和执行吗?
1 回答
This question is very board and I will only scratch the surface with my answer. Please read documentation that I mentioned to get more information.
If you have full source code of UEFI firmware for your hardware then you can add UEFI module to be executed before BDS phase. Otherwise you can affect only boot order (which is right before calling ExitBootServices
) by adding UEFI Application using bcfg
shell command, pleas check this question.
If you want to execute code before BDS it have to be DXE module (ie. DRIVER
, RUNTIME_DRIVER
). There are many module types that can be used and exact depend on your use case. More about module types you can find in Appendix G of INF file specification.
Adding to FDF
file is not enough for code to be executed. FDF
file describe only flash layout: how and where each binary would be placed in final flash image. To add DXE driver you also have to add your INF
file to platform DSC
file. Next thing is to have correct [Depex]
section in INF, which can be as simple as:
[Depex]
TRUE
Last thing that you have to understand is DXE Dispatcher
. Each boot DXE Dispatcher
iterate over know image list and and call EFI_DRIVER_BINDING_SUPPORTED
function (defined by EFI_DRIVER_BINDING_PROTOCOL
). This method should check if supported hardware is available in platform. If EFI_DRIVER_BINDING_SUPPORTED
return success then other driver binding method will be called (EFI_DRIVER_BINDING_START
), which starts device. Entry point should be used only for protocol registration, starting device in entry point is not recommended.
Useful resources:
- EDK II Specifications - specs for various file types (
INF
,FDF
,DSC
,DEC
, etc.) - Developer Resources - Drivers Writers Guide and Drivers Wizard.
- EDK2 sourceforge - repository of very useful resources about EDK2