From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ma1-aaemail-dr-lapp02.apple.com (ma1-aaemail-dr-lapp02.apple.com [17.171.2.68]) by mx.groups.io with SMTP id smtpd.web08.300.1668016339881275733 for ; Wed, 09 Nov 2022 09:52:20 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@apple.com header.s=20180706 header.b=CkGezNB2; spf=pass (domain: apple.com, ip: 17.171.2.68, mailfrom: afish@apple.com) Received: from pps.filterd (ma1-aaemail-dr-lapp02.apple.com [127.0.0.1]) by ma1-aaemail-dr-lapp02.apple.com (8.16.0.42/8.16.0.42) with SMTP id 2A9HlvuB040921; Wed, 9 Nov 2022 09:52:19 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=from : content-type : mime-version : subject : date : references : to : in-reply-to : message-id; s=20180706; bh=1h862D3KP7uTTBrSYq68Z2PkY8f+S2UiyINVg0xf1YQ=; b=CkGezNB2yCDjiRV9fTtdjt4JR5yquko2fB+U3y5PBD/ovidFFbjuuzTcqIqWIfJRVwRp RBctpmUWwETN1jbKhHNiebvO8LfrAysHZev5odmOIEdLqhHSNwNIQyS6XvRAoAfZx5vt /NrazX+z/wUAqWRx5mOHE5TeVg/zk4/qd9rgE1aqSyOINz2y3NwEOPAD7U5ck2qGe9JF Thz/lq1xs0aG3YByYUNaUiTi+OmMNUUXNXPebvJs75ExipAbU0M4EjJSFg0IpuNVhWKc 0NDjd6eq0gHTe+m4eHVqulEi/w/Tf0T6sLoKOsbHkDgKD7qLOgy871yTkloMDVVwApf1 Dw== Received: from rn-mailsvcp-mta-lapp03.rno.apple.com (rn-mailsvcp-mta-lapp03.rno.apple.com [10.225.203.151]) by ma1-aaemail-dr-lapp02.apple.com with ESMTP id 3knmgsyqm5-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Wed, 09 Nov 2022 09:52:19 -0800 Received: from rn-mailsvcp-mmp-lapp02.rno.apple.com (rn-mailsvcp-mmp-lapp02.rno.apple.com [17.179.253.15]) by rn-mailsvcp-mta-lapp03.rno.apple.com (Oracle Communications Messaging Server 8.1.0.20.20220923 64bit (built Sep 23 2022)) with ESMTPS id <0RL300SC1DN51H80@rn-mailsvcp-mta-lapp03.rno.apple.com>; Wed, 09 Nov 2022 09:52:17 -0800 (PST) Received: from process_milters-daemon.rn-mailsvcp-mmp-lapp02.rno.apple.com by rn-mailsvcp-mmp-lapp02.rno.apple.com (Oracle Communications Messaging Server 8.1.0.20.20220923 64bit (built Sep 23 2022)) id <0RL300500DM4MU00@rn-mailsvcp-mmp-lapp02.rno.apple.com>; Wed, 09 Nov 2022 09:52:17 -0800 (PST) X-Va-A: X-Va-T-CD: 5590f8ce7f355594fd700460ed24ba63 X-Va-E-CD: ec9cc94c51167e28e069118bb1fce29d X-Va-R-CD: ce3ffbac7fc5b1e5f0bf2f56a281a21d X-Va-CD: 0 X-Va-ID: 7f744503-7266-435b-8ae4-3f747885a7bd X-V-A: X-V-T-CD: 5590f8ce7f355594fd700460ed24ba63 X-V-E-CD: ec9cc94c51167e28e069118bb1fce29d X-V-R-CD: ce3ffbac7fc5b1e5f0bf2f56a281a21d X-V-CD: 0 X-V-ID: 6b268556-8d51-4c4d-b667-bf79cb29c25f X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.545,18.0.895 definitions=2022-11-09_06:2022-11-09,2022-11-09 signatures=0 Received: from smtpclient.apple (unknown [17.11.229.200]) by rn-mailsvcp-mmp-lapp02.rno.apple.com (Oracle Communications Messaging Server 8.1.0.20.20220923 64bit (built Sep 23 2022)) with ESMTPSA id <0RL300EJYDN5CD00@rn-mailsvcp-mmp-lapp02.rno.apple.com>; Wed, 09 Nov 2022 09:52:17 -0800 (PST) From: "Andrew Fish" MIME-version: 1.0 (Mac OS X Mail 16.0 \(3731.200.22\)) Subject: Re: [edk2-devel] How to add a DXE driver to an OVMF image? Date: Wed, 09 Nov 2022 09:52:06 -0800 References: <22885.1667513571456708695@groups.io> <17126.1667568054194961949@groups.io> To: devel@edk2.groups.io, d.meneses@softi9.pt In-reply-to: <17126.1667568054194961949@groups.io> Message-id: X-Mailer: Apple Mail (2.3731.200.22) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.545,18.0.895 definitions=2022-11-09_06:2022-11-09,2022-11-09 signatures=0 Content-type: multipart/alternative; boundary="Apple-Mail=_7505BF06-4501-4D04-9AF3-835709423007" --Apple-Mail=_7505BF06-4501-4D04-9AF3-835709423007 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Nov 4, 2022, at 6:20 AM, d.meneses via groups.io wrote: >=20 > 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 b= y UEFITool. >=20 > 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_DRI= VER. > What is it that I'm missing? >=20 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 wha= t driver gets connected to what device. This is all managed by gBS->Connect= Controller()/gBS->DisconnectController().=20 A DXE Driver just publishes an arbitrary protocol.=20 [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/D= riverBinding.h PS I seem to remember a question about launching an App=E2=80=A6. It is possible to customize a generic UEFIs system boot policy via NVRAM va= riable. You can read up on that here [3].=20 If you want to change the platform policy in a secure way to do something y= ou likely need to modify the BDS (Boot Device Selection). The design idea a= round BDS is you could make a system an ATM or a PC just by changing the po= licy 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 PlatformBootMana= gerLib. You can look at the OVMF instance here [4]. You can use this librar= y to add extra policy on top of the NVRAM variables in the UEFI Spec [3]. I= f 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/PlatformB= ootManagerLib [5] https://github.com/tianocore/edk2/blob/master/OvmfPkg/Library/PlatformB= ootManagerLib/BdsPlatform.c#L1717 Sorry if I=E2=80=99m mixing up threads. So much email, and so little time= =E2=80=A6. > Thank you for your attention, > Diogo >=20 --Apple-Mail=_7505BF06-4501-4D04-9AF3-835709423007 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Nov 4, 2022, at 6:20 AM, d.meneses via groups.io <d.menese= s=3Dsofti9.pt@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 retu= rn.
Nonetheless, the same is happening when I package it as a DX= E_RUNTIME_DRIVER.
What is it that I'm missing?


The UEFI Shell drivers command is managing UE= FI Driver Model Drivers [1]. A UEFI Driver Model Driver has no depex and pu= blishes 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. 

[2] https://github.com/tianocore/edk2/blob/master/MdePkg/I= nclude/Protocol/DriverBinding.h


PS I seem to remember a question about launching an App=E2=80=A6.

It is possible to customize a generic UEFIs system boot po= licy 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). Th= e 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 p= latform policy. The easiest way to customize the edk2 BDS is via a custom P= latformBootManagerLib. 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 U= EFI Spec [3]. If you look at the OVMF example this is how the OVMF platform= makes the UEFI Shell a default boot option [5].


--Apple-Mail=_7505BF06-4501-4D04-9AF3-835709423007--