Index: amd64/amd64/db_interface.c =================================================================== RCS file: /home/ncvs/src/sys/amd64/amd64/db_interface.c,v retrieving revision 1.75 diff -u -r1.75 db_interface.c --- amd64/amd64/db_interface.c 17 Nov 2003 08:58:12 -0000 1.75 +++ amd64/amd64/db_interface.c 4 Feb 2004 18:57:33 -0000 @@ -87,7 +87,7 @@ * 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 @@ * 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)) { Index: dev/syscons/syscons.c =================================================================== RCS file: /home/ncvs/src/sys/dev/syscons/syscons.c,v retrieving revision 1.410 diff -u -r1.410 syscons.c --- dev/syscons/syscons.c 21 Jan 2004 05:08:51 -0000 1.410 +++ dev/syscons/syscons.c 4 Feb 2004 20:03:59 -0000 @@ -97,6 +97,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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_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 @@ 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 @@ 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); Index: i386/i386/db_interface.c =================================================================== RCS file: /home/ncvs/src/sys/i386/i386/db_interface.c,v retrieving revision 1.77 diff -u -r1.77 db_interface.c --- i386/i386/db_interface.c 8 Nov 2003 03:01:26 -0000 1.77 +++ i386/i386/db_interface.c 4 Feb 2004 18:58:25 -0000 @@ -90,7 +90,7 @@ * 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 @@ * 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)) { Index: i386/isa/pcvt/pcvt_drv.c =================================================================== RCS file: /home/ncvs/src/sys/i386/isa/pcvt/pcvt_drv.c,v retrieving revision 1.80 diff -u -r1.80 pcvt_drv.c --- i386/isa/pcvt/pcvt_drv.c 26 Sep 2003 08:51:54 -0000 1.80 +++ i386/isa/pcvt/pcvt_drv.c 4 Feb 2004 20:08:45 -0000 @@ -673,6 +673,7 @@ int i; pcvt_is_console = 1; + pcvt_consptr = cp; /* * Don't reset the keyboard via `kbdio' just yet. Index: i386/isa/pcvt/pcvt_ext.c =================================================================== RCS file: /home/ncvs/src/sys/i386/isa/pcvt/pcvt_ext.c,v retrieving revision 1.30 diff -u -r1.30 pcvt_ext.c --- i386/isa/pcvt/pcvt_ext.c 7 Jan 2004 10:12:59 -0000 1.30 +++ i386/isa/pcvt/pcvt_ext.c 4 Feb 2004 20:13:04 -0000 @@ -2385,7 +2385,7 @@ * process mode. */ if(pcvt_is_console) - cons_unavail = 0; + cnavaiable(pcvt_consptr, TRUE); } } return 0; @@ -2470,7 +2470,7 @@ * 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 @@ /* XXX */ if(pcvt_is_console) - cons_unavail = 0; + cnavailable(pcvt_consptr, TRUE); } return 0; } @@ -2563,7 +2563,7 @@ /* XXX */ if(pcvt_is_console) - cons_unavail = 1; + cnavailable(pcvt_consptr, FALSE); return 0; } Index: i386/isa/pcvt/pcvt_hdr.h =================================================================== RCS file: /home/ncvs/src/sys/i386/isa/pcvt/pcvt_hdr.h,v retrieving revision 1.48 diff -u -r1.48 pcvt_hdr.h --- i386/isa/pcvt/pcvt_hdr.h 27 Jul 2003 14:01:33 -0000 1.48 +++ i386/isa/pcvt/pcvt_hdr.h 4 Feb 2004 20:11:41 -0000 @@ -763,6 +763,7 @@ 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 kbd_polling; extern u_char reset_keyboard; extern keyboard_t *kbd; +extern struct consdev *pcvt_consptr; #if PCVT_SHOWKEYS extern u_char keyboard_show; Index: kern/tty_cons.c =================================================================== RCS file: /home/ncvs/src/sys/kern/tty_cons.c,v retrieving revision 1.118 diff -u -r1.118 tty_cons.c --- kern/tty_cons.c 18 Oct 2003 12:16:17 -0000 1.118 +++ kern/tty_cons.c 4 Feb 2004 20:55:32 -0000 @@ -110,9 +110,10 @@ 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 @@ 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 @@ 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 @@ 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 @@ -256,6 +269,32 @@ STAILQ_INSERT_HEAD(&cn_devlist, cnd, cnd_next); return; } +} + +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 Index: sys/cons.h =================================================================== RCS file: /home/ncvs/src/sys/sys/cons.h,v retrieving revision 1.33 diff -u -r1.33 cons.h --- sys/cons.h 18 Oct 2003 02:13:39 -0000 1.33 +++ sys/cons.h 4 Feb 2004 20:16:21 -0000 @@ -83,9 +83,9 @@ /* 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 @@ 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 */