]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/i386/cons.c
577768fb0fc83a024b2d3b39003a54901c7a3a3f
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 * Copyright (c) 1987, 1988 NeXT, Inc.
34 * 7-Jan-93 Mac Gillon (mgillon) at NeXT
35 * Integrated POSIX support
37 * 12-Aug-87 John Seamons (jks) at NeXT
42 * Indirect driver for console.
44 #include <sys/param.h>
45 #include <sys/systm.h>
47 #include <sys/ioctl.h>
53 struct tty
*constty
; /* current console device */
55 int cnopen(__unused dev_t dev
, int flag
, int devtype
, struct proc
*pp
);
56 int cnclose(__unused dev_t dev
, int flag
, int mode
, struct proc
*pp
);
57 int cnread(__unused dev_t dev
, struct uio
*uio
, int ioflag
);
58 int cnwrite(__unused dev_t dev
, struct uio
*uio
, int ioflag
);
59 int cnioctl(__unused dev_t dev
, int cmd
, caddr_t addr
, int flg
, struct proc
*p
);
60 int cnselect(__unused dev_t dev
, int flag
, void * wql
, struct proc
*p
);
62 void slave_cnenable(void);
67 __unused
const char *title
,
69 int p1
, int p2
, int p3
, int p4
, int p5
, int p6
, int p7
, int p8
);
74 cnopen(__unused dev_t dev
, int flag
, int devtype
, struct proc
*pp
)
77 boolean_t funnel_state
;
80 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
83 device
= constty
->t_dev
;
86 error
= (*cdevsw
[major(device
)].d_open
)(device
, flag
, devtype
, pp
);
87 thread_funnel_set(kernel_flock
, funnel_state
);
94 cnclose(__unused dev_t dev
, int flag
, int mode
, struct proc
*pp
)
97 boolean_t funnel_state
;
100 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
102 device
= constty
->t_dev
;
105 error
= (*cdevsw
[major(device
)].d_close
)(device
, flag
, mode
, pp
);
106 thread_funnel_set(kernel_flock
, funnel_state
);
115 cnread(__unused dev_t dev
, struct uio
*uio
, int ioflag
)
118 boolean_t funnel_state
;
121 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
123 device
= constty
->t_dev
;
126 error
= (*cdevsw
[major(device
)].d_read
)(device
, uio
, ioflag
);
127 thread_funnel_set(kernel_flock
, funnel_state
);
134 cnwrite(__unused dev_t dev
, struct uio
*uio
, int ioflag
)
137 boolean_t funnel_state
;
140 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
142 device
= constty
->t_dev
;
145 error
= (*cdevsw
[major(device
)].d_write
)(device
, uio
, ioflag
);
146 thread_funnel_set(kernel_flock
, funnel_state
);
153 cnioctl(__unused dev_t dev
, int cmd
, caddr_t addr
, int flag
, struct proc
*p
)
156 boolean_t funnel_state
;
159 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
162 device
= constty
->t_dev
;
166 * Superuser can always use this to wrest control of console
167 * output from the "virtual" console.
169 if ((unsigned) cmd
== TIOCCONS
&& constty
) {
170 error
= proc_suser(p
);
178 error
= (*cdevsw
[major(device
)].d_ioctl
)(device
, cmd
, addr
, flag
, p
);
180 thread_funnel_set(kernel_flock
, funnel_state
);
186 /* called with funnel held */
188 cnselect(__unused dev_t dev
, int flag
, void * wql
, struct proc
*p
)
193 device
= constty
->t_dev
;
196 return ((*cdevsw
[major(device
)].d_select
)(device
, flag
, wql
, p
));
199 #if 0 /* FIXME - using OSFMK console driver for the moment */
204 boolean_t funnel_state
;
207 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
209 device
= constty
->t_dev
;
212 error
= (*cdevsw
[major(device
)].d_getc
)(device
);
213 thread_funnel_set(kernel_flock
, funnel_state
);
224 boolean_t funnel_state
;
227 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
229 device
= constty
->t_dev
;
232 error
= (*cdevsw
[major(device
)].d_putc
)(device
, c
);
233 thread_funnel_set(kernel_flock
, funnel_state
);
242 /* FIXME: what to do here? */
247 kprintf( const char *format
, ...)
249 /* on PPC this outputs to the serial line */
250 /* nop on intel ... umeshv@apple.com */
256 * Write message to console; create an alert panel if no text-type window
257 * currently exists. Caller must call alert_done() when finished.
258 * The height and width arguments are not used; they are provided for
259 * compatibility with the 68k version of alert().
265 __unused
const char *title
,
278 sprintf(smsg
, msg
, p1
, p2
, p3
, p4
, p5
, p6
, p7
, p8
);
280 /* DoAlert(title, smsg); */