X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/8ad349bb6ed4a0be06e34c92be0d98b92e078db4..527f99514973766e9c0382a4d8550dfb00f54939:/bsd/kern/tty_compat.c diff --git a/bsd/kern/tty_compat.c b/bsd/kern/tty_compat.c index bbc2d2f7a..4348bd133 100644 --- a/bsd/kern/tty_compat.c +++ b/bsd/kern/tty_compat.c @@ -1,31 +1,29 @@ /* - * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved. + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. * - * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. The rights granted to you under the - * License may not be used to create, or enable the creation or - * redistribution of, unlawful or unlicensed copies of an Apple operating - * system, or to circumvent, violate, or enable the circumvention or - * violation of, any terms of an Apple operating system software license - * agreement. - * - * Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and * limitations under the License. - * - * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* Copyright (c) 1997 Apple Computer, Inc. All Rights Reserved */ /*- @@ -64,7 +62,15 @@ */ /* - * mapping routines for old line discipline (yuck) + * Compatibility routines for BSD 4.3 tty ioctl() commands + * + * The only function externalized from this file is ttcompat() and it is + * externalized as private extern to prevent exporting of the symbol when + * KEXTs link against the kernel. + * + * Locks: All functions in this file assume that the tty_lock() + * is held on the tty structure before these functions are + * called. */ #include @@ -79,9 +85,6 @@ #include #include -/* NeXT Move define down here cause COMPAT_43_TTY not valid earlier */ -#if COMPAT_43_TTY || defined(COMPAT_SUNOS) - static int ttcompatgetflags(struct tty *tp); static void ttcompatsetflags(struct tty *tp, struct termios *t); static void ttcompatsetlflags(struct tty *tp, struct termios *t); @@ -154,6 +157,7 @@ ttcompatspeedtab(int speed, struct speedtab *table) return (1); /* 50, min and not hangup */ } + /* * ttsetcompat * @@ -169,8 +173,8 @@ ttcompatspeedtab(int speed, struct speedtab *table) * TIOCLSET -> TIOCSETA * * The converted command argument and potentially modified 'term' - * argument are returned to the caller, which will then call ttioctl(), - * if this function returns successfully. + * argument are returned to ttcompat(), which will then call + * ttioctl_locked(), if this function returns successfully. * * Parameters struct tty *tp The tty on which the operation is * being performed. @@ -194,11 +198,16 @@ ttcompatspeedtab(int speed, struct speedtab *table) * TIOCLBIC, or TIOCLSET. * * All other tp fields will remain unmodifed, since the struct - * termious is a local stack copy from ttcompat(), and not the - * real thing. A subsequent call to ttioctl() in ttcompat(), - * however, may result in subsequent changes. + * termios is a local stack copy from ttcompat(), and not the + * real thing. A subsequent call to ttioctl_locked() in + * ttcompat(), however, may result in subsequent changes. + * + * WARNING: This compatibility code is not 6/432 clean; it will only + * work for 32 bit processes on 32 bit kernels or 64 bit + * processes on 64 bit kernels. We are not addressing this + * due to . */ -__private_extern__ int +static int ttsetcompat(struct tty *tp, u_long *com, caddr_t data, struct termios *term) { switch (*com) { @@ -215,7 +224,7 @@ ttsetcompat(struct tty *tp, u_long *com, caddr_t data, struct termios *term) * pending input is not discarded. */ { - register struct sgttyb *sg = (struct sgttyb *)data; + struct sgttyb *sg = (struct sgttyb *)data; int speed; if ((speed = sg->sg_ispeed) > MAX_SPEED || speed < 0) @@ -244,7 +253,7 @@ ttsetcompat(struct tty *tp, u_long *com, caddr_t data, struct termios *term) */ { struct tchars *tc = (struct tchars *)data; - register cc_t *cc; + cc_t *cc; cc = term->c_cc; cc[VINTR] = tc->t_intrc; @@ -265,7 +274,7 @@ ttsetcompat(struct tty *tp, u_long *com, caddr_t data, struct termios *term) */ { struct ltchars *ltc = (struct ltchars *)data; - register cc_t *cc; + cc_t *cc; cc = term->c_cc; cc[VSUSP] = ltc->t_suspc; @@ -316,8 +325,8 @@ ttsetcompat(struct tty *tp, u_long *com, caddr_t data, struct termios *term) * ttcompat * * Description: For 'set' commands, convert the command and arguments as - * necessary, and call ttioctl(), returning the result as - * our result; for 'get' commands, obtain the requested data + * necessary, and call ttioctl_locked(), returning the result + * as our result; for 'get' commands, obtain the requested data * from the appropriate source, and return it in the expected * format. If the command is not recognized, return EINVAL. * @@ -338,12 +347,12 @@ ttsetcompat(struct tty *tp, u_long *com, caddr_t data, struct termios *term) * terminal with no associated session, * or for which there is a session, but * no session leader. - * EIOCTL If the command cannot be handled at + * ENOTTY If the command cannot be handled at * this layer, this will be returned. - * * Any value returned by ttioctl(), if a - * set command is requested. + * * Any value returned by ttioctl_locked(), + * if a set command is requested. * - * NOTES: The process pointer may be a proxy on whose behalf we are + * Notes: The process pointer may be a proxy on whose behalf we are * operating, so it is not safe to simply use current_process() * instead. */ @@ -370,7 +379,7 @@ ttcompat(struct tty *tp, u_long com, caddr_t data, int flag, struct proc *p) term = tp->t_termios; if ((error = ttsetcompat(tp, &com, data, &term)) != 0) return error; - return ttioctl(tp, com, (caddr_t) &term, flag, p); + return ttioctl_locked(tp, com, (caddr_t) &term, flag, p); } case TIOCGETP: /* @@ -378,8 +387,8 @@ ttcompat(struct tty *tp, u_long com, caddr_t data, int flag, struct proc *p) * flags, into the structure pointed to by 'data'. */ { - register struct sgttyb *sg = (struct sgttyb *)data; - register cc_t *cc = tp->t_cc; + struct sgttyb *sg = (struct sgttyb *)data; + cc_t *cc = tp->t_cc; sg->sg_ospeed = ttcompatspeedtab(tp->t_ospeed, compatspeeds); if (tp->t_ispeed == 0) @@ -398,7 +407,7 @@ ttcompat(struct tty *tp, u_long com, caddr_t data, int flag, struct proc *p) */ { struct tchars *tc = (struct tchars *)data; - register cc_t *cc = tp->t_cc; + cc_t *cc = tp->t_cc; tc->t_intrc = cc[VINTR]; tc->t_quitc = cc[VQUIT]; @@ -415,7 +424,7 @@ ttcompat(struct tty *tp, u_long com, caddr_t data, int flag, struct proc *p) */ { struct ltchars *ltc = (struct ltchars *)data; - register cc_t *cc = tp->t_cc; + cc_t *cc = tp->t_cc; ltc->t_suspc = cc[VSUSP]; ltc->t_dsuspc = cc[VDSUSP]; @@ -452,7 +461,7 @@ ttcompat(struct tty *tp, u_long com, caddr_t data, int flag, struct proc *p) { int ldisczero = 0; - return (ttioctl(tp, TIOCSETD, + return (ttioctl_locked(tp, TIOCSETD, *(int *)data == 2 ? (caddr_t)&ldisczero : data, flag, p)); } @@ -461,7 +470,7 @@ ttcompat(struct tty *tp, u_long com, caddr_t data, int flag, struct proc *p) * Become the console device. */ *(int *)data = 1; - return (ttioctl(tp, TIOCCONS, data, flag, p)); + return (ttioctl_locked(tp, TIOCCONS, data, flag, p)); case TIOCGSID: /* @@ -508,11 +517,11 @@ ttcompat(struct tty *tp, u_long com, caddr_t data, int flag, struct proc *p) static int ttcompatgetflags(struct tty *tp) { - register tcflag_t iflag = tp->t_iflag; - register tcflag_t lflag = tp->t_lflag; - register tcflag_t oflag = tp->t_oflag; - register tcflag_t cflag = tp->t_cflag; - register int flags = 0; + tcflag_t iflag = tp->t_iflag; + tcflag_t lflag = tp->t_lflag; + tcflag_t oflag = tp->t_oflag; + tcflag_t cflag = tp->t_cflag; + int flags = 0; if (iflag&IXOFF) flags |= TANDEM; @@ -580,11 +589,11 @@ ttcompatgetflags(struct tty *tp) static void ttcompatsetflags(struct tty *tp, struct termios *t) { - register int flags = tp->t_flags; - register tcflag_t iflag = t->c_iflag; - register tcflag_t oflag = t->c_oflag; - register tcflag_t lflag = t->c_lflag; - register tcflag_t cflag = t->c_cflag; + int flags = tp->t_flags; + tcflag_t iflag = t->c_iflag; + tcflag_t oflag = t->c_oflag; + tcflag_t lflag = t->c_lflag; + tcflag_t cflag = t->c_cflag; if (flags & RAW) { iflag = IGNBRK; @@ -671,11 +680,11 @@ ttcompatsetflags(struct tty *tp, struct termios *t) static void ttcompatsetlflags(struct tty *tp, struct termios *t) { - register int flags = tp->t_flags; - register tcflag_t iflag = t->c_iflag; - register tcflag_t oflag = t->c_oflag; - register tcflag_t lflag = t->c_lflag; - register tcflag_t cflag = t->c_cflag; + int flags = tp->t_flags; + tcflag_t iflag = t->c_iflag; + tcflag_t oflag = t->c_oflag; + tcflag_t lflag = t->c_lflag; + tcflag_t cflag = t->c_cflag; iflag &= ~(PARMRK|IGNPAR|IGNCR|INLCR); if (flags&CRTERA) @@ -743,4 +752,3 @@ ttcompatsetlflags(struct tty *tp, struct termios *t) t->c_lflag = lflag; t->c_cflag = cflag; } -#endif /* COMPAT_43_TTY || COMPAT_SUNOS */