summaryrefslogtreecommitdiff
path: root/lib/tiny-printf.c
Commit message (Collapse)AuthorAgeLines
* tiny-printf: Adjust to avoid using data sectionSimon Glass2016-08-08-44/+58
| | | | | | | | | | | | | | | | | We can pass all the variables down to the functions that need them, and then everything is on the stack. This is safer than using the data section. At least on firefly-rk3288, the code size is the same and the data size is 12 bytes smaller: before: 18865 2636 40 21541 5425 b/firefly-rk3288/spl/u-boot-spl after: 18865 2624 40 21529 5419 b/firefly-rk3288/spl/u-boot-spl Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Stefan Roese <sr@denx.de>
* tiny-printf: Support assert()Simon Glass2016-07-14-0/+9
| | | | | | | | | | At present assert() is not supported with tiny-printf, so when DEBUG is enabled a build error is generated for each assert(). Add an __assert_fail() function to correct this. It prints a message and then hangs. Signed-off-by: Simon Glass <sjg@chromium.org>
* SPL: tiny-printf: avoid any BSS usageAndre Przywara2016-07-08-3/+8
| | | | | | | | | | As printf calls may be executed quite early, we should avoid using any BSS stored variables, since some boards put BSS in DRAM, which may not have been initialised yet. Explicitly mark those "static global" variables as belonging to the .data section, to keep tiny-printf clear of any BSS usage. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
* tinyprintf: Add vprintf implementationHans de Goede2016-06-20-0/+5
| | | | | | | | | vprintf is used by panic() which is used in various SPL paths on some boards. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Ian Campbell <ijc@hellion.org.uk> Reviewed-by: Simon Glass <sjg@chromium.org>
* tiny-printf: Correct the snprintf() implementationSimon Glass2016-06-09-1/+3
| | | | | | | | | | | | This current code passes the variable arguments list to sprintf(). This is not correct. Fix it by calling _vprintf() directly. This makes firefly-rk3288 boot again. Fixes: abeb272 ("tiny-printf: Support snprintf()") Reviewed-by: Stefan Roese <sr@denx.de> Acked-by: Marek Vasut <marex@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org>
* tiny-printf: Support sprintf()Marek Vasut2016-06-02-2/+14
| | | | | | | | | | | | | | Add a simple version of this function for SPL. It does not check the buffer size as this would add to the code size. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Simon Glass <sjg@chromium.org> Cc: Stefan Roese <sr@denx.de> Cc: Tom Rini <trini@konsulko.com> Cc: lesne@alse-fr.com Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Sylvain Lesne <lesne@alse-fr.com> Tested-by: Sylvain Lesne <lesne@alse-fr.com>
* tiny-printf: Support snprintf()Simon Glass2016-05-26-2/+25
| | | | | | | | Add a simple version of this function for SPL. It does not check the buffer size as this would add to the code size. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Roese <sr@denx.de>
* tiny-printf: Tidy up a few nitsSimon Glass2016-05-26-8/+8
| | | | | | | | | - Rename 'w' to 'width' to make it more obvious what it is used for - Use bool and int types instead of char to avoid register-masking on 32-bit machines Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Roese <sr@denx.de>
* tiny-printf: Always print zeroesSimon Glass2016-01-20-4/+12
| | | | | | | | | At present this does not print zero values in numeric format (hex and decimal). Add a special case for this. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
* tiny-printf: Avoid printing NULL stringsSimon Glass2016-01-20-2/+4
| | | | | | | Add a check for NULL strings to avoid printing junk to the console. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Roese <sr@denx.de>
* lib/tiny-printf.c: Implement vprintfSjoerd Simons2015-12-13-5/+13
| | | | | | | Implement both printf and vprintf for a bit more flexibility, e.g. allows the panic() function to work with tiny-printf. Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
* lib/tiny-printf.c: Support numbers bigger than 0xffff and misc updatesStefan Roese2015-11-23-20/+12
| | | | | | | | | | | | | | | | | | | | | | | With this patch now, the tiny printf() function also supports numbers bigger than 0xffff. Additionally the code is simplified a bit and some static variables are moved to function parameters. Also the upper case hex variable output support is removed, as its not really needed in this simple printf version. And removing it reduces the complexity and the code size again a bit. Here the new numbers, again on the db-mv784mp-gp (Armada XP): Without this patch: 56542 18536 1956 77034 12cea ./spl/u-boot-spl With this patch: 56446 18536 1936 76918 12c76 ./spl/u-boot-spl Signed-off-by: Stefan Roese <sr@denx.de> Cc: Simon Glass <sjg@chromium.org> Cc: Hans de Goede <hdegoede@redhat.com> Cc: Tom Rini <trini@konsulko.com> Cc: Albert Aribaud <albert.u.boot@aribaud.net>
* lib/tiny-printf.c: Add tiny printf function for space limited environmentsStefan Roese2015-11-23-0/+130
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 <sr@denx.de> Cc: Simon Glass <sjg@chromium.org> Cc: Hans de Goede <hdegoede@redhat.com> Cc: Tom Rini <trini@konsulko.com> Cc: Albert Aribaud <albert.u.boot@aribaud.net>