4
4
#include <BoardConsole.h>
5
5
#include <osdebug.h>
6
6
7
- static const char hex_conv [] = "0123456789ABCDEF" ;
7
+ static const char * hex_conv [2 ] =
8
+ {
9
+ "0123456789abcdef" , // lower-case
10
+ "0123456789ABCDEF" // upper-case
11
+ };
12
+
8
13
static void dbgput (const void * _str , int n ) {
9
14
const char * str = (const char * ) _str ;
10
15
while (n -- )
@@ -29,6 +34,7 @@ void osDbgPrintf(const char * str, ...) {
29
34
long arg_i ;
30
35
uintptr_t arg_p ;
31
36
int str_size , i ;
37
+ int ucase = 0 ;
32
38
33
39
va_start (ap , str );
34
40
@@ -75,7 +81,7 @@ void osDbgPrintf(const char * str, ...) {
75
81
tmp_conv_ptr = tmp_n_conv + 32 ;
76
82
* tmp_conv_ptr = 0 ;
77
83
do {
78
- * -- tmp_conv_ptr = hex_conv [arg_u % 10 ];
84
+ * -- tmp_conv_ptr = hex_conv [0 ][ arg_u % 10 ];
79
85
arg_u /= 10 ;
80
86
} while (arg_u );
81
87
dbgput (tmp_conv_ptr , strlen (tmp_conv_ptr ));
@@ -84,20 +90,25 @@ void osDbgPrintf(const char * str, ...) {
84
90
arg_p = va_arg (ap , uintptr_t );
85
91
dbgput ("0x" , 2 );
86
92
for (i = sizeof (arg_p ) * 2 - 1 ; i >= 0 ; i -- ) {
87
- dbgput (& hex_conv [(arg_p >> (i << 2 )) & 15 ], 1 );
93
+ dbgput (& hex_conv [1 ][ (arg_p >> (i << 2 )) & 15 ], 1 );
88
94
}
89
95
break ;
96
+ case 'X' : // same as x but uppercase for alpha chars
97
+ ucase = 1 ;
98
+ // fall through
90
99
case 'x' :
91
100
arg_u = va_arg (ap , unsigned long );
92
101
seen_something = 0 ;
102
+ const char * hex_p = hex_conv [ucase ];
93
103
for (i = sizeof (arg_p ) * 2 - 1 ; i >= 0 ; i -- ) {
94
104
if (!seen_something && ((arg_u >> (i << 2 )) == 0 ))
95
105
continue ;
96
- dbgput (& hex_conv [(arg_u >> (i << 2 )) & 15 ], 1 );
106
+ dbgput (& hex_p [(arg_u >> (i << 2 )) & 15 ], 1 );
97
107
seen_something = 1 ;
98
108
}
99
109
if (!seen_something )
100
110
dbgput ("0" , 1 );
111
+ ucase = 0 ;
101
112
break ;
102
113
case 0 : // malformed format string with a trailing %.
103
114
dbgput ("%" , 1 );
0 commit comments