From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from rn-mailsvcp-ppex-lapp24.apple.com (rn-mailsvcp-ppex-lapp24.apple.com [17.179.253.38]) by mx.groups.io with SMTP id smtpd.web12.2025.1668024612655295271 for ; Wed, 09 Nov 2022 12:10:12 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@apple.com header.s=20180706 header.b=r8W85+b9; spf=pass (domain: apple.com, ip: 17.179.253.38, mailfrom: afish@apple.com) Received: from pps.filterd (rn-mailsvcp-ppex-lapp24.rno.apple.com [127.0.0.1]) by rn-mailsvcp-ppex-lapp24.rno.apple.com (8.16.1.2/8.16.1.2) with SMTP id 2A9K1nRu028250; Wed, 9 Nov 2022 12:10:12 -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=glfXKV+U1jX45TFG4+54yHfi7qxXRkw53YkkvjFq3Fw=; b=r8W85+b9esh/u3SOlJCseXHHSjnMcgGfFTrunw/3846bY04iOoic+XQBITmMz2yf9Jf2 Jnw+uLmXQyG9o0OixXQO0aQEeHqM4TZ5QYu4EFpdI1vi+Jlch7OmvwHmqDFmxrmMQTcJ gccKZLmv10440ZVvLKG09bNBj5nsQ2AZt0Rv0eshiJdW+maZtPGQOdUk+lKz9qczMN0z qcMyIVBpJB0TNC+bRg8webXmbcDRMyFL2aGvfud2QS7ECuoYF7qjZhbT2QAxs9GxPmfb vl2NGIWWNuy1jG712wdS3CLmBpaw8DX1r8UjlRBJmXHffh1sUEZtrtpeuMfLqaMnB4Rx Tg== Received: from rn-mailsvcp-mta-lapp03.rno.apple.com (rn-mailsvcp-mta-lapp03.rno.apple.com [10.225.203.151]) by rn-mailsvcp-ppex-lapp24.rno.apple.com with ESMTP id 3kp9456e7c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Wed, 09 Nov 2022 12:10:12 -0800 Received: from rn-mailsvcp-policy-lapp01.rno.apple.com (rn-mailsvcp-policy-lapp01.rno.apple.com [17.179.253.18]) 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 <0RL300LUPK1059D0@rn-mailsvcp-mta-lapp03.rno.apple.com>; Wed, 09 Nov 2022 12:10:12 -0800 (PST) Received: from process_milters-daemon.rn-mailsvcp-policy-lapp01.rno.apple.com by rn-mailsvcp-policy-lapp01.rno.apple.com (Oracle Communications Messaging Server 8.1.0.20.20220923 64bit (built Sep 23 2022)) id <0RL300L00JG5P100@rn-mailsvcp-policy-lapp01.rno.apple.com>; Wed, 09 Nov 2022 12:10:12 -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: 4c24700e-c837-4126-8fc9-f5378f4de5a5 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: 24544650-5b52-4e8e-b9c2-0f7875612bc6 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-policy-lapp01.rno.apple.com (Oracle Communications Messaging Server 8.1.0.20.20220923 64bit (built Sep 23 2022)) with ESMTPSA id <0RL300MIGK0X2W00@rn-mailsvcp-policy-lapp01.rno.apple.com>; Wed, 09 Nov 2022 12:10:10 -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 12:09:59 -0800 References: <8217.1668018556935621513@groups.io> To: devel@edk2.groups.io, d.meneses@softi9.pt In-reply-to: <8217.1668018556935621513@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 X-Groupsio-MsgNum: 96169 Content-type: multipart/alternative; boundary="Apple-Mail=_6116037E-7BD0-417B-936E-DFB44545DDE0" --Apple-Mail=_6116037E-7BD0-417B-936E-DFB44545DDE0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Nov 9, 2022, at 10:29 AM, d.meneses via groups.io wrote: >=20 > Thank you Andrew for your reply.=20 >=20 > Your explanation about the Driver Binding protocol cleared up some questi= ons of mine. >=20 > Regarding the BDS, I recon I have some reading to do before I understand = what you said and why it might be relevant to me. >=20 The BDS is what runs after all the discovered drivers have been dispatched.= The BDS processes all those UEFI NVRAM variables I references, and sets pl= atform defaults.=20 > For now I am investigating the possibility of having a DxeDriver load an = UEFI application and create an event to start it after the DXE Phase is ove= r and the Terminal protocol is available.=20 >=20 That seems very Rube Goldberg. There are no threads in UEFI, just events th= at run at a higher TPL. It is not legal, per the UEFI specification to run = applications at elevate TPL [1]. There is no way for a driver to inject its= self into the main thread. So for example your App running at elevate TPL = could block the lower priority events needed to read from the disk or manag= e the network traffic. EFI is a cooperative event model so your code runnin= g at a given event level blocks all code at that level or lower from runnin= g indefinitely.=20 > I need to: > - learn how to load and start images. To that end I have found a CoreLoad= Image and CoreStartImage edk2 functions, buuut > - I haven't figured out how to get the device path to my UEFI app > - I was wondering if I could somehow use my app's GUID to search for it?= =20 If you look at the code I pointed you to in the OVMF BDS Platform lib I thi= nk you will find it writes an UEFI Boot Variable that contains a Device Pat= h that has the FILE_GUID as the file name.=20 If you want to try something quick you could replace the FILE_GUID for the = UEFI Shell with the FILE_GUID for your App and it should not launch in plac= e of the UEFI Shell.=20 > - Then I'd learn how to use events and have them start the app=20 >=20 As I mentioned that is going to break stuff.=20 [1] https://uefi.org/specs/UEFI/2.10/07_Services_Boot_Services.html#event-timer= -and-task-priority-services=EF=BF=BC > I'm deeply thankful for your time, wish you luck and peace >=20 --Apple-Mail=_6116037E-7BD0-417B-936E-DFB44545DDE0 Content-Type: multipart/related; type="text/html"; boundary="Apple-Mail=_9B6847BB-FA59-4975-AF6F-F31B96AEF648" --Apple-Mail=_9B6847BB-FA59-4975-AF6F-F31B96AEF648 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Nov 9, 2022, at 10:29 AM, d.meneses via groups.io <d.menes= es=3Dsofti9.pt@groups.io> wrote:

