Re: [edk2] Printing UINTN numbers in X64 (David F.)

Subject: Re: [edk2] Printing UINTN numbers in X64 (David F.)

From: Alexei Fedorov <Alexei.Fedorov@arm.com>

To: "edk2-devel@lists.sourceforge.net" <edk2-devel@lists.sourceforge.net>

Date: 2013-09-07 01:05:46

What I meant was using 0x%x for 64-bit UINTN:
...size=0x%x\n", ...BufferSize
>> DEBUG ((EFI_D_INFO, "BlockIo (MMIO) ReadBlocks: lba=0x%lx, size=0x%x\n", Lba, BufferSize));
>Shouldn't that be %llx and not %lx

-----Original Message-----
From: edk2-devel-request@lists.sourceforge.net [mailto:edk2-devel-request@lists.sourceforge.net]
Sent: 06 September 2013 16:17
To: edk2-devel@lists.sourceforge.net
Subject: edk2-devel Digest, Vol 45, Issue 35

Send edk2-devel mailing list submissions to
        edk2-devel@lists.sourceforge.net

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.sourceforge.net/lists/listinfo/edk2-devel
or, via email, send a message with subject or body 'help' to
        edk2-devel-request@lists.sourceforge.net

You can reach the person managing the list at
        edk2-devel-owner@lists.sourceforge.net

When replying, please edit your Subject line so it is more specific
than "Re: Contents of edk2-devel digest..."


Today's Topics:

   1. Re: Printing UINTN numbers in X64 (David F.)
   2. Re: Getting actual device name from block devices (David F.)


----------------------------------------------------------------------

Message: 1
Date: Fri, 6 Sep 2013 08:10:54 -0700
From: "David F." 
Subject: Re: [edk2] Printing UINTN numbers in X64
To: "edk2-devel@lists.sourceforge.net"
        
Message-ID:
        
Content-Type: text/plain; charset="windows-1252"

>> DEBUG ((EFI_D_INFO, "BlockIo (MMIO) ReadBlocks: lba=0x%lx, size=0x%x\n",
Lba, BufferSize));

Shouldn't that be %llx and not %lx




On Fri, Sep 6, 2013 at 3:45 AM, Alexei Fedorov wrote:

