This source file includes following definitions.
- prom_nbgetchar
- prom_nbputchar
- prom_getchar
- prom_putchar
- prom_query_input_device
- prom_query_output_device
1
2
3
4
5
6
7
8 #include <asm/openprom.h>
9 #include <asm/oplib.h>
10 #include <linux/string.h>
11
12
13
14
15 int
16 prom_nbgetchar(void)
17 {
18 static char inc;
19
20 switch(prom_vers) {
21 case PROM_V0:
22 return (*(romvec->pv_nbgetchar))();
23 break;
24 case PROM_V2:
25 case PROM_V3:
26 case PROM_P1275:
27 if( (*(romvec->pv_v2devops).v2_dev_read)(*romvec->pv_v2bootargs.fd_stdin , &inc, 0x1) == 1)
28 return inc;
29 return -1;
30 break;
31 };
32 return 0;
33 }
34
35
36
37
38 int
39 prom_nbputchar(char c)
40 {
41 static char outc;
42
43 switch(prom_vers) {
44 case PROM_V0:
45 return (*(romvec->pv_nbputchar))(c);
46 break;
47 case PROM_V2:
48 case PROM_V3:
49 case PROM_P1275:
50 outc = c;
51 if( (*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout, &outc, 0x1) == 1)
52 return 0;
53 return -1;
54 break;
55 };
56 return 0;
57 }
58
59
60 char
61 prom_getchar(void)
62 {
63 int character;
64 while((character = prom_nbgetchar()) == -1) ;
65 return (char) character;
66 }
67
68
69 void
70 prom_putchar(char c)
71 {
72 while(prom_nbputchar(c) == -1) ;
73 return;
74 }
75
76
77 enum prom_input_device
78 prom_query_input_device()
79 {
80 int st_p;
81 char propb[64];
82 char *p;
83
84 switch(prom_vers) {
85 case PROM_V0:
86 case PROM_V2:
87 default:
88 switch(*romvec->pv_stdin) {
89 case PROMDEV_KBD: return PROMDEV_IKBD;
90 case PROMDEV_TTYA: return PROMDEV_ITTYA;
91 case PROMDEV_TTYB: return PROMDEV_ITTYB;
92 default:
93 return PROMDEV_I_UNK;
94 };
95 case PROM_V3:
96 case PROM_P1275:
97 st_p = (*romvec->pv_v2devops.v2_inst2pkg)(*romvec->pv_v2bootargs.fd_stdin);
98 if(prom_node_has_property(st_p, "keyboard"))
99 return PROMDEV_IKBD;
100 prom_getproperty(st_p, "device_type", propb, sizeof(propb));
101 if(strncmp(propb, "serial", sizeof("serial")))
102 return PROMDEV_I_UNK;
103 prom_getproperty(prom_root_node, "stdin-path", propb, sizeof(propb));
104 p = propb;
105 while(*p) p++; p -= 2;
106 if(p[0] == ':') {
107 if(p[1] == 'a')
108 return PROMDEV_ITTYA;
109 else if(p[1] == 'b')
110 return PROMDEV_ITTYB;
111 }
112 return PROMDEV_I_UNK;
113 };
114 }
115
116
117
118 enum prom_output_device
119 prom_query_output_device()
120 {
121 int st_p;
122 char propb[64];
123 char *p;
124 int propl;
125
126 switch(prom_vers) {
127 case PROM_V0:
128 switch(*romvec->pv_stdin) {
129 case PROMDEV_SCREEN: return PROMDEV_OSCREEN;
130 case PROMDEV_TTYA: return PROMDEV_OTTYA;
131 case PROMDEV_TTYB: return PROMDEV_OTTYB;
132 };
133 break;
134 case PROM_V2:
135 case PROM_V3:
136 case PROM_P1275:
137 st_p = (*romvec->pv_v2devops.v2_inst2pkg)(*romvec->pv_v2bootargs.fd_stdout);
138 propl = prom_getproperty(st_p, "device_type", propb, sizeof(propb));
139 if (propl >= 0 && propl == sizeof("display") &&
140 strncmp("display", propb, sizeof("display")) == 0)
141 {
142 return PROMDEV_OSCREEN;
143 }
144 if(prom_vers == PROM_V3) {
145 if(strncmp("serial", propb, sizeof("serial")))
146 return PROMDEV_O_UNK;
147 prom_getproperty(prom_root_node, "stdout-path", propb, sizeof(propb));
148 p = propb;
149 while(*p) p++; p -= 2;
150 if(p[0]==':') {
151 if(p[1] == 'a')
152 return PROMDEV_OTTYA;
153 else if(p[1] == 'b')
154 return PROMDEV_OTTYB;
155 }
156 return PROMDEV_O_UNK;
157 } else {
158
159 switch(*romvec->pv_stdin) {
160 case PROMDEV_TTYA: return PROMDEV_OTTYA;
161 case PROMDEV_TTYB: return PROMDEV_OTTYB;
162 };
163 }
164 break;
165 };
166 return PROMDEV_O_UNK;
167 }