From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-x234.google.com (mail-it0-x234.google.com [IPv6:2607:f8b0:4001:c0b::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 96A981A1E26 for ; Thu, 29 Sep 2016 00:53:11 -0700 (PDT) Received: by mail-it0-x234.google.com with SMTP id u134so96336493itb.1 for ; Thu, 29 Sep 2016 00:53:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NqycTVKYmk6fw7LhZook11PxUSjx/3AgZILBEbB8cZw=; b=Xpiyzli1dFSEUbxM85ZXX0TOociQm2JOxrt32wOMhyHAwWQz4MQciehIoXwjUitAB6 6nt/uiAA41IPusvnhm5wUwpEJNWAv3w1sheksOq9szeeabdiLZMDPEj6CSoQqAdflwXB tnEHbxt2O4S4UyWaqu6MOOCl+jj7cSPt9pV9BrtcJBRX0kN5tK534JOVRFkeeVeb4E4+ 0Y8kHbBA65z+CVit8EnZXvC+nLJBy3FDdQJm52u9Hl7ygayDGnzdSwRXcfMSSA6P/tt1 mXXI5/ZnoyOKPrV1n3koRz6boKgk4Z0eegqzhbJ49kHkU0hKCKc9pRjlZYgkGaaPAEIm LNCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NqycTVKYmk6fw7LhZook11PxUSjx/3AgZILBEbB8cZw=; b=lYYBN5lDXHqMFEDyOCBnWKBmqopEcegXLKMPHInuqy68IwL7ROrmEJ/l8HncvBZ9Dd GM+UzquBya3+zCH2yajmPSmD9hOkthWh1q3gY8IYt7qFVpCZRKUY0DKLYkPAM9OSlt1w x12Ziw6G3+A2OaIh1b42UUj2cVZsgEAH6gsWp1NolldL5MAT5EfQrnw5rM6oKjGDqr1D 40UIhUggeyDKQ3a8Sec2hQmE+t35G0KXwlp7/QNgGlmQFCiEN6jDJ7MxtpTBeKVNFDt2 jmDARoGQvkNMEeGrW4qH0xf0wREf/R636dS7pu5Vdym5ttoycEjP8XunRFkoKaj1hUmP wovw== X-Gm-Message-State: AA6/9RnxYqCVpQvtoQfKo0R3NZWNrNAvJhba8TAPImLdHkeNGFkX/rmIIYcWhP9iUr/6nLMmKiXOJcqVPPKjag== X-Received: by 10.107.128.31 with SMTP id b31mr477937iod.163.1475135590708; Thu, 29 Sep 2016 00:53:10 -0700 (PDT) MIME-Version: 1.0 References: <49e7533e-4c7c-3585-2b57-6f851860da46@redhat.com> In-Reply-To: <49e7533e-4c7c-3585-2b57-6f851860da46@redhat.com> From: GN Keshava Date: Thu, 29 Sep 2016 07:52:59 +0000 Message-ID: To: Laszlo Ersek Cc: "edk2-devel@lists.01.org" , "Carsey, Jaben" X-Content-Filtered-By: Mailman/MimeDel 2.1.21 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:53:11 -0000 Content-Type: text/plain; charset=UTF-8 Thank you for detailed answer. Laszlo. Regards, Keshava On Thu, 29 Sep 2016 at 13:01 Laszlo Ersek 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 >