Index: vt.h =================================================================== --- vt.h (revision 266880) +++ vt.h (working copy) @@ -259,6 +259,7 @@ #define VWF_CONSOLE 0x8 /* Kernel message console window. */ #define VWF_VTYLOCK 0x10 /* Prevent window switch. */ #define VWF_MOUSE_HIDE 0x20 /* Disable mouse events processing. */ +#define VWF_READY 0x40 /* Window fully initialized. */ #define VWF_SWWAIT_REL 0x10000 /* Program wait for VT acquire is done. */ #define VWF_SWWAIT_ACQ 0x20000 /* Program wait for VT release is done. */ pid_t vw_pid; /* Terminal holding process */ Index: vt_core.c =================================================================== --- vt_core.c (revision 266880) +++ vt_core.c (working copy) @@ -120,9 +120,10 @@ VT_SYSCTL_INT(deadtimer, 15, "Time to wait busy process in VT_PROCESS mode"); VT_SYSCTL_INT(suspendswitch, 1, "Switch to VT0 before suspend"); +static struct vt_device vt_consdev; static unsigned int vt_unit = 0; static MALLOC_DEFINE(M_VT, "vt", "vt device"); -struct vt_device *main_vd = NULL; +struct vt_device *main_vd = &vt_consdev; /* Boot logo. */ extern unsigned int vt_logo_width; @@ -214,12 +215,16 @@ vt_update_static(void *dummy) { - if (main_vd != NULL) { - printf("VT: running with driver \"%s\".\n", - main_vd->vd_driver->vd_name); +// if (main_vd != NULL) { + if (main_vd->vd_driver != NULL) + printf("VT: running with driver \"%s\".\n", + main_vd->vd_driver->vd_name); + else + printf("VT: init without driver.\n"); + mtx_init(&main_vd->vd_lock, "vtdev", NULL, MTX_DEF); cv_init(&main_vd->vd_winswitch, "vtwswt"); - } +// } } static void @@ -970,15 +975,17 @@ if (vtdbest == NULL) { cp->cn_pri = CN_DEAD; vd->vd_flags |= VDF_DEAD; - return; +// return; } - vd->vd_driver = vtdbest; + if (vtdbest != NULL) { + vd->vd_driver = vtdbest; + cp->cn_pri = vd->vd_driver->vd_init(vd); + } - cp->cn_pri = vd->vd_driver->vd_init(vd); if (cp->cn_pri == CN_DEAD) { vd->vd_flags |= VDF_DEAD; - return; +// return; } /* Initialize any early-boot keyboard drivers */ @@ -995,12 +1002,14 @@ vt_winsize(vd, vw->vw_font, &wsz); terminal_set_winsize(tm, &wsz); + if (vtdbest != NULL) { #ifdef DEV_SPLASH - vtterm_splash(vd); + vtterm_splash(vd); #endif - vd->vd_flags |= VDF_INITIALIZED; - main_vd = vd; + vd->vd_flags |= VDF_INITIALIZED; + } +// main_vd = vd; } static int @@ -1988,28 +1997,27 @@ unsigned int i; /* Device didn't pass vd_init() or already upgraded. */ - if (vd->vd_flags & (VDF_ASYNC|VDF_DEAD)) { - /* Refill settings with new sizes anyway. */ - vt_resize(vd); - return; - } - vd->vd_flags |= VDF_ASYNC; - +// if (vd->vd_flags & (VDF_ASYNC|VDF_DEAD)) { +// /* Refill settings with new sizes anyway. */ +// vt_resize(vd); +// return; +// } for (i = 0; i < VT_MAXWINDOWS; i++) { vw = vd->vd_windows[i]; if (vw == NULL) { /* New window. */ vw = vt_allocate_window(vd, i); - } else if (vw->vw_flags & VWF_CONSOLE) { - /* For existing console window. */ + } + if (!(vw->vw_flags & VWF_READY)) { callout_init(&vw->vw_proc_dead_timer, 0); + terminal_maketty(vw->vw_terminal, "v%r", VT_UNIT(vw)); + vw->vw_flags |= VWF_READY; + if (vw->vw_flags & VWF_CONSOLE) { + /* For existing console window. */ + EVENTHANDLER_REGISTER(shutdown_pre_sync, + vt_window_switch, vw, SHUTDOWN_PRI_DEFAULT); + } } - if (i == VT_CONSWINDOW) { - /* Console window. */ - EVENTHANDLER_REGISTER(shutdown_pre_sync, - vt_window_switch, vw, SHUTDOWN_PRI_DEFAULT); - } - terminal_maketty(vw->vw_terminal, "v%r", VT_UNIT(vw)); } VT_LOCK(vd); @@ -2020,11 +2028,15 @@ vt_allocate_keyboard(vd); DPRINTF(20, "%s: vd_keyboard = %d\n", __func__, vd->vd_keyboard); - /* Init 25 Hz timer. */ - callout_init_mtx(&vd->vd_timer, &vd->vd_lock, 0); + if (!(vd->vd_flags & VDF_ASYNC)) { + /* Init 25 Hz timer. */ + callout_init_mtx(&vd->vd_timer, &vd->vd_lock, 0); - /* Start timer when everything ready. */ - callout_reset(&vd->vd_timer, hz / VT_TIMERFREQ, vt_timer, vd); + /* Start timer when everything ready. */ + vd->vd_flags |= VDF_ASYNC; + callout_reset(&vd->vd_timer, hz / VT_TIMERFREQ, vt_timer, vd); + } + VT_UNLOCK(vd); /* Refill settings with new sizes. */ @@ -2055,18 +2067,24 @@ struct vt_device *vd; struct winsize wsz; - if (main_vd == NULL) { - main_vd = malloc(sizeof *vd, M_VT, M_WAITOK|M_ZERO); - printf("VT: initialize with new VT driver \"%s\".\n", - drv->vd_name); - mtx_init(&main_vd->vd_lock, "vtdev", NULL, MTX_DEF); - cv_init(&main_vd->vd_winswitch, "vtwswt"); - - } else { +// if (main_vd == NULL) { +// main_vd = malloc(sizeof *vd, M_VT, M_WAITOK|M_ZERO); +// printf("VT: initialize with new VT driver \"%s\".\n", +// drv->vd_name); +// mtx_init(&main_vd->vd_lock, "vtdev", NULL, MTX_DEF); +// cv_init(&main_vd->vd_winswitch, "vtwswt"); +// +// } else { /* * Check if have rights to replace current driver. For example: * it is bad idea to replace KMS driver with generic VGA one. */ + if (main_vd->vd_driver == NULL) { + main_vd->vd_driver = drv; + printf("VT: initialize with new VT driver \"%s\".\n", + drv->vd_name); + } else { + if (drv->vd_priority <= main_vd->vd_driver->vd_priority) { printf("VT: Driver priority %d too low. Current %d\n ", drv->vd_priority, main_vd->vd_driver->vd_priority); @@ -2075,6 +2093,8 @@ printf("VT: Replacing driver \"%s\" with new \"%s\".\n", main_vd->vd_driver->vd_name, drv->vd_name); } + +// } vd = main_vd; VT_LOCK(vd); if (drv->vd_maskbitbltchr == NULL)