Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/vt/vt_core.c
Show First 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | |||||
static int vt_window_switch(struct vt_window *); | static int vt_window_switch(struct vt_window *); | ||||
static int vt_late_window_switch(struct vt_window *); | static int vt_late_window_switch(struct vt_window *); | ||||
static int vt_proc_alive(struct vt_window *); | static int vt_proc_alive(struct vt_window *); | ||||
static void vt_resize(struct vt_device *); | static void vt_resize(struct vt_device *); | ||||
static void vt_update_static(void *); | static void vt_update_static(void *); | ||||
#ifndef SC_NO_CUTPASTE | #ifndef SC_NO_CUTPASTE | ||||
static void vt_mouse_paste(void); | static void vt_mouse_paste(void); | ||||
#endif | #endif | ||||
static void vt_suspend_handler(void *priv); | |||||
static void vt_resume_handler(void *priv); | |||||
SET_DECLARE(vt_drv_set, struct vt_driver); | SET_DECLARE(vt_drv_set, struct vt_driver); | ||||
#define _VTDEFH MAX(100, PIXEL_HEIGHT(VT_FB_DEFAULT_HEIGHT)) | #define _VTDEFH MAX(100, PIXEL_HEIGHT(VT_FB_DEFAULT_HEIGHT)) | ||||
#define _VTDEFW MAX(200, PIXEL_WIDTH(VT_FB_DEFAULT_WIDTH)) | #define _VTDEFW MAX(200, PIXEL_WIDTH(VT_FB_DEFAULT_WIDTH)) | ||||
static struct terminal vt_consterm; | static struct terminal vt_consterm; | ||||
static struct vt_window vt_conswindow; | static struct vt_window vt_conswindow; | ||||
▲ Show 20 Lines • Show All 2,360 Lines • ▼ Show 20 Lines | if (!(vd->vd_flags & VDF_ASYNC)) { | ||||
/* Init 25 Hz timer. */ | /* Init 25 Hz timer. */ | ||||
callout_init_mtx(&vd->vd_timer, &vd->vd_lock, 0); | callout_init_mtx(&vd->vd_timer, &vd->vd_lock, 0); | ||||
/* Start timer when everything ready. */ | /* Start timer when everything ready. */ | ||||
vd->vd_flags |= VDF_ASYNC; | vd->vd_flags |= VDF_ASYNC; | ||||
callout_reset(&vd->vd_timer, hz / VT_TIMERFREQ, vt_timer, vd); | callout_reset(&vd->vd_timer, hz / VT_TIMERFREQ, vt_timer, vd); | ||||
vd->vd_timer_armed = 1; | vd->vd_timer_armed = 1; | ||||
/* Register suspend/resume handlers. */ | |||||
EVENTHANDLER_REGISTER(power_suspend, vt_suspend_handler, vd, | |||||
EVENTHANDLER_PRI_ANY); | |||||
EVENTHANDLER_REGISTER(power_resume, vt_resume_handler, vd, | |||||
EVENTHANDLER_PRI_ANY); | |||||
} | } | ||||
VT_UNLOCK(vd); | VT_UNLOCK(vd); | ||||
/* Refill settings with new sizes. */ | /* Refill settings with new sizes. */ | ||||
vt_resize(vd); | vt_resize(vd); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | #endif | ||||
/* | /* | ||||
* Register as console. If it already registered, cnadd() will ignore | * Register as console. If it already registered, cnadd() will ignore | ||||
* it. | * it. | ||||
*/ | */ | ||||
termcn_cnregister(vd->vd_windows[VT_CONSWINDOW]->vw_terminal); | termcn_cnregister(vd->vd_windows[VT_CONSWINDOW]->vw_terminal); | ||||
} | } | ||||
static void | |||||
vt_suspend_handler(void *priv) | |||||
{ | |||||
struct vt_device *vd; | |||||
vd = priv; | |||||
if (vd->vd_driver != NULL && vd->vd_driver->vd_suspend != NULL) | |||||
vd->vd_driver->vd_suspend(vd); | |||||
} | |||||
static void | |||||
vt_resume_handler(void *priv) | |||||
{ | |||||
struct vt_device *vd; | |||||
vd = priv; | |||||
if (vd->vd_driver != NULL && vd->vd_driver->vd_resume != NULL) | |||||
vd->vd_driver->vd_resume(vd); | |||||
} | |||||
void | void | ||||
vt_suspend() | vt_suspend(struct vt_device *vd) | ||||
{ | { | ||||
int error; | |||||
if (vt_suspendswitch == 0) | if (vt_suspendswitch == 0) | ||||
return; | return; | ||||
/* Save current window. */ | /* Save current window. */ | ||||
main_vd->vd_savedwindow = main_vd->vd_curwindow; | vd->vd_savedwindow = vd->vd_curwindow; | ||||
/* Ask holding process to free window and switch to console window */ | /* Ask holding process to free window and switch to console window */ | ||||
vt_proc_window_switch(main_vd->vd_windows[VT_CONSWINDOW]); | vt_proc_window_switch(vd->vd_windows[VT_CONSWINDOW]); | ||||
/* Wait for the window switch to complete. */ | |||||
error = 0; | |||||
VT_LOCK(vd); | |||||
while (vd->vd_curwindow != vd->vd_windows[VT_CONSWINDOW] && error == 0) | |||||
error = cv_wait_sig(&vd->vd_winswitch, &vd->vd_lock); | |||||
VT_UNLOCK(vd); | |||||
} | } | ||||
void | void | ||||
vt_resume() | vt_resume(struct vt_device *vd) | ||||
{ | { | ||||
if (vt_suspendswitch == 0) | if (vt_suspendswitch == 0) | ||||
return; | return; | ||||
/* Switch back to saved window */ | /* Switch back to saved window */ | ||||
if (main_vd->vd_savedwindow != NULL) | if (vd->vd_savedwindow != NULL) | ||||
vt_proc_window_switch(main_vd->vd_savedwindow); | vt_proc_window_switch(vd->vd_savedwindow); | ||||
main_vd->vd_savedwindow = NULL; | vd->vd_savedwindow = NULL; | ||||
} | } |