Rev 885 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 885 | Rev 953 | ||
---|---|---|---|
Line 30... | Line 30... | ||
30 | #include "ofw.h" |
30 | #include "ofw.h" |
31 | 31 | ||
32 | static char digits[] = "0123456789abcdef"; /**< Hexadecimal characters */ |
32 | static char digits[] = "0123456789abcdef"; /**< Hexadecimal characters */ |
33 | 33 | ||
34 | 34 | ||
- | 35 | void puts(const char *str) |
|
- | 36 | { |
|
- | 37 | int len = 0; |
|
- | 38 | ||
- | 39 | while (str[len] != 0) |
|
- | 40 | len++; |
|
- | 41 | ||
- | 42 | ofw_write(str, len); |
|
- | 43 | } |
|
- | 44 | ||
- | 45 | ||
35 | /** Print hexadecimal digits |
46 | /** Print hexadecimal digits |
36 | * |
47 | * |
37 | * Print fixed count of hexadecimal digits from |
48 | * Print fixed count of hexadecimal digits from |
38 | * the number num. The digits are printed in |
49 | * the number num. The digits are printed in |
39 | * natural left-to-right order starting with |
50 | * natural left-to-right order starting with |
Line 71... | Line 82... | ||
71 | do { |
82 | do { |
72 | d[i--] = digits[val % base]; |
83 | d[i--] = digits[val % base]; |
73 | } while (val /= base); |
84 | } while (val /= base); |
74 | 85 | ||
75 | d[sizeof(__native) * 8] = 0; |
86 | d[sizeof(__native) * 8] = 0; |
76 | ofw_puts(&d[i + 1]); |
87 | puts(&d[i + 1]); |
77 | } |
88 | } |
78 | 89 | ||
79 | 90 | ||
80 | /** General formatted text print |
91 | /** General formatted text print |
81 | * |
92 | * |
Line 154... | Line 165... | ||
154 | 165 | ||
155 | /* |
166 | /* |
156 | * String and character conversions. |
167 | * String and character conversions. |
157 | */ |
168 | */ |
158 | case 's': |
169 | case 's': |
159 | ofw_puts(va_arg(ap, char_ptr)); |
170 | puts(va_arg(ap, char_ptr)); |
160 | goto loop; |
171 | goto loop; |
161 | 172 | ||
162 | case 'c': |
173 | case 'c': |
163 | c = (char) va_arg(ap, int); |
174 | c = (char) va_arg(ap, int); |
164 | break; |
175 | break; |
165 | 176 | ||
166 | /* |
177 | /* |
167 | * Hexadecimal conversions with fixed width. |
178 | * Hexadecimal conversions with fixed width. |
168 | */ |
179 | */ |
169 | case 'P': |
180 | case 'P': |
170 | ofw_puts("0x"); |
181 | puts("0x"); |
171 | case 'p': |
182 | case 'p': |
172 | print_fixed_hex(va_arg(ap, __native), sizeof(__native)); |
183 | print_fixed_hex(va_arg(ap, __native), sizeof(__native)); |
173 | goto loop; |
184 | goto loop; |
174 | 185 | ||
175 | case 'Q': |
186 | case 'Q': |
176 | ofw_puts("0x"); |
187 | puts("0x"); |
177 | case 'q': |
188 | case 'q': |
178 | print_fixed_hex(va_arg(ap, __u64), INT64); |
189 | print_fixed_hex(va_arg(ap, __u64), INT64); |
179 | goto loop; |
190 | goto loop; |
180 | 191 | ||
181 | case 'L': |
192 | case 'L': |
182 | ofw_puts("0x"); |
193 | puts("0x"); |
183 | case 'l': |
194 | case 'l': |
184 | print_fixed_hex(va_arg(ap, __native), INT32); |
195 | print_fixed_hex(va_arg(ap, __native), INT32); |
185 | goto loop; |
196 | goto loop; |
186 | 197 | ||
187 | case 'W': |
198 | case 'W': |
188 | ofw_puts("0x"); |
199 | puts("0x"); |
189 | case 'w': |
200 | case 'w': |
190 | print_fixed_hex(va_arg(ap, __native), INT16); |
201 | print_fixed_hex(va_arg(ap, __native), INT16); |
191 | goto loop; |
202 | goto loop; |
192 | 203 | ||
193 | case 'B': |
204 | case 'B': |
194 | ofw_puts("0x"); |
205 | puts("0x"); |
195 | case 'b': |
206 | case 'b': |
196 | print_fixed_hex(va_arg(ap, __native), INT8); |
207 | print_fixed_hex(va_arg(ap, __native), INT8); |
197 | goto loop; |
208 | goto loop; |
198 | 209 | ||
199 | /* |
210 | /* |
Line 202... | Line 213... | ||
202 | case 'd': |
213 | case 'd': |
203 | print_number(va_arg(ap, __native), 10); |
214 | print_number(va_arg(ap, __native), 10); |
204 | goto loop; |
215 | goto loop; |
205 | 216 | ||
206 | case 'X': |
217 | case 'X': |
207 | ofw_puts("0x"); |
218 | puts("0x"); |
208 | case 'x': |
219 | case 'x': |
209 | print_number(va_arg(ap, __native), 16); |
220 | print_number(va_arg(ap, __native), 16); |
210 | goto loop; |
221 | goto loop; |
211 | 222 | ||
212 | /* |
223 | /* |