]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/i386/cons.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1987, 1988 NeXT, Inc.
32 * 7-Jan-93 Mac Gillon (mgillon) at NeXT
33 * Integrated POSIX support
35 * 12-Aug-87 John Seamons (jks) at NeXT
40 * Indirect driver for console.
42 #include <sys/param.h>
43 #include <sys/systm.h>
45 #include <sys/ioctl.h>
51 struct tty
*constty
; /* current console device */
53 int cnopen(__unused dev_t dev
, int flag
, int devtype
, struct proc
*pp
);
54 int cnclose(__unused dev_t dev
, int flag
, int mode
, struct proc
*pp
);
55 int cnread(__unused dev_t dev
, struct uio
*uio
, int ioflag
);
56 int cnwrite(__unused dev_t dev
, struct uio
*uio
, int ioflag
);
57 int cnioctl(__unused dev_t dev
, int cmd
, caddr_t addr
, int flg
, struct proc
*p
);
58 int cnselect(__unused dev_t dev
, int flag
, void * wql
, struct proc
*p
);
60 void slave_cnenable(void);
65 __unused
const char *title
,
67 int p1
, int p2
, int p3
, int p4
, int p5
, int p6
, int p7
, int p8
);
72 cnopen(__unused dev_t dev
, int flag
, int devtype
, struct proc
*pp
)
75 boolean_t funnel_state
;
78 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
81 device
= constty
->t_dev
;
84 error
= (*cdevsw
[major(device
)].d_open
)(device
, flag
, devtype
, pp
);
85 thread_funnel_set(kernel_flock
, funnel_state
);
92 cnclose(__unused dev_t dev
, int flag
, int mode
, struct proc
*pp
)
95 boolean_t funnel_state
;
98 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
100 device
= constty
->t_dev
;
103 error
= (*cdevsw
[major(device
)].d_close
)(device
, flag
, mode
, pp
);
104 thread_funnel_set(kernel_flock
, funnel_state
);
113 cnread(__unused dev_t dev
, struct uio
*uio
, int ioflag
)
116 boolean_t funnel_state
;
119 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
121 device
= constty
->t_dev
;
124 error
= (*cdevsw
[major(device
)].d_read
)(device
, uio
, ioflag
);
125 thread_funnel_set(kernel_flock
, funnel_state
);
132 cnwrite(__unused dev_t dev
, struct uio
*uio
, int ioflag
)
135 boolean_t funnel_state
;
138 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
140 device
= constty
->t_dev
;
143 error
= (*cdevsw
[major(device
)].d_write
)(device
, uio
, ioflag
);
144 thread_funnel_set(kernel_flock
, funnel_state
);
151 cnioctl(__unused dev_t dev
, int cmd
, caddr_t addr
, int flag
, struct proc
*p
)
154 boolean_t funnel_state
;
157 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
160 device
= constty
->t_dev
;
164 * Superuser can always use this to wrest control of console
165 * output from the "virtual" console.
167 if ((unsigned) cmd
== TIOCCONS
&& constty
) {
168 error
= proc_suser(p
);
176 error
= (*cdevsw
[major(device
)].d_ioctl
)(device
, cmd
, addr
, flag
, p
);
178 thread_funnel_set(kernel_flock
, funnel_state
);
184 /* called with funnel held */
186 cnselect(__unused dev_t dev
, int flag
, void * wql
, struct proc
*p
)
191 device
= constty
->t_dev
;
194 return ((*cdevsw
[major(device
)].d_select
)(device
, flag
, wql
, p
));
197 #if 0 /* FIXME - using OSFMK console driver for the moment */
202 boolean_t funnel_state
;
205 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
207 device
= constty
->t_dev
;
210 error
= (*cdevsw
[major(device
)].d_getc
)(device
);
211 thread_funnel_set(kernel_flock
, funnel_state
);
222 boolean_t funnel_state
;
225 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
227 device
= constty
->t_dev
;
230 error
= (*cdevsw
[major(device
)].d_putc
)(device
, c
);
231 thread_funnel_set(kernel_flock
, funnel_state
);
240 /* FIXME: what to do here? */
245 kprintf( const char *format
, ...)
247 /* on PPC this outputs to the serial line */
248 /* nop on intel ... umeshv@apple.com */
254 * Write message to console; create an alert panel if no text-type window
255 * currently exists. Caller must call alert_done() when finished.
256 * The height and width arguments are not used; they are provided for
257 * compatibility with the 68k version of alert().
263 __unused
const char *title
,
276 sprintf(smsg
, msg
, p1
, p2
, p3
, p4
, p5
, p6
, p7
, p8
);
278 /* DoAlert(title, smsg); */