09 Dec, 2019

1 commit


03 Dec, 2019

1 commit

  • At present this function sits in its own file but it does not really
    justify it. There are similar string functions in vsprintf.h, so move it
    there. Also add the missing function comment.

    Use the vsprintf.h include file explicitly where needed.

    Signed-off-by: Simon Glass
    Reviewed-by: Tom Rini

    Simon Glass
     

07 Jun, 2019

1 commit

  • In the UEFI context GUIDs are expected to be rendered in upper case.

    The patch uses the formerly unused bit 1 of the parameter str_format
    of function uuid_bin_to_str() to indicate if we need upper or lower case
    output.

    Function uuid_string() in vsprint.c is adjusted to correctly set the bit
    depending on the print format code.

    %pUb: 01020304-0506-0708-090a-0b0c0d0e0f10
    %pUB: 01020304-0506-0708-090A-0B0C0D0E0F10
    %pUl: 04030201-0605-0807-090a-0b0c0d0e0f10
    %pUL: 04030201-0605-0807-090A-0B0C0D0E0F10

    Up to this point only a diagnostic message in mount_ubifs() using '%pUB' is
    concerned by the change. Further patches are needed to adjust the UEFI
    subsystem.

    A unit test is provided inside the ut_print command.

    Signed-off-by: Heinrich Schuchardt

    Heinrich Schuchardt
     

13 May, 2019

1 commit


03 May, 2019

1 commit


12 Apr, 2019

1 commit

  • When phys_addr_t printf specifier support was first introduced in commit
    1eebd14b7902 ("vsprintf: Add modifier for phys_addr_t"), it was enabled
    only if CONFIG_CMD_NET was selected. Since physical addresses are not
    unique to networking support it doesn't make sense to conditionally add
    it in those cases only. Move support for it outside of the CMD_NET guard
    so that the specifier is always supported.

    Signed-off-by: Thierry Reding
    Reviewed-by: Simon Glass

    Thierry Reding
     

16 Feb, 2019

1 commit


13 Feb, 2019

1 commit


24 Sep, 2018

4 commits


25 Jul, 2018

1 commit

  • At present a NULL pointer passed to printf for a %pU argument will cause
    U-Boot to access memory at 0. Fix this by adding a check, and print
    "(null)" instead.

    Signed-off-by: Simon Glass
    Reviewed-by: Alexander Graf
    [agraf: s/(null)//]
    Signed-off-by: Alexander Graf

    Simon Glass
     

13 Jun, 2018

1 commit

  • Often during debugging session it's very interesting to see
    what data we were dealing with. For example what we write or read
    to/from memory or peripherals.

    This change introduces functions that allow to dump binary
    data with one simple function invocation like:
    ------------------->8----------------
    print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, len);
    ------------------->8----------------

    which gives us the following:
    ------------------->8----------------
    00000000: f2 b7 c9 88 62 61 75 64 72 61 74 65 3d 31 31 35 ....baudrate=115
    00000010: 32 30 30 00 62 6f 6f 74 61 72 67 73 3d 63 6f 6e 200.bootargs=con
    00000020: 73 6f 6c 65 3d 74 74 79 53 33 2c 31 31 35 32 30 sole=ttyS3,11520
    00000030: 30 6e 38 00 62 6f 6f 74 64 65 6c 61 79 3d 33 00 0n8.bootdelay=3.
    00000040: 62 6f 6f 74 66 69 6c 65 3d 75 49 6d 61 67 65 00 bootfile=uImage.
    00000050: 66 64 74 63 6f 6e 74 72 6f 6c 61 64 64 72 3d 39 fdtcontroladdr=9
    00000060: 66 66 62 31 62 61 30 00 6c 6f 61 64 61 64 64 72 ffb1ba0.loadaddr
    00000070: 3d 30 78 38 32 30 30 30 30 30 30 00 73 74 64 65 =0x82000000.stde
    00000080: 72 72 3d 73 65 72 69 61 6c 30 40 65 30 30 32 32 rr=serial0@e0022
    00000090: 30 30 30 00 73 74 64 69 6e 3d 73 65 72 69 61 6c 000.stdin=serial
    000000a0: 30 40 65 30 30 32 32 30 30 30 00 73 74 64 6f 75 0@e0022000.stdou
    000000b0: 74 3d 73 65 72 69 61 6c 30 40 65 30 30 32 32 30 t=serial0@e00220
    000000c0: 30 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00..............
    ...
    ------------------->8----------------

    Source of hexdump.c was copied from Linux kernel v4.7-rc2.

    Signed-off-by: Alexey Brodkin
    Cc: Anatolij Gustschin
    Cc: Mario Six
    Cc: Simon Glass
    Cc: Tom Rini
    Cc: Stefan Roese

    Alexey Brodkin
     

