Rev 228 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 228 | Rev 264 | ||
---|---|---|---|
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, __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 | if (fmath_is_nan(num)) { |
53 | if (fmath_is_nan(num)) { |
53 | print_str("NaN"); |
54 | print_str("NaN"); |
54 | return; |
55 | return; |
55 | } |
56 | } |
56 | */ |
57 | */ |
57 | 58 | ||
58 | if (fmath_is_negative(num)) { |
59 | if (fmath_is_negative(num)) { |
59 | putchar('-'); |
60 | putchar('-'); |
60 | } |
61 | } |
61 | 62 | ||
62 | num=fmath_abs(num); |
63 | num=fmath_abs(num); |
63 | 64 | ||
- | 65 | if ((modifier=='E')||(modifier=='e')) { |
|
- | 66 | intval2=fmath_fint(fmath_get_decimal_exponent(num),&intval); |
|
- | 67 | exponent=intval; |
|
- | 68 | if ((intval2<0.0)&&(exponent<0)) exponent--; |
|
- | 69 | num = num / ((fmath_dpow(10.0,exponent))); |
|
- | 70 | ||
- | 71 | print_double(num,modifier+1,precision); //modifier+1 = E => F or e => f |
|
- | 72 | putchar(modifier); |
|
- | 73 | if (exponent<0) { |
|
- | 74 | putchar('-'); |
|
- | 75 | exponent*=-1; |
|
- | 76 | } |
|
- | 77 | print_number(exponent,10); |
|
- | 78 | return; |
|
- | 79 | } |
|
- | 80 | ||
- | 81 | ||
64 | /* |
82 | /* |
65 | if (fmath_is_infinity(num)) { |
83 | if (fmath_is_infinity(num)) { |
66 | print_str("Inf"); |
84 | print_str("Inf"); |
67 | } |
85 | } |
68 | */ |
86 | */ |
69 | //TODO: rounding constant - when we got fraction >= 0.5, we must increment last printed number |
87 | //TODO: rounding constant - when we got fraction >= 0.5, we must increment last printed number |
70 | 88 | ||
71 | /* Here is problem with cumulative error while printing big double values -> we will divide |
89 | /* Here is problem with cumulative error while printing big double values -> we will divide |
72 | the number with a power of 10, print new number with better method for small numbers and then print decimal point at correct position */ |
90 | the number with a power of 10, print new number with better method for small numbers and then print decimal point at correct position */ |
73 | 91 | ||
74 | fmath_fint(fmath_get_decimal_exponent(num),&intval); |
92 | fmath_fint(fmath_get_decimal_exponent(num),&intval); |
75 | 93 | ||
76 | exponent=(intval>0.0?intval:0); |
94 | exponent=(intval>0.0?intval:0); |
77 | 95 | ||
78 | precision+=exponent; |
96 | precision+=exponent; |
79 | 97 | ||
80 | if (exponent>0) num = num / ((fmath_dpow(10.0,exponent))); |
98 | if (exponent>0) num = num / ((fmath_dpow(10.0,exponent))); |
81 | 99 | ||
82 | num=fmath_fint(num,&intval); |
100 | num=fmath_fint(num,&intval); |
83 | 101 | ||
84 | if (precision>0) { |
102 | if (precision>0) { |
85 | counter=precision-1; |
103 | counter=precision-1; |
86 | if (exponent>0) counter++; |
104 | if (exponent>0) counter++; |
87 | 105 | ||
88 | if (counter>=DEFAULT_DOUBLE_BUFFER_SIZE) { |
106 | if (counter>=DEFAULT_DOUBLE_BUFFER_SIZE) { |
89 | counter=DEFAULT_DOUBLE_BUFFER_SIZE; |
107 | counter=DEFAULT_DOUBLE_BUFFER_SIZE; |
90 | } |
108 | } |
91 | exponenttmp=exponent; |
109 | exponenttmp=exponent; |
92 | while(counter>=0) { |
110 | while(counter>=0) { |
93 | num *= 10.0; |
111 | num *= 10.0; |
94 | num = fmath_fint(num,&intval2); |
112 | num = fmath_fint(num,&intval2); |
95 | buf[counter--]=((int)intval2)+'0'; |
113 | buf[counter--]=((int)intval2)+'0'; |
96 | exponenttmp--; |
114 | exponenttmp--; |
97 | if ((exponenttmp==0)&&(counter>=0)) buf[counter--]='.'; |
115 | if ((exponenttmp==0)&&(counter>=0)) buf[counter--]='.'; |
98 | } |
116 | } |
99 | counter=precision; |
117 | counter=precision; |
100 | if ((exponent==0)&&(counter<DEFAULT_DOUBLE_BUFFER_SIZE)) buf[counter]='.'; |
118 | if ((exponent==0)&&(counter<DEFAULT_DOUBLE_BUFFER_SIZE)) buf[counter]='.'; |
101 | counter++; |
119 | counter++; |
102 | } else { |
120 | } else { |
103 | counter=0; |
121 | counter=0; |
104 | } |
122 | } |
105 | 123 | ||
106 | if (intval==0.0) { |
124 | if (intval==0.0) { |
107 | if (counter<DEFAULT_DOUBLE_BUFFER_SIZE) buf[counter++]='0'; |
125 | if (counter<DEFAULT_DOUBLE_BUFFER_SIZE) buf[counter++]='0'; |
108 | } else { |
126 | } else { |
109 | in1=intval; |
127 | in1=intval; |
110 | while(( in1>0 )&&(counter<DEFAULT_DOUBLE_BUFFER_SIZE)) { |
128 | while(( in1>0 )&&(counter<DEFAULT_DOUBLE_BUFFER_SIZE)) { |
111 | 129 | ||
112 | in2=in1; |
130 | in2=in1; |
113 | in1/=10; |
131 | in1/=10; |
114 | buf[counter]=in2-in1*10 + '0'; |
132 | buf[counter]=in2-in1*10 + '0'; |
115 | counter++; |
133 | counter++; |
116 | } |
134 | } |
117 | } |
135 | } |
118 | 136 | ||
119 | counter = (counter>=DEFAULT_DOUBLE_BUFFER_SIZE?DEFAULT_DOUBLE_BUFFER_SIZE:counter); |
137 | counter = (counter>=DEFAULT_DOUBLE_BUFFER_SIZE?DEFAULT_DOUBLE_BUFFER_SIZE:counter); |
120 | while (counter>0) { |
138 | while (counter>0) { |
121 | putchar(buf[--counter]); |
139 | putchar(buf[--counter]); |
122 | }; |
140 | }; |
123 | return; |
141 | return; |
124 | } |
142 | } |
125 | 143 | ||
126 | /** Print NULL terminated string |
144 | /** Print NULL terminated string |
127 | * |
145 | * |
128 | * Print characters from str using putchar() until |
146 | * Print characters from str using putchar() until |
129 | * \x00 character is reached. |
147 | * \x00 character is reached. |
130 | * |
148 | * |
131 | * @param str Characters to print. |
149 | * @param str Characters to print. |
132 | * |
150 | * |
133 | */ |
151 | */ |
134 | void print_str(const char *str) |
152 | void print_str(const char *str) |
135 | { |
153 | { |
136 | int i = 0; |
154 | int i = 0; |
137 | char c; |
155 | char c; |
138 | 156 | ||
139 | while (c = str[i++]) |
157 | while (c = str[i++]) |
140 | putchar(c); |
158 | putchar(c); |
141 | } |
159 | } |
142 | 160 | ||
143 | 161 | ||
144 | /** Print hexadecimal digits |
162 | /** Print hexadecimal digits |
145 | * |
163 | * |
146 | * Print fixed count of hexadecimal digits from |
164 | * Print fixed count of hexadecimal digits from |
147 | * the number num. The digits are printed in |
165 | * the number num. The digits are printed in |
148 | * natural left-to-right order starting with |
166 | * natural left-to-right order starting with |
149 | * the width-th digit. |
167 | * the width-th digit. |
150 | * |
168 | * |
151 | * @param num Number containing digits. |
169 | * @param num Number containing digits. |
152 | * @param width Count of digits to print. |
170 | * @param width Count of digits to print. |
153 | * |
171 | * |
154 | */ |
172 | */ |
155 | void print_fixed_hex(const __u64 num, const int width) |
173 | void print_fixed_hex(const __u64 num, const int width) |
156 | { |
174 | { |
157 | int i; |
175 | int i; |
158 | 176 | ||
159 | for (i = width*8 - 4; i >= 0; i -= 4) |
177 | for (i = width*8 - 4; i >= 0; i -= 4) |
160 | putchar(digits[(num>>i) & 0xf]); |
178 | putchar(digits[(num>>i) & 0xf]); |
161 | } |
179 | } |
162 | 180 | ||
163 | 181 | ||
164 | /** Print number in given base |
182 | /** Print number in given base |
165 | * |
183 | * |
166 | * Print significant digits of a number in given |
184 | * Print significant digits of a number in given |
167 | * base. |
185 | * base. |
168 | * |
186 | * |
169 | * @param num Number to print. |
187 | * @param num Number to print. |
170 | * @param base Base to print the number in (should |
188 | * @param base Base to print the number in (should |
171 | * be in range 2 .. 16). |
189 | * be in range 2 .. 16). |
172 | * |
190 | * |
173 | */ |
191 | */ |
174 | void print_number(const __native num, const unsigned int base) |
192 | void print_number(const __native num, const unsigned int base) |
175 | { |
193 | { |
176 | int val = num; |
194 | int val = num; |
177 | char d[sizeof(__native)*8+1]; /* this is good enough even for base == 2 */ |
195 | char d[sizeof(__native)*8+1]; /* this is good enough even for base == 2 */ |
178 | int i = sizeof(__native)*8-1; |
196 | int i = sizeof(__native)*8-1; |
179 | 197 | ||
180 | do { |
198 | do { |
181 | d[i--] = digits[val % base]; |
199 | d[i--] = digits[val % base]; |
182 | } while (val /= base); |
200 | } while (val /= base); |
183 | 201 | ||
184 | d[sizeof(__native)*8] = 0; |
202 | d[sizeof(__native)*8] = 0; |
185 | print_str(&d[i + 1]); |
203 | print_str(&d[i + 1]); |
186 | } |
204 | } |
187 | 205 | ||
188 | 206 | ||
189 | /** General formatted text print |
207 | /** General formatted text print |
190 | * |
208 | * |
191 | * Print text formatted according the fmt parameter |
209 | * Print text formatted according the fmt parameter |
192 | * and variant arguments. Each formatting directive |
210 | * and variant arguments. Each formatting directive |
193 | * begins with % (percentage) character and one of the |
211 | * begins with % (percentage) character and one of the |
194 | * following character: |
212 | * following character: |
195 | * |
213 | * |
196 | * % Prints the percentage character. |
214 | * % Prints the percentage character. |
197 | * s The next variant argument is treated as char* |
215 | * s The next variant argument is treated as char* |
198 | * and printed as a NULL terminated string. |
216 | * and printed as a NULL terminated string. |
199 | * c The next variant argument is treated as a single char. |
217 | * c The next variant argument is treated as a single char. |
200 | * p The next variant argument is treated as a maximum |
218 | * p The next variant argument is treated as a maximum |
201 | * bit-width integer with respect to architecture |
219 | * bit-width integer with respect to architecture |
202 | * and printed in full hexadecimal width. |
220 | * and printed in full hexadecimal width. |
203 | * P As with 'p', but '0x' is prefixed. |
221 | * P As with 'p', but '0x' is prefixed. |
204 | * q The next variant argument is treated as a 64b integer |
222 | * q The next variant argument is treated as a 64b integer |
205 | * and printed in full hexadecimal width. |
223 | * and printed in full hexadecimal width. |
206 | * Q As with 'q', but '0x' is prefixed. |
224 | * Q As with 'q', but '0x' is prefixed. |
207 | * l The next variant argument is treated as a 32b integer |
225 | * l The next variant argument is treated as a 32b integer |
208 | * and printed in full hexadecimal width. |
226 | * and printed in full hexadecimal width. |
209 | * L As with 'l', but '0x' is prefixed. |
227 | * L As with 'l', but '0x' is prefixed. |
210 | * w The next variant argument is treated as a 16b integer |
228 | * w The next variant argument is treated as a 16b integer |
211 | * and printed in full hexadecimal width. |
229 | * and printed in full hexadecimal width. |
212 | * W As with 'w', but '0x' is prefixed. |
230 | * W As with 'w', but '0x' is prefixed. |
213 | * b The next variant argument is treated as a 8b integer |
231 | * b The next variant argument is treated as a 8b integer |
214 | * and printed in full hexadecimal width. |
232 | * and printed in full hexadecimal width. |
215 | * N As with 'b', but '0x' is prefixed. |
233 | * N As with 'b', but '0x' is prefixed. |
216 | * d The next variant argument is treated as integer |
234 | * d The next variant argument is treated as integer |
217 | * and printed in standard decimal format (only significant |
235 | * and printed in standard decimal format (only significant |
218 | * digits). |
236 | * digits). |
219 | * x The next variant argument is treated as integer |
237 | * x The next variant argument is treated as integer |
220 | * and printed in standard hexadecimal format (only significant |
238 | * and printed in standard hexadecimal format (only significant |
221 | * digits). |
239 | * digits). |
222 | * X As with 'x', but '0x' is prefixed. |
240 | * X As with 'x', but '0x' is prefixed. |
223 | * |
241 | * |
224 | * All other characters from fmt except the formatting directives |
242 | * All other characters from fmt except the formatting directives |
225 | * are printed in verbatim. |
243 | * are printed in verbatim. |
226 | * |
244 | * |
227 | * @param fmt Formatting NULL terminated string. |
245 | * @param fmt Formatting NULL terminated string. |
228 | * |
246 | * |
229 | */ |
247 | */ |
230 | void printf(const char *fmt, ...) |
248 | void printf(const char *fmt, ...) |
231 | { |
249 | { |
232 | int irqpri, i = 0; |
250 | int irqpri, i = 0; |
233 | va_list ap; |
251 | va_list ap; |
234 | char c; |
252 | char c; |
- | 253 | ||
- | 254 | __u16 precision; |
|
235 | 255 | ||
236 | va_start(ap, fmt); |
256 | va_start(ap, fmt); |
237 | 257 | ||
238 | irqpri = cpu_priority_high(); |
258 | irqpri = cpu_priority_high(); |
239 | spinlock_lock(&printflock); |
259 | spinlock_lock(&printflock); |
240 | 260 | ||
241 | while (c = fmt[i++]) { |
261 | while (c = fmt[i++]) { |
242 | switch (c) { |
262 | switch (c) { |
243 | 263 | ||
- | 264 | ||
- | 265 | ||
244 | /* control character */ |
266 | /* control character */ |
245 | case '%': |
267 | case '%': |
- | 268 | ||
- | 269 | precision = DEFAULT_DOUBLE_PRECISION; |
|
- | 270 | if (fmt[i]=='.') { |
|
- | 271 | precision=0; |
|
- | 272 | c=fmt[++i]; |
|
- | 273 | while((c>='0')&&(c<='9')) { |
|
- | 274 | precision = precision*10 + c - '0'; |
|
- | 275 | c=fmt[++i]; |
|
- | 276 | } |
|
- | 277 | ||
- | 278 | } |
|
- | 279 | ||
246 | switch (c = fmt[i++]) { |
280 | switch (c = fmt[i++]) { |
247 | 281 | ||
248 | /* percentile itself */ |
282 | /* percentile itself */ |
249 | case '%': |
283 | case '%': |
250 | break; |
284 | break; |
251 | 285 | ||
252 | /* |
286 | /* |
253 | * String and character conversions. |
287 | * String and character conversions. |
254 | */ |
288 | */ |
255 | case 's': |
289 | case 's': |
256 | print_str(va_arg(ap, char_ptr)); |
290 | print_str(va_arg(ap, char_ptr)); |
257 | goto loop; |
291 | goto loop; |
258 | 292 | ||
259 | case 'c': |
293 | case 'c': |
260 | c = (char) va_arg(ap, int); |
294 | c = (char) va_arg(ap, int); |
261 | break; |
295 | break; |
262 | 296 | ||
263 | /* |
297 | /* |
264 | * Hexadecimal conversions with fixed width. |
298 | * Hexadecimal conversions with fixed width. |
265 | */ |
299 | */ |
266 | case 'P': |
300 | case 'P': |
267 | print_str("0x"); |
301 | print_str("0x"); |
268 | case 'p': |
302 | case 'p': |
269 | print_fixed_hex(va_arg(ap, __native), sizeof(__native)); |
303 | print_fixed_hex(va_arg(ap, __native), sizeof(__native)); |
270 | goto loop; |
304 | goto loop; |
271 | 305 | ||
272 | case 'Q': |
306 | case 'Q': |
273 | print_str("0x"); |
307 | print_str("0x"); |
274 | case 'q': |
308 | case 'q': |
275 | print_fixed_hex(va_arg(ap, __u64), INT64); |
309 | print_fixed_hex(va_arg(ap, __u64), INT64); |
276 | goto loop; |
310 | goto loop; |
277 | 311 | ||
278 | case 'L': |
312 | case 'L': |
279 | print_str("0x"); |
313 | print_str("0x"); |
280 | case 'l': |
314 | case 'l': |
281 | print_fixed_hex(va_arg(ap, __native), INT32); |
315 | print_fixed_hex(va_arg(ap, __native), INT32); |
282 | goto loop; |
316 | goto loop; |
283 | 317 | ||
284 | case 'W': |
318 | case 'W': |
285 | print_str("0x"); |
319 | print_str("0x"); |
286 | case 'w': |
320 | case 'w': |
287 | print_fixed_hex(va_arg(ap, __native), INT16); |
321 | print_fixed_hex(va_arg(ap, __native), INT16); |
288 | goto loop; |
322 | goto loop; |
289 | 323 | ||
290 | case 'B': |
324 | case 'B': |
291 | print_str("0x"); |
325 | print_str("0x"); |
292 | case 'b': |
326 | case 'b': |
293 | print_fixed_hex(va_arg(ap, __native), INT8); |
327 | print_fixed_hex(va_arg(ap, __native), INT8); |
294 | goto loop; |
328 | goto loop; |
295 | 329 | ||
296 | /* |
330 | /* |
297 | * Floating point conversions. |
331 | * Floating point conversions. |
298 | */ |
332 | */ |
299 | 333 | ||
300 | case 'F': |
334 | case 'F': |
- | 335 | print_double(va_arg(ap, double),'F',precision); |
|
- | 336 | goto loop; |
|
- | 337 | ||
301 | case 'f': |
338 | case 'f': |
302 | print_double(va_arg(ap, double),DEFAULT_DOUBLE_PRECISION); |
339 | print_double(va_arg(ap, double),'f',precision); |
303 | goto loop; |
340 | goto loop; |
- | 341 | ||
- | 342 | case 'E': |
|
- | 343 | print_double(va_arg(ap, double),'E',precision); |
|
- | 344 | goto loop; |
|
- | 345 | case 'e': |
|
- | 346 | print_double(va_arg(ap, double),'e',precision); |
|
- | 347 | goto loop; |
|
- | 348 | ||
304 | /* |
349 | /* |
305 | * Decimal and hexadecimal conversions. |
350 | * Decimal and hexadecimal conversions. |
306 | */ |
351 | */ |
307 | case 'd': |
352 | case 'd': |
308 | print_number(va_arg(ap, __native), 10); |
353 | print_number(va_arg(ap, __native), 10); |
309 | goto loop; |
354 | goto loop; |
310 | 355 | ||
311 | case 'X': |
356 | case 'X': |
312 | print_str("0x"); |
357 | print_str("0x"); |
313 | case 'x': |
358 | case 'x': |
314 | print_number(va_arg(ap, __native), 16); |
359 | print_number(va_arg(ap, __native), 16); |
315 | goto loop; |
360 | goto loop; |
316 | 361 | ||
317 | /* |
362 | /* |
318 | * Bad formatting. |
363 | * Bad formatting. |
319 | */ |
364 | */ |
320 | default: |
365 | default: |
321 | goto out; |
366 | goto out; |
322 | } |
367 | } |
323 | 368 | ||
324 | default: putchar(c); |
369 | default: putchar(c); |
325 | } |
370 | } |
326 | 371 | ||
327 | loop: |
372 | loop: |
328 | ; |
373 | ; |
329 | } |
374 | } |
330 | 375 | ||
331 | out: |
376 | out: |
332 | spinlock_unlock(&printflock); |
377 | spinlock_unlock(&printflock); |
333 | cpu_priority_restore(irqpri); |
378 | cpu_priority_restore(irqpri); |
334 | 379 | ||
335 | va_end(ap); |
380 | va_end(ap); |
336 | } |
381 | } |
337 | 382 |