* Use fprintf in UEFI @ 2016-09-29 6:01 GN Keshava 2016-09-29 7:31 ` Laszlo Ersek 0 siblings, 1 reply; 3+ messages in thread From: GN Keshava @ 2016-09-29 6:01 UTC (permalink / raw) To: edk2-devel@lists.01.org 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. :) Thanks. Regards, Keshava ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Use fprintf in UEFI 2016-09-29 6:01 Use fprintf in UEFI GN Keshava @ 2016-09-29 7:31 ` Laszlo Ersek 2016-09-29 7:52 ` GN Keshava 0 siblings, 1 reply; 3+ messages in thread From: Laszlo Ersek @ 2016-09-29 7:31 UTC (permalink / raw) To: GN Keshava; +Cc: edk2-devel@lists.01.org, Carsey, Jaben 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Use fprintf in UEFI 2016-09-29 7:31 ` Laszlo Ersek @ 2016-09-29 7:52 ` GN Keshava 0 siblings, 0 replies; 3+ messages in thread From: GN Keshava @ 2016-09-29 7:52 UTC (permalink / raw) To: Laszlo Ersek; +Cc: edk2-devel@lists.01.org, Carsey, Jaben Thank you for detailed answer. Laszlo. Regards, Keshava On Thu, 29 Sep 2016 at 13:01 Laszlo Ersek <lersek@redhat.com> wrote: > 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 > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-29 7:53 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-09-29 6:01 Use fprintf in UEFI GN Keshava 2016-09-29 7:31 ` Laszlo Ersek 2016-09-29 7:52 ` GN Keshava
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox