]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/arm/cons.c
2 * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
5 * Copyright (c) 1987, 1988 NeXT, Inc.
7 * HISTORY 7-Jan-93 Mac Gillon (mgillon) at NeXT Integrated POSIX support
9 * 12-Aug-87 John Seamons (jks) at NeXT Ported to NeXT.
13 * Indirect driver for console.
15 #include <sys/param.h>
16 #include <sys/systm.h>
18 #include <sys/ioctl.h>
23 struct tty
*constty
; /* current console device */
26 * The km driver supplied the default console device for the systems
27 * (usually a raw frame buffer driver, but potentially a serial driver).
29 extern struct tty
*km_tty
[1];
32 * cdevsw[] entries for the console device driver
34 int cnopen(__unused dev_t dev
, int flag
, int devtype
, proc_t pp
);
35 int cnclose(__unused dev_t dev
, int flag
, int mode
, proc_t pp
);
36 int cnread(__unused dev_t dev
, struct uio
*uio
, int ioflag
);
37 int cnwrite(__unused dev_t dev
, struct uio
*uio
, int ioflag
);
38 int cnioctl(__unused dev_t dev
, u_long cmd
, caddr_t addr
, int flg
, proc_t p
);
39 int cnselect(__unused dev_t dev
, int flag
, void * wql
, proc_t p
);
45 return constty
->t_dev
;
47 return km_tty
[0]->t_dev
;
52 cnopen(__unused dev_t dev
, int flag
, int devtype
, struct proc
*pp
)
55 return (*cdevsw
[major(dev
)].d_open
)(dev
, flag
, devtype
, pp
);
60 cnclose(__unused dev_t dev
, int flag
, int mode
, struct proc
*pp
)
63 return (*cdevsw
[major(dev
)].d_close
)(dev
, flag
, mode
, pp
);
68 cnread(__unused dev_t dev
, struct uio
*uio
, int ioflag
)
71 return (*cdevsw
[major(dev
)].d_read
)(dev
, uio
, ioflag
);
76 cnwrite(__unused dev_t dev
, struct uio
*uio
, int ioflag
)
79 return (*cdevsw
[major(dev
)].d_write
)(dev
, uio
, ioflag
);
84 cnioctl(__unused dev_t dev
, u_long cmd
, caddr_t addr
, int flag
, struct proc
*p
)
89 * XXX This check prevents the cons.c code from being shared between
90 * XXX all architectures; it is probably not needed on ARM, either,
91 * XXX but I have no test platforms or ability to run a kernel.
93 * Superuser can always use this to wrest control of console
94 * output from the "virtual" console.
96 if ((unsigned) cmd
== TIOCCONS
&& constty
) {
97 int error
= proc_suser(p
);
104 return (*cdevsw
[major(dev
)].d_ioctl
)(dev
, cmd
, addr
, flag
, p
);
109 cnselect(__unused dev_t dev
, int flag
, void *wql
, struct proc
*p
)
112 return (*cdevsw
[major(dev
)].d_select
)(dev
, flag
, wql
, p
);