public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: GN Keshava <keshava.gn@gmail.com>
To: Laszlo Ersek <lersek@redhat.com>
Cc: "edk2-devel@lists.01.org" <edk2-devel@ml01.01.org>,
	"Carsey, Jaben" <jaben.carsey@intel.com>
Subject: Re: Use fprintf in UEFI
Date: Thu, 29 Sep 2016 07:52:59 +0000	[thread overview]
Message-ID: <CABKwMdv_hZS2eBWMHOHeWDDrKX529jTQUNJuL9i8khPHRiymvw@mail.gmail.com> (raw)
In-Reply-To: <49e7533e-4c7c-3585-2b57-6f851860da46@redhat.com>

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
>


      reply	other threads:[~2016-09-29  7:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABKwMdv_hZS2eBWMHOHeWDDrKX529jTQUNJuL9i8khPHRiymvw@mail.gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox