Re: [edk2] Using StdLib in UEFI_DRIVER Type

Subject: Re: [edk2] Using StdLib in UEFI_DRIVER Type

From: Jeffrey Chou <edk2.jeffrey@gmail.com>

To: edk2-devel <edk2-devel@lists.sourceforge.net>

Date: 2013-05-14 23:05:54

Thanks Andrew,
Maybe my question is not complete. MyUEFI Driver is loaded viaanother UEFI Application(Main.efi)with LoadImage function. So based on your advice, I modified my Main.efi to pass its ImageHandle to my UEFI Driver, because I think the ImageHandle should be application-based, andthen a ShellExecute used the ImageHandle in My UEFI Driver. It works.
The flowwould be:
Main.efi --LoadImage--> UEFI Driver --ShellExecute(with Main.efi's ImageHandle)--> StdLibApp

Thanks
Jeffrey
2013/5/13 Andrew Fish <afish@apple.com>

On May 13, 2013, at 2:02 AM, Jeffrey Chou <edk2.jeffrey@gmail.com> wrote:

Hi Daryl,
Thanks for your advice. Currently I just have the workaroundthat myUEFI driver invoking a application by LoadImage or ShellExecute,of causethe application should be built with StdLib.
But I encountered some problems when using LoadImage and ShellExecute:
Case 1:
For ShellExecute, I have an absolute filepath of application for parameter in ShellExecute. I always get EFI_SUCCESS from Status, but it seems that the StdLibApp.efi is never executed.
My UEFI Driver--ShellExecute-->StdLibApp
e.g.
ShellExecute (ImageHandle, L"folder1\folder2\StdLibApp.efi", FALSE, NULL, &Status);

Why would you expect a call ShellExecute from a driver to work? ShellExecute is a wrapper that calls a protocol produced by the shell. So by definition if the shell is not present it will not work. Your driver can't assume that the shell is present.


Case 2:
For LoadImage, also have the absolute file path for LoadImage function.
My UEFI Driver--LoadImage/StartImage-->StdLibApp
e.g.
gBS->LoadImage(FALSE, ImageHandle, FilePath, NULL, 0, &Handle);
gBS->StartImage(Handle, NULL, NULL );
But I got an error EFI_STATUS from StartImage.

If the return value is notEFI_INVALID_PARAMETER orEFI_SECURITY_VIOLATION then EFI_STATUS is coming from the image.

I tried to change the StdLibApp to a PURE EFI Application, it works.
Case 3:
Base on the result from case 2, an idea as below.
My UEFI Driver--LoadImage/StartImage-->PureEFIApp--ShellExecute-->StdLibApp
Unfortunately, also failed in case 3. I got the situation when calling ShellExeute which is same as case 1.
Maybemy method and ideaare a bit tortuous, butabove are solutionsI can think of so far.
Now I am back to case 2 and studying any solution can load a StdLibApp in an UEFI Driver.

Maybe you didn't understand the implication of Daryl's answer. A Shell Application, requires the actual Shell to be present. A driver can't depend on the shell. So non of this stuff you are trying is going to work.

You need to port your driver to not use C lib APIs that are not available and use edk2 library functions that are available, or you need create a version of the C lib that implements the functions you need that does not depend on the shell.

Thanks,

Andrew Fish

Thanks
Jeffrey
2013/5/11 Mcdaniel, Daryl <daryl.mcdaniel@intel.com>

Jeffrey,

The current version of StdLib is designed to only work as a Shell Application. Many of the services that StdLib relies upon are not available until the BDS phase, or later. As such, it is strongly recommended that StdLib not be used in drivers. It is my desire to provide a standalone version of StdLib in the future, but it is not currently scheduled.

Daryl McDaniel

In the pun, two strings of thought are tangled into one acoustic knot.
-- Arthur Koestler


From: Jeffrey Chou [mailto:edk2.jeffrey@gmail.com]
Sent: Tuesday, May 07, 2013 3:20 AM
To: edk2-devel
Subject: [edk2] Using StdLib in UEFI_DRIVER Type

Hi all,

I am trying to use StbLib in an uefi driver module,and it seems the StbLib is only supported on UEFI_APPLICATION. So I have an idea that my uefi driverinvoking an uefi application built with StdLib thru ShellExecute or LoadImage. But I am facing a problem that I don't know how to pass auguments to the application (in loadimage)and get the return valuefrom the application. Any suggestions?

Thanks

Jeffrey


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel