> On May 15, 2015, at 8:52 AM, S.Vieira <jwvsan...@outlook.com> wrote:
>
> I need get the DevicePath of the File, then i pass the FileName (CHAR16) and
> i want get return as DevicePath to use with LoadImage…
In general device paths are a space namespace that point to a boot device, and
they are a collection of nodes (parent/child relationships). So you need the
device path to the disk (it would include PCI Root Bridge, PCI device, drive,
etc.), the partition on the disk, and the file.
I think the function you are looking for is in the
https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Include/Library/DevicePathLib.h
<https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Include/Library/DevicePathLib.h>
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
Status = gBS->HandleProtocol (
ImageHandle,
&gEfiLoadedImageProtocolGuid,
(VOID **) &LoadedImage
);
FilePath = FileDevicePath (LoadedImage->DeviceHandle, FileName);
If you want to load from a device other than the device your program was loaded
from you need to replace LoadedImage->DeviceHandle with a handle that supports
the Simple File System protocol.
Thanks,
Andrew Fish
> I can not to use Shell Protocol.
>
>
> VOID
> GetDevicePathFromText (IN CHAR16* FileName,IN EFI_HANDLE ImageHandle)
> {
> EFI_GUID
> DevicePathFromTextGUID =
> EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID;
You don’t need to do this. You can use gEfiDevicePathFromTextProtocolGuid
You just need to add a [Protocols] section to the INF and list
gEfiDevicePathFromTextProtocolGuid this will make the linking resolve.
> EFI_HANDLE
> *handle;
> EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL
> *DevicePathFromTextProtocol;
> EFI_STATUS
> Status;
> UINTN
> bufferSize;
> int
> index;
>
> EFI_DEVICE_PATH
> *FilePath;
> EFI_HANDLE
> *LoadedDriverHandle;
>
> LoadedDriverHandle = NULL;
>
> Status = gBS->LocateHandleBuffer(ByProtocol,
>
> &DevicePathFromTextGUID,
> NULL,
>
> &bufferSize,
> &handle
> );
>
> if(!EFI_ERROR(Status))
> {
> Print(L"\nLocate: %r",Status);
> for(index = 0 ; index < bufferSize ; index++)
> {
> Status = gBS->OpenProtocol( handle[index],
>
> &DevicePathFromTextGUID,
>
> (void **)&DevicePathFromTextProtocol,
>
> ImageHandle,
>
> NULL,
>
> EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL
>
> );
> if(EFI_ERROR(Status))
> {
> Print(L"\nERRO");
> }else{
> FilePath =
> DevicePathFromTextProtocol->ConvertTextToDevicePath(FileName);
> Status =
> gBS->LoadImage(FALSE,ImageHandle,FilePath,NULL,0,LoadedDriverHandle);
> if(!EFI_ERROR(Status)){
> Print(L"Loaded %r",Status);
>
> }else
> {
> Print(L"Loaded %r",Status);
> }
> }
>
> }
>
> }else
> {
> Print(L"\nLocate: %r",Status);
> }
> }
>
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel