CC Jaben

On 09/29/16 08:01, GN Keshava wrote:
> Hi,
> 
> There is fprintf function in Stdio library. But how to use it? The first
> argument is "FILE" type. But I have "EFI_FILE_PROTOCOL* File" which I got
> from "EFIOpenFile" function. How to map to "FILE" type?
> 
> Sorry if this is silly. A newbie here. Didn't get much idea in internet
> search. :)

(1) You're trying to mix edk2 APIs with standard C library APIs. Don't
do that.

I think what you are missing is the fact that using edk2, you can write
a UEFI application *either* against edk2 APIs (protocols and libraries),
*or* against standard C APIs (using the stdlib implementation of edk2).
In some cases it is okay to call edk2 APIs directly, from stdlib
applications, but in general I'd advise against that.

I told you to read "AppPkg/ReadMe.txt"; that file explains what is
necessary for what "flavor" of UEFI application. It even mentions two
example programs, "Main" and "Hello", which don't do anything but
highlight the differences.

For another (quite self-contained) example,
"AppPkg/Applications/OrderedCollectionTest" is an application that I
wrote myself; it uses fopen() and fprintf(). This is a unit tester for
an MdePkg library that I also wrote, so it actually exemplifies how you
can use both stdlib and an edk2 library, as long as they don't step on
each other's toes.

(2) You can write formatted output to files using only edk2 APIs as
well, but for that, you first have to format the text into memory
buffers with PrintLib functions, then write the buffers to files with
the ShellLib APIs or with direct protocol calls.

(3) The standard C lib implementation in edk2 is only available for use
by UEFI applications (no other module types; that is, no drivers).
What's more, those applications have to be started from the shell (you
can't boot them directly from the boot manager, for example). This is
also documented in AppPkg/ReadMe.txt.

Thanks
Laszlo
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to