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.
This commit is contained in:
parent
668329e94b
commit
e99c09e2dc
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=125467
@ -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)) {
|
||||
|
@ -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);
|
||||
|
@ -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)) {
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
@ -258,6 +271,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)
|
||||
{
|
||||
|
@ -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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user