]>
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_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1987, 1988 NeXT, Inc.
26 * 7-Jan-93 Mac Gillon (mgillon) at NeXT
27 * Integrated POSIX support
29 * 12-Aug-87 John Seamons (jks) at NeXT
34 * Indirect driver for console.
36 #include <sys/param.h>
37 #include <sys/systm.h>
39 #include <sys/ioctl.h>
45 struct tty
*constty
; /* current console device */
47 int cnopen(__unused dev_t dev
, int flag
, int devtype
, struct proc
*pp
);
48 int cnclose(__unused dev_t dev
, int flag
, int mode
, struct proc
*pp
);
49 int cnread(__unused dev_t dev
, struct uio
*uio
, int ioflag
);
50 int cnwrite(__unused dev_t dev
, struct uio
*uio
, int ioflag
);
51 int cnioctl(__unused dev_t dev
, int cmd
, caddr_t addr
, int flg
, struct proc
*p
);
52 int cnselect(__unused dev_t dev
, int flag
, void * wql
, struct proc
*p
);
54 void slave_cnenable(void);
59 __unused
const char *title
,
61 int p1
, int p2
, int p3
, int p4
, int p5
, int p6
, int p7
, int p8
);
66 cnopen(__unused dev_t dev
, int flag
, int devtype
, struct proc
*pp
)
69 boolean_t funnel_state
;
72 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
75 device
= constty
->t_dev
;
78 error
= (*cdevsw
[major(device
)].d_open
)(device
, flag
, devtype
, pp
);
79 thread_funnel_set(kernel_flock
, funnel_state
);
86 cnclose(__unused dev_t dev
, int flag
, int mode
, struct proc
*pp
)
89 boolean_t funnel_state
;
92 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
94 device
= constty
->t_dev
;
97 error
= (*cdevsw
[major(device
)].d_close
)(device
, flag
, mode
, pp
);
98 thread_funnel_set(kernel_flock
, funnel_state
);
107 cnread(__unused dev_t dev
, struct uio
*uio
, int ioflag
)
110 boolean_t funnel_state
;
113 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
115 device
= constty
->t_dev
;
118 error
= (*cdevsw
[major(device
)].d_read
)(device
, uio
, ioflag
);
119 thread_funnel_set(kernel_flock
, funnel_state
);
126 cnwrite(__unused dev_t dev
, struct uio
*uio
, int ioflag
)
129 boolean_t funnel_state
;
132 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
134 device
= constty
->t_dev
;
137 error
= (*cdevsw
[major(device
)].d_write
)(device
, uio
, ioflag
);
138 thread_funnel_set(kernel_flock
, funnel_state
);
145 cnioctl(__unused dev_t dev
, int cmd
, caddr_t addr
, int flag
, struct proc
*p
)
148 boolean_t funnel_state
;
151 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
154 device
= constty
->t_dev
;
158 * Superuser can always use this to wrest control of console
159 * output from the "virtual" console.
161 if ((unsigned) cmd
== TIOCCONS
&& constty
) {
162 error
= proc_suser(p
);
170 error
= (*cdevsw
[major(device
)].d_ioctl
)(device
, cmd
, addr
, flag
, p
);
172 thread_funnel_set(kernel_flock
, funnel_state
);
178 /* called with funnel held */
180 cnselect(__unused dev_t dev
, int flag
, void * wql
, struct proc
*p
)
185 device
= constty
->t_dev
;
188 return ((*cdevsw
[major(device
)].d_select
)(device
, flag
, wql
, p
));
191 #if 0 /* FIXME - using OSFMK console driver for the moment */
196 boolean_t funnel_state
;
199 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
201 device
= constty
->t_dev
;
204 error
= (*cdevsw
[major(device
)].d_getc
)(device
);
205 thread_funnel_set(kernel_flock
, funnel_state
);
216 boolean_t funnel_state
;
219 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
221 device
= constty
->t_dev
;
224 error
= (*cdevsw
[major(device
)].d_putc
)(device
, c
);
225 thread_funnel_set(kernel_flock
, funnel_state
);
234 /* FIXME: what to do here? */
239 kprintf( const char *format
, ...)
241 /* on PPC this outputs to the serial line */
242 /* nop on intel ... umeshv@apple.com */
248 * Write message to console; create an alert panel if no text-type window
249 * currently exists. Caller must call alert_done() when finished.
250 * The height and width arguments are not used; they are provided for
251 * compatibility with the 68k version of alert().
257 __unused
const char *title
,
270 sprintf(smsg
, msg
, p1
, p2
, p3
, p4
, p5
, p6
, p7
, p8
);
272 /* DoAlert(title, smsg); */