Thank you Andrew for your reply. 

Your explanation a= bout the Driver Binding protocol cleared up some questions of mine.

= Regarding the BDS, I recon I have some reading to do before I understand wh= at you said and why it might be relevant to me.

<= div>
The BDS is what runs after all the discovered drivers ha= ve been dispatched. The BDS processes all those UEFI NVRAM variables I refe= rences, and sets platform defaults. 

For now I am investigating the possibility of having a DxeDriver loa= d an UEFI application and create an event to start it after the DXE Phase i= s over and the Terminal protocol is available. 


That seems very Rube Goldberg. There are no threads= in UEFI, just events that run at a higher TPL. It is not legal, per the UE= FI specification to run applications at elevate TPL [1]. There is no way fo= r a driver to inject its self into the main thread. So for example your App= running at elevate TPL could block the lower priority events needed to rea= d from the disk or manage the network traffic. EFI is a cooperative event m= odel so your code running at a given event level blocks all code at that le= vel or lower from running indefinitely. 

I need to:
- learn how to load and start images. To that end = I have found a CoreLoadImage and CoreStartImage edk2 functions, buuut
- = I haven't figured out how to get the device path to my UEFI app
- I was = wondering if I could somehow use my app's GUID to search for it? 
<= /div>

If you look at the code I pointed you= to in the OVMF BDS Platform lib I think you will find it writes an UEFI Bo= ot Variable that contains a Device Path that has the FILE_GUID as the file = name. 

If you want to try something quick you= could replace the FILE_GUID for the UEFI Shell with the FILE_GUID for your= App and it should not launch in place of the UEFI Shell. 

- Then I'd learn how to use events and have th= em start the app 


As I m= entioned that is going to break stuff. 

[1]