|
|
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: #import <sys/param.h> ! 37: #import <sys/systm.h> ! 38: #import <sys/conf.h> ! 39: #import <sys/ioctl.h> ! 40: #import <sys/tty.h> ! 41: #import <sys/proc.h> ! 42: #import <sys/uio.h> ! 43: ! 44: struct tty cons; ! 45: struct tty *constty; /* current console device */ ! 46: ! 47: /*ARGSUSED*/ ! 48: int ! 49: cnopen(dev, flag, devtype, pp) ! 50: dev_t dev; ! 51: int flag, devtype; ! 52: struct proc *pp; ! 53: { ! 54: dev_t device; ! 55: ! 56: if (constty) ! 57: device = constty->t_dev; ! 58: else ! 59: device = cons.t_dev; ! 60: return ((*cdevsw[major(device)].d_open)(device, flag, devtype, pp)); ! 61: } ! 62: ! 63: /*ARGSUSED*/ ! 64: int ! 65: cnclose(dev, flag, mode, pp) ! 66: dev_t dev; ! 67: int flag, mode; ! 68: struct proc *pp; ! 69: { ! 70: dev_t device; ! 71: ! 72: if (constty) ! 73: device = constty->t_dev; ! 74: else ! 75: device = cons.t_dev; ! 76: return ((*cdevsw[major(device)].d_close)(device, flag, mode, pp)); ! 77: } ! 78: ! 79: /*ARGSUSED*/ ! 80: int ! 81: cnread(dev, uio, ioflag) ! 82: dev_t dev; ! 83: struct uio *uio; ! 84: int ioflag; ! 85: { ! 86: dev_t device; ! 87: ! 88: if (constty) ! 89: device = constty->t_dev; ! 90: else ! 91: device = cons.t_dev; ! 92: return ((*cdevsw[major(device)].d_read)(device, uio, ioflag)); ! 93: } ! 94: ! 95: /*ARGSUSED*/ ! 96: int ! 97: cnwrite(dev, uio, ioflag) ! 98: dev_t dev; ! 99: struct uio *uio; ! 100: int ioflag; ! 101: { ! 102: dev_t device; ! 103: ! 104: if (constty) ! 105: device = constty->t_dev; ! 106: else ! 107: device = cons.t_dev; ! 108: return ((*cdevsw[major(device)].d_write)(device, uio, ioflag)); ! 109: } ! 110: ! 111: /*ARGSUSED*/ ! 112: int ! 113: cnioctl(dev, cmd, addr, flag, p) ! 114: dev_t dev; ! 115: int cmd; ! 116: caddr_t addr; ! 117: int flag; ! 118: struct proc *p; ! 119: { ! 120: dev_t device; ! 121: ! 122: if (constty) ! 123: device = constty->t_dev; ! 124: else ! 125: device = cons.t_dev; ! 126: /* ! 127: * Superuser can always use this to wrest control of console ! 128: * output from the "virtual" console. ! 129: */ ! 130: if (cmd == TIOCCONS && constty) { ! 131: int error = suser(p->p_ucred, (u_short *) NULL); ! 132: if (error) ! 133: return (error); ! 134: constty = NULL; ! 135: return (0); ! 136: } ! 137: return ((*cdevsw[major(device)].d_ioctl)(device, cmd, addr, flag, p)); ! 138: } ! 139: ! 140: /*ARGSUSED*/ ! 141: int ! 142: cnselect(dev, flag, p) ! 143: dev_t dev; ! 144: int flag; ! 145: struct proc *p; ! 146: { ! 147: dev_t device; ! 148: ! 149: if (constty) ! 150: device = constty->t_dev; ! 151: else ! 152: device = cons.t_dev; ! 153: return ((*cdevsw[major(device)].d_select)(device, flag, p)); ! 154: } ! 155: ! 156: #if 0 /* FIXME - using OSFMK console driver for the moment */ ! 157: int ! 158: cngetc() ! 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: cnputc(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: #endif ! 183: ! 184: #if NCPUS > 1 ! 185: slave_cnenable() ! 186: { ! 187: /* FIXME: what to do here? */ ! 188: } ! 189: #endif NCPUS > 1 ! 190: ! 191: #if 0 ! 192: void ! 193: kprintf( const char *format, ...) ! 194: { ! 195: /* on PPC this outputs to the serial line */ ! 196: /* nop on intel ... [email protected] */ ! 197: ! 198: } ! 199: #endif ! 200: ! 201: /* ! 202: * Write message to console; create an alert panel if no text-type window ! 203: * currently exists. Caller must call alert_done() when finished. ! 204: * The height and width arguments are not used; they are provided for ! 205: * compatibility with the 68k version of alert(). ! 206: */ ! 207: int ! 208: alert( ! 209: int width, ! 210: int height, ! 211: const char *title, ! 212: const char *msg, ! 213: int p1, ! 214: int p2, ! 215: int p3, ! 216: int p4, ! 217: int p5, ! 218: int p6, ! 219: int p7, ! 220: int p8) ! 221: { ! 222: char smsg[200]; ! 223: ! 224: sprintf(smsg, msg, p1, p2, p3, p4, p5, p6, p7, p8); ! 225: #if FIXME /* [ */ ! 226: /* DoAlert(title, smsg); */ ! 227: #else ! 228: printf("%s\n",smsg); ! 229: #endif /* FIXME ] */ ! 230: ! 231: return 0; ! 232: } ! 233: ! 234: int ! 235: alert_done() ! 236: { ! 237: /* DoRestore(); */ ! 238: return 0; ! 239: } ! 240:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.