29 Apr, 2018

2 commits


29 Jan, 2018

1 commit

  • When printing '%pD' with a value of NULL we want to output
    ''. But this requires copying to buf. Leave this
    to string16.

    A unit test is supplied which relies on EFI support in the sandbox.

    The development for EFI support in the sandbox is currently in branch
    u-boot-dm/efi-working. The branch lacks commit 6ea8b580f06b ("efi_loader:
    correct DeviceNodeToText for media types"). Ater rebasing the aforementioned
    branch on U-Boot v2018.01 and adding 256060e4257a2 and this patch the test
    is executed successfully.

    Fixes: 256060e4257a2 (vsprintf.c: add EFI device path printing)
    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     

23 Jan, 2018

1 commit

  • For debugging efi_loader we need the capability to print EFI
    device paths. With this patch we can write:

    debug("device path: %pD", dp);

    A possible output would be

    device path: /MemoryMapped(0x0,0x3ff93a82,0x3ff93a82)

    This enhancement is not available when building without EFI support
    and neither in the SPL nor in the API example.

    A test is provided. It can be executed in the sandbox with command
    ut_print.

    The development for EFI support in the sandbox is currently in
    branch u-boot-dm/efi-working. The branch currently lacks
    commit 6ea8b580f06b ("efi_loader: correct DeviceNodeToText
    for media types"). Ater rebasing the aforementioned branch on
    U-Boot v2018.01 the test is executed successfully.

    Without EFI support in the sandbox the test is simply skipped.

    Suggested-by: Rob Clark
    Signed-off-by: Heinrich Schuchardt
    Reviewed-by: Simon Glass
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     

13 Sep, 2017

2 commits

  • This works (roughly) the same way as linux's, but we currently always
    print lower-case (ie. we just keep %pUB and %pUL for compat with linux),
    mostly just because that is what uuid_bin_to_str() supports.

    %pUb: 01020304-0506-0708-090a-0b0c0d0e0f10
    %pUl: 04030201-0605-0807-090a-0b0c0d0e0f10

    It will be used by a later efi_loader paths for efi variables and for
    device-path-to-text protocol, and also quite useful for debug prints
    of protocol GUIDs.

    Signed-off-by: Rob Clark
    Tested-by: Heinrich Schuchardt
    Reviewed-by: Simon Glass

    Rob Clark
     
  • This is convenient for efi_loader which deals a lot with UTF-16. Only
    enabled with CC_SHORT_WCHAR, leaving room to add a UTF-32 version when
    CC_SHORT_WCHAR is not enabled.

    Signed-off-by: Rob Clark
    Reviewed-by: Simon Glass
    Reviewed-by: Simon Glass

    Rob Clark
     

19 Jan, 2016

1 commit

  • Enabling this function always removes some class of string saftey issues.
    The size change here in general is about 400 bytes and this seems a reasonable
    trade-off.

    Cc: Peng Fan
    Cc: Peter Robinson
    Cc: Fabio Estevam
    Cc: Adrian Alonso
    Cc: Stefano Babic
    Cc: Hans de Goede
    Signed-off-by: Tom Rini

    Tom Rini
     

14 Dec, 2015

2 commits


23 Nov, 2015

1 commit

  • This patch adds a small printf() version that supports all basic formats.
    Its intented to be used in U-Boot SPL versions on platforms with very
    limited internal RAM sizes.

    To enable it, just define CONFIG_USE_TINY_PRINTF in your defconfig. This
    will result in the SPL using this tiny function and the main U-Boot
    still using the full-blown printf() function.

    This code was copied from:
    http://www.sparetimelabs.com/printfrevisited
    With mostly only coding style related changes so that its checkpatch
    clean.

    The size reduction is about 2.5KiB. Here a comparison for the db-mv784mp-gp
    (Marvell AXP) SPL:

    Without this patch:
    58963 18536 1928 79427 13643 ./spl/u-boot-spl

    With this patch:
    56542 18536 1956 77034 12cea ./spl/u-boot-spl

    Note:
    To make it possible to compile tiny-printf.c instead of vsprintf.c when
    CONFIG_USE_TINY_PRINTF is defined, the functions printf() and vprintf() are
    moved from common/console.c into vsprintf.c in this patch.

    Signed-off-by: Stefan Roese
    Cc: Simon Glass
    Cc: Hans de Goede
    Cc: Tom Rini
    Cc: Albert Aribaud

    Stefan Roese
     

22 Jul, 2015

1 commit


30 Jun, 2015

1 commit

  • Move common functions from cmd_nand.c (for calculating offset
    and size from cmdline paramter) to common place, so they could
    used from other commands which use mtd partitions.

    For onenand the arg_off_size() is left in common/cmd_onenand.c.
    It should use now the common arg_off() function, but as I could
    not test onenand I let it there ...

    Signed-off-by: Heiko Schocher
    Acked-by: Scott Wood
    Reviewed-by: Jagannadh Teki

    Heiko Schocher
     

23 Apr, 2015

1 commit


23 Nov, 2014

1 commit

  • Provide a new modifier to vsprintf() to print phys_addr_t variables to
    avoid having to cast or #ifdef when printing them out. The %pa modifier
    is used for this purpose, so phys_addr_t variables need to be passed by
    reference, like so:

    phys_addr_t start = 0;

    printf("start: %pa\n", &start);

    Depending on the size of phys_addr_t this will print out the address
    with 8 or 16 hexadecimal digits following a 0x prefix.

    Signed-off-by: Thierry Reding
    Tested-by: Stephen Warren
    Signed-off-by: Simon Glass

    Thierry Reding
     

21 Nov, 2014

1 commit

  • U-Boot has imported various utility macros from Linux
    scattering them to various places without consistency.

    In include/common.h are min, max, min3, max3, ARRAY_SIZE, ALIGN,
    container_of, DIV_ROUND_UP, etc.
    In include/linux/compat.h are min_t, max_t, round_up, round_down,
    etc.
    We also have duplicated defines of min_t in some *.c files.

    Moreover, we are suffering from too cluttered include/common.h.

    This commit moves various macros that originate in
    include/linux/kernel.h of Linux to their original position.

    Note:
    This commit simply moves the macros; the macros roundup,
    min, max, min2, max3, ARRAY_SIZE are different
    from those of Linux at this point.

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

27 Oct, 2014

1 commit


19 Jul, 2014

1 commit


25 Jan, 2014

1 commit

  • When CONFIG_SYS_VSNPRINTF is enabled, it protects print operations
    such as sprintf, snprintf, vsnprintf, etc., from buffer overflows.
    But vsnprintf_internal includes the terminating NULL character in
    the calculation of number of characters written. This affects sprintf
    and snprintf return values. Fix this issue by setting pointer 'str'
    back to the location of the '\0'.

    Signed-off-by: Darwin Rambo
    Reviewed-by: Steve Rae

    Darwin Rambo
     

26 Jun, 2013

1 commit


20 Feb, 2013

1 commit


14 Dec, 2012

1 commit

  • The ustrtoul shall convert string defined size (e.g. 1GiB) to unsigned
    long type (as its name implies).

    Up till now it had returned int, which might cause problems with large
    numbers (GiB range), when interpreted as U2 signed numbers.

    Signed-off-by: Lukasz Majewski
    Signed-off-by: Kyungmin Park

    Lukasz Majewski
     

05 Nov, 2012

1 commit


03 Nov, 2012

1 commit

  • The %p format of printf() would print a pointer to address null as
    "(null)". This makes sense in a real OS where a NULL pointer must
    never be dereferenced, but this is a bootloader, and there are cases
    where accessing the data at address null makes perfect sense.

    Remove the special case in lib/vsprintf.c using "#if 0" with a comment
    to make clear this was an intentional change and to stop re-adding
    this code.

    Signed-off-by: Wolfgang Denk
    Acked-by: Joe Hershberger

    Wolfgang Denk
     

16 Oct, 2012

2 commits


18 Dec, 2011

1 commit