From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D21EE1A1E26 for ; Thu, 29 Sep 2016 00:31:44 -0700 (PDT) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 23AFDC003584; Thu, 29 Sep 2016 07:31:44 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-12.phx2.redhat.com [10.3.116.12]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8T7VgM3019666; Thu, 29 Sep 2016 03:31:43 -0400 To: GN Keshava References: From: Laszlo Ersek Cc: "edk2-devel@lists.01.org" , "Carsey, Jaben" Message-ID: <49e7533e-4c7c-3585-2b57-6f851860da46@redhat.com> Date: Thu, 29 Sep 2016 09:31:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 29 Sep 2016 07:31:44 +0000 (UTC) Subject: Re: Use fprintf in UEFI X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Sep 2016 07:31:45 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit 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