29 */ 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/consio.h> 34#include <sys/fcntl.h> 35#include <sys/file.h> 36#include <sys/filedesc.h> 37#include <sys/filio.h> 38#include <sys/ioctl_compat.h> 39#include <sys/kbio.h> 40#include <sys/lock.h> 41#include <sys/mutex.h> 42#include <sys/sysproto.h> 43#include <sys/tty.h> 44 45#include <i386/ibcs2/ibcs2_signal.h> 46#include <i386/ibcs2/ibcs2_socksys.h> 47#include <i386/ibcs2/ibcs2_stropts.h> 48#include <i386/ibcs2/ibcs2_proto.h> 49#include <i386/ibcs2/ibcs2_termios.h> 50#include <i386/ibcs2/ibcs2_util.h> 51#include <i386/ibcs2/ibcs2_ioctl.h> 52 53static void stios2btios __P((struct ibcs2_termios *, struct termios *)); 54static void btios2stios __P((struct termios *, struct ibcs2_termios *)); 55static void stios2stio __P((struct ibcs2_termios *, struct ibcs2_termio *)); 56static void stio2stios __P((struct ibcs2_termio *, struct ibcs2_termios *)); 57static int ibcs2_do_ioctl __P((struct proc *, struct ibcs2_ioctl_args *, 58 struct file *)); 59 60 61int 62ibcs2_gtty(struct thread *td, struct ibcs2_gtty_args *args) 63{ 64 struct ioctl_args ioctl_arg; 65 66 ioctl_arg.fd = args->fd; 67 ioctl_arg.com = TIOCGETC; 68 ioctl_arg.data = (caddr_t)args->buf; 69 70 return ioctl(td, &ioctl_arg); 71} 72 73int 74ibcs2_stty(struct thread *td, struct ibcs2_stty_args *args) 75{ 76 struct ioctl_args ioctl_arg; 77 78 ioctl_arg.fd = args->fd; 79 ioctl_arg.com = TIOCSETC; 80 ioctl_arg.data = (caddr_t)args->buf; 81 82 return ioctl(td, &ioctl_arg); 83} 84 85 86/* 87 * iBCS2 ioctl calls. 88 */ 89 90static struct speedtab sptab[] = { 91 { 0, 0 }, 92 { 50, 1 }, 93 { 75, 2 }, 94 { 110, 3 }, 95 { 134, 4 }, 96 { 135, 4 }, 97 { 150, 5 }, 98 { 200, 6 }, 99 { 300, 7 }, 100 { 600, 8 }, 101 { 1200, 9 }, 102 { 1800, 10 }, 103 { 2400, 11 }, 104 { 4800, 12 }, 105 { 9600, 13 }, 106 { 19200, 14 }, 107 { 38400, 15 }, 108 { -1, -1 } 109}; 110 111static u_long s2btab[] = { 112 0, 113 50, 114 75, 115 110, 116 134, 117 150, 118 200, 119 300, 120 600, 121 1200, 122 1800, 123 2400, 124 4800, 125 9600, 126 19200, 127 38400, 128}; 129 130static void 131stios2btios(st, bt) 132 struct ibcs2_termios *st; 133 struct termios *bt; 134{ 135 register u_long l, r; 136 137 l = st->c_iflag; r = 0; 138 if (l & IBCS2_IGNBRK) r |= IGNBRK; 139 if (l & IBCS2_BRKINT) r |= BRKINT; 140 if (l & IBCS2_IGNPAR) r |= IGNPAR; 141 if (l & IBCS2_PARMRK) r |= PARMRK; 142 if (l & IBCS2_INPCK) r |= INPCK; 143 if (l & IBCS2_ISTRIP) r |= ISTRIP; 144 if (l & IBCS2_INLCR) r |= INLCR; 145 if (l & IBCS2_IGNCR) r |= IGNCR; 146 if (l & IBCS2_ICRNL) r |= ICRNL; 147 if (l & IBCS2_IXON) r |= IXON; 148 if (l & IBCS2_IXANY) r |= IXANY; 149 if (l & IBCS2_IXOFF) r |= IXOFF; 150 if (l & IBCS2_IMAXBEL) r |= IMAXBEL; 151 bt->c_iflag = r; 152 153 l = st->c_oflag; r = 0; 154 if (l & IBCS2_OPOST) r |= OPOST; 155 if (l & IBCS2_ONLCR) r |= ONLCR; 156 if (l & IBCS2_TAB3) r |= OXTABS; 157 bt->c_oflag = r; 158 159 l = st->c_cflag; r = 0; 160 switch (l & IBCS2_CSIZE) { 161 case IBCS2_CS5: r |= CS5; break; 162 case IBCS2_CS6: r |= CS6; break; 163 case IBCS2_CS7: r |= CS7; break; 164 case IBCS2_CS8: r |= CS8; break; 165 } 166 if (l & IBCS2_CSTOPB) r |= CSTOPB; 167 if (l & IBCS2_CREAD) r |= CREAD; 168 if (l & IBCS2_PARENB) r |= PARENB; 169 if (l & IBCS2_PARODD) r |= PARODD; 170 if (l & IBCS2_HUPCL) r |= HUPCL; 171 if (l & IBCS2_CLOCAL) r |= CLOCAL; 172 bt->c_cflag = r; 173 174 bt->c_ispeed = bt->c_ospeed = s2btab[l & 0x0000000f]; 175 176 l = st->c_lflag; r = 0; 177 if (l & IBCS2_ISIG) r |= ISIG; 178 if (l & IBCS2_ICANON) r |= ICANON; 179 if (l & IBCS2_ECHO) r |= ECHO; 180 if (l & IBCS2_ECHOE) r |= ECHOE; 181 if (l & IBCS2_ECHOK) r |= ECHOK; 182 if (l & IBCS2_ECHONL) r |= ECHONL; 183 if (l & IBCS2_NOFLSH) r |= NOFLSH; 184 if (l & IBCS2_TOSTOP) r |= TOSTOP; 185 bt->c_lflag = r; 186 187 bt->c_cc[VINTR] = 188 st->c_cc[IBCS2_VINTR] ? st->c_cc[IBCS2_VINTR] : _POSIX_VDISABLE; 189 bt->c_cc[VQUIT] = 190 st->c_cc[IBCS2_VQUIT] ? st->c_cc[IBCS2_VQUIT] : _POSIX_VDISABLE; 191 bt->c_cc[VERASE] = 192 st->c_cc[IBCS2_VERASE] ? st->c_cc[IBCS2_VERASE] : _POSIX_VDISABLE; 193 bt->c_cc[VKILL] = 194 st->c_cc[IBCS2_VKILL] ? st->c_cc[IBCS2_VKILL] : _POSIX_VDISABLE; 195 if (bt->c_lflag & ICANON) { 196 bt->c_cc[VEOF] = 197 st->c_cc[IBCS2_VEOF] ? st->c_cc[IBCS2_VEOF] : _POSIX_VDISABLE; 198 bt->c_cc[VEOL] = 199 st->c_cc[IBCS2_VEOL] ? st->c_cc[IBCS2_VEOL] : _POSIX_VDISABLE; 200 } else { 201 bt->c_cc[VMIN] = st->c_cc[IBCS2_VMIN]; 202 bt->c_cc[VTIME] = st->c_cc[IBCS2_VTIME]; 203 } 204 bt->c_cc[VEOL2] = 205 st->c_cc[IBCS2_VEOL2] ? st->c_cc[IBCS2_VEOL2] : _POSIX_VDISABLE; 206#if 0 207 bt->c_cc[VSWTCH] = 208 st->c_cc[IBCS2_VSWTCH] ? st->c_cc[IBCS2_VSWTCH] : _POSIX_VDISABLE; 209#endif 210 bt->c_cc[VSTART] = 211 st->c_cc[IBCS2_VSTART] ? st->c_cc[IBCS2_VSTART] : _POSIX_VDISABLE; 212 bt->c_cc[VSTOP] = 213 st->c_cc[IBCS2_VSTOP] ? st->c_cc[IBCS2_VSTOP] : _POSIX_VDISABLE; 214 bt->c_cc[VSUSP] = 215 st->c_cc[IBCS2_VSUSP] ? st->c_cc[IBCS2_VSUSP] : _POSIX_VDISABLE; 216 bt->c_cc[VDSUSP] = _POSIX_VDISABLE; 217 bt->c_cc[VREPRINT] = _POSIX_VDISABLE; 218 bt->c_cc[VDISCARD] = _POSIX_VDISABLE; 219 bt->c_cc[VWERASE] = _POSIX_VDISABLE; 220 bt->c_cc[VLNEXT] = _POSIX_VDISABLE; 221 bt->c_cc[VSTATUS] = _POSIX_VDISABLE; 222} 223 224static void 225btios2stios(bt, st) 226 struct termios *bt; 227 struct ibcs2_termios *st; 228{ 229 register u_long l, r; 230 231 l = bt->c_iflag; r = 0; 232 if (l & IGNBRK) r |= IBCS2_IGNBRK; 233 if (l & BRKINT) r |= IBCS2_BRKINT; 234 if (l & IGNPAR) r |= IBCS2_IGNPAR; 235 if (l & PARMRK) r |= IBCS2_PARMRK; 236 if (l & INPCK) r |= IBCS2_INPCK; 237 if (l & ISTRIP) r |= IBCS2_ISTRIP; 238 if (l & INLCR) r |= IBCS2_INLCR; 239 if (l & IGNCR) r |= IBCS2_IGNCR; 240 if (l & ICRNL) r |= IBCS2_ICRNL; 241 if (l & IXON) r |= IBCS2_IXON; 242 if (l & IXANY) r |= IBCS2_IXANY; 243 if (l & IXOFF) r |= IBCS2_IXOFF; 244 if (l & IMAXBEL) r |= IBCS2_IMAXBEL; 245 st->c_iflag = r; 246 247 l = bt->c_oflag; r = 0; 248 if (l & OPOST) r |= IBCS2_OPOST; 249 if (l & ONLCR) r |= IBCS2_ONLCR; 250 if (l & OXTABS) r |= IBCS2_TAB3; 251 st->c_oflag = r; 252 253 l = bt->c_cflag; r = 0; 254 switch (l & CSIZE) { 255 case CS5: r |= IBCS2_CS5; break; 256 case CS6: r |= IBCS2_CS6; break; 257 case CS7: r |= IBCS2_CS7; break; 258 case CS8: r |= IBCS2_CS8; break; 259 } 260 if (l & CSTOPB) r |= IBCS2_CSTOPB; 261 if (l & CREAD) r |= IBCS2_CREAD; 262 if (l & PARENB) r |= IBCS2_PARENB; 263 if (l & PARODD) r |= IBCS2_PARODD; 264 if (l & HUPCL) r |= IBCS2_HUPCL; 265 if (l & CLOCAL) r |= IBCS2_CLOCAL; 266 st->c_cflag = r; 267 268 l = bt->c_lflag; r = 0; 269 if (l & ISIG) r |= IBCS2_ISIG; 270 if (l & ICANON) r |= IBCS2_ICANON; 271 if (l & ECHO) r |= IBCS2_ECHO; 272 if (l & ECHOE) r |= IBCS2_ECHOE; 273 if (l & ECHOK) r |= IBCS2_ECHOK; 274 if (l & ECHONL) r |= IBCS2_ECHONL; 275 if (l & NOFLSH) r |= IBCS2_NOFLSH; 276 if (l & TOSTOP) r |= IBCS2_TOSTOP; 277 st->c_lflag = r; 278 279 l = ttspeedtab(bt->c_ospeed, sptab); 280 if ((int)l >= 0) 281 st->c_cflag |= l; 282 283 st->c_cc[IBCS2_VINTR] = 284 bt->c_cc[VINTR] != _POSIX_VDISABLE ? bt->c_cc[VINTR] : 0; 285 st->c_cc[IBCS2_VQUIT] = 286 bt->c_cc[VQUIT] != _POSIX_VDISABLE ? bt->c_cc[VQUIT] : 0; 287 st->c_cc[IBCS2_VERASE] = 288 bt->c_cc[VERASE] != _POSIX_VDISABLE ? bt->c_cc[VERASE] : 0; 289 st->c_cc[IBCS2_VKILL] = 290 bt->c_cc[VKILL] != _POSIX_VDISABLE ? bt->c_cc[VKILL] : 0; 291 if (bt->c_lflag & ICANON) { 292 st->c_cc[IBCS2_VEOF] = 293 bt->c_cc[VEOF] != _POSIX_VDISABLE ? bt->c_cc[VEOF] : 0; 294 st->c_cc[IBCS2_VEOL] = 295 bt->c_cc[VEOL] != _POSIX_VDISABLE ? bt->c_cc[VEOL] : 0; 296 } else { 297 st->c_cc[IBCS2_VMIN] = bt->c_cc[VMIN]; 298 st->c_cc[IBCS2_VTIME] = bt->c_cc[VTIME]; 299 } 300 st->c_cc[IBCS2_VEOL2] = 301 bt->c_cc[VEOL2] != _POSIX_VDISABLE ? bt->c_cc[VEOL2] : 0; 302 st->c_cc[IBCS2_VSWTCH] = 303 0; 304 st->c_cc[IBCS2_VSUSP] = 305 bt->c_cc[VSUSP] != _POSIX_VDISABLE ? bt->c_cc[VSUSP] : 0; 306 st->c_cc[IBCS2_VSTART] = 307 bt->c_cc[VSTART] != _POSIX_VDISABLE ? bt->c_cc[VSTART] : 0; 308 st->c_cc[IBCS2_VSTOP] = 309 bt->c_cc[VSTOP] != _POSIX_VDISABLE ? bt->c_cc[VSTOP] : 0; 310 311 st->c_line = 0; 312} 313 314static void 315stios2stio(ts, t) 316 struct ibcs2_termios *ts; 317 struct ibcs2_termio *t; 318{ 319 t->c_iflag = ts->c_iflag; 320 t->c_oflag = ts->c_oflag; 321 t->c_cflag = ts->c_cflag; 322 t->c_lflag = ts->c_lflag; 323 t->c_line = ts->c_line; 324 bcopy(ts->c_cc, t->c_cc, IBCS2_NCC); 325} 326 327static void 328stio2stios(t, ts) 329 struct ibcs2_termio *t; 330 struct ibcs2_termios *ts; 331{ 332 ts->c_iflag = t->c_iflag; 333 ts->c_oflag = t->c_oflag; 334 ts->c_cflag = t->c_cflag; 335 ts->c_lflag = t->c_lflag; 336 ts->c_line = t->c_line; 337 bcopy(t->c_cc, ts->c_cc, IBCS2_NCC); 338} 339 340int 341ibcs2_ioctl(td, uap) 342 struct thread *td; 343 struct ibcs2_ioctl_args *uap; 344{ 345 struct proc *p = td->td_proc; 346 struct file *fp; 347 int error; 348 349 if ((error = fget(td, uap->fd, &fp)) != 0) { 350 DPRINTF(("ibcs2_ioctl(%d): bad fd %d ", p->p_pid, 351 SCARG(uap, fd))); 352 return EBADF; 353 } 354 355 if ((fp->f_flag & (FREAD|FWRITE)) == 0) { 356 fdrop(fp, td); 357 DPRINTF(("ibcs2_ioctl(%d): bad fp flag ", p->p_pid)); 358 return EBADF; 359 } 360 361 switch (SCARG(uap, cmd)) { 362 case IBCS2_TCGETA: 363 case IBCS2_XCGETA: 364 case IBCS2_OXCGETA: 365 { 366 struct termios bts; 367 struct ibcs2_termios sts; 368 struct ibcs2_termio st; 369 370 if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bts, td)) != 0) 371 break; 372 373 btios2stios (&bts, &sts); 374 if (SCARG(uap, cmd) == IBCS2_TCGETA) { 375 stios2stio (&sts, &st); 376 error = copyout((caddr_t)&st, SCARG(uap, data), 377 sizeof (st)); 378#ifdef DEBUG_IBCS2 379 if (error) 380 DPRINTF(("ibcs2_ioctl(%d): copyout failed ", 381 p->p_pid)); 382#endif 383 break; 384 } else { 385 error = copyout((caddr_t)&sts, SCARG(uap, data), 386 sizeof (sts)); 387 break; 388 } 389 /*NOTREACHED*/ 390 } 391 392 case IBCS2_TCSETA: 393 case IBCS2_TCSETAW: 394 case IBCS2_TCSETAF: 395 { 396 struct termios bts; 397 struct ibcs2_termios sts; 398 struct ibcs2_termio st; 399 400 if ((error = copyin(SCARG(uap, data), (caddr_t)&st, 401 sizeof(st))) != 0) { 402 DPRINTF(("ibcs2_ioctl(%d): TCSET copyin failed ", 403 p->p_pid)); 404 break; 405 } 406 407 /* get full BSD termios so we don't lose information */ 408 if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bts, td)) != 0) { 409 DPRINTF(("ibcs2_ioctl(%d): TCSET ctl failed fd %d ", 410 p->p_pid, SCARG(uap, fd))); 411 break; 412 } 413 414 /* 415 * convert to iBCS2 termios, copy in information from 416 * termio, and convert back, then set new values. 417 */ 418 btios2stios(&bts, &sts); 419 stio2stios(&st, &sts); 420 stios2btios(&sts, &bts); 421 422 error = fo_ioctl(fp, SCARG(uap, cmd) - IBCS2_TCSETA + TIOCSETA, 423 (caddr_t)&bts, td); 424 break; 425 } 426 427 case IBCS2_XCSETA: 428 case IBCS2_XCSETAW: 429 case IBCS2_XCSETAF: 430 { 431 struct termios bts; 432 struct ibcs2_termios sts; 433 434 if ((error = copyin(SCARG(uap, data), (caddr_t)&sts, 435 sizeof (sts))) != 0) 436 break; 437 stios2btios (&sts, &bts); 438 error = fo_ioctl(fp, SCARG(uap, cmd) - IBCS2_XCSETA + TIOCSETA, 439 (caddr_t)&bts, td); 440 break; 441 } 442 443 case IBCS2_OXCSETA: 444 case IBCS2_OXCSETAW: 445 case IBCS2_OXCSETAF: 446 { 447 struct termios bts; 448 struct ibcs2_termios sts; 449 450 if ((error = copyin(SCARG(uap, data), (caddr_t)&sts, 451 sizeof (sts))) != 0) 452 break; 453 stios2btios (&sts, &bts); 454 error = fo_ioctl(fp, SCARG(uap, cmd) - IBCS2_OXCSETA + TIOCSETA, 455 (caddr_t)&bts, td); 456 break; 457 } 458 459 case IBCS2_TCSBRK: 460 DPRINTF(("ibcs2_ioctl(%d): TCSBRK ", p->p_pid)); 461 error = ENOSYS; 462 break; 463 464 case IBCS2_TCXONC: 465 { 466 switch ((int)SCARG(uap, data)) { 467 case 0: 468 case 1: 469 DPRINTF(("ibcs2_ioctl(%d): TCXONC ", p->p_pid)); 470 error = ENOSYS; 471 break; 472 case 2: 473 error = fo_ioctl(fp, TIOCSTOP, (caddr_t)0, td); 474 break; 475 case 3: 476 error = fo_ioctl(fp, TIOCSTART, (caddr_t)1, td); 477 break; 478 default: 479 error = EINVAL; 480 break; 481 } 482 break; 483 } 484 485 case IBCS2_TCFLSH: 486 { 487 int arg; 488 489 switch ((int)SCARG(uap, data)) { 490 case 0: 491 arg = FREAD; 492 break; 493 case 1: 494 arg = FWRITE; 495 break; 496 case 2: 497 arg = FREAD | FWRITE; 498 break; 499 default: 500 fdrop(fp, td); 501 return EINVAL; 502 } 503 error = fo_ioctl(fp, TIOCFLUSH, (caddr_t)&arg, td); 504 break; 505 } 506 507 case IBCS2_TIOCGWINSZ: 508 SCARG(uap, cmd) = TIOCGWINSZ; 509 error = ioctl(td, (struct ioctl_args *)uap); 510 break; 511 512 case IBCS2_TIOCSWINSZ: 513 SCARG(uap, cmd) = TIOCSWINSZ; 514 error = ioctl(td, (struct ioctl_args *)uap); 515 break; 516 517 case IBCS2_TIOCGPGRP: 518 { 519 pid_t pg_id; 520 521 PROC_LOCK(p); 522 pg_id = p->p_pgrp->pg_id; 523 PROC_UNLOCK(p); 524 error = copyout((caddr_t)&pg_id, SCARG(uap, data), 525 sizeof(pg_id)); 526 break; 527 } 528 529 case IBCS2_TIOCSPGRP: /* XXX - is uap->data a pointer to pgid? */ 530 { 531 struct setpgid_args sa; 532 533 SCARG(&sa, pid) = 0; 534 SCARG(&sa, pgid) = (int)SCARG(uap, data); 535 error = setpgid(td, &sa); 536 break; 537 } 538 539 case IBCS2_TCGETSC: /* SCO console - get scancode flags */ 540 error = EINTR; /* ENOSYS; */ 541 break; 542 543 case IBCS2_TCSETSC: /* SCO console - set scancode flags */ 544 error = 0; /* ENOSYS; */ 545 break; 546 547 case IBCS2_JWINSIZE: /* Unix to Jerq I/O control */ 548 { 549 struct ibcs2_jwinsize { 550 char bytex, bytey; 551 short bitx, bity; 552 } ibcs2_jwinsize; 553 554 PROC_LOCK(p);
| 29 */ 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/consio.h> 34#include <sys/fcntl.h> 35#include <sys/file.h> 36#include <sys/filedesc.h> 37#include <sys/filio.h> 38#include <sys/ioctl_compat.h> 39#include <sys/kbio.h> 40#include <sys/lock.h> 41#include <sys/mutex.h> 42#include <sys/sysproto.h> 43#include <sys/tty.h> 44 45#include <i386/ibcs2/ibcs2_signal.h> 46#include <i386/ibcs2/ibcs2_socksys.h> 47#include <i386/ibcs2/ibcs2_stropts.h> 48#include <i386/ibcs2/ibcs2_proto.h> 49#include <i386/ibcs2/ibcs2_termios.h> 50#include <i386/ibcs2/ibcs2_util.h> 51#include <i386/ibcs2/ibcs2_ioctl.h> 52 53static void stios2btios __P((struct ibcs2_termios *, struct termios *)); 54static void btios2stios __P((struct termios *, struct ibcs2_termios *)); 55static void stios2stio __P((struct ibcs2_termios *, struct ibcs2_termio *)); 56static void stio2stios __P((struct ibcs2_termio *, struct ibcs2_termios *)); 57static int ibcs2_do_ioctl __P((struct proc *, struct ibcs2_ioctl_args *, 58 struct file *)); 59 60 61int 62ibcs2_gtty(struct thread *td, struct ibcs2_gtty_args *args) 63{ 64 struct ioctl_args ioctl_arg; 65 66 ioctl_arg.fd = args->fd; 67 ioctl_arg.com = TIOCGETC; 68 ioctl_arg.data = (caddr_t)args->buf; 69 70 return ioctl(td, &ioctl_arg); 71} 72 73int 74ibcs2_stty(struct thread *td, struct ibcs2_stty_args *args) 75{ 76 struct ioctl_args ioctl_arg; 77 78 ioctl_arg.fd = args->fd; 79 ioctl_arg.com = TIOCSETC; 80 ioctl_arg.data = (caddr_t)args->buf; 81 82 return ioctl(td, &ioctl_arg); 83} 84 85 86/* 87 * iBCS2 ioctl calls. 88 */ 89 90static struct speedtab sptab[] = { 91 { 0, 0 }, 92 { 50, 1 }, 93 { 75, 2 }, 94 { 110, 3 }, 95 { 134, 4 }, 96 { 135, 4 }, 97 { 150, 5 }, 98 { 200, 6 }, 99 { 300, 7 }, 100 { 600, 8 }, 101 { 1200, 9 }, 102 { 1800, 10 }, 103 { 2400, 11 }, 104 { 4800, 12 }, 105 { 9600, 13 }, 106 { 19200, 14 }, 107 { 38400, 15 }, 108 { -1, -1 } 109}; 110 111static u_long s2btab[] = { 112 0, 113 50, 114 75, 115 110, 116 134, 117 150, 118 200, 119 300, 120 600, 121 1200, 122 1800, 123 2400, 124 4800, 125 9600, 126 19200, 127 38400, 128}; 129 130static void 131stios2btios(st, bt) 132 struct ibcs2_termios *st; 133 struct termios *bt; 134{ 135 register u_long l, r; 136 137 l = st->c_iflag; r = 0; 138 if (l & IBCS2_IGNBRK) r |= IGNBRK; 139 if (l & IBCS2_BRKINT) r |= BRKINT; 140 if (l & IBCS2_IGNPAR) r |= IGNPAR; 141 if (l & IBCS2_PARMRK) r |= PARMRK; 142 if (l & IBCS2_INPCK) r |= INPCK; 143 if (l & IBCS2_ISTRIP) r |= ISTRIP; 144 if (l & IBCS2_INLCR) r |= INLCR; 145 if (l & IBCS2_IGNCR) r |= IGNCR; 146 if (l & IBCS2_ICRNL) r |= ICRNL; 147 if (l & IBCS2_IXON) r |= IXON; 148 if (l & IBCS2_IXANY) r |= IXANY; 149 if (l & IBCS2_IXOFF) r |= IXOFF; 150 if (l & IBCS2_IMAXBEL) r |= IMAXBEL; 151 bt->c_iflag = r; 152 153 l = st->c_oflag; r = 0; 154 if (l & IBCS2_OPOST) r |= OPOST; 155 if (l & IBCS2_ONLCR) r |= ONLCR; 156 if (l & IBCS2_TAB3) r |= OXTABS; 157 bt->c_oflag = r; 158 159 l = st->c_cflag; r = 0; 160 switch (l & IBCS2_CSIZE) { 161 case IBCS2_CS5: r |= CS5; break; 162 case IBCS2_CS6: r |= CS6; break; 163 case IBCS2_CS7: r |= CS7; break; 164 case IBCS2_CS8: r |= CS8; break; 165 } 166 if (l & IBCS2_CSTOPB) r |= CSTOPB; 167 if (l & IBCS2_CREAD) r |= CREAD; 168 if (l & IBCS2_PARENB) r |= PARENB; 169 if (l & IBCS2_PARODD) r |= PARODD; 170 if (l & IBCS2_HUPCL) r |= HUPCL; 171 if (l & IBCS2_CLOCAL) r |= CLOCAL; 172 bt->c_cflag = r; 173 174 bt->c_ispeed = bt->c_ospeed = s2btab[l & 0x0000000f]; 175 176 l = st->c_lflag; r = 0; 177 if (l & IBCS2_ISIG) r |= ISIG; 178 if (l & IBCS2_ICANON) r |= ICANON; 179 if (l & IBCS2_ECHO) r |= ECHO; 180 if (l & IBCS2_ECHOE) r |= ECHOE; 181 if (l & IBCS2_ECHOK) r |= ECHOK; 182 if (l & IBCS2_ECHONL) r |= ECHONL; 183 if (l & IBCS2_NOFLSH) r |= NOFLSH; 184 if (l & IBCS2_TOSTOP) r |= TOSTOP; 185 bt->c_lflag = r; 186 187 bt->c_cc[VINTR] = 188 st->c_cc[IBCS2_VINTR] ? st->c_cc[IBCS2_VINTR] : _POSIX_VDISABLE; 189 bt->c_cc[VQUIT] = 190 st->c_cc[IBCS2_VQUIT] ? st->c_cc[IBCS2_VQUIT] : _POSIX_VDISABLE; 191 bt->c_cc[VERASE] = 192 st->c_cc[IBCS2_VERASE] ? st->c_cc[IBCS2_VERASE] : _POSIX_VDISABLE; 193 bt->c_cc[VKILL] = 194 st->c_cc[IBCS2_VKILL] ? st->c_cc[IBCS2_VKILL] : _POSIX_VDISABLE; 195 if (bt->c_lflag & ICANON) { 196 bt->c_cc[VEOF] = 197 st->c_cc[IBCS2_VEOF] ? st->c_cc[IBCS2_VEOF] : _POSIX_VDISABLE; 198 bt->c_cc[VEOL] = 199 st->c_cc[IBCS2_VEOL] ? st->c_cc[IBCS2_VEOL] : _POSIX_VDISABLE; 200 } else { 201 bt->c_cc[VMIN] = st->c_cc[IBCS2_VMIN]; 202 bt->c_cc[VTIME] = st->c_cc[IBCS2_VTIME]; 203 } 204 bt->c_cc[VEOL2] = 205 st->c_cc[IBCS2_VEOL2] ? st->c_cc[IBCS2_VEOL2] : _POSIX_VDISABLE; 206#if 0 207 bt->c_cc[VSWTCH] = 208 st->c_cc[IBCS2_VSWTCH] ? st->c_cc[IBCS2_VSWTCH] : _POSIX_VDISABLE; 209#endif 210 bt->c_cc[VSTART] = 211 st->c_cc[IBCS2_VSTART] ? st->c_cc[IBCS2_VSTART] : _POSIX_VDISABLE; 212 bt->c_cc[VSTOP] = 213 st->c_cc[IBCS2_VSTOP] ? st->c_cc[IBCS2_VSTOP] : _POSIX_VDISABLE; 214 bt->c_cc[VSUSP] = 215 st->c_cc[IBCS2_VSUSP] ? st->c_cc[IBCS2_VSUSP] : _POSIX_VDISABLE; 216 bt->c_cc[VDSUSP] = _POSIX_VDISABLE; 217 bt->c_cc[VREPRINT] = _POSIX_VDISABLE; 218 bt->c_cc[VDISCARD] = _POSIX_VDISABLE; 219 bt->c_cc[VWERASE] = _POSIX_VDISABLE; 220 bt->c_cc[VLNEXT] = _POSIX_VDISABLE; 221 bt->c_cc[VSTATUS] = _POSIX_VDISABLE; 222} 223 224static void 225btios2stios(bt, st) 226 struct termios *bt; 227 struct ibcs2_termios *st; 228{ 229 register u_long l, r; 230 231 l = bt->c_iflag; r = 0; 232 if (l & IGNBRK) r |= IBCS2_IGNBRK; 233 if (l & BRKINT) r |= IBCS2_BRKINT; 234 if (l & IGNPAR) r |= IBCS2_IGNPAR; 235 if (l & PARMRK) r |= IBCS2_PARMRK; 236 if (l & INPCK) r |= IBCS2_INPCK; 237 if (l & ISTRIP) r |= IBCS2_ISTRIP; 238 if (l & INLCR) r |= IBCS2_INLCR; 239 if (l & IGNCR) r |= IBCS2_IGNCR; 240 if (l & ICRNL) r |= IBCS2_ICRNL; 241 if (l & IXON) r |= IBCS2_IXON; 242 if (l & IXANY) r |= IBCS2_IXANY; 243 if (l & IXOFF) r |= IBCS2_IXOFF; 244 if (l & IMAXBEL) r |= IBCS2_IMAXBEL; 245 st->c_iflag = r; 246 247 l = bt->c_oflag; r = 0; 248 if (l & OPOST) r |= IBCS2_OPOST; 249 if (l & ONLCR) r |= IBCS2_ONLCR; 250 if (l & OXTABS) r |= IBCS2_TAB3; 251 st->c_oflag = r; 252 253 l = bt->c_cflag; r = 0; 254 switch (l & CSIZE) { 255 case CS5: r |= IBCS2_CS5; break; 256 case CS6: r |= IBCS2_CS6; break; 257 case CS7: r |= IBCS2_CS7; break; 258 case CS8: r |= IBCS2_CS8; break; 259 } 260 if (l & CSTOPB) r |= IBCS2_CSTOPB; 261 if (l & CREAD) r |= IBCS2_CREAD; 262 if (l & PARENB) r |= IBCS2_PARENB; 263 if (l & PARODD) r |= IBCS2_PARODD; 264 if (l & HUPCL) r |= IBCS2_HUPCL; 265 if (l & CLOCAL) r |= IBCS2_CLOCAL; 266 st->c_cflag = r; 267 268 l = bt->c_lflag; r = 0; 269 if (l & ISIG) r |= IBCS2_ISIG; 270 if (l & ICANON) r |= IBCS2_ICANON; 271 if (l & ECHO) r |= IBCS2_ECHO; 272 if (l & ECHOE) r |= IBCS2_ECHOE; 273 if (l & ECHOK) r |= IBCS2_ECHOK; 274 if (l & ECHONL) r |= IBCS2_ECHONL; 275 if (l & NOFLSH) r |= IBCS2_NOFLSH; 276 if (l & TOSTOP) r |= IBCS2_TOSTOP; 277 st->c_lflag = r; 278 279 l = ttspeedtab(bt->c_ospeed, sptab); 280 if ((int)l >= 0) 281 st->c_cflag |= l; 282 283 st->c_cc[IBCS2_VINTR] = 284 bt->c_cc[VINTR] != _POSIX_VDISABLE ? bt->c_cc[VINTR] : 0; 285 st->c_cc[IBCS2_VQUIT] = 286 bt->c_cc[VQUIT] != _POSIX_VDISABLE ? bt->c_cc[VQUIT] : 0; 287 st->c_cc[IBCS2_VERASE] = 288 bt->c_cc[VERASE] != _POSIX_VDISABLE ? bt->c_cc[VERASE] : 0; 289 st->c_cc[IBCS2_VKILL] = 290 bt->c_cc[VKILL] != _POSIX_VDISABLE ? bt->c_cc[VKILL] : 0; 291 if (bt->c_lflag & ICANON) { 292 st->c_cc[IBCS2_VEOF] = 293 bt->c_cc[VEOF] != _POSIX_VDISABLE ? bt->c_cc[VEOF] : 0; 294 st->c_cc[IBCS2_VEOL] = 295 bt->c_cc[VEOL] != _POSIX_VDISABLE ? bt->c_cc[VEOL] : 0; 296 } else { 297 st->c_cc[IBCS2_VMIN] = bt->c_cc[VMIN]; 298 st->c_cc[IBCS2_VTIME] = bt->c_cc[VTIME]; 299 } 300 st->c_cc[IBCS2_VEOL2] = 301 bt->c_cc[VEOL2] != _POSIX_VDISABLE ? bt->c_cc[VEOL2] : 0; 302 st->c_cc[IBCS2_VSWTCH] = 303 0; 304 st->c_cc[IBCS2_VSUSP] = 305 bt->c_cc[VSUSP] != _POSIX_VDISABLE ? bt->c_cc[VSUSP] : 0; 306 st->c_cc[IBCS2_VSTART] = 307 bt->c_cc[VSTART] != _POSIX_VDISABLE ? bt->c_cc[VSTART] : 0; 308 st->c_cc[IBCS2_VSTOP] = 309 bt->c_cc[VSTOP] != _POSIX_VDISABLE ? bt->c_cc[VSTOP] : 0; 310 311 st->c_line = 0; 312} 313 314static void 315stios2stio(ts, t) 316 struct ibcs2_termios *ts; 317 struct ibcs2_termio *t; 318{ 319 t->c_iflag = ts->c_iflag; 320 t->c_oflag = ts->c_oflag; 321 t->c_cflag = ts->c_cflag; 322 t->c_lflag = ts->c_lflag; 323 t->c_line = ts->c_line; 324 bcopy(ts->c_cc, t->c_cc, IBCS2_NCC); 325} 326 327static void 328stio2stios(t, ts) 329 struct ibcs2_termio *t; 330 struct ibcs2_termios *ts; 331{ 332 ts->c_iflag = t->c_iflag; 333 ts->c_oflag = t->c_oflag; 334 ts->c_cflag = t->c_cflag; 335 ts->c_lflag = t->c_lflag; 336 ts->c_line = t->c_line; 337 bcopy(t->c_cc, ts->c_cc, IBCS2_NCC); 338} 339 340int 341ibcs2_ioctl(td, uap) 342 struct thread *td; 343 struct ibcs2_ioctl_args *uap; 344{ 345 struct proc *p = td->td_proc; 346 struct file *fp; 347 int error; 348 349 if ((error = fget(td, uap->fd, &fp)) != 0) { 350 DPRINTF(("ibcs2_ioctl(%d): bad fd %d ", p->p_pid, 351 SCARG(uap, fd))); 352 return EBADF; 353 } 354 355 if ((fp->f_flag & (FREAD|FWRITE)) == 0) { 356 fdrop(fp, td); 357 DPRINTF(("ibcs2_ioctl(%d): bad fp flag ", p->p_pid)); 358 return EBADF; 359 } 360 361 switch (SCARG(uap, cmd)) { 362 case IBCS2_TCGETA: 363 case IBCS2_XCGETA: 364 case IBCS2_OXCGETA: 365 { 366 struct termios bts; 367 struct ibcs2_termios sts; 368 struct ibcs2_termio st; 369 370 if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bts, td)) != 0) 371 break; 372 373 btios2stios (&bts, &sts); 374 if (SCARG(uap, cmd) == IBCS2_TCGETA) { 375 stios2stio (&sts, &st); 376 error = copyout((caddr_t)&st, SCARG(uap, data), 377 sizeof (st)); 378#ifdef DEBUG_IBCS2 379 if (error) 380 DPRINTF(("ibcs2_ioctl(%d): copyout failed ", 381 p->p_pid)); 382#endif 383 break; 384 } else { 385 error = copyout((caddr_t)&sts, SCARG(uap, data), 386 sizeof (sts)); 387 break; 388 } 389 /*NOTREACHED*/ 390 } 391 392 case IBCS2_TCSETA: 393 case IBCS2_TCSETAW: 394 case IBCS2_TCSETAF: 395 { 396 struct termios bts; 397 struct ibcs2_termios sts; 398 struct ibcs2_termio st; 399 400 if ((error = copyin(SCARG(uap, data), (caddr_t)&st, 401 sizeof(st))) != 0) { 402 DPRINTF(("ibcs2_ioctl(%d): TCSET copyin failed ", 403 p->p_pid)); 404 break; 405 } 406 407 /* get full BSD termios so we don't lose information */ 408 if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bts, td)) != 0) { 409 DPRINTF(("ibcs2_ioctl(%d): TCSET ctl failed fd %d ", 410 p->p_pid, SCARG(uap, fd))); 411 break; 412 } 413 414 /* 415 * convert to iBCS2 termios, copy in information from 416 * termio, and convert back, then set new values. 417 */ 418 btios2stios(&bts, &sts); 419 stio2stios(&st, &sts); 420 stios2btios(&sts, &bts); 421 422 error = fo_ioctl(fp, SCARG(uap, cmd) - IBCS2_TCSETA + TIOCSETA, 423 (caddr_t)&bts, td); 424 break; 425 } 426 427 case IBCS2_XCSETA: 428 case IBCS2_XCSETAW: 429 case IBCS2_XCSETAF: 430 { 431 struct termios bts; 432 struct ibcs2_termios sts; 433 434 if ((error = copyin(SCARG(uap, data), (caddr_t)&sts, 435 sizeof (sts))) != 0) 436 break; 437 stios2btios (&sts, &bts); 438 error = fo_ioctl(fp, SCARG(uap, cmd) - IBCS2_XCSETA + TIOCSETA, 439 (caddr_t)&bts, td); 440 break; 441 } 442 443 case IBCS2_OXCSETA: 444 case IBCS2_OXCSETAW: 445 case IBCS2_OXCSETAF: 446 { 447 struct termios bts; 448 struct ibcs2_termios sts; 449 450 if ((error = copyin(SCARG(uap, data), (caddr_t)&sts, 451 sizeof (sts))) != 0) 452 break; 453 stios2btios (&sts, &bts); 454 error = fo_ioctl(fp, SCARG(uap, cmd) - IBCS2_OXCSETA + TIOCSETA, 455 (caddr_t)&bts, td); 456 break; 457 } 458 459 case IBCS2_TCSBRK: 460 DPRINTF(("ibcs2_ioctl(%d): TCSBRK ", p->p_pid)); 461 error = ENOSYS; 462 break; 463 464 case IBCS2_TCXONC: 465 { 466 switch ((int)SCARG(uap, data)) { 467 case 0: 468 case 1: 469 DPRINTF(("ibcs2_ioctl(%d): TCXONC ", p->p_pid)); 470 error = ENOSYS; 471 break; 472 case 2: 473 error = fo_ioctl(fp, TIOCSTOP, (caddr_t)0, td); 474 break; 475 case 3: 476 error = fo_ioctl(fp, TIOCSTART, (caddr_t)1, td); 477 break; 478 default: 479 error = EINVAL; 480 break; 481 } 482 break; 483 } 484 485 case IBCS2_TCFLSH: 486 { 487 int arg; 488 489 switch ((int)SCARG(uap, data)) { 490 case 0: 491 arg = FREAD; 492 break; 493 case 1: 494 arg = FWRITE; 495 break; 496 case 2: 497 arg = FREAD | FWRITE; 498 break; 499 default: 500 fdrop(fp, td); 501 return EINVAL; 502 } 503 error = fo_ioctl(fp, TIOCFLUSH, (caddr_t)&arg, td); 504 break; 505 } 506 507 case IBCS2_TIOCGWINSZ: 508 SCARG(uap, cmd) = TIOCGWINSZ; 509 error = ioctl(td, (struct ioctl_args *)uap); 510 break; 511 512 case IBCS2_TIOCSWINSZ: 513 SCARG(uap, cmd) = TIOCSWINSZ; 514 error = ioctl(td, (struct ioctl_args *)uap); 515 break; 516 517 case IBCS2_TIOCGPGRP: 518 { 519 pid_t pg_id; 520 521 PROC_LOCK(p); 522 pg_id = p->p_pgrp->pg_id; 523 PROC_UNLOCK(p); 524 error = copyout((caddr_t)&pg_id, SCARG(uap, data), 525 sizeof(pg_id)); 526 break; 527 } 528 529 case IBCS2_TIOCSPGRP: /* XXX - is uap->data a pointer to pgid? */ 530 { 531 struct setpgid_args sa; 532 533 SCARG(&sa, pid) = 0; 534 SCARG(&sa, pgid) = (int)SCARG(uap, data); 535 error = setpgid(td, &sa); 536 break; 537 } 538 539 case IBCS2_TCGETSC: /* SCO console - get scancode flags */ 540 error = EINTR; /* ENOSYS; */ 541 break; 542 543 case IBCS2_TCSETSC: /* SCO console - set scancode flags */ 544 error = 0; /* ENOSYS; */ 545 break; 546 547 case IBCS2_JWINSIZE: /* Unix to Jerq I/O control */ 548 { 549 struct ibcs2_jwinsize { 550 char bytex, bytey; 551 short bitx, bity; 552 } ibcs2_jwinsize; 553 554 PROC_LOCK(p);
|
563 PROC_UNLOCK(p); 564 error = copyout((caddr_t)&ibcs2_jwinsize, SCARG(uap, data), 565 sizeof(ibcs2_jwinsize)); 566 break; 567 } 568 569 /* keyboard and display ioctl's -- type 'K' */ 570 case IBCS2_KDGKBMODE: /* get keyboard translation mode */ 571 SCARG(uap, cmd) = KDGKBMODE; 572/* printf("ioctl KDGKBMODE = %x\n", SCARG(uap, cmd));*/ 573 error = ioctl(td, (struct ioctl_args *)uap); 574 break; 575 576 case IBCS2_KDSKBMODE: /* set keyboard translation mode */ 577 SCARG(uap, cmd) = KDSKBMODE; 578 error = ioctl(td, (struct ioctl_args *)uap); 579 break; 580 581 case IBCS2_KDMKTONE: /* sound tone */ 582 SCARG(uap, cmd) = KDMKTONE; 583 error = ioctl(td, (struct ioctl_args *)uap); 584 break; 585 586 case IBCS2_KDGETMODE: /* get text/graphics mode */ 587 SCARG(uap, cmd) = KDGETMODE; 588 error = ioctl(td, (struct ioctl_args *)uap); 589 break; 590 591 case IBCS2_KDSETMODE: /* set text/graphics mode */ 592 SCARG(uap, cmd) = KDSETMODE; 593 error = ioctl(td, (struct ioctl_args *)uap); 594 break; 595 596 case IBCS2_KDSBORDER: /* set ega color border */ 597 SCARG(uap, cmd) = KDSBORDER; 598 error = ioctl(td, (struct ioctl_args *)uap); 599 break; 600 601 case IBCS2_KDGKBSTATE: 602 SCARG(uap, cmd) = KDGKBSTATE; 603 error = ioctl(td, (struct ioctl_args *)uap); 604 break; 605 606 case IBCS2_KDSETRAD: 607 SCARG(uap, cmd) = KDSETRAD; 608 error = ioctl(td, (struct ioctl_args *)uap); 609 break; 610 611 case IBCS2_KDENABIO: /* enable direct I/O to ports */ 612 SCARG(uap, cmd) = KDENABIO; 613 error = ioctl(td, (struct ioctl_args *)uap); 614 break; 615 616 case IBCS2_KDDISABIO: /* disable direct I/O to ports */ 617 SCARG(uap, cmd) = KDDISABIO; 618 error = ioctl(td, (struct ioctl_args *)uap); 619 break; 620 621 case IBCS2_KIOCSOUND: /* start sound generation */ 622 SCARG(uap, cmd) = KIOCSOUND; 623 error = ioctl(td, (struct ioctl_args *)uap); 624 break; 625 626 case IBCS2_KDGKBTYPE: /* get keyboard type */ 627 SCARG(uap, cmd) = KDGKBTYPE; 628 error = ioctl(td, (struct ioctl_args *)uap); 629 break; 630 631 case IBCS2_KDGETLED: /* get keyboard LED status */ 632 SCARG(uap, cmd) = KDGETLED; 633 error = ioctl(td, (struct ioctl_args *)uap); 634 break; 635 636 case IBCS2_KDSETLED: /* set keyboard LED status */ 637 SCARG(uap, cmd) = KDSETLED; 638 error = ioctl(td, (struct ioctl_args *)uap); 639 break; 640 641 /* Xenix keyboard and display ioctl's from sys/kd.h -- type 'k' */ 642 case IBCS2_GETFKEY: /* Get function key */ 643 SCARG(uap, cmd) = GETFKEY; 644 error = ioctl(td, (struct ioctl_args *)uap); 645 break; 646 647 case IBCS2_SETFKEY: /* Set function key */ 648 SCARG(uap, cmd) = SETFKEY; 649 error = ioctl(td, (struct ioctl_args *)uap); 650 break; 651 652 case IBCS2_GIO_SCRNMAP: /* Get screen output map table */ 653 SCARG(uap, cmd) = GIO_SCRNMAP; 654 error = ioctl(td, (struct ioctl_args *)uap); 655 break; 656 657 case IBCS2_PIO_SCRNMAP: /* Set screen output map table */ 658 SCARG(uap, cmd) = PIO_SCRNMAP; 659 error = ioctl(td, (struct ioctl_args *)uap); 660 break; 661 662 case IBCS2_GIO_KEYMAP: /* Get keyboard map table */ 663 SCARG(uap, cmd) = GIO_KEYMAP; 664 error = ioctl(td, (struct ioctl_args *)uap); 665 break; 666 667 case IBCS2_PIO_KEYMAP: /* Set keyboard map table */ 668 SCARG(uap, cmd) = PIO_KEYMAP; 669 error = ioctl(td, (struct ioctl_args *)uap); 670 break; 671 672 /* socksys */ 673 case IBCS2_SIOCSOCKSYS: 674 error = ibcs2_socksys(td, (struct ibcs2_socksys_args *)uap); 675 break; 676 677 case IBCS2_FIONREAD: 678 case IBCS2_I_NREAD: /* STREAMS */ 679 SCARG(uap, cmd) = FIONREAD; 680 error = ioctl(td, (struct ioctl_args *)uap); 681 break; 682 683 default: 684 DPRINTF(("ibcs2_ioctl(%d): unknown cmd 0x%lx ", 685 td->proc->p_pid, SCARG(uap, cmd))); 686 error = ENOSYS; 687 break; 688 } 689 690 fdrop(fp, td); 691 return error; 692}
| 565 PROC_UNLOCK(p); 566 error = copyout((caddr_t)&ibcs2_jwinsize, SCARG(uap, data), 567 sizeof(ibcs2_jwinsize)); 568 break; 569 } 570 571 /* keyboard and display ioctl's -- type 'K' */ 572 case IBCS2_KDGKBMODE: /* get keyboard translation mode */ 573 SCARG(uap, cmd) = KDGKBMODE; 574/* printf("ioctl KDGKBMODE = %x\n", SCARG(uap, cmd));*/ 575 error = ioctl(td, (struct ioctl_args *)uap); 576 break; 577 578 case IBCS2_KDSKBMODE: /* set keyboard translation mode */ 579 SCARG(uap, cmd) = KDSKBMODE; 580 error = ioctl(td, (struct ioctl_args *)uap); 581 break; 582 583 case IBCS2_KDMKTONE: /* sound tone */ 584 SCARG(uap, cmd) = KDMKTONE; 585 error = ioctl(td, (struct ioctl_args *)uap); 586 break; 587 588 case IBCS2_KDGETMODE: /* get text/graphics mode */ 589 SCARG(uap, cmd) = KDGETMODE; 590 error = ioctl(td, (struct ioctl_args *)uap); 591 break; 592 593 case IBCS2_KDSETMODE: /* set text/graphics mode */ 594 SCARG(uap, cmd) = KDSETMODE; 595 error = ioctl(td, (struct ioctl_args *)uap); 596 break; 597 598 case IBCS2_KDSBORDER: /* set ega color border */ 599 SCARG(uap, cmd) = KDSBORDER; 600 error = ioctl(td, (struct ioctl_args *)uap); 601 break; 602 603 case IBCS2_KDGKBSTATE: 604 SCARG(uap, cmd) = KDGKBSTATE; 605 error = ioctl(td, (struct ioctl_args *)uap); 606 break; 607 608 case IBCS2_KDSETRAD: 609 SCARG(uap, cmd) = KDSETRAD; 610 error = ioctl(td, (struct ioctl_args *)uap); 611 break; 612 613 case IBCS2_KDENABIO: /* enable direct I/O to ports */ 614 SCARG(uap, cmd) = KDENABIO; 615 error = ioctl(td, (struct ioctl_args *)uap); 616 break; 617 618 case IBCS2_KDDISABIO: /* disable direct I/O to ports */ 619 SCARG(uap, cmd) = KDDISABIO; 620 error = ioctl(td, (struct ioctl_args *)uap); 621 break; 622 623 case IBCS2_KIOCSOUND: /* start sound generation */ 624 SCARG(uap, cmd) = KIOCSOUND; 625 error = ioctl(td, (struct ioctl_args *)uap); 626 break; 627 628 case IBCS2_KDGKBTYPE: /* get keyboard type */ 629 SCARG(uap, cmd) = KDGKBTYPE; 630 error = ioctl(td, (struct ioctl_args *)uap); 631 break; 632 633 case IBCS2_KDGETLED: /* get keyboard LED status */ 634 SCARG(uap, cmd) = KDGETLED; 635 error = ioctl(td, (struct ioctl_args *)uap); 636 break; 637 638 case IBCS2_KDSETLED: /* set keyboard LED status */ 639 SCARG(uap, cmd) = KDSETLED; 640 error = ioctl(td, (struct ioctl_args *)uap); 641 break; 642 643 /* Xenix keyboard and display ioctl's from sys/kd.h -- type 'k' */ 644 case IBCS2_GETFKEY: /* Get function key */ 645 SCARG(uap, cmd) = GETFKEY; 646 error = ioctl(td, (struct ioctl_args *)uap); 647 break; 648 649 case IBCS2_SETFKEY: /* Set function key */ 650 SCARG(uap, cmd) = SETFKEY; 651 error = ioctl(td, (struct ioctl_args *)uap); 652 break; 653 654 case IBCS2_GIO_SCRNMAP: /* Get screen output map table */ 655 SCARG(uap, cmd) = GIO_SCRNMAP; 656 error = ioctl(td, (struct ioctl_args *)uap); 657 break; 658 659 case IBCS2_PIO_SCRNMAP: /* Set screen output map table */ 660 SCARG(uap, cmd) = PIO_SCRNMAP; 661 error = ioctl(td, (struct ioctl_args *)uap); 662 break; 663 664 case IBCS2_GIO_KEYMAP: /* Get keyboard map table */ 665 SCARG(uap, cmd) = GIO_KEYMAP; 666 error = ioctl(td, (struct ioctl_args *)uap); 667 break; 668 669 case IBCS2_PIO_KEYMAP: /* Set keyboard map table */ 670 SCARG(uap, cmd) = PIO_KEYMAP; 671 error = ioctl(td, (struct ioctl_args *)uap); 672 break; 673 674 /* socksys */ 675 case IBCS2_SIOCSOCKSYS: 676 error = ibcs2_socksys(td, (struct ibcs2_socksys_args *)uap); 677 break; 678 679 case IBCS2_FIONREAD: 680 case IBCS2_I_NREAD: /* STREAMS */ 681 SCARG(uap, cmd) = FIONREAD; 682 error = ioctl(td, (struct ioctl_args *)uap); 683 break; 684 685 default: 686 DPRINTF(("ibcs2_ioctl(%d): unknown cmd 0x%lx ", 687 td->proc->p_pid, SCARG(uap, cmd))); 688 error = ENOSYS; 689 break; 690 } 691 692 fdrop(fp, td); 693 return error; 694}
|