]> git.saurik.com Git - apple/xnu.git/blame - bsd/dev/ppc/cons.c
xnu-201.19.3.tar.gz
[apple/xnu.git] / bsd / dev / ppc / cons.c
CommitLineData
1c79356b
A
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#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/conf.h>
39#include <sys/ioctl.h>
40#include <sys/tty.h>
41#include <sys/proc.h>
42#include <sys/uio.h>
43#include <dev/ppc/cons.h>
44
45struct tty cons;
46struct tty *constty; /* current console device */
47
48/*ARGSUSED*/
49int
50consopen(dev, flag, devtype, pp)
51 dev_t dev;
52 int flag, devtype;
53 struct proc *pp;
54{
55 dev_t device;
56
57 if (constty)
58 device = constty->t_dev;
59 else
60 device = cons.t_dev;
61 return ((*cdevsw[major(device)].d_open)(device, flag, devtype, pp));
62}
63
64/*ARGSUSED*/
65int
66consclose(dev, flag, mode, pp)
67 dev_t dev;
68 int flag, mode;
69 struct proc *pp;
70{
71 dev_t device;
72
73 if (constty)
74 device = constty->t_dev;
75 else
76 device = cons.t_dev;
77 return ((*cdevsw[major(device)].d_close)(device, flag, mode, pp));
78}
79
80/*ARGSUSED*/
81int
82consread(dev, uio, ioflag)
83 dev_t dev;
84 struct uio *uio;
85 int ioflag;
86{
87 dev_t device;
88
89 if (constty)
90 device = constty->t_dev;
91 else
92 device = cons.t_dev;
93 return ((*cdevsw[major(device)].d_read)(device, uio, ioflag));
94}
95
96/*ARGSUSED*/
97int
98conswrite(dev, uio, ioflag)
99 dev_t dev;
100 struct uio *uio;
101 int ioflag;
102{
103 dev_t device;
104
105 if (constty)
106 device = constty->t_dev;
107 else
108 device = cons.t_dev;
109 return ((*cdevsw[major(device)].d_write)(device, uio, ioflag));
110}
111
112/*ARGSUSED*/
113int
114consioctl(dev, cmd, addr, flag, p)
115 dev_t dev;
116 int cmd;
117 caddr_t addr;
118 int flag;
119 struct proc *p;
120{
121 dev_t device;
122
123 if (constty)
124 device = constty->t_dev;
125 else
126 device = cons.t_dev;
127 /*
128 * Superuser can always use this to wrest control of console
129 * output from the "virtual" console.
130 */
131 if (cmd == TIOCCONS && constty) {
132 int error = suser(p->p_ucred, (u_short *) NULL);
133 if (error)
134 return (error);
135 constty = NULL;
136 return (0);
137 }
138 return ((*cdevsw[major(device)].d_ioctl)(device, cmd, addr, flag, p));
139}
140
141/*ARGSUSED*/
142int
0b4e3aa0 143consselect(dev, flag, wql, p)
1c79356b
A
144 dev_t dev;
145 int flag;
0b4e3aa0 146 void *wql;
1c79356b
A
147 struct proc *p;
148{
149 dev_t device;
150
151 if (constty)
152 device = constty->t_dev;
153 else
154 device = cons.t_dev;
0b4e3aa0 155 return ((*cdevsw[major(device)].d_select)(device, flag, wql, p));
1c79356b
A
156}
157
158int
159cons_getc()
160{
161 dev_t device;
162
163 if (constty)
164 device = constty->t_dev;
165 else
166 device = cons.t_dev;
167 return ((*cdevsw[major(device)].d_getc)(device));
168}
169
170/*ARGSUSED*/
171int
172cons_putc(c)
173 char c;
174{
175 dev_t device;
176
177 if (constty)
178 device = constty->t_dev;
179 else
180 device = cons.t_dev;
181 return ((*cdevsw[major(device)].d_putc)(device, c));
182}
183
184/*
185 * Write message to console; create an alert panel if no text-type window
186 * currently exists. Caller must call alert_done() when finished.
187 * The height and width arguments are not used; they are provided for
188 * compatibility with the 68k version of alert().
189 */
190int
191alert(
192 int width,
193 int height,
194 const char *title,
195 const char *msg,
196 int p1,
197 int p2,
198 int p3,
199 int p4,
200 int p5,
201 int p6,
202 int p7,
203 int p8)
204{
205 char smsg[200];
206
207 sprintf(smsg, msg, p1, p2, p3, p4, p5, p6, p7, p8);
208#if FIXME /* [ */
209 /* DoAlert(title, smsg); */
210#else
211 printf("%s\n",smsg);
212#endif /* FIXME ] */
213
214 return 0;
215}
216
217int
218alert_done()
219{
220 /* DoRestore(); */
221 return 0;
222}
223