summaryrefslogtreecommitdiff
path: root/sys/dev/syscons
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-05-15 14:30:37 +0000
committerEd Schouten <ed@FreeBSD.org>2009-05-15 14:30:37 +0000
commit983d12f39bb7be63481ca7137b3a5b72b619cc23 (patch)
tree2b10322f810d595d16d77765c24376fbfe77981f /sys/dev/syscons
parenta9754a7538f0db267c50c8354263dab12ae5666b (diff)
Notes
Diffstat (limited to 'sys/dev/syscons')
-rw-r--r--sys/dev/syscons/syscons.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index 77f4e61fed9a..0ba7d7dcac89 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -207,7 +207,7 @@ static int save_kbd_state(scr_stat *scp);
static int update_kbd_state(scr_stat *scp, int state, int mask);
static int update_kbd_leds(scr_stat *scp, int which);
static timeout_t blink_screen;
-static struct tty *sc_alloc_tty(int, const char *, ...) __printflike(2, 3);
+static struct tty *sc_alloc_tty(int, int);
static cn_probe_t sc_cnprobe;
static cn_init_t sc_cninit;
@@ -224,11 +224,6 @@ static tsw_ioctl_t sctty_ioctl;
static tsw_mmap_t sctty_mmap;
static struct ttydevsw sc_ttydevsw = {
- /*
- * XXX: we should use the prefix, but this doesn't work for
- * consolectl.
- */
- .tsw_flags = TF_NOPREFIX,
.tsw_open = sctty_open,
.tsw_close = sctty_close,
.tsw_outwakeup = sctty_outwakeup,
@@ -236,6 +231,15 @@ static struct ttydevsw sc_ttydevsw = {
.tsw_mmap = sctty_mmap,
};
+static d_ioctl_t consolectl_ioctl;
+
+static struct cdevsw consolectl_devsw = {
+ .d_version = D_VERSION,
+ .d_flags = D_NEEDGIANT,
+ .d_ioctl = consolectl_ioctl,
+ .d_name = "consolectl",
+};
+
int
sc_probe_unit(int unit, int flags)
{
@@ -321,14 +325,10 @@ sctty_outwakeup(struct tty *tp)
}
static struct tty *
-sc_alloc_tty(int index, const char *fmt, ...)
+sc_alloc_tty(int index, int devnum)
{
- va_list ap;
struct sc_ttysoftc *stc;
struct tty *tp;
- char name[11]; /* "consolectl" */
-
- va_start(ap, fmt);
/* Allocate TTY object and softc to store unit number. */
stc = malloc(sizeof(struct sc_ttysoftc), M_DEVBUF, M_WAITOK);
@@ -337,10 +337,7 @@ sc_alloc_tty(int index, const char *fmt, ...)
tp = tty_alloc(&sc_ttydevsw, stc, &Giant);
/* Create device node. */
- va_start(ap, fmt);
- vsnrprintf(name, sizeof name, 32, fmt, ap);
- va_end(ap);
- tty_makedev(tp, NULL, "%s", name);
+ tty_makedev(tp, NULL, "v%r", devnum);
return (tp);
}
@@ -354,7 +351,7 @@ sc_attach_unit(int unit, int flags)
video_info_t info;
#endif
int vc;
- struct tty *tp;
+ struct cdev *dev;
flags &= ~SC_KERNEL_CONSOLE;
@@ -425,7 +422,7 @@ sc_attach_unit(int unit, int flags)
for (vc = 0; vc < sc->vtys; vc++) {
if (sc->dev[vc] == NULL) {
- sc->dev[vc] = sc_alloc_tty(vc, "ttyv%r", vc + unit * MAXCONS);
+ sc->dev[vc] = sc_alloc_tty(vc, vc + unit * MAXCONS);
if (vc == 0 && sc->dev == main_devs)
SC_STAT(sc->dev[0]) = &main_console;
}
@@ -436,8 +433,9 @@ sc_attach_unit(int unit, int flags)
*/
}
- tp = sc_alloc_tty(0, "consolectl");
- SC_STAT(tp) = sc_console;
+ dev = make_dev(&consolectl_devsw, 0, UID_ROOT, GID_WHEEL, 0600,
+ "consolectl");
+ dev->si_drv1 = sc->dev[0];
return 0;
}
@@ -1428,6 +1426,14 @@ sctty_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
return (ENOIOCTL);
}
+static int
+consolectl_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
+ struct thread *td)
+{
+
+ return sctty_ioctl(dev->si_drv1, cmd, data, td);
+}
+
static void
sc_cnprobe(struct consdev *cp)
{
@@ -2728,7 +2734,7 @@ scinit(int unit, int flags)
/* assert(sc_malloc) */
sc->dev = malloc(sizeof(struct tty *)*sc->vtys, M_DEVBUF,
M_WAITOK|M_ZERO);
- sc->dev[0] = sc_alloc_tty(0, "ttyv%r", unit * MAXCONS);
+ sc->dev[0] = sc_alloc_tty(0, unit * MAXCONS);
scp = alloc_scp(sc, sc->first_vty);
SC_STAT(sc->dev[0]) = scp;
}