Lines Matching full: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 restore_cur(struct vc_data *vc);
146 static void save_cur(struct vc_data *vc);
147 static void reset_terminal(struct vc_data *vc, int do_clear);
150 static void set_cursor(struct vc_data *vc);
151 static void hide_cursor(struct vc_data *vc);
155 static void set_palette(struct vc_data *vc);
236 * the attribute 'active' contains the name of the current vc
237 * console and it supports poll() to detect vc switches
258 static void notify_write(struct vc_data *vc, unsigned int unicode) in notify_write() argument
260 struct vt_notifier_param param = { .vc = vc, .c = unicode }; in notify_write()
264 static void notify_update(struct vc_data *vc) in notify_update() argument
266 struct vt_notifier_param param = { .vc = vc }; in notify_update()
273 static inline bool con_is_fg(const struct vc_data *vc) in con_is_fg() argument
275 return vc->vc_num == fg_console; in con_is_fg()
278 static inline bool con_should_update(const struct vc_data *vc) in con_should_update() argument
280 return con_is_visible(vc) && !console_blanked; in con_should_update()
283 static inline u16 *screenpos(const struct vc_data *vc, unsigned int offset, in screenpos() argument
286 unsigned long origin = viewed ? vc->vc_visible_origin : vc->vc_origin; in screenpos()
291 static void con_putc(struct vc_data *vc, u16 ca, unsigned int y, unsigned int x) in con_putc() argument
293 if (vc->vc_sw->con_putc) in con_putc()
294 vc->vc_sw->con_putc(vc, ca, y, x); in con_putc()
296 vc->vc_sw->con_putcs(vc, &ca, 1, y, x); in con_putc()
351 static void vc_uniscr_set(struct vc_data *vc, u32 **new_uni_lines) in vc_uniscr_set() argument
353 vc_uniscr_free(vc->vc_uni_lines); in vc_uniscr_set()
354 vc->vc_uni_lines = new_uni_lines; in vc_uniscr_set()
357 static void vc_uniscr_putc(struct vc_data *vc, u32 uc) in vc_uniscr_putc() argument
359 if (vc->vc_uni_lines) in vc_uniscr_putc()
360 vc->vc_uni_lines[vc->state.y][vc->state.x] = uc; in vc_uniscr_putc()
363 static void vc_uniscr_insert(struct vc_data *vc, unsigned int nr) in vc_uniscr_insert() argument
365 if (vc->vc_uni_lines) { in vc_uniscr_insert()
366 u32 *ln = vc->vc_uni_lines[vc->state.y]; in vc_uniscr_insert()
367 unsigned int x = vc->state.x, cols = vc->vc_cols; in vc_uniscr_insert()
374 static void vc_uniscr_delete(struct vc_data *vc, unsigned int nr) in vc_uniscr_delete() argument
376 if (vc->vc_uni_lines) { in vc_uniscr_delete()
377 u32 *ln = vc->vc_uni_lines[vc->state.y]; in vc_uniscr_delete()
378 unsigned int x = vc->state.x, cols = vc->vc_cols; in vc_uniscr_delete()
385 static void vc_uniscr_clear_line(struct vc_data *vc, unsigned int x, in vc_uniscr_clear_line() argument
388 if (vc->vc_uni_lines) in vc_uniscr_clear_line()
389 memset32(&vc->vc_uni_lines[vc->state.y][x], ' ', nr); in vc_uniscr_clear_line()
392 static void vc_uniscr_clear_lines(struct vc_data *vc, unsigned int y, in vc_uniscr_clear_lines() argument
395 if (vc->vc_uni_lines) in vc_uniscr_clear_lines()
397 memset32(vc->vc_uni_lines[y++], ' ', vc->vc_cols); in vc_uniscr_clear_lines()
422 static void vc_uniscr_scroll(struct vc_data *vc, unsigned int top, in vc_uniscr_scroll() argument
426 u32 **uni_lines = vc->vc_uni_lines; in vc_uniscr_scroll()
434 vc_uniscr_clear_lines(vc, top, nr); in vc_uniscr_scroll()
437 vc_uniscr_clear_lines(vc, bottom - nr, nr); in vc_uniscr_scroll()
441 static u32 vc_uniscr_getc(struct vc_data *vc, int relative_pos) in vc_uniscr_getc() argument
443 int pos = vc->state.x + vc->vc_need_wrap + relative_pos; in vc_uniscr_getc()
445 if (vc->vc_uni_lines && in_range(pos, 0, vc->vc_cols)) in vc_uniscr_getc()
446 return vc->vc_uni_lines[vc->state.y][pos]; in vc_uniscr_getc()
487 int vc_uniscr_check(struct vc_data *vc) in vc_uniscr_check() argument
495 if (!vc->vc_utf) in vc_uniscr_check()
498 if (vc->vc_uni_lines) in vc_uniscr_check()
501 uni_lines = vc_uniscr_alloc(vc->vc_cols, vc->vc_rows); in vc_uniscr_check()
511 p = (unsigned short *)vc->vc_origin; in vc_uniscr_check()
512 mask = vc->vc_hi_font_mask | 0xff; in vc_uniscr_check()
513 for (y = 0; y < vc->vc_rows; y++) { in vc_uniscr_check()
515 for (x = 0; x < vc->vc_cols; x++) { in vc_uniscr_check()
517 line[x] = inverse_translate(vc, glyph, true); in vc_uniscr_check()
521 vc->vc_uni_lines = uni_lines; in vc_uniscr_check()
531 void vc_uniscr_copy_line(const struct vc_data *vc, void *dest, bool viewed, in vc_uniscr_copy_line() argument
534 u32 **uni_lines = vc->vc_uni_lines; in vc_uniscr_copy_line()
535 int offset = row * vc->vc_size_row + col * 2; in vc_uniscr_copy_line()
541 pos = (unsigned long)screenpos(vc, offset, viewed); in vc_uniscr_copy_line()
542 if (pos >= vc->vc_origin && pos < vc->vc_scr_end) { in vc_uniscr_copy_line()
548 row = (pos - vc->vc_origin) / vc->vc_size_row; in vc_uniscr_copy_line()
549 col = ((pos - vc->vc_origin) % vc->vc_size_row) / 2; in vc_uniscr_copy_line()
559 int mask = vc->vc_hi_font_mask | 0xff; in vc_uniscr_copy_line()
563 *uni_buf++ = inverse_translate(vc, glyph, true); in vc_uniscr_copy_line()
568 static void con_scroll(struct vc_data *vc, unsigned int top, in con_scroll() argument
577 if (bottom > vc->vc_rows || top >= bottom || nr < 1) in con_scroll()
580 vc_uniscr_scroll(vc, top, bottom, dir, nr); in con_scroll()
581 if (con_is_visible(vc) && in con_scroll()
582 vc->vc_sw->con_scroll(vc, top, bottom, dir, nr)) in con_scroll()
585 src = clear = (u16 *)(vc->vc_origin + vc->vc_size_row * top); in con_scroll()
586 dst = (u16 *)(vc->vc_origin + vc->vc_size_row * (top + nr)); in con_scroll()
589 clear = src + (rows - nr) * vc->vc_cols; in con_scroll()
592 scr_memmovew(dst, src, (rows - nr) * vc->vc_size_row); in con_scroll()
593 scr_memsetw(clear, vc->vc_video_erase_char, vc->vc_size_row * nr); in con_scroll()
596 static void do_update_region(struct vc_data *vc, unsigned long start, int count) in do_update_region() argument
601 offset = (start - vc->vc_origin) / 2; in do_update_region()
602 xx = offset % vc->vc_cols; in do_update_region()
603 yy = offset / vc->vc_cols; in do_update_region()
609 while (xx < vc->vc_cols && count) { in do_update_region()
612 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); in do_update_region()
622 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); in do_update_region()
630 void update_region(struct vc_data *vc, unsigned long start, int count) in update_region() argument
634 if (con_should_update(vc)) { in update_region()
635 hide_cursor(vc); in update_region()
636 do_update_region(vc, start, count); in update_region()
637 set_cursor(vc); in update_region()
644 static u8 build_attr(struct vc_data *vc, u8 _color, in build_attr() argument
648 if (vc->vc_sw->con_build_attr) in build_attr()
649 return vc->vc_sw->con_build_attr(vc, _color, _intensity, in build_attr()
664 if (!vc->vc_can_do_color) in build_attr()
671 a = (a & 0xF0) | vc->vc_itcolor; in build_attr()
673 a = (a & 0xf0) | vc->vc_ulcolor; in build_attr()
675 a = (a & 0xf0) | vc->vc_halfcolor; in build_attr()
682 if (vc->vc_hi_font_mask == 0x100) in build_attr()
688 static void update_attr(struct vc_data *vc) in update_attr() argument
690 vc->vc_attr = build_attr(vc, vc->state.color, vc->state.intensity, in update_attr()
691 vc->state.blink, vc->state.underline, in update_attr()
692 vc->state.reverse ^ vc->vc_decscnm, vc->state.italic); in update_attr()
693 vc->vc_video_erase_char = ' ' | (build_attr(vc, vc->state.color, in update_attr()
694 VCI_NORMAL, vc->state.blink, false, in update_attr()
695 vc->vc_decscnm, false) << 8); in update_attr()
699 void invert_screen(struct vc_data *vc, int offset, int count, bool viewed) in invert_screen() argument
706 p = screenpos(vc, offset, viewed); in invert_screen()
707 if (vc->vc_sw->con_invert_region) { in invert_screen()
708 vc->vc_sw->con_invert_region(vc, p, count); in invert_screen()
714 if (!vc->vc_can_do_color) { in invert_screen()
721 } else if (vc->vc_hi_font_mask == 0x100) { in invert_screen()
742 if (con_should_update(vc)) in invert_screen()
743 do_update_region(vc, (unsigned long) p, count); in invert_screen()
744 notify_update(vc); in invert_screen()
748 void complement_pos(struct vc_data *vc, int offset) in complement_pos() argument
757 old_offset < vc->vc_screenbuf_size) { in complement_pos()
758 scr_writew(old, screenpos(vc, old_offset, true)); in complement_pos()
759 if (con_should_update(vc)) in complement_pos()
760 con_putc(vc, old, oldy, oldx); in complement_pos()
761 notify_update(vc); in complement_pos()
767 offset < vc->vc_screenbuf_size) { in complement_pos()
769 u16 *p = screenpos(vc, offset, true); in complement_pos()
771 new = old ^ vc->vc_complement_mask; in complement_pos()
773 if (con_should_update(vc)) { in complement_pos()
774 oldx = (offset >> 1) % vc->vc_cols; in complement_pos()
775 oldy = (offset >> 1) / vc->vc_cols; in complement_pos()
776 con_putc(vc, new, oldy, oldx); in complement_pos()
778 notify_update(vc); in complement_pos()
782 static void insert_char(struct vc_data *vc, unsigned int nr) in insert_char() argument
784 unsigned short *p = (unsigned short *) vc->vc_pos; in insert_char()
786 vc_uniscr_insert(vc, nr); in insert_char()
787 scr_memmovew(p + nr, p, (vc->vc_cols - vc->state.x - nr) * 2); in insert_char()
788 scr_memsetw(p, vc->vc_video_erase_char, nr * 2); in insert_char()
789 vc->vc_need_wrap = 0; in insert_char()
790 if (con_should_update(vc)) in insert_char()
791 do_update_region(vc, (unsigned long) p, in insert_char()
792 vc->vc_cols - vc->state.x); in insert_char()
795 static void delete_char(struct vc_data *vc, unsigned int nr) in delete_char() argument
797 unsigned short *p = (unsigned short *) vc->vc_pos; in delete_char()
799 vc_uniscr_delete(vc, nr); in delete_char()
800 scr_memmovew(p, p + nr, (vc->vc_cols - vc->state.x - nr) * 2); in delete_char()
801 scr_memsetw(p + vc->vc_cols - vc->state.x - nr, vc->vc_video_erase_char, in delete_char()
803 vc->vc_need_wrap = 0; in delete_char()
804 if (con_should_update(vc)) in delete_char()
805 do_update_region(vc, (unsigned long) p, in delete_char()
806 vc->vc_cols - vc->state.x); in delete_char()
811 static void add_softcursor(struct vc_data *vc) in add_softcursor() argument
813 int i = scr_readw((u16 *) vc->vc_pos); in add_softcursor()
814 u32 type = vc->vc_cursor_type; in add_softcursor()
828 scr_writew(i, (u16 *)vc->vc_pos); in add_softcursor()
829 if (con_should_update(vc)) in add_softcursor()
830 con_putc(vc, i, vc->state.y, vc->state.x); in add_softcursor()
833 static void hide_softcursor(struct vc_data *vc) in hide_softcursor() argument
836 scr_writew(softcursor_original, (u16 *)vc->vc_pos); in hide_softcursor()
837 if (con_should_update(vc)) in hide_softcursor()
838 con_putc(vc, softcursor_original, vc->state.y, in hide_softcursor()
839 vc->state.x); in hide_softcursor()
844 static void hide_cursor(struct vc_data *vc) in hide_cursor() argument
846 if (vc_is_sel(vc)) in hide_cursor()
849 vc->vc_sw->con_cursor(vc, false); in hide_cursor()
850 hide_softcursor(vc); in hide_cursor()
853 static void set_cursor(struct vc_data *vc) in set_cursor() argument
855 if (!con_is_fg(vc) || console_blanked || vc->vc_mode == KD_GRAPHICS) in set_cursor()
857 if (vc->vc_deccm) { in set_cursor()
858 if (vc_is_sel(vc)) in set_cursor()
860 add_softcursor(vc); in set_cursor()
861 if (CUR_SIZE(vc->vc_cursor_type) != CUR_NONE) in set_cursor()
862 vc->vc_sw->con_cursor(vc, true); in set_cursor()
864 hide_cursor(vc); in set_cursor()
867 static void set_origin(struct vc_data *vc) in set_origin() argument
871 if (!con_is_visible(vc) || in set_origin()
872 !vc->vc_sw->con_set_origin || in set_origin()
873 !vc->vc_sw->con_set_origin(vc)) in set_origin()
874 vc->vc_origin = (unsigned long)vc->vc_screenbuf; in set_origin()
875 vc->vc_visible_origin = vc->vc_origin; in set_origin()
876 vc->vc_scr_end = vc->vc_origin + vc->vc_screenbuf_size; in set_origin()
877 vc->vc_pos = vc->vc_origin + vc->vc_size_row * vc->state.y + in set_origin()
878 2 * vc->state.x; in set_origin()
881 static void save_screen(struct vc_data *vc) in save_screen() argument
885 if (vc->vc_sw->con_save_screen) in save_screen()
886 vc->vc_sw->con_save_screen(vc); in save_screen()
889 static void flush_scrollback(struct vc_data *vc) in flush_scrollback() argument
893 set_origin(vc); in flush_scrollback()
894 if (!con_is_visible(vc)) in flush_scrollback()
903 hide_cursor(vc); in flush_scrollback()
904 vc->vc_sw->con_switch(vc); in flush_scrollback()
905 set_cursor(vc); in flush_scrollback()
912 void clear_buffer_attributes(struct vc_data *vc) in clear_buffer_attributes() argument
914 unsigned short *p = (unsigned short *)vc->vc_origin; in clear_buffer_attributes()
915 int count = vc->vc_screenbuf_size / 2; in clear_buffer_attributes()
916 int mask = vc->vc_hi_font_mask | 0xff; in clear_buffer_attributes()
919 scr_writew((scr_readw(p)&mask) | (vc->vc_video_erase_char & ~mask), p); in clear_buffer_attributes()
923 void redraw_screen(struct vc_data *vc, int is_switch) in redraw_screen() argument
929 if (!vc) { in redraw_screen()
937 if (old_vc == vc) in redraw_screen()
939 if (!con_is_visible(vc)) in redraw_screen()
941 *vc->vc_display_fg = vc; in redraw_screen()
942 fg_console = vc->vc_num; in redraw_screen()
951 hide_cursor(vc); in redraw_screen()
957 int old_was_color = vc->vc_can_do_color; in redraw_screen()
959 set_origin(vc); in redraw_screen()
960 update = vc->vc_sw->con_switch(vc); in redraw_screen()
961 set_palette(vc); in redraw_screen()
968 if (old_was_color != vc->vc_can_do_color) { in redraw_screen()
969 update_attr(vc); in redraw_screen()
970 clear_buffer_attributes(vc); in redraw_screen()
973 if (update && vc->vc_mode != KD_GRAPHICS) in redraw_screen()
974 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in redraw_screen()
976 set_cursor(vc); in redraw_screen()
979 notify_update(vc); in redraw_screen()
993 static void visual_init(struct vc_data *vc, int num, bool init) in visual_init() argument
995 /* ++Geert: vc->vc_sw->con_init determines console size */ in visual_init()
996 if (vc->vc_sw) in visual_init()
997 module_put(vc->vc_sw->owner); in visual_init()
998 vc->vc_sw = conswitchp; in visual_init()
1001 vc->vc_sw = con_driver_map[num]; in visual_init()
1003 __module_get(vc->vc_sw->owner); in visual_init()
1004 vc->vc_num = num; in visual_init()
1005 vc->vc_display_fg = &master_display_fg; in visual_init()
1006 if (vc->uni_pagedict_loc) in visual_init()
1007 con_free_unimap(vc); in visual_init()
1008 vc->uni_pagedict_loc = &vc->uni_pagedict; in visual_init()
1009 vc->uni_pagedict = NULL; in visual_init()
1010 vc->vc_hi_font_mask = 0; in visual_init()
1011 vc->vc_complement_mask = 0; in visual_init()
1012 vc->vc_can_do_color = 0; in visual_init()
1013 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in visual_init()
1014 vc->vc_sw->con_init(vc, init); in visual_init()
1015 if (!vc->vc_complement_mask) in visual_init()
1016 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; in visual_init()
1017 vc->vc_s_complement_mask = vc->vc_complement_mask; in visual_init()
1018 vc->vc_size_row = vc->vc_cols << 1; in visual_init()
1019 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; in visual_init()
1023 static void visual_deinit(struct vc_data *vc) in visual_deinit() argument
1025 vc->vc_sw->con_deinit(vc); in visual_deinit()
1026 module_put(vc->vc_sw->owner); in visual_deinit()
1031 struct vc_data *vc = container_of(port, struct vc_data, port); in vc_port_destruct() local
1033 kfree(vc); in vc_port_destruct()
1051 struct vc_data *vc; in vc_allocate() local
1068 param.vc = vc = kzalloc_obj(struct vc_data); in vc_allocate()
1069 if (!vc) in vc_allocate()
1072 vc_cons[currcons].d = vc; in vc_allocate()
1073 tty_port_init(&vc->port); in vc_allocate()
1074 vc->port.ops = &vc_port_ops; in vc_allocate()
1077 visual_init(vc, currcons, true); in vc_allocate()
1079 if (!*vc->uni_pagedict_loc) in vc_allocate()
1080 con_set_default_unimap(vc); in vc_allocate()
1083 if (vc->vc_cols > VC_MAXCOL || vc->vc_rows > VC_MAXROW || in vc_allocate()
1084 vc->vc_screenbuf_size > KMALLOC_MAX_SIZE || !vc->vc_screenbuf_size) in vc_allocate()
1087 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_KERNEL); in vc_allocate()
1088 if (!vc->vc_screenbuf) in vc_allocate()
1096 vc_init(vc, 1); in vc_allocate()
1102 visual_deinit(vc); in vc_allocate()
1103 kfree(vc); in vc_allocate()
1108 static inline int resize_screen(struct vc_data *vc, int width, int height, in resize_screen() argument
1114 if (vc->vc_sw->con_resize) in resize_screen()
1115 err = vc->vc_sw->con_resize(vc, width, height, from_user); in resize_screen()
1123 * @vc: virtual console private data
1135 static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, in vc_do_resize() argument
1150 new_cols = (cols ? cols : vc->vc_cols); in vc_do_resize()
1151 new_rows = (lines ? lines : vc->vc_rows); in vc_do_resize()
1155 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) { in vc_do_resize()
1172 return resize_screen(vc, new_cols, new_rows, from_user); in vc_do_resize()
1181 if (vc->vc_uni_lines) { in vc_do_resize()
1189 if (vc_is_sel(vc)) in vc_do_resize()
1192 old_rows = vc->vc_rows; in vc_do_resize()
1193 old_row_size = vc->vc_size_row; in vc_do_resize()
1195 err = resize_screen(vc, new_cols, new_rows, from_user); in vc_do_resize()
1202 vc->vc_rows = new_rows; in vc_do_resize()
1203 vc->vc_cols = new_cols; in vc_do_resize()
1204 vc->vc_size_row = new_row_size; in vc_do_resize()
1205 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
1209 old_origin = vc->vc_origin; in vc_do_resize()
1213 if (vc->state.y > new_rows) { in vc_do_resize()
1214 if (old_rows - vc->state.y < new_rows) { in vc_do_resize()
1225 first_copied_row = (vc->state.y - new_rows/2); in vc_do_resize()
1233 vc->vc_uni_lines, rlth/2, first_copied_row, in vc_do_resize()
1235 vc_uniscr_set(vc, new_uniscr); in vc_do_resize()
1237 update_attr(vc); in vc_do_resize()
1244 vc->vc_video_erase_char, rrem); in vc_do_resize()
1249 scr_memsetw((void *)new_origin, vc->vc_video_erase_char, in vc_do_resize()
1251 oldscreen = vc->vc_screenbuf; in vc_do_resize()
1252 vc->vc_screenbuf = newscreen; in vc_do_resize()
1253 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
1254 set_origin(vc); in vc_do_resize()
1258 vc->vc_top = 0; in vc_do_resize()
1259 vc->vc_bottom = vc->vc_rows; in vc_do_resize()
1260 gotoxy(vc, vc->state.x, vc->state.y); in vc_do_resize()
1261 save_cur(vc); in vc_do_resize()
1268 ws.ws_row = vc->vc_rows; in vc_do_resize()
1269 ws.ws_col = vc->vc_cols; in vc_do_resize()
1270 ws.ws_ypixel = vc->vc_scan_lines; in vc_do_resize()
1274 if (con_is_visible(vc)) in vc_do_resize()
1275 update_screen(vc); in vc_do_resize()
1276 vt_event_post(VT_EVENT_RESIZE, vc->vc_num, vc->vc_num); in vc_do_resize()
1277 notify_update(vc); in vc_do_resize()
1283 * @vc: virtual console
1292 * and @vc->port.tty.
1294 int __vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows, in __vc_resize() argument
1297 return vc_do_resize(vc->port.tty, vc, cols, rows, from_user); in __vc_resize()
1314 struct vc_data *vc = tty->driver_data; in vt_resize() local
1317 return vc_do_resize(tty, vc, ws->ws_col, ws->ws_row, false); in vt_resize()
1322 struct vc_data *vc = NULL; in vc_deallocate() local
1329 param.vc = vc = vc_cons[currcons].d; in vc_deallocate()
1332 visual_deinit(vc); in vc_deallocate()
1333 con_free_unimap(vc); in vc_deallocate()
1334 put_pid(vc->vt_pid); in vc_deallocate()
1335 vc_uniscr_set(vc, NULL); in vc_deallocate()
1336 kfree(vc->vc_screenbuf); in vc_deallocate()
1338 if (vc->vc_saved_screen != NULL) { in vc_deallocate()
1339 kfree(vc->vc_saved_screen); in vc_deallocate()
1340 vc->vc_saved_screen = NULL; in vc_deallocate()
1342 vc_uniscr_free(vc->vc_saved_uni_lines); in vc_deallocate()
1343 vc->vc_saved_uni_lines = NULL; in vc_deallocate()
1345 return vc; in vc_deallocate()
1354 #define set_kbd(vc, x) vt_set_kbd_mode_bit((vc)->vc_num, (x)) argument
1355 #define clr_kbd(vc, x) vt_clr_kbd_mode_bit((vc)->vc_num, (x)) argument
1356 #define is_kbd(vc, x) vt_get_kbd_mode_bit((vc)->vc_num, (x)) argument
1394 static void gotoxy(struct vc_data *vc, int new_x, int new_y) in gotoxy() argument
1399 vc->state.x = 0; in gotoxy()
1401 if (new_x >= vc->vc_cols) in gotoxy()
1402 vc->state.x = vc->vc_cols - 1; in gotoxy()
1404 vc->state.x = new_x; in gotoxy()
1407 if (vc->vc_decom) { in gotoxy()
1408 min_y = vc->vc_top; in gotoxy()
1409 max_y = vc->vc_bottom; in gotoxy()
1412 max_y = vc->vc_rows; in gotoxy()
1415 vc->state.y = min_y; in gotoxy()
1417 vc->state.y = max_y - 1; in gotoxy()
1419 vc->state.y = new_y; in gotoxy()
1420 vc->vc_pos = vc->vc_origin + vc->state.y * vc->vc_size_row + in gotoxy()
1421 (vc->state.x << 1); in gotoxy()
1422 vc->vc_need_wrap = 0; in gotoxy()
1426 static void gotoxay(struct vc_data *vc, int new_x, int new_y) in gotoxay() argument
1428 gotoxy(vc, new_x, vc->vc_decom ? (vc->vc_top + new_y) : new_y); in gotoxay()
1431 void scrollback(struct vc_data *vc) in scrollback() argument
1433 scrolldelta(-(vc->vc_rows / 2)); in scrollback()
1436 void scrollfront(struct vc_data *vc, int lines) in scrollfront() argument
1439 lines = vc->vc_rows / 2; in scrollfront()
1443 static void lf(struct vc_data *vc) in lf() argument
1448 if (vc->state.y + 1 == vc->vc_bottom) in lf()
1449 con_scroll(vc, vc->vc_top, vc->vc_bottom, SM_UP, 1); in lf()
1450 else if (vc->state.y < vc->vc_rows - 1) { in lf()
1451 vc->state.y++; in lf()
1452 vc->vc_pos += vc->vc_size_row; in lf()
1454 vc->vc_need_wrap = 0; in lf()
1455 notify_write(vc, '\n'); in lf()
1458 static void ri(struct vc_data *vc) in ri() argument
1463 if (vc->state.y == vc->vc_top) in ri()
1464 con_scroll(vc, vc->vc_top, vc->vc_bottom, SM_DOWN, 1); in ri()
1465 else if (vc->state.y > 0) { in ri()
1466 vc->state.y--; in ri()
1467 vc->vc_pos -= vc->vc_size_row; in ri()
1469 vc->vc_need_wrap = 0; in ri()
1472 static inline void cr(struct vc_data *vc) in cr() argument
1474 vc->vc_pos -= vc->state.x << 1; in cr()
1475 vc->vc_need_wrap = vc->state.x = 0; in cr()
1476 notify_write(vc, '\r'); in cr()
1479 static inline void bs(struct vc_data *vc) in bs() argument
1481 if (vc->state.x) { in bs()
1482 vc->vc_pos -= 2; in bs()
1483 vc->state.x--; in bs()
1484 vc->vc_need_wrap = 0; in bs()
1485 notify_write(vc, '\b'); in bs()
1489 static inline void del(struct vc_data *vc) in del() argument
1501 static void csi_J(struct vc_data *vc, enum CSI_J vpar) in csi_J() argument
1508 vc_uniscr_clear_line(vc, vc->state.x, in csi_J()
1509 vc->vc_cols - vc->state.x); in csi_J()
1510 vc_uniscr_clear_lines(vc, vc->state.y + 1, in csi_J()
1511 vc->vc_rows - vc->state.y - 1); in csi_J()
1512 count = (vc->vc_scr_end - vc->vc_pos) >> 1; in csi_J()
1513 start = (unsigned short *)vc->vc_pos; in csi_J()
1516 vc_uniscr_clear_line(vc, 0, vc->state.x + 1); in csi_J()
1517 vc_uniscr_clear_lines(vc, 0, vc->state.y); in csi_J()
1518 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1; in csi_J()
1519 start = (unsigned short *)vc->vc_origin; in csi_J()
1522 flush_scrollback(vc); in csi_J()
1525 vc_uniscr_clear_lines(vc, 0, vc->vc_rows); in csi_J()
1526 count = vc->vc_cols * vc->vc_rows; in csi_J()
1527 start = (unsigned short *)vc->vc_origin; in csi_J()
1532 scr_memsetw(start, vc->vc_video_erase_char, 2 * count); in csi_J()
1533 if (con_should_update(vc)) in csi_J()
1534 do_update_region(vc, (unsigned long) start, count); in csi_J()
1535 vc->vc_need_wrap = 0; in csi_J()
1544 static void csi_K(struct vc_data *vc) in csi_K() argument
1547 unsigned short *start = (unsigned short *)vc->vc_pos; in csi_K()
1550 switch (vc->vc_par[0]) { in csi_K()
1553 count = vc->vc_cols - vc->state.x; in csi_K()
1556 offset = -vc->state.x; in csi_K()
1557 count = vc->state.x + 1; in csi_K()
1560 offset = -vc->state.x; in csi_K()
1561 count = vc->vc_cols; in csi_K()
1566 vc_uniscr_clear_line(vc, vc->state.x + offset, count); in csi_K()
1567 scr_memsetw(start + offset, vc->vc_video_erase_char, 2 * count); in csi_K()
1568 vc->vc_need_wrap = 0; in csi_K()
1569 if (con_should_update(vc)) in csi_K()
1570 do_update_region(vc, (unsigned long)(start + offset), count); in csi_K()
1574 static void csi_X(struct vc_data *vc) in csi_X() argument
1576 unsigned int count = clamp(vc->vc_par[0], 1, vc->vc_cols - vc->state.x); in csi_X()
1578 vc_uniscr_clear_line(vc, vc->state.x, count); in csi_X()
1579 scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count); in csi_X()
1580 if (con_should_update(vc)) in csi_X()
1581 vc->vc_sw->con_clear(vc, vc->state.y, vc->state.x, count); in csi_X()
1582 vc->vc_need_wrap = 0; in csi_X()
1585 static void default_attr(struct vc_data *vc) in default_attr() argument
1587 vc->state.intensity = VCI_NORMAL; in default_attr()
1588 vc->state.italic = false; in default_attr()
1589 vc->state.underline = false; in default_attr()
1590 vc->state.reverse = false; in default_attr()
1591 vc->state.blink = false; in default_attr()
1592 vc->state.color = vc->vc_def_color; in default_attr()
1618 static void rgb_foreground(struct vc_data *vc, const struct rgb *c) in rgb_foreground() argument
1631 vc->state.intensity = VCI_BOLD; in rgb_foreground()
1633 vc->state.intensity = VCI_BOLD; in rgb_foreground()
1635 vc->state.intensity = VCI_NORMAL; in rgb_foreground()
1637 vc->state.color = (vc->state.color & 0xf0) | hue; in rgb_foreground()
1640 static void rgb_background(struct vc_data *vc, const struct rgb *c) in rgb_background() argument
1643 vc->state.color = (vc->state.color & 0x0f) in rgb_background()
1656 static int vc_t416_color(struct vc_data *vc, int i, in vc_t416_color() argument
1657 void(*set_color)(struct vc_data *vc, const struct rgb *c)) in vc_t416_color() argument
1662 if (i > vc->vc_npar) in vc_t416_color()
1665 if (vc->vc_par[i] == 5 && i + 1 <= vc->vc_npar) { in vc_t416_color()
1668 rgb_from_256(vc->vc_par[i], &c); in vc_t416_color()
1669 } else if (vc->vc_par[i] == 2 && i + 3 <= vc->vc_npar) { in vc_t416_color()
1671 c.r = vc->vc_par[i + 1]; in vc_t416_color()
1672 c.g = vc->vc_par[i + 2]; in vc_t416_color()
1673 c.b = vc->vc_par[i + 3]; in vc_t416_color()
1678 set_color(vc, &c); in vc_t416_color()
1717 static void csi_m(struct vc_data *vc) in csi_m() argument
1721 for (i = 0; i <= vc->vc_npar; i++) in csi_m()
1722 switch (vc->vc_par[i]) { in csi_m()
1724 default_attr(vc); in csi_m()
1727 vc->state.intensity = VCI_BOLD; in csi_m()
1730 vc->state.intensity = VCI_HALF_BRIGHT; in csi_m()
1733 vc->state.italic = true; in csi_m()
1741 vc->state.underline = true; in csi_m()
1744 vc->state.blink = true; in csi_m()
1747 vc->state.reverse = true; in csi_m()
1753 vc->vc_translate = set_translate(vc->state.Gx_charset[vc->state.charset], vc); in csi_m()
1754 vc->vc_disp_ctrl = 0; in csi_m()
1755 vc->vc_toggle_meta = 0; in csi_m()
1761 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1762 vc->vc_disp_ctrl = 1; in csi_m()
1763 vc->vc_toggle_meta = 0; in csi_m()
1769 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1770 vc->vc_disp_ctrl = 1; in csi_m()
1771 vc->vc_toggle_meta = 1; in csi_m()
1774 vc->state.intensity = VCI_NORMAL; in csi_m()
1777 vc->state.italic = false; in csi_m()
1780 vc->state.underline = false; in csi_m()
1783 vc->state.blink = false; in csi_m()
1786 vc->state.reverse = false; in csi_m()
1789 i = vc_t416_color(vc, i, rgb_foreground); in csi_m()
1792 i = vc_t416_color(vc, i, rgb_background); in csi_m()
1795 vc->state.color = (vc->vc_def_color & 0x0f) | in csi_m()
1796 (vc->state.color & 0xf0); in csi_m()
1799 vc->state.color = (vc->vc_def_color & 0xf0) | in csi_m()
1800 (vc->state.color & 0x0f); in csi_m()
1803 vc->state.intensity = VCI_BOLD; in csi_m()
1804 vc->vc_par[i] -= CSI_m_BRIGHT_FG_COLOR_OFF; in csi_m()
1807 vc->vc_par[i] -= CSI_m_FG_COLOR_BEG; in csi_m()
1808 vc->state.color = color_table[vc->vc_par[i]] | in csi_m()
1809 (vc->state.color & 0xf0); in csi_m()
1812 vc->vc_par[i] -= CSI_m_BRIGHT_BG_COLOR_OFF; in csi_m()
1815 vc->vc_par[i] -= CSI_m_BG_COLOR_BEG; in csi_m()
1816 vc->state.color = (color_table[vc->vc_par[i]] << 4) | in csi_m()
1817 (vc->state.color & 0x0f); in csi_m()
1820 update_attr(vc); in csi_m()
1829 static void cursor_report(struct vc_data *vc, struct tty_struct *tty) in cursor_report() argument
1834 len = sprintf(buf, "\033[%d;%dR", vc->state.y + in cursor_report()
1835 (vc->vc_decom ? vc->vc_top + 1 : 1), in cursor_report()
1836 vc->state.x + 1); in cursor_report()
1874 struct vc_data *vc = tty->driver_data; in get_bracketed_paste() local
1876 return vc->vc_bracketed_paste; in get_bracketed_paste()
1880 static void enter_alt_screen(struct vc_data *vc) in enter_alt_screen() argument
1882 unsigned int size = vc->vc_rows * vc->vc_cols * 2; in enter_alt_screen()
1884 if (vc->vc_saved_screen != NULL) in enter_alt_screen()
1886 vc->vc_saved_screen = kmemdup((u16 *)vc->vc_origin, size, GFP_KERNEL); in enter_alt_screen()
1887 if (vc->vc_saved_screen == NULL) in enter_alt_screen()
1889 vc->vc_saved_uni_lines = vc->vc_uni_lines; in enter_alt_screen()
1890 vc->vc_uni_lines = NULL; in enter_alt_screen()
1891 vc->vc_saved_rows = vc->vc_rows; in enter_alt_screen()
1892 vc->vc_saved_cols = vc->vc_cols; in enter_alt_screen()
1893 save_cur(vc); in enter_alt_screen()
1895 csi_J(vc, CSI_J_FULL); in enter_alt_screen()
1899 static void leave_alt_screen(struct vc_data *vc) in leave_alt_screen() argument
1901 unsigned int rows = min(vc->vc_saved_rows, vc->vc_rows); in leave_alt_screen()
1902 unsigned int cols = min(vc->vc_saved_cols, vc->vc_cols); in leave_alt_screen()
1905 if (vc->vc_saved_screen == NULL) in leave_alt_screen()
1908 src = vc->vc_saved_screen + r * vc->vc_saved_cols; in leave_alt_screen()
1909 dest = ((u16 *)vc->vc_origin) + r * vc->vc_cols; in leave_alt_screen()
1912 vc_uniscr_set(vc, vc->vc_saved_uni_lines); in leave_alt_screen()
1913 vc->vc_saved_uni_lines = NULL; in leave_alt_screen()
1914 restore_cur(vc); in leave_alt_screen()
1916 if (con_should_update(vc)) in leave_alt_screen()
1917 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in leave_alt_screen()
1918 kfree(vc->vc_saved_screen); in leave_alt_screen()
1919 vc->vc_saved_screen = NULL; in leave_alt_screen()
1937 static void csi_DEC_hl(struct vc_data *vc, bool on_off) in csi_DEC_hl() argument
1941 for (i = 0; i <= vc->vc_npar; i++) in csi_DEC_hl()
1942 switch (vc->vc_par[i]) { in csi_DEC_hl()
1945 set_kbd(vc, decckm); in csi_DEC_hl()
1947 clr_kbd(vc, decckm); in csi_DEC_hl()
1951 vc_resize(deccolm ? 132 : 80, vc->vc_rows); in csi_DEC_hl()
1957 if (vc->vc_decscnm != on_off) { in csi_DEC_hl()
1958 vc->vc_decscnm = on_off; in csi_DEC_hl()
1959 invert_screen(vc, 0, vc->vc_screenbuf_size, in csi_DEC_hl()
1961 update_attr(vc); in csi_DEC_hl()
1965 vc->vc_decom = on_off; in csi_DEC_hl()
1966 gotoxay(vc, 0, 0); in csi_DEC_hl()
1969 vc->vc_decawm = on_off; in csi_DEC_hl()
1973 set_kbd(vc, decarm); in csi_DEC_hl()
1975 clr_kbd(vc, decarm); in csi_DEC_hl()
1978 vc->vc_report_mouse = on_off ? 1 : 0; in csi_DEC_hl()
1981 vc->vc_deccm = on_off; in csi_DEC_hl()
1984 vc->vc_report_mouse = on_off ? 2 : 0; in csi_DEC_hl()
1987 vc->vc_bracketed_paste = on_off; in csi_DEC_hl()
1991 enter_alt_screen(vc); in csi_DEC_hl()
1993 leave_alt_screen(vc); in csi_DEC_hl()
2005 static void csi_hl(struct vc_data *vc, bool on_off) in csi_hl() argument
2009 for (i = 0; i <= vc->vc_npar; i++) in csi_hl()
2010 switch (vc->vc_par[i]) { /* ANSI modes set/reset */ in csi_hl()
2012 vc->vc_disp_ctrl = on_off; in csi_hl()
2015 vc->vc_decim = on_off; in csi_hl()
2019 set_kbd(vc, lnm); in csi_hl()
2021 clr_kbd(vc, lnm); in csi_hl()
2047 static void csi_RSB(struct vc_data *vc) in csi_RSB() argument
2049 switch (vc->vc_par[0]) { in csi_RSB()
2051 if (vc->vc_can_do_color && vc->vc_par[1] < 16) { in csi_RSB()
2052 vc->vc_ulcolor = color_table[vc->vc_par[1]]; in csi_RSB()
2053 if (vc->state.underline) in csi_RSB()
2054 update_attr(vc); in csi_RSB()
2058 if (vc->vc_can_do_color && vc->vc_par[1] < 16) { in csi_RSB()
2059 vc->vc_halfcolor = color_table[vc->vc_par[1]]; in csi_RSB()
2060 if (vc->state.intensity == VCI_HALF_BRIGHT) in csi_RSB()
2061 update_attr(vc); in csi_RSB()
2065 vc->vc_def_color = vc->vc_attr; in csi_RSB()
2066 if (vc->vc_hi_font_mask == 0x100) in csi_RSB()
2067 vc->vc_def_color >>= 1; in csi_RSB()
2068 default_attr(vc); in csi_RSB()
2069 update_attr(vc); in csi_RSB()
2072 blankinterval = min(vc->vc_par[1], 60U) * 60; in csi_RSB()
2076 if (vc->vc_npar >= 1) in csi_RSB()
2077 vc->vc_bell_pitch = vc->vc_par[1]; in csi_RSB()
2079 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in csi_RSB()
2082 if (vc->vc_npar >= 1) in csi_RSB()
2083 vc->vc_bell_duration = (vc->vc_par[1] < 2000) ? in csi_RSB()
2084 msecs_to_jiffies(vc->vc_par[1]) : 0; in csi_RSB()
2086 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in csi_RSB()
2089 if (vc->vc_par[1] >= 1 && vc_cons_allocated(vc->vc_par[1] - 1)) in csi_RSB()
2090 set_console(vc->vc_par[1] - 1); in csi_RSB()
2096 vesa_off_interval = min(vc->vc_par[1], 60U) * 60 * HZ; in csi_RSB()
2102 if (vc->vc_npar >= 1 && vc->vc_par[1] >= 50 && in csi_RSB()
2103 vc->vc_par[1] <= USHRT_MAX) in csi_RSB()
2104 vc->vc_cur_blink_ms = vc->vc_par[1]; in csi_RSB()
2106 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in csi_RSB()
2112 static void csi_at(struct vc_data *vc, unsigned int nr) in csi_at() argument
2114 nr = clamp(nr, 1, vc->vc_cols - vc->state.x); in csi_at()
2115 insert_char(vc, nr); in csi_at()
2119 static void csi_L(struct vc_data *vc) in csi_L() argument
2121 unsigned int nr = clamp(vc->vc_par[0], 1, vc->vc_rows - vc->state.y); in csi_L()
2123 con_scroll(vc, vc->state.y, vc->vc_bottom, SM_DOWN, nr); in csi_L()
2124 vc->vc_need_wrap = 0; in csi_L()
2128 static void csi_P(struct vc_data *vc) in csi_P() argument
2130 unsigned int nr = clamp(vc->vc_par[0], 1, vc->vc_cols - vc->state.x); in csi_P()
2132 delete_char(vc, nr); in csi_P()
2136 static void csi_M(struct vc_data *vc) in csi_M() argument
2138 unsigned int nr = clamp(vc->vc_par[0], 1, vc->vc_rows - vc->state.y); in csi_M()
2140 con_scroll(vc, vc->state.y, vc->vc_bottom, SM_UP, nr); in csi_M()
2141 vc->vc_need_wrap = 0; in csi_M()
2145 static void save_cur(struct vc_data *vc) in save_cur() argument
2147 memcpy(&vc->saved_state, &vc->state, sizeof(vc->state)); in save_cur()
2151 static void restore_cur(struct vc_data *vc) in restore_cur() argument
2153 memcpy(&vc->state, &vc->saved_state, sizeof(vc->state)); in restore_cur()
2155 gotoxy(vc, vc->state.x, vc->state.y); in restore_cur()
2156 vc->vc_translate = set_translate(vc->state.Gx_charset[vc->state.charset], in restore_cur()
2157 vc); in restore_cur()
2158 update_attr(vc); in restore_cur()
2159 vc->vc_need_wrap = 0; in restore_cur()
2206 static void reset_terminal(struct vc_data *vc, int do_clear) in reset_terminal() argument
2210 vc->vc_top = 0; in reset_terminal()
2211 vc->vc_bottom = vc->vc_rows; in reset_terminal()
2212 vc->vc_state = ESnormal; in reset_terminal()
2213 vc->vc_priv = EPecma; in reset_terminal()
2214 vc->vc_translate = set_translate(LAT1_MAP, vc); in reset_terminal()
2215 vc->state.Gx_charset[0] = LAT1_MAP; in reset_terminal()
2216 vc->state.Gx_charset[1] = GRAF_MAP; in reset_terminal()
2217 vc->state.charset = 0; in reset_terminal()
2218 vc->vc_need_wrap = 0; in reset_terminal()
2219 vc->vc_report_mouse = 0; in reset_terminal()
2220 vc->vc_bracketed_paste = 0; in reset_terminal()
2221 vc->vc_utf = default_utf8; in reset_terminal()
2222 vc->vc_utf_count = 0; in reset_terminal()
2224 vc->vc_disp_ctrl = 0; in reset_terminal()
2225 vc->vc_toggle_meta = 0; in reset_terminal()
2227 vc->vc_decscnm = 0; in reset_terminal()
2228 vc->vc_decom = 0; in reset_terminal()
2229 vc->vc_decawm = 1; in reset_terminal()
2230 vc->vc_deccm = global_cursor_default; in reset_terminal()
2231 vc->vc_decim = 0; in reset_terminal()
2233 if (vc->vc_saved_screen != NULL) { in reset_terminal()
2234 kfree(vc->vc_saved_screen); in reset_terminal()
2235 vc->vc_saved_screen = NULL; in reset_terminal()
2236 vc_uniscr_free(vc->vc_saved_uni_lines); in reset_terminal()
2237 vc->vc_saved_uni_lines = NULL; in reset_terminal()
2238 vc->vc_saved_rows = 0; in reset_terminal()
2239 vc->vc_saved_cols = 0; in reset_terminal()
2242 vt_reset_keyboard(vc->vc_num); in reset_terminal()
2244 vc->vc_cursor_type = cur_default; in reset_terminal()
2245 vc->vc_complement_mask = vc->vc_s_complement_mask; in reset_terminal()
2247 default_attr(vc); in reset_terminal()
2248 update_attr(vc); in reset_terminal()
2250 bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); in reset_terminal()
2252 set_bit(i, vc->vc_tab_stop); in reset_terminal()
2254 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in reset_terminal()
2255 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in reset_terminal()
2256 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in reset_terminal()
2258 gotoxy(vc, 0, 0); in reset_terminal()
2259 save_cur(vc); in reset_terminal()
2261 csi_J(vc, CSI_J_VISIBLE); in reset_terminal()
2264 static void vc_setGx(struct vc_data *vc, unsigned int which, u8 c) in vc_setGx() argument
2266 unsigned char *charset = &vc->state.Gx_charset[which]; in vc_setGx()
2283 if (vc->state.charset == which) in vc_setGx()
2284 vc->vc_translate = set_translate(*charset, vc); in vc_setGx()
2316 * E.g. ESC sets the state of vc to ESesc.
2320 static bool handle_ascii(struct tty_struct *tty, struct vc_data *vc, u8 c) in handle_ascii() argument
2326 if (ansi_control_string(vc->vc_state)) in handle_ascii()
2327 vc->vc_state = ESnormal; in handle_ascii()
2328 else if (vc->vc_bell_duration) in handle_ascii()
2329 kd_mksound(vc->vc_bell_pitch, vc->vc_bell_duration); in handle_ascii()
2332 bs(vc); in handle_ascii()
2335 vc->vc_pos -= (vc->state.x << 1); in handle_ascii()
2337 vc->state.x = find_next_bit(vc->vc_tab_stop, in handle_ascii()
2338 min(vc->vc_cols - 1, VC_TABSTOPS_COUNT), in handle_ascii()
2339 vc->state.x + 1); in handle_ascii()
2340 if (vc->state.x >= VC_TABSTOPS_COUNT) in handle_ascii()
2341 vc->state.x = vc->vc_cols - 1; in handle_ascii()
2343 vc->vc_pos += (vc->state.x << 1); in handle_ascii()
2344 notify_write(vc, '\t'); in handle_ascii()
2349 lf(vc); in handle_ascii()
2350 if (!is_kbd(vc, lnm)) in handle_ascii()
2354 cr(vc); in handle_ascii()
2357 vc->state.charset = 1; in handle_ascii()
2358 vc->vc_translate = set_translate(vc->state.Gx_charset[1], vc); in handle_ascii()
2359 vc->vc_disp_ctrl = 1; in handle_ascii()
2362 vc->state.charset = 0; in handle_ascii()
2363 vc->vc_translate = set_translate(vc->state.Gx_charset[0], vc); in handle_ascii()
2364 vc->vc_disp_ctrl = 0; in handle_ascii()
2368 vc->vc_state = ESnormal; in handle_ascii()
2371 vc->vc_state = ESesc; in handle_ascii()
2374 del(vc); in handle_ascii()
2377 vc->vc_state = ESsquare; in handle_ascii()
2385 * Handle a character (@c) following an ESC (when @vc is in the ESesc state).
2389 static void handle_esc(struct tty_struct *tty, struct vc_data *vc, u8 c) in handle_esc() argument
2391 vc->vc_state = ESnormal; in handle_esc()
2394 vc->vc_state = ESsquare; in handle_esc()
2397 vc->vc_state = ESnonstd; in handle_esc()
2400 vc->vc_state = ESapc; in handle_esc()
2403 vc->vc_state = ESpm; in handle_esc()
2406 vc->vc_state = ESpercent; in handle_esc()
2409 cr(vc); in handle_esc()
2410 lf(vc); in handle_esc()
2413 ri(vc); in handle_esc()
2416 lf(vc); in handle_esc()
2419 if (vc->state.x < VC_TABSTOPS_COUNT) in handle_esc()
2420 set_bit(vc->state.x, vc->vc_tab_stop); in handle_esc()
2423 vc->vc_state = ESdcs; in handle_esc()
2429 save_cur(vc); in handle_esc()
2432 restore_cur(vc); in handle_esc()
2435 vc->vc_state = ESsetG0; in handle_esc()
2438 vc->vc_state = ESsetG1; in handle_esc()
2441 vc->vc_state = EShash; in handle_esc()
2444 reset_terminal(vc, 1); in handle_esc()
2447 clr_kbd(vc, kbdapplic); in handle_esc()
2450 set_kbd(vc, kbdapplic); in handle_esc()
2457 * are in @vc->vc_par and the char is in @c here.
2459 static void csi_DEC(struct tty_struct *tty, struct vc_data *vc, u8 c) in csi_DEC() argument
2463 csi_DEC_hl(vc, true); in csi_DEC()
2466 csi_DEC_hl(vc, false); in csi_DEC()
2469 if (vc->vc_par[0]) in csi_DEC()
2470 vc->vc_cursor_type = CUR_MAKE(vc->vc_par[0], in csi_DEC()
2471 vc->vc_par[1], in csi_DEC()
2472 vc->vc_par[2]); in csi_DEC()
2474 vc->vc_cursor_type = cur_default; in csi_DEC()
2478 if (vc->vc_par[0]) in csi_DEC()
2479 vc->vc_complement_mask = vc->vc_par[0] << 8 | vc->vc_par[1]; in csi_DEC()
2481 vc->vc_complement_mask = vc->vc_s_complement_mask; in csi_DEC()
2484 if (vc->vc_par[0] == 5) in csi_DEC()
2486 else if (vc->vc_par[0] == 6) in csi_DEC()
2487 cursor_report(vc, tty); in csi_DEC()
2494 * "ESC [ parameters char". Parameters are in @vc->vc_par and the char is in
2497 static void csi_ECMA(struct tty_struct *tty, struct vc_data *vc, u8 c) in csi_ECMA() argument
2502 if (vc->vc_par[0]) in csi_ECMA()
2503 vc->vc_par[0]--; in csi_ECMA()
2504 gotoxy(vc, vc->vc_par[0], vc->state.y); in csi_ECMA()
2507 if (!vc->vc_par[0]) in csi_ECMA()
2508 vc->vc_par[0]++; in csi_ECMA()
2509 gotoxy(vc, vc->state.x, vc->state.y - vc->vc_par[0]); in csi_ECMA()
2513 if (!vc->vc_par[0]) in csi_ECMA()
2514 vc->vc_par[0]++; in csi_ECMA()
2515 gotoxy(vc, vc->state.x, vc->state.y + vc->vc_par[0]); in csi_ECMA()
2519 if (!vc->vc_par[0]) in csi_ECMA()
2520 vc->vc_par[0]++; in csi_ECMA()
2521 gotoxy(vc, vc->state.x + vc->vc_par[0], vc->state.y); in csi_ECMA()
2524 if (!vc->vc_par[0]) in csi_ECMA()
2525 vc->vc_par[0]++; in csi_ECMA()
2526 gotoxy(vc, vc->state.x - vc->vc_par[0], vc->state.y); in csi_ECMA()
2529 if (!vc->vc_par[0]) in csi_ECMA()
2530 vc->vc_par[0]++; in csi_ECMA()
2531 gotoxy(vc, 0, vc->state.y + vc->vc_par[0]); in csi_ECMA()
2534 if (!vc->vc_par[0]) in csi_ECMA()
2535 vc->vc_par[0]++; in csi_ECMA()
2536 gotoxy(vc, 0, vc->state.y - vc->vc_par[0]); in csi_ECMA()
2539 if (vc->vc_par[0]) in csi_ECMA()
2540 vc->vc_par[0]--; in csi_ECMA()
2541 gotoxay(vc, vc->state.x ,vc->vc_par[0]); in csi_ECMA()
2545 if (vc->vc_par[0]) in csi_ECMA()
2546 vc->vc_par[0]--; in csi_ECMA()
2547 if (vc->vc_par[1]) in csi_ECMA()
2548 vc->vc_par[1]--; in csi_ECMA()
2549 gotoxay(vc, vc->vc_par[1], vc->vc_par[0]); in csi_ECMA()
2552 csi_J(vc, vc->vc_par[0]); in csi_ECMA()
2555 csi_K(vc); in csi_ECMA()
2558 csi_L(vc); in csi_ECMA()
2561 csi_M(vc); in csi_ECMA()
2564 csi_P(vc); in csi_ECMA()
2567 if (!vc->vc_par[0]) in csi_ECMA()
2571 if (!vc->vc_par[0] && vc->state.x < VC_TABSTOPS_COUNT) in csi_ECMA()
2572 set_bit(vc->state.x, vc->vc_tab_stop); in csi_ECMA()
2573 else if (vc->vc_par[0] == 3) in csi_ECMA()
2574 bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); in csi_ECMA()
2577 csi_hl(vc, true); in csi_ECMA()
2580 csi_hl(vc, false); in csi_ECMA()
2583 csi_m(vc); in csi_ECMA()
2586 if (vc->vc_par[0] == 5) in csi_ECMA()
2588 else if (vc->vc_par[0] == 6) in csi_ECMA()
2589 cursor_report(vc, tty); in csi_ECMA()
2593 if (vc->vc_par[0] < 4) in csi_ECMA()
2594 vt_set_led_state(vc->vc_num, in csi_ECMA()
2595 (vc->vc_par[0] < 3) ? vc->vc_par[0] : 4); in csi_ECMA()
2598 if (!vc->vc_par[0]) in csi_ECMA()
2599 vc->vc_par[0]++; in csi_ECMA()
2600 if (!vc->vc_par[1]) in csi_ECMA()
2601 vc->vc_par[1] = vc->vc_rows; in csi_ECMA()
2603 if (vc->vc_par[0] < vc->vc_par[1] && in csi_ECMA()
2604 vc->vc_par[1] <= vc->vc_rows) { in csi_ECMA()
2605 vc->vc_top = vc->vc_par[0] - 1; in csi_ECMA()
2606 vc->vc_bottom = vc->vc_par[1]; in csi_ECMA()
2607 gotoxay(vc, 0, 0); in csi_ECMA()
2611 save_cur(vc); in csi_ECMA()
2614 restore_cur(vc); in csi_ECMA()
2617 csi_X(vc); in csi_ECMA()
2620 csi_at(vc, vc->vc_par[0]); in csi_ECMA()
2623 csi_RSB(vc); in csi_ECMA()
2629 static void vc_reset_params(struct vc_data *vc) in vc_reset_params() argument
2631 memset(vc->vc_par, 0, sizeof(vc->vc_par)); in vc_reset_params()
2632 vc->vc_npar = 0; in vc_reset_params()
2636 static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) in do_con_trol() argument
2642 if (ansi_control_string(vc->vc_state) && c >= ASCII_IGNORE_FIRST && in do_con_trol()
2646 if (handle_ascii(tty, vc, c)) in do_con_trol()
2649 switch(vc->vc_state) { in do_con_trol()
2651 handle_esc(tty, vc, c); in do_con_trol()
2656 vc_reset_params(vc); in do_con_trol()
2657 vc->vc_state = ESpalette; in do_con_trol()
2660 reset_palette(vc); in do_con_trol()
2663 vc->vc_state = ESosc; in do_con_trol()
2666 vc->vc_state = ESnormal; in do_con_trol()
2670 vc->vc_par[vc->vc_npar++] = hex_to_bin(c); in do_con_trol()
2671 if (vc->vc_npar == 7) { in do_con_trol()
2672 int i = vc->vc_par[0] * 3, j = 1; in do_con_trol()
2673 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2674 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
2675 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2676 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
2677 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
2678 vc->vc_palette[i] += vc->vc_par[j]; in do_con_trol()
2679 set_palette(vc); in do_con_trol()
2680 vc->vc_state = ESnormal; in do_con_trol()
2683 vc->vc_state = ESnormal; in do_con_trol()
2686 vc_reset_params(vc); in do_con_trol()
2688 vc->vc_state = ESgetpars; in do_con_trol()
2691 vc->vc_state = ESfunckey; in do_con_trol()
2694 vc->vc_priv = EPdec; in do_con_trol()
2697 vc->vc_priv = EPgt; in do_con_trol()
2700 vc->vc_priv = EPeq; in do_con_trol()
2703 vc->vc_priv = EPlt; in do_con_trol()
2706 vc->vc_priv = EPecma; in do_con_trol()
2711 if (vc->vc_npar < NPAR - 1) { in do_con_trol()
2712 vc->vc_npar++; in do_con_trol()
2717 vc->vc_par[vc->vc_npar] *= 10; in do_con_trol()
2718 vc->vc_par[vc->vc_npar] += c - '0'; in do_con_trol()
2722 vc->vc_state = EScsiignore; in do_con_trol()
2728 vc->vc_state = ESnormal; in do_con_trol()
2730 switch (vc->vc_priv) { in do_con_trol()
2732 csi_DEC(tty, vc, c); in do_con_trol()
2735 csi_ECMA(tty, vc, c); in do_con_trol()
2743 vc->vc_state = ESnormal; in do_con_trol()
2746 vc->vc_state = ESnormal; in do_con_trol()
2749 vc->vc_utf = 0; in do_con_trol()
2753 vc->vc_utf = 1; in do_con_trol()
2758 vc->vc_state = ESnormal; in do_con_trol()
2761 vc->vc_state = ESnormal; in do_con_trol()
2764 vc->vc_video_erase_char = in do_con_trol()
2765 (vc->vc_video_erase_char & 0xff00) | 'E'; in do_con_trol()
2766 csi_J(vc, CSI_J_VISIBLE); in do_con_trol()
2767 vc->vc_video_erase_char = in do_con_trol()
2768 (vc->vc_video_erase_char & 0xff00) | ' '; in do_con_trol()
2769 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in do_con_trol()
2773 vc_setGx(vc, 0, c); in do_con_trol()
2774 vc->vc_state = ESnormal; in do_con_trol()
2777 vc_setGx(vc, 1, c); in do_con_trol()
2778 vc->vc_state = ESnormal; in do_con_trol()
2789 vc->vc_state = ESnormal; in do_con_trol()
2798 static void con_flush(struct vc_data *vc, struct vc_draw_region *draw) in con_flush() argument
2803 vc->vc_sw->con_putcs(vc, (u16 *)draw->from, in con_flush()
2804 (u16 *)draw->to - (u16 *)draw->from, vc->state.y, in con_flush()
2809 static inline int vc_translate_ascii(const struct vc_data *vc, int c) in vc_translate_ascii() argument
2812 if (vc->vc_toggle_meta) in vc_translate_ascii()
2815 return vc->vc_translate[c]; in vc_translate_ascii()
2836 * @vc: virtual console
2853 static int vc_translate_unicode(struct vc_data *vc, int c, bool *rescan) in vc_translate_unicode() argument
2860 if (!vc->vc_utf_count) in vc_translate_unicode()
2863 vc->vc_utf_char = (vc->vc_utf_char << 6) | (c & 0x3f); in vc_translate_unicode()
2864 vc->vc_npar++; in vc_translate_unicode()
2865 if (--vc->vc_utf_count) in vc_translate_unicode()
2869 c = vc->vc_utf_char; in vc_translate_unicode()
2871 if (c <= utf8_length_changes[vc->vc_npar - 1] || in vc_translate_unicode()
2872 c > utf8_length_changes[vc->vc_npar]) in vc_translate_unicode()
2879 if (vc->vc_utf_count) { in vc_translate_unicode()
2882 vc->vc_utf_count = 0; in vc_translate_unicode()
2891 vc->vc_npar = 0; in vc_translate_unicode()
2893 vc->vc_utf_count = 1; in vc_translate_unicode()
2894 vc->vc_utf_char = (c & 0x1f); in vc_translate_unicode()
2896 vc->vc_utf_count = 2; in vc_translate_unicode()
2897 vc->vc_utf_char = (c & 0x0f); in vc_translate_unicode()
2899 vc->vc_utf_count = 3; in vc_translate_unicode()
2900 vc->vc_utf_char = (c & 0x07); in vc_translate_unicode()
2912 static int vc_translate(struct vc_data *vc, int *c, bool *rescan) in vc_translate() argument
2915 if (vc->vc_state != ESnormal) in vc_translate()
2918 if (vc->vc_utf && !vc->vc_disp_ctrl) in vc_translate()
2919 return *c = vc_translate_unicode(vc, *c, rescan); in vc_translate()
2922 return vc_translate_ascii(vc, *c); in vc_translate()
2925 static inline unsigned char vc_invert_attr(const struct vc_data *vc) in vc_invert_attr() argument
2927 if (!vc->vc_can_do_color) in vc_invert_attr()
2928 return vc->vc_attr ^ 0x08; in vc_invert_attr()
2930 if (vc->vc_hi_font_mask == 0x100) in vc_invert_attr()
2931 return (vc->vc_attr & 0x11) | in vc_invert_attr()
2932 ((vc->vc_attr & 0xe0) >> 4) | in vc_invert_attr()
2933 ((vc->vc_attr & 0x0e) << 4); in vc_invert_attr()
2935 return (vc->vc_attr & 0x88) | in vc_invert_attr()
2936 ((vc->vc_attr & 0x70) >> 4) | in vc_invert_attr()
2937 ((vc->vc_attr & 0x07) << 4); in vc_invert_attr()
2940 static bool vc_is_control(struct vc_data *vc, int tc, int c) in vc_is_control() argument
2956 if (vc->vc_state != ESnormal) in vc_is_control()
2972 if (vc->vc_disp_ctrl) in vc_is_control()
2975 return vc->vc_utf || (CTRL_ACTION & BIT(c)); in vc_is_control()
2978 if (c == ASCII_DEL && !vc->vc_disp_ctrl) in vc_is_control()
2987 static void vc_con_rewind(struct vc_data *vc) in vc_con_rewind() argument
2989 if (vc->state.x && !vc->vc_need_wrap) { in vc_con_rewind()
2990 vc->vc_pos -= 2; in vc_con_rewind()
2991 vc->state.x--; in vc_con_rewind()
2993 vc->vc_need_wrap = 0; in vc_con_rewind()
3000 static int vc_process_ucs(struct vc_data *vc, int *c, int *tc) in vc_process_ucs() argument
3010 vc_uniscr_check(vc); in vc_process_ucs()
3019 if (ucs_is_double_width(vc_uniscr_getc(vc, -2))) { in vc_process_ucs()
3027 vc_con_rewind(vc); in vc_process_ucs()
3033 prev_c = vc_uniscr_getc(vc, -1); in vc_process_ucs()
3049 vc_con_rewind(vc); in vc_process_ucs()
3058 static int vc_get_glyph(struct vc_data *vc, int tc) in vc_get_glyph() argument
3060 int glyph = conv_uni_to_pc(vc, tc); in vc_get_glyph()
3061 u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; in vc_get_glyph()
3070 if ((!vc->vc_utf || vc->vc_disp_ctrl || tc < 128) && !(tc & ~charmask)) { in vc_get_glyph()
3086 vc_uniscr_check(vc); in vc_get_glyph()
3091 return vc_get_glyph(vc, tc); in vc_get_glyph()
3094 return conv_uni_to_pc(vc, UCS_REPLACEMENT); in vc_get_glyph()
3097 static int vc_con_write_normal(struct vc_data *vc, int tc, int c, in vc_con_write_normal() argument
3101 unsigned char vc_attr = vc->vc_attr; in vc_con_write_normal()
3102 u16 himask = vc->vc_hi_font_mask; in vc_con_write_normal()
3106 if (vc->vc_utf && !vc->vc_disp_ctrl) { in vc_con_write_normal()
3107 width = vc_process_ucs(vc, &c, &tc); in vc_con_write_normal()
3113 tc = vc_get_glyph(vc, tc); in vc_con_write_normal()
3118 tc = conv_uni_to_pc(vc, '?'); in vc_con_write_normal()
3122 vc_attr = vc_invert_attr(vc); in vc_con_write_normal()
3123 con_flush(vc, draw); in vc_con_write_normal()
3128 if (vc->vc_need_wrap || vc->vc_decim) in vc_con_write_normal()
3129 con_flush(vc, draw); in vc_con_write_normal()
3130 if (vc->vc_need_wrap) { in vc_con_write_normal()
3131 cr(vc); in vc_con_write_normal()
3132 lf(vc); in vc_con_write_normal()
3134 if (vc->vc_decim) in vc_con_write_normal()
3135 insert_char(vc, 1); in vc_con_write_normal()
3136 vc_uniscr_putc(vc, next_c); in vc_con_write_normal()
3143 scr_writew(tc, (u16 *)vc->vc_pos); in vc_con_write_normal()
3145 if (con_should_update(vc) && draw->x < 0) { in vc_con_write_normal()
3146 draw->x = vc->state.x; in vc_con_write_normal()
3147 draw->from = vc->vc_pos; in vc_con_write_normal()
3149 if (vc->state.x == vc->vc_cols - 1) { in vc_con_write_normal()
3150 vc->vc_need_wrap = vc->vc_decawm; in vc_con_write_normal()
3151 draw->to = vc->vc_pos + 2; in vc_con_write_normal()
3153 vc->state.x++; in vc_con_write_normal()
3154 draw->to = (vc->vc_pos += 2); in vc_con_write_normal()
3161 tc = conv_uni_to_pc(vc, ' '); in vc_con_write_normal()
3172 notify_write(vc, c); in vc_con_write_normal()
3175 con_flush(vc, draw); in vc_con_write_normal()
3188 struct vc_data *vc = tty->driver_data; in do_con_write() local
3196 currcons = vc->vc_num; in do_con_write()
3205 if (con_is_fg(vc)) in do_con_write()
3206 hide_cursor(vc); in do_con_write()
3208 param.vc = vc; in do_con_write()
3219 tc = vc_translate(vc, &c, &rescan); in do_con_write()
3228 if (vc_is_control(vc, tc, c)) { in do_con_write()
3229 con_flush(vc, &draw); in do_con_write()
3230 do_con_trol(tty, vc, orig); in do_con_write()
3234 if (vc_con_write_normal(vc, tc, c, &draw) < 0) in do_con_write()
3240 con_flush(vc, &draw); in do_con_write()
3241 notify_update(vc); in do_con_write()
3275 struct vc_data *vc = vc_cons[fg_console].d; in console_callback() local
3277 if (vc->vc_mode == KD_TEXT && vc->vc_sw->con_scrolldelta) in console_callback()
3278 vc->vc_sw->con_scrolldelta(vc, scrollback_delta); in console_callback()
3290 struct vc_data *vc = vc_cons[fg_console].d; in set_console() local
3293 (vc->vt_mode.mode == VT_AUTO && vc->vc_mode == KD_GRAPHICS)) { in set_console()
3355 struct vc_data *vc = vc_cons[fg_console].d; in vt_console_print() local
3370 vc = vc_cons[kmsg_console - 1].d; in vt_console_print()
3378 if (vc->vc_mode != KD_TEXT) in vt_console_print()
3382 if (con_is_fg(vc)) in vt_console_print()
3383 hide_cursor(vc); in vt_console_print()
3385 start = (ushort *)vc->vc_pos; in vt_console_print()
3386 start_x = vc->state.x; in vt_console_print()
3391 c == ASCII_BACKSPACE || vc->vc_need_wrap) { in vt_console_print()
3392 if (cnt && con_is_visible(vc)) in vt_console_print()
3393 vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x); in vt_console_print()
3396 bs(vc); in vt_console_print()
3397 start = (ushort *)vc->vc_pos; in vt_console_print()
3398 start_x = vc->state.x; in vt_console_print()
3402 lf(vc); in vt_console_print()
3403 cr(vc); in vt_console_print()
3404 start = (ushort *)vc->vc_pos; in vt_console_print()
3405 start_x = vc->state.x; in vt_console_print()
3409 vc_uniscr_putc(vc, c); in vt_console_print()
3410 scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos); in vt_console_print()
3411 notify_write(vc, c); in vt_console_print()
3413 if (vc->state.x == vc->vc_cols - 1) { in vt_console_print()
3414 vc->vc_need_wrap = 1; in vt_console_print()
3416 vc->vc_pos += 2; in vt_console_print()
3417 vc->state.x++; in vt_console_print()
3420 if (cnt && con_is_visible(vc)) in vt_console_print()
3421 vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x); in vt_console_print()
3422 set_cursor(vc); in vt_console_print()
3423 notify_update(vc); in vt_console_print()
3452 * Handling of Linux-specific VC ioctls
3595 struct vc_data *vc = tty->driver_data; in con_unthrottle() local
3597 wake_up_interruptible(&vc->paste_wait); in con_unthrottle()
3630 struct vc_data *vc = tty->driver_data; in con_flush_chars() local
3636 set_cursor(vc); in con_flush_chars()
3645 struct vc_data *vc; in con_install() local
3653 vc = vc_cons[currcons].d; in con_install()
3656 if (vc->port.tty) in con_install()
3659 ret = tty_port_install(&vc->port, driver, tty); in con_install()
3663 tty->driver_data = vc; in con_install()
3664 vc->port.tty = tty; in con_install()
3665 tty_port_get(&vc->port); in con_install()
3671 if (vc->vc_utf) in con_install()
3693 struct vc_data *vc = tty->driver_data; in con_shutdown() local
3694 BUG_ON(vc == NULL); in con_shutdown()
3697 vc->port.tty = NULL; in con_shutdown()
3702 struct vc_data *vc = tty->driver_data; in con_cleanup() local
3704 tty_port_put(&vc->port); in con_cleanup()
3723 static void vc_init(struct vc_data *vc, int do_clear) in vc_init() argument
3727 set_origin(vc); in vc_init()
3728 vc->vc_pos = vc->vc_origin; in vc_init()
3729 reset_vc(vc); in vc_init()
3731 vc->vc_palette[k++] = default_red[j] ; in vc_init()
3732 vc->vc_palette[k++] = default_grn[j] ; in vc_init()
3733 vc->vc_palette[k++] = default_blu[j] ; in vc_init()
3735 vc->vc_def_color = default_color; in vc_init()
3736 vc->vc_ulcolor = default_underline_color; in vc_init()
3737 vc->vc_itcolor = default_italic_color; in vc_init()
3738 vc->vc_halfcolor = 0x08; /* grey */ in vc_init()
3739 init_waitqueue_head(&vc->paste_wait); in vc_init()
3740 reset_terminal(vc, do_clear); in vc_init()
3752 struct vc_data *vc; in con_init() local
3788 vc_cons[currcons].d = vc = kzalloc_obj(struct vc_data, in con_init()
3791 tty_port_init(&vc->port); in con_init()
3792 visual_init(vc, currcons, true); in con_init()
3793 /* Assuming vc->vc_{cols,rows,screenbuf_size} are sane here. */ in con_init()
3794 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT); in con_init()
3795 vc_init(vc, currcons || !vc->vc_sw->con_save_screen); in con_init()
3798 master_display_fg = vc = vc_cons[currcons].d; in con_init()
3799 set_origin(vc); in con_init()
3800 save_screen(vc); in con_init()
3801 gotoxy(vc, vc->state.x, vc->state.y); in con_init()
3802 csi_J(vc, CSI_J_CURSOR_TO_END); in con_init()
3803 update_screen(vc); in con_init()
3805 vc->vc_can_do_color ? "colour" : "mono", in con_init()
3806 display_desc, vc->vc_cols, vc->vc_rows); in con_init()
3859 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0) in vty_init()
3942 struct vc_data *vc = vc_cons[i].d; in do_bind_con_driver() local
3949 if (!vc || !vc->vc_sw) in do_bind_con_driver()
3954 if (con_is_visible(vc)) { in do_bind_con_driver()
3956 save_screen(vc); in do_bind_con_driver()
3959 old_was_color = vc->vc_can_do_color; in do_bind_con_driver()
3960 vc->vc_sw->con_deinit(vc); in do_bind_con_driver()
3961 vc->vc_origin = (unsigned long)vc->vc_screenbuf; in do_bind_con_driver()
3962 visual_init(vc, i, false); in do_bind_con_driver()
3963 set_origin(vc); in do_bind_con_driver()
3964 update_attr(vc); in do_bind_con_driver()
3970 if (old_was_color != vc->vc_can_do_color) in do_bind_con_driver()
3971 clear_buffer_attributes(vc); in do_bind_con_driver()
3978 struct vc_data *vc = vc_cons[j].d; in do_bind_con_driver() local
3981 vc->vc_can_do_color ? "colour" : "mono", in do_bind_con_driver()
3982 desc, vc->vc_cols, vc->vc_rows); in do_bind_con_driver()
3985 vc = vc_cons[k].d; in do_bind_con_driver()
3986 update_screen(vc); in do_bind_con_driver()
4270 * @vc: virtual console
4274 bool con_is_visible(const struct vc_data *vc) in con_is_visible() argument
4278 return *vc->vc_display_fg == vc; in con_is_visible()
4284 * @vc: virtual console
4290 void con_debug_enter(struct vc_data *vc) in con_debug_enter() argument
4294 if (vc->vc_rows < 999) { in con_debug_enter()
4303 snprintf(lns, 4, "%i", vc->vc_rows); in con_debug_enter()
4307 if (vc->vc_cols < 999) { in con_debug_enter()
4316 snprintf(cols, 4, "%i", vc->vc_cols); in con_debug_enter()
4572 struct vc_data *vc = vc_cons[fg_console].d; in do_blank_screen() local
4582 vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0); in do_blank_screen()
4589 hide_cursor(vc); in do_blank_screen()
4590 save_screen(vc); in do_blank_screen()
4591 vc->vc_sw->con_blank(vc, VESA_VSYNC_SUSPEND, 1); in do_blank_screen()
4594 set_origin(vc); in do_blank_screen()
4601 if (vc->vc_mode != KD_TEXT) { in do_blank_screen()
4606 hide_cursor(vc); in do_blank_screen()
4610 save_screen(vc); in do_blank_screen()
4612 i = vc->vc_sw->con_blank(vc, vesa_off_interval ? VESA_VSYNC_SUSPEND : in do_blank_screen()
4616 set_origin(vc); in do_blank_screen()
4625 vt_event_post(VT_EVENT_BLANK, vc->vc_num, vc->vc_num); in do_blank_screen()
4634 struct vc_data *vc; in do_unblank_screen() local
4654 vc = vc_cons[fg_console].d; in do_unblank_screen()
4655 if (vc->vc_mode != KD_TEXT) in do_unblank_screen()
4664 if (vc->vc_sw->con_blank(vc, VESA_NO_BLANKING, leaving_gfx)) in do_unblank_screen()
4666 update_screen(vc); in do_unblank_screen()
4669 set_palette(vc); in do_unblank_screen()
4670 set_cursor(vc); in do_unblank_screen()
4671 vt_event_post(VT_EVENT_UNBLANK, vc->vc_num, vc->vc_num); in do_unblank_screen()
4672 notify_update(vc); in do_unblank_screen()
4730 static void set_palette(struct vc_data *vc) in set_palette() argument
4734 if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_set_palette) in set_palette()
4735 vc->vc_sw->con_set_palette(vc, color_table); in set_palette()
4789 void reset_palette(struct vc_data *vc) in reset_palette() argument
4793 vc->vc_palette[k++] = default_red[j]; in reset_palette()
4794 vc->vc_palette[k++] = default_grn[j]; in reset_palette()
4795 vc->vc_palette[k++] = default_blu[j]; in reset_palette()
4797 set_palette(vc); in reset_palette()
4818 static int con_font_get(struct vc_data *vc, struct console_font_op *op) in con_font_get() argument
4836 if (vc->vc_mode != KD_TEXT) in con_font_get()
4838 if (!vc->vc_sw->con_font_get) in con_font_get()
4841 int ret = vc->vc_sw->con_font_get(vc, &font, vpitch); in con_font_get()
4863 static int con_font_set(struct vc_data *vc, const struct console_font_op *op) in con_font_set() argument
4892 if (vc->vc_mode != KD_TEXT) in con_font_set()
4894 if (!vc->vc_sw->con_font_set) in con_font_set()
4897 if (vc_is_sel(vc)) in con_font_set()
4900 return vc->vc_sw->con_font_set(vc, &font, vpitch, op->flags); in con_font_set()
4903 static int con_font_default(struct vc_data *vc, struct console_font_op *op) in con_font_default() argument
4917 if (vc->vc_mode != KD_TEXT) in con_font_default()
4919 if (!vc->vc_sw->con_font_default) in con_font_default()
4922 if (vc_is_sel(vc)) in con_font_default()
4924 int ret = vc->vc_sw->con_font_default(vc, &font, s); in con_font_default()
4935 int con_font_op(struct vc_data *vc, struct console_font_op *op) in con_font_op() argument
4940 return con_font_set(vc, op); in con_font_op()
4943 return con_font_get(vc, op); in con_font_op()
4945 return con_font_default(vc, op); in con_font_op()
4958 u16 screen_glyph(const struct vc_data *vc, int offset) in screen_glyph() argument
4960 u16 w = scr_readw(screenpos(vc, offset, true)); in screen_glyph()
4963 if (w & vc->vc_hi_font_mask) in screen_glyph()
4969 u32 screen_glyph_unicode(const struct vc_data *vc, int n) in screen_glyph_unicode() argument
4971 u32 **uni_lines = vc->vc_uni_lines; in screen_glyph_unicode()
4974 return uni_lines[n / vc->vc_cols][n % vc->vc_cols]; in screen_glyph_unicode()
4976 return inverse_translate(vc, screen_glyph(vc, n * 2), true); in screen_glyph_unicode()
4981 unsigned short *screen_pos(const struct vc_data *vc, int w_offset, bool viewed) in screen_pos() argument
4983 return screenpos(vc, 2 * w_offset, viewed); in screen_pos()
4987 void getconsxy(const struct vc_data *vc, unsigned char xy[static 2]) in getconsxy() argument
4990 xy[0] = min(vc->state.x, 0xFFu); in getconsxy()
4991 xy[1] = min(vc->state.y, 0xFFu); in getconsxy()
4994 void putconsxy(struct vc_data *vc, unsigned char xy[static const 2]) in putconsxy() argument
4996 hide_cursor(vc); in putconsxy()
4997 gotoxy(vc, xy[0], xy[1]); in putconsxy()
4998 set_cursor(vc); in putconsxy()
5001 u16 vcs_scr_readw(const struct vc_data *vc, const u16 *org) in vcs_scr_readw() argument
5003 if ((unsigned long)org == vc->vc_pos && softcursor_original != -1) in vcs_scr_readw()
5008 void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org) in vcs_scr_writew() argument
5011 if ((unsigned long)org == vc->vc_pos) { in vcs_scr_writew()
5013 add_softcursor(vc); in vcs_scr_writew()
5017 void vcs_scr_updated(struct vc_data *vc) in vcs_scr_updated() argument
5019 notify_update(vc); in vcs_scr_updated()