From c36146f4cfea03d5d61bbe4851f4a0d80845c5cf Mon Sep 17 00:00:00 2001 From: ray Date: Mon, 14 Apr 2014 12:40:37 +0000 Subject: [PATCH] MFC 264242,264244,264259 Fix panic on load new driver while vt(4) is in VGA textmode. o Mute terminal while vt(4) driver change in progress. o Reset VDF_TEXTMODE before init new driver. o Assign default font, if new driver is not in TEXTMODE. o Do not update screen while driver changing. o Unmute terminal when done with driver replacement. o Move init fonts to early point. o Minor cleanup. o Do not fill screen, while muted. (kern/subr_terminal.c) Sponsored by: The FreeBSD Foundation git-svn-id: svn://svn.freebsd.org/base/stable/10@264455 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/vt/vt_core.c | 36 +++++++++++++++++++++++++++++++----- sys/kern/subr_terminal.c | 2 +- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index b21b42e1e..0cf029291 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -705,8 +705,8 @@ vt_bitblt_char(struct vt_device *vd, struct vt_font *vf, term_char_t c, static void vt_flush(struct vt_device *vd) { - struct vt_window *vw = vd->vd_curwindow; - struct vt_font *vf = vw->vw_font; + struct vt_window *vw; + struct vt_font *vf; struct vt_bufmask tmask; unsigned int row, col; term_rect_t tarea; @@ -717,6 +717,13 @@ vt_flush(struct vt_device *vd) int bpl, h, w; #endif + vw = vd->vd_curwindow; + if (vw == NULL) + return; + vf = vw->vw_font; + if (((vd->vd_flags & VDF_TEXTMODE) == 0) && (vf == NULL)) + return; + if (vd->vd_flags & VDF_SPLASH || vw->vw_flags & VWF_BUSY) return; @@ -794,6 +801,7 @@ vt_timer(void *arg) vd = arg; /* Update screen if required. */ vt_flush(vd); + /* Schedule for next update. */ callout_schedule(&vd->vd_timer, hz / VT_TIMERFREQ); } @@ -1882,6 +1890,7 @@ vt_upgrade(struct vt_device *vd) vt_window_switch, vw, SHUTDOWN_PRI_DEFAULT); } terminal_maketty(vw->vw_terminal, "v%r", VT_UNIT(vw)); + } if (vd->vd_curwindow == NULL) vd->vd_curwindow = vd->vd_windows[VT_CONSWINDOW]; @@ -1902,6 +1911,9 @@ vt_resize(struct vt_device *vd) for (i = 0; i < VT_MAXWINDOWS; i++) { vw = vd->vd_windows[i]; + /* Assign default font to window, if not textmode. */ + if (!(vd->vd_flags & VDF_TEXTMODE) && vw->vw_font == NULL) + vw->vw_font = vtfont_ref(&vt_font_default); /* Resize terminal windows */ vt_change_font(vw, vw->vw_font); } @@ -1933,9 +1945,21 @@ vt_allocate(struct vt_driver *drv, void *softc) if (drv->vd_maskbitbltchr == NULL) drv->vd_maskbitbltchr = drv->vd_bitbltchr; - /* Stop vt_flush periodic task. */ - if (vd->vd_curwindow != NULL) + if (vd->vd_flags & VDF_ASYNC) { + /* Stop vt_flush periodic task. */ callout_drain(&vd->vd_timer); + /* + * Mute current terminal until we done. vt_change_font (called + * from vt_resize) will unmute it. + */ + terminal_mute(vd->vd_curwindow->vw_terminal, 1); + } + + /* + * Reset VDF_TEXTMODE flag, driver who require that flag (vt_vga) will + * set it. + */ + vd->vd_flags &= ~VDF_TEXTMODE; vd->vd_driver = drv; vd->vd_softc = softc; @@ -1951,8 +1975,10 @@ vt_allocate(struct vt_driver *drv, void *softc) vtterm_splash(vd); #endif - if (vd->vd_curwindow != NULL) + if (vd->vd_flags & VDF_ASYNC) { + terminal_mute(vd->vd_curwindow->vw_terminal, 0); callout_schedule(&vd->vd_timer, hz / VT_TIMERFREQ); + } termcn_cnregister(vd->vd_windows[VT_CONSWINDOW]->vw_terminal); diff --git a/sys/kern/subr_terminal.c b/sys/kern/subr_terminal.c index a3ccbaa82..5f8ffec7e 100644 --- a/sys/kern/subr_terminal.c +++ b/sys/kern/subr_terminal.c @@ -208,7 +208,7 @@ terminal_set_winsize_blank(struct terminal *tm, const struct winsize *size, teken_set_winsize(&tm->tm_emulator, &r.tr_end); TERMINAL_UNLOCK(tm); - if (blank != 0) + if ((blank != 0) && !(tm->tm_flags & TF_MUTE)) tm->tm_class->tc_fill(tm, &r, TCHAR_CREATE((teken_char_t)' ', &default_message)); -- 2.45.0