public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Amit kumar <akamit91@hotmail.com>
To: "Carsey, Jaben" <jaben.carsey@intel.com>,
	"afish@apple.com" <afish@apple.com>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: How to get fs index from controller handle.
Date: Fri, 7 Apr 2017 10:16:37 +0000	[thread overview]
Message-ID: <MWHPR11MB18225E72BA5E6E3BA87E2D9ADC0C0@MWHPR11MB1822.namprd11.prod.outlook.com> (raw)
In-Reply-To: <CB6E33457884FA40993F35157061515C54BDDF96@FMSMSX103.amr.corp.intel.com>

Andrew, Jaben

Thanks for your suggestions.

I have one more query , i have a handle that contains a devicepath and i have a file say filename.efi wich is inside directory structure.

say

XYZ\Par\Chld\filename.efi

NewDevPath =FileDevicePath(devicepath,L"XYZ\Par\Chld\filename.efi ");


and then i do


gBS->LoadImage (
              FALSE,
              ImageHandle,
              NewDevPath,
              NULL,
              0,
              &NewHandle
            );

which returns me Status = Not Found;

But when i place the  filename.efi in volume root
NewDevPath =FileDevicePath(devicepath,L"filename.efi ");
LoadImage succeeds.

Can some one tell me how to deal with directories while generating the devicepath for a file inside a directory.

Amit



________________________________
From: Carsey, Jaben <jaben.carsey@intel.com>
Sent: Friday, April 7, 2017 2:22:15 AM
To: afish@apple.com
Cc: Amit kumar; edk2-devel@lists.01.org
Subject: RE: [edk2] How to get fs index from controller handle.

Andrew,

I was assuming not wanting ShellExecute()  might extend to the rest of the shell.

If the shell is in use, that can definitely help. While those 2 APIs do exist in theory, there is a single one that does all I think: GetDevicePathFromFilePath.

-Jaben


From: afish@apple.com [mailto:afish@apple.com]
Sent: Thursday, April 06, 2017 1:49 PM
To: Carsey, Jaben <jaben.carsey@intel.com>
Cc: Amit kumar <akamit91@hotmail.com>; edk2-devel@lists.01.org
Subject: Re: [edk2] How to get fs index from controller handle.
Importance: High


On Apr 6, 2017, at 1:30 PM, Carsey, Jaben <jaben.carsey@intel.com<mailto:jaben.carsey@intel.com>> wrote:

That's the way to do it.  the hard work is around finding the DevicePath for the application you want to run to pass to LoadImage.


Jaben,

It was easy in the old days.....

DevPath  = gSE2->NameToPath (ShellPathName);
gSE2->GetFsName (DevPath, FALSE, & ShellPathName);

Maybe we should default EFI_SHELL_ENVIRONMENT2 to on :)? Half joking.

I used those 2 APIs in the past to glue in shell volume names to a really simplistic C lib.

Also if you have the File System Handle and path you can use the DevicePathLib.

/**
  Allocates a device path for a file and appends it to an existing device path.

  If Device is a valid device handle that contains a device path protocol, then a device path for
  the file specified by FileName  is allocated and appended to the device path associated with the
  handle Device.  The allocated device path is returned.  If Device is NULL or Device is a handle
  that does not support the device path protocol, then a device path containing a single device
  path node for the file specified by FileName is allocated and returned.
  The memory for the new device path is allocated from EFI boot services memory. It is the responsibility
  of the caller to free the memory allocated.

  If FileName is NULL, then ASSERT().
  If FileName is not aligned on a 16-bit boundary, then ASSERT().

  @param  Device                     A pointer to a device handle.  This parameter is optional and
                                     may be NULL.
  @param  FileName                   A pointer to a Null-terminated Unicode string.

  @return The allocated device path.

**/
EFI_DEVICE_PATH_PROTOCOL *
EFIAPI
FileDevicePath (
  IN EFI_HANDLE                      Device,     OPTIONAL
  IN CONST CHAR16                    *FileName
  );


Thanks,

Andrew Fish


-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
Amit kumar
Sent: Thursday, April 06, 2017 9:45 AM
To: Andrew Fish <afish@apple.com<mailto:afish@apple.com>>
Cc: edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
Subject: Re: [edk2] How to get fs index from controller handle.
Importance: High

Hi,


Can i use gbs->loadimage() and gbs->startimage() to load an efi application
and execute it.

Suppose i have a app1.efi and from app1.efi i want to execute app2.efi.

Or is there some other way to do it ?

Not considering ShellExecute();

Amit

________________________________
From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>> on behalf of Andrew Fish
<afish@apple.com<mailto:afish@apple.com>>
Sent: Thursday, April 6, 2017 4:39:22 PM
To: Amit kumar
Cc: edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
Subject: Re: [edk2] How to get fs index from controller handle.


On Apr 6, 2017, at 3:30 AM, Amit kumar
<akamit91@hotmail.com<mailto:akamit91@hotmail.com><mailto:akamit91@hotmail.com>> wrote:

Hi,

I want to get the fs index from the controller handle.
e.g In map command i see my controller is mapped to fs10.
So i there any API i can use in my code to get the fs index( which is 10 as in
example) from the controller handle.


Amit,

It is important to remember that fs0:, and the other device names are a Shell
concept and not an EFI concept. So they only exist in the context of the shell.

I took a quick look and I did not see an easy way to do this with the current
Shell APIs.

In the older Shell you could use this  protocol  EfiShellEnvironment2 Protocol
has a function that converts a EFI_DEVICE_PATH_PROTOCOL (would be on
your controller handle) to a CHAR16. Thus you can get the volume name the
Shell would display to the user. I don't the index exists as a concept.  So
EFI_SHELL_ENVIRONMENT2.GetFsName() and
EFI_SHELL_ENVIRONMENT2.GetFsDevicepath() are the closest thing I can
think of.
https://github.com/tianocore/edk2/blob/master/ShellPkg/Include/Protocol/
EfiShellEnvironment2.h#L812

The only problem with that is EfiShellEnvironment2 is not produced by the
Shell by default.

 ## This flag is used to control the protocols produced by the shell
 #  If TRUE the shell will produce EFI_SHELL_ENVIRONMENT2 and
EFI_SHELL_INTERFACE

gEfiShellPkgTokenSpaceGuid.PcdShellSupportOldProtocols|FALSE|BOOLEAN
|0x00000002

I've use the EFI_SHELL_ENVIRONMENT2 in the past to enable a non Shell
application to print out volume names that match the map command of the
shell. Hopefully some one knows how to do this in the modern Shell?

Thanks,

Andrew Fish

Regards
Amit
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org><mailto:edk2-devel@lists.01.org>
https://lists.01.org/mailman/listinfo/edk2-devel

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
https://lists.01.org/mailman/listinfo/edk2-devel



  reply	other threads:[~2017-04-07 10:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-06 10:30 How to get fs index from controller handle Amit kumar
2017-04-06 11:09 ` Andrew Fish
2017-04-06 16:44   ` Amit kumar
2017-04-06 20:30     ` Carsey, Jaben
2017-04-06 20:48       ` Andrew Fish
2017-04-06 20:52         ` Carsey, Jaben
2017-04-07 10:16           ` Amit kumar [this message]
2017-04-07 10:40             ` Amit kumar
2017-04-07 14:42               ` Andrew Fish
2017-04-07 15:23                 ` Amit kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MWHPR11MB18225E72BA5E6E3BA87E2D9ADC0C0@MWHPR11MB1822.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox