summaryrefslogtreecommitdiff
path: root/lib/display_options.c
AgeCommit message (Collapse)Author
2022-09-23display_options: print_size: Fix order overflowPali Rohár
Function print_size() round size to the nearst value with one decimal fraction number. But in special cases also unit order may overflow. For example value 1073689396 is printed as "1024 MiB" and value 1073741824 as "1 GiB". Fix this issue by detecting order overflow and increasing unit order. With this change also value 1073689396 is printed as "1 GiB". Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-08-10common: Drop display_options.h from common headerSimon Glass
Move this out of the common header and include it only where needed. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-09-17version: Move version_string[] from version.h to version_string.hPali Rohár
More C files do not use compile time timestamp macros and do not have to be recompiled every time when SOURCE_DATE_EPOCH changes. This patch moves version_string[] from version.h to version_string.h and updates other C files which only needs version_string[] string to include version_string.h instead of version.h. After applying this patch these files are not recompiled every time when SOURCE_DATE_EPOCH changes. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2021-08-21display_options: Do not use %llu in print_sizeMatwey V. Kornilov
tiny-printf variant doesn't know how to handle %llu format string, but both tiny-printf and print_size can meet in SPL when TFTP is used to obtain main u-boot image. This is known to lead to critical boot issue at AM335x platform when printf is catched in infinite loop. To avoid such issues and make print_size function tiny-printf friendly, use %u instead of %luu. Note, that the size value is guaranteed to be less than 1024 in this conditional branch, so the cast to unsigned int is safe. Signed-off-by: Matwey V. Kornilov <matwey.kornilov@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-06-08display_options: Split print_buffer() into two functionsSimon Glass
At present print_buffer() outputs a hex dump but it is not possible to place this dump in a string. Refactor it into a top-level function which does the printing and a utility function that dumps a line into a string. This makes the code more generally useful. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08display_options: Drop two spaces before the ASCII columnSimon Glass
At present with print_buffer() U-Boot shows four spaces between the hex and ASCII data. Two seems enough and matches print_hex_dump(). Change it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-27display_options: Use USE_TINY_PRINTF for SPL checkSimon Glass
At present this code uses a simple printf() format if running in SPL. But SPL can use the full printf. Use USE_TINY_PRINTF instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-22lib: print_freq() should output kHz not KHzHeinrich Schuchardt
In the International System of Units (SI) the prefix kilo is abbreviated as 'k' not 'K'. 'K' is the symbol for Kelvin. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Stefan Roese <sr@denx.de>
2020-07-08display_options: Drop #ifdef for MEM_SUPPORT_64BIT_DATASimon Glass
This is defined only when __lp64__ is defined. That means that ulong is 64 bits long. Therefore we don't need to use a separate u64 type on those architectures. Fix up the code to take advantage of that, removing the preprocessor conditions. Also include the missing header file that defines MEM_SUPPORT_64BIT_DATA Fixes: 09140113108 ("command: Remove the cmd_tbl_t typedef") Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-08Update MEM_SUPPORT_64BIT_DATA to be always definedSimon Glass
Define this macro always so we don't need the preprocessor to check it. Convert the users to #if instead of #ifdef. Note that '#if MEM_SUPPORT_64BIT_DATA' does not give an error if the macro is not define. It just assumes zero. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Roese <sr@denx.de>
2020-06-08cmd: Correct the 'md.q' commandSimon Glass
This displays incorrect data at present due to a missing header file in display_options. Fix it. Fixes: 09140113108 ("command: Remove the cmd_tbl_t typedef") Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-17common: Move and rename CONFIG_SYS_SUPPORT_64BIT_DATASimon Glass
This is not really a CONFIG since it is not intended to be set by boards. Move it into the compiler header with other similar defines, and rename it. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-10-08spl: Avoid checking for Ctrl-C in SPL with print_buffer()Simon Glass
We don't have a console in SPL so it doesn't make sense to check for Ctrl-C when printing a memory dump. Skip this so that print_buffer() can be used in SPL. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-05-05lib/display_options: avoid illegal memory accessHeinrich Schuchardt
display_options_get_banner_priv() overwrites bytes before the start of the buffer if the buffer size is less then 3. This case occurs in the Sandbox when executing the `ut_print` command. Correctly handle small buffer sizes. Adjust the print unit test to catch when bytes before the buffer are overwritten. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-02-01lib: Allow using display_buffer() in SPLSimon Glass
At present this function uses printf() format strings that are not supported in SPL, so the output just consists of %llx strings on 64-bit. machines. Fix this by adding a special case. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
2018-09-10Remove <inttypes.h> includes and PRI* usages in printf() entirelyMasahiro Yamada
In int-ll64.h, we always use the following typedefs: typedef unsigned int u32; typedef unsigned long uintptr_t; typedef unsigned long long u64; This does not need to match to the compiler's <inttypes.h>. Do not include it. The use of PRI* makes the code super-ugly. You can simply use "l" for printing uintptr_t, "ll" for u64, and no modifier for u32. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2017-07-11display_options: Refactor to allow obtaining the bannerSimon Glass
Move the display options code into a separate function so that the U-Boot banner can be obtained from other code. Adjust the 'version' command to use it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
2015-11-19Drop config.h header from display_options.cSimon Glass
Since common.h will always include this automatically, it is not needed. Signed-off-by: Simon Glass <sjg@chromium.org>
2015-11-19Move console definitions into a new console.h fileSimon Glass
The console includes a global variable and several functions that are only used by a small subset of U-Boot files. Before adding more functions, move the definitions into their own header file. Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-28lib/display_options: Fix print_freqSuriyan Ramasami
Build without CONFIG_SPL_SERIAL_SUPPORT does not print the cpu freq. I have seen this in the odroid U3 board, where on boot one sees this: CPU: Exynos4412 @ GHz instead of: CPU: Exynos4412 @ 1 GHz I am assuming that this change was done to get rid of compiler warnings related to unused variables when building with CONFIG_SPL_SERIAL_SUPPORT not being defined in an SPL build. Signed-off-by: Suriyan Ramasami <suriyan.r@gmail.com> Acked-by: Simon Glass <sjg@chromium.org> Acked-by: Heiko Schocher <hs@denx.de> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
2015-08-12spl, common, serial: build SPL without serial supportHeiko Schocher
This patch enables building SPL without CONFIG_SPL_SERIAL_SUPPORT support. Signed-off-by: Heiko Schocher <hs@denx.de> [trini: Ensure we build arch/arm/imx-common on mx28] Signed-off-by: Tom Rini <trini@konsulko.com>
2015-05-14sandbox: Fix warning in display_optionsSimon Glass
This fixes a warning in the print_buffer() function with some toolchains. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
2015-04-29Add print_freq() to display frequencies nicelySimon Glass
Add a function similar to print_size() that works for frequencies. It can handle from Hz to GHz. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com>
2015-04-29Move display_options functions to their own headerSimon Glass
Before adding one more function, create a separate header to help reduce the size of common.h. Add the missing function comments and tidy up. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2014-10-27Tidy up data sizes and function comment in display_optionsSimon Glass
Use inttypes.h and uint64_t to correct the code so that it will not issue warnings on 64-bit machines where 'uint64_t' is 'unsigned long'. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-03-04Add 64-bit data support for memory commandsYork Sun
Add 64-bit data for memory commands, such as md, mw, mm, cmp. The new size ".q " is introduced. For 64-bit architecture, 64-bit data is enabled by default, by detecting compiler __LP64__. It is optional for other architectures. Signed-off-by: York Sun <yorksun@freescale.com>
2013-07-24Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk
Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>
2013-03-11display_options:print_buffer: align ASCII printAndreas Bießmann
This patch adds whitespace to the printed hex numbers to have an aligned ASCII printout at the end of the line. This changes for example the md output from: ---8<--- OMAP3 Tricorder # md.l $loadaddr 5 82000000: 30200109 20a4028c 90010000 08a00000 .. 0... ........ 82000010: 01010000 .... --->8--- to ---8<--- OMAP3 Tricorder # md.l $loadaddr 5 82000000: 30200109 20a4028c 90010000 08a00000 .. 0... ........ 82000010: 01010000 .... --->8--- The cost of this is about 72 byte .text increase (tested with at91 build). Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
2013-02-28Update print_buffer() to use constSimon Glass
The buffer cannot be changed by this function, so change the buffer pointer to a const. This allows callers with const pointer to use the function without a cast. Signed-off-by: Simon Glass <sjg@chromium.org>
2011-07-28unify version_stringAndreas Bießmann
This patch removes the architecture specific implementation of version_string where possible. Some architectures use a special place and therefore we provide U_BOOT_VERSION_STRING definition and a common weak symbol version_string. Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com> CC: Mike Frysinger <vapier@gentoo.org> CC: Peter Pan <pppeterpppan@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org>
2010-09-13display_buffer: fix misaligned bufferReinhard Meyer
use a union to cause necessary alignment per architecture Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>
2010-08-09print_buffer: optimize & shrinkMike Frysinger
Applying a little creative format string allows us to shrink the initial data read & display loop by only calling printf once. Re-using the local data buffer to generate the string we want to display then allows us to output everything with just one printf call instead of multiple calls to the putc function. The local stack buffer needs increasing by 1 byte, but the resulting code shrink and speed up is worth it I think. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-05-17Avoid use of divides in print_sizeNick Thompson
Modification of print_size to avoid use of divides and especially long long divides. Keep the binary scale factor in terms of bit shifts instead. This should be faster, since the previous code gave the compiler no clues that the divides where always powers of two, preventing optimisation. Signed-off-by: Nick Thompson <nick.thompson@ge.com> Acked-by: Timur Tabi <timur@freescale.com>
2010-05-05allow print_size to print large numbers on 32-bit systemsTimur Tabi
Modify print_size() so that it can accept numbers larger than 4GB on 32-bit systems. Add support for display terabyte, petabyte, and exabyte sizes. Change the output to use International Electrotechnical Commission binary prefix standard. Signed-off-by: Timur Tabi <timur@freescale.com>
2010-05-05fix print_size printing fractional gigabyte numbers on 32-bit platformsTimur Tabi
In print_size(), the math that calculates the fractional remainder of a number used the same integer size as a physical address. However, the "10 *" factor of the algorithm means that a large number (e.g. 1.5GB) can overflow the integer if we're running on a 32-bit system. Therefore, we need to disassociate this function from the size of a physical address. Signed-off-by: Timur Tabi <timur@freescale.com>
2010-04-13Rename lib_generic/ to lib/Peter Tyser
Now that the other architecture-specific lib directories have been moved out of the top-level directory there's not much reason to have the '_generic' suffix on the common lib directory. Signed-off-by: Peter Tyser <ptyser@xes-inc.com>