subr_terminal.c (264455) | subr_terminal.c (268037) |
---|---|
1/*- 2 * Copyright (c) 2009 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 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2009 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 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: stable/10/sys/kern/subr_terminal.c 264455 2014-04-14 12:40:37Z ray $"); | 31__FBSDID("$FreeBSD: stable/10/sys/kern/subr_terminal.c 268037 2014-06-30 09:59:23Z marius $"); |
32 33#include <sys/param.h> 34#include <sys/cons.h> 35#include <sys/consio.h> 36#include <sys/kernel.h> 37#include <sys/lock.h> 38#include <sys/malloc.h> 39#include <sys/mutex.h> --- 74 unchanged lines hidden (view full) --- 114 .tf_fill = termteken_fill, 115 .tf_copy = termteken_copy, 116 .tf_param = termteken_param, 117 .tf_respond = termteken_respond, 118}; 119 120/* Kernel message formatting. */ 121static const teken_attr_t kernel_message = { | 32 33#include <sys/param.h> 34#include <sys/cons.h> 35#include <sys/consio.h> 36#include <sys/kernel.h> 37#include <sys/lock.h> 38#include <sys/malloc.h> 39#include <sys/mutex.h> --- 74 unchanged lines hidden (view full) --- 114 .tf_fill = termteken_fill, 115 .tf_copy = termteken_copy, 116 .tf_param = termteken_param, 117 .tf_respond = termteken_respond, 118}; 119 120/* Kernel message formatting. */ 121static const teken_attr_t kernel_message = { |
122 .ta_fgcolor = TC_WHITE, 123 .ta_bgcolor = TC_BLACK, 124 .ta_format = TF_BOLD, | 122 .ta_fgcolor = TCHAR_FGCOLOR(TERMINAL_KERN_ATTR), 123 .ta_bgcolor = TCHAR_BGCOLOR(TERMINAL_KERN_ATTR), 124 .ta_format = TCHAR_FORMAT(TERMINAL_KERN_ATTR) |
125}; 126 127static const teken_attr_t default_message = { | 125}; 126 127static const teken_attr_t default_message = { |
128 .ta_fgcolor = TC_WHITE, 129 .ta_bgcolor = TC_BLACK, | 128 .ta_fgcolor = TCHAR_FGCOLOR(TERMINAL_NORM_ATTR), 129 .ta_bgcolor = TCHAR_BGCOLOR(TERMINAL_NORM_ATTR), 130 .ta_format = TCHAR_FORMAT(TERMINAL_NORM_ATTR) |
130}; 131 | 131}; 132 |
132#define TCHAR_CREATE(c, a) ((c) | \ 133 (a)->ta_format << 21 | \ 134 teken_256to8((a)->ta_fgcolor) << 26 | \ 135 teken_256to8((a)->ta_bgcolor) << 29) | 133#define TCHAR_CREATE(c, a) ((c) | TFORMAT((a)->ta_format) | \ 134 TCOLOR_FG(teken_256to8((a)->ta_fgcolor)) | \ 135 TCOLOR_BG(teken_256to8((a)->ta_bgcolor))) |
136 137static void 138terminal_init(struct terminal *tm) 139{ 140 141 if (tm->tm_flags & TF_CONS) 142 mtx_init(&tm->tm_mtx, "trmlck", NULL, MTX_SPIN); 143 teken_init(&tm->tm_emulator, &terminal_drawmethods, tm); --- 42 unchanged lines hidden (view full) --- 186 tp = tty_alloc(&terminal_tty_class, tm); 187 tty_makedev(tp, NULL, "%s", name); 188 tm->tm_tty = tp; 189 terminal_sync_ttysize(tm); 190} 191 192void 193terminal_set_winsize_blank(struct terminal *tm, const struct winsize *size, | 136 137static void 138terminal_init(struct terminal *tm) 139{ 140 141 if (tm->tm_flags & TF_CONS) 142 mtx_init(&tm->tm_mtx, "trmlck", NULL, MTX_SPIN); 143 teken_init(&tm->tm_emulator, &terminal_drawmethods, tm); --- 42 unchanged lines hidden (view full) --- 186 tp = tty_alloc(&terminal_tty_class, tm); 187 tty_makedev(tp, NULL, "%s", name); 188 tm->tm_tty = tp; 189 terminal_sync_ttysize(tm); 190} 191 192void 193terminal_set_winsize_blank(struct terminal *tm, const struct winsize *size, |
194 int blank) | 194 int blank, const term_attr_t *attr) |
195{ 196 term_rect_t r; 197 198 tm->tm_winsize = *size; 199 200 r.tr_begin.tp_row = r.tr_begin.tp_col = 0; 201 r.tr_end.tp_row = size->ws_row; 202 r.tr_end.tp_col = size->ws_col; 203 204 TERMINAL_LOCK(tm); 205 if (blank == 0) 206 teken_set_winsize_noreset(&tm->tm_emulator, &r.tr_end); 207 else 208 teken_set_winsize(&tm->tm_emulator, &r.tr_end); 209 TERMINAL_UNLOCK(tm); 210 211 if ((blank != 0) && !(tm->tm_flags & TF_MUTE)) | 195{ 196 term_rect_t r; 197 198 tm->tm_winsize = *size; 199 200 r.tr_begin.tp_row = r.tr_begin.tp_col = 0; 201 r.tr_end.tp_row = size->ws_row; 202 r.tr_end.tp_col = size->ws_col; 203 204 TERMINAL_LOCK(tm); 205 if (blank == 0) 206 teken_set_winsize_noreset(&tm->tm_emulator, &r.tr_end); 207 else 208 teken_set_winsize(&tm->tm_emulator, &r.tr_end); 209 TERMINAL_UNLOCK(tm); 210 211 if ((blank != 0) && !(tm->tm_flags & TF_MUTE)) |
212 tm->tm_class->tc_fill(tm, &r, TCHAR_CREATE((teken_char_t)' ', 213 &default_message)); | 212 tm->tm_class->tc_fill(tm, &r, 213 TCHAR_CREATE((teken_char_t)' ', attr)); |
214 215 terminal_sync_ttysize(tm); 216} 217 218void 219terminal_set_winsize(struct terminal *tm, const struct winsize *size) 220{ 221 | 214 215 terminal_sync_ttysize(tm); 216} 217 218void 219terminal_set_winsize(struct terminal *tm, const struct winsize *size) 220{ 221 |
222 terminal_set_winsize_blank(tm, size, 1); | 222 terminal_set_winsize_blank(tm, size, 1, 223 (const term_attr_t *)&default_message); |
223} 224 225/* 226 * XXX: This function is a kludge. Drivers like vt(4) need to 227 * temporarily stop input when resizing, etc. This should ideally be 228 * handled within the driver. 229 */ 230 --- 389 unchanged lines hidden --- | 224} 225 226/* 227 * XXX: This function is a kludge. Drivers like vt(4) need to 228 * temporarily stop input when resizing, etc. This should ideally be 229 * handled within the driver. 230 */ 231 --- 389 unchanged lines hidden --- |