vt_core.c (285765) | vt_core.c (285766) |
---|---|
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: head/sys/dev/vt/vt_core.c 285765 2015-07-21 20:30:06Z cem $"); | 34__FBSDID("$FreeBSD: head/sys/dev/vt/vt_core.c 285766 2015-07-21 20:33:36Z cem $"); |
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> --- 65 unchanged lines hidden (view full) --- 108 * really slows down the system. 109 */ 110#define VT_TIMERFREQ 25 111 112/* Bell pitch/duration. */ 113#define VT_BELLDURATION ((5 * hz + 99) / 100) 114#define VT_BELLPITCH 800 115 | 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> --- 65 unchanged lines hidden (view full) --- 108 * really slows down the system. 109 */ 110#define VT_TIMERFREQ 25 111 112/* Bell pitch/duration. */ 113#define VT_BELLDURATION ((5 * hz + 99) / 100) 114#define VT_BELLPITCH 800 115 |
116#define VT_LOCK(vd) mtx_lock(&(vd)->vd_lock) 117#define VT_UNLOCK(vd) mtx_unlock(&(vd)->vd_lock) 118#define VT_LOCK_ASSERT(vd, what) mtx_assert(&(vd)->vd_lock, what) 119 | |
120#define VT_UNIT(vw) ((vw)->vw_device->vd_unit * VT_MAXWINDOWS + \ 121 (vw)->vw_number) 122 123static SYSCTL_NODE(_kern, OID_AUTO, vt, CTLFLAG_RD, 0, "vt(9) parameters"); 124static VT_SYSCTL_INT(enable_altgr, 1, "Enable AltGr key (Do not assume R.Alt as Alt)"); 125static VT_SYSCTL_INT(enable_bell, 1, "Enable bell"); 126static VT_SYSCTL_INT(debug, 0, "vt(9) debug level"); 127static VT_SYSCTL_INT(deadtimer, 15, "Time to wait busy process in VT_PROCESS mode"); --- 6 unchanged lines hidden (view full) --- 134 "See kbdmap(5) to configure."); 135static VT_SYSCTL_INT(kbd_reboot, 1, "Enable reboot keyboard combination. " 136 "See kbdmap(5) to configure (typically Ctrl-Alt-Delete)."); 137static VT_SYSCTL_INT(kbd_debug, 1, "Enable key combination to enter debugger. " 138 "See kbdmap(5) to configure (typically Ctrl-Alt-Esc)."); 139static VT_SYSCTL_INT(kbd_panic, 0, "Enable request to panic. " 140 "See kbdmap(5) to configure."); 141 | 116#define VT_UNIT(vw) ((vw)->vw_device->vd_unit * VT_MAXWINDOWS + \ 117 (vw)->vw_number) 118 119static SYSCTL_NODE(_kern, OID_AUTO, vt, CTLFLAG_RD, 0, "vt(9) parameters"); 120static VT_SYSCTL_INT(enable_altgr, 1, "Enable AltGr key (Do not assume R.Alt as Alt)"); 121static VT_SYSCTL_INT(enable_bell, 1, "Enable bell"); 122static VT_SYSCTL_INT(debug, 0, "vt(9) debug level"); 123static VT_SYSCTL_INT(deadtimer, 15, "Time to wait busy process in VT_PROCESS mode"); --- 6 unchanged lines hidden (view full) --- 130 "See kbdmap(5) to configure."); 131static VT_SYSCTL_INT(kbd_reboot, 1, "Enable reboot keyboard combination. " 132 "See kbdmap(5) to configure (typically Ctrl-Alt-Delete)."); 133static VT_SYSCTL_INT(kbd_debug, 1, "Enable key combination to enter debugger. " 134 "See kbdmap(5) to configure (typically Ctrl-Alt-Esc)."); 135static VT_SYSCTL_INT(kbd_panic, 0, "Enable request to panic. " 136 "See kbdmap(5) to configure."); 137 |
138/* Used internally, not a tunable. */ 139int vt_draw_logo_cpus; 140VT_SYSCTL_INT(splash_cpu, 1, "Show logo CPUs during boot"); 141VT_SYSCTL_INT(splash_ncpu, 0, "Override number of logos displayed " 142 "(0 = do not override)"); 143VT_SYSCTL_INT(splash_cpu_style, 1, "Draw logo style " 144 "(0=Beastie, 1=Alternate beastie, 2=Orb)"); 145VT_SYSCTL_INT(splash_cpu_duration, 10, "Hide logos after (seconds)"); 146 |
|
142static struct vt_device vt_consdev; 143static unsigned int vt_unit = 0; 144static MALLOC_DEFINE(M_VT, "vt", "vt device"); 145struct vt_device *main_vd = &vt_consdev; 146 147/* Boot logo. */ 148extern unsigned int vt_logo_width; 149extern unsigned int vt_logo_height; --- 21 unchanged lines hidden (view full) --- 171static void vt_suspend_handler(void *priv); 172static void vt_resume_handler(void *priv); 173 174SET_DECLARE(vt_drv_set, struct vt_driver); 175 176#define _VTDEFH MAX(100, PIXEL_HEIGHT(VT_FB_DEFAULT_HEIGHT)) 177#define _VTDEFW MAX(200, PIXEL_WIDTH(VT_FB_DEFAULT_WIDTH)) 178 | 147static struct vt_device vt_consdev; 148static unsigned int vt_unit = 0; 149static MALLOC_DEFINE(M_VT, "vt", "vt device"); 150struct vt_device *main_vd = &vt_consdev; 151 152/* Boot logo. */ 153extern unsigned int vt_logo_width; 154extern unsigned int vt_logo_height; --- 21 unchanged lines hidden (view full) --- 176static void vt_suspend_handler(void *priv); 177static void vt_resume_handler(void *priv); 178 179SET_DECLARE(vt_drv_set, struct vt_driver); 180 181#define _VTDEFH MAX(100, PIXEL_HEIGHT(VT_FB_DEFAULT_HEIGHT)) 182#define _VTDEFW MAX(200, PIXEL_WIDTH(VT_FB_DEFAULT_WIDTH)) 183 |
179static struct terminal vt_consterm; | 184struct terminal vt_consterm; |
180static struct vt_window vt_conswindow; 181static struct vt_device vt_consdev = { 182 .vd_driver = NULL, 183 .vd_softc = NULL, 184 .vd_prev_driver = NULL, 185 .vd_prev_softc = NULL, 186 .vd_flags = VDF_INVALID, 187 .vd_windows = { [VT_CONSWINDOW] = &vt_conswindow, }, --- 30 unchanged lines hidden (view full) --- 218 .tp_col = _VTDEFW, 219 }, 220 }, 221 .vw_device = &vt_consdev, 222 .vw_terminal = &vt_consterm, 223 .vw_kbdmode = K_XLATE, 224 .vw_grabbed = 0, 225}; | 185static struct vt_window vt_conswindow; 186static struct vt_device vt_consdev = { 187 .vd_driver = NULL, 188 .vd_softc = NULL, 189 .vd_prev_driver = NULL, 190 .vd_prev_softc = NULL, 191 .vd_flags = VDF_INVALID, 192 .vd_windows = { [VT_CONSWINDOW] = &vt_conswindow, }, --- 30 unchanged lines hidden (view full) --- 223 .tp_col = _VTDEFW, 224 }, 225 }, 226 .vw_device = &vt_consdev, 227 .vw_terminal = &vt_consterm, 228 .vw_kbdmode = K_XLATE, 229 .vw_grabbed = 0, 230}; |
226static struct terminal vt_consterm = { | 231struct terminal vt_consterm = { |
227 .tm_class = &vt_termclass, 228 .tm_softc = &vt_conswindow, 229 .tm_flags = TF_CONS, 230}; 231static struct consdev vt_consterm_consdev = { 232 .cn_ops = &termcn_cnops, 233 .cn_arg = &vt_consterm, 234 .cn_name = "ttyv0", --- 35 unchanged lines hidden (view full) --- 270 271 if (ms <= 0) 272 /* Default to initial value. */ 273 ms = 1000 / VT_TIMERFREQ; 274 275 callout_schedule(&vd->vd_timer, hz / (1000 / ms)); 276} 277 | 232 .tm_class = &vt_termclass, 233 .tm_softc = &vt_conswindow, 234 .tm_flags = TF_CONS, 235}; 236static struct consdev vt_consterm_consdev = { 237 .cn_ops = &termcn_cnops, 238 .cn_arg = &vt_consterm, 239 .cn_name = "ttyv0", --- 35 unchanged lines hidden (view full) --- 275 276 if (ms <= 0) 277 /* Default to initial value. */ 278 ms = 1000 / VT_TIMERFREQ; 279 280 callout_schedule(&vd->vd_timer, hz / (1000 / ms)); 281} 282 |
278static void | 283void |
279vt_resume_flush_timer(struct vt_device *vd, int ms) 280{ 281 282 if (!(vd->vd_flags & VDF_ASYNC) || 283 !atomic_cmpset_int(&vd->vd_timer_armed, 0, 1)) 284 return; 285 286 vt_schedule_flush(vd, ms); --- 256 unchanged lines hidden (view full) --- 543 vt_update_kbd_state(vw, kbd); 544 } 545 mtx_unlock(&Giant); 546 DPRINTF(10, "%s(ttyv%d) done\n", __func__, vw->vw_number); 547 548 return (0); 549} 550 | 284vt_resume_flush_timer(struct vt_device *vd, int ms) 285{ 286 287 if (!(vd->vd_flags & VDF_ASYNC) || 288 !atomic_cmpset_int(&vd->vd_timer_armed, 0, 1)) 289 return; 290 291 vt_schedule_flush(vd, ms); --- 256 unchanged lines hidden (view full) --- 548 vt_update_kbd_state(vw, kbd); 549 } 550 mtx_unlock(&Giant); 551 DPRINTF(10, "%s(ttyv%d) done\n", __func__, vw->vw_number); 552 553 return (0); 554} 555 |
551static inline void | 556void |
552vt_termsize(struct vt_device *vd, struct vt_font *vf, term_pos_t *size) 553{ 554 555 size->tp_row = vd->vd_height; | 557vt_termsize(struct vt_device *vd, struct vt_font *vf, term_pos_t *size) 558{ 559 560 size->tp_row = vd->vd_height; |
561 if (vt_draw_logo_cpus) 562 size->tp_row -= vt_logo_sprite_height; |
|
556 size->tp_col = vd->vd_width; 557 if (vf != NULL) { 558 size->tp_row /= vf->vf_height; 559 size->tp_col /= vf->vf_width; 560 } 561} 562 563static inline void | 563 size->tp_col = vd->vd_width; 564 if (vf != NULL) { 565 size->tp_row /= vf->vf_height; 566 size->tp_col /= vf->vf_width; 567 } 568} 569 570static inline void |
571vt_termrect(struct vt_device *vd, struct vt_font *vf, term_rect_t *rect) 572{ 573 574 rect->tr_begin.tp_row = rect->tr_begin.tp_col = 0; 575 if (vt_draw_logo_cpus) 576 rect->tr_begin.tp_row = vt_logo_sprite_height; 577 578 rect->tr_end.tp_row = vd->vd_height; 579 rect->tr_end.tp_col = vd->vd_width; 580 581 if (vf != NULL) { 582 rect->tr_begin.tp_row = 583 howmany(rect->tr_begin.tp_row, vf->vf_height); 584 585 rect->tr_end.tp_row /= vf->vf_height; 586 rect->tr_end.tp_col /= vf->vf_width; 587 } 588} 589 590void |
|
564vt_winsize(struct vt_device *vd, struct vt_font *vf, struct winsize *size) 565{ 566 | 591vt_winsize(struct vt_device *vd, struct vt_font *vf, struct winsize *size) 592{ 593 |
567 size->ws_row = size->ws_ypixel = vd->vd_height; | 594 size->ws_ypixel = vd->vd_height; 595 if (vt_draw_logo_cpus) 596 size->ws_ypixel -= vt_logo_sprite_height; 597 size->ws_row = size->ws_ypixel; |
568 size->ws_col = size->ws_xpixel = vd->vd_width; 569 if (vf != NULL) { 570 size->ws_row /= vf->vf_height; 571 size->ws_col /= vf->vf_width; 572 } 573} 574 | 598 size->ws_col = size->ws_xpixel = vd->vd_width; 599 if (vf != NULL) { 600 size->ws_row /= vf->vf_height; 601 size->ws_col /= vf->vf_width; 602 } 603} 604 |
575static inline void | 605void |
576vt_compute_drawable_area(struct vt_window *vw) 577{ 578 struct vt_device *vd; 579 struct vt_font *vf; | 606vt_compute_drawable_area(struct vt_window *vw) 607{ 608 struct vt_device *vd; 609 struct vt_font *vf; |
610 vt_axis_t height; |
|
580 581 vd = vw->vw_device; 582 583 if (vw->vw_font == NULL) { 584 vw->vw_draw_area.tr_begin.tp_col = 0; 585 vw->vw_draw_area.tr_begin.tp_row = 0; | 611 612 vd = vw->vw_device; 613 614 if (vw->vw_font == NULL) { 615 vw->vw_draw_area.tr_begin.tp_col = 0; 616 vw->vw_draw_area.tr_begin.tp_row = 0; |
617 if (vt_draw_logo_cpus) 618 vw->vw_draw_area.tr_begin.tp_row = vt_logo_sprite_height; |
|
586 vw->vw_draw_area.tr_end.tp_col = vd->vd_width; 587 vw->vw_draw_area.tr_end.tp_row = vd->vd_height; 588 return; 589 } 590 591 vf = vw->vw_font; 592 593 /* 594 * Compute the drawable area, so that the text is centered on 595 * the screen. 596 */ 597 | 619 vw->vw_draw_area.tr_end.tp_col = vd->vd_width; 620 vw->vw_draw_area.tr_end.tp_row = vd->vd_height; 621 return; 622 } 623 624 vf = vw->vw_font; 625 626 /* 627 * Compute the drawable area, so that the text is centered on 628 * the screen. 629 */ 630 |
631 height = vd->vd_height; 632 if (vt_draw_logo_cpus) 633 height -= vt_logo_sprite_height; |
|
598 vw->vw_draw_area.tr_begin.tp_col = (vd->vd_width % vf->vf_width) / 2; | 634 vw->vw_draw_area.tr_begin.tp_col = (vd->vd_width % vf->vf_width) / 2; |
599 vw->vw_draw_area.tr_begin.tp_row = (vd->vd_height % vf->vf_height) / 2; | 635 vw->vw_draw_area.tr_begin.tp_row = (height % vf->vf_height) / 2; 636 if (vt_draw_logo_cpus) 637 vw->vw_draw_area.tr_begin.tp_row += vt_logo_sprite_height; |
600 vw->vw_draw_area.tr_end.tp_col = vw->vw_draw_area.tr_begin.tp_col + 601 vd->vd_width / vf->vf_width * vf->vf_width; 602 vw->vw_draw_area.tr_end.tp_row = vw->vw_draw_area.tr_begin.tp_row + | 638 vw->vw_draw_area.tr_end.tp_col = vw->vw_draw_area.tr_begin.tp_col + 639 vd->vd_width / vf->vf_width * vf->vf_width; 640 vw->vw_draw_area.tr_end.tp_row = vw->vw_draw_area.tr_begin.tp_row + |
603 vd->vd_height / vf->vf_height * vf->vf_height; | 641 height / vf->vf_height * vf->vf_height; |
604} 605 606static void 607vt_scroll(struct vt_window *vw, int offset, int whence) 608{ 609 int diff; 610 term_pos_t size; 611 --- 494 unchanged lines hidden (view full) --- 1106#endif 1107 1108static int 1109vt_flush(struct vt_device *vd) 1110{ 1111 struct vt_window *vw; 1112 struct vt_font *vf; 1113 term_rect_t tarea; | 642} 643 644static void 645vt_scroll(struct vt_window *vw, int offset, int whence) 646{ 647 int diff; 648 term_pos_t size; 649 --- 494 unchanged lines hidden (view full) --- 1144#endif 1145 1146static int 1147vt_flush(struct vt_device *vd) 1148{ 1149 struct vt_window *vw; 1150 struct vt_font *vf; 1151 term_rect_t tarea; |
1114 term_pos_t size; | |
1115#ifndef SC_NO_CUTPASTE 1116 int cursor_was_shown, cursor_moved; 1117#endif 1118 1119 vw = vd->vd_curwindow; 1120 if (vw == NULL) 1121 return (0); 1122 --- 38 unchanged lines hidden (view full) --- 1161 * If the cursor is displayed and has moved since last refresh, 1162 * mark the new position as dirty. 1163 */ 1164 if (vd->vd_mshown && cursor_moved) 1165 vt_mark_mouse_position_as_dirty(vd); 1166#endif 1167 1168 vtbuf_undirty(&vw->vw_buf, &tarea); | 1152#ifndef SC_NO_CUTPASTE 1153 int cursor_was_shown, cursor_moved; 1154#endif 1155 1156 vw = vd->vd_curwindow; 1157 if (vw == NULL) 1158 return (0); 1159 --- 38 unchanged lines hidden (view full) --- 1198 * If the cursor is displayed and has moved since last refresh, 1199 * mark the new position as dirty. 1200 */ 1201 if (vd->vd_mshown && cursor_moved) 1202 vt_mark_mouse_position_as_dirty(vd); 1203#endif 1204 1205 vtbuf_undirty(&vw->vw_buf, &tarea); |
1169 vt_termsize(vd, vf, &size); | |
1170 1171 /* Force a full redraw when the screen contents are invalid. */ 1172 if (vd->vd_flags & VDF_INVALID) { | 1206 1207 /* Force a full redraw when the screen contents are invalid. */ 1208 if (vd->vd_flags & VDF_INVALID) { |
1173 tarea.tr_begin.tp_row = tarea.tr_begin.tp_col = 0; 1174 tarea.tr_end = size; 1175 | |
1176 vd->vd_flags &= ~VDF_INVALID; | 1209 vd->vd_flags &= ~VDF_INVALID; |
1210 1211 vt_termrect(vd, vf, &tarea); 1212 if (vt_draw_logo_cpus) 1213 vtterm_draw_cpu_logos(vd); |
|
1177 } 1178 1179 if (tarea.tr_begin.tp_col < tarea.tr_end.tp_col) { 1180 vd->vd_driver->vd_bitblt_text(vd, vw, &tarea); 1181 return (1); 1182 } 1183 1184 return (0); --- 128 unchanged lines hidden (view full) --- 1313 TERMINAL_NORM_ATTR; 1314 attr.ta_format = TCHAR_FORMAT(c); 1315 attr.ta_fgcolor = TCHAR_FGCOLOR(c); 1316 attr.ta_bgcolor = TCHAR_BGCOLOR(c); 1317 terminal_set_winsize_blank(tm, &wsz, 1, &attr); 1318 1319 if (vtdbest != NULL) { 1320#ifdef DEV_SPLASH | 1214 } 1215 1216 if (tarea.tr_begin.tp_col < tarea.tr_end.tp_col) { 1217 vd->vd_driver->vd_bitblt_text(vd, vw, &tarea); 1218 return (1); 1219 } 1220 1221 return (0); --- 128 unchanged lines hidden (view full) --- 1350 TERMINAL_NORM_ATTR; 1351 attr.ta_format = TCHAR_FORMAT(c); 1352 attr.ta_fgcolor = TCHAR_FGCOLOR(c); 1353 attr.ta_bgcolor = TCHAR_BGCOLOR(c); 1354 terminal_set_winsize_blank(tm, &wsz, 1, &attr); 1355 1356 if (vtdbest != NULL) { 1357#ifdef DEV_SPLASH |
1321 vtterm_splash(vd); | 1358 if (!vt_splash_cpu) 1359 vtterm_splash(vd); |
1322#endif 1323 vd->vd_flags |= VDF_INITIALIZED; 1324 } 1325} 1326 1327static int 1328vtterm_cngetc(struct terminal *tm) 1329{ --- 1472 unchanged lines hidden --- | 1360#endif 1361 vd->vd_flags |= VDF_INITIALIZED; 1362 } 1363} 1364 1365static int 1366vtterm_cngetc(struct terminal *tm) 1367{ --- 1472 unchanged lines hidden --- |