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