On Feb 13, 2013, at 1:36 PM, Thomas Rognon <tcrog...@gmail.com> wrote:

> Thanks for helping me!  Tried just L"Load.efi", but still no luck.  I'm 
> starting to research LoadImage and StartImage to use instead of the ShellLib, 
> but Load Image needs the EFI_DEVICE_PATH_PROTOCOL for my efi image and that 
> seems hard to figure out how to get.
> 

Your ImageHandle will contain an EFI_LOADED_IMAGE_PROTOCOL and this protocol 
contains the DeviceHandle. You can then use the DevicePathLib FileDevicePath() 
to make the device path that points to your file. 

https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/MdePkg/Include/Library/DevicePathLib.h

The important thing to remember is the volume names are made up by the shell 
and don't relate to the device path. Another way to say this is that L"fs1:" 
would map a device path like DeviceHandle. So only use directory and file names 
with FileDevicePath() library calls. 

You can also locate all the handles in the system that contain a file system 
protocol and grab the device path protocol instance from that handle and use it 
with the device path lib. 

> 
> Here is what my screen looks like:
> 

Have you tried running in one of the emulators and just source level debugging 
to see what is going on?

https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/Nt32Pkg/
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EmulatorPkg/

Thanks,

Andrew

> ============================
> fs1:\> Load.efi
> Inside Load.efi
> 
> fs1:\> Test.efi
> ImageHandle: B86D1218
> ShellInitialize: Success
> ShellExecute: Invalid Parameter
> 
> fs1:\>
> ============================
> 
> Here are my .inf files, by the way:
> ###############################
> ## Test.inf
> ###############################
> [Defines]
>   INF_VERSION                    = 0x00010005
>   BASE_NAME                      = Test
>   FILE_GUID                      = 144F4789-F85E-4097-AABA-D0D0781C5F3D
>   MODULE_TYPE                    = UEFI_APPLICATION
>   VERSION_STRING                 = 0.1
>   ENTRY_POINT                    = UefiMain
> 
> [Sources]
>   Test.c
>     
> [Packages]
>   MdePkg/MdePkg.dec
>   ShellPkg/ShellPkg.dec
> 
> [LibraryClasses]
>   UefiLib
>   UefiApplicationEntryPoint
>   ShellLib
> 
> ###############################
> ## Load.inf
> ###############################
> [Defines]
>   INF_VERSION                    = 0x00010005
>   BASE_NAME                      = Load
>   FILE_GUID                      = 15E7F2DC-27C2-4db6-8CDE-CB52007DA8A2
>   MODULE_TYPE                    = UEFI_APPLICATION
>   VERSION_STRING                 = 0.1
>   ENTRY_POINT                    = UefiMain
> 
> [Sources]
>   Load.c
>     
> [Packages]
>   MdePkg/MdePkg.dec
> 
> [LibraryClasses]
>   UefiLib
>   UefiApplicationEntryPoint
> 
> On Wed, Feb 13, 2013 at 3:09 PM, Carsey, Jaben <jaben.car...@intel.com> wrote:
> Try like this (no drive information) – that’s how I’ve used it before.
> 
>  
> 
>   Status = ShellExecute (
> 
>              ImageHandle,
> 
>              L"Load.efi",
> 
>              FALSE,
> 
>              NULL,
> 
>              NULL
> 
>              );
> 
>  
> 
>  
> 
> -Jaben
> 
>  
> 
>  
> 
> From: Thomas Rognon [mailto:tcrog...@gmail.com] 
> Sent: Wednesday, February 13, 2013 12:06 PM
> 
> 
> To: edk2-devel@lists.sourceforge.net
> Subject: Re: [edk2] ShellExecute
> 
>  
> 
> I'm new to this and using CommandInit because I've seen it used after 
> ShellInitialize in other files.  I removed it and now it doesn't hang, but 
> ShellExecute returns Invalid Parameter.
> 
>  
> 
> My goal is to execute a uefi application from inside another uefi 
> application.  Here is my code:
> 
>  
> 
> ////////////////////////////////////////////////
> 
> // Test.c
> 
> ////////////////////////////////////////////////
> 
>  
> 
> #include <Library/UefiLib.h>
> 
> #include <Library/UefiApplicationEntryPoint.h>
> 
> #include <Library/ShellLib.h>
> 
>  
> 
> EFI_STATUS
> 
> EFIAPI
> 
> UefiMain (
> 
>   IN     EFI_HANDLE        ImageHandle,
> 
>   IN     EFI_SYSTEM_TABLE  *SystemTable
> 
>   )
> 
> {
> 
>   EFI_STATUS  Status;
> 
>   
> 
>   Print (L"ImageHandle: %x\n", ImageHandle);
> 
>   
> 
>   Status = ShellInitialize ();
> 
>   Print (L"ShellInitialize: %r\n", Status);
> 
>   
> 
>   Status = ShellExecute (
> 
>              ImageHandle,
> 
>              L" Load.efi",
> 
>              FALSE,
> 
>              NULL,
> 
>              NULL
> 
>              );
> 
>   Print (L"ShellExecute: %r\n", Status);
> 
>   return EFI_SUCCESS;
> 
> }
> 
>  
> 
> ////////////////////////////////////////////////
> 
> // Load.c
> 
> ////////////////////////////////////////////////
> 
>  
> 
> #include <Library/UefiLib.h>
> 
> #include <Library/UefiApplicationEntryPoint.h>
> 
>  
> 
> EFI_STATUS
> 
> EFIAPI
> 
> UefiMain (
> 
>   IN     EFI_HANDLE        ImageHandle,
> 
>   IN     EFI_SYSTEM_TABLE  *SystemTable
> 
>   )
> 
> {
> 
>   Print (L"Inside Load.efi.\n");
> 
>   return EFI_SUCCESS;
> 
> }
> 
>  
> 
>  
> 
> fs1 contains both Load.efi and Test.efi.  The output from Test.efi is:
> 
>  
> 
> ImageHandle: B86D1518
> 
> ShellInitialize: Success
> 
> ShellExecute: Invalid Parameter
> 
>  
> 
> On Wed, Feb 13, 2013 at 11:15 AM, Carsey, Jaben <jaben.car...@intel.com> 
> wrote:
> 
> Have you tried removing the CommandInit() call?  Why do you need that?
> 
>  
> 
> From: Thomas Rognon [mailto:tcrog...@gmail.com] 
> Sent: Tuesday, February 12, 2013 8:43 PM
> To: edk2-devel@lists.sourceforge.net
> Subject: Re: [edk2] ShellExecute
> 
>  
> 
> Additional info:
> 
> It crashes on ShellExecute with a memory violation and I'm using 64 bit UEFI 
> 2.1+, UDK2010, and VS2008.
> 
>  
> 
> On Tue, Feb 12, 2013 at 10:30 PM, Thomas Rognon <tcrog...@gmail.com> wrote:
> 
> UEFI Ninjas,
> 
>  
> 
> I can execute an uefi application from the shell as follows:
> 
> Shell>map -r
> 
> Shell>fs0:
> 
> fs0:>launch.efi
> 
>  
> 
> But when I try this, it hangs and I have to restart the machine:
> 
> Shell>map -r
> 
> Shell>fs0:
> 
> fs0:>test.efi
> 
>  
> 
> where test.efi executes only the following code in UefiMain:
> 
> ShellInitialize ();
> 
> CommandInit ();
> 
> ShellExecute (ImageHandle, L"fs0:\\launch.efi", FALSE, NULL, NULL);
> 
> return EFI_SUCCESS;
> 
>  
> 
> where ImageHandle is the parameter passed into UefiMain.
> 
>  
> 
> If anyone can help, I would appreciate it very much!
> 
>  
> 
> Thomas Rognon
> 
>  
> 
> 
> ------------------------------------------------------------------------------
> Free Next-Gen Firewall Hardware Offer
> Buy your Sophos next-gen firewall before the end March 2013
> and get the hardware for free! Learn more.
> http://p.sf.net/sfu/sophos-d2d-feb
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
> 
>  
> 
> 
> ------------------------------------------------------------------------------
> Free Next-Gen Firewall Hardware Offer
> Buy your Sophos next-gen firewall before the end March 2013
> and get the hardware for free! Learn more.
> http://p.sf.net/sfu/sophos-d2d-feb
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
> 
> 
> ------------------------------------------------------------------------------
> Free Next-Gen Firewall Hardware Offer
> Buy your Sophos next-gen firewall before the end March 2013 
> and get the hardware for free! Learn more.
> http://p.sf.net/sfu/sophos-d2d-feb_______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to