>  According to \edk2\MdePkg\Include\X64\ProcessorBind.h****
>
> ** **
>
> for X64 ?UINTN? type has a length of 8 bytes:****
>
> ** **
>
> typedef UINT64  UINTN;****
>
> ** **
>
> and ?int? is 32-bit value:****
>
> ** **
>
> typedef unsigned int        UINT32;****
>
> ** **
>
> , so debug macros like in CpuConvertPagesToUncachedVirtualAddress()
> function (\edk2\OvmfPkg\BlockMmioToBlockIoDxe\BlockIo.c):****
>
> ** **
>
> EFI_STATUS****
>
> EFIAPI****
>
> BlockIoReadBlocks (****
>
>   IN EFI_BLOCK_IO_PROTOCOL    *This,****
>
>   IN UINT32                   MediaId,****
>
>   IN EFI_LBA                  Lba,****
>
>   IN UINTN                    BufferSize,****
>
>   OUT VOID                    *Buffer****
>
>   )****
>
> {****
>
>   DEBUG ((EFI_D_INFO, "BlockIo (MMIO) ReadBlocks: lba=0x%lx, size=0x%x\n",
> Lba, BufferSize));****
>
> ...****
>
> ** **
>
> using ?%x? format for UINTN BufferSize will result in truncation to 32-bit
> value. ****
>
> In some cases ?%x? for UINTN can produce wrong output if this UINTN number
> is specified as not the last parameter.****
>
> ** **
>
> This happens because ?int? type is still 32-bit value & it?s used in
> BasePrintLibSPrintMarker() function
> (\edk2\MdePkg\Library\BasePrintLib\PrintLibInternal.c):****
>
> Line #543:****
>
>       case 'd':****
>
>         if ((Flags & LONG_TYPE) == 0) {****
>
>           //****
>
>           // 'd','x', and 'X' that are not preceded by 'l' or 'L' are
> assumed to be type "int".****
>
>           // This assumption is made so the format string definition is
> compatible with the ANSI C****
>
>           // Specification for formatted strings.  It is recommended that
> the Base Types be used ****
>
>           // everywhere, but in this one case, compliance with ANSI C is
> more important, and ****
>
>           // provides an implementation that is compatible with that
> largest possible set of CPU ****
>
>           // architectures.  This is why the type "int" is used in this
> one case.****
>
>           //****
>
>           if (BaseListMarker == NULL) {****
>
>             Value = VA_ARG (VaListMarker, int);****
>
>           } else {****
>
>             Value = BASE_ARG (BaseListMarker, int);****
>
>           }****
>
> ** **
>
> & line #588:****
>
>           if ((Flags & LONG_TYPE) == 0 && Value < 0) {****
>
>             //****
>
>             // 'd','x', and 'X' that are not preceded by 'l' or 'L' are
> assumed to be type "int".****
>
>             // This assumption is made so the format string definition is
> compatible with the ANSI C****
>
>             // Specification for formatted strings.  It is recommended
> that the Base Types be used ****
>
>             // everywhere, but in this one case, compliance with ANSI C is
> more important, and ****
>
>             // provides an implementation that is compatible with that
> largest possible set of CPU ****
>
>             // architectures.  This is why the type "unsigned int" is used
> in this one case.****
>
>             //****
>
>             Value = (unsigned int)Value;****
>
> ** **
>
> Any comments on that?****
>
> ** **
>
> Alexei.****
>
> ** **
>
> ** **
>
> -- IMPORTANT NOTICE: The contents of this email and any attachments are
> confidential and may also be privileged. If you are not the intended
> recipient, please notify the sender immediately and do not disclose the
> contents to any other person, use it for any purpose, or store or copy the
> information in any medium. Thank you.
>
> ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ,
> Registered in England & Wales, Company No: 2557590
> ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ,
> Registered in England & Wales, Company No: 2548782
>
>
> ------------------------------------------------------------------------------
> Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
> Discover the easy way to master current and previous Microsoft technologies
> and advance your career. Get an incredible 1,500+ hours of step-by-step
> tutorial videos with LearnDevNow. Subscribe today and save!
> http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

Message: 2
Date: Fri, 6 Sep 2013 08:17:13 -0700
From: "David F." 
Subject: Re: [edk2] Getting actual device name from block devices
To: "edk2-devel@lists.sourceforge.net"
        
Message-ID:
        
Content-Type: text/plain; charset="iso-8859-1"

but want the actual device name, also at minimum need load/eject and
prevent/allow removal support, but really able to send any command to the
devices.  Not the controller info...


On Fri, Sep 6, 2013 at 4:59 AM, Sergey Isakov  wrote:

> May be this part of codes helps you
> ----------------
>   // Scan PCI handles
>   Status = gBS->LocateHandleBuffer (
>                                     ByProtocol,
>                                     &gEfiPciIoProtocolGuid,
>                                     NULL,
>                                     &HandleCount,
>                                     &HandleArray
>                                     );
>   if (!EFI_ERROR (Status)) {
>     for (Index = 0; Index < HandleCount; Index++) {
>       Status = gBS->HandleProtocol (
>                                     HandleArray[Index],
>                                     &gEfiPciIoProtocolGuid,
>                                     (VOID **)&PciIo
>                                     );
>       if (!EFI_ERROR (Status)) {
>         // Read PCI BUS
>         Status = PciIo->GetLocation (PciIo, &Segment, &Bus, &Device,
> &Function);
>         Status = PciIo->Pci.Read (
>                                   PciIo,
>                                   EfiPciIoWidthUint32,
>                                   0,
>                                   sizeof (Pci) / sizeof (UINT32),
>                                   &Pci
>                                   );
>         Print(L"PCI (%02x|%02x:%02x.%02x) : %04x %04x
> class=%02x%02x%02x\n",
>             Segment, Bus, Device, Function,
>             Pci.Hdr.VendorId, Pci.Hdr.DeviceId,
>             Pci.Hdr.ClassCode[2], Pci.Hdr.ClassCode[1], Pci.Hdr.ClassCode[
> 0]);
>
> ----------------
> The same is possible for ExtScsiPassTru protocol
>
> Regards,
> Sergey
>
> On 06.09.2013, at 9:40, David F.  wrote:
>
> Yes, but to do it right you really need the SCSI Pass Through Interface to
> talk directly with the device as you may need to send setup or blank
> commands, etc...  Also for ATA devices, be nice for the various commands
> dealing with their command set.
>
>
>
>
>
> On Thu, Sep 5, 2013 at 7:42 PM, Sergey Isakov  wrote:
>
>> Hi David,
>> I am not understanding what are you going to do. How did you propose to
>> burn DVD in UEFI mode? Do you have such UEFI application to burn DVD?
>> Sergey.
>>
>> On 06.09.2013, at 6:22, David F.  wrote:
>>
>> > Well, without any passthru support, I'm not sure how I'm, as an
>> application, supposed to get the device names of the various hard drives
>> and dvd drives in the system? Also, how you would be able to burn a CD/DVD
>> and send the various commands to setup for the burn.   I see the Visual
>> BIOS on the system has all the name, so there must be a way without
>> essentially turning off all UEFI services and writing a raw DOS like
>> program to directly program the SATA/PATA controllers like the old days?
>>  Strange?
>> >
>> > Does anyone have the answer??
>> >
>> > TIA!!
>> >
>> >
>> ------------------------------------------------------------------------------
>> > Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
>> > Discover the easy way to master current and previous Microsoft
>> technologies
>> > and advance your career. Get an incredible 1,500+ hours of step-by-step
>> > tutorial videos with LearnDevNow. Subscribe today and save!
>> >
>> http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk_______________________________________________
>> > edk2-devel mailing list
>> > edk2-devel@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/edk2-devel
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
>> Discover the easy way to master current and previous Microsoft
>> technologies
>> and advance your career. Get an incredible 1,500+ hours of step-by-step
>> tutorial videos with LearnDevNow. Subscribe today and save!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>>
>
>
> ------------------------------------------------------------------------------
> Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
> Discover the easy way to master current and previous Microsoft technologies
> and advance your career. Get an incredible 1,500+ hours of step-by-step
> tutorial videos with LearnDevNow. Subscribe today and save!
>
> http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk_______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
>
>
>
> ------------------------------------------------------------------------------
> Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
> Discover the easy way to master current and previous Microsoft technologies
> and advance your career. Get an incredible 1,500+ hours of step-by-step
> tutorial videos with LearnDevNow. Subscribe today and save!
> http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk

------------------------------

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel


End of edk2-devel Digest, Vol 45, Issue 35
******************************************


-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium.  Thank you.

ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No:  2557590
ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No:  2548782


------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel