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 unsigned short *screenpos(const struct vc_data *vc, int offset,
295 p = (unsigned short *)(vc->vc_origin + offset);
296 else if (!vc->vc_sw->con_screen_pos)
297 p = (unsigned short *)(vc->vc_visible_origin + offset);
299 p = vc->vc_sw->con_screen_pos(vc, offset);
355 static void vc_uniscr_set(struct vc_data *vc, u32 **new_uni_lines)
357 vc_uniscr_free(vc->vc_uni_lines);
358 vc->vc_uni_lines = new_uni_lines;
361 static void vc_uniscr_putc(struct vc_data *vc, u32 uc)
363 if (vc->vc_uni_lines)
364 vc->vc_uni_lines[vc->state.y][vc->state.x] = uc;
367 static void vc_uniscr_insert(struct vc_data *vc, unsigned int nr)
369 if (vc->vc_uni_lines) {
370 u32 *ln = vc->vc_uni_lines[vc->state.y];
371 unsigned int x = vc->state.x, cols = vc->vc_cols;
378 static void vc_uniscr_delete(struct vc_data *vc, unsigned int nr)
380 if (vc->vc_uni_lines) {
381 u32 *ln = vc->vc_uni_lines[vc->state.y];
382 unsigned int x = vc->state.x, cols = vc->vc_cols;
389 static void vc_uniscr_clear_line(struct vc_data *vc, unsigned int x,
392 if (vc->vc_uni_lines)
393 memset32(&vc->vc_uni_lines[vc->state.y][x], ' ', nr);
396 static void vc_uniscr_clear_lines(struct vc_data *vc, unsigned int y,
399 if (vc->vc_uni_lines)
401 memset32(vc->vc_uni_lines[y++], ' ', vc->vc_cols);
426 static void vc_uniscr_scroll(struct vc_data *vc, unsigned int top,
430 u32 **uni_lines = vc->vc_uni_lines;
438 vc_uniscr_clear_lines(vc, top, nr);
441 vc_uniscr_clear_lines(vc, bottom - nr, nr);
482 int vc_uniscr_check(struct vc_data *vc)
490 if (!vc->vc_utf)
493 if (vc->vc_uni_lines)
496 uni_lines = vc_uniscr_alloc(vc->vc_cols, vc->vc_rows);
506 p = (unsigned short *)vc->vc_origin;
507 mask = vc->vc_hi_font_mask | 0xff;
508 for (y = 0; y < vc->vc_rows; y++) {
510 for (x = 0; x < vc->vc_cols; x++) {
512 line[x] = inverse_translate(vc, glyph, true);
516 vc->vc_uni_lines = uni_lines;
526 void vc_uniscr_copy_line(const struct vc_data *vc, void *dest, bool viewed,
529 u32 **uni_lines = vc->vc_uni_lines;
530 int offset = row * vc->vc_size_row + col * 2;
536 pos = (unsigned long)screenpos(vc, offset, viewed);
537 if (pos >= vc->vc_origin && pos < vc->vc_scr_end) {
543 row = (pos - vc->vc_origin) / vc->vc_size_row;
544 col = ((pos - vc->vc_origin) % vc->vc_size_row) / 2;
554 int mask = vc->vc_hi_font_mask | 0xff;
558 *uni_buf++ = inverse_translate(vc, glyph, true);
563 static void con_scroll(struct vc_data *vc, unsigned int top,
572 if (bottom > vc->vc_rows || top >= bottom || nr < 1)
575 vc_uniscr_scroll(vc, top, bottom, dir, nr);
576 if (con_is_visible(vc) &&
577 vc->vc_sw->con_scroll(vc, top, bottom, dir, nr))
580 src = clear = (u16 *)(vc->vc_origin + vc->vc_size_row * top);
581 dst = (u16 *)(vc->vc_origin + vc->vc_size_row * (top + nr));
584 clear = src + (rows - nr) * vc->vc_cols;
587 scr_memmovew(dst, src, (rows - nr) * vc->vc_size_row);
588 scr_memsetw(clear, vc->vc_video_erase_char, vc->vc_size_row * nr);
591 static void do_update_region(struct vc_data *vc, unsigned long start, int count)
597 if (!vc->vc_sw->con_getxy) {
598 offset = (start - vc->vc_origin) / 2;
599 xx = offset % vc->vc_cols;
600 yy = offset / vc->vc_cols;
603 start = vc->vc_sw->con_getxy(vc, start, &nxx, &nyy);
610 while (xx < vc->vc_cols && count) {
613 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx);
623 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx);
628 if (vc->vc_sw->con_getxy) {
630 start = vc->vc_sw->con_getxy(vc, start, NULL, NULL);
635 void update_region(struct vc_data *vc, unsigned long start, int count)
639 if (con_should_update(vc)) {
640 hide_cursor(vc);
641 do_update_region(vc, start, count);
642 set_cursor(vc);
649 static u8 build_attr(struct vc_data *vc, u8 _color,
653 if (vc->vc_sw->con_build_attr)
654 return vc->vc_sw->con_build_attr(vc, _color, _intensity,
669 if (!vc->vc_can_do_color)
676 a = (a & 0xF0) | vc->vc_itcolor;
678 a = (a & 0xf0) | vc->vc_ulcolor;
680 a = (a & 0xf0) | vc->vc_halfcolor;
687 if (vc->vc_hi_font_mask == 0x100)
693 static void update_attr(struct vc_data *vc)
695 vc->vc_attr = build_attr(vc, vc->state.color, vc->state.intensity,
696 vc->state.blink, vc->state.underline,
697 vc->state.reverse ^ vc->vc_decscnm, vc->state.italic);
698 vc->vc_video_erase_char = ' ' | (build_attr(vc, vc->state.color,
699 VCI_NORMAL, vc->state.blink, false,
700 vc->vc_decscnm, false) << 8);
704 void invert_screen(struct vc_data *vc, int offset, int count, bool viewed)
711 p = screenpos(vc, offset, viewed);
712 if (vc->vc_sw->con_invert_region) {
713 vc->vc_sw->con_invert_region(vc, p, count);
719 if (!vc->vc_can_do_color) {
726 } else if (vc->vc_hi_font_mask == 0x100) {
747 if (con_should_update(vc))
748 do_update_region(vc, (unsigned long) p, count);
749 notify_update(vc);
753 void complement_pos(struct vc_data *vc, int offset)
762 old_offset < vc->vc_screenbuf_size) {
763 scr_writew(old, screenpos(vc, old_offset, true));
764 if (con_should_update(vc))
765 vc->vc_sw->con_putc(vc, old, oldy, oldx);
766 notify_update(vc);
772 offset < vc->vc_screenbuf_size) {
775 p = screenpos(vc, offset, true);
777 new = old ^ vc->vc_complement_mask;
779 if (con_should_update(vc)) {
780 oldx = (offset >> 1) % vc->vc_cols;
781 oldy = (offset >> 1) / vc->vc_cols;
782 vc->vc_sw->con_putc(vc, new, oldy, oldx);
784 notify_update(vc);
788 static void insert_char(struct vc_data *vc, unsigned int nr)
790 unsigned short *p = (unsigned short *) vc->vc_pos;
792 vc_uniscr_insert(vc, nr);
793 scr_memmovew(p + nr, p, (vc->vc_cols - vc->state.x - nr) * 2);
794 scr_memsetw(p, vc->vc_video_erase_char, nr * 2);
795 vc->vc_need_wrap = 0;
796 if (con_should_update(vc))
797 do_update_region(vc, (unsigned long) p,
798 vc->vc_cols - vc->state.x);
801 static void delete_char(struct vc_data *vc, unsigned int nr)
803 unsigned short *p = (unsigned short *) vc->vc_pos;
805 vc_uniscr_delete(vc, nr);
806 scr_memmovew(p, p + nr, (vc->vc_cols - vc->state.x - nr) * 2);
807 scr_memsetw(p + vc->vc_cols - vc->state.x - nr, vc->vc_video_erase_char,
809 vc->vc_need_wrap = 0;
810 if (con_should_update(vc))
811 do_update_region(vc, (unsigned long) p,
812 vc->vc_cols - vc->state.x);
817 static void add_softcursor(struct vc_data *vc)
819 int i = scr_readw((u16 *) vc->vc_pos);
820 u32 type = vc->vc_cursor_type;
834 scr_writew(i, (u16 *)vc->vc_pos);
835 if (con_should_update(vc))
836 vc->vc_sw->con_putc(vc, i, vc->state.y, vc->state.x);
839 static void hide_softcursor(struct vc_data *vc)
842 scr_writew(softcursor_original, (u16 *)vc->vc_pos);
843 if (con_should_update(vc))
844 vc->vc_sw->con_putc(vc, softcursor_original,
845 vc->state.y, vc->state.x);
850 static void hide_cursor(struct vc_data *vc)
852 if (vc_is_sel(vc))
855 vc->vc_sw->con_cursor(vc, CM_ERASE);
856 hide_softcursor(vc);
859 static void set_cursor(struct vc_data *vc)
861 if (!con_is_fg(vc) || console_blanked || vc->vc_mode == KD_GRAPHICS)
863 if (vc->vc_deccm) {
864 if (vc_is_sel(vc))
866 add_softcursor(vc);
867 if (CUR_SIZE(vc->vc_cursor_type) != CUR_NONE)
868 vc->vc_sw->con_cursor(vc, CM_DRAW);
870 hide_cursor(vc);
873 static void set_origin(struct vc_data *vc)
877 if (!con_is_visible(vc) ||
878 !vc->vc_sw->con_set_origin ||
879 !vc->vc_sw->con_set_origin(vc))
880 vc->vc_origin = (unsigned long)vc->vc_screenbuf;
881 vc->vc_visible_origin = vc->vc_origin;
882 vc->vc_scr_end = vc->vc_origin + vc->vc_screenbuf_size;
883 vc->vc_pos = vc->vc_origin + vc->vc_size_row * vc->state.y +
884 2 * vc->state.x;
887 static void save_screen(struct vc_data *vc)
891 if (vc->vc_sw->con_save_screen)
892 vc->vc_sw->con_save_screen(vc);
895 static void flush_scrollback(struct vc_data *vc)
899 set_origin(vc);
900 if (vc->vc_sw->con_flush_scrollback) {
901 vc->vc_sw->con_flush_scrollback(vc);
902 } else if (con_is_visible(vc)) {
911 hide_cursor(vc);
912 vc->vc_sw->con_switch(vc);
913 set_cursor(vc);
921 void clear_buffer_attributes(struct vc_data *vc)
923 unsigned short *p = (unsigned short *)vc->vc_origin;
924 int count = vc->vc_screenbuf_size / 2;
925 int mask = vc->vc_hi_font_mask | 0xff;
928 scr_writew((scr_readw(p)&mask) | (vc->vc_video_erase_char & ~mask), p);
932 void redraw_screen(struct vc_data *vc, int is_switch)
938 if (!vc) {
946 if (old_vc == vc)
948 if (!con_is_visible(vc))
950 *vc->vc_display_fg = vc;
951 fg_console = vc->vc_num;
960 hide_cursor(vc);
966 int old_was_color = vc->vc_can_do_color;
968 set_origin(vc);
969 update = vc->vc_sw->con_switch(vc);
970 set_palette(vc);
977 if (old_was_color != vc->vc_can_do_color) {
978 update_attr(vc);
979 clear_buffer_attributes(vc);
982 if (update && vc->vc_mode != KD_GRAPHICS)
983 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2);
985 set_cursor(vc);
988 notify_update(vc);
1002 static void visual_init(struct vc_data *vc, int num, int init)
1004 /* ++Geert: vc->vc_sw->con_init determines console size */
1005 if (vc->vc_sw)
1006 module_put(vc->vc_sw->owner);
1007 vc->vc_sw = conswitchp;
1010 vc->vc_sw = con_driver_map[num];
1012 __module_get(vc->vc_sw->owner);
1013 vc->vc_num = num;
1014 vc->vc_display_fg = &master_display_fg;
1015 if (vc->uni_pagedict_loc)
1016 con_free_unimap(vc);
1017 vc->uni_pagedict_loc = &vc->uni_pagedict;
1018 vc->uni_pagedict = NULL;
1019 vc->vc_hi_font_mask = 0;
1020 vc->vc_complement_mask = 0;
1021 vc->vc_can_do_color = 0;
1022 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS;
1023 vc->vc_sw->con_init(vc, init);
1024 if (!vc->vc_complement_mask)
1025 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
1026 vc->vc_s_complement_mask = vc->vc_complement_mask;
1027 vc->vc_size_row = vc->vc_cols << 1;
1028 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row;
1032 static void visual_deinit(struct vc_data *vc)
1034 vc->vc_sw->con_deinit(vc);
1035 module_put(vc->vc_sw->owner);
1040 struct vc_data *vc = container_of(port, struct vc_data, port);
1042 kfree(vc);
1060 struct vc_data *vc;
1077 param.vc = vc = kzalloc(sizeof(struct vc_data), GFP_KERNEL);
1078 if (!vc)
1081 vc_cons[currcons].d = vc;
1082 tty_port_init(&vc->port);
1083 vc->port.ops = &vc_port_ops;
1086 visual_init(vc, currcons, 1);
1088 if (!*vc->uni_pagedict_loc)
1089 con_set_default_unimap(vc);
1092 if (vc->vc_cols > VC_MAXCOL || vc->vc_rows > VC_MAXROW ||
1093 vc->vc_screenbuf_size > KMALLOC_MAX_SIZE || !vc->vc_screenbuf_size)
1096 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_KERNEL);
1097 if (!vc->vc_screenbuf)
1105 vc_init(vc, 1);
1111 visual_deinit(vc);
1112 kfree(vc);
1117 static inline int resize_screen(struct vc_data *vc, int width, int height,
1123 if (vc->vc_sw->con_resize)
1124 err = vc->vc_sw->con_resize(vc, width, height, user);
1132 * @vc: virtual console private data
1144 static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
1157 if (!vc)
1160 user = vc->vc_resize_user;
1161 vc->vc_resize_user = 0;
1166 new_cols = (cols ? cols : vc->vc_cols);
1167 new_rows = (lines ? lines : vc->vc_rows);
1171 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) {
1188 return resize_screen(vc, new_cols, new_rows, user);
1197 if (vc->vc_uni_lines) {
1205 if (vc_is_sel(vc))
1208 old_rows = vc->vc_rows;
1209 old_row_size = vc->vc_size_row;
1211 err = resize_screen(vc, new_cols, new_rows, user);
1218 vc->vc_rows = new_rows;
1219 vc->vc_cols = new_cols;
1220 vc->vc_size_row = new_row_size;
1221 vc->vc_screenbuf_size = new_screen_size;
1225 old_origin = vc->vc_origin;
1229 if (vc->state.y > new_rows) {
1230 if (old_rows - vc->state.y < new_rows) {
1241 first_copied_row = (vc->state.y - new_rows/2);
1249 vc->vc_uni_lines, rlth/2, first_copied_row,
1251 vc_uniscr_set(vc, new_uniscr);
1253 update_attr(vc);
1260 vc->vc_video_erase_char, rrem);
1265 scr_memsetw((void *)new_origin, vc->vc_video_erase_char,
1267 oldscreen = vc->vc_screenbuf;
1268 vc->vc_screenbuf = newscreen;
1269 vc->vc_screenbuf_size = new_screen_size;
1270 set_origin(vc);
1274 vc->vc_top = 0;
1275 vc->vc_bottom = vc->vc_rows;
1276 gotoxy(vc, vc->state.x, vc->state.y);
1277 save_cur(vc);
1284 ws.ws_row = vc->vc_rows;
1285 ws.ws_col = vc->vc_cols;
1286 ws.ws_ypixel = vc->vc_scan_lines;
1290 if (con_is_visible(vc))
1291 update_screen(vc);
1292 vt_event_post(VT_EVENT_RESIZE, vc->vc_num, vc->vc_num);
1293 notify_update(vc);
1299 * @vc: virtual console
1306 * vc->port.tty
1309 int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows)
1311 return vc_do_resize(vc->port.tty, vc, cols, rows);
1329 struct vc_data *vc = tty->driver_data;
1333 ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row);
1340 struct vc_data *vc = NULL;
1347 param.vc = vc = vc_cons[currcons].d;
1350 visual_deinit(vc);
1351 con_free_unimap(vc);
1352 put_pid(vc->vt_pid);
1353 vc_uniscr_set(vc, NULL);
1354 kfree(vc->vc_screenbuf);
1357 return vc;
1366 #define set_kbd(vc, x) vt_set_kbd_mode_bit((vc)->vc_num, (x))
1367 #define clr_kbd(vc, x) vt_clr_kbd_mode_bit((vc)->vc_num, (x))
1368 #define is_kbd(vc, x) vt_get_kbd_mode_bit((vc)->vc_num, (x))
1406 static void gotoxy(struct vc_data *vc, int new_x, int new_y)
1411 vc->state.x = 0;
1413 if (new_x >= vc->vc_cols)
1414 vc->state.x = vc->vc_cols - 1;
1416 vc->state.x = new_x;
1419 if (vc->vc_decom) {
1420 min_y = vc->vc_top;
1421 max_y = vc->vc_bottom;
1424 max_y = vc->vc_rows;
1427 vc->state.y = min_y;
1429 vc->state.y = max_y - 1;
1431 vc->state.y = new_y;
1432 vc->vc_pos = vc->vc_origin + vc->state.y * vc->vc_size_row +
1433 (vc->state.x << 1);
1434 vc->vc_need_wrap = 0;
1438 static void gotoxay(struct vc_data *vc, int new_x, int new_y)
1440 gotoxy(vc, new_x, vc->vc_decom ? (vc->vc_top + new_y) : new_y);
1443 void scrollback(struct vc_data *vc)
1445 scrolldelta(-(vc->vc_rows / 2));
1448 void scrollfront(struct vc_data *vc, int lines)
1451 lines = vc->vc_rows / 2;
1455 static void lf(struct vc_data *vc)
1460 if (vc->state.y + 1 == vc->vc_bottom)
1461 con_scroll(vc, vc->vc_top, vc->vc_bottom, SM_UP, 1);
1462 else if (vc->state.y < vc->vc_rows - 1) {
1463 vc->state.y++;
1464 vc->vc_pos += vc->vc_size_row;
1466 vc->vc_need_wrap = 0;
1467 notify_write(vc, '\n');
1470 static void ri(struct vc_data *vc)
1475 if (vc->state.y == vc->vc_top)
1476 con_scroll(vc, vc->vc_top, vc->vc_bottom, SM_DOWN, 1);
1477 else if (vc->state.y > 0) {
1478 vc->state.y--;
1479 vc->vc_pos -= vc->vc_size_row;
1481 vc->vc_need_wrap = 0;
1484 static inline void cr(struct vc_data *vc)
1486 vc->vc_pos -= vc->state.x << 1;
1487 vc->vc_need_wrap = vc->state.x = 0;
1488 notify_write(vc, '\r');
1491 static inline void bs(struct vc_data *vc)
1493 if (vc->state.x) {
1494 vc->vc_pos -= 2;
1495 vc->state.x--;
1496 vc->vc_need_wrap = 0;
1497 notify_write(vc, '\b');
1501 static inline void del(struct vc_data *vc)
1506 static void csi_J(struct vc_data *vc, int vpar)
1513 vc_uniscr_clear_line(vc, vc->state.x,
1514 vc->vc_cols - vc->state.x);
1515 vc_uniscr_clear_lines(vc, vc->state.y + 1,
1516 vc->vc_rows - vc->state.y - 1);
1517 count = (vc->vc_scr_end - vc->vc_pos) >> 1;
1518 start = (unsigned short *)vc->vc_pos;
1521 vc_uniscr_clear_line(vc, 0, vc->state.x + 1);
1522 vc_uniscr_clear_lines(vc, 0, vc->state.y);
1523 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1;
1524 start = (unsigned short *)vc->vc_origin;
1527 flush_scrollback(vc);
1530 vc_uniscr_clear_lines(vc, 0, vc->vc_rows);
1531 count = vc->vc_cols * vc->vc_rows;
1532 start = (unsigned short *)vc->vc_origin;
1537 scr_memsetw(start, vc->vc_video_erase_char, 2 * count);
1538 if (con_should_update(vc))
1539 do_update_region(vc, (unsigned long) start, count);
1540 vc->vc_need_wrap = 0;
1543 static void csi_K(struct vc_data *vc, int vpar)
1546 unsigned short *start = (unsigned short *)vc->vc_pos;
1552 count = vc->vc_cols - vc->state.x;
1555 offset = -vc->state.x;
1556 count = vc->state.x + 1;
1559 offset = -vc->state.x;
1560 count = vc->vc_cols;
1565 vc_uniscr_clear_line(vc, vc->state.x + offset, count);
1566 scr_memsetw(start + offset, vc->vc_video_erase_char, 2 * count);
1567 vc->vc_need_wrap = 0;
1568 if (con_should_update(vc))
1569 do_update_region(vc, (unsigned long)(start + offset), count);
1573 static void csi_X(struct vc_data *vc, unsigned int vpar)
1580 count = min(vpar, vc->vc_cols - vc->state.x);
1582 vc_uniscr_clear_line(vc, vc->state.x, count);
1583 scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count);
1584 if (con_should_update(vc))
1585 vc->vc_sw->con_clear(vc, vc->state.y, vc->state.x, 1, count);
1586 vc->vc_need_wrap = 0;
1589 static void default_attr(struct vc_data *vc)
1591 vc->state.intensity = VCI_NORMAL;
1592 vc->state.italic = false;
1593 vc->state.underline = false;
1594 vc->state.reverse = false;
1595 vc->state.blink = false;
1596 vc->state.color = vc->vc_def_color;
1619 static void rgb_foreground(struct vc_data *vc, const struct rgb *c)
1632 vc->state.intensity = VCI_BOLD;
1634 vc->state.intensity = VCI_BOLD;
1636 vc->state.intensity = VCI_NORMAL;
1638 vc->state.color = (vc->state.color & 0xf0) | hue;
1641 static void rgb_background(struct vc_data *vc, const struct rgb *c)
1644 vc->state.color = (vc->state.color & 0x0f)
1657 static int vc_t416_color(struct vc_data *vc, int i,
1658 void(*set_color)(struct vc_data *vc, const struct rgb *c))
1663 if (i > vc->vc_npar)
1666 if (vc->vc_par[i] == 5 && i + 1 <= vc->vc_npar) {
1669 rgb_from_256(vc->vc_par[i], &c);
1670 } else if (vc->vc_par[i] == 2 && i + 3 <= vc->vc_npar) {
1672 c.r = vc->vc_par[i + 1];
1673 c.g = vc->vc_par[i + 2];
1674 c.b = vc->vc_par[i + 3];
1679 set_color(vc, &c);
1685 static void csi_m(struct vc_data *vc)
1689 for (i = 0; i <= vc->vc_npar; i++)
1690 switch (vc->vc_par[i]) {
1692 default_attr(vc);
1695 vc->state.intensity = VCI_BOLD;
1698 vc->state.intensity = VCI_HALF_BRIGHT;
1701 vc->state.italic = true;
1709 vc->state.underline = true;
1712 vc->state.blink = true;
1715 vc->state.reverse = true;
1721 vc->vc_translate = set_translate(vc->state.Gx_charset[vc->state.charset], vc);
1722 vc->vc_disp_ctrl = 0;
1723 vc->vc_toggle_meta = 0;
1729 vc->vc_translate = set_translate(IBMPC_MAP, vc);
1730 vc->vc_disp_ctrl = 1;
1731 vc->vc_toggle_meta = 0;
1737 vc->vc_translate = set_translate(IBMPC_MAP, vc);
1738 vc->vc_disp_ctrl = 1;
1739 vc->vc_toggle_meta = 1;
1742 vc->state.intensity = VCI_NORMAL;
1745 vc->state.italic = false;
1748 vc->state.underline = false;
1751 vc->state.blink = false;
1754 vc->state.reverse = false;
1757 i = vc_t416_color(vc, i, rgb_foreground);
1760 i = vc_t416_color(vc, i, rgb_background);
1763 vc->state.color = (vc->vc_def_color & 0x0f) |
1764 (vc->state.color & 0xf0);
1767 vc->state.color = (vc->vc_def_color & 0xf0) |
1768 (vc->state.color & 0x0f);
1771 if (vc->vc_par[i] >= 90 && vc->vc_par[i] <= 107) {
1772 if (vc->vc_par[i] < 100)
1773 vc->state.intensity = VCI_BOLD;
1774 vc->vc_par[i] -= 60;
1776 if (vc->vc_par[i] >= 30 && vc->vc_par[i] <= 37)
1777 vc->state.color = color_table[vc->vc_par[i] - 30]
1778 | (vc->state.color & 0xf0);
1779 else if (vc->vc_par[i] >= 40 && vc->vc_par[i] <= 47)
1780 vc->state.color = (color_table[vc->vc_par[i] - 40] << 4)
1781 | (vc->state.color & 0x0f);
1784 update_attr(vc);
1793 static void cursor_report(struct vc_data *vc, struct tty_struct *tty)
1798 len = sprintf(buf, "\033[%d;%dR", vc->state.y +
1799 (vc->vc_decom ? vc->vc_top + 1 : 1),
1800 vc->state.x + 1);
1836 static void set_mode(struct vc_data *vc, int on_off)
1840 for (i = 0; i <= vc->vc_npar; i++)
1841 if (vc->vc_priv == EPdec) {
1842 switch(vc->vc_par[i]) { /* DEC private modes set/reset */
1845 set_kbd(vc, decckm);
1847 clr_kbd(vc, decckm);
1851 vc_resize(deccolm ? 132 : 80, vc->vc_rows);
1857 if (vc->vc_decscnm != on_off) {
1858 vc->vc_decscnm = on_off;
1859 invert_screen(vc, 0,
1860 vc->vc_screenbuf_size,
1862 update_attr(vc);
1866 vc->vc_decom = on_off;
1867 gotoxay(vc, 0, 0);
1870 vc->vc_decawm = on_off;
1874 set_kbd(vc, decarm);
1876 clr_kbd(vc, decarm);
1879 vc->vc_report_mouse = on_off ? 1 : 0;
1882 vc->vc_deccm = on_off;
1885 vc->vc_report_mouse = on_off ? 2 : 0;
1889 switch(vc->vc_par[i]) { /* ANSI modes set/reset */
1891 vc->vc_disp_ctrl = on_off;
1894 vc->vc_decim = on_off;
1898 set_kbd(vc, lnm);
1900 clr_kbd(vc, lnm);
1907 static void setterm_command(struct vc_data *vc)
1909 switch (vc->vc_par[0]) {
1911 if (vc->vc_can_do_color && vc->vc_par[1] < 16) {
1912 vc->vc_ulcolor = color_table[vc->vc_par[1]];
1913 if (vc->state.underline)
1914 update_attr(vc);
1918 if (vc->vc_can_do_color && vc->vc_par[1] < 16) {
1919 vc->vc_halfcolor = color_table[vc->vc_par[1]];
1920 if (vc->state.intensity == VCI_HALF_BRIGHT)
1921 update_attr(vc);
1925 vc->vc_def_color = vc->vc_attr;
1926 if (vc->vc_hi_font_mask == 0x100)
1927 vc->vc_def_color >>= 1;
1928 default_attr(vc);
1929 update_attr(vc);
1932 blankinterval = min(vc->vc_par[1], 60U) * 60;
1936 if (vc->vc_npar >= 1)
1937 vc->vc_bell_pitch = vc->vc_par[1];
1939 vc->vc_bell_pitch = DEFAULT_BELL_PITCH;
1942 if (vc->vc_npar >= 1)
1943 vc->vc_bell_duration = (vc->vc_par[1] < 2000) ?
1944 msecs_to_jiffies(vc->vc_par[1]) : 0;
1946 vc->vc_bell_duration = DEFAULT_BELL_DURATION;
1949 if (vc->vc_par[1] >= 1 && vc_cons_allocated(vc->vc_par[1] - 1))
1950 set_console(vc->vc_par[1] - 1);
1956 vesa_off_interval = min(vc->vc_par[1], 60U) * 60 * HZ;
1962 if (vc->vc_npar >= 1 && vc->vc_par[1] >= 50 &&
1963 vc->vc_par[1] <= USHRT_MAX)
1964 vc->vc_cur_blink_ms = vc->vc_par[1];
1966 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS;
1972 static void csi_at(struct vc_data *vc, unsigned int nr)
1974 if (nr > vc->vc_cols - vc->state.x)
1975 nr = vc->vc_cols - vc->state.x;
1978 insert_char(vc, nr);
1982 static void csi_L(struct vc_data *vc, unsigned int nr)
1984 if (nr > vc->vc_rows - vc->state.y)
1985 nr = vc->vc_rows - vc->state.y;
1988 con_scroll(vc, vc->state.y, vc->vc_bottom, SM_DOWN, nr);
1989 vc->vc_need_wrap = 0;
1993 static void csi_P(struct vc_data *vc, unsigned int nr)
1995 if (nr > vc->vc_cols - vc->state.x)
1996 nr = vc->vc_cols - vc->state.x;
1999 delete_char(vc, nr);
2003 static void csi_M(struct vc_data *vc, unsigned int nr)
2005 if (nr > vc->vc_rows - vc->state.y)
2006 nr = vc->vc_rows - vc->state.y;
2009 con_scroll(vc, vc->state.y, vc->vc_bottom, SM_UP, nr);
2010 vc->vc_need_wrap = 0;
2014 static void save_cur(struct vc_data *vc)
2016 memcpy(&vc->saved_state, &vc->state, sizeof(vc->state));
2020 static void restore_cur(struct vc_data *vc)
2022 memcpy(&vc->state, &vc->saved_state, sizeof(vc->state));
2024 gotoxy(vc, vc->state.x, vc->state.y);
2025 vc->vc_translate = set_translate(vc->state.Gx_charset[vc->state.charset],
2026 vc);
2027 update_attr(vc);
2028 vc->vc_need_wrap = 0;
2036 static void reset_terminal(struct vc_data *vc, int do_clear)
2040 vc->vc_top = 0;
2041 vc->vc_bottom = vc->vc_rows;
2042 vc->vc_state = ESnormal;
2043 vc->vc_priv = EPecma;
2044 vc->vc_translate = set_translate(LAT1_MAP, vc);
2045 vc->state.Gx_charset[0] = LAT1_MAP;
2046 vc->state.Gx_charset[1] = GRAF_MAP;
2047 vc->state.charset = 0;
2048 vc->vc_need_wrap = 0;
2049 vc->vc_report_mouse = 0;
2050 vc->vc_utf = default_utf8;
2051 vc->vc_utf_count = 0;
2053 vc->vc_disp_ctrl = 0;
2054 vc->vc_toggle_meta = 0;
2056 vc->vc_decscnm = 0;
2057 vc->vc_decom = 0;
2058 vc->vc_decawm = 1;
2059 vc->vc_deccm = global_cursor_default;
2060 vc->vc_decim = 0;
2062 vt_reset_keyboard(vc->vc_num);
2064 vc->vc_cursor_type = cur_default;
2065 vc->vc_complement_mask = vc->vc_s_complement_mask;
2067 default_attr(vc);
2068 update_attr(vc);
2070 bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT);
2072 set_bit(i, vc->vc_tab_stop);
2074 vc->vc_bell_pitch = DEFAULT_BELL_PITCH;
2075 vc->vc_bell_duration = DEFAULT_BELL_DURATION;
2076 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS;
2078 gotoxy(vc, 0, 0);
2079 save_cur(vc);
2081 csi_J(vc, 2);
2084 static void vc_setGx(struct vc_data *vc, unsigned int which, int c)
2086 unsigned char *charset = &vc->state.Gx_charset[which];
2103 if (vc->state.charset == which)
2104 vc->vc_translate = set_translate(*charset, vc);
2116 static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
2122 if (ansi_control_string(vc->vc_state) && c >= 8 && c <= 13)
2128 if (ansi_control_string(vc->vc_state))
2129 vc->vc_state = ESnormal;
2130 else if (vc->vc_bell_duration)
2131 kd_mksound(vc->vc_bell_pitch, vc->vc_bell_duration);
2134 bs(vc);
2137 vc->vc_pos -= (vc->state.x << 1);
2139 vc->state.x = find_next_bit(vc->vc_tab_stop,
2140 min(vc->vc_cols - 1, VC_TABSTOPS_COUNT),
2141 vc->state.x + 1);
2142 if (vc->state.x >= VC_TABSTOPS_COUNT)
2143 vc->state.x = vc->vc_cols - 1;
2145 vc->vc_pos += (vc->state.x << 1);
2146 notify_write(vc, '\t');
2149 lf(vc);
2150 if (!is_kbd(vc, lnm))
2154 cr(vc);
2157 vc->state.charset = 1;
2158 vc->vc_translate = set_translate(vc->state.Gx_charset[1], vc);
2159 vc->vc_disp_ctrl = 1;
2162 vc->state.charset = 0;
2163 vc->vc_translate = set_translate(vc->state.Gx_charset[0], vc);
2164 vc->vc_disp_ctrl = 0;
2167 vc->vc_state = ESnormal;
2170 vc->vc_state = ESesc;
2173 del(vc);
2176 vc->vc_state = ESsquare;
2179 switch(vc->vc_state) {
2181 vc->vc_state = ESnormal;
2184 vc->vc_state = ESsquare;
2187 vc->vc_state = ESnonstd;
2190 vc->vc_state = ESapc;
2193 vc->vc_state = ESpm;
2196 vc->vc_state = ESpercent;
2199 cr(vc);
2200 lf(vc);
2203 ri(vc);
2206 lf(vc);
2209 if (vc->state.x < VC_TABSTOPS_COUNT)
2210 set_bit(vc->state.x, vc->vc_tab_stop);
2213 vc->vc_state = ESdcs;
2219 save_cur(vc);
2222 restore_cur(vc);
2225 vc->vc_state = ESsetG0;
2228 vc->vc_state = ESsetG1;
2231 vc->vc_state = EShash;
2234 reset_terminal(vc, 1);
2237 clr_kbd(vc, kbdapplic);
2240 set_kbd(vc, kbdapplic);
2246 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++)
2247 vc->vc_par[vc->vc_npar] = 0;
2248 vc->vc_npar = 0;
2249 vc->vc_state = ESpalette;
2252 reset_palette(vc);
2253 vc->vc_state = ESnormal;
2255 vc->vc_state = ESosc;
2257 vc->vc_state = ESnormal;
2261 vc->vc_par[vc->vc_npar++] = hex_to_bin(c);
2262 if (vc->vc_npar == 7) {
2263 int i = vc->vc_par[0] * 3, j = 1;
2264 vc->vc_palette[i] = 16 * vc->vc_par[j++];
2265 vc->vc_palette[i++] += vc->vc_par[j++];
2266 vc->vc_palette[i] = 16 * vc->vc_par[j++];
2267 vc->vc_palette[i++] += vc->vc_par[j++];
2268 vc->vc_palette[i] = 16 * vc->vc_par[j++];
2269 vc->vc_palette[i] += vc->vc_par[j];
2270 set_palette(vc);
2271 vc->vc_state = ESnormal;
2274 vc->vc_state = ESnormal;
2277 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++)
2278 vc->vc_par[vc->vc_npar] = 0;
2279 vc->vc_npar = 0;
2280 vc->vc_state = ESgetpars;
2282 vc->vc_state=ESfunckey;
2287 vc->vc_priv = EPdec;
2290 vc->vc_priv = EPgt;
2293 vc->vc_priv = EPeq;
2296 vc->vc_priv = EPlt;
2299 vc->vc_priv = EPecma;
2302 if (c == ';' && vc->vc_npar < NPAR - 1) {
2303 vc->vc_npar++;
2306 vc->vc_par[vc->vc_npar] *= 10;
2307 vc->vc_par[vc->vc_npar] += c - '0';
2311 vc->vc_state = EScsiignore;
2314 vc->vc_state = ESnormal;
2317 if (vc->vc_priv <= EPdec)
2318 set_mode(vc, 1);
2321 if (vc->vc_priv <= EPdec)
2322 set_mode(vc, 0);
2325 if (vc->vc_priv == EPdec) {
2326 if (vc->vc_par[0])
2327 vc->vc_cursor_type =
2328 CUR_MAKE(vc->vc_par[0],
2329 vc->vc_par[1],
2330 vc->vc_par[2]);
2332 vc->vc_cursor_type = cur_default;
2337 if (vc->vc_priv == EPdec) {
2339 if (vc->vc_par[0])
2340 vc->vc_complement_mask = vc->vc_par[0] << 8 | vc->vc_par[1];
2342 vc->vc_complement_mask = vc->vc_s_complement_mask;
2347 if (vc->vc_priv == EPecma) {
2348 if (vc->vc_par[0] == 5)
2350 else if (vc->vc_par[0] == 6)
2351 cursor_report(vc, tty);
2355 if (vc->vc_priv != EPecma) {
2356 vc->vc_priv = EPecma;
2361 if (vc->vc_par[0])
2362 vc->vc_par[0]--;
2363 gotoxy(vc, vc->vc_par[0], vc->state.y);
2366 if (!vc->vc_par[0])
2367 vc->vc_par[0]++;
2368 gotoxy(vc, vc->state.x, vc->state.y - vc->vc_par[0]);
2371 if (!vc->vc_par[0])
2372 vc->vc_par[0]++;
2373 gotoxy(vc, vc->state.x, vc->state.y + vc->vc_par[0]);
2376 if (!vc->vc_par[0])
2377 vc->vc_par[0]++;
2378 gotoxy(vc, vc->state.x + vc->vc_par[0], vc->state.y);
2381 if (!vc->vc_par[0])
2382 vc->vc_par[0]++;
2383 gotoxy(vc, vc->state.x - vc->vc_par[0], vc->state.y);
2386 if (!vc->vc_par[0])
2387 vc->vc_par[0]++;
2388 gotoxy(vc, 0, vc->state.y + vc->vc_par[0]);
2391 if (!vc->vc_par[0])
2392 vc->vc_par[0]++;
2393 gotoxy(vc, 0, vc->state.y - vc->vc_par[0]);
2396 if (vc->vc_par[0])
2397 vc->vc_par[0]--;
2398 gotoxay(vc, vc->state.x ,vc->vc_par[0]);
2401 if (vc->vc_par[0])
2402 vc->vc_par[0]--;
2403 if (vc->vc_par[1])
2404 vc->vc_par[1]--;
2405 gotoxay(vc, vc->vc_par[1], vc->vc_par[0]);
2408 csi_J(vc, vc->vc_par[0]);
2411 csi_K(vc, vc->vc_par[0]);
2414 csi_L(vc, vc->vc_par[0]);
2417 csi_M(vc, vc->vc_par[0]);
2420 csi_P(vc, vc->vc_par[0]);
2423 if (!vc->vc_par[0])
2427 if (!vc->vc_par[0] && vc->state.x < VC_TABSTOPS_COUNT)
2428 set_bit(vc->state.x, vc->vc_tab_stop);
2429 else if (vc->vc_par[0] == 3)
2430 bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT);
2433 csi_m(vc);
2437 if (vc->vc_par[0] < 4)
2438 vt_set_led_state(vc->vc_num,
2439 (vc->vc_par[0] < 3) ? vc->vc_par[0] : 4);
2442 if (!vc->vc_par[0])
2443 vc->vc_par[0]++;
2444 if (!vc->vc_par[1])
2445 vc->vc_par[1] = vc->vc_rows;
2447 if (vc->vc_par[0] < vc->vc_par[1] &&
2448 vc->vc_par[1] <= vc->vc_rows) {
2449 vc->vc_top = vc->vc_par[0] - 1;
2450 vc->vc_bottom = vc->vc_par[1];
2451 gotoxay(vc, 0, 0);
2455 save_cur(vc);
2458 restore_cur(vc);
2461 csi_X(vc, vc->vc_par[0]);
2464 csi_at(vc, vc->vc_par[0]);
2467 setterm_command(vc);
2474 vc->vc_state = ESnormal;
2477 vc->vc_state = ESnormal;
2480 vc->vc_utf = 0;
2484 vc->vc_utf = 1;
2489 vc->vc_state = ESnormal;
2492 vc->vc_state = ESnormal;
2495 vc->vc_video_erase_char =
2496 (vc->vc_video_erase_char & 0xff00) | 'E';
2497 csi_J(vc, 2);
2498 vc->vc_video_erase_char =
2499 (vc->vc_video_erase_char & 0xff00) | ' ';
2500 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2);
2504 vc_setGx(vc, 0, c);
2505 vc->vc_state = ESnormal;
2508 vc_setGx(vc, 1, c);
2509 vc->vc_state = ESnormal;
2520 vc->vc_state = ESnormal;
2566 static void con_flush(struct vc_data *vc, struct vc_draw_region *draw)
2571 vc->vc_sw->con_putcs(vc, (u16 *)draw->from,
2572 (u16 *)draw->to - (u16 *)draw->from, vc->state.y,
2577 static inline int vc_translate_ascii(const struct vc_data *vc, int c)
2580 if (vc->vc_toggle_meta)
2583 return vc->vc_translate[c];
2604 * @vc: virtual console
2612 static int vc_translate_unicode(struct vc_data *vc, int c, bool *rescan)
2622 if (!vc->vc_utf_count)
2625 vc->vc_utf_char = (vc->vc_utf_char << 6) | (c & 0x3f);
2626 vc->vc_npar++;
2627 if (--vc->vc_utf_count)
2631 c = vc->vc_utf_char;
2633 if (c <= utf8_length_changes[vc->vc_npar - 1] ||
2634 c > utf8_length_changes[vc->vc_npar])
2641 if (vc->vc_utf_count) {
2644 vc->vc_utf_count = 0;
2653 vc->vc_npar = 0;
2655 vc->vc_utf_count = 1;
2656 vc->vc_utf_char = (c & 0x1f);
2658 vc->vc_utf_count = 2;
2659 vc->vc_utf_char = (c & 0x0f);
2661 vc->vc_utf_count = 3;
2662 vc->vc_utf_char = (c & 0x07);
2664 vc->vc_utf_count = 4;
2665 vc->vc_utf_char = (c & 0x03);
2667 vc->vc_utf_count = 5;
2668 vc->vc_utf_char = (c & 0x01);
2678 static int vc_translate(struct vc_data *vc, int *c, bool *rescan)
2681 if (vc->vc_state != ESnormal)
2684 if (vc->vc_utf && !vc->vc_disp_ctrl)
2685 return *c = vc_translate_unicode(vc, *c, rescan);
2688 return vc_translate_ascii(vc, *c);
2691 static inline unsigned char vc_invert_attr(const struct vc_data *vc)
2693 if (!vc->vc_can_do_color)
2694 return vc->vc_attr ^ 0x08;
2696 if (vc->vc_hi_font_mask == 0x100)
2697 return (vc->vc_attr & 0x11) |
2698 ((vc->vc_attr & 0xe0) >> 4) |
2699 ((vc->vc_attr & 0x0e) << 4);
2701 return (vc->vc_attr & 0x88) |
2702 ((vc->vc_attr & 0x70) >> 4) |
2703 ((vc->vc_attr & 0x07) << 4);
2706 static bool vc_is_control(struct vc_data *vc, int tc, int c)
2718 if (vc->vc_state != ESnormal)
2734 if (vc->vc_disp_ctrl)
2737 return vc->vc_utf || (CTRL_ACTION & BIT(c));
2740 if (c == 127 && !vc->vc_disp_ctrl)
2749 static int vc_con_write_normal(struct vc_data *vc, int tc, int c,
2753 unsigned char vc_attr = vc->vc_attr;
2754 u16 himask = vc->vc_hi_font_mask, charmask = himask ? 0x1ff : 0xff;
2758 if (vc->vc_utf && !vc->vc_disp_ctrl) {
2764 tc = conv_uni_to_pc(vc, tc);
2770 if ((!vc->vc_utf || vc->vc_disp_ctrl || c < 128) &&
2786 tc = conv_uni_to_pc(vc, 0xfffd);
2789 tc = conv_uni_to_pc(vc, '?');
2793 vc_attr = vc_invert_attr(vc);
2794 con_flush(vc, draw);
2801 if (vc->vc_need_wrap || vc->vc_decim)
2802 con_flush(vc, draw);
2803 if (vc->vc_need_wrap) {
2804 cr(vc);
2805 lf(vc);
2807 if (vc->vc_decim)
2808 insert_char(vc, 1);
2809 vc_uniscr_putc(vc, next_c);
2816 scr_writew(tc, (u16 *)vc->vc_pos);
2818 if (con_should_update(vc) && draw->x < 0) {
2819 draw->x = vc->state.x;
2820 draw->from = vc->vc_pos;
2822 if (vc->state.x == vc->vc_cols - 1) {
2823 vc->vc_need_wrap = vc->vc_decawm;
2824 draw->to = vc->vc_pos + 2;
2826 vc->state.x++;
2827 draw->to = (vc->vc_pos += 2);
2834 tc = conv_uni_to_pc(vc, ' ');
2839 notify_write(vc, c);
2842 con_flush(vc, draw);
2855 struct vc_data *vc;
2863 vc = tty->driver_data;
2864 if (vc == NULL) {
2870 currcons = vc->vc_num;
2880 if (con_is_fg(vc))
2881 hide_cursor(vc);
2883 param.vc = vc;
2894 tc = vc_translate(vc, &c, &rescan);
2903 if (vc_is_control(vc, tc, c)) {
2904 con_flush(vc, &draw);
2905 do_con_trol(tty, vc, orig);
2909 if (vc_con_write_normal(vc, tc, c, &draw) < 0)
2915 con_flush(vc, &draw);
2917 notify_update(vc);
2951 struct vc_data *vc = vc_cons[fg_console].d;
2953 if (vc->vc_mode == KD_TEXT && vc->vc_sw->con_scrolldelta)
2954 vc->vc_sw->con_scrolldelta(vc, scrollback_delta);
2968 struct vc_data *vc = vc_cons[fg_console].d;
2971 (vc->vt_mode.mode == VT_AUTO && vc->vc_mode == KD_GRAPHICS)) {
3033 struct vc_data *vc = vc_cons[fg_console].d;
3048 vc = vc_cons[kmsg_console - 1].d;
3056 if (vc->vc_mode != KD_TEXT)
3060 if (con_is_fg(vc))
3061 hide_cursor(vc);
3063 start = (ushort *)vc->vc_pos;
3064 start_x = vc->state.x;
3068 if (c == 10 || c == 13 || c == 8 || vc->vc_need_wrap) {
3069 if (cnt && con_is_visible(vc))
3070 vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x);
3073 bs(vc);
3074 start = (ushort *)vc->vc_pos;
3075 start_x = vc->state.x;
3079 lf(vc);
3080 cr(vc);
3081 start = (ushort *)vc->vc_pos;
3082 start_x = vc->state.x;
3086 vc_uniscr_putc(vc, c);
3087 scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos);
3088 notify_write(vc, c);
3090 if (vc->state.x == vc->vc_cols - 1) {
3091 vc->vc_need_wrap = 1;
3093 vc->vc_pos += 2;
3094 vc->state.x++;
3097 if (cnt && con_is_visible(vc))
3098 vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x);
3099 set_cursor(vc);
3100 notify_update(vc);
3274 struct vc_data *vc = tty->driver_data;
3276 wake_up_interruptible(&vc->paste_wait);
3309 struct vc_data *vc;
3316 vc = tty->driver_data;
3317 if (vc)
3318 set_cursor(vc);
3328 struct vc_data *vc;
3336 vc = vc_cons[currcons].d;
3339 if (vc->port.tty) {
3344 ret = tty_port_install(&vc->port, driver, tty);
3348 tty->driver_data = vc;
3349 vc->port.tty = tty;
3350 tty_port_get(&vc->port);
3356 if (vc->vc_utf)
3379 struct vc_data *vc = tty->driver_data;
3380 BUG_ON(vc == NULL);
3382 vc->port.tty = NULL;
3388 struct vc_data *vc = tty->driver_data;
3390 tty_port_put(&vc->port);
3400 static void vc_init(struct vc_data *vc, int do_clear)
3404 set_origin(vc);
3405 vc->vc_pos = vc->vc_origin;
3406 reset_vc(vc);
3408 vc->vc_palette[k++] = default_red[j] ;
3409 vc->vc_palette[k++] = default_grn[j] ;
3410 vc->vc_palette[k++] = default_blu[j] ;
3412 vc->vc_def_color = default_color;
3413 vc->vc_ulcolor = default_underline_color;
3414 vc->vc_itcolor = default_italic_color;
3415 vc->vc_halfcolor = 0x08; /* grey */
3416 init_waitqueue_head(&vc->paste_wait);
3417 reset_terminal(vc, do_clear);
3429 struct vc_data *vc;
3465 vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT);
3467 tty_port_init(&vc->port);
3468 visual_init(vc, currcons, 1);
3469 /* Assuming vc->vc_{cols,rows,screenbuf_size} are sane here. */
3470 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT);
3471 vc_init(vc, currcons || !vc->vc_sw->con_save_screen);
3474 master_display_fg = vc = vc_cons[currcons].d;
3475 set_origin(vc);
3476 save_screen(vc);
3477 gotoxy(vc, vc->state.x, vc->state.y);
3478 csi_J(vc, 0);
3479 update_screen(vc);
3481 vc->vc_can_do_color ? "colour" : "mono",
3482 display_desc, vc->vc_cols, vc->vc_rows);
3534 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
3615 struct vc_data *vc = vc_cons[i].d;
3622 if (!vc || !vc->vc_sw)
3627 if (con_is_visible(vc)) {
3629 save_screen(vc);
3632 old_was_color = vc->vc_can_do_color;
3633 vc->vc_sw->con_deinit(vc);
3634 vc->vc_origin = (unsigned long)vc->vc_screenbuf;
3635 visual_init(vc, i, 0);
3636 set_origin(vc);
3637 update_attr(vc);
3643 if (old_was_color != vc->vc_can_do_color)
3644 clear_buffer_attributes(vc);
3651 struct vc_data *vc = vc_cons[j].d;
3654 vc->vc_can_do_color ? "colour" : "mono",
3655 desc, vc->vc_cols, vc->vc_rows);
3658 vc = vc_cons[k].d;
3659 update_screen(vc);
3946 * @vc: virtual console
3950 bool con_is_visible(const struct vc_data *vc)
3954 return *vc->vc_display_fg == vc;
3960 * @vc: virtual console
3970 int con_debug_enter(struct vc_data *vc)
3977 saved_vc_mode = vc->vc_mode;
3979 vc->vc_mode = KD_TEXT;
3981 if (vc->vc_sw->con_debug_enter)
3982 ret = vc->vc_sw->con_debug_enter(vc);
3985 if (vc->vc_rows < 999) {
3994 snprintf(lns, 4, "%i", vc->vc_rows);
3998 if (vc->vc_cols < 999) {
4007 snprintf(cols, 4, "%i", vc->vc_cols);
4028 struct vc_data *vc;
4037 vc = vc_cons[fg_console].d;
4038 if (vc->vc_sw->con_debug_leave)
4039 ret = vc->vc_sw->con_debug_leave(vc);
4286 struct vc_data *vc = vc_cons[fg_console].d;
4296 vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0);
4303 hide_cursor(vc);
4304 save_screen(vc);
4305 vc->vc_sw->con_blank(vc, -1, 1);
4308 set_origin(vc);
4315 if (vc->vc_mode != KD_TEXT) {
4320 hide_cursor(vc);
4324 save_screen(vc);
4326 i = vc->vc_sw->con_blank(vc, vesa_off_interval ? 1 : (vesa_blank_mode + 1), 0);
4329 set_origin(vc);
4338 vt_event_post(VT_EVENT_BLANK, vc->vc_num, vc->vc_num);
4347 struct vc_data *vc;
4367 vc = vc_cons[fg_console].d;
4368 if (vc->vc_mode != KD_TEXT)
4377 if (vc->vc_sw->con_blank(vc, 0, leaving_gfx))
4379 update_screen(vc);
4382 set_palette(vc);
4383 set_cursor(vc);
4384 vt_event_post(VT_EVENT_UNBLANK, vc->vc_num, vc->vc_num);
4442 static void set_palette(struct vc_data *vc)
4446 if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_set_palette)
4447 vc->vc_sw->con_set_palette(vc, color_table);
4503 void reset_palette(struct vc_data *vc)
4507 vc->vc_palette[k++] = default_red[j];
4508 vc->vc_palette[k++] = default_grn[j];
4509 vc->vc_palette[k++] = default_blu[j];
4511 set_palette(vc);
4532 static int con_font_get(struct vc_data *vc, struct console_font_op *op)
4550 if (vc->vc_mode != KD_TEXT)
4552 else if (vc->vc_sw->con_font_get)
4553 rc = vc->vc_sw->con_font_get(vc, &font, vpitch);
4582 static int con_font_set(struct vc_data *vc, struct console_font_op *op)
4589 if (vc->vc_mode != KD_TEXT)
4613 if (vc->vc_mode != KD_TEXT)
4615 else if (vc->vc_sw->con_font_set) {
4616 if (vc_is_sel(vc))
4618 rc = vc->vc_sw->con_font_set(vc, &font, vpitch, op->flags);
4626 static int con_font_default(struct vc_data *vc, struct console_font_op *op)
4642 if (vc->vc_mode != KD_TEXT) {
4646 if (vc->vc_sw->con_font_default) {
4647 if (vc_is_sel(vc))
4649 rc = vc->vc_sw->con_font_default(vc, &font, s);
4660 int con_font_op(struct vc_data *vc, struct console_font_op *op)
4665 return con_font_set(vc, op);
4668 return con_font_get(vc, op);
4670 return con_font_default(vc, op);
4683 u16 screen_glyph(const struct vc_data *vc, int offset)
4685 u16 w = scr_readw(screenpos(vc, offset, true));
4688 if (w & vc->vc_hi_font_mask)
4694 u32 screen_glyph_unicode(const struct vc_data *vc, int n)
4696 u32 **uni_lines = vc->vc_uni_lines;
4699 return uni_lines[n / vc->vc_cols][n % vc->vc_cols];
4701 return inverse_translate(vc, screen_glyph(vc, n * 2), true);
4706 unsigned short *screen_pos(const struct vc_data *vc, int w_offset, bool viewed)
4708 return screenpos(vc, 2 * w_offset, viewed);
4712 void getconsxy(const struct vc_data *vc, unsigned char xy[static 2])
4715 xy[0] = min(vc->state.x, 0xFFu);
4716 xy[1] = min(vc->state.y, 0xFFu);
4719 void putconsxy(struct vc_data *vc, unsigned char xy[static const 2])
4721 hide_cursor(vc);
4722 gotoxy(vc, xy[0], xy[1]);
4723 set_cursor(vc);
4726 u16 vcs_scr_readw(const struct vc_data *vc, const u16 *org)
4728 if ((unsigned long)org == vc->vc_pos && softcursor_original != -1)
4733 void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org)
4736 if ((unsigned long)org == vc->vc_pos) {
4738 add_softcursor(vc);
4742 void vcs_scr_updated(struct vc_data *vc)
4744 notify_update(vc);