Angel Pons | b706ab3 | 2020-04-02 23:48:09 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Angel Pons | b706ab3 | 2020-04-02 23:48:09 +0200 | [diff] [blame] | 2 | |
Damien Roth | 4e7e987 | 2016-01-16 18:59:51 -0700 | [diff] [blame] | 3 | /* |
Damien Roth | 4e7e987 | 2016-01-16 18:59:51 -0700 | [diff] [blame] | 4 | * vtxprintf.c, originally from linux/lib/vsprintf.c |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Stefan Reinauer | 52fc6b1 | 2009-10-24 13:06:04 +0000 | [diff] [blame] | 7 | #include <console/vtxprintf.h> |
Joel Kitching | 393c71c | 2019-06-16 16:09:42 +0800 | [diff] [blame] | 8 | #include <ctype.h> |
Edward O'Callaghan | 0ddb826 | 2014-06-17 18:37:08 +1000 | [diff] [blame] | 9 | #include <string.h> |
Jacob Garber | c764fb2 | 2019-07-03 12:38:46 -0600 | [diff] [blame] | 10 | #include <stdint.h> |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 11 | |
Kyösti Mälkki | b04e0ff | 2014-02-04 14:28:17 +0200 | [diff] [blame] | 12 | #define call_tx(x) tx_byte(x, data) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 13 | |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 14 | #define ZEROPAD 1 /* pad with zero */ |
| 15 | #define SIGN 2 /* unsigned/signed long */ |
| 16 | #define PLUS 4 /* show plus */ |
| 17 | #define SPACE 8 /* space if plus */ |
| 18 | #define LEFT 16 /* left justified */ |
| 19 | #define SPECIAL 32 /* 0x */ |
| 20 | #define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ |
| 21 | |
Kyösti Mälkki | b04e0ff | 2014-02-04 14:28:17 +0200 | [diff] [blame] | 22 | static int number(void (*tx_byte)(unsigned char byte, void *data), |
Vadim Bendebury | 9b058467 | 2014-11-29 22:05:09 -0800 | [diff] [blame] | 23 | unsigned long long inum, int base, int size, int precision, int type, |
Kyösti Mälkki | b04e0ff | 2014-02-04 14:28:17 +0200 | [diff] [blame] | 24 | void *data) |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 25 | { |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 26 | char c, sign, tmp[66]; |
Jacob Garber | b19946c | 2019-07-03 14:40:11 -0600 | [diff] [blame] | 27 | const char *digits = "0123456789abcdef"; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 28 | int i; |
| 29 | int count = 0; |
Vadim Bendebury | 9b058467 | 2014-11-29 22:05:09 -0800 | [diff] [blame] | 30 | unsigned long long num = inum; |
Julius Werner | 7c712bb | 2019-05-01 16:51:20 -0700 | [diff] [blame] | 31 | long long snum = num; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 32 | |
| 33 | if (type & LARGE) |
Jacob Garber | b19946c | 2019-07-03 14:40:11 -0600 | [diff] [blame] | 34 | digits = "0123456789ABCDEF"; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 35 | if (type & LEFT) |
| 36 | type &= ~ZEROPAD; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 37 | c = (type & ZEROPAD) ? '0' : ' '; |
| 38 | sign = 0; |
| 39 | if (type & SIGN) { |
Julius Werner | 7c712bb | 2019-05-01 16:51:20 -0700 | [diff] [blame] | 40 | if (snum < 0) { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 41 | sign = '-'; |
Julius Werner | 7c712bb | 2019-05-01 16:51:20 -0700 | [diff] [blame] | 42 | num = -snum; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 43 | size--; |
| 44 | } else if (type & PLUS) { |
| 45 | sign = '+'; |
| 46 | size--; |
| 47 | } else if (type & SPACE) { |
| 48 | sign = ' '; |
| 49 | size--; |
| 50 | } |
| 51 | } |
| 52 | if (type & SPECIAL) { |
| 53 | if (base == 16) |
| 54 | size -= 2; |
| 55 | else if (base == 8) |
| 56 | size--; |
| 57 | } |
| 58 | i = 0; |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 59 | if (num == 0) { |
| 60 | tmp[i++] = '0'; |
| 61 | } else { |
| 62 | while (num != 0) { |
| 63 | tmp[i++] = digits[num % base]; |
| 64 | num /= base; |
| 65 | } |
Ronald G. Minnich | 79e36d9 | 2013-01-30 14:29:34 -0800 | [diff] [blame] | 66 | } |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 67 | if (i > precision) { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 68 | precision = i; |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 69 | } |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 70 | size -= precision; |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 71 | if (!(type&(ZEROPAD+LEFT))) { |
Elyes HAOUAS | 2e0f3d7 | 2018-05-03 09:36:28 +0200 | [diff] [blame] | 72 | while (size-- > 0) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 73 | call_tx(' '), count++; |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 74 | } |
| 75 | if (sign) { |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 76 | call_tx(sign), count++; |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 77 | } |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 78 | if (type & SPECIAL) { |
Elyes HAOUAS | 20767ba | 2018-04-26 10:00:35 +0200 | [diff] [blame] | 79 | if (base == 8) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 80 | call_tx('0'), count++; |
Elyes HAOUAS | 20767ba | 2018-04-26 10:00:35 +0200 | [diff] [blame] | 81 | else if (base == 16) { |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 82 | call_tx('0'), count++; |
Jacob Garber | 5b99481 | 2019-07-10 11:44:45 -0600 | [diff] [blame] | 83 | if (type & LARGE) |
| 84 | call_tx('X'), count++; |
| 85 | else |
| 86 | call_tx('x'), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 87 | } |
| 88 | } |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 89 | if (!(type & LEFT)) { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 90 | while (size-- > 0) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 91 | call_tx(c), count++; |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 92 | } |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 93 | while (i < precision--) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 94 | call_tx('0'), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 95 | while (i-- > 0) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 96 | call_tx(tmp[i]), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 97 | while (size-- > 0) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 98 | call_tx(' '), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 99 | return count; |
| 100 | } |
| 101 | |
Kyösti Mälkki | b04e0ff | 2014-02-04 14:28:17 +0200 | [diff] [blame] | 102 | int vtxprintf(void (*tx_byte)(unsigned char byte, void *data), |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 103 | const char *fmt, va_list args, void *data) |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 104 | { |
| 105 | int len; |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 106 | unsigned long long num; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 107 | int i, base; |
| 108 | const char *s; |
| 109 | |
| 110 | int flags; /* flags to number() */ |
| 111 | |
| 112 | int field_width; /* width of output field */ |
| 113 | int precision; /* min. # of digits for integers; max |
| 114 | number of chars for from string */ |
Jacob Garber | c764fb2 | 2019-07-03 12:38:46 -0600 | [diff] [blame] | 115 | int qualifier; /* 'h', 'H', 'l', 'L', 'z', or 'j' for integer fields */ |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 116 | |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 117 | int count; |
| 118 | |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 119 | for (count = 0; *fmt ; ++fmt) { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 120 | if (*fmt != '%') { |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 121 | call_tx(*fmt), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 122 | continue; |
| 123 | } |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 124 | |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 125 | /* process flags */ |
| 126 | flags = 0; |
Patrick Georgi | c5fc7db | 2012-03-07 15:55:47 +0100 | [diff] [blame] | 127 | repeat: |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 128 | ++fmt; /* this also skips first '%' */ |
| 129 | switch (*fmt) { |
| 130 | case '-': flags |= LEFT; goto repeat; |
| 131 | case '+': flags |= PLUS; goto repeat; |
| 132 | case ' ': flags |= SPACE; goto repeat; |
| 133 | case '#': flags |= SPECIAL; goto repeat; |
| 134 | case '0': flags |= ZEROPAD; goto repeat; |
| 135 | } |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 136 | |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 137 | /* get field width */ |
| 138 | field_width = -1; |
Julius Werner | 66c77c2 | 2019-05-13 17:45:27 -0700 | [diff] [blame] | 139 | if (isdigit(*fmt)) { |
| 140 | field_width = skip_atoi((char **)&fmt); |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 141 | } else if (*fmt == '*') { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 142 | ++fmt; |
| 143 | /* it's the next argument */ |
| 144 | field_width = va_arg(args, int); |
| 145 | if (field_width < 0) { |
| 146 | field_width = -field_width; |
| 147 | flags |= LEFT; |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | /* get the precision */ |
| 152 | precision = -1; |
| 153 | if (*fmt == '.') { |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 154 | ++fmt; |
Julius Werner | 66c77c2 | 2019-05-13 17:45:27 -0700 | [diff] [blame] | 155 | if (isdigit(*fmt)) { |
| 156 | precision = skip_atoi((char **)&fmt); |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 157 | } else if (*fmt == '*') { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 158 | ++fmt; |
| 159 | /* it's the next argument */ |
| 160 | precision = va_arg(args, int); |
| 161 | } |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 162 | if (precision < 0) { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 163 | precision = 0; |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 164 | } |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | /* get the conversion qualifier */ |
| 168 | qualifier = -1; |
Jacob Garber | c764fb2 | 2019-07-03 12:38:46 -0600 | [diff] [blame] | 169 | if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'z' || *fmt == 'j') { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 170 | qualifier = *fmt; |
| 171 | ++fmt; |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 172 | if (*fmt == 'l') { |
| 173 | qualifier = 'L'; |
| 174 | ++fmt; |
| 175 | } |
Patrick Georgi | d01ed75 | 2014-01-18 16:56:36 +0100 | [diff] [blame] | 176 | if (*fmt == 'h') { |
| 177 | qualifier = 'H'; |
| 178 | ++fmt; |
| 179 | } |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | /* default base */ |
| 183 | base = 10; |
| 184 | |
| 185 | switch (*fmt) { |
| 186 | case 'c': |
| 187 | if (!(flags & LEFT)) |
| 188 | while (--field_width > 0) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 189 | call_tx(' '), count++; |
| 190 | call_tx((unsigned char) va_arg(args, int)), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 191 | while (--field_width > 0) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 192 | call_tx(' '), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 193 | continue; |
| 194 | |
| 195 | case 's': |
| 196 | s = va_arg(args, char *); |
| 197 | if (!s) |
| 198 | s = "<NULL>"; |
| 199 | |
Martin Roth | ad6c885 | 2016-11-18 11:35:01 -0700 | [diff] [blame] | 200 | len = strnlen(s, (size_t)precision); |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 201 | |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 202 | if (!(flags & LEFT)) { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 203 | while (len < field_width--) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 204 | call_tx(' '), count++; |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 205 | } |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 206 | for (i = 0; i < len; ++i) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 207 | call_tx(*s++), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 208 | while (len < field_width--) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 209 | call_tx(' '), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 210 | continue; |
| 211 | |
| 212 | case 'p': |
Julius Werner | 540a980 | 2019-12-09 13:03:29 -0800 | [diff] [blame] | 213 | /* even on 64-bit systems, coreboot only resides in the |
| 214 | low 4GB so pad pointers to 32-bit for readability. */ |
| 215 | if (field_width == -1 && precision == -1) |
| 216 | precision = 2*sizeof(uint32_t); |
| 217 | flags |= SPECIAL; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 218 | count += number(tx_byte, |
| 219 | (unsigned long) va_arg(args, void *), 16, |
Kyösti Mälkki | b04e0ff | 2014-02-04 14:28:17 +0200 | [diff] [blame] | 220 | field_width, precision, flags, data); |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 221 | continue; |
| 222 | |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 223 | case 'n': |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 224 | if (qualifier == 'L') { |
| 225 | long long *ip = va_arg(args, long long *); |
| 226 | *ip = count; |
| 227 | } else if (qualifier == 'l') { |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 228 | long *ip = va_arg(args, long *); |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 229 | *ip = count; |
| 230 | } else { |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 231 | int *ip = va_arg(args, int *); |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 232 | *ip = count; |
| 233 | } |
| 234 | continue; |
| 235 | |
| 236 | case '%': |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 237 | call_tx('%'), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 238 | continue; |
| 239 | |
| 240 | /* integer number formats - set up the flags and "break" */ |
| 241 | case 'o': |
| 242 | base = 8; |
| 243 | break; |
| 244 | |
| 245 | case 'X': |
| 246 | flags |= LARGE; |
Jacob Garber | 4c33a3a | 2019-07-12 10:34:06 -0600 | [diff] [blame] | 247 | /* fall through */ |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 248 | case 'x': |
| 249 | base = 16; |
| 250 | break; |
| 251 | |
| 252 | case 'd': |
| 253 | case 'i': |
| 254 | flags |= SIGN; |
| 255 | case 'u': |
| 256 | break; |
| 257 | |
| 258 | default: |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 259 | call_tx('%'), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 260 | if (*fmt) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 261 | call_tx(*fmt), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 262 | else |
| 263 | --fmt; |
| 264 | continue; |
| 265 | } |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 266 | if (qualifier == 'L') { |
| 267 | num = va_arg(args, unsigned long long); |
| 268 | } else if (qualifier == 'l') { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 269 | num = va_arg(args, unsigned long); |
Stefan Reinauer | bfff6de | 2012-05-15 13:28:07 -0700 | [diff] [blame] | 270 | } else if (qualifier == 'z') { |
| 271 | num = va_arg(args, size_t); |
Jacob Garber | c764fb2 | 2019-07-03 12:38:46 -0600 | [diff] [blame] | 272 | } else if (qualifier == 'j') { |
| 273 | num = va_arg(args, uintmax_t); |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 274 | } else if (qualifier == 'h') { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 275 | num = (unsigned short) va_arg(args, int); |
| 276 | if (flags & SIGN) |
| 277 | num = (short) num; |
Patrick Georgi | d01ed75 | 2014-01-18 16:56:36 +0100 | [diff] [blame] | 278 | } else if (qualifier == 'H') { |
| 279 | num = (unsigned char) va_arg(args, int); |
| 280 | if (flags & SIGN) |
| 281 | num = (signed char) num; |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 282 | } else if (flags & SIGN) { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 283 | num = va_arg(args, int); |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 284 | } else { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 285 | num = va_arg(args, unsigned int); |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 286 | } |
Kyösti Mälkki | b04e0ff | 2014-02-04 14:28:17 +0200 | [diff] [blame] | 287 | count += number(tx_byte, num, base, field_width, precision, flags, data); |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 288 | } |
| 289 | return count; |
| 290 | } |