I always thought type 'X' was always assumed to be a UINTN, but apparently I was wrong. Maybe what is missing here is a new [flag], call it 'N', which is equivalent 'L' in 64-bit builds, and ignored in 32-bit builds.
Deric Cole Sr. Customer Engineer Phoenix Technologies Ltd. -----Original Message----- From: Andrew Fish [mailto:[email protected]] Sent: Friday, September 06, 2013 9:27 AM To: [email protected] Subject: Re: [edk2] Printing UINTN numbers in X64 (David F.) Andrew Fish On Sep 6, 2013, at 9:05 AM, Alexei Fedorov <[email protected]> wrote: > 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 > Print() is not ANSI C. It also changed as in the EDK %X was a UINTN, so the bug you see could be something that was missed when the change happened. >From >https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Include/Library/PrintLib.h This does not follow the ANSI C standard for sprint(). The format of argument descriptors is described below. The ANSI C standard for sprint() has been followed for some of the format types, and has not been followed for others. The exceptions are noted below. %[flags][width][.precision]type [flags]: - - - The field is left justified. If not flag is not specified, then the field is right justified. - space - Prefix a space character to a number. Only valid for types X, x, and d. - + - Prefix a plus character to a number. Only valid for types X, x, and d. If both space and + are specified, then space is ignored. - 0 - Pad with 0 characters to the left of a number. Only valid for types X, x, and d. - , - Place a comma every 3rd digit of the number. Only valid for type d. If 0 is also specified, then 0 is ignored. - L, l - The number being printed is size UINT64. Only valid for types X, x, and d. If this flag is not specified, then the number being printed is size int. - NOTE: All invalid flags are ignored. [width]: - * - The width of the field is specified by a UINTN argument in the argument list. - number - The number specified as a decimal value represents the width of the field. - NOTE: If [width] is not specified, then a field width of 0 is assumed. [.precision]: - * - The precision of the field is specified by a UINTN argument in the argument list. - number - The number specified as a decimal value represents the precision of the field. - NOTE: If [.precision] is not specified, then a precision of 0 is assumed. type: - % - Print a %%. - c - The argument is a Unicode character. ASCII characters can be printed using this type too by making sure bits 8..15 of the argument are set to 0. - x - The argument is an unsigned hexadecimal number. The characters used are 0..9 and A..F. If the flag 'L' is not specified, then the argument is assumed to be size int. This does not follow ANSI C. - X - The argument is an unsigned hexadecimal number and the number is padded with zeros. This is equivalent to a format string of "0x". If the flag 'L' is not specified, then the argument is assumed to be size int. This does not follow ANSI C. - d - The argument is a signed decimal number. If the flag 'L' is not specified, then the argument is assumed to be size int. - p - The argument is a pointer that is a (VOID *), and it is printed as an unsigned hexadecimal number The characters used are 0..9 and A..F. - a - The argument is a pointer to an ASCII string. This does not follow ANSI C. - S, s - The argument is a pointer to a Unicode string. This does not follow ANSI C. - g - The argument is a pointer to a GUID structure. The GUID is printed in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. This does not follow ANSI C. - t - The argument is a pointer to an EFI_TIME structure. The time and date are printed in the format "mm/dd/yyyy hh:mm" where mm is the month zero padded, dd is the day zero padded, yyyy is the year zero padded, hh is the hour zero padded, and mm is minutes zero padded. This does not follow ANSI C. - r - The argument is a RETURN_STATUS value. This value is converted to a string following the table below. This does not follow ANSI C. - RETURN_SUCCESS - "Success" - RETURN_LOAD_ERROR - "Load Error" - RETURN_INVALID_PARAMETER - "Invalid Parameter" - RETURN_UNSUPPORTED - "Unsupported" - RETURN_BAD_BUFFER_SIZE - "Bad Buffer Size" - RETURN_BUFFER_TOO_SMALL - "Buffer Too Small" - RETURN_NOT_READY - "Not Ready" - RETURN_DEVICE_ERROR - "Device Error" - RETURN_WRITE_PROTECTED - "Write Protected" - RETURN_OUT_OF_RESOURCES - "Out of Resources" - RETURN_VOLUME_CORRUPTED - "Volume Corrupt" - RETURN_VOLUME_FULL - "Volume Full" - RETURN_NO_MEDIA - "No Media" - RETURN_MEDIA_CHANGED - "Media changed" - RETURN_NOT_FOUND - "Not Found" - RETURN_ACCESS_DENIED - "Access Denied" - RETURN_NO_RESPONSE - "No Response" - RETURN_NO_MAPPING - "No mapping" - RETURN_TIMEOUT - "Time out" - RETURN_NOT_STARTED - "Not started" - RETURN_ALREADY_STARTED - "Already started" - RETURN_ABORTED - "Aborted" - RETURN_ICMP_ERROR - "ICMP Error" - RETURN_TFTP_ERROR - "TFTP Error" - RETURN_PROTOCOL_ERROR - "Protocol Error" - RETURN_WARN_UNKNOWN_GLYPH - "Warning Unknown Glyph" - RETURN_WARN_DELETE_FAILURE - "Warning Delete Failure" - RETURN_WARN_WRITE_FAILURE - "Warning Write Failure" - RETURN_WARN_BUFFER_TOO_SMALL - "Warning Buffer Too Small" > -----Original Message----- > From: [email protected] > [mailto:[email protected]] > Sent: 06 September 2013 16:17 > To: [email protected] > Subject: edk2-devel Digest, Vol 45, Issue 35 > > Send edk2-devel mailing list submissions to > [email protected] > > 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 > [email protected] > > You can reach the person managing the list at > [email protected] > > 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." <[email protected]> > Subject: Re: [edk2] Printing UINTN numbers in X64 > To: "[email protected]" > <[email protected]> > Message-ID: > <cagrsmlswxs9kqt6o+yvc1a3kc7hphofkm42r5p39fu-gnha...@mail.gmail.com> > 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 <[email protected]>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 >> [email protected] >> 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." <[email protected]> > Subject: Re: [edk2] Getting actual device name from block devices > To: "[email protected]" > <[email protected]> > Message-ID: > <CAGRSmLu3mVXyYC2h-=9et8r42gtdkbs7y85izlym5-dgxgo...@mail.gmail.com> > 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 <[email protected]> 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. <[email protected]> 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 <[email protected]> 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. <[email protected]> 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 >>>> [email protected] >>>> 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 >>> [email protected] >>> 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 >> [email protected] >> 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 >> [email protected] >> 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 > [email protected] > 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 > [email protected] > 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 [email protected] 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 [email protected] https://lists.sourceforge.net/lists/listinfo/edk2-devel
