1 /*
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Sony Corp. and Kazumasa Utashiro of Software Research Associates, Inc.
7 *
8 * %sccs.include.redist.c%
9 *
10 * from: $Hdr: vt100if.c,v 4.300 91/06/09 06:15:02 root Rel41 $ SONY
11 *
12 * @(#)vt100if.c 8.1 (Berkeley) 06/10/93
13 */
14
15 #ifdef IPC_MRX
16 #include "types.h"
17 #include "ioctl.h"
18 #else /* IPC_MRX */
19 #include <sys/types.h>
20 #ifdef CPU_SINGLE
21 #include <sys/param.h>
22 #endif /* CPU_SINGLE */
23 #include <sys/ioctl.h>
24 #endif /* IPC_MRX */
25
26 #if CPU_SINGLE
27 #include <news3400/sio/scc.h>
28 #include <news3400/sio/sccparam.h>
29 #endif /* CPU_SINGLE */
30
31 #ifdef IPC_MRX
32 #include "scc.h"
33 #include "sccparam.h"
34 #include "cio.h"
35 #define SCC_KEYBOARD 0
36 #undef MAX_CIO
37 #include "object.h"
38 #include "process.h"
39
40 #include "config.h"
41 #define kbd_ioctl(chan, cmd, argp) { \
42 if (kb_ioctl) \
43 (*kb_ioctl)(chan, cmd, argp); \
44 }
45 extern int bitmap_use;
46 #endif /* IPC_MRX */
47
48 #ifdef IPC_MRX
49 #include "../../iop/kbreg.h"
50 #include "../../iop/keyboard.h"
51 #ifdef IPC_3CPU
52 #include "../../ubdev/msgio.h"
53 extern int *gcpu_semadr;
54 #endif /* IPC_3CPU */
55 #else /* IPC_MRX */
56 #include <news3400/iop/keyboard.h>
57 #endif /* IPC_MRX */
58
59 #ifdef CPU_SINGLE
60 #include <machine/cpu.h>
61 #define PRE_EMPT need_resched()
62 #endif
63
64 int tmode;
65
66 static int char_mask = 0x7f;
67
68 int bm_todo;
69
vt100_write(chan,buf,count)70 vt100_write(chan, buf, count)
71 int chan;
72 register char *buf;
73 register int count;
74 {
75 bm_todo = count;
76
77 rst_dimmer_cnt();
78
79 #ifdef IPC_MRX
80 #ifdef IPC_3CPU
81 *gcpu_semadr = 1;
82 #endif
83 sem_wait(bitmap_use);
84 #endif
85
86 while (bm_todo-- > 0)
87 Putchar(*buf++ & char_mask, 0);
88 Putchar(0, 1);
89
90 #ifdef IPC_MRX
91 #ifdef IPC_3CPU
92 *gcpu_semadr = 0;
93 #endif
94 sem_signal(bitmap_use);
95 #endif
96 #ifdef CPU_SINGLE
97 PRE_EMPT;
98 #endif
99
100 return (count);
101 }
102
vt100_read(chan,buf,count)103 vt100_read(chan, buf, count)
104 int chan;
105 char *buf;
106 int count;
107 {
108 #ifdef IPC_MRX
109 if (kb_read) {
110 return ((*kb_read)(chan, buf, count));
111 } else {
112 return (-1);
113 }
114 #else /* IPC_MRX */
115 return (kbd_read(chan, buf, count));
116 #endif /* IPC_MRX */
117 }
118
119 #ifdef CPU_SINGLE
120 static int param;
121
bitmap_set_param(c)122 bitmap_set_param(c)
123 int c;
124 {
125 if ((c & CHAR_SIZE) == C7BIT) {
126 char_mask = 0x7f;
127 } else {
128 char_mask = 0xff;
129 }
130 #ifdef KM_JIS
131 switch (c & TERM_MODE) {
132 case CJIS:
133 tmode = KM_JIS;
134 break;
135 case CSJIS:
136 tmode = KM_SJIS;
137 break;
138 case CEUC:
139 tmode = KM_EUC;
140 break;
141 default:
142 tmode = KM_ASCII;
143 break;
144 }
145 #endif
146 param = c;
147 return (0);
148 }
149
bitmap_get_param()150 bitmap_get_param()
151 {
152 return(param);
153 }
154
155 #else /* CPU_SINGLE */
156
157 #ifdef IPC_MRX
158 #define SCC_SETPARAMS CIO_SETPARAMS
159 #define SCC_GETPARAMS CIO_GETPARAMS
160 #define SCC_LINE_CHG CIO_LINE_CHG
161 #define SCC_NREAD CIO_NREAD
162 #define SCC_FLUSH CIO_FLUSH
163 #define SCC_STOP CIO_STOP
164 #define SCC_START CIO_START
165 #define SCC_RESET CIO_RESET
166 #endif /* IPC_MRX */
167
vt100_ioctl(chan,cmd,argp)168 vt100_ioctl(chan, cmd, argp)
169 int chan, cmd, *argp;
170 {
171 static int param;
172
173 switch (cmd) {
174 case SCC_SETPARAMS:
175 param = *argp;
176 if ((param & CHAR_SIZE) == C7BIT)
177 char_mask = 0x7f;
178 else
179 char_mask = 0xff;
180 #ifdef KM_JIS
181 switch (param & TERM_MODE) {
182 case CJIS:
183 tmode = KM_JIS;
184 break;
185 case CSJIS:
186 tmode = KM_SJIS;
187 break;
188 case CEUC:
189 tmode = KM_EUC;
190 break;
191 default:
192 tmode = KM_ASCII;
193 break;
194 }
195 #endif
196 return (0);
197 case SCC_GETPARAMS:
198 *argp = param;
199 return (0);
200 case SCC_LINE_CHG:
201 return (0);
202 case SCC_NREAD:
203 kbd_ioctl(SCC_KEYBOARD, KIOCNREAD, argp);
204 return (0);
205 case SCC_FLUSH:
206 case SCC_STOP:
207 case SCC_START:
208 case SCC_RESET:
209 return (0);
210 default:
211 return (-1);
212 }
213 }
214 #endif /* CPU_SINGLE */
215