Commit 2d7e8282 authored by Soby Mathew's avatar Soby Mathew
Browse files

Introduce tf_vprintf() and tf_string_print()


This patch introduces tf_vprintf() and tf_string_print() APIs
which is needed by the logging framework introduced in a later
patch.

Change-Id: Ie4240443d0e04e070502b51e371e546dd469fd33
Signed-off-by: default avatarSoby Mathew <soby.mathew@arm.com>
parent 8b6385de
Showing with 19 additions and 9 deletions
+19 -9
...@@ -23,8 +23,10 @@ ...@@ -23,8 +23,10 @@
(((lcount) > 1) ? va_arg(args, unsigned long long int) : \ (((lcount) > 1) ? va_arg(args, unsigned long long int) : \
((lcount) ? va_arg(args, unsigned long int) : va_arg(args, unsigned int))) ((lcount) ? va_arg(args, unsigned long int) : va_arg(args, unsigned int)))
static void string_print(const char *str) void tf_string_print(const char *str)
{ {
assert(str);
while (*str) while (*str)
putchar(*str++); putchar(*str++);
} }
...@@ -64,15 +66,13 @@ static void unsigned_num_print(unsigned long long int unum, unsigned int radix) ...@@ -64,15 +66,13 @@ static void unsigned_num_print(unsigned long long int unum, unsigned int radix)
* The print exits on all other formats specifiers other than valid * The print exits on all other formats specifiers other than valid
* combinations of the above specifiers. * combinations of the above specifiers.
*******************************************************************/ *******************************************************************/
void tf_printf(const char *fmt, ...) void tf_vprintf(const char *fmt, va_list args)
{ {
va_list args;
int l_count; int l_count;
long long int num; long long int num;
unsigned long long int unum; unsigned long long int unum;
char *str; char *str;
va_start(args, fmt);
while (*fmt) { while (*fmt) {
l_count = 0; l_count = 0;
...@@ -94,12 +94,12 @@ loop: ...@@ -94,12 +94,12 @@ loop:
break; break;
case 's': case 's':
str = va_arg(args, char *); str = va_arg(args, char *);
string_print(str); tf_string_print(str);
break; break;
case 'p': case 'p':
unum = (uintptr_t)va_arg(args, void *); unum = (uintptr_t)va_arg(args, void *);
if (unum) if (unum)
string_print("0x"); tf_string_print("0x");
unsigned_num_print(unum, 16); unsigned_num_print(unum, 16);
break; break;
...@@ -123,13 +123,20 @@ loop: ...@@ -123,13 +123,20 @@ loop:
break; break;
default: default:
/* Exit on any other format specifier */ /* Exit on any other format specifier */
goto exit; return;
} }
fmt++; fmt++;
continue; continue;
} }
putchar(*fmt++); putchar(*fmt++);
} }
exit: }
va_end(args);
void tf_printf(const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
tf_vprintf(fmt, va);
va_end(va);
} }
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#define LOG_LEVEL_VERBOSE 50 #define LOG_LEVEL_VERBOSE 50
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#if LOG_LEVEL >= LOG_LEVEL_NOTICE #if LOG_LEVEL >= LOG_LEVEL_NOTICE
...@@ -65,6 +66,8 @@ void __dead2 __stack_chk_fail(void); ...@@ -65,6 +66,8 @@ void __dead2 __stack_chk_fail(void);
void tf_printf(const char *fmt, ...) __printflike(1, 2); void tf_printf(const char *fmt, ...) __printflike(1, 2);
int tf_snprintf(char *s, size_t n, const char *fmt, ...) __printflike(3, 4); int tf_snprintf(char *s, size_t n, const char *fmt, ...) __printflike(3, 4);
void tf_vprintf(const char *fmt, va_list args);
void tf_string_print(const char *str);
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
#endif /* __DEBUG_H__ */ #endif /* __DEBUG_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment