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 switch(*romvec->pv_stdin) {
81 case PROMDEV_KBD: return PROMDEV_IKBD;
82 case PROMDEV_TTYA: return PROMDEV_ITTYA;
83 case PROMDEV_TTYB: return PROMDEV_ITTYB;
84 default:
85 return PROMDEV_I_UNK;
86 };
87 }
88
89
90
91 enum prom_output_device
92 prom_query_output_device()
93 {
94 int st_p;
95 char propb[ sizeof("display") ];
96 int propl;
97
98 switch(prom_vers) {
99 case PROM_V0:
100 switch(*romvec->pv_stdin) {
101 case PROMDEV_SCREEN: return PROMDEV_OSCREEN;
102 case PROMDEV_TTYA: return PROMDEV_OTTYA;
103 case PROMDEV_TTYB: return PROMDEV_OTTYB;
104 };
105 break;
106 case PROM_V2:
107 case PROM_V3:
108 case PROM_P1275:
109 st_p = (*romvec->pv_v2devops.v2_inst2pkg)(*romvec->pv_v2bootargs.fd_stdout);
110 propl = prom_getproperty(st_p, "device_type", propb, sizeof(propb));
111 if (propl >= 0 && propl == sizeof("display") &&
112 strncmp("display", propb, sizeof("display")) == 0)
113 {
114 return PROMDEV_OSCREEN;
115 }
116
117
118 switch(*romvec->pv_stdin) {
119 case PROMDEV_TTYA: return PROMDEV_OTTYA;
120 case PROMDEV_TTYB: return PROMDEV_OTTYB;
121 };
122 break;
123 };
124 return PROMDEV_O_UNK;
125 }