This source file includes following definitions.
- prom_printf
1
2
3
4
5
6
7
8
9
10 #include <stdarg.h>
11
12 #include <asm/openprom.h>
13 #include <asm/oplib.h>
14
15 char hexstring[] = "0123456789abcdef";
16
17 void
18 prom_printf(char *fmt, ...)
19 {
20 va_list args;
21 unsigned int ui_val;
22 int i_val, n_ctr;
23 char c_val;
24 char nstr_buf[32];
25 char *s_val;
26
27 va_start(args, fmt);
28 while(*fmt) {
29 if(*fmt != '%') {
30 if(*fmt == '\n')
31 prom_putchar('\r');
32 prom_putchar(*fmt++);
33 continue;
34 }
35
36 fmt++;
37 if(!*fmt) break;
38 n_ctr = 0;
39 switch(*fmt) {
40 case 'c':
41 c_val = va_arg(args, char);
42 if(c_val == '\n')
43 prom_putchar('\r');
44 prom_putchar(c_val);
45 fmt++;
46 break;
47 case 's':
48 s_val = va_arg(args, char *);
49 while(*s_val != 0) {
50 prom_putchar(*s_val);
51 s_val++;
52 }
53 fmt++;
54 break;
55 case 'd':
56
57 i_val = va_arg(args, int);
58 if(i_val==0x0)
59 prom_putchar('0');
60 else
61 while(i_val != 0x0) {
62 nstr_buf[n_ctr] = hexstring[i_val%0xa];
63 i_val = ((unsigned long)i_val) / (unsigned) 0xa;
64 n_ctr++;
65 };
66 while(--n_ctr >= 0)
67 prom_putchar(nstr_buf[n_ctr]);
68 fmt++;
69 break;
70 case 'x':
71
72 ui_val = va_arg(args, unsigned int);
73 if(ui_val==0x0)
74 prom_putchar('0');
75 else
76 while(ui_val != 0x0) {
77 nstr_buf[n_ctr] = hexstring[ui_val%0x10];
78 ui_val = ((unsigned long) ui_val) / (unsigned) 0x10;
79 n_ctr++;
80 };
81 while(--n_ctr >= 0)
82 prom_putchar(nstr_buf[n_ctr]);
83 fmt++;
84 break;
85 case 'o':
86
87 ui_val = va_arg(args, unsigned int);
88 if(ui_val==0x0)
89 prom_putchar('0');
90 else
91 while(ui_val != 0x0) {
92 nstr_buf[n_ctr] = hexstring[ui_val%0x8];
93 ui_val = ((unsigned long) ui_val) / (unsigned) 0x8;
94 };
95 while(--n_ctr >= 0)
96 prom_putchar(nstr_buf[n_ctr]);
97 fmt++;
98 break;
99 default:
100
101 fmt++;
102 break;
103 };
104 }
105
106
107 return;
108 }