Rev 276 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 276 | Rev 323 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (C) 2001-2004 Jakub Jermar |
2 | * Copyright (C) 2001-2004 Jakub Jermar |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | #include <putchar.h> |
29 | #include <putchar.h> |
30 | #include <print.h> |
30 | #include <print.h> |
31 | #include <synch/spinlock.h> |
31 | #include <synch/spinlock.h> |
32 | #include <arch/arg.h> |
32 | #include <arch/arg.h> |
33 | #include <arch/asm.h> |
33 | #include <arch/asm.h> |
34 | #include <arch/fmath.h> |
34 | #include <arch/fmath.h> |
35 | 35 | ||
36 | #include <arch.h> |
36 | #include <arch.h> |
37 | 37 | ||
38 | static char digits[] = "0123456789abcdef"; /**< Hexadecimal characters */ |
38 | static char digits[] = "0123456789abcdef"; /**< Hexadecimal characters */ |
39 | static spinlock_t printflock; /**< printf spinlock */ |
39 | static spinlock_t printflock; /**< printf spinlock */ |
40 | 40 | ||
41 | #define DEFAULT_DOUBLE_PRECISION 16 |
41 | #define DEFAULT_DOUBLE_PRECISION 16 |
42 | #define DEFAULT_DOUBLE_BUFFER_SIZE 128 |
42 | #define DEFAULT_DOUBLE_BUFFER_SIZE 128 |
43 | 43 | ||
44 | void print_double(double num, __u8 modifier, __u16 precision) |
44 | void print_double(double num, __u8 modifier, __u16 precision) |
45 | { |
45 | { |
46 | double intval,intval2; |
46 | double intval,intval2; |
47 | int counter; |
47 | int counter; |
48 | int exponent,exponenttmp; |
48 | int exponent,exponenttmp; |
49 | unsigned char buf[DEFAULT_DOUBLE_BUFFER_SIZE]; |
49 | unsigned char buf[DEFAULT_DOUBLE_BUFFER_SIZE]; |
50 | unsigned long in1,in2; |
50 | unsigned long in1,in2; |
51 | 51 | ||
52 | 52 | ||
53 | if (fmath_is_nan(num)) { |
53 | if (fmath_is_nan(num)) { |
54 | print_str("NaN"); |
54 | print_str("NaN"); |
55 | return; |
55 | return; |
56 | } |
56 | } |
57 | 57 | ||
58 | if (num<0.0) { |
58 | if (num<0.0) { |
59 | putchar('-'); |
59 | putchar('-'); |
60 | num=num*-1.0; |
60 | num=num*-1.0; |
61 | } |
61 | } |
62 | 62 | ||
63 | 63 | ||
64 | if (fmath_is_infinity(num)) { |
64 | if (fmath_is_infinity(num)) { |
65 | print_str("Inf"); |
65 | print_str("Inf"); |
66 | return; |
66 | return; |
67 | } |
67 | } |
68 | 68 | ||
69 | if ((modifier=='E')||(modifier=='e')) { |
69 | if ((modifier=='E')||(modifier=='e')) { |
70 | intval2=fmath_fint(fmath_get_decimal_exponent(num),&intval); |
70 | intval2=fmath_fint(fmath_get_decimal_exponent(num),&intval); |
71 | exponent=intval; |
71 | exponent=intval; |
72 | if ((intval2<0.0)) exponent--; |
72 | if ((intval2<0.0)) exponent--; |
73 | num = num / ((fmath_dpow(10.0,exponent))); |
73 | num = num / ((fmath_dpow(10.0,exponent))); |
74 | 74 | ||
75 | print_double(num,modifier+1,precision); //modifier+1 = E => F or e => f |
75 | print_double(num,modifier+1,precision); /* modifier+1 = E => F or e => f */ |
76 | putchar(modifier); |
76 | putchar(modifier); |
77 | if (exponent<0) { |
77 | if (exponent<0) { |
78 | putchar('-'); |
78 | putchar('-'); |
79 | exponent*=-1; |
79 | exponent*=-1; |
80 | } |
80 | } |
81 | print_number(exponent,10); |
81 | print_number(exponent,10); |
82 | return; |
82 | return; |
83 | } |
83 | } |
84 | 84 | ||
85 | //TODO: rounding constant - when we got fraction >= 0.5, we must increment last printed number |
85 | /* TODO: rounding constant - when we got fraction >= 0.5, we must increment last printed number */ |
86 | 86 | ||
- | 87 | /* |
|
87 | /* Here is problem with cumulative error while printing big double values -> we will divide |
88 | * Here is a problem with cumulative error while printing big double values -> we will divide |
88 | the number with a power of 10, print new number with better method for small numbers and then print decimal point at correct position */ |
89 | * the number with a power of 10, print new number with better method for small numbers and |
- | 90 | * then print decimal point at correct position. |
|
- | 91 | */ |
|
89 | 92 | ||
90 | fmath_fint(fmath_get_decimal_exponent(num),&intval); |
93 | fmath_fint(fmath_get_decimal_exponent(num),&intval); |
91 | 94 | ||
92 | exponent=(intval>0.0?intval:0); |
95 | exponent=(intval>0.0?intval:0); |
93 | 96 | ||
94 | precision+=exponent; |
97 | precision+=exponent; |
95 | 98 | ||
96 | if (exponent>0) num = num / ((fmath_dpow(10.0,exponent))); |
99 | if (exponent>0) num = num / ((fmath_dpow(10.0,exponent))); |
97 | 100 | ||
98 | num=fmath_fint(num,&intval); |
101 | num=fmath_fint(num,&intval); |
99 | 102 | ||
100 | if (precision>0) { |
103 | if (precision>0) { |
101 | counter=precision-1; |
104 | counter=precision-1; |
102 | if (exponent>0) counter++; |
105 | if (exponent>0) counter++; |
103 | 106 | ||
104 | if (counter>=DEFAULT_DOUBLE_BUFFER_SIZE) { |
107 | if (counter>=DEFAULT_DOUBLE_BUFFER_SIZE) { |
105 | counter=DEFAULT_DOUBLE_BUFFER_SIZE; |
108 | counter=DEFAULT_DOUBLE_BUFFER_SIZE; |
106 | } |
109 | } |
107 | exponenttmp=exponent; |
110 | exponenttmp=exponent; |
108 | while(counter>=0) { |
111 | while(counter>=0) { |
109 | num *= 10.0; |
112 | num *= 10.0; |
110 | num = fmath_fint(num,&intval2); |
113 | num = fmath_fint(num,&intval2); |
111 | buf[counter--]=((int)intval2)+'0'; |
114 | buf[counter--]=((int)intval2)+'0'; |
112 | exponenttmp--; |
115 | exponenttmp--; |
113 | if ((exponenttmp==0)&&(counter>=0)) buf[counter--]='.'; |
116 | if ((exponenttmp==0)&&(counter>=0)) buf[counter--]='.'; |
114 | } |
117 | } |
115 | counter=precision; |
118 | counter=precision; |
116 | if ((exponent==0)&&(counter<DEFAULT_DOUBLE_BUFFER_SIZE)) buf[counter]='.'; |
119 | if ((exponent==0)&&(counter<DEFAULT_DOUBLE_BUFFER_SIZE)) buf[counter]='.'; |
117 | counter++; |
120 | counter++; |
118 | } else { |
121 | } else { |
119 | counter=0; |
122 | counter=0; |
120 | } |
123 | } |
121 | 124 | ||
122 | in1=intval; |
125 | in1=intval; |
123 | if (in1==0.0) { |
126 | if (in1==0.0) { |
124 | if (counter<DEFAULT_DOUBLE_BUFFER_SIZE) buf[counter++]='0'; |
127 | if (counter<DEFAULT_DOUBLE_BUFFER_SIZE) buf[counter++]='0'; |
125 | } else { |
128 | } else { |
126 | while(( in1>0 )&&(counter<DEFAULT_DOUBLE_BUFFER_SIZE)) { |
129 | while(( in1>0 )&&(counter<DEFAULT_DOUBLE_BUFFER_SIZE)) { |
127 | 130 | ||
128 | in2=in1; |
131 | in2=in1; |
129 | in1/=10; |
132 | in1/=10; |
130 | buf[counter]=in2-in1*10 + '0'; |
133 | buf[counter]=in2-in1*10 + '0'; |
131 | counter++; |
134 | counter++; |
132 | } |
135 | } |
133 | } |
136 | } |
134 | 137 | ||
135 | counter = (counter>=DEFAULT_DOUBLE_BUFFER_SIZE?DEFAULT_DOUBLE_BUFFER_SIZE:counter); |
138 | counter = (counter>=DEFAULT_DOUBLE_BUFFER_SIZE?DEFAULT_DOUBLE_BUFFER_SIZE:counter); |
136 | while (counter>0) { |
139 | while (counter>0) { |
137 | putchar(buf[--counter]); |
140 | putchar(buf[--counter]); |
138 | }; |
141 | } |
139 | return; |
142 | return; |
140 | } |
143 | } |
141 | 144 | ||
142 | /** Print NULL terminated string |
145 | /** Print NULL terminated string |
143 | * |
146 | * |
144 | * Print characters from str using putchar() until |
147 | * Print characters from str using putchar() until |
145 | * \x00 character is reached. |
148 | * \x00 character is reached. |
146 | * |
149 | * |
147 | * @param str Characters to print. |
150 | * @param str Characters to print. |
148 | * |
151 | * |
149 | */ |
152 | */ |
150 | void print_str(const char *str) |
153 | void print_str(const char *str) |
151 | { |
154 | { |
152 | int i = 0; |
155 | int i = 0; |
153 | char c; |
156 | char c; |
154 | 157 | ||
155 | while (c = str[i++]) |
158 | while (c = str[i++]) |
156 | putchar(c); |
159 | putchar(c); |
157 | } |
160 | } |
158 | 161 | ||
159 | 162 | ||
160 | /** Print hexadecimal digits |
163 | /** Print hexadecimal digits |
161 | * |
164 | * |
162 | * Print fixed count of hexadecimal digits from |
165 | * Print fixed count of hexadecimal digits from |
163 | * the number num. The digits are printed in |
166 | * the number num. The digits are printed in |
164 | * natural left-to-right order starting with |
167 | * natural left-to-right order starting with |
165 | * the width-th digit. |
168 | * the width-th digit. |
166 | * |
169 | * |
167 | * @param num Number containing digits. |
170 | * @param num Number containing digits. |
168 | * @param width Count of digits to print. |
171 | * @param width Count of digits to print. |
169 | * |
172 | * |
170 | */ |
173 | */ |
171 | void print_fixed_hex(const __u64 num, const int width) |
174 | void print_fixed_hex(const __u64 num, const int width) |
172 | { |
175 | { |
173 | int i; |
176 | int i; |
174 | 177 | ||
175 | for (i = width*8 - 4; i >= 0; i -= 4) |
178 | for (i = width*8 - 4; i >= 0; i -= 4) |
176 | putchar(digits[(num>>i) & 0xf]); |
179 | putchar(digits[(num>>i) & 0xf]); |
177 | } |
180 | } |
178 | 181 | ||
179 | 182 | ||
180 | /** Print number in given base |
183 | /** Print number in given base |
181 | * |
184 | * |
182 | * Print significant digits of a number in given |
185 | * Print significant digits of a number in given |
183 | * base. |
186 | * base. |
184 | * |
187 | * |
185 | * @param num Number to print. |
188 | * @param num Number to print. |
186 | * @param base Base to print the number in (should |
189 | * @param base Base to print the number in (should |
187 | * be in range 2 .. 16). |
190 | * be in range 2 .. 16). |
188 | * |
191 | * |
189 | */ |
192 | */ |
190 | void print_number(const __native num, const unsigned int base) |
193 | void print_number(const __native num, const unsigned int base) |
191 | { |
194 | { |
192 | int val = num; |
195 | int val = num; |
193 | char d[sizeof(__native)*8+1]; /* this is good enough even for base == 2 */ |
196 | char d[sizeof(__native)*8+1]; /* this is good enough even for base == 2 */ |
194 | int i = sizeof(__native)*8-1; |
197 | int i = sizeof(__native)*8-1; |
195 | 198 | ||
196 | do { |
199 | do { |
197 | d[i--] = digits[val % base]; |
200 | d[i--] = digits[val % base]; |
198 | } while (val /= base); |
201 | } while (val /= base); |
199 | 202 | ||
200 | d[sizeof(__native)*8] = 0; |
203 | d[sizeof(__native)*8] = 0; |
201 | print_str(&d[i + 1]); |
204 | print_str(&d[i + 1]); |
202 | } |
205 | } |
203 | 206 | ||
204 | 207 | ||
205 | /** General formatted text print |
208 | /** General formatted text print |
206 | * |
209 | * |
207 | * Print text formatted according the fmt parameter |
210 | * Print text formatted according the fmt parameter |
208 | * and variant arguments. Each formatting directive |
211 | * and variant arguments. Each formatting directive |
209 | * begins with % (percentage) character and one of the |
212 | * begins with % (percentage) character and one of the |
210 | * following character: |
213 | * following character: |
211 | * |
214 | * |
212 | * % Prints the percentage character. |
215 | * % Prints the percentage character. |
213 | * s The next variant argument is treated as char* |
216 | * s The next variant argument is treated as char* |
214 | * and printed as a NULL terminated string. |
217 | * and printed as a NULL terminated string. |
215 | * c The next variant argument is treated as a single char. |
218 | * c The next variant argument is treated as a single char. |
216 | * p The next variant argument is treated as a maximum |
219 | * p The next variant argument is treated as a maximum |
217 | * bit-width integer with respect to architecture |
220 | * bit-width integer with respect to architecture |
218 | * and printed in full hexadecimal width. |
221 | * and printed in full hexadecimal width. |
219 | * P As with 'p', but '0x' is prefixed. |
222 | * P As with 'p', but '0x' is prefixed. |
220 | * q The next variant argument is treated as a 64b integer |
223 | * q The next variant argument is treated as a 64b integer |
221 | * and printed in full hexadecimal width. |
224 | * and printed in full hexadecimal width. |
222 | * Q As with 'q', but '0x' is prefixed. |
225 | * Q As with 'q', but '0x' is prefixed. |
223 | * l The next variant argument is treated as a 32b integer |
226 | * l The next variant argument is treated as a 32b integer |
224 | * and printed in full hexadecimal width. |
227 | * and printed in full hexadecimal width. |
225 | * L As with 'l', but '0x' is prefixed. |
228 | * L As with 'l', but '0x' is prefixed. |
226 | * w The next variant argument is treated as a 16b integer |
229 | * w The next variant argument is treated as a 16b integer |
227 | * and printed in full hexadecimal width. |
230 | * and printed in full hexadecimal width. |
228 | * W As with 'w', but '0x' is prefixed. |
231 | * W As with 'w', but '0x' is prefixed. |
229 | * b The next variant argument is treated as a 8b integer |
232 | * b The next variant argument is treated as a 8b integer |
230 | * and printed in full hexadecimal width. |
233 | * and printed in full hexadecimal width. |
231 | * N As with 'b', but '0x' is prefixed. |
234 | * N As with 'b', but '0x' is prefixed. |
232 | * d The next variant argument is treated as integer |
235 | * d The next variant argument is treated as integer |
233 | * and printed in standard decimal format (only significant |
236 | * and printed in standard decimal format (only significant |
234 | * digits). |
237 | * digits). |
235 | * x The next variant argument is treated as integer |
238 | * x The next variant argument is treated as integer |
236 | * and printed in standard hexadecimal format (only significant |
239 | * and printed in standard hexadecimal format (only significant |
237 | * digits). |
240 | * digits). |
238 | * X As with 'x', but '0x' is prefixed. |
241 | * X As with 'x', but '0x' is prefixed. |
- | 242 | * . The decimal number following period will be treated as precision |
|
- | 243 | * for printing floating point numbers. One of 'e', 'E', 'f' or 'F' |
|
- | 244 | * must follow. |
|
- | 245 | * e The next variant argument is treated as double precision float |
|
- | 246 | * and printed in exponent notation with only one digit before decimal point |
|
- | 247 | * in specified precision. The exponent sign is printed as 'e'. |
|
- | 248 | * E As with 'e', but the exponent sign is printed as 'E'. |
|
- | 249 | * f The next variant argument is treated as double precision float |
|
- | 250 | * and printed in decimal notation in specified precision. |
|
- | 251 | * F As with 'f'. |
|
239 | * |
252 | * |
240 | * All other characters from fmt except the formatting directives |
253 | * All other characters from fmt except the formatting directives |
241 | * are printed in verbatim. |
254 | * are printed in verbatim. |
242 | * |
255 | * |
243 | * @param fmt Formatting NULL terminated string. |
256 | * @param fmt Formatting NULL terminated string. |
244 | * |
257 | * |
245 | */ |
258 | */ |
246 | void printf(const char *fmt, ...) |
259 | void printf(const char *fmt, ...) |
247 | { |
260 | { |
248 | int irqpri, i = 0; |
261 | int irqpri, i = 0; |
249 | va_list ap; |
262 | va_list ap; |
250 | char c; |
263 | char c; |
251 | 264 | ||
252 | __u16 precision; |
265 | __u16 precision; |
253 | 266 | ||
254 | va_start(ap, fmt); |
267 | va_start(ap, fmt); |
255 | 268 | ||
256 | irqpri = cpu_priority_high(); |
269 | irqpri = cpu_priority_high(); |
257 | spinlock_lock(&printflock); |
270 | spinlock_lock(&printflock); |
258 | 271 | ||
259 | while (c = fmt[i++]) { |
272 | while (c = fmt[i++]) { |
260 | switch (c) { |
273 | switch (c) { |
261 | 274 | ||
262 | - | ||
263 | - | ||
264 | /* control character */ |
275 | /* control character */ |
265 | case '%': |
276 | case '%': |
266 | - | ||
267 | precision = DEFAULT_DOUBLE_PRECISION; |
277 | precision = DEFAULT_DOUBLE_PRECISION; |
268 | if (fmt[i]=='.') { |
278 | if (fmt[i]=='.') { |
269 | precision=0; |
279 | precision=0; |
- | 280 | c=fmt[++i]; |
|
- | 281 | while((c>='0')&&(c<='9')) { |
|
- | 282 | precision = precision*10 + c - '0'; |
|
270 | c=fmt[++i]; |
283 | c=fmt[++i]; |
271 | while((c>='0')&&(c<='9')) { |
- | |
272 | precision = precision*10 + c - '0'; |
- | |
273 | c=fmt[++i]; |
- | |
274 | } |
- | |
275 | - | ||
276 | } |
284 | } |
- | 285 | } |
|
277 | 286 | ||
278 | switch (c = fmt[i++]) { |
287 | switch (c = fmt[i++]) { |
279 | 288 | ||
280 | /* percentile itself */ |
289 | /* percentile itself */ |
281 | case '%': |
290 | case '%': |
282 | break; |
291 | break; |
283 | 292 | ||
284 | /* |
293 | /* |
285 | * String and character conversions. |
294 | * String and character conversions. |
286 | */ |
295 | */ |
287 | case 's': |
296 | case 's': |
288 | print_str(va_arg(ap, char_ptr)); |
297 | print_str(va_arg(ap, char_ptr)); |
289 | goto loop; |
298 | goto loop; |
290 | 299 | ||
291 | case 'c': |
300 | case 'c': |
292 | c = (char) va_arg(ap, int); |
301 | c = (char) va_arg(ap, int); |
293 | break; |
302 | break; |
294 | 303 | ||
295 | /* |
304 | /* |
296 | * Hexadecimal conversions with fixed width. |
305 | * Hexadecimal conversions with fixed width. |
297 | */ |
306 | */ |
298 | case 'P': |
307 | case 'P': |
299 | print_str("0x"); |
308 | print_str("0x"); |
300 | case 'p': |
309 | case 'p': |
301 | print_fixed_hex(va_arg(ap, __native), sizeof(__native)); |
310 | print_fixed_hex(va_arg(ap, __native), sizeof(__native)); |
302 | goto loop; |
311 | goto loop; |
303 | 312 | ||
304 | case 'Q': |
313 | case 'Q': |
305 | print_str("0x"); |
314 | print_str("0x"); |
306 | case 'q': |
315 | case 'q': |
307 | print_fixed_hex(va_arg(ap, __u64), INT64); |
316 | print_fixed_hex(va_arg(ap, __u64), INT64); |
308 | goto loop; |
317 | goto loop; |
309 | 318 | ||
310 | case 'L': |
319 | case 'L': |
311 | print_str("0x"); |
320 | print_str("0x"); |
312 | case 'l': |
321 | case 'l': |
313 | print_fixed_hex(va_arg(ap, __native), INT32); |
322 | print_fixed_hex(va_arg(ap, __native), INT32); |
314 | goto loop; |
323 | goto loop; |
315 | 324 | ||
316 | case 'W': |
325 | case 'W': |
317 | print_str("0x"); |
326 | print_str("0x"); |
318 | case 'w': |
327 | case 'w': |
319 | print_fixed_hex(va_arg(ap, __native), INT16); |
328 | print_fixed_hex(va_arg(ap, __native), INT16); |
320 | goto loop; |
329 | goto loop; |
321 | 330 | ||
322 | case 'B': |
331 | case 'B': |
323 | print_str("0x"); |
332 | print_str("0x"); |
324 | case 'b': |
333 | case 'b': |
325 | print_fixed_hex(va_arg(ap, __native), INT8); |
334 | print_fixed_hex(va_arg(ap, __native), INT8); |
326 | goto loop; |
335 | goto loop; |
327 | 336 | ||
328 | /* |
337 | /* |
329 | * Floating point conversions. |
338 | * Floating point conversions. |
330 | */ |
339 | */ |
331 | - | ||
332 | case 'F': |
340 | case 'F': |
333 | print_double(va_arg(ap, double),'F',precision); |
341 | print_double(va_arg(ap, double),'F',precision); |
334 | goto loop; |
342 | goto loop; |
335 | 343 | ||
336 | case 'f': |
344 | case 'f': |
337 | print_double(va_arg(ap, double),'f',precision); |
345 | print_double(va_arg(ap, double),'f',precision); |
338 | goto loop; |
346 | goto loop; |
339 | 347 | ||
340 | case 'E': |
348 | case 'E': |
341 | print_double(va_arg(ap, double),'E',precision); |
349 | print_double(va_arg(ap, double),'E',precision); |
342 | goto loop; |
350 | goto loop; |
343 | case 'e': |
351 | case 'e': |
344 | print_double(va_arg(ap, double),'e',precision); |
352 | print_double(va_arg(ap, double),'e',precision); |
345 | goto loop; |
353 | goto loop; |
346 | 354 | ||
347 | /* |
355 | /* |
348 | * Decimal and hexadecimal conversions. |
356 | * Decimal and hexadecimal conversions. |
349 | */ |
357 | */ |
350 | case 'd': |
358 | case 'd': |
351 | print_number(va_arg(ap, __native), 10); |
359 | print_number(va_arg(ap, __native), 10); |
352 | goto loop; |
360 | goto loop; |
353 | 361 | ||
354 | case 'X': |
362 | case 'X': |
355 | print_str("0x"); |
363 | print_str("0x"); |
356 | case 'x': |
364 | case 'x': |
357 | print_number(va_arg(ap, __native), 16); |
365 | print_number(va_arg(ap, __native), 16); |
358 | goto loop; |
366 | goto loop; |
359 | 367 | ||
360 | /* |
368 | /* |
361 | * Bad formatting. |
369 | * Bad formatting. |
362 | */ |
370 | */ |
363 | default: |
371 | default: |
364 | goto out; |
372 | goto out; |
365 | } |
373 | } |
366 | 374 | ||
367 | default: putchar(c); |
375 | default: putchar(c); |
368 | } |
376 | } |
369 | 377 | ||
370 | loop: |
378 | loop: |
371 | ; |
379 | ; |
372 | } |
380 | } |
373 | 381 | ||
374 | out: |
382 | out: |
375 | spinlock_unlock(&printflock); |
383 | spinlock_unlock(&printflock); |
376 | cpu_priority_restore(irqpri); |
384 | cpu_priority_restore(irqpri); |
377 | 385 | ||
378 | va_end(ap); |
386 | va_end(ap); |
379 | } |
387 | } |
380 | 388 |