Restructure the grabbing functions into mere wrappers of new open and

close functions.  Scattered calls to sc_cnputc() and sc_cngetc() were
broken by turning the semi-reentrant inline context-switching code in
these functions into the grabbing functions.  cncheckc() calls for
panic dumps are the main broken case.  The grabbing functions have
special behaviour (mainly screen switching in sc_cngrab()) which makes
them unsuitable as replacements for the inline code.
This commit is contained in:
Bruce Evans 2016-08-15 19:37:18 +00:00
parent 2f514f92cf
commit 43e5b7b6b3

View file

@ -1645,8 +1645,12 @@ sc_cnterm(struct consdev *cp)
sc_console = NULL;
}
struct sc_cnstate; /* not used yet */
static void sccnclose(sc_softc_t *sc, struct sc_cnstate *sp);
static void sccnopen(sc_softc_t *sc, struct sc_cnstate *sp, int flags);
static void
sc_cngrab(struct consdev *cp)
sccnopen(sc_softc_t *sc, struct sc_cnstate *sp, int flags)
{
scr_stat *scp;
int kbd_mode;
@ -1662,9 +1666,6 @@ sc_cngrab(struct consdev *cp)
if (scp->sc->kbd == NULL)
return;
if (scp->sc->grab_level++ > 0)
return;
/*
* Make sure the keyboard is accessible even when the kbd device
* driver is disabled.
@ -1678,7 +1679,7 @@ sc_cngrab(struct consdev *cp)
}
static void
sc_cnungrab(struct consdev *cp)
sccnclose(sc_softc_t *sc, struct sc_cnstate *sp)
{
scr_stat *scp;
@ -1686,9 +1687,6 @@ sc_cnungrab(struct consdev *cp)
if (scp->sc->kbd == NULL)
return;
if (--scp->sc->grab_level > 0)
return;
/* Restore keyboard mode (for the current, possibly-changed scp). */
kbdd_poll(scp->sc->kbd, FALSE);
(void)kbdd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
@ -1696,6 +1694,26 @@ sc_cnungrab(struct consdev *cp)
kbdd_disable(scp->sc->kbd);
}
static void
sc_cngrab(struct consdev *cp)
{
sc_softc_t *sc;
sc = sc_console->sc;
if (sc->grab_level++ == 0)
sccnopen(sc, NULL, 0);
}
static void
sc_cnungrab(struct consdev *cp)
{
sc_softc_t *sc;
sc = sc_console->sc;
if (--sc->grab_level == 0)
sccnclose(sc, NULL);
}
static void
sc_cnputc(struct consdev *cd, int c)
{