aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/boot
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/boot')
-rw-r--r--arch/x86/boot/printf.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/arch/x86/boot/printf.c b/arch/x86/boot/printf.c
index 1a09f9309d3c..7e7e890699be 100644
--- a/arch/x86/boot/printf.c
+++ b/arch/x86/boot/printf.c
@@ -33,8 +33,8 @@ static int skip_atoi(const char **s)
33#define PLUS 4 /* show plus */ 33#define PLUS 4 /* show plus */
34#define SPACE 8 /* space if plus */ 34#define SPACE 8 /* space if plus */
35#define LEFT 16 /* left justified */ 35#define LEFT 16 /* left justified */
36#define SPECIAL 32 /* 0x */ 36#define SMALL 32 /* Must be 32 == 0x20 */
37#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ 37#define SPECIAL 64 /* 0x */
38 38
39#define do_div(n,base) ({ \ 39#define do_div(n,base) ({ \
40int __res; \ 40int __res; \
@@ -45,12 +45,16 @@ __res; })
45static char *number(char *str, long num, int base, int size, int precision, 45static char *number(char *str, long num, int base, int size, int precision,
46 int type) 46 int type)
47{ 47{
48 char c, sign, tmp[66]; 48 /* we are called with base 8, 10 or 16, only, thus don't need "G..." */
49 const char *digits = "0123456789abcdefghijklmnopqrstuvwxyz"; 49 static const char digits[16] = "0123456789ABCDEF"; /* "GHIJKLMNOPQRSTUVWXYZ"; */
50
51 char tmp[66];
52 char c, sign, locase;
50 int i; 53 int i;
51 54
52 if (type & LARGE) 55 /* locase = 0 or 0x20. ORing digits or letters with 'locase'
53 digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 56 * produces same digits or (maybe lowercased) letters */
57 locase = (type & SMALL);
54 if (type & LEFT) 58 if (type & LEFT)
55 type &= ~ZEROPAD; 59 type &= ~ZEROPAD;
56 if (base < 2 || base > 36) 60 if (base < 2 || base > 36)
@@ -81,7 +85,7 @@ static char *number(char *str, long num, int base, int size, int precision,
81 tmp[i++] = '0'; 85 tmp[i++] = '0';
82 else 86 else
83 while (num != 0) 87 while (num != 0)
84 tmp[i++] = digits[do_div(num, base)]; 88 tmp[i++] = (digits[do_div(num, base)] | locase);
85 if (i > precision) 89 if (i > precision)
86 precision = i; 90 precision = i;
87 size -= precision; 91 size -= precision;
@@ -95,7 +99,7 @@ static char *number(char *str, long num, int base, int size, int precision,
95 *str++ = '0'; 99 *str++ = '0';
96 else if (base == 16) { 100 else if (base == 16) {
97 *str++ = '0'; 101 *str++ = '0';
98 *str++ = digits[33]; 102 *str++ = ('X' | locase);
99 } 103 }
100 } 104 }
101 if (!(type & LEFT)) 105 if (!(type & LEFT))
@@ -244,9 +248,9 @@ int vsprintf(char *buf, const char *fmt, va_list args)
244 base = 8; 248 base = 8;
245 break; 249 break;
246 250
247 case 'X':
248 flags |= LARGE;
249 case 'x': 251 case 'x':
252 flags |= SMALL;
253 case 'X':
250 base = 16; 254 base = 16;
251 break; 255 break;
252 256