* stuck on LoadImage while loading image from usb
@ 2016-09-29 11:41 Saqib Khan
2016-09-30 1:23 ` Tian, Feng
0 siblings, 1 reply; 2+ messages in thread
From: Saqib Khan @ 2016-09-29 11:41 UTC (permalink / raw)
To: edk2-devel
Hi ,
I am trying to load an EFI from another EFI, it stuck when LoadImage is
called
both EFI are located on USB .
Here is code snippet
"
UINTN NumberFileSystemHandles;
EFI_HANDLE *FileSystemHandles;
UINTN Index;
EFI_BLOCK_IO* BlkIo;
EFI_DEVICE_PATH_PROTOCOL *FilePath;
EFI_HANDLE NewHandle;
UINTN ExitDataSizePtr;
EFI_BOOT_LOGO_PROTOCOL *BootLogo;
EFI_STATUS Status;
gBS->LocateHandleBuffer(ByProtocol,
&gEfiBlockIoProtocolGuid,
NULL,
&NumberFileSystemHandles,
&FileSystemHandles);
for(Index = 0; Index<NumberFileSystemHandles; ++Index) {
Status = gBS -> HandleProtocol(FileSystemHandles[Index],
&gEfiBlockIoProtocolGuid,
(VOID**) &BlkIo);
Print(L"after HandleProtocol %x - %r\n",FileSystemHandles[Index],
Status);
if(!EFI_ERROR(Status)) {
//check if it is usb
if(!BlkIo->Media->RemovableMedia ||
BlkIo->Media->RemovableMedia)
{
FilePath = FileDevicePath(FileSystemHandles[Index],
L"Hello.efi");
Status = gBS->LoadImage(
FALSE,
gImageHandle,
FilePath,
NULL,
0,
&NewHandle);
if (EFI_ERROR(Status)) {
if (NewHandle != NULL) {
gBS->UnloadImage(NewHandle);
}
//return (Status);
}
}
"
can any one help me what I am doing wrong here?
--
Regards
Saqib
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: stuck on LoadImage while loading image from usb
2016-09-29 11:41 stuck on LoadImage while loading image from usb Saqib Khan
@ 2016-09-30 1:23 ` Tian, Feng
0 siblings, 0 replies; 2+ messages in thread
From: Tian, Feng @ 2016-09-30 1:23 UTC (permalink / raw)
To: Saqib Khan, edk2-devel@lists.01.org; +Cc: Tian, Feng
In your code, there are several problems.
1. For your case, you couldn't simply locate all BlockIo instances. It's because some of these BlockIo instances may belong to other removable devices, some may point to physical partition rather than logical partition.
2. The logic below is incorrect. It means TRUE
if(!BlkIo->Media->RemovableMedia || BlkIo->Media->RemovableMedia)
3. Why don't you directly locate all SimpleFileSystem protocol instances and then find out Hello.efi? It's more simple.
4. The hang you found should be due to a wrong device path pass down to LoadImage().
Thanks
Feng
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Saqib Khan
Sent: Thursday, September 29, 2016 7:41 PM
To: edk2-devel@lists.01.org
Subject: [edk2] stuck on LoadImage while loading image from usb
Hi ,
I am trying to load an EFI from another EFI, it stuck when LoadImage is called both EFI are located on USB .
Here is code snippet
"
UINTN NumberFileSystemHandles;
EFI_HANDLE *FileSystemHandles;
UINTN Index;
EFI_BLOCK_IO* BlkIo;
EFI_DEVICE_PATH_PROTOCOL *FilePath;
EFI_HANDLE NewHandle;
UINTN ExitDataSizePtr;
EFI_BOOT_LOGO_PROTOCOL *BootLogo;
EFI_STATUS Status;
gBS->LocateHandleBuffer(ByProtocol,
&gEfiBlockIoProtocolGuid,
NULL,
&NumberFileSystemHandles,
&FileSystemHandles);
for(Index = 0; Index<NumberFileSystemHandles; ++Index) {
Status = gBS -> HandleProtocol(FileSystemHandles[Index],
&gEfiBlockIoProtocolGuid,
(VOID**) &BlkIo);
Print(L"after HandleProtocol %x - %r\n",FileSystemHandles[Index], Status);
if(!EFI_ERROR(Status)) {
//check if it is usb
if(!BlkIo->Media->RemovableMedia ||
BlkIo->Media->RemovableMedia)
{
FilePath = FileDevicePath(FileSystemHandles[Index],
L"Hello.efi");
Status = gBS->LoadImage(
FALSE,
gImageHandle,
FilePath,
NULL,
0,
&NewHandle);
if (EFI_ERROR(Status)) {
if (NewHandle != NULL) {
gBS->UnloadImage(NewHandle);
}
//return (Status);
}
}
"
can any one help me what I am doing wrong here?
--
Regards
Saqib
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-30 1:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-29 11:41 stuck on LoadImage while loading image from usb Saqib Khan
2016-09-30 1:23 ` Tian, Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox