user28264
user28264

Reputation: 249

Can an EFI application automatically loaded and executed before BDS phase?

Can an EFI application be automatically loaded and executed before BDS phase, just after all the DXE drivers have been loaded? If I include the application in .fdf file just after the DXE drivers, will it be automatically loaded and executed ?

Upvotes: 4

Views: 1821

Answers (1)

Piotr Król
Piotr Król

Reputation: 3450

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:

Upvotes: 1

Related Questions