aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kabaev <kan@FreeBSD.org>2004-02-05 01:56:43 +0000
committerAlexander Kabaev <kan@FreeBSD.org>2004-02-05 01:56:43 +0000
commite99c09e2dc011dcf7f559afcf09419ece30828cf (patch)
treeb0e2cc0cdb632a2786c857eb38a7809fd634eacd
parent668329e94b11496cb1d9e6324767986f9b441f7e (diff)
downloadsrc-e99c09e2dc011dcf7f559afcf09419ece30828cf.tar.gz
src-e99c09e2dc011dcf7f559afcf09419ece30828cf.zip
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.
Notes
Notes: svn path=/head/; revision=125467
-rw-r--r--sys/amd64/amd64/db_interface.c4
-rw-r--r--sys/dev/syscons/syscons.c15
-rw-r--r--sys/i386/i386/db_interface.c4
-rw-r--r--sys/i386/isa/pcvt/pcvt_drv.c1
-rw-r--r--sys/i386/isa/pcvt/pcvt_ext.c8
-rw-r--r--sys/i386/isa/pcvt/pcvt_hdr.h2
-rw-r--r--sys/kern/tty_cons.c45
-rw-r--r--sys/sys/cons.h4
8 files changed, 65 insertions, 18 deletions
diff --git a/sys/amd64/amd64/db_interface.c b/sys/amd64/amd64/db_interface.c
index 077c9149d794..6a49ef9a9341 100644
--- a/sys/amd64/amd64/db_interface.c
+++ b/sys/amd64/amd64/db_interface.c
@@ -87,7 +87,7 @@ kdb_trap(int type, int code, struct amd64_saved_state *regs)
* our breakpoints by disarming our breakpoints and fixing up
* %eip.
*/
- if (cons_unavail && ddb_mode) {
+ if (cn_unavailable() != 0 && ddb_mode) {
if (type == T_TRCTRAP) {
regs->tf_rflags &= ~PSL_T;
return (1);
@@ -327,7 +327,7 @@ Debugger(const char *msg)
* OK if the call is for the debugger hotkey but not if the call
* is a weak form of panicing.
*/
- if (cons_unavail && !(boothowto & RB_GDB))
+ if (cn_unavailable() != 0 && !(boothowto & RB_GDB))
return;
if (atomic_cmpset_acq_int(&in_Debugger, 0, 1)) {
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index b054b41c8a94..01159548a693 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -97,6 +97,7 @@ static int sc_console_unit = -1;
static int sc_saver_keyb_only = 1;
static scr_stat *sc_console;
static struct tty *sc_console_tty;
+static struct consdev *sc_consptr;
static void *kernel_console_ts;
static char init_done = COLD;
@@ -526,7 +527,7 @@ scclose(dev_t dev, int flag, int mode, struct thread *td)
DPRINTF(5, ("sc%d: scclose(), ", scp->sc->unit));
s = spltty();
if ((scp == scp->sc->cur_scp) && (scp->sc->unit == sc_console_unit))
- cons_unavail = FALSE;
+ cnavailable(sc_consptr, TRUE);
if (finish_vt_rel(scp, TRUE, &s) == 0) /* force release */
DPRINTF(5, ("reset WAIT_REL, "));
if (finish_vt_acq(scp) == 0) /* force acknowledge */
@@ -927,7 +928,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
scp->pid = 0;
DPRINTF(5, ("VT_AUTO, "));
if ((scp == sc->cur_scp) && (sc->unit == sc_console_unit))
- cons_unavail = FALSE;
+ cnavailable(sc_consptr, TRUE);
/* were we in the middle of the vty switching process? */
if (finish_vt_rel(scp, TRUE, &s) == 0)
DPRINTF(5, ("reset WAIT_REL, "));
@@ -945,7 +946,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
scp->proc = td->td_proc;
scp->pid = scp->proc->p_pid;
if ((scp == sc->cur_scp) && (sc->unit == sc_console_unit))
- cons_unavail = TRUE;
+ cnavailable(sc_consptr, FALSE);
}
splx(s);
DPRINTF(5, ("\n"));
@@ -1419,6 +1420,7 @@ sccninit(struct consdev *cp)
scinit(unit, flags | SC_KERNEL_CONSOLE);
sc_console_unit = unit;
sc_console = SC_STAT(sc_get_softc(unit, SC_KERNEL_CONSOLE)->dev[0]);
+ sc_consptr = cp;
#endif /* !__alpha__ */
#if __alpha__
@@ -1474,6 +1476,7 @@ sccnattach(void)
scinit(unit, flags | SC_KERNEL_CONSOLE);
sc_console_unit = unit;
+ sc_consptr = &consdev;
sc_console = SC_STAT(sc_get_softc(unit, SC_KERNEL_CONSOLE)->dev[0]);
sprintf(consdev.cn_name, "ttyv%r", 0);
cnadd(&consdev);
@@ -2356,7 +2359,7 @@ sc_switch_scr(sc_softc_t *sc, u_int next_scr)
sc->switch_in_progress = 0;
if (sc->unit == sc_console_unit)
- cons_unavail = FALSE;
+ cnavailable(sc_consptr, TRUE);
splx(s);
DPRINTF(5, ("switch done\n"));
@@ -2378,7 +2381,7 @@ do_switch_scr(sc_softc_t *sc, int s)
if (!signal_vt_acq(sc->cur_scp)) {
sc->switch_in_progress = 0;
if (sc->unit == sc_console_unit)
- cons_unavail = FALSE;
+ cnavailable(sc_consptr, TRUE);
}
return s;
@@ -2420,7 +2423,7 @@ signal_vt_acq(scr_stat *scp)
if (scp->smode.mode != VT_PROCESS)
return FALSE;
if (scp->sc->unit == sc_console_unit)
- cons_unavail = TRUE;
+ cnavailable(sc_consptr, FALSE);
scp->status |= SWITCH_WAIT_ACQ;
PROC_LOCK(scp->proc);
psignal(scp->proc, scp->smode.acqsig);
diff --git a/sys/i386/i386/db_interface.c b/sys/i386/i386/db_interface.c
index 92e98f59c179..6e7b99a58517 100644
--- a/sys/i386/i386/db_interface.c
+++ b/sys/i386/i386/db_interface.c
@@ -90,7 +90,7 @@ kdb_trap(int type, int code, struct i386_saved_state *regs)
* our breakpoints by disarming our breakpoints and fixing up
* %eip.
*/
- if (cons_unavail && ddb_mode) {
+ if (cn_unavailable() != 0 && ddb_mode) {
if (type == T_TRCTRAP) {
regs->tf_eflags &= ~PSL_T;
return (1);
@@ -320,7 +320,7 @@ Debugger(const char *msg)
* OK if the call is for the debugger hotkey but not if the call
* is a weak form of panicing.
*/
- if (cons_unavail && !(boothowto & RB_GDB))
+ if (cn_unavailable() != 0 && !(boothowto & RB_GDB))
return;
if (atomic_cmpset_acq_int(&in_Debugger, 0, 1)) {
diff --git a/sys/i386/isa/pcvt/pcvt_drv.c b/sys/i386/isa/pcvt/pcvt_drv.c
index 9462c34d70e2..38c1ced77314 100644
--- a/sys/i386/isa/pcvt/pcvt_drv.c
+++ b/sys/i386/isa/pcvt/pcvt_drv.c
@@ -673,6 +673,7 @@ pcvt_cn_init(struct consdev *cp)
int i;
pcvt_is_console = 1;
+ pcvt_consptr = cp;
/*
* Don't reset the keyboard via `kbdio' just yet.
diff --git a/sys/i386/isa/pcvt/pcvt_ext.c b/sys/i386/isa/pcvt/pcvt_ext.c
index ea02437fbb3d..4a1e6a07ba65 100644
--- a/sys/i386/isa/pcvt/pcvt_ext.c
+++ b/sys/i386/isa/pcvt/pcvt_ext.c
@@ -2385,7 +2385,7 @@ vgapage(int new_screen)
* process mode.
*/
if(pcvt_is_console)
- cons_unavail = 0;
+ cnavaiable(pcvt_consptr, TRUE);
}
}
return 0;
@@ -2470,7 +2470,7 @@ usl_vt_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct thread *td)
* process mode.
*/
if(pcvt_is_console)
- cons_unavail = (newmode.mode == VT_PROCESS);
+ cnavailable(pcvt_consptr, (newmode.mode != VT_PROCESS));
splx(opri);
return 0;
@@ -2549,7 +2549,7 @@ usl_vt_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct thread *td)
/* XXX */
if(pcvt_is_console)
- cons_unavail = 0;
+ cnavailable(pcvt_consptr, TRUE);
}
return 0;
}
@@ -2563,7 +2563,7 @@ usl_vt_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct thread *td)
/* XXX */
if(pcvt_is_console)
- cons_unavail = 1;
+ cnavailable(pcvt_consptr, FALSE);
return 0;
}
diff --git a/sys/i386/isa/pcvt/pcvt_hdr.h b/sys/i386/isa/pcvt/pcvt_hdr.h
index de8678f4c553..fedb925b25f8 100644
--- a/sys/i386/isa/pcvt/pcvt_hdr.h
+++ b/sys/i386/isa/pcvt/pcvt_hdr.h
@@ -763,6 +763,7 @@ u_char keyboard_is_initialized = 0; /* for ddb sanity */
u_char kbd_polling = 0; /* keyboard is being polled */
u_char reset_keyboard = 0; /* OK to reset keyboard */
keyboard_t *kbd = NULL;
+struct consdev *pcvt_consptr = NULL;
#if PCVT_SHOWKEYS
u_char keyboard_show = 0; /* normal display */
@@ -899,6 +900,7 @@ extern u_char keyboard_is_initialized;
extern u_char kbd_polling;
extern u_char reset_keyboard;
extern keyboard_t *kbd;
+extern struct consdev *pcvt_consptr;
#if PCVT_SHOWKEYS
extern u_char keyboard_show;
diff --git a/sys/kern/tty_cons.c b/sys/kern/tty_cons.c
index 5ebbe8b7f4e9..9a0a12fe698e 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;
diff --git a/sys/sys/cons.h b/sys/sys/cons.h
index d7face75b90a..3721a39271d4 100644
--- a/sys/sys/cons.h
+++ b/sys/sys/cons.h
@@ -83,9 +83,9 @@ struct consdev {
/* Values for cn_flags. */
#define CN_FLAG_NODEBUG 0x00000001 /* Not supported with debugger. */
+#define CN_FLAG_NOAVAIL 0x00000002 /* Temporarily not available. */
#ifdef _KERNEL
-extern int cons_unavail;
#define CONS_DRIVER(name, probe, init, term, getc, checkc, putc, dbctl) \
static struct consdev name##_consdev = { \
@@ -97,12 +97,14 @@ extern int cons_unavail;
void cninit(void);
void cninit_finish(void);
int cnadd(struct consdev *);
+void cnavailable(struct consdev *, int);
void cnremove(struct consdev *);
void cnselect(struct consdev *);
int cncheckc(void);
int cngetc(void);
void cndbctl(int);
void cnputc(int);
+int cn_unavailable(void);
#endif /* _KERNEL */