4 #include <BoardConsole.h>
7 static const char hex_conv[] =
"0123456789ABCDEF";
8 static void dbgput(
const void * _str,
int n) {
9 const char * str = (
const char *) _str;
20 const char * ptr = str;
22 char tmp_n_conv[33], * tmp_conv_ptr;
28 unsigned long arg_u = 0;
35 while ((percent = strchr(ptr,
'%'))) {
36 dbgput(ptr, percent - ptr);
39 while ((*ptr >=
'0') && (*ptr <=
'9')) {
41 entry_size += *ptr -
'0';
49 arg_c = va_arg(ap,
int);
53 arg_s = va_arg(ap,
char *);
55 for (str_size = strlen(arg_s); str_size < entry_size; str_size++)
57 dbgput(arg_s, strlen(arg_s));
59 for (str_size = 0; str_size < entry_size; str_size++)
65 arg_i = va_arg(ap,
long);
74 arg_u = va_arg(ap,
unsigned long);
75 tmp_conv_ptr = tmp_n_conv + 32;
78 *--tmp_conv_ptr = hex_conv[arg_u % 10];
81 dbgput(tmp_conv_ptr, strlen(tmp_conv_ptr));
84 arg_p = va_arg(ap, uintptr_t);
86 for (i =
sizeof(arg_p) * 2 - 1; i >= 0; i--) {
87 dbgput(&hex_conv[(arg_p >> (i << 2)) & 15], 1);
91 arg_u = va_arg(ap,
unsigned long);
93 for (i =
sizeof(arg_p) * 2 - 1; i >= 0; i--) {
94 if (!seen_something && ((arg_u >> (i << 2)) == 0))
96 dbgput(&hex_conv[(arg_u >> (i << 2)) & 15], 1);
106 dbgput(
"<unsupported format: %", 22);
115 dbgput(ptr, strlen(ptr));