X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/9bccf70c0258c7cac2dcb80011b2a964d884c552..2d21ac55c334faf3a56e5634905ed6987fc787d4:/bsd/dev/i386/km.c diff --git a/bsd/dev/i386/km.c b/bsd/dev/i386/km.c index ff1fa1978..d5ecffc29 100644 --- a/bsd/dev/i386/km.c +++ b/bsd/dev/i386/km.c @@ -1,23 +1,29 @@ /* * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource 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. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * 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 OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * 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_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. * @@ -40,11 +46,27 @@ #include #include #include +#include + +extern int hz; + +extern void cnputcusr(char); +extern int cngetc(void); + +void kminit(void); +int kmopen(dev_t dev, int flag, int devtype, struct proc *pp); +int kmclose(dev_t dev, int flag, int mode, struct proc *p); +int kmread(dev_t dev, struct uio *uio, int ioflag); +int kmwrite(dev_t dev, struct uio *uio, int ioflag); +int kmioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p); +int kmputc(int c); +int kmgetc(dev_t dev); +int kmgetc_silent(dev_t dev); +void cons_cinput(char ch); /* * 'Global' variables, shared only by this file and conf.c. */ -extern struct tty cons; struct tty *km_tty[1] = { &cons }; /* @@ -59,14 +81,14 @@ int disableConsoleOutput; int initialized = 0; static int kmoutput(struct tty *tp); -static void kmtimeout(struct tty *tp); static void kmstart(struct tty *tp); extern void KeyboardOpen(void); -int kminit() +void +kminit(void) { - cons.t_dev = makedev(12, 0); + cons.t_dev = makedev(12, 0); initialized = 1; } /* @@ -76,10 +98,9 @@ int kmopen( dev_t dev, int flag, - int devtype, + __unused int devtype, struct proc *pp) { - int rtn; int unit; struct tty *tp; struct winsize *wp; @@ -102,7 +123,7 @@ kmopen( tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; termioschars(&tp->t_termios); ttsetwater(tp); - } else if ((tp->t_state & TS_XCLUDE) && pp->p_ucred->cr_uid != 0) + } else if ((tp->t_state & TS_XCLUDE) && proc_suser(pp)) return EBUSY; tp->t_state |= TS_CARR_ON; /* lie and say carrier exists and is on. */ @@ -121,7 +142,10 @@ kmopen( bzero(&video, sizeof(video)); PE_current_console(&video); - if( video.v_width != 0 && video.v_height != 0 ) { + if( video.v_display == VGA_TEXT_MODE ) { + wp->ws_col = video.v_width; + wp->ws_row = video.v_height; + } else if( video.v_width != 0 && video.v_height != 0 ) { wp->ws_col = video.v_width / wp->ws_xpixel; wp->ws_row = video.v_height / wp->ws_ypixel; } else { @@ -134,10 +158,10 @@ kmopen( int kmclose( - dev_t dev, + __unused dev_t dev, int flag, - int mode, - struct proc *p) + __unused int mode, + __unused struct proc *p) { struct tty *tp; @@ -150,7 +174,7 @@ kmclose( int kmread( - dev_t dev, + __unused dev_t dev, struct uio *uio, int ioflag) { @@ -162,7 +186,7 @@ kmread( int kmwrite( - dev_t dev, + __unused dev_t dev, struct uio *uio, int ioflag) { @@ -174,7 +198,7 @@ kmwrite( int kmioctl( - dev_t dev, + __unused dev_t dev, int cmd, caddr_t data, int flag, @@ -210,16 +234,9 @@ kmioctl( } default: error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); - if (error >= 0) { + if (ENOTTY != error) return error; - } - error = ttioctl (tp, cmd, data, flag, p); - if (error >= 0) { - return error; - } - else { - return ENOTTY; - } + return ttioctl (tp, cmd, data, flag, p); } } @@ -235,16 +252,16 @@ kmputc( return( 0); if(c == '\n') - cnputc('\r'); + cnputcusr('\r'); - cnputc(c); + cnputcusr(c); return 0; } int kmgetc( - dev_t dev) + __unused dev_t dev) { int c; @@ -253,13 +270,13 @@ kmgetc( if (c == '\r') { c = '\n'; } - cnputc(c); + cnputcusr(c); return c; } int kmgetc_silent( - dev_t dev) + __unused dev_t dev) { int c; @@ -280,37 +297,24 @@ static void kmstart( struct tty *tp) { - extern int hz; if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP)) goto out; if (tp->t_outq.c_cc == 0) goto out; tp->t_state |= TS_BUSY; - if (tp->t_outq.c_cc > tp->t_lowat) { - /* - * Start immediately. - */ - kmoutput(tp); - } - else { - /* - * Wait a bit... - */ -#if 0 - /* FIXME */ - timeout(kmtimeout, tp, hz); -#else - kmoutput(tp); -#endif - } + kmoutput(tp); + return; + out: - ttwwakeup(tp); + (*linesw[tp->t_line].l_start)(tp); + return; } static void -kmtimeout( struct tty *tp) +kmtimeout(void *arg) { boolean_t funnel_state; + struct tty *tp = (struct tty *) arg; funnel_state = thread_funnel_set(kernel_flock, TRUE); kmoutput(tp); @@ -328,7 +332,6 @@ kmoutput( char buf[80]; char *cp; int cc = -1; - extern int hz; while (tp->t_outq.c_cc > 0) { @@ -345,17 +348,16 @@ kmoutput( timeout(kmtimeout, tp, hz); } tp->t_state &= ~TS_BUSY; - ttwwakeup(tp); + (*linesw[tp->t_line].l_start)(tp); return 0; } + +void cons_cinput(char ch) { struct tty *tp = &cons; - boolean_t funnel_state; - (*linesw[tp->t_line].l_rint) (ch, tp); - }