Itay,
This isn't code, but hopefully it helps...
UEFI has a database of handles where protocols are installed on. If there
is a USB storage device attached, there will be a handle that has an
instance of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL installed on it (there will be
more than one handle where this is true if you have multiple storage
devices attached).
1. Get the handles that have an instance of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.
Use SystemTable->BootServices->LocateHandle() or gBS->LocateHandle() with
&gEfiSimpleFileSystemProtocolGuid. Now you have a buffer of all the handles
that have an instance of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on them.
2. Narrow down to USB storage.
Since you know it is a USB storage device, then you can loop through the
handles and test whether or not a EFI_USB_IO_PROTOCOL instance is installed
on the handle. Use SystemTable->BootServices->OpenProtocol() or
gBS->OpenProtocol() with &gEfiUsbIoProtocolGuid. Use
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
for the Attributes parameter.
3. Get the instance.
Now you only have handles that have EFI_SIMPLE_FILE_SYSTEM_PROTOCOL and
EFI_USB_IO_PROTOCOL instances installed. If there is more than one, you
need to have the user choose from them, or figure out some other way to
decide which one you want to use. Once you know which handle you want, use
SystemTable->BootServices->OpenProtocol() or gBS->OpenProtocol() with
&gEfiSimpleFileSystemProtocolGuid to the instance of
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL installed on that handle. You'll probably
use EFI_OPEN_PROTOCOL_GET_PROTOCOL for the Attributes parameter.
4. Open the volume.
Assuming your instance is stored in a variable called Fs, use
Fs->OpenVolume (Fs, &Root) where Root is an EFI_FILE_PROTOCOL.
5. Open/Read/Write/Close etc.
Now you can use Root to Open, Read, Write, etc. Refer to the UEFI spec or
protocol header.
Here are the headers for the protocols above:
https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Include/Uefi/UefiSpec.h
https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Include/Protocol/SimpleFileSystem.h
https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Include/Protocol/UsbIo.h
Thomas Rognon
On Mon, Apr 7, 2014 at 6:55 AM, Itay Sali <[email protected]> wrote:
> Hi,
>
>
>
> Does anyone have an example of writing text to file on usb storage.
>
> I am using DXE_DRIVER and shell is not relevant.
>
>
>
> I am trying to figure out how can I get the simple file protocol, then
> open the volume and then open the file.
>
>
>
> I would appreciate if I can get cookbook for that or detailed example.
>
>
>
> Thanks, Itay
>
>
> ------------------------------------------------------------------------------
> Put Bad Developers to Shame
> Dominate Development with Jenkins Continuous Integration
> Continuously Automate Build, Test & Deployment
> Start a new project now. Try Jenkins in the cloud.
> http://p.sf.net/sfu/13600_Cloudbees_APR
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
>
------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel