summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty_cons.c
diff options
context:
space:
mode:
authorkan <kan@FreeBSD.org>2004-02-05 01:56:43 +0000
committerkan <kan@FreeBSD.org>2004-02-05 01:56:43 +0000
commit8f796dca97febb2b0e668cd3613331a54c6a74c7 (patch)
treeb0e2cc0cdb632a2786c857eb38a7809fd634eacd /sys/kern/tty_cons.c
parent9a226ff388c34edb12ae278cd6e5f3357fe6796a (diff)
downloadFreeBSD-src-8f796dca97febb2b0e668cd3613331a54c6a74c7.zip
FreeBSD-src-8f796dca97febb2b0e668cd3613331a54c6a74c7.tar.gz
Eliminate global cons_unavailable flag and replace it by the status
bit maintained on a per-device basis. Single variable is inadequate on machines running with multiple consoles enabled.
Diffstat (limited to 'sys/kern/tty_cons.c')
-rw-r--r--sys/kern/tty_cons.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/sys/kern/tty_cons.c b/sys/kern/tty_cons.c
index 5ebbe8b..9a0a12f 100644
--- a/sys/kern/tty_cons.c
+++ b/sys/kern/tty_cons.c
@@ -110,9 +110,10 @@ static udev_t cn_udev_t;
SYSCTL_OPAQUE(_machdep, CPU_CONSDEV, consdev, CTLFLAG_RD,
&cn_udev_t, sizeof cn_udev_t, "T,dev_t", "");
-int cons_unavail = 0; /* XXX:
- * physical console not available for
- * input (i.e., it is in graphics mode)
+int cons_avail_mask = 0; /* Bit mask. Each registered low level console
+ * which is currently unavailable for inpit
+ * (i.e., if it is in graphics mode) will have
+ * this bit cleared.
*/
static int cn_mute;
static int openflag; /* how /dev/console was opened */
@@ -213,6 +214,10 @@ cnadd(struct consdev *cn)
printf("WARNING: console at %p has no name\n", cn);
}
STAILQ_INSERT_TAIL(&cn_devlist, cnd, cnd_next);
+
+ /* Add device to the active mask. */
+ cnavailable(cn, (cn->cn_flags & CN_FLAG_NOAVAIL) == 0);
+
return (0);
}
@@ -220,6 +225,7 @@ void
cnremove(struct consdev *cn)
{
struct cn_device *cnd;
+ int i;
STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) {
if (cnd->cnd_cn != cn)
@@ -229,6 +235,13 @@ cnremove(struct consdev *cn)
vn_close(cnd->cnd_vp, openflag, NOCRED, NULL);
cnd->cnd_vp = NULL;
cnd->cnd_cn = NULL;
+
+ /* Remove this device from available mask. */
+ for (i = 0; i < CNDEVTAB_SIZE; i++)
+ if (cnd == &cn_devtab[i]) {
+ cons_avail_mask &= ~(1 << i);
+ break;
+ }
#if 0
/*
* XXX
@@ -259,6 +272,32 @@ cnselect(struct consdev *cn)
}
void
+cnavailable(struct consdev *cn, int available)
+{
+ int i;
+
+ for (i = 0; i < CNDEVTAB_SIZE; i++) {
+ if (cn_devtab[i].cnd_cn == cn)
+ break;
+ }
+ if (available) {
+ if (i < CNDEVTAB_SIZE)
+ cons_avail_mask |= (1 << i);
+ cn->cn_flags &= ~CN_FLAG_NOAVAIL;
+ } else {
+ if (i < CNDEVTAB_SIZE)
+ cons_avail_mask &= ~(1 << i);
+ cn->cn_flags |= CN_FLAG_NOAVAIL;
+ }
+}
+
+int
+cn_unavailable(void)
+{
+ return (cons_avail_mask == 0);
+}
+
+void
cndebug(char *str)
{
int i, len;
OpenPOWER on IntegriCloud