]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/ppc/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>
49 #include <dev/ppc/cons.h>
52 struct tty
*constty
; /* current console device */
56 consopen(dev
, flag
, devtype
, pp
)
62 boolean_t funnel_state
;
65 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
68 device
= constty
->t_dev
;
71 error
= (*cdevsw
[major(device
)].d_open
)(device
, flag
, devtype
, pp
);
72 thread_funnel_set(kernel_flock
, funnel_state
);
79 consclose(dev
, flag
, mode
, pp
)
85 boolean_t funnel_state
;
88 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
90 device
= constty
->t_dev
;
93 error
= (*cdevsw
[major(device
)].d_close
)(device
, flag
, mode
, pp
);
94 thread_funnel_set(kernel_flock
, funnel_state
);
103 consread(dev
, uio
, ioflag
)
109 boolean_t funnel_state
;
112 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
114 device
= constty
->t_dev
;
117 error
= (*cdevsw
[major(device
)].d_read
)(device
, uio
, ioflag
);
118 thread_funnel_set(kernel_flock
, funnel_state
);
125 conswrite(dev
, uio
, ioflag
)
131 boolean_t funnel_state
;
134 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
136 device
= constty
->t_dev
;
139 error
= (*cdevsw
[major(device
)].d_write
)(device
, uio
, ioflag
);
140 thread_funnel_set(kernel_flock
, funnel_state
);
147 consioctl(dev
, cmd
, addr
, flag
, p
)
155 boolean_t funnel_state
;
158 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
161 device
= constty
->t_dev
;
165 * Superuser can always use this to wrest control of console
166 * output from the "virtual" console.
168 if (cmd
== TIOCCONS
&& constty
) {
169 error
= proc_suser(p
);
177 error
= (*cdevsw
[major(device
)].d_ioctl
)(device
, cmd
, addr
, flag
, p
);
179 thread_funnel_set(kernel_flock
, funnel_state
);
185 /* called with funnel held */
187 consselect(dev
, flag
, wql
, p
)
196 device
= constty
->t_dev
;
199 return ((*cdevsw
[major(device
)].d_select
)(device
, flag
, wql
, p
));
206 boolean_t funnel_state
;
209 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
211 device
= constty
->t_dev
;
214 error
= (*cdevsw
[major(device
)].d_getc
)(device
);
215 thread_funnel_set(kernel_flock
, funnel_state
);
226 boolean_t funnel_state
;
229 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
231 device
= constty
->t_dev
;
234 error
= (*cdevsw
[major(device
)].d_putc
)(device
, c
);
235 thread_funnel_set(kernel_flock
, funnel_state
);
241 * Write message to console; create an alert panel if no text-type window
242 * currently exists. Caller must call alert_done() when finished.
243 * The height and width arguments are not used; they are provided for
244 * compatibility with the 68k version of alert().
263 sprintf(smsg
, msg
, p1
, p2
, p3
, p4
, p5
, p6
, p7
, p8
);
265 /* DoAlert(title, smsg); */