From 1c1c8a3a990742a73a75b091c35213b0a50f0c45 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 21 Oct 2019 17:26:43 -0600 Subject: tiny-printf: Reduce size by removing ctype The ctype array is brought into the image, adding 256 bytes, when it is unlikely to be needed. The extra code for %p is only present when DEBUG is defined, so let's drop ctype as well unless DEBUG is defined. Signed-off-by: Simon Glass --- lib/tiny-printf.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/tiny-printf.c') diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index ebef92fc9f6..632b4249142 100644 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@ -289,8 +289,15 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va) break; case 'p': pointer(info, fmt, va_arg(va, void *)); + /* + * Skip this because it pulls in _ctype which is + * 256 bytes, and we don't generally implement + * pointer anyway + */ +#ifdef DEBUG while (isalnum(fmt[0])) fmt++; +#endif break; case '%': out(info, '%'); -- cgit v1.2.3 From dee74e6cc4a94da19b99309ad1c99eb5bddfe217 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 21 Oct 2019 17:26:44 -0600 Subject: tiny-printf: Add print_grouped_ull() This function is used in the bootstage report which may be trigged in TPL or TPL. Add a very basic implication of this function so that it builds. There is no attempt to get the formatting right, since this would add too much code size. Signed-off-by: Simon Glass Reviewed-by: Stefan Roese --- lib/tiny-printf.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/tiny-printf.c') diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index 632b4249142..d46d206873f 100644 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@ -389,3 +389,9 @@ int snprintf(char *buf, size_t size, const char *fmt, ...) return ret; } + +void print_grouped_ull(unsigned long long int_val, int digits) +{ + /* Don't try to print the upper 32-bits */ + printf("%ld ", (ulong)int_val); +} -- cgit v1.2.3 From 831c1611195961bf79ac55a8deaac9034112ef5f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 21 Oct 2019 17:26:45 -0600 Subject: tiny-printf: Reorder code to support %p With a bit of code reordering we can support %p using the existing code for ulong. Move the %p code up and adjust the logic accordingly. Signed-off-by: Simon Glass --- lib/tiny-printf.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'lib/tiny-printf.c') diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index d46d206873f..4f7fc239ae9 100644 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@ -157,7 +157,8 @@ static void ip4_addr_string(struct printf_info *info, u8 *addr) * decimal). */ -static void pointer(struct printf_info *info, const char *fmt, void *ptr) +static void __maybe_unused pointer(struct printf_info *info, const char *fmt, + void *ptr) { #ifdef DEBUG unsigned long num = (uintptr_t)ptr; @@ -266,6 +267,21 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va) div_out(info, &num, div); } break; + case 'p': +#ifdef DEBUG + pointer(info, fmt, va_arg(va, void *)); + /* + * Skip this because it pulls in _ctype which is + * 256 bytes, and we don't generally implement + * pointer anyway + */ + while (isalnum(fmt[0])) + fmt++; + break; +#else + islong = true; + /* no break */ +#endif case 'x': if (islong) { num = va_arg(va, unsigned long); @@ -287,18 +303,6 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va) case 's': p = va_arg(va, char*); break; - case 'p': - pointer(info, fmt, va_arg(va, void *)); - /* - * Skip this because it pulls in _ctype which is - * 256 bytes, and we don't generally implement - * pointer anyway - */ -#ifdef DEBUG - while (isalnum(fmt[0])) - fmt++; -#endif - break; case '%': out(info, '%'); default: -- cgit v1.2.3