Re: [edk2] USB detection and file accessing example

Subject: Re: [edk2] USB detection and file accessing example

From: ravi ranjan mishra <raviranjanmishra24@gmail.com>

To: edk2-devel@lists.sourceforge.net

Date: 2014-06-04 19:09:54

i m getting only 2 handles from LocateHandleBuffer, previously i was using LocateHandle that time getting 16 why its difference.



On Wed, Jun 4, 2014 at 3:45 AM, Carsey, Jaben <jaben.carsey@intel.com> wrote:

are you getting lots of handles back from the first LocateHandleBuffer? Is it possible that youre failing too early and just need to go to the next handle in the list?

From: ravi ranjan mishra [mailto:raviranjanmishra24@gmail.com]
Sent: Tuesday, June 03, 2014 2:30 AM
To: edk2-devel@lists.sourceforge.net; Pirandello Chou
Subject: [edk2] USB detection and file accessing example

Hi All,

I am a newbie in EFI development. Currently I have a requirement of accessing a file from an external USB device and loading the contents to system memory. However, even after several attempts I could not able to crack this thing.

In one of my attempts I tried calling this below mentioned sequence;

Status = gBS->LocateHandleBuffer ( ByProtocol, & GEfiSimpleFileSystemProtocolGuid, NULL, & HandleCount, & HandleBuffer );

if (!EFI_ERROR (Status)) {

for (Index = 0; Index <HandleCount; Index + +) {

Status = gBS->HandleProtocol ( HandleBuffer [Index], & GEfiSimpleFileSystemProtocolGuid, & SimpleFileSystem );

if (! EFI_ERROR (Status)) {

Status = SimpleFileSystem->OpenVolume (SimpleFileSystem, & RootFs);

if (! EFI_ERROR (Status)) {

Status = RootFs->Open (RootFs, & FileHandle, FileName, EFI_FILE_MODE_READ, 0);

if (! EFI_ERROR (Status)) {

break;

}

else {

print("RootFs->Open failed ! with error = %d\n", Status);

}

}

else {

print("SimpleFileSystem->OpenVolume failed ! with error = %d\n", Status);

}

}

else {

print("gBS->HandleProtocol failed ! with error = %d\n", Status);

}

}

}

else {

print("gBS->LocateHandleBuffer failed ! with error = %d\n", Status);

}

However in this method, I got error (14) in call to RootFs->Open. My file is located in root directory of the external USB drive and also where the system boots.

In my second attempt;

Status = gBS->LocateHandleBuffer (

ByProtocol,

&gEfiSimpleFileSystemProtocolGuid,

NULL,

&HandleCount,

&HandleBuffer

);

if (!EFI_ERROR(Status)) {

for (Index = 0; Index < HandleCount; Index++) {

FileSystemDevicePath = DevicePathFromHandle(HandleBuffer[Index]);

if (FileSystemDevicePath == NULL) {

continue;

}

//Check if UsbIo is on any handles in the device path.

Status = gBS->LocateDevicePath(&gEfiUsbIoProtocolGuid, &FileSystemDevicePath, &UsbDeviceHandle);

if (! EFI_ERROR (Status)) {

Status = gBS->HandleProtocol ( HandleBuffer[Index], &gEfiSimpleFileSystemProtocolGuid,(void **) & Fs );

if (! EFI_ERROR (Status)) {

Status = Fs->OpenVolume (Fs, & Root);

if (! EFI_ERROR (Status)) {

Status = Root->Open (Root, &File, FileName, EFI_FILE_MODE_READ, 0);

if (! EFI_ERROR (Status)) {

break;

}

else {

Print(L"RootFs->Open failed ! with error = %d\n", Status);

}

}

else {

Print(L"SimpleFileSystem->OpenVolume failed ! with error = %d\n", Status);

}

}

else {

Print(L"gBS->HandleProtocol failed ! with error = %d\n", Status);

}

}

else {

Print(L"LocateDevicePath is failed = %d\n", Status);

}

However, this time I get LocateDevicePath with error (14).

Please help.

Thanks,

Ravi


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel