vt_core.c (278106) | vt_core.c (282749) |
---|---|
1/*- 2 * Copyright (c) 2009, 2013 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Ed Schouten under sponsorship from the 6 * FreeBSD Foundation. 7 * 8 * Portions of this software were developed by Oleksandr Rybalko --- 17 unchanged lines hidden (view full) --- 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2009, 2013 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Ed Schouten under sponsorship from the 6 * FreeBSD Foundation. 7 * 8 * Portions of this software were developed by Oleksandr Rybalko --- 17 unchanged lines hidden (view full) --- 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: stable/10/sys/dev/vt/vt_core.c 278106 2015-02-02 18:48:49Z delphij $"); | 34__FBSDID("$FreeBSD: stable/10/sys/dev/vt/vt_core.c 282749 2015-05-11 08:00:16Z avg $"); |
35 36#include "opt_compat.h" 37 38#include <sys/param.h> 39#include <sys/consio.h> 40#include <sys/eventhandler.h> 41#include <sys/fbio.h> 42#include <sys/kbio.h> --- 118 unchanged lines hidden (view full) --- 161static int vt_window_switch(struct vt_window *); 162static int vt_late_window_switch(struct vt_window *); 163static int vt_proc_alive(struct vt_window *); 164static void vt_resize(struct vt_device *); 165static void vt_update_static(void *); 166#ifndef SC_NO_CUTPASTE 167static void vt_mouse_paste(void); 168#endif | 35 36#include "opt_compat.h" 37 38#include <sys/param.h> 39#include <sys/consio.h> 40#include <sys/eventhandler.h> 41#include <sys/fbio.h> 42#include <sys/kbio.h> --- 118 unchanged lines hidden (view full) --- 161static int vt_window_switch(struct vt_window *); 162static int vt_late_window_switch(struct vt_window *); 163static int vt_proc_alive(struct vt_window *); 164static void vt_resize(struct vt_device *); 165static void vt_update_static(void *); 166#ifndef SC_NO_CUTPASTE 167static void vt_mouse_paste(void); 168#endif |
169static void vt_suspend_handler(void *priv); 170static void vt_resume_handler(void *priv); |
|
169 170SET_DECLARE(vt_drv_set, struct vt_driver); 171 172#define _VTDEFH MAX(100, PIXEL_HEIGHT(VT_FB_DEFAULT_HEIGHT)) 173#define _VTDEFW MAX(200, PIXEL_WIDTH(VT_FB_DEFAULT_WIDTH)) 174 175static struct terminal vt_consterm; 176static struct vt_window vt_conswindow; --- 2325 unchanged lines hidden (view full) --- 2502 return (vw); 2503} 2504 2505void 2506vt_upgrade(struct vt_device *vd) 2507{ 2508 struct vt_window *vw; 2509 unsigned int i; | 171 172SET_DECLARE(vt_drv_set, struct vt_driver); 173 174#define _VTDEFH MAX(100, PIXEL_HEIGHT(VT_FB_DEFAULT_HEIGHT)) 175#define _VTDEFW MAX(200, PIXEL_WIDTH(VT_FB_DEFAULT_WIDTH)) 176 177static struct terminal vt_consterm; 178static struct vt_window vt_conswindow; --- 2325 unchanged lines hidden (view full) --- 2504 return (vw); 2505} 2506 2507void 2508vt_upgrade(struct vt_device *vd) 2509{ 2510 struct vt_window *vw; 2511 unsigned int i; |
2512 int register_handlers; |
|
2510 2511 if (!vty_enabled(VTY_VT)) 2512 return; 2513 if (main_vd->vd_driver == NULL) 2514 return; 2515 2516 for (i = 0; i < VT_MAXWINDOWS; i++) { 2517 vw = vd->vd_windows[i]; --- 12 unchanged lines hidden (view full) --- 2530 } 2531 } 2532 2533 } 2534 VT_LOCK(vd); 2535 if (vd->vd_curwindow == NULL) 2536 vd->vd_curwindow = vd->vd_windows[VT_CONSWINDOW]; 2537 | 2513 2514 if (!vty_enabled(VTY_VT)) 2515 return; 2516 if (main_vd->vd_driver == NULL) 2517 return; 2518 2519 for (i = 0; i < VT_MAXWINDOWS; i++) { 2520 vw = vd->vd_windows[i]; --- 12 unchanged lines hidden (view full) --- 2533 } 2534 } 2535 2536 } 2537 VT_LOCK(vd); 2538 if (vd->vd_curwindow == NULL) 2539 vd->vd_curwindow = vd->vd_windows[VT_CONSWINDOW]; 2540 |
2541 register_handlers = 0; |
|
2538 if (!(vd->vd_flags & VDF_ASYNC)) { 2539 /* Attach keyboard. */ 2540 vt_allocate_keyboard(vd); 2541 2542 /* Init 25 Hz timer. */ 2543 callout_init_mtx(&vd->vd_timer, &vd->vd_lock, 0); 2544 2545 /* Start timer when everything ready. */ 2546 vd->vd_flags |= VDF_ASYNC; 2547 callout_reset(&vd->vd_timer, hz / VT_TIMERFREQ, vt_timer, vd); 2548 vd->vd_timer_armed = 1; | 2542 if (!(vd->vd_flags & VDF_ASYNC)) { 2543 /* Attach keyboard. */ 2544 vt_allocate_keyboard(vd); 2545 2546 /* Init 25 Hz timer. */ 2547 callout_init_mtx(&vd->vd_timer, &vd->vd_lock, 0); 2548 2549 /* Start timer when everything ready. */ 2550 vd->vd_flags |= VDF_ASYNC; 2551 callout_reset(&vd->vd_timer, hz / VT_TIMERFREQ, vt_timer, vd); 2552 vd->vd_timer_armed = 1; |
2553 register_handlers = 1; |
|
2549 } 2550 2551 VT_UNLOCK(vd); 2552 2553 /* Refill settings with new sizes. */ 2554 vt_resize(vd); | 2554 } 2555 2556 VT_UNLOCK(vd); 2557 2558 /* Refill settings with new sizes. */ 2559 vt_resize(vd); |
2560 2561 if (register_handlers) { 2562 /* Register suspend/resume handlers. */ 2563 EVENTHANDLER_REGISTER(power_suspend, vt_suspend_handler, vd, 2564 EVENTHANDLER_PRI_ANY); 2565 EVENTHANDLER_REGISTER(power_resume, vt_resume_handler, vd, 2566 EVENTHANDLER_PRI_ANY); 2567 } |
|
2555} 2556 2557static void 2558vt_resize(struct vt_device *vd) 2559{ 2560 struct vt_window *vw; 2561 int i; 2562 --- 81 unchanged lines hidden (view full) --- 2644 2645 /* 2646 * Register as console. If it already registered, cnadd() will ignore 2647 * it. 2648 */ 2649 termcn_cnregister(vd->vd_windows[VT_CONSWINDOW]->vw_terminal); 2650} 2651 | 2568} 2569 2570static void 2571vt_resize(struct vt_device *vd) 2572{ 2573 struct vt_window *vw; 2574 int i; 2575 --- 81 unchanged lines hidden (view full) --- 2657 2658 /* 2659 * Register as console. If it already registered, cnadd() will ignore 2660 * it. 2661 */ 2662 termcn_cnregister(vd->vd_windows[VT_CONSWINDOW]->vw_terminal); 2663} 2664 |
2665static void 2666vt_suspend_handler(void *priv) 2667{ 2668 struct vt_device *vd; 2669 2670 vd = priv; 2671 if (vd->vd_driver != NULL && vd->vd_driver->vd_suspend != NULL) 2672 vd->vd_driver->vd_suspend(vd); 2673} 2674 2675static void 2676vt_resume_handler(void *priv) 2677{ 2678 struct vt_device *vd; 2679 2680 vd = priv; 2681 if (vd->vd_driver != NULL && vd->vd_driver->vd_resume != NULL) 2682 vd->vd_driver->vd_resume(vd); 2683} 2684 |
|
2652void | 2685void |
2653vt_suspend() | 2686vt_suspend(struct vt_device *vd) |
2654{ | 2687{ |
2688 int error; |
|
2655 2656 if (vt_suspendswitch == 0) 2657 return; 2658 /* Save current window. */ | 2689 2690 if (vt_suspendswitch == 0) 2691 return; 2692 /* Save current window. */ |
2659 main_vd->vd_savedwindow = main_vd->vd_curwindow; | 2693 vd->vd_savedwindow = vd->vd_curwindow; |
2660 /* Ask holding process to free window and switch to console window */ | 2694 /* Ask holding process to free window and switch to console window */ |
2661 vt_proc_window_switch(main_vd->vd_windows[VT_CONSWINDOW]); | 2695 vt_proc_window_switch(vd->vd_windows[VT_CONSWINDOW]); 2696 2697 /* Wait for the window switch to complete. */ 2698 error = 0; 2699 VT_LOCK(vd); 2700 while (vd->vd_curwindow != vd->vd_windows[VT_CONSWINDOW] && error == 0) 2701 error = cv_wait_sig(&vd->vd_winswitch, &vd->vd_lock); 2702 VT_UNLOCK(vd); |
2662} 2663 2664void | 2703} 2704 2705void |
2665vt_resume() | 2706vt_resume(struct vt_device *vd) |
2666{ 2667 2668 if (vt_suspendswitch == 0) 2669 return; 2670 /* Switch back to saved window */ | 2707{ 2708 2709 if (vt_suspendswitch == 0) 2710 return; 2711 /* Switch back to saved window */ |
2671 if (main_vd->vd_savedwindow != NULL) 2672 vt_proc_window_switch(main_vd->vd_savedwindow); 2673 main_vd->vd_savedwindow = NULL; | 2712 if (vd->vd_savedwindow != NULL) 2713 vt_proc_window_switch(vd->vd_savedwindow); 2714 vd->vd_savedwindow = NULL; |
2674} | 2715} |