[edk2-devel] How to add a DXE driver to an OVMF image?

Andrew Fish via groups.io afish=apple.com at groups.io
Wed Nov 9 17:52:06 UTC 2022



> On Nov 4, 2022, at 6:20 AM, d.meneses via groups.io <d.meneses=softi9.pt at groups.io> wrote:
> 
> Using DebugLib instead to print a message, I was able to confirm that my driver is now running properly:
> cat debug.log | grep Hello
> This works both when adding it in the OVMF build and also when inserted by UEFITool.
> 
> The drivers is not being listed by the EFI Shell drivers command.
> This is expected to me as Dxe Drivers are unloaded after they return.
> Nonetheless, the same is happening when I package it as a DXE_RUNTIME_DRIVER.
> What is it that I'm missing?
> 

The UEFI Shell drivers command is managing UEFI Driver Model Drivers [1]. A UEFI Driver Model Driver has no depex and publishes an EFI Driver Binding protocol [2]. The idea is the BDS (platform) can now have the policy of what driver gets connected to what device. This is all managed by gBS->ConnectController()/gBS->DisconnectController(). 

A DXE Driver just publishes an arbitrary protocol. 

[1] https://uefi.org/specs/UEFI/2.10/11_Protocols_UEFI_Driver_Model.html
[2] https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Protocol/DriverBinding.h


PS I seem to remember a question about launching an App….

It is possible to customize a generic UEFIs system boot policy via NVRAM variable. You can read up on that here [3]. 

If you want to change the platform policy in a secure way to do something you likely need to modify the BDS (Boot Device Selection). The design idea around BDS is you could make a system an ATM or a PC just by changing the policy in the BDS, thus the BDS is a place to centralize the platform policy. The easiest way to customize the edk2 BDS is via a custom PlatformBootManagerLib. You can look at the OVMF instance here [4]. You can use this library to add extra policy on top of the NVRAM variables in the UEFI Spec [3]. If you look at the OVMF example this is how the OVMF platform makes the UEFI Shell a default boot option [5].

[3] https://uefi.org/specs/UEFI/2.10/03_Boot_Manager.html#globally-defined-variables
[4] https://github.com/tianocore/edk2/tree/master/OvmfPkg/Library/PlatformBootManagerLib
[5] https://github.com/tianocore/edk2/blob/master/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c#L1717

Sorry if I’m mixing up threads. So much email, and so little time….

> Thank you for your attention,
> Diogo
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96162): https://edk2.groups.io/g/devel/message/96162
Mute This Topic: https://groups.io/mt/94734592/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/edk2-devel-archive/attachments/20221109/b73dac52/attachment.htm>


More information about the edk2-devel-archive mailing list