1995-10-07 09:25:19 +03:00
|
|
|
/* $NetBSD: hpux_tty.c,v 1.11 1995/10/07 06:26:40 mycroft Exp $ */
|
1994-10-26 05:45:11 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1988 University of Utah.
|
1994-05-23 12:03:32 +04:00
|
|
|
* Copyright (c) 1990, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-05-13 17:56:20 +04:00
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* the Systems Programming Group of the University of Utah Computer
|
|
|
|
* Science Department.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1994-05-23 12:03:32 +04:00
|
|
|
* from: Utah $Hdr: hpux_tty.c 1.14 93/08/05$
|
|
|
|
*
|
1994-10-26 05:45:11 +03:00
|
|
|
* @(#)hpux_tty.c 8.3 (Berkeley) 1/12/94
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* stty/gtty/termio emulation stuff
|
|
|
|
*/
|
|
|
|
|
1994-05-23 12:03:32 +04:00
|
|
|
#ifndef COMPAT_43
|
|
|
|
#define COMPAT_43
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/filedesc.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/kernel.h>
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
#include <compat/hpux/hpux.h>
|
|
|
|
#include <compat/hpux/hpux_termio.h>
|
|
|
|
#include <compat/hpux/hpux_syscallargs.h>
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Map BSD/POSIX style termios info to and from SYS5 style termio stuff.
|
|
|
|
*/
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1994-05-23 12:03:32 +04:00
|
|
|
hpux_termio(fd, com, data, p)
|
|
|
|
int fd, com;
|
1993-05-13 17:56:20 +04:00
|
|
|
caddr_t data;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1994-05-23 12:03:32 +04:00
|
|
|
struct file *fp;
|
1993-05-13 17:56:20 +04:00
|
|
|
struct termios tios;
|
1994-05-23 12:03:32 +04:00
|
|
|
struct hpux_termios htios;
|
1993-05-13 17:56:20 +04:00
|
|
|
int line, error, (*ioctlrout)();
|
1994-05-23 12:03:32 +04:00
|
|
|
int newi = 0;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1994-05-23 12:03:32 +04:00
|
|
|
fp = p->p_fd->fd_ofiles[fd];
|
1993-05-13 17:56:20 +04:00
|
|
|
ioctlrout = fp->f_ops->fo_ioctl;
|
|
|
|
switch (com) {
|
1994-05-23 12:03:32 +04:00
|
|
|
case HPUXTCGETATTR:
|
|
|
|
newi = 1;
|
|
|
|
/* fall into ... */
|
1993-05-13 17:56:20 +04:00
|
|
|
case HPUXTCGETA:
|
|
|
|
/*
|
|
|
|
* Get BSD terminal state
|
|
|
|
*/
|
|
|
|
if (error = (*ioctlrout)(fp, TIOCGETA, (caddr_t)&tios, p))
|
|
|
|
break;
|
1994-05-23 12:03:32 +04:00
|
|
|
bzero((char *)&htios, sizeof htios);
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Set iflag.
|
|
|
|
* Same through ICRNL, no BSD equivs for IUCLC, IENQAK
|
|
|
|
*/
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_iflag = tios.c_iflag & 0x1ff;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tios.c_iflag & IXON)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_iflag |= TIO_IXON;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tios.c_iflag & IXOFF)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_iflag |= TIO_IXOFF;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tios.c_iflag & IXANY)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_iflag |= TIO_IXANY;
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Set oflag.
|
|
|
|
* No BSD equivs for OLCUC/OCRNL/ONOCR/ONLRET/OFILL/OFDEL
|
|
|
|
* or any of the delays.
|
|
|
|
*/
|
|
|
|
if (tios.c_oflag & OPOST)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_oflag |= TIO_OPOST;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tios.c_oflag & ONLCR)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_oflag |= TIO_ONLCR;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tios.c_oflag & OXTABS)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_oflag |= TIO_TAB3;
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Set cflag.
|
|
|
|
* Baud from ospeed, rest from cflag.
|
|
|
|
*/
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_cflag = bsdtohpuxbaud(tios.c_ospeed);
|
1993-05-13 17:56:20 +04:00
|
|
|
switch (tios.c_cflag & CSIZE) {
|
|
|
|
case CS5:
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_cflag |= TIO_CS5; break;
|
1993-05-13 17:56:20 +04:00
|
|
|
case CS6:
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_cflag |= TIO_CS6; break;
|
1993-05-13 17:56:20 +04:00
|
|
|
case CS7:
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_cflag |= TIO_CS7; break;
|
1993-05-13 17:56:20 +04:00
|
|
|
case CS8:
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_cflag |= TIO_CS8; break;
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
if (tios.c_cflag & CSTOPB)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_cflag |= TIO_CSTOPB;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tios.c_cflag & CREAD)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_cflag |= TIO_CREAD;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tios.c_cflag & PARENB)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_cflag |= TIO_PARENB;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tios.c_cflag & PARODD)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_cflag |= TIO_PARODD;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tios.c_cflag & HUPCL)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_cflag |= TIO_HUPCL;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tios.c_cflag & CLOCAL)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_cflag |= TIO_CLOCAL;
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Set lflag.
|
|
|
|
* No BSD equiv for XCASE.
|
|
|
|
*/
|
|
|
|
if (tios.c_lflag & ECHOE)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_lflag |= TIO_ECHOE;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tios.c_lflag & ECHOK)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_lflag |= TIO_ECHOK;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tios.c_lflag & ECHO)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_lflag |= TIO_ECHO;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tios.c_lflag & ECHONL)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_lflag |= TIO_ECHONL;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tios.c_lflag & ISIG)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_lflag |= TIO_ISIG;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tios.c_lflag & ICANON)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_lflag |= TIO_ICANON;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tios.c_lflag & NOFLSH)
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_lflag |= TIO_NOFLSH;
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Line discipline
|
|
|
|
*/
|
1994-05-23 12:03:32 +04:00
|
|
|
if (!newi) {
|
|
|
|
line = 0;
|
|
|
|
(void) (*ioctlrout)(fp, TIOCGETD, (caddr_t)&line, p);
|
|
|
|
htios.c_reserved = line;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Set editing chars.
|
|
|
|
* No BSD equiv for VSWTCH.
|
|
|
|
*/
|
|
|
|
htios.c_cc[HPUXVINTR] = tios.c_cc[VINTR];
|
|
|
|
htios.c_cc[HPUXVQUIT] = tios.c_cc[VQUIT];
|
|
|
|
htios.c_cc[HPUXVERASE] = tios.c_cc[VERASE];
|
|
|
|
htios.c_cc[HPUXVKILL] = tios.c_cc[VKILL];
|
|
|
|
htios.c_cc[HPUXVEOF] = tios.c_cc[VEOF];
|
|
|
|
htios.c_cc[HPUXVEOL] = tios.c_cc[VEOL];
|
|
|
|
htios.c_cc[HPUXVEOL2] = tios.c_cc[VEOL2];
|
|
|
|
htios.c_cc[HPUXVSWTCH] = 0;
|
|
|
|
#if 1
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
1994-05-23 12:03:32 +04:00
|
|
|
* XXX since VMIN and VTIME are not implemented,
|
|
|
|
* we need to return something reasonable.
|
|
|
|
* Otherwise a GETA/SETA combo would always put
|
|
|
|
* the tty in non-blocking mode (since VMIN == VTIME == 0).
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
1994-05-23 12:03:32 +04:00
|
|
|
if (fp->f_flag & FNONBLOCK) {
|
|
|
|
htios.c_cc[HPUXVMINS] = 0;
|
|
|
|
htios.c_cc[HPUXVTIMES] = 0;
|
1993-05-13 17:56:20 +04:00
|
|
|
} else {
|
1994-05-23 12:03:32 +04:00
|
|
|
htios.c_cc[HPUXVMINS] = 6;
|
|
|
|
htios.c_cc[HPUXVTIMES] = 1;
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1994-05-23 12:03:32 +04:00
|
|
|
#else
|
|
|
|
htios.c_cc[HPUXVMINS] = tios.c_cc[VMIN];
|
|
|
|
htios.c_cc[HPUXVTIMES] = tios.c_cc[VTIME];
|
|
|
|
#endif
|
|
|
|
htios.c_cc[HPUXVSUSP] = tios.c_cc[VSUSP];
|
|
|
|
htios.c_cc[HPUXVSTART] = tios.c_cc[VSTART];
|
|
|
|
htios.c_cc[HPUXVSTOP] = tios.c_cc[VSTOP];
|
|
|
|
if (newi)
|
|
|
|
bcopy((char *)&htios, data, sizeof htios);
|
|
|
|
else
|
|
|
|
termiostotermio(&htios, (struct hpux_termio *)data);
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
|
|
|
|
1994-05-23 12:03:32 +04:00
|
|
|
case HPUXTCSETATTR:
|
|
|
|
case HPUXTCSETATTRD:
|
|
|
|
case HPUXTCSETATTRF:
|
|
|
|
newi = 1;
|
|
|
|
/* fall into ... */
|
1993-05-13 17:56:20 +04:00
|
|
|
case HPUXTCSETA:
|
|
|
|
case HPUXTCSETAW:
|
|
|
|
case HPUXTCSETAF:
|
|
|
|
/*
|
|
|
|
* Get old characteristics and determine if we are a tty.
|
|
|
|
*/
|
|
|
|
if (error = (*ioctlrout)(fp, TIOCGETA, (caddr_t)&tios, p))
|
|
|
|
break;
|
1994-05-23 12:03:32 +04:00
|
|
|
if (newi)
|
|
|
|
bcopy(data, (char *)&htios, sizeof htios);
|
|
|
|
else
|
|
|
|
termiototermios((struct termio *)data, &htios, &tios);
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Set iflag.
|
|
|
|
* Same through ICRNL, no HP-UX equiv for IMAXBEL
|
|
|
|
*/
|
|
|
|
tios.c_iflag &= ~(IXON|IXOFF|IXANY|0x1ff);
|
1994-05-23 12:03:32 +04:00
|
|
|
tios.c_iflag |= htios.c_iflag & 0x1ff;
|
|
|
|
if (htios.c_iflag & TIO_IXON)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_iflag |= IXON;
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_iflag & TIO_IXOFF)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_iflag |= IXOFF;
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_iflag & TIO_IXANY)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_iflag |= IXANY;
|
|
|
|
/*
|
|
|
|
* Set oflag.
|
|
|
|
* No HP-UX equiv for ONOEOT
|
|
|
|
*/
|
|
|
|
tios.c_oflag &= ~(OPOST|ONLCR|OXTABS);
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_oflag & TIO_OPOST)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_oflag |= OPOST;
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_oflag & TIO_ONLCR)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_oflag |= ONLCR;
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_oflag & TIO_TAB3)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_oflag |= OXTABS;
|
|
|
|
/*
|
|
|
|
* Set cflag.
|
|
|
|
* No HP-UX equiv for CCTS_OFLOW/CCTS_IFLOW/MDMBUF
|
|
|
|
*/
|
|
|
|
tios.c_cflag &=
|
|
|
|
~(CSIZE|CSTOPB|CREAD|PARENB|PARODD|HUPCL|CLOCAL);
|
1994-05-23 12:03:32 +04:00
|
|
|
switch (htios.c_cflag & TIO_CSIZE) {
|
1993-05-13 17:56:20 +04:00
|
|
|
case TIO_CS5:
|
|
|
|
tios.c_cflag |= CS5; break;
|
|
|
|
case TIO_CS6:
|
|
|
|
tios.c_cflag |= CS6; break;
|
|
|
|
case TIO_CS7:
|
|
|
|
tios.c_cflag |= CS7; break;
|
|
|
|
case TIO_CS8:
|
|
|
|
tios.c_cflag |= CS8; break;
|
|
|
|
}
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_cflag & TIO_CSTOPB)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_cflag |= CSTOPB;
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_cflag & TIO_CREAD)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_cflag |= CREAD;
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_cflag & TIO_PARENB)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_cflag |= PARENB;
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_cflag & TIO_PARODD)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_cflag |= PARODD;
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_cflag & TIO_HUPCL)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_cflag |= HUPCL;
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_cflag & TIO_CLOCAL)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_cflag |= CLOCAL;
|
|
|
|
/*
|
|
|
|
* Set lflag.
|
|
|
|
* No HP-UX equiv for ECHOKE/ECHOPRT/ECHOCTL
|
|
|
|
* IEXTEN treated as part of ICANON
|
|
|
|
*/
|
|
|
|
tios.c_lflag &= ~(ECHOE|ECHOK|ECHO|ISIG|ICANON|IEXTEN|NOFLSH);
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_lflag & TIO_ECHOE)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_lflag |= ECHOE;
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_lflag & TIO_ECHOK)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_lflag |= ECHOK;
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_lflag & TIO_ECHO)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_lflag |= ECHO;
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_lflag & TIO_ECHONL)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_lflag |= ECHONL;
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_lflag & TIO_ISIG)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_lflag |= ISIG;
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_lflag & TIO_ICANON)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_lflag |= (ICANON|IEXTEN);
|
1994-05-23 12:03:32 +04:00
|
|
|
if (htios.c_lflag & TIO_NOFLSH)
|
1993-05-13 17:56:20 +04:00
|
|
|
tios.c_lflag |= NOFLSH;
|
|
|
|
/*
|
|
|
|
* Set editing chars.
|
1994-05-23 12:03:32 +04:00
|
|
|
* No HP-UX equivs of VWERASE/VREPRINT/VDSUSP/VLNEXT
|
|
|
|
* /VDISCARD/VSTATUS/VERASE2
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
1994-05-23 12:03:32 +04:00
|
|
|
tios.c_cc[VINTR] = htios.c_cc[HPUXVINTR];
|
|
|
|
tios.c_cc[VQUIT] = htios.c_cc[HPUXVQUIT];
|
|
|
|
tios.c_cc[VERASE] = htios.c_cc[HPUXVERASE];
|
|
|
|
tios.c_cc[VKILL] = htios.c_cc[HPUXVKILL];
|
|
|
|
tios.c_cc[VEOF] = htios.c_cc[HPUXVEOF];
|
|
|
|
tios.c_cc[VEOL] = htios.c_cc[HPUXVEOL];
|
|
|
|
tios.c_cc[VEOL2] = htios.c_cc[HPUXVEOL2];
|
|
|
|
tios.c_cc[VMIN] = htios.c_cc[HPUXVMINS];
|
|
|
|
tios.c_cc[VTIME] = htios.c_cc[HPUXVTIMES];
|
|
|
|
tios.c_cc[VSUSP] = htios.c_cc[HPUXVSUSP];
|
|
|
|
tios.c_cc[VSTART] = htios.c_cc[HPUXVSTART];
|
|
|
|
tios.c_cc[VSTOP] = htios.c_cc[HPUXVSTOP];
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Set the new stuff
|
|
|
|
*/
|
1994-05-23 12:03:32 +04:00
|
|
|
if (com == HPUXTCSETA || com == HPUXTCSETATTR)
|
1993-05-13 17:56:20 +04:00
|
|
|
com = TIOCSETA;
|
1994-05-23 12:03:32 +04:00
|
|
|
else if (com == HPUXTCSETAW || com == HPUXTCSETATTRD)
|
1993-05-13 17:56:20 +04:00
|
|
|
com = TIOCSETAW;
|
|
|
|
else
|
|
|
|
com = TIOCSETAF;
|
|
|
|
error = (*ioctlrout)(fp, com, (caddr_t)&tios, p);
|
|
|
|
if (error == 0) {
|
|
|
|
/*
|
|
|
|
* Set line discipline
|
|
|
|
*/
|
1994-05-23 12:03:32 +04:00
|
|
|
if (!newi) {
|
|
|
|
line = htios.c_reserved;
|
|
|
|
(void) (*ioctlrout)(fp, TIOCSETD,
|
|
|
|
(caddr_t)&line, p);
|
|
|
|
}
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
1994-05-23 12:03:32 +04:00
|
|
|
* Set non-blocking IO if VMIN == VTIME == 0, clear
|
|
|
|
* if not. Should handle the other cases as well.
|
|
|
|
* Note it isn't correct to just turn NBIO off like
|
|
|
|
* we do as it could be on as the result of a fcntl
|
|
|
|
* operation.
|
|
|
|
*
|
1993-05-13 17:56:20 +04:00
|
|
|
* XXX - wouldn't need to do this at all if VMIN/VTIME
|
|
|
|
* were implemented.
|
|
|
|
*/
|
1994-05-23 12:03:32 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct hpux_sys_fcntl_args {
|
1994-05-23 12:03:32 +04:00
|
|
|
int fdes, cmd, arg;
|
|
|
|
} args;
|
|
|
|
int flags, nbio;
|
|
|
|
|
|
|
|
nbio = (htios.c_cc[HPUXVMINS] == 0 &&
|
|
|
|
htios.c_cc[HPUXVTIMES] == 0);
|
|
|
|
if (nbio && (fp->f_flag & FNONBLOCK) == 0 ||
|
|
|
|
!nbio && (fp->f_flag & FNONBLOCK)) {
|
|
|
|
args.fdes = fd;
|
|
|
|
args.cmd = F_GETFL;
|
|
|
|
args.arg = 0;
|
1995-10-07 09:25:19 +03:00
|
|
|
(void) hpux_sys_fcntl(p, &args, &flags);
|
1994-05-23 12:03:32 +04:00
|
|
|
if (nbio)
|
|
|
|
flags |= HPUXNDELAY;
|
|
|
|
else
|
|
|
|
flags &= ~HPUXNDELAY;
|
|
|
|
args.cmd = F_SETFL;
|
|
|
|
args.arg = flags;
|
1995-10-07 09:25:19 +03:00
|
|
|
(void) hpux_sys_fcntl(p, &args, &flags);
|
1994-05-23 12:03:32 +04:00
|
|
|
}
|
|
|
|
}
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1994-05-23 12:03:32 +04:00
|
|
|
termiototermios(tio, tios, bsdtios)
|
|
|
|
struct hpux_termio *tio;
|
|
|
|
struct hpux_termios *tios;
|
|
|
|
struct termios *bsdtios;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
bzero((char *)tios, sizeof *tios);
|
|
|
|
tios->c_iflag = tio->c_iflag;
|
|
|
|
tios->c_oflag = tio->c_oflag;
|
|
|
|
tios->c_cflag = tio->c_cflag;
|
|
|
|
tios->c_lflag = tio->c_lflag;
|
|
|
|
tios->c_reserved = tio->c_line;
|
|
|
|
for (i = 0; i <= HPUXVSWTCH; i++)
|
|
|
|
tios->c_cc[i] = tio->c_cc[i];
|
|
|
|
if (tios->c_lflag & TIO_ICANON) {
|
|
|
|
tios->c_cc[HPUXVEOF] = tio->c_cc[HPUXVEOF];
|
|
|
|
tios->c_cc[HPUXVEOL] = tio->c_cc[HPUXVEOL];
|
|
|
|
tios->c_cc[HPUXVMINS] = 0;
|
|
|
|
tios->c_cc[HPUXVTIMES] = 0;
|
|
|
|
} else {
|
|
|
|
tios->c_cc[HPUXVEOF] = 0;
|
|
|
|
tios->c_cc[HPUXVEOL] = 0;
|
|
|
|
tios->c_cc[HPUXVMINS] = tio->c_cc[HPUXVMIN];
|
|
|
|
tios->c_cc[HPUXVTIMES] = tio->c_cc[HPUXVTIME];
|
|
|
|
}
|
|
|
|
tios->c_cc[HPUXVSUSP] = bsdtios->c_cc[VSUSP];
|
|
|
|
tios->c_cc[HPUXVSTART] = bsdtios->c_cc[VSTART];
|
|
|
|
tios->c_cc[HPUXVSTOP] = bsdtios->c_cc[VSTOP];
|
|
|
|
}
|
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1994-05-23 12:03:32 +04:00
|
|
|
termiostotermio(tios, tio)
|
|
|
|
struct hpux_termios *tios;
|
|
|
|
struct hpux_termio *tio;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
tio->c_iflag = tios->c_iflag;
|
|
|
|
tio->c_oflag = tios->c_oflag;
|
|
|
|
tio->c_cflag = tios->c_cflag;
|
|
|
|
tio->c_lflag = tios->c_lflag;
|
|
|
|
tio->c_line = tios->c_reserved;
|
|
|
|
for (i = 0; i <= HPUXVSWTCH; i++)
|
|
|
|
tio->c_cc[i] = tios->c_cc[i];
|
|
|
|
if (tios->c_lflag & TIO_ICANON) {
|
|
|
|
tio->c_cc[HPUXVEOF] = tios->c_cc[HPUXVEOF];
|
|
|
|
tio->c_cc[HPUXVEOL] = tios->c_cc[HPUXVEOL];
|
|
|
|
} else {
|
|
|
|
tio->c_cc[HPUXVMIN] = tios->c_cc[HPUXVMINS];
|
|
|
|
tio->c_cc[HPUXVTIME] = tios->c_cc[HPUXVTIMES];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
bsdtohpuxbaud(bsdspeed)
|
|
|
|
long bsdspeed;
|
|
|
|
{
|
|
|
|
switch (bsdspeed) {
|
|
|
|
case B0: return(TIO_B0);
|
|
|
|
case B50: return(TIO_B50);
|
|
|
|
case B75: return(TIO_B75);
|
|
|
|
case B110: return(TIO_B110);
|
|
|
|
case B134: return(TIO_B134);
|
|
|
|
case B150: return(TIO_B150);
|
|
|
|
case B200: return(TIO_B200);
|
|
|
|
case B300: return(TIO_B300);
|
|
|
|
case B600: return(TIO_B600);
|
|
|
|
case B1200: return(TIO_B1200);
|
|
|
|
case B1800: return(TIO_B1800);
|
|
|
|
case B2400: return(TIO_B2400);
|
|
|
|
case B4800: return(TIO_B4800);
|
|
|
|
case B9600: return(TIO_B9600);
|
|
|
|
case B19200: return(TIO_B19200);
|
|
|
|
case B38400: return(TIO_B38400);
|
|
|
|
default: return(TIO_B0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1994-05-23 12:03:32 +04:00
|
|
|
hpuxtobsdbaud(hpux_speed)
|
|
|
|
int hpux_speed;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
|
|
|
static char hpuxtobsdbaudtab[32] = {
|
|
|
|
B0, B50, B75, B110, B134, B150, B200, B300,
|
|
|
|
B600, B0, B1200, B1800, B2400, B0, B4800, B0,
|
|
|
|
B9600, B19200, B38400, B0, B0, B0, B0, B0,
|
|
|
|
B0, B0, B0, B0, B0, B0, EXTA, EXTB
|
|
|
|
};
|
|
|
|
|
1994-05-23 12:03:32 +04:00
|
|
|
return(hpuxtobsdbaudtab[hpux_speed & TIO_CBAUD]);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
#ifdef COMPAT_HPUX_6X
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
compat_hpux_6x_sys_gtty(p, v, retval)
|
1993-05-13 17:56:20 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct compat_hpux_6x_sys_gtty_args *uap = v;
|
1995-09-20 02:53:47 +04:00
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
return (getsettty(p, SCARG(uap, fd), HPUXTIOCGETP, SCARG(uap, arg)));
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
compat_hpux_6x_sys_stty(p, v, retval)
|
1993-05-13 17:56:20 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct compat_hpux_6x_sys_stty_args *uap = v;
|
1995-09-20 02:53:47 +04:00
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
return (getsettty(p, SCARG(uap, fd), HPUXTIOCSETP, SCARG(uap, arg)));
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Simplified version of ioctl() for use by
|
|
|
|
* gtty/stty and TIOCGETP/TIOCSETP.
|
|
|
|
*/
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
getsettty(p, fdes, com, cmarg)
|
|
|
|
struct proc *p;
|
|
|
|
int fdes, com;
|
|
|
|
caddr_t cmarg;
|
|
|
|
{
|
|
|
|
register struct filedesc *fdp = p->p_fd;
|
|
|
|
register struct file *fp;
|
1994-01-07 03:43:39 +03:00
|
|
|
struct hpux_sgttyb hsb;
|
1993-05-13 17:56:20 +04:00
|
|
|
struct sgttyb sb;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (((unsigned)fdes) >= fdp->fd_nfiles ||
|
|
|
|
(fp = fdp->fd_ofiles[fdes]) == NULL)
|
|
|
|
return (EBADF);
|
|
|
|
if ((fp->f_flag & (FREAD|FWRITE)) == 0)
|
|
|
|
return (EBADF);
|
|
|
|
if (com == HPUXTIOCSETP) {
|
|
|
|
if (error = copyin(cmarg, (caddr_t)&hsb, sizeof hsb))
|
|
|
|
return (error);
|
|
|
|
sb.sg_ispeed = hsb.sg_ispeed;
|
|
|
|
sb.sg_ospeed = hsb.sg_ospeed;
|
|
|
|
sb.sg_erase = hsb.sg_erase;
|
|
|
|
sb.sg_kill = hsb.sg_kill;
|
|
|
|
sb.sg_flags = hsb.sg_flags & ~(V7_HUPCL|V7_XTABS|V7_NOAL);
|
|
|
|
if (hsb.sg_flags & V7_XTABS)
|
|
|
|
sb.sg_flags |= XTABS;
|
|
|
|
if (hsb.sg_flags & V7_HUPCL)
|
|
|
|
(void)(*fp->f_ops->fo_ioctl)
|
|
|
|
(fp, TIOCHPCL, (caddr_t)0, p);
|
|
|
|
com = TIOCSETP;
|
|
|
|
} else {
|
|
|
|
bzero((caddr_t)&hsb, sizeof hsb);
|
|
|
|
com = TIOCGETP;
|
|
|
|
}
|
|
|
|
error = (*fp->f_ops->fo_ioctl)(fp, com, (caddr_t)&sb, p);
|
|
|
|
if (error == 0 && com == TIOCGETP) {
|
|
|
|
hsb.sg_ispeed = sb.sg_ispeed;
|
|
|
|
hsb.sg_ospeed = sb.sg_ospeed;
|
|
|
|
hsb.sg_erase = sb.sg_erase;
|
|
|
|
hsb.sg_kill = sb.sg_kill;
|
|
|
|
hsb.sg_flags = sb.sg_flags & ~(V7_HUPCL|V7_XTABS|V7_NOAL);
|
|
|
|
if (sb.sg_flags & XTABS)
|
|
|
|
hsb.sg_flags |= V7_XTABS;
|
|
|
|
error = copyout((caddr_t)&hsb, cmarg, sizeof hsb);
|
|
|
|
}
|
|
|
|
return (error);
|
|
|
|
}
|
1994-05-23 12:03:32 +04:00
|
|
|
#endif
|