Lines Matching refs:vc

137 struct vc vc_cons [MAX_NR_CONSOLES];
143 static void vc_init(struct vc_data *vc, int do_clear);
144 static void gotoxy(struct vc_data *vc, int new_x, int new_y);
145 static void save_cur(struct vc_data *vc);
146 static void reset_terminal(struct vc_data *vc, int do_clear);
149 static void set_cursor(struct vc_data *vc);
150 static void hide_cursor(struct vc_data *vc);
154 static void set_palette(struct vc_data *vc);
242 * the attribute 'active' contains the name of the current vc
243 * console and it supports poll() to detect vc switches
264 static void notify_write(struct vc_data *vc, unsigned int unicode)
266 struct vt_notifier_param param = { .vc = vc, .c = unicode };
270 static void notify_update(struct vc_data *vc)
272 struct vt_notifier_param param = { .vc = vc };
279 static inline bool con_is_fg(const struct vc_data *vc)
281 return vc->vc_num == fg_console;
284 static inline bool con_should_update(const struct vc_data *vc)
286 return con_is_visible(vc) && !console_blanked;
289 static inline u16 *screenpos(const struct vc_data *vc, unsigned int offset,
292 unsigned long origin = viewed ? vc->vc_visible_origin : vc->vc_origin;
297 static void con_putc(struct vc_data *vc, u16 ca, unsigned int y, unsigned int x)
299 if (vc->vc_sw->con_putc)
300 vc->vc_sw->con_putc(vc, ca, y, x);
302 vc->vc_sw->con_putcs(vc, &ca, 1, y, x);
357 static void vc_uniscr_set(struct vc_data *vc, u32 **new_uni_lines)
359 vc_uniscr_free(vc->vc_uni_lines);
360 vc->vc_uni_lines = new_uni_lines;
363 static void vc_uniscr_putc(struct vc_data *vc, u32 uc)
365 if (vc->vc_uni_lines)
366 vc->vc_uni_lines[vc->state.y][vc->state.x] = uc;
369 static void vc_uniscr_insert(struct vc_data *vc, unsigned int nr)
371 if (vc->vc_uni_lines) {
372 u32 *ln = vc->vc_uni_lines[vc->state.y];
373 unsigned int x = vc->state.x, cols = vc->vc_cols;
380 static void vc_uniscr_delete(struct vc_data *vc, unsigned int nr)
382 if (vc->vc_uni_lines) {
383 u32 *ln = vc->vc_uni_lines[vc->state.y];
384 unsigned int x = vc->state.x, cols = vc->vc_cols;
391 static void vc_uniscr_clear_line(struct vc_data *vc, unsigned int x,
394 if (vc->vc_uni_lines)
395 memset32(&vc->vc_uni_lines[vc->state.y][x], ' ', nr);
398 static void vc_uniscr_clear_lines(struct vc_data *vc, unsigned int y,
401 if (vc->vc_uni_lines)
403 memset32(vc->vc_uni_lines[y++], ' ', vc->vc_cols);
428 static void vc_uniscr_scroll(struct vc_data *vc, unsigned int top,
432 u32 **uni_lines = vc->vc_uni_lines;
440 vc_uniscr_clear_lines(vc, top, nr);
443 vc_uniscr_clear_lines(vc, bottom - nr, nr);
484 int vc_uniscr_check(struct vc_data *vc)
492 if (!vc->vc_utf)
495 if (vc->vc_uni_lines)
498 uni_lines = vc_uniscr_alloc(vc->vc_cols, vc->vc_rows);
508 p = (unsigned short *)vc->vc_origin;
509 mask = vc->vc_hi_font_mask | 0xff;
510 for (y = 0; y < vc->vc_rows; y++) {
512 for (x = 0; x < vc->vc_cols; x++) {
514 line[x] = inverse_translate(vc, glyph, true);
518 vc->vc_uni_lines = uni_lines;
528 void vc_uniscr_copy_line(const struct vc_data *vc, void *dest, bool viewed,
531 u32 **uni_lines = vc->vc_uni_lines;
532 int offset = row * vc->vc_size_row + col * 2;
538 pos = (unsigned long)screenpos(vc, offset, viewed);
539 if (pos >= vc->vc_origin && pos < vc->vc_scr_end) {
545 row = (pos - vc->vc_origin) / vc->vc_size_row;
546 col = ((pos - vc->vc_origin) % vc->vc_size_row) / 2;
556 int mask = vc->vc_hi_font_mask | 0xff;
560 *uni_buf++ = inverse_translate(vc, glyph, true);
565 static void con_scroll(struct vc_data *vc, unsigned int top,
574 if (bottom > vc->vc_rows || top >= bottom || nr < 1)
577 vc_uniscr_scroll(vc, top, bottom, dir, nr);
578 if (con_is_visible(vc) &&
579 vc->vc_sw->con_scroll(vc, top, bottom, dir, nr))
582 src = clear = (u16 *)(vc->vc_origin + vc->vc_size_row * top);
583 dst = (u16 *)(vc->vc_origin + vc->vc_size_row * (top + nr));
586 clear = src + (rows - nr) * vc->vc_cols;
589 scr_memmovew(dst, src, (rows - nr) * vc->vc_size_row);
590 scr_memsetw(clear, vc->vc_video_erase_char, vc->vc_size_row * nr);
593 static void do_update_region(struct vc_data *vc, unsigned long start, int count)
598 offset = (start - vc->vc_origin) / 2;
599 xx = offset % vc->vc_cols;
600 yy = offset / vc->vc_cols;
606 while (xx < vc->vc_cols && count) {
609 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx);
619 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx);
627 void update_region(struct vc_data *vc, unsigned long start, int count)
631 if (con_should_update(vc)) {
632 hide_cursor(vc);
633 do_update_region(vc, start, count);
634 set_cursor(vc);
641 static u8 build_attr(struct vc_data *vc, u8 _color,
645 if (vc->vc_sw->con_build_attr)
646 return vc->vc_sw->con_build_attr(vc, _color, _intensity,
661 if (!vc->vc_can_do_color)
668 a = (a & 0xF0) | vc->vc_itcolor;
670 a = (a & 0xf0) | vc->vc_ulcolor;
672 a = (a & 0xf0) | vc->vc_halfcolor;
679 if (vc->vc_hi_font_mask == 0x100)
685 static void update_attr(struct vc_data *vc)
687 vc->vc_attr = build_attr(vc, vc->state.color, vc->state.intensity,
688 vc->state.blink, vc->state.underline,
689 vc->state.reverse ^ vc->vc_decscnm, vc->state.italic);
690 vc->vc_video_erase_char = ' ' | (build_attr(vc, vc->state.color,
691 VCI_NORMAL, vc->state.blink, false,
692 vc->vc_decscnm, false) << 8);
696 void invert_screen(struct vc_data *vc, int offset, int count, bool viewed)
703 p = screenpos(vc, offset, viewed);
704 if (vc->vc_sw->con_invert_region) {
705 vc->vc_sw->con_invert_region(vc, p, count);
711 if (!vc->vc_can_do_color) {
718 } else if (vc->vc_hi_font_mask == 0x100) {
739 if (con_should_update(vc))
740 do_update_region(vc, (unsigned long) p, count);
741 notify_update(vc);
745 void complement_pos(struct vc_data *vc, int offset)
754 old_offset < vc->vc_screenbuf_size) {
755 scr_writew(old, screenpos(vc, old_offset, true));
756 if (con_should_update(vc))
757 con_putc(vc, old, oldy, oldx);
758 notify_update(vc);
764 offset < vc->vc_screenbuf_size) {
766 u16 *p = screenpos(vc, offset, true);
768 new = old ^ vc->vc_complement_mask;
770 if (con_should_update(vc)) {
771 oldx = (offset >> 1) % vc->vc_cols;
772 oldy = (offset >> 1) / vc->vc_cols;
773 con_putc(vc, new, oldy, oldx);
775 notify_update(vc);
779 static void insert_char(struct vc_data *vc, unsigned int nr)
781 unsigned short *p = (unsigned short *) vc->vc_pos;
783 vc_uniscr_insert(vc, nr);
784 scr_memmovew(p + nr, p, (vc->vc_cols - vc->state.x - nr) * 2);
785 scr_memsetw(p, vc->vc_video_erase_char, nr * 2);
786 vc->vc_need_wrap = 0;
787 if (con_should_update(vc))
788 do_update_region(vc, (unsigned long) p,
789 vc->vc_cols - vc->state.x);
792 static void delete_char(struct vc_data *vc, unsigned int nr)
794 unsigned short *p = (unsigned short *) vc->vc_pos;
796 vc_uniscr_delete(vc, nr);
797 scr_memmovew(p, p + nr, (vc->vc_cols - vc->state.x - nr) * 2);
798 scr_memsetw(p + vc->vc_cols - vc->state.x - nr, vc->vc_video_erase_char,
800 vc->vc_need_wrap = 0;
801 if (con_should_update(vc))
802 do_update_region(vc, (unsigned long) p,
803 vc->vc_cols - vc->state.x);
808 static void add_softcursor(struct vc_data *vc)
810 int i = scr_readw((u16 *) vc->vc_pos);
811 u32 type = vc->vc_cursor_type;
825 scr_writew(i, (u16 *)vc->vc_pos);
826 if (con_should_update(vc))
827 con_putc(vc, i, vc->state.y, vc->state.x);
830 static void hide_softcursor(struct vc_data *vc)
833 scr_writew(softcursor_original, (u16 *)vc->vc_pos);
834 if (con_should_update(vc))
835 con_putc(vc, softcursor_original, vc->state.y,
836 vc->state.x);
841 static void hide_cursor(struct vc_data *vc)
843 if (vc_is_sel(vc))
846 vc->vc_sw->con_cursor(vc, false);
847 hide_softcursor(vc);
850 static void set_cursor(struct vc_data *vc)
852 if (!con_is_fg(vc) || console_blanked || vc->vc_mode == KD_GRAPHICS)
854 if (vc->vc_deccm) {
855 if (vc_is_sel(vc))
857 add_softcursor(vc);
858 if (CUR_SIZE(vc->vc_cursor_type) != CUR_NONE)
859 vc->vc_sw->con_cursor(vc, true);
861 hide_cursor(vc);
864 static void set_origin(struct vc_data *vc)
868 if (!con_is_visible(vc) ||
869 !vc->vc_sw->con_set_origin ||
870 !vc->vc_sw->con_set_origin(vc))
871 vc->vc_origin = (unsigned long)vc->vc_screenbuf;
872 vc->vc_visible_origin = vc->vc_origin;
873 vc->vc_scr_end = vc->vc_origin + vc->vc_screenbuf_size;
874 vc->vc_pos = vc->vc_origin + vc->vc_size_row * vc->state.y +
875 2 * vc->state.x;
878 static void save_screen(struct vc_data *vc)
882 if (vc->vc_sw->con_save_screen)
883 vc->vc_sw->con_save_screen(vc);
886 static void flush_scrollback(struct vc_data *vc)
890 set_origin(vc);
891 if (!con_is_visible(vc))
900 hide_cursor(vc);
901 vc->vc_sw->con_switch(vc);
902 set_cursor(vc);
909 void clear_buffer_attributes(struct vc_data *vc)
911 unsigned short *p = (unsigned short *)vc->vc_origin;
912 int count = vc->vc_screenbuf_size / 2;
913 int mask = vc->vc_hi_font_mask | 0xff;
916 scr_writew((scr_readw(p)&mask) | (vc->vc_video_erase_char & ~mask), p);
920 void redraw_screen(struct vc_data *vc, int is_switch)
926 if (!vc) {
934 if (old_vc == vc)
936 if (!con_is_visible(vc))
938 *vc->vc_display_fg = vc;
939 fg_console = vc->vc_num;
948 hide_cursor(vc);
954 int old_was_color = vc->vc_can_do_color;
956 set_origin(vc);
957 update = vc->vc_sw->con_switch(vc);
958 set_palette(vc);
965 if (old_was_color != vc->vc_can_do_color) {
966 update_attr(vc);
967 clear_buffer_attributes(vc);
970 if (update && vc->vc_mode != KD_GRAPHICS)
971 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2);
973 set_cursor(vc);
976 notify_update(vc);
990 static void visual_init(struct vc_data *vc, int num, bool init)
992 /* ++Geert: vc->vc_sw->con_init determines console size */
993 if (vc->vc_sw)
994 module_put(vc->vc_sw->owner);
995 vc->vc_sw = conswitchp;
998 vc->vc_sw = con_driver_map[num];
1000 __module_get(vc->vc_sw->owner);
1001 vc->vc_num = num;
1002 vc->vc_display_fg = &master_display_fg;
1003 if (vc->uni_pagedict_loc)
1004 con_free_unimap(vc);
1005 vc->uni_pagedict_loc = &vc->uni_pagedict;
1006 vc->uni_pagedict = NULL;
1007 vc->vc_hi_font_mask = 0;
1008 vc->vc_complement_mask = 0;
1009 vc->vc_can_do_color = 0;
1010 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS;
1011 vc->vc_sw->con_init(vc, init);
1012 if (!vc->vc_complement_mask)
1013 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
1014 vc->vc_s_complement_mask = vc->vc_complement_mask;
1015 vc->vc_size_row = vc->vc_cols << 1;
1016 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row;
1020 static void visual_deinit(struct vc_data *vc)
1022 vc->vc_sw->con_deinit(vc);
1023 module_put(vc->vc_sw->owner);
1028 struct vc_data *vc = container_of(port, struct vc_data, port);
1030 kfree(vc);
1048 struct vc_data *vc;
1065 param.vc = vc = kzalloc(sizeof(struct vc_data), GFP_KERNEL);
1066 if (!vc)
1069 vc_cons[currcons].d = vc;
1070 tty_port_init(&vc->port);
1071 vc->port.ops = &vc_port_ops;
1074 visual_init(vc, currcons, true);
1076 if (!*vc->uni_pagedict_loc)
1077 con_set_default_unimap(vc);
1080 if (vc->vc_cols > VC_MAXCOL || vc->vc_rows > VC_MAXROW ||
1081 vc->vc_screenbuf_size > KMALLOC_MAX_SIZE || !vc->vc_screenbuf_size)
1084 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_KERNEL);
1085 if (!vc->vc_screenbuf)
1093 vc_init(vc, 1);
1099 visual_deinit(vc);
1100 kfree(vc);
1105 static inline int resize_screen(struct vc_data *vc, int width, int height,
1111 if (vc->vc_sw->con_resize)
1112 err = vc->vc_sw->con_resize(vc, width, height, from_user);
1120 * @vc: virtual console private data
1132 static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
1147 new_cols = (cols ? cols : vc->vc_cols);
1148 new_rows = (lines ? lines : vc->vc_rows);
1152 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) {
1169 return resize_screen(vc, new_cols, new_rows, from_user);
1178 if (vc->vc_uni_lines) {
1186 if (vc_is_sel(vc))
1189 old_rows = vc->vc_rows;
1190 old_row_size = vc->vc_size_row;
1192 err = resize_screen(vc, new_cols, new_rows, from_user);
1199 vc->vc_rows = new_rows;
1200 vc->vc_cols = new_cols;
1201 vc->vc_size_row = new_row_size;
1202 vc->vc_screenbuf_size = new_screen_size;
1206 old_origin = vc->vc_origin;
1210 if (vc->state.y > new_rows) {
1211 if (old_rows - vc->state.y < new_rows) {
1222 first_copied_row = (vc->state.y - new_rows/2);
1230 vc->vc_uni_lines, rlth/2, first_copied_row,
1232 vc_uniscr_set(vc, new_uniscr);
1234 update_attr(vc);
1241 vc->vc_video_erase_char, rrem);
1246 scr_memsetw((void *)new_origin, vc->vc_video_erase_char,
1248 oldscreen = vc->vc_screenbuf;
1249 vc->vc_screenbuf = newscreen;
1250 vc->vc_screenbuf_size = new_screen_size;
1251 set_origin(vc);
1255 vc->vc_top = 0;
1256 vc->vc_bottom = vc->vc_rows;
1257 gotoxy(vc, vc->state.x, vc->state.y);
1258 save_cur(vc);
1265 ws.ws_row = vc->vc_rows;
1266 ws.ws_col = vc->vc_cols;
1267 ws.ws_ypixel = vc->vc_scan_lines;
1271 if (con_is_visible(vc))
1272 update_screen(vc);
1273 vt_event_post(VT_EVENT_RESIZE, vc->vc_num, vc->vc_num);
1274 notify_update(vc);
1280 * @vc: virtual console
1289 * and @vc->port.tty.
1291 int __vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows,
1294 return vc_do_resize(vc->port.tty, vc, cols, rows, from_user);
1311 struct vc_data *vc = tty->driver_data;
1315 ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row, false);
1322 struct vc_data *vc = NULL;
1329 param.vc = vc = vc_cons[currcons].d;
1332 visual_deinit(vc);
1333 con_free_unimap(vc);
1334 put_pid(vc->vt_pid);
1335 vc_uniscr_set(vc, NULL);
1336 kfree(vc->vc_screenbuf);
1339 return vc;
1348 #define set_kbd(vc, x) vt_set_kbd_mode_bit((vc)->vc_num, (x))
1349 #define clr_kbd(vc, x) vt_clr_kbd_mode_bit((vc)->vc_num, (x))
1350 #define is_kbd(vc, x) vt_get_kbd_mode_bit((vc)->vc_num, (x))
1388 static void gotoxy(struct vc_data *vc, int new_x, int new_y)
1393 vc->state.x = 0;
1395 if (new_x >= vc->vc_cols)
1396 vc->state.x = vc->vc_cols - 1;
1398 vc->state.x = new_x;
1401 if (vc->vc_decom) {
1402 min_y = vc->vc_top;
1403 max_y = vc->vc_bottom;
1406 max_y = vc->vc_rows;
1409 vc->state.y = min_y;
1411 vc->state.y = max_y - 1;
1413 vc->state.y = new_y;
1414 vc->vc_pos = vc->vc_origin + vc->state.y * vc->vc_size_row +
1415 (vc->state.x << 1);
1416 vc->vc_need_wrap = 0;
1420 static void gotoxay(struct vc_data *vc, int new_x, int new_y)
1422 gotoxy(vc, new_x, vc->vc_decom ? (vc->vc_top + new_y) : new_y);
1425 void scrollback(struct vc_data *vc)
1427 scrolldelta(-(vc->vc_rows / 2));
1430 void scrollfront(struct vc_data *vc, int lines)
1433 lines = vc->vc_rows / 2;
1437 static void lf(struct vc_data *vc)
1442 if (vc->state.y + 1 == vc->vc_bottom)
1443 con_scroll(vc, vc->vc_top, vc->vc_bottom, SM_UP, 1);
1444 else if (vc->state.y < vc->vc_rows - 1) {
1445 vc->state.y++;
1446 vc->vc_pos += vc->vc_size_row;
1448 vc->vc_need_wrap = 0;
1449 notify_write(vc, '\n');
1452 static void ri(struct vc_data *vc)
1457 if (vc->state.y == vc->vc_top)
1458 con_scroll(vc, vc->vc_top, vc->vc_bottom, SM_DOWN, 1);
1459 else if (vc->state.y > 0) {
1460 vc->state.y--;
1461 vc->vc_pos -= vc->vc_size_row;
1463 vc->vc_need_wrap = 0;
1466 static inline void cr(struct vc_data *vc)
1468 vc->vc_pos -= vc->state.x << 1;
1469 vc->vc_need_wrap = vc->state.x = 0;
1470 notify_write(vc, '\r');
1473 static inline void bs(struct vc_data *vc)
1475 if (vc->state.x) {
1476 vc->vc_pos -= 2;
1477 vc->state.x--;
1478 vc->vc_need_wrap = 0;
1479 notify_write(vc, '\b');
1483 static inline void del(struct vc_data *vc)
1495 static void csi_J(struct vc_data *vc, enum CSI_J vpar)
1502 vc_uniscr_clear_line(vc, vc->state.x,
1503 vc->vc_cols - vc->state.x);
1504 vc_uniscr_clear_lines(vc, vc->state.y + 1,
1505 vc->vc_rows - vc->state.y - 1);
1506 count = (vc->vc_scr_end - vc->vc_pos) >> 1;
1507 start = (unsigned short *)vc->vc_pos;
1510 vc_uniscr_clear_line(vc, 0, vc->state.x + 1);
1511 vc_uniscr_clear_lines(vc, 0, vc->state.y);
1512 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1;
1513 start = (unsigned short *)vc->vc_origin;
1516 flush_scrollback(vc);
1519 vc_uniscr_clear_lines(vc, 0, vc->vc_rows);
1520 count = vc->vc_cols * vc->vc_rows;
1521 start = (unsigned short *)vc->vc_origin;
1526 scr_memsetw(start, vc->vc_video_erase_char, 2 * count);
1527 if (con_should_update(vc))
1528 do_update_region(vc, (unsigned long) start, count);
1529 vc->vc_need_wrap = 0;
1538 static void csi_K(struct vc_data *vc)
1541 unsigned short *start = (unsigned short *)vc->vc_pos;
1544 switch (vc->vc_par[0]) {
1547 count = vc->vc_cols - vc->state.x;
1550 offset = -vc->state.x;
1551 count = vc->state.x + 1;
1554 offset = -vc->state.x;
1555 count = vc->vc_cols;
1560 vc_uniscr_clear_line(vc, vc->state.x + offset, count);
1561 scr_memsetw(start + offset, vc->vc_video_erase_char, 2 * count);
1562 vc->vc_need_wrap = 0;
1563 if (con_should_update(vc))
1564 do_update_region(vc, (unsigned long)(start + offset), count);
1568 static void csi_X(struct vc_data *vc)
1570 unsigned int count = clamp(vc->vc_par[0], 1, vc->vc_cols - vc->state.x);
1572 vc_uniscr_clear_line(vc, vc->state.x, count);
1573 scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count);
1574 if (con_should_update(vc))
1575 vc->vc_sw->con_clear(vc, vc->state.y, vc->state.x, count);
1576 vc->vc_need_wrap = 0;
1579 static void default_attr(struct vc_data *vc)
1581 vc->state.intensity = VCI_NORMAL;
1582 vc->state.italic = false;
1583 vc->state.underline = false;
1584 vc->state.reverse = false;
1585 vc->state.blink = false;
1586 vc->state.color = vc->vc_def_color;
1612 static void rgb_foreground(struct vc_data *vc, const struct rgb *c)
1625 vc->state.intensity = VCI_BOLD;
1627 vc->state.intensity = VCI_BOLD;
1629 vc->state.intensity = VCI_NORMAL;
1631 vc->state.color = (vc->state.color & 0xf0) | hue;
1634 static void rgb_background(struct vc_data *vc, const struct rgb *c)
1637 vc->state.color = (vc->state.color & 0x0f)
1650 static int vc_t416_color(struct vc_data *vc, int i,
1651 void(*set_color)(struct vc_data *vc, const struct rgb *c))
1656 if (i > vc->vc_npar)
1659 if (vc->vc_par[i] == 5 && i + 1 <= vc->vc_npar) {
1662 rgb_from_256(vc->vc_par[i], &c);
1663 } else if (vc->vc_par[i] == 2 && i + 3 <= vc->vc_npar) {
1665 c.r = vc->vc_par[i + 1];
1666 c.g = vc->vc_par[i + 2];
1667 c.b = vc->vc_par[i + 3];
1672 set_color(vc, &c);
1711 static void csi_m(struct vc_data *vc)
1715 for (i = 0; i <= vc->vc_npar; i++)
1716 switch (vc->vc_par[i]) {
1718 default_attr(vc);
1721 vc->state.intensity = VCI_BOLD;
1724 vc->state.intensity = VCI_HALF_BRIGHT;
1727 vc->state.italic = true;
1735 vc->state.underline = true;
1738 vc->state.blink = true;
1741 vc->state.reverse = true;
1747 vc->vc_translate = set_translate(vc->state.Gx_charset[vc->state.charset], vc);
1748 vc->vc_disp_ctrl = 0;
1749 vc->vc_toggle_meta = 0;
1755 vc->vc_translate = set_translate(IBMPC_MAP, vc);
1756 vc->vc_disp_ctrl = 1;
1757 vc->vc_toggle_meta = 0;
1763 vc->vc_translate = set_translate(IBMPC_MAP, vc);
1764 vc->vc_disp_ctrl = 1;
1765 vc->vc_toggle_meta = 1;
1768 vc->state.intensity = VCI_NORMAL;
1771 vc->state.italic = false;
1774 vc->state.underline = false;
1777 vc->state.blink = false;
1780 vc->state.reverse = false;
1783 i = vc_t416_color(vc, i, rgb_foreground);
1786 i = vc_t416_color(vc, i, rgb_background);
1789 vc->state.color = (vc->vc_def_color & 0x0f) |
1790 (vc->state.color & 0xf0);
1793 vc->state.color = (vc->vc_def_color & 0xf0) |
1794 (vc->state.color & 0x0f);
1797 vc->state.intensity = VCI_BOLD;
1798 vc->vc_par[i] -= CSI_m_BRIGHT_FG_COLOR_OFF;
1801 vc->vc_par[i] -= CSI_m_FG_COLOR_BEG;
1802 vc->state.color = color_table[vc->vc_par[i]] |
1803 (vc->state.color & 0xf0);
1806 vc->vc_par[i] -= CSI_m_BRIGHT_BG_COLOR_OFF;
1809 vc->vc_par[i] -= CSI_m_BG_COLOR_BEG;
1810 vc->state.color = (color_table[vc->vc_par[i]] << 4) |
1811 (vc->state.color & 0x0f);
1814 update_attr(vc);
1823 static void cursor_report(struct vc_data *vc, struct tty_struct *tty)
1828 len = sprintf(buf, "\033[%d;%dR", vc->state.y +
1829 (vc->vc_decom ? vc->vc_top + 1 : 1),
1830 vc->state.x + 1);
1878 static void csi_DEC_hl(struct vc_data *vc, bool on_off)
1882 for (i = 0; i <= vc->vc_npar; i++)
1883 switch (vc->vc_par[i]) {
1886 set_kbd(vc, decckm);
1888 clr_kbd(vc, decckm);
1892 vc_resize(deccolm ? 132 : 80, vc->vc_rows);
1898 if (vc->vc_decscnm != on_off) {
1899 vc->vc_decscnm = on_off;
1900 invert_screen(vc, 0, vc->vc_screenbuf_size,
1902 update_attr(vc);
1906 vc->vc_decom = on_off;
1907 gotoxay(vc, 0, 0);
1910 vc->vc_decawm = on_off;
1914 set_kbd(vc, decarm);
1916 clr_kbd(vc, decarm);
1919 vc->vc_report_mouse = on_off ? 1 : 0;
1922 vc->vc_deccm = on_off;
1925 vc->vc_report_mouse = on_off ? 2 : 0;
1937 static void csi_hl(struct vc_data *vc, bool on_off)
1941 for (i = 0; i <= vc->vc_npar; i++)
1942 switch (vc->vc_par[i]) { /* ANSI modes set/reset */
1944 vc->vc_disp_ctrl = on_off;
1947 vc->vc_decim = on_off;
1951 set_kbd(vc, lnm);
1953 clr_kbd(vc, lnm);
1979 static void csi_RSB(struct vc_data *vc)
1981 switch (vc->vc_par[0]) {
1983 if (vc->vc_can_do_color && vc->vc_par[1] < 16) {
1984 vc->vc_ulcolor = color_table[vc->vc_par[1]];
1985 if (vc->state.underline)
1986 update_attr(vc);
1990 if (vc->vc_can_do_color && vc->vc_par[1] < 16) {
1991 vc->vc_halfcolor = color_table[vc->vc_par[1]];
1992 if (vc->state.intensity == VCI_HALF_BRIGHT)
1993 update_attr(vc);
1997 vc->vc_def_color = vc->vc_attr;
1998 if (vc->vc_hi_font_mask == 0x100)
1999 vc->vc_def_color >>= 1;
2000 default_attr(vc);
2001 update_attr(vc);
2004 blankinterval = min(vc->vc_par[1], 60U) * 60;
2008 if (vc->vc_npar >= 1)
2009 vc->vc_bell_pitch = vc->vc_par[1];
2011 vc->vc_bell_pitch = DEFAULT_BELL_PITCH;
2014 if (vc->vc_npar >= 1)
2015 vc->vc_bell_duration = (vc->vc_par[1] < 2000) ?
2016 msecs_to_jiffies(vc->vc_par[1]) : 0;
2018 vc->vc_bell_duration = DEFAULT_BELL_DURATION;
2021 if (vc->vc_par[1] >= 1 && vc_cons_allocated(vc->vc_par[1] - 1))
2022 set_console(vc->vc_par[1] - 1);
2028 vesa_off_interval = min(vc->vc_par[1], 60U) * 60 * HZ;
2034 if (vc->vc_npar >= 1 && vc->vc_par[1] >= 50 &&
2035 vc->vc_par[1] <= USHRT_MAX)
2036 vc->vc_cur_blink_ms = vc->vc_par[1];
2038 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS;
2044 static void csi_at(struct vc_data *vc, unsigned int nr)
2046 nr = clamp(nr, 1, vc->vc_cols - vc->state.x);
2047 insert_char(vc, nr);
2051 static void csi_L(struct vc_data *vc)
2053 unsigned int nr = clamp(vc->vc_par[0], 1, vc->vc_rows - vc->state.y);
2055 con_scroll(vc, vc->state.y, vc->vc_bottom, SM_DOWN, nr);
2056 vc->vc_need_wrap = 0;
2060 static void csi_P(struct vc_data *vc)
2062 unsigned int nr = clamp(vc->vc_par[0], 1, vc->vc_cols - vc->state.x);
2064 delete_char(vc, nr);
2068 static void csi_M(struct vc_data *vc)
2070 unsigned int nr = clamp(vc->vc_par[0], 1, vc->vc_rows - vc->state.y);
2072 con_scroll(vc, vc->state.y, vc->vc_bottom, SM_UP, nr);
2073 vc->vc_need_wrap = 0;
2077 static void save_cur(struct vc_data *vc)
2079 memcpy(&vc->saved_state, &vc->state, sizeof(vc->state));
2083 static void restore_cur(struct vc_data *vc)
2085 memcpy(&vc->state, &vc->saved_state, sizeof(vc->state));
2087 gotoxy(vc, vc->state.x, vc->state.y);
2088 vc->vc_translate = set_translate(vc->state.Gx_charset[vc->state.charset],
2089 vc);
2090 update_attr(vc);
2091 vc->vc_need_wrap = 0;
2138 static void reset_terminal(struct vc_data *vc, int do_clear)
2142 vc->vc_top = 0;
2143 vc->vc_bottom = vc->vc_rows;
2144 vc->vc_state = ESnormal;
2145 vc->vc_priv = EPecma;
2146 vc->vc_translate = set_translate(LAT1_MAP, vc);
2147 vc->state.Gx_charset[0] = LAT1_MAP;
2148 vc->state.Gx_charset[1] = GRAF_MAP;
2149 vc->state.charset = 0;
2150 vc->vc_need_wrap = 0;
2151 vc->vc_report_mouse = 0;
2152 vc->vc_utf = default_utf8;
2153 vc->vc_utf_count = 0;
2155 vc->vc_disp_ctrl = 0;
2156 vc->vc_toggle_meta = 0;
2158 vc->vc_decscnm = 0;
2159 vc->vc_decom = 0;
2160 vc->vc_decawm = 1;
2161 vc->vc_deccm = global_cursor_default;
2162 vc->vc_decim = 0;
2164 vt_reset_keyboard(vc->vc_num);
2166 vc->vc_cursor_type = cur_default;
2167 vc->vc_complement_mask = vc->vc_s_complement_mask;
2169 default_attr(vc);
2170 update_attr(vc);
2172 bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT);
2174 set_bit(i, vc->vc_tab_stop);
2176 vc->vc_bell_pitch = DEFAULT_BELL_PITCH;
2177 vc->vc_bell_duration = DEFAULT_BELL_DURATION;
2178 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS;
2180 gotoxy(vc, 0, 0);
2181 save_cur(vc);
2183 csi_J(vc, CSI_J_VISIBLE);
2186 static void vc_setGx(struct vc_data *vc, unsigned int which, u8 c)
2188 unsigned char *charset = &vc->state.Gx_charset[which];
2205 if (vc->state.charset == which)
2206 vc->vc_translate = set_translate(*charset, vc);
2238 * E.g. ESC sets the state of vc to ESesc.
2242 static bool handle_ascii(struct tty_struct *tty, struct vc_data *vc, u8 c)
2248 if (ansi_control_string(vc->vc_state))
2249 vc->vc_state = ESnormal;
2250 else if (vc->vc_bell_duration)
2251 kd_mksound(vc->vc_bell_pitch, vc->vc_bell_duration);
2254 bs(vc);
2257 vc->vc_pos -= (vc->state.x << 1);
2259 vc->state.x = find_next_bit(vc->vc_tab_stop,
2260 min(vc->vc_cols - 1, VC_TABSTOPS_COUNT),
2261 vc->state.x + 1);
2262 if (vc->state.x >= VC_TABSTOPS_COUNT)
2263 vc->state.x = vc->vc_cols - 1;
2265 vc->vc_pos += (vc->state.x << 1);
2266 notify_write(vc, '\t');
2271 lf(vc);
2272 if (!is_kbd(vc, lnm))
2276 cr(vc);
2279 vc->state.charset = 1;
2280 vc->vc_translate = set_translate(vc->state.Gx_charset[1], vc);
2281 vc->vc_disp_ctrl = 1;
2284 vc->state.charset = 0;
2285 vc->vc_translate = set_translate(vc->state.Gx_charset[0], vc);
2286 vc->vc_disp_ctrl = 0;
2290 vc->vc_state = ESnormal;
2293 vc->vc_state = ESesc;
2296 del(vc);
2299 vc->vc_state = ESsquare;
2307 * Handle a character (@c) following an ESC (when @vc is in the ESesc state).
2311 static void handle_esc(struct tty_struct *tty, struct vc_data *vc, u8 c)
2313 vc->vc_state = ESnormal;
2316 vc->vc_state = ESsquare;
2319 vc->vc_state = ESnonstd;
2322 vc->vc_state = ESapc;
2325 vc->vc_state = ESpm;
2328 vc->vc_state = ESpercent;
2331 cr(vc);
2332 lf(vc);
2335 ri(vc);
2338 lf(vc);
2341 if (vc->state.x < VC_TABSTOPS_COUNT)
2342 set_bit(vc->state.x, vc->vc_tab_stop);
2345 vc->vc_state = ESdcs;
2351 save_cur(vc);
2354 restore_cur(vc);
2357 vc->vc_state = ESsetG0;
2360 vc->vc_state = ESsetG1;
2363 vc->vc_state = EShash;
2366 reset_terminal(vc, 1);
2369 clr_kbd(vc, kbdapplic);
2372 set_kbd(vc, kbdapplic);
2379 * are in @vc->vc_par and the char is in @c here.
2381 static void csi_DEC(struct tty_struct *tty, struct vc_data *vc, u8 c)
2385 csi_DEC_hl(vc, true);
2388 csi_DEC_hl(vc, false);
2391 if (vc->vc_par[0])
2392 vc->vc_cursor_type = CUR_MAKE(vc->vc_par[0],
2393 vc->vc_par[1],
2394 vc->vc_par[2]);
2396 vc->vc_cursor_type = cur_default;
2400 if (vc->vc_par[0])
2401 vc->vc_complement_mask = vc->vc_par[0] << 8 | vc->vc_par[1];
2403 vc->vc_complement_mask = vc->vc_s_complement_mask;
2406 if (vc->vc_par[0] == 5)
2408 else if (vc->vc_par[0] == 6)
2409 cursor_report(vc, tty);
2416 * "ESC [ parameters char". Parameters are in @vc->vc_par and the char is in
2419 static void csi_ECMA(struct tty_struct *tty, struct vc_data *vc, u8 c)
2424 if (vc->vc_par[0])
2425 vc->vc_par[0]--;
2426 gotoxy(vc, vc->vc_par[0], vc->state.y);
2429 if (!vc->vc_par[0])
2430 vc->vc_par[0]++;
2431 gotoxy(vc, vc->state.x, vc->state.y - vc->vc_par[0]);
2435 if (!vc->vc_par[0])
2436 vc->vc_par[0]++;
2437 gotoxy(vc, vc->state.x, vc->state.y + vc->vc_par[0]);
2441 if (!vc->vc_par[0])
2442 vc->vc_par[0]++;
2443 gotoxy(vc, vc->state.x + vc->vc_par[0], vc->state.y);
2446 if (!vc->vc_par[0])
2447 vc->vc_par[0]++;
2448 gotoxy(vc, vc->state.x - vc->vc_par[0], vc->state.y);
2451 if (!vc->vc_par[0])
2452 vc->vc_par[0]++;
2453 gotoxy(vc, 0, vc->state.y + vc->vc_par[0]);
2456 if (!vc->vc_par[0])
2457 vc->vc_par[0]++;
2458 gotoxy(vc, 0, vc->state.y - vc->vc_par[0]);
2461 if (vc->vc_par[0])
2462 vc->vc_par[0]--;
2463 gotoxay(vc, vc->state.x ,vc->vc_par[0]);
2467 if (vc->vc_par[0])
2468 vc->vc_par[0]--;
2469 if (vc->vc_par[1])
2470 vc->vc_par[1]--;
2471 gotoxay(vc, vc->vc_par[1], vc->vc_par[0]);
2474 csi_J(vc, vc->vc_par[0]);
2477 csi_K(vc);
2480 csi_L(vc);
2483 csi_M(vc);
2486 csi_P(vc);
2489 if (!vc->vc_par[0])
2493 if (!vc->vc_par[0] && vc->state.x < VC_TABSTOPS_COUNT)
2494 set_bit(vc->state.x, vc->vc_tab_stop);
2495 else if (vc->vc_par[0] == 3)
2496 bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT);
2499 csi_hl(vc, true);
2502 csi_hl(vc, false);
2505 csi_m(vc);
2508 if (vc->vc_par[0] == 5)
2510 else if (vc->vc_par[0] == 6)
2511 cursor_report(vc, tty);
2515 if (vc->vc_par[0] < 4)
2516 vt_set_led_state(vc->vc_num,
2517 (vc->vc_par[0] < 3) ? vc->vc_par[0] : 4);
2520 if (!vc->vc_par[0])
2521 vc->vc_par[0]++;
2522 if (!vc->vc_par[1])
2523 vc->vc_par[1] = vc->vc_rows;
2525 if (vc->vc_par[0] < vc->vc_par[1] &&
2526 vc->vc_par[1] <= vc->vc_rows) {
2527 vc->vc_top = vc->vc_par[0] - 1;
2528 vc->vc_bottom = vc->vc_par[1];
2529 gotoxay(vc, 0, 0);
2533 save_cur(vc);
2536 restore_cur(vc);
2539 csi_X(vc);
2542 csi_at(vc, vc->vc_par[0]);
2545 csi_RSB(vc);
2551 static void vc_reset_params(struct vc_data *vc)
2553 memset(vc->vc_par, 0, sizeof(vc->vc_par));
2554 vc->vc_npar = 0;
2558 static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c)
2564 if (ansi_control_string(vc->vc_state) && c >= ASCII_IGNORE_FIRST &&
2568 if (handle_ascii(tty, vc, c))
2571 switch(vc->vc_state) {
2573 handle_esc(tty, vc, c);
2578 vc_reset_params(vc);
2579 vc->vc_state = ESpalette;
2582 reset_palette(vc);
2585 vc->vc_state = ESosc;
2588 vc->vc_state = ESnormal;
2592 vc->vc_par[vc->vc_npar++] = hex_to_bin(c);
2593 if (vc->vc_npar == 7) {
2594 int i = vc->vc_par[0] * 3, j = 1;
2595 vc->vc_palette[i] = 16 * vc->vc_par[j++];
2596 vc->vc_palette[i++] += vc->vc_par[j++];
2597 vc->vc_palette[i] = 16 * vc->vc_par[j++];
2598 vc->vc_palette[i++] += vc->vc_par[j++];
2599 vc->vc_palette[i] = 16 * vc->vc_par[j++];
2600 vc->vc_palette[i] += vc->vc_par[j];
2601 set_palette(vc);
2602 vc->vc_state = ESnormal;
2605 vc->vc_state = ESnormal;
2608 vc_reset_params(vc);
2610 vc->vc_state = ESgetpars;
2613 vc->vc_state = ESfunckey;
2616 vc->vc_priv = EPdec;
2619 vc->vc_priv = EPgt;
2622 vc->vc_priv = EPeq;
2625 vc->vc_priv = EPlt;
2628 vc->vc_priv = EPecma;
2633 if (vc->vc_npar < NPAR - 1) {
2634 vc->vc_npar++;
2639 vc->vc_par[vc->vc_npar] *= 10;
2640 vc->vc_par[vc->vc_npar] += c - '0';
2644 vc->vc_state = EScsiignore;
2650 vc->vc_state = ESnormal;
2652 switch (vc->vc_priv) {
2654 csi_DEC(tty, vc, c);
2657 csi_ECMA(tty, vc, c);
2665 vc->vc_state = ESnormal;
2668 vc->vc_state = ESnormal;
2671 vc->vc_utf = 0;
2675 vc->vc_utf = 1;
2680 vc->vc_state = ESnormal;
2683 vc->vc_state = ESnormal;
2686 vc->vc_video_erase_char =
2687 (vc->vc_video_erase_char & 0xff00) | 'E';
2688 csi_J(vc, CSI_J_VISIBLE);
2689 vc->vc_video_erase_char =
2690 (vc->vc_video_erase_char & 0xff00) | ' ';
2691 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2);
2695 vc_setGx(vc, 0, c);
2696 vc->vc_state = ESnormal;
2699 vc_setGx(vc, 1, c);
2700 vc->vc_state = ESnormal;
2711 vc->vc_state = ESnormal;
2757 static void con_flush(struct vc_data *vc, struct vc_draw_region *draw)
2762 vc->vc_sw->con_putcs(vc, (u16 *)draw->from,
2763 (u16 *)draw->to - (u16 *)draw->from, vc->state.y,
2768 static inline int vc_translate_ascii(const struct vc_data *vc, int c)
2771 if (vc->vc_toggle_meta)
2774 return vc->vc_translate[c];
2795 * @vc: virtual console
2812 static int vc_translate_unicode(struct vc_data *vc, int c, bool *rescan)
2819 if (!vc->vc_utf_count)
2822 vc->vc_utf_char = (vc->vc_utf_char << 6) | (c & 0x3f);
2823 vc->vc_npar++;
2824 if (--vc->vc_utf_count)
2828 c = vc->vc_utf_char;
2830 if (c <= utf8_length_changes[vc->vc_npar - 1] ||
2831 c > utf8_length_changes[vc->vc_npar])
2838 if (vc->vc_utf_count) {
2841 vc->vc_utf_count = 0;
2850 vc->vc_npar = 0;
2852 vc->vc_utf_count = 1;
2853 vc->vc_utf_char = (c & 0x1f);
2855 vc->vc_utf_count = 2;
2856 vc->vc_utf_char = (c & 0x0f);
2858 vc->vc_utf_count = 3;
2859 vc->vc_utf_char = (c & 0x07);
2868 static int vc_translate(struct vc_data *vc, int *c, bool *rescan)
2871 if (vc->vc_state != ESnormal)
2874 if (vc->vc_utf && !vc->vc_disp_ctrl)
2875 return *c = vc_translate_unicode(vc, *c, rescan);
2878 return vc_translate_ascii(vc, *c);
2881 static inline unsigned char vc_invert_attr(const struct vc_data *vc)
2883 if (!vc->vc_can_do_color)
2884 return vc->vc_attr ^ 0x08;
2886 if (vc->vc_hi_font_mask == 0x100)
2887 return (vc->vc_attr & 0x11) |
2888 ((vc->vc_attr & 0xe0) >> 4) |
2889 ((vc->vc_attr & 0x0e) << 4);
2891 return (vc->vc_attr & 0x88) |
2892 ((vc->vc_attr & 0x70) >> 4) |
2893 ((vc->vc_attr & 0x07) << 4);
2896 static bool vc_is_control(struct vc_data *vc, int tc, int c)
2912 if (vc->vc_state != ESnormal)
2928 if (vc->vc_disp_ctrl)
2931 return vc->vc_utf || (CTRL_ACTION & BIT(c));
2934 if (c == ASCII_DEL && !vc->vc_disp_ctrl)
2943 static int vc_con_write_normal(struct vc_data *vc, int tc, int c,
2947 unsigned char vc_attr = vc->vc_attr;
2948 u16 himask = vc->vc_hi_font_mask, charmask = himask ? 0x1ff : 0xff;
2952 if (vc->vc_utf && !vc->vc_disp_ctrl) {
2958 tc = conv_uni_to_pc(vc, tc);
2964 if ((!vc->vc_utf || vc->vc_disp_ctrl || c < 128) &&
2980 tc = conv_uni_to_pc(vc, 0xfffd);
2983 tc = conv_uni_to_pc(vc, '?');
2987 vc_attr = vc_invert_attr(vc);
2988 con_flush(vc, draw);
2995 if (vc->vc_need_wrap || vc->vc_decim)
2996 con_flush(vc, draw);
2997 if (vc->vc_need_wrap) {
2998 cr(vc);
2999 lf(vc);
3001 if (vc->vc_decim)
3002 insert_char(vc, 1);
3003 vc_uniscr_putc(vc, next_c);
3010 scr_writew(tc, (u16 *)vc->vc_pos);
3012 if (con_should_update(vc) && draw->x < 0) {
3013 draw->x = vc->state.x;
3014 draw->from = vc->vc_pos;
3016 if (vc->state.x == vc->vc_cols - 1) {
3017 vc->vc_need_wrap = vc->vc_decawm;
3018 draw->to = vc->vc_pos + 2;
3020 vc->state.x++;
3021 draw->to = (vc->vc_pos += 2);
3028 tc = conv_uni_to_pc(vc, ' ');
3033 notify_write(vc, c);
3036 con_flush(vc, draw);
3049 struct vc_data *vc = tty->driver_data;
3057 currcons = vc->vc_num;
3067 if (con_is_fg(vc))
3068 hide_cursor(vc);
3070 param.vc = vc;
3081 tc = vc_translate(vc, &c, &rescan);
3090 if (vc_is_control(vc, tc, c)) {
3091 con_flush(vc, &draw);
3092 do_con_trol(tty, vc, orig);
3096 if (vc_con_write_normal(vc, tc, c, &draw) < 0)
3102 con_flush(vc, &draw);
3104 notify_update(vc);
3138 struct vc_data *vc = vc_cons[fg_console].d;
3140 if (vc->vc_mode == KD_TEXT && vc->vc_sw->con_scrolldelta)
3141 vc->vc_sw->con_scrolldelta(vc, scrollback_delta);
3155 struct vc_data *vc = vc_cons[fg_console].d;
3158 (vc->vt_mode.mode == VT_AUTO && vc->vc_mode == KD_GRAPHICS)) {
3220 struct vc_data *vc = vc_cons[fg_console].d;
3235 vc = vc_cons[kmsg_console - 1].d;
3243 if (vc->vc_mode != KD_TEXT)
3247 if (con_is_fg(vc))
3248 hide_cursor(vc);
3250 start = (ushort *)vc->vc_pos;
3251 start_x = vc->state.x;
3256 c == ASCII_BACKSPACE || vc->vc_need_wrap) {
3257 if (cnt && con_is_visible(vc))
3258 vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x);
3261 bs(vc);
3262 start = (ushort *)vc->vc_pos;
3263 start_x = vc->state.x;
3267 lf(vc);
3268 cr(vc);
3269 start = (ushort *)vc->vc_pos;
3270 start_x = vc->state.x;
3274 vc_uniscr_putc(vc, c);
3275 scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos);
3276 notify_write(vc, c);
3278 if (vc->state.x == vc->vc_cols - 1) {
3279 vc->vc_need_wrap = 1;
3281 vc->vc_pos += 2;
3282 vc->state.x++;
3285 if (cnt && con_is_visible(vc))
3286 vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x);
3287 set_cursor(vc);
3288 notify_update(vc);
3463 struct vc_data *vc = tty->driver_data;
3465 wake_up_interruptible(&vc->paste_wait);
3498 struct vc_data *vc = tty->driver_data;
3504 set_cursor(vc);
3514 struct vc_data *vc;
3522 vc = vc_cons[currcons].d;
3525 if (vc->port.tty) {
3530 ret = tty_port_install(&vc->port, driver, tty);
3534 tty->driver_data = vc;
3535 vc->port.tty = tty;
3536 tty_port_get(&vc->port);
3542 if (vc->vc_utf)
3565 struct vc_data *vc = tty->driver_data;
3566 BUG_ON(vc == NULL);
3568 vc->port.tty = NULL;
3574 struct vc_data *vc = tty->driver_data;
3576 tty_port_put(&vc->port);
3586 static void vc_init(struct vc_data *vc, int do_clear)
3590 set_origin(vc);
3591 vc->vc_pos = vc->vc_origin;
3592 reset_vc(vc);
3594 vc->vc_palette[k++] = default_red[j] ;
3595 vc->vc_palette[k++] = default_grn[j] ;
3596 vc->vc_palette[k++] = default_blu[j] ;
3598 vc->vc_def_color = default_color;
3599 vc->vc_ulcolor = default_underline_color;
3600 vc->vc_itcolor = default_italic_color;
3601 vc->vc_halfcolor = 0x08; /* grey */
3602 init_waitqueue_head(&vc->paste_wait);
3603 reset_terminal(vc, do_clear);
3615 struct vc_data *vc;
3651 vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT);
3653 tty_port_init(&vc->port);
3654 visual_init(vc, currcons, true);
3655 /* Assuming vc->vc_{cols,rows,screenbuf_size} are sane here. */
3656 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT);
3657 vc_init(vc, currcons || !vc->vc_sw->con_save_screen);
3660 master_display_fg = vc = vc_cons[currcons].d;
3661 set_origin(vc);
3662 save_screen(vc);
3663 gotoxy(vc, vc->state.x, vc->state.y);
3664 csi_J(vc, CSI_J_CURSOR_TO_END);
3665 update_screen(vc);
3667 vc->vc_can_do_color ? "colour" : "mono",
3668 display_desc, vc->vc_cols, vc->vc_rows);
3720 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
3803 struct vc_data *vc = vc_cons[i].d;
3810 if (!vc || !vc->vc_sw)
3815 if (con_is_visible(vc)) {
3817 save_screen(vc);
3820 old_was_color = vc->vc_can_do_color;
3821 vc->vc_sw->con_deinit(vc);
3822 vc->vc_origin = (unsigned long)vc->vc_screenbuf;
3823 visual_init(vc, i, false);
3824 set_origin(vc);
3825 update_attr(vc);
3831 if (old_was_color != vc->vc_can_do_color)
3832 clear_buffer_attributes(vc);
3839 struct vc_data *vc = vc_cons[j].d;
3842 vc->vc_can_do_color ? "colour" : "mono",
3843 desc, vc->vc_cols, vc->vc_rows);
3846 vc = vc_cons[k].d;
3847 update_screen(vc);
4134 * @vc: virtual console
4138 bool con_is_visible(const struct vc_data *vc)
4142 return *vc->vc_display_fg == vc;
4148 * @vc: virtual console
4154 void con_debug_enter(struct vc_data *vc)
4159 saved_vc_mode = vc->vc_mode;
4161 vc->vc_mode = KD_TEXT;
4163 if (vc->vc_sw->con_debug_enter)
4164 vc->vc_sw->con_debug_enter(vc);
4167 if (vc->vc_rows < 999) {
4176 snprintf(lns, 4, "%i", vc->vc_rows);
4180 if (vc->vc_cols < 999) {
4189 snprintf(cols, 4, "%i", vc->vc_cols);
4205 struct vc_data *vc;
4213 vc = vc_cons[fg_console].d;
4214 if (vc->vc_sw->con_debug_leave)
4215 vc->vc_sw->con_debug_leave(vc);
4461 struct vc_data *vc = vc_cons[fg_console].d;
4471 vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0);
4478 hide_cursor(vc);
4479 save_screen(vc);
4480 vc->vc_sw->con_blank(vc, VESA_VSYNC_SUSPEND, 1);
4483 set_origin(vc);
4490 if (vc->vc_mode != KD_TEXT) {
4495 hide_cursor(vc);
4499 save_screen(vc);
4501 i = vc->vc_sw->con_blank(vc, vesa_off_interval ? VESA_VSYNC_SUSPEND :
4505 set_origin(vc);
4514 vt_event_post(VT_EVENT_BLANK, vc->vc_num, vc->vc_num);
4523 struct vc_data *vc;
4543 vc = vc_cons[fg_console].d;
4544 if (vc->vc_mode != KD_TEXT)
4553 if (vc->vc_sw->con_blank(vc, VESA_NO_BLANKING, leaving_gfx))
4555 update_screen(vc);
4558 set_palette(vc);
4559 set_cursor(vc);
4560 vt_event_post(VT_EVENT_UNBLANK, vc->vc_num, vc->vc_num);
4618 static void set_palette(struct vc_data *vc)
4622 if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_set_palette)
4623 vc->vc_sw->con_set_palette(vc, color_table);
4679 void reset_palette(struct vc_data *vc)
4683 vc->vc_palette[k++] = default_red[j];
4684 vc->vc_palette[k++] = default_grn[j];
4685 vc->vc_palette[k++] = default_blu[j];
4687 set_palette(vc);
4708 static int con_font_get(struct vc_data *vc, struct console_font_op *op)
4726 if (vc->vc_mode != KD_TEXT)
4728 else if (vc->vc_sw->con_font_get)
4729 rc = vc->vc_sw->con_font_get(vc, &font, vpitch);
4758 static int con_font_set(struct vc_data *vc, const struct console_font_op *op)
4765 if (vc->vc_mode != KD_TEXT)
4789 if (vc->vc_mode != KD_TEXT)
4791 else if (vc->vc_sw->con_font_set) {
4792 if (vc_is_sel(vc))
4794 rc = vc->vc_sw->con_font_set(vc, &font, vpitch, op->flags);
4802 static int con_font_default(struct vc_data *vc, struct console_font_op *op)
4818 if (vc->vc_mode != KD_TEXT) {
4822 if (vc->vc_sw->con_font_default) {
4823 if (vc_is_sel(vc))
4825 rc = vc->vc_sw->con_font_default(vc, &font, s);
4836 int con_font_op(struct vc_data *vc, struct console_font_op *op)
4841 return con_font_set(vc, op);
4844 return con_font_get(vc, op);
4846 return con_font_default(vc, op);
4859 u16 screen_glyph(const struct vc_data *vc, int offset)
4861 u16 w = scr_readw(screenpos(vc, offset, true));
4864 if (w & vc->vc_hi_font_mask)
4870 u32 screen_glyph_unicode(const struct vc_data *vc, int n)
4872 u32 **uni_lines = vc->vc_uni_lines;
4875 return uni_lines[n / vc->vc_cols][n % vc->vc_cols];
4877 return inverse_translate(vc, screen_glyph(vc, n * 2), true);
4882 unsigned short *screen_pos(const struct vc_data *vc, int w_offset, bool viewed)
4884 return screenpos(vc, 2 * w_offset, viewed);
4888 void getconsxy(const struct vc_data *vc, unsigned char xy[static 2])
4891 xy[0] = min(vc->state.x, 0xFFu);
4892 xy[1] = min(vc->state.y, 0xFFu);
4895 void putconsxy(struct vc_data *vc, unsigned char xy[static const 2])
4897 hide_cursor(vc);
4898 gotoxy(vc, xy[0], xy[1]);
4899 set_cursor(vc);
4902 u16 vcs_scr_readw(const struct vc_data *vc, const u16 *org)
4904 if ((unsigned long)org == vc->vc_pos && softcursor_original != -1)
4909 void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org)
4912 if ((unsigned long)org == vc->vc_pos) {
4914 add_softcursor(vc);
4918 void vcs_scr_updated(struct vc_data *vc)
4920 notify_update(vc);