Annotation of XNU/bsd/dev/ppc/cons.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * The contents of this file constitute Original Code as defined in and
        !             7:  * are subject to the Apple Public Source License Version 1.1 (the
        !             8:  * "License").  You may not use this file except in compliance with the
        !             9:  * License.  Please obtain a copy of the License at
        !            10:  * http://www.apple.com/publicsource and read it before using this file.
        !            11:  * 
        !            12:  * This Original Code and all software distributed under the License are
        !            13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            17:  * License for the specific language governing rights and limitations
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: /* 
        !            23:  * Copyright (c) 1987, 1988 NeXT, Inc.
        !            24:  *
        !            25:  * HISTORY
        !            26:  *  7-Jan-93  Mac Gillon (mgillon) at NeXT
        !            27:  *     Integrated POSIX support
        !            28:  *
        !            29:  * 12-Aug-87  John Seamons (jks) at NeXT
        !            30:  *     Ported to NeXT.
        !            31:  */ 
        !            32: 
        !            33: /*
        !            34:  * Indirect driver for console.
        !            35:  */
        !            36: #include <sys/param.h>
        !            37: #include <sys/systm.h>
        !            38: #include <sys/conf.h>
        !            39: #include <sys/ioctl.h>
        !            40: #include <sys/tty.h>
        !            41: #include <sys/proc.h>
        !            42: #include <sys/uio.h>
        !            43: #include <dev/ppc/cons.h>
        !            44: 
        !            45: struct tty     cons;
        !            46: struct tty     *constty;               /* current console device */
        !            47: 
        !            48: /*ARGSUSED*/
        !            49: int
        !            50: consopen(dev, flag, devtype, pp)
        !            51:        dev_t dev;
        !            52:        int flag, devtype;
        !            53:        struct proc *pp;
        !            54: {
        !            55:        dev_t device;
        !            56: 
        !            57:        if (constty)
        !            58:            device = constty->t_dev;
        !            59:        else
        !            60:            device = cons.t_dev;
        !            61:        return ((*cdevsw[major(device)].d_open)(device, flag, devtype, pp));
        !            62: }
        !            63: 
        !            64: /*ARGSUSED*/
        !            65: int
        !            66: consclose(dev, flag, mode, pp)
        !            67:        dev_t dev;
        !            68:        int flag, mode;
        !            69:        struct proc *pp;
        !            70: {
        !            71:        dev_t device;
        !            72: 
        !            73:        if (constty)
        !            74:            device = constty->t_dev;
        !            75:        else
        !            76:            device = cons.t_dev;
        !            77:        return ((*cdevsw[major(device)].d_close)(device, flag, mode, pp));
        !            78: }
        !            79: 
        !            80: /*ARGSUSED*/
        !            81: int
        !            82: consread(dev, uio, ioflag)
        !            83:        dev_t dev;
        !            84:        struct uio *uio;
        !            85:        int ioflag;
        !            86: {
        !            87:        dev_t device;
        !            88: 
        !            89:        if (constty)
        !            90:            device = constty->t_dev;
        !            91:        else
        !            92:            device = cons.t_dev;
        !            93:        return ((*cdevsw[major(device)].d_read)(device, uio, ioflag));
        !            94: }
        !            95: 
        !            96: /*ARGSUSED*/
        !            97: int
        !            98: conswrite(dev, uio, ioflag)
        !            99:        dev_t dev;
        !           100:        struct uio *uio;
        !           101:        int ioflag;
        !           102: {
        !           103:     dev_t device;
        !           104: 
        !           105:        if (constty)
        !           106:            device = constty->t_dev;
        !           107:        else
        !           108:            device = cons.t_dev;
        !           109:     return ((*cdevsw[major(device)].d_write)(device, uio, ioflag));
        !           110: }
        !           111: 
        !           112: /*ARGSUSED*/
        !           113: int
        !           114: consioctl(dev, cmd, addr, flag, p)
        !           115:        dev_t dev;
        !           116:        int cmd;
        !           117:        caddr_t addr;
        !           118:        int flag;
        !           119:        struct proc *p;
        !           120: {
        !           121:        dev_t device;
        !           122: 
        !           123:        if (constty)
        !           124:            device = constty->t_dev;
        !           125:        else
        !           126:            device = cons.t_dev;
        !           127:        /*
        !           128:         * Superuser can always use this to wrest control of console
        !           129:         * output from the "virtual" console.
        !           130:         */
        !           131:        if (cmd == TIOCCONS && constty) {
        !           132:                int error = suser(p->p_ucred, (u_short *) NULL);
        !           133:                if (error)
        !           134:                        return (error);
        !           135:                constty = NULL;
        !           136:                return (0);
        !           137:        }
        !           138:        return ((*cdevsw[major(device)].d_ioctl)(device, cmd, addr, flag, p));
        !           139: }
        !           140: 
        !           141: /*ARGSUSED*/
        !           142: int
        !           143: consselect(dev, flag, p)
        !           144:        dev_t dev;
        !           145:        int flag;
        !           146:        struct proc *p;
        !           147: {
        !           148:        dev_t device;
        !           149: 
        !           150:        if (constty)
        !           151:            device = constty->t_dev;
        !           152:        else
        !           153:            device = cons.t_dev;
        !           154:        return ((*cdevsw[major(device)].d_select)(device, flag, p));
        !           155: }
        !           156: 
        !           157: int
        !           158: cons_getc()
        !           159: {
        !           160:        dev_t device;
        !           161: 
        !           162:        if (constty)
        !           163:            device = constty->t_dev;
        !           164:        else
        !           165:            device = cons.t_dev;
        !           166:        return ((*cdevsw[major(device)].d_getc)(device));
        !           167: }
        !           168: 
        !           169: /*ARGSUSED*/
        !           170: int
        !           171: cons_putc(c)
        !           172:        char c;
        !           173: {
        !           174:        dev_t device;
        !           175: 
        !           176:        if (constty)
        !           177:            device = constty->t_dev;
        !           178:        else
        !           179:            device = cons.t_dev;
        !           180:        return ((*cdevsw[major(device)].d_putc)(device, c));
        !           181: }
        !           182: 
        !           183: /*
        !           184:  * Write message to console; create an alert panel if no text-type window
        !           185:  * currently exists. Caller must call alert_done() when finished.
        !           186:  * The height and width arguments are not used; they are provided for 
        !           187:  * compatibility with the 68k version of alert().
        !           188:  */
        !           189: int 
        !           190: alert(
        !           191:        int width, 
        !           192:        int height, 
        !           193:        const char *title, 
        !           194:        const char *msg, 
        !           195:        int p1, 
        !           196:        int p2, 
        !           197:        int p3, 
        !           198:        int p4, 
        !           199:        int p5, 
        !           200:        int p6, 
        !           201:        int p7, 
        !           202:        int p8)
        !           203: {
        !           204:        char smsg[200];
        !           205:        
        !           206:        sprintf(smsg, msg,  p1, p2, p3, p4, p5, p6, p7, p8);
        !           207: #if FIXME  /* [ */
        !           208:        /* DoAlert(title, smsg); */
        !           209: #else
        !           210:        printf("%s\n",smsg);
        !           211: #endif  /* FIXME ] */
        !           212: 
        !           213:        return 0;
        !           214: }
        !           215: 
        !           216: int 
        !           217: alert_done()
        !           218: {
        !           219:        /* DoRestore(); */
        !           220:        return 0;
        !           221: }
        !           222: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.