Lines Matching refs:vc

141 struct vc vc_cons [MAX_NR_CONSOLES];
148 static void vc_init(struct vc_data *vc, unsigned int rows,
150 static void gotoxy(struct vc_data *vc, int new_x, int new_y);
151 static void save_cur(struct vc_data *vc);
152 static void reset_terminal(struct vc_data *vc, int do_clear);
155 static void set_cursor(struct vc_data *vc);
156 static void hide_cursor(struct vc_data *vc);
160 static void set_palette(struct vc_data *vc);
265 static void notify_write(struct vc_data *vc, unsigned int unicode) in notify_write() argument
267 struct vt_notifier_param param = { .vc = vc, .c = unicode }; in notify_write()
271 static void notify_update(struct vc_data *vc) in notify_update() argument
273 struct vt_notifier_param param = { .vc = vc }; in notify_update()
280 #define IS_FG(vc) ((vc)->vc_num == fg_console) argument
283 #define DO_UPDATE(vc) 0 argument
285 #define DO_UPDATE(vc) (CON_IS_VISIBLE(vc) && !console_blanked) argument
288 static inline unsigned short *screenpos(struct vc_data *vc, int offset, int viewed) in screenpos() argument
293 p = (unsigned short *)(vc->vc_origin + offset); in screenpos()
294 else if (!vc->vc_sw->con_screen_pos) in screenpos()
295 p = (unsigned short *)(vc->vc_visible_origin + offset); in screenpos()
297 p = vc->vc_sw->con_screen_pos(vc, offset); in screenpos()
316 static void scrup(struct vc_data *vc, unsigned int t, unsigned int b, int nr) in scrup() argument
322 if (b > vc->vc_rows || t >= b || nr < 1) in scrup()
324 if (CON_IS_VISIBLE(vc) && vc->vc_sw->con_scroll(vc, t, b, SM_UP, nr)) in scrup()
326 d = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t); in scrup()
327 s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * (t + nr)); in scrup()
328 scr_memmovew(d, s, (b - t - nr) * vc->vc_size_row); in scrup()
329 scr_memsetw(d + (b - t - nr) * vc->vc_cols, vc->vc_video_erase_char, in scrup()
330 vc->vc_size_row * nr); in scrup()
333 static void scrdown(struct vc_data *vc, unsigned int t, unsigned int b, int nr) in scrdown() argument
340 if (b > vc->vc_rows || t >= b || nr < 1) in scrdown()
342 if (CON_IS_VISIBLE(vc) && vc->vc_sw->con_scroll(vc, t, b, SM_DOWN, nr)) in scrdown()
344 s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t); in scrdown()
345 step = vc->vc_cols * nr; in scrdown()
346 scr_memmovew(s + step, s, (b - t - nr) * vc->vc_size_row); in scrdown()
347 scr_memsetw(s, vc->vc_video_erase_char, 2 * step); in scrdown()
350 static void do_update_region(struct vc_data *vc, unsigned long start, int count) in do_update_region() argument
357 if (!vc->vc_sw->con_getxy) { in do_update_region()
358 offset = (start - vc->vc_origin) / 2; in do_update_region()
359 xx = offset % vc->vc_cols; in do_update_region()
360 yy = offset / vc->vc_cols; in do_update_region()
363 start = vc->vc_sw->con_getxy(vc, start, &nxx, &nyy); in do_update_region()
370 while (xx < vc->vc_cols && count) { in do_update_region()
373 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); in do_update_region()
383 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); in do_update_region()
388 if (vc->vc_sw->con_getxy) { in do_update_region()
390 start = vc->vc_sw->con_getxy(vc, start, NULL, NULL); in do_update_region()
396 void update_region(struct vc_data *vc, unsigned long start, int count) in update_region() argument
400 if (DO_UPDATE(vc)) { in update_region()
401 hide_cursor(vc); in update_region()
402 do_update_region(vc, start, count); in update_region()
403 set_cursor(vc); in update_region()
409 static u8 build_attr(struct vc_data *vc, u8 _color, u8 _intensity, u8 _blink, in build_attr() argument
412 if (vc->vc_sw->con_build_attr) in build_attr()
413 return vc->vc_sw->con_build_attr(vc, _color, _intensity, in build_attr()
429 if (!vc->vc_can_do_color) in build_attr()
436 a = (a & 0xF0) | vc->vc_itcolor; in build_attr()
438 a = (a & 0xf0) | vc->vc_ulcolor; in build_attr()
440 a = (a & 0xf0) | vc->vc_ulcolor; in build_attr()
447 if (vc->vc_hi_font_mask == 0x100) in build_attr()
456 static void update_attr(struct vc_data *vc) in update_attr() argument
458 vc->vc_attr = build_attr(vc, vc->vc_color, vc->vc_intensity, in update_attr()
459 vc->vc_blink, vc->vc_underline, in update_attr()
460 vc->vc_reverse ^ vc->vc_decscnm, vc->vc_italic); in update_attr()
461vc->vc_video_erase_char = (build_attr(vc, vc->vc_color, 1, vc->vc_blink, 0, vc->vc_decscnm, 0) << … in update_attr()
465 void invert_screen(struct vc_data *vc, int offset, int count, int viewed) in invert_screen() argument
472 p = screenpos(vc, offset, viewed); in invert_screen()
473 if (vc->vc_sw->con_invert_region) in invert_screen()
474 vc->vc_sw->con_invert_region(vc, p, count); in invert_screen()
481 if (!vc->vc_can_do_color) { in invert_screen()
488 } else if (vc->vc_hi_font_mask == 0x100) { in invert_screen()
505 if (DO_UPDATE(vc)) in invert_screen()
506 do_update_region(vc, (unsigned long) p, count); in invert_screen()
507 notify_update(vc); in invert_screen()
511 void complement_pos(struct vc_data *vc, int offset) in complement_pos() argument
520 old_offset < vc->vc_screenbuf_size) { in complement_pos()
521 scr_writew(old, screenpos(vc, old_offset, 1)); in complement_pos()
522 if (DO_UPDATE(vc)) in complement_pos()
523 vc->vc_sw->con_putc(vc, old, oldy, oldx); in complement_pos()
524 notify_update(vc); in complement_pos()
530 offset < vc->vc_screenbuf_size) { in complement_pos()
533 p = screenpos(vc, offset, 1); in complement_pos()
535 new = old ^ vc->vc_complement_mask; in complement_pos()
537 if (DO_UPDATE(vc)) { in complement_pos()
538 oldx = (offset >> 1) % vc->vc_cols; in complement_pos()
539 oldy = (offset >> 1) / vc->vc_cols; in complement_pos()
540 vc->vc_sw->con_putc(vc, new, oldy, oldx); in complement_pos()
542 notify_update(vc); in complement_pos()
546 static void insert_char(struct vc_data *vc, unsigned int nr) in insert_char() argument
548 unsigned short *p = (unsigned short *) vc->vc_pos; in insert_char()
550 scr_memmovew(p + nr, p, (vc->vc_cols - vc->vc_x - nr) * 2); in insert_char()
551 scr_memsetw(p, vc->vc_video_erase_char, nr * 2); in insert_char()
552 vc->vc_need_wrap = 0; in insert_char()
553 if (DO_UPDATE(vc)) in insert_char()
554 do_update_region(vc, (unsigned long) p, in insert_char()
555 vc->vc_cols - vc->vc_x); in insert_char()
558 static void delete_char(struct vc_data *vc, unsigned int nr) in delete_char() argument
560 unsigned short *p = (unsigned short *) vc->vc_pos; in delete_char()
562 scr_memcpyw(p, p + nr, (vc->vc_cols - vc->vc_x - nr) * 2); in delete_char()
563 scr_memsetw(p + vc->vc_cols - vc->vc_x - nr, vc->vc_video_erase_char, in delete_char()
565 vc->vc_need_wrap = 0; in delete_char()
566 if (DO_UPDATE(vc)) in delete_char()
567 do_update_region(vc, (unsigned long) p, in delete_char()
568 vc->vc_cols - vc->vc_x); in delete_char()
573 static void add_softcursor(struct vc_data *vc) in add_softcursor() argument
575 int i = scr_readw((u16 *) vc->vc_pos); in add_softcursor()
576 u32 type = vc->vc_cursor_type; in add_softcursor()
585 scr_writew(i, (u16 *) vc->vc_pos); in add_softcursor()
586 if (DO_UPDATE(vc)) in add_softcursor()
587 vc->vc_sw->con_putc(vc, i, vc->vc_y, vc->vc_x); in add_softcursor()
590 static void hide_softcursor(struct vc_data *vc) in hide_softcursor() argument
593 scr_writew(softcursor_original, (u16 *)vc->vc_pos); in hide_softcursor()
594 if (DO_UPDATE(vc)) in hide_softcursor()
595 vc->vc_sw->con_putc(vc, softcursor_original, in hide_softcursor()
596 vc->vc_y, vc->vc_x); in hide_softcursor()
601 static void hide_cursor(struct vc_data *vc) in hide_cursor() argument
603 if (vc == sel_cons) in hide_cursor()
605 vc->vc_sw->con_cursor(vc, CM_ERASE); in hide_cursor()
606 hide_softcursor(vc); in hide_cursor()
609 static void set_cursor(struct vc_data *vc) in set_cursor() argument
611 if (!IS_FG(vc) || console_blanked || in set_cursor()
612 vc->vc_mode == KD_GRAPHICS) in set_cursor()
614 if (vc->vc_deccm) { in set_cursor()
615 if (vc == sel_cons) in set_cursor()
617 add_softcursor(vc); in set_cursor()
618 if ((vc->vc_cursor_type & 0x0f) != 1) in set_cursor()
619 vc->vc_sw->con_cursor(vc, CM_DRAW); in set_cursor()
621 hide_cursor(vc); in set_cursor()
624 static void set_origin(struct vc_data *vc) in set_origin() argument
628 if (!CON_IS_VISIBLE(vc) || in set_origin()
629 !vc->vc_sw->con_set_origin || in set_origin()
630 !vc->vc_sw->con_set_origin(vc)) in set_origin()
631 vc->vc_origin = (unsigned long)vc->vc_screenbuf; in set_origin()
632 vc->vc_visible_origin = vc->vc_origin; in set_origin()
633 vc->vc_scr_end = vc->vc_origin + vc->vc_screenbuf_size; in set_origin()
634 vc->vc_pos = vc->vc_origin + vc->vc_size_row * vc->vc_y + 2 * vc->vc_x; in set_origin()
637 static inline void save_screen(struct vc_data *vc) in save_screen() argument
641 if (vc->vc_sw->con_save_screen) in save_screen()
642 vc->vc_sw->con_save_screen(vc); in save_screen()
649 void clear_buffer_attributes(struct vc_data *vc) in clear_buffer_attributes() argument
651 unsigned short *p = (unsigned short *)vc->vc_origin; in clear_buffer_attributes()
652 int count = vc->vc_screenbuf_size / 2; in clear_buffer_attributes()
653 int mask = vc->vc_hi_font_mask | 0xff; in clear_buffer_attributes()
656 scr_writew((scr_readw(p)&mask) | (vc->vc_video_erase_char & ~mask), p); in clear_buffer_attributes()
660 void redraw_screen(struct vc_data *vc, int is_switch) in redraw_screen() argument
666 if (!vc) { in redraw_screen()
674 if (old_vc == vc) in redraw_screen()
676 if (!CON_IS_VISIBLE(vc)) in redraw_screen()
678 *vc->vc_display_fg = vc; in redraw_screen()
679 fg_console = vc->vc_num; in redraw_screen()
688 hide_cursor(vc); in redraw_screen()
694 int old_was_color = vc->vc_can_do_color; in redraw_screen()
696 set_origin(vc); in redraw_screen()
697 update = vc->vc_sw->con_switch(vc); in redraw_screen()
698 set_palette(vc); in redraw_screen()
705 if (old_was_color != vc->vc_can_do_color) { in redraw_screen()
706 update_attr(vc); in redraw_screen()
707 clear_buffer_attributes(vc); in redraw_screen()
711 if ((update && vc->vc_mode != KD_GRAPHICS) || in redraw_screen()
712 vt_force_oops_output(vc)) in redraw_screen()
713 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in redraw_screen()
715 set_cursor(vc); in redraw_screen()
719 notify_update(vc); in redraw_screen()
732 static void visual_init(struct vc_data *vc, int num, int init) in visual_init() argument
735 if (vc->vc_sw) in visual_init()
736 module_put(vc->vc_sw->owner); in visual_init()
737 vc->vc_sw = conswitchp; in visual_init()
740 vc->vc_sw = con_driver_map[num]; in visual_init()
742 __module_get(vc->vc_sw->owner); in visual_init()
743 vc->vc_num = num; in visual_init()
744 vc->vc_display_fg = &master_display_fg; in visual_init()
745 if (vc->vc_uni_pagedir_loc) in visual_init()
746 con_free_unimap(vc); in visual_init()
747 vc->vc_uni_pagedir_loc = &vc->vc_uni_pagedir; in visual_init()
748 vc->vc_uni_pagedir = NULL; in visual_init()
749 vc->vc_hi_font_mask = 0; in visual_init()
750 vc->vc_complement_mask = 0; in visual_init()
751 vc->vc_can_do_color = 0; in visual_init()
752 vc->vc_panic_force_write = false; in visual_init()
753 vc->vc_sw->con_init(vc, init); in visual_init()
754 if (!vc->vc_complement_mask) in visual_init()
755 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; in visual_init()
756 vc->vc_s_complement_mask = vc->vc_complement_mask; in visual_init()
757 vc->vc_size_row = vc->vc_cols << 1; in visual_init()
758 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; in visual_init()
768 struct vc_data *vc; in vc_allocate() local
781 param.vc = vc = kzalloc(sizeof(struct vc_data), GFP_KERNEL); in vc_allocate()
782 if (!vc) in vc_allocate()
784 vc_cons[currcons].d = vc; in vc_allocate()
785 tty_port_init(&vc->port); in vc_allocate()
787 visual_init(vc, currcons, 1); in vc_allocate()
788 if (!*vc->vc_uni_pagedir_loc) in vc_allocate()
789 con_set_default_unimap(vc); in vc_allocate()
790 vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size, GFP_KERNEL); in vc_allocate()
791 if (!vc->vc_screenbuf) { in vc_allocate()
792 kfree(vc); in vc_allocate()
802 vc_init(vc, vc->vc_rows, vc->vc_cols, 1); in vc_allocate()
809 static inline int resize_screen(struct vc_data *vc, int width, int height, in resize_screen() argument
815 if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_resize) in resize_screen()
816 err = vc->vc_sw->con_resize(vc, width, height, user); in resize_screen()
845 static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, in vc_do_resize() argument
857 if (!vc) in vc_do_resize()
860 user = vc->vc_resize_user; in vc_do_resize()
861 vc->vc_resize_user = 0; in vc_do_resize()
866 new_cols = (cols ? cols : vc->vc_cols); in vc_do_resize()
867 new_rows = (lines ? lines : vc->vc_rows); in vc_do_resize()
871 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) in vc_do_resize()
878 old_rows = vc->vc_rows; in vc_do_resize()
879 old_row_size = vc->vc_size_row; in vc_do_resize()
881 err = resize_screen(vc, new_cols, new_rows, user); in vc_do_resize()
887 vc->vc_rows = new_rows; in vc_do_resize()
888 vc->vc_cols = new_cols; in vc_do_resize()
889 vc->vc_size_row = new_row_size; in vc_do_resize()
890 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
894 old_origin = vc->vc_origin; in vc_do_resize()
898 if (vc->vc_y > new_rows) { in vc_do_resize()
899 if (old_rows - vc->vc_y < new_rows) { in vc_do_resize()
910 old_origin += (vc->vc_y - new_rows/2) * old_row_size; in vc_do_resize()
916 update_attr(vc); in vc_do_resize()
923 vc->vc_video_erase_char, rrem); in vc_do_resize()
928 scr_memsetw((void *)new_origin, vc->vc_video_erase_char, in vc_do_resize()
930 kfree(vc->vc_screenbuf); in vc_do_resize()
931 vc->vc_screenbuf = newscreen; in vc_do_resize()
932 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
933 set_origin(vc); in vc_do_resize()
936 vc->vc_top = 0; in vc_do_resize()
937 vc->vc_bottom = vc->vc_rows; in vc_do_resize()
938 gotoxy(vc, vc->vc_x, vc->vc_y); in vc_do_resize()
939 save_cur(vc); in vc_do_resize()
946 ws.ws_row = vc->vc_rows; in vc_do_resize()
947 ws.ws_col = vc->vc_cols; in vc_do_resize()
948 ws.ws_ypixel = vc->vc_scan_lines; in vc_do_resize()
952 if (CON_IS_VISIBLE(vc)) in vc_do_resize()
953 update_screen(vc); in vc_do_resize()
954 vt_event_post(VT_EVENT_RESIZE, vc->vc_num, vc->vc_num); in vc_do_resize()
970 int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows) in vc_resize() argument
972 return vc_do_resize(vc->port.tty, vc, cols, rows); in vc_resize()
989 struct vc_data *vc = tty->driver_data; in vt_resize() local
993 ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row); in vt_resize()
1000 struct vc_data *vc = NULL; in vc_deallocate() local
1007 param.vc = vc = vc_cons[currcons].d; in vc_deallocate()
1010 vc->vc_sw->con_deinit(vc); in vc_deallocate()
1011 put_pid(vc->vt_pid); in vc_deallocate()
1012 module_put(vc->vc_sw->owner); in vc_deallocate()
1013 kfree(vc->vc_screenbuf); in vc_deallocate()
1016 return vc; in vc_deallocate()
1023 #define set_kbd(vc, x) vt_set_kbd_mode_bit((vc)->vc_num, (x)) argument
1024 #define clr_kbd(vc, x) vt_clr_kbd_mode_bit((vc)->vc_num, (x)) argument
1025 #define is_kbd(vc, x) vt_get_kbd_mode_bit((vc)->vc_num, (x)) argument
1058 static void gotoxy(struct vc_data *vc, int new_x, int new_y) in gotoxy() argument
1063 vc->vc_x = 0; in gotoxy()
1065 if (new_x >= vc->vc_cols) in gotoxy()
1066 vc->vc_x = vc->vc_cols - 1; in gotoxy()
1068 vc->vc_x = new_x; in gotoxy()
1071 if (vc->vc_decom) { in gotoxy()
1072 min_y = vc->vc_top; in gotoxy()
1073 max_y = vc->vc_bottom; in gotoxy()
1076 max_y = vc->vc_rows; in gotoxy()
1079 vc->vc_y = min_y; in gotoxy()
1081 vc->vc_y = max_y - 1; in gotoxy()
1083 vc->vc_y = new_y; in gotoxy()
1084 vc->vc_pos = vc->vc_origin + vc->vc_y * vc->vc_size_row + (vc->vc_x<<1); in gotoxy()
1085 vc->vc_need_wrap = 0; in gotoxy()
1089 static void gotoxay(struct vc_data *vc, int new_x, int new_y) in gotoxay() argument
1091 gotoxy(vc, new_x, vc->vc_decom ? (vc->vc_top + new_y) : new_y); in gotoxay()
1094 void scrollback(struct vc_data *vc, int lines) in scrollback() argument
1097 lines = vc->vc_rows / 2; in scrollback()
1101 void scrollfront(struct vc_data *vc, int lines) in scrollfront() argument
1104 lines = vc->vc_rows / 2; in scrollfront()
1108 static void lf(struct vc_data *vc) in lf() argument
1113 if (vc->vc_y + 1 == vc->vc_bottom) in lf()
1114 scrup(vc, vc->vc_top, vc->vc_bottom, 1); in lf()
1115 else if (vc->vc_y < vc->vc_rows - 1) { in lf()
1116 vc->vc_y++; in lf()
1117 vc->vc_pos += vc->vc_size_row; in lf()
1119 vc->vc_need_wrap = 0; in lf()
1120 notify_write(vc, '\n'); in lf()
1123 static void ri(struct vc_data *vc) in ri() argument
1128 if (vc->vc_y == vc->vc_top) in ri()
1129 scrdown(vc, vc->vc_top, vc->vc_bottom, 1); in ri()
1130 else if (vc->vc_y > 0) { in ri()
1131 vc->vc_y--; in ri()
1132 vc->vc_pos -= vc->vc_size_row; in ri()
1134 vc->vc_need_wrap = 0; in ri()
1137 static inline void cr(struct vc_data *vc) in cr() argument
1139 vc->vc_pos -= vc->vc_x << 1; in cr()
1140 vc->vc_need_wrap = vc->vc_x = 0; in cr()
1141 notify_write(vc, '\r'); in cr()
1144 static inline void bs(struct vc_data *vc) in bs() argument
1146 if (vc->vc_x) { in bs()
1147 vc->vc_pos -= 2; in bs()
1148 vc->vc_x--; in bs()
1149 vc->vc_need_wrap = 0; in bs()
1150 notify_write(vc, '\b'); in bs()
1154 static inline void del(struct vc_data *vc) in del() argument
1159 static void csi_J(struct vc_data *vc, int vpar) in csi_J() argument
1166 count = (vc->vc_scr_end - vc->vc_pos) >> 1; in csi_J()
1167 start = (unsigned short *)vc->vc_pos; in csi_J()
1170 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1; in csi_J()
1171 start = (unsigned short *)vc->vc_origin; in csi_J()
1174 scr_memsetw(vc->vc_screenbuf, vc->vc_video_erase_char, in csi_J()
1175 vc->vc_screenbuf_size >> 1); in csi_J()
1176 set_origin(vc); in csi_J()
1177 if (CON_IS_VISIBLE(vc)) in csi_J()
1178 update_screen(vc); in csi_J()
1181 count = vc->vc_cols * vc->vc_rows; in csi_J()
1182 start = (unsigned short *)vc->vc_origin; in csi_J()
1187 scr_memsetw(start, vc->vc_video_erase_char, 2 * count); in csi_J()
1188 if (DO_UPDATE(vc)) in csi_J()
1189 do_update_region(vc, (unsigned long) start, count); in csi_J()
1190 vc->vc_need_wrap = 0; in csi_J()
1193 static void csi_K(struct vc_data *vc, int vpar) in csi_K() argument
1200 count = vc->vc_cols - vc->vc_x; in csi_K()
1201 start = (unsigned short *)vc->vc_pos; in csi_K()
1204 start = (unsigned short *)(vc->vc_pos - (vc->vc_x << 1)); in csi_K()
1205 count = vc->vc_x + 1; in csi_K()
1208 start = (unsigned short *)(vc->vc_pos - (vc->vc_x << 1)); in csi_K()
1209 count = vc->vc_cols; in csi_K()
1214 scr_memsetw(start, vc->vc_video_erase_char, 2 * count); in csi_K()
1215 vc->vc_need_wrap = 0; in csi_K()
1216 if (DO_UPDATE(vc)) in csi_K()
1217 do_update_region(vc, (unsigned long) start, count); in csi_K()
1220 static void csi_X(struct vc_data *vc, int vpar) /* erase the following vpar positions */ in csi_X() argument
1226 count = (vpar > vc->vc_cols - vc->vc_x) ? (vc->vc_cols - vc->vc_x) : vpar; in csi_X()
1228 scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count); in csi_X()
1229 if (DO_UPDATE(vc)) in csi_X()
1230 vc->vc_sw->con_clear(vc, vc->vc_y, vc->vc_x, 1, count); in csi_X()
1231 vc->vc_need_wrap = 0; in csi_X()
1234 static void default_attr(struct vc_data *vc) in default_attr() argument
1236 vc->vc_intensity = 1; in default_attr()
1237 vc->vc_italic = 0; in default_attr()
1238 vc->vc_underline = 0; in default_attr()
1239 vc->vc_reverse = 0; in default_attr()
1240 vc->vc_blink = 0; in default_attr()
1241 vc->vc_color = vc->vc_def_color; in default_attr()
1266 static void rgb_foreground(struct vc_data *vc, struct rgb c) in rgb_foreground() argument
1277 hue = 0, vc->vc_intensity = 2; in rgb_foreground()
1279 vc->vc_intensity = (max > 0xaa) + 1; in rgb_foreground()
1280 vc->vc_color = (vc->vc_color & 0xf0) | hue; in rgb_foreground()
1283 static void rgb_background(struct vc_data *vc, struct rgb c) in rgb_background() argument
1286 vc->vc_color = (vc->vc_color & 0x0f) in rgb_background()
1291 static void csi_m(struct vc_data *vc) in csi_m() argument
1295 for (i = 0; i <= vc->vc_npar; i++) in csi_m()
1296 switch (vc->vc_par[i]) { in csi_m()
1298 default_attr(vc); in csi_m()
1301 vc->vc_intensity = 2; in csi_m()
1304 vc->vc_intensity = 0; in csi_m()
1307 vc->vc_italic = 1; in csi_m()
1310 vc->vc_underline = 1; in csi_m()
1313 vc->vc_blink = 1; in csi_m()
1316 vc->vc_reverse = 1; in csi_m()
1323 vc->vc_translate = set_translate(vc->vc_charset == 0 in csi_m()
1324 ? vc->vc_G0_charset in csi_m()
1325 : vc->vc_G1_charset, vc); in csi_m()
1326 vc->vc_disp_ctrl = 0; in csi_m()
1327 vc->vc_toggle_meta = 0; in csi_m()
1333 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1334 vc->vc_disp_ctrl = 1; in csi_m()
1335 vc->vc_toggle_meta = 0; in csi_m()
1341 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1342 vc->vc_disp_ctrl = 1; in csi_m()
1343 vc->vc_toggle_meta = 1; in csi_m()
1347 vc->vc_intensity = 1; in csi_m()
1350 vc->vc_italic = 0; in csi_m()
1353 vc->vc_underline = 0; in csi_m()
1356 vc->vc_blink = 0; in csi_m()
1359 vc->vc_reverse = 0; in csi_m()
1371 if (i > vc->vc_npar) in csi_m()
1373 if (vc->vc_par[i] == 5 && /* 256 colours */ in csi_m()
1374 i < vc->vc_npar) { /* ubiquitous */ in csi_m()
1376 rgb_foreground(vc, in csi_m()
1377 rgb_from_256(vc->vc_par[i])); in csi_m()
1378 } else if (vc->vc_par[i] == 2 && /* 24 bit */ in csi_m()
1379 i <= vc->vc_npar + 3) {/* extremely rare */ in csi_m()
1381 .r = vc->vc_par[i + 1], in csi_m()
1382 .g = vc->vc_par[i + 2], in csi_m()
1383 .b = vc->vc_par[i + 3], in csi_m()
1385 rgb_foreground(vc, c); in csi_m()
1394 if (i > vc->vc_npar) in csi_m()
1396 if (vc->vc_par[i] == 5 && /* 256 colours */ in csi_m()
1397 i < vc->vc_npar) { in csi_m()
1399 rgb_background(vc, in csi_m()
1400 rgb_from_256(vc->vc_par[i])); in csi_m()
1401 } else if (vc->vc_par[i] == 2 && /* 24 bit */ in csi_m()
1402 i <= vc->vc_npar + 3) { in csi_m()
1404 .r = vc->vc_par[i + 1], in csi_m()
1405 .g = vc->vc_par[i + 2], in csi_m()
1406 .b = vc->vc_par[i + 3], in csi_m()
1408 rgb_background(vc, c); in csi_m()
1413 vc->vc_color = (vc->vc_def_color & 0x0f) | (vc->vc_color & 0xf0); in csi_m()
1416 vc->vc_color = (vc->vc_def_color & 0xf0) | (vc->vc_color & 0x0f); in csi_m()
1419 if (vc->vc_par[i] >= 30 && vc->vc_par[i] <= 37) in csi_m()
1420 vc->vc_color = color_table[vc->vc_par[i] - 30] in csi_m()
1421 | (vc->vc_color & 0xf0); in csi_m()
1422 else if (vc->vc_par[i] >= 40 && vc->vc_par[i] <= 47) in csi_m()
1423 vc->vc_color = (color_table[vc->vc_par[i] - 40] << 4) in csi_m()
1424 | (vc->vc_color & 0x0f); in csi_m()
1427 update_attr(vc); in csi_m()
1439 static void cursor_report(struct vc_data *vc, struct tty_struct *tty) in cursor_report() argument
1443 sprintf(buf, "\033[%d;%dR", vc->vc_y + (vc->vc_decom ? vc->vc_top + 1 : 1), vc->vc_x + 1); in cursor_report()
1473 static void set_mode(struct vc_data *vc, int on_off) in set_mode() argument
1477 for (i = 0; i <= vc->vc_npar; i++) in set_mode()
1478 if (vc->vc_ques) { in set_mode()
1479 switch(vc->vc_par[i]) { /* DEC private modes set/reset */ in set_mode()
1482 set_kbd(vc, decckm); in set_mode()
1484 clr_kbd(vc, decckm); in set_mode()
1487 vc->vc_deccolm = on_off; in set_mode()
1489 vc_resize(deccolm ? 132 : 80, vc->vc_rows); in set_mode()
1495 if (vc->vc_decscnm != on_off) { in set_mode()
1496 vc->vc_decscnm = on_off; in set_mode()
1497 invert_screen(vc, 0, vc->vc_screenbuf_size, 0); in set_mode()
1498 update_attr(vc); in set_mode()
1502 vc->vc_decom = on_off; in set_mode()
1503 gotoxay(vc, 0, 0); in set_mode()
1506 vc->vc_decawm = on_off; in set_mode()
1510 set_kbd(vc, decarm); in set_mode()
1512 clr_kbd(vc, decarm); in set_mode()
1515 vc->vc_report_mouse = on_off ? 1 : 0; in set_mode()
1518 vc->vc_deccm = on_off; in set_mode()
1521 vc->vc_report_mouse = on_off ? 2 : 0; in set_mode()
1525 switch(vc->vc_par[i]) { /* ANSI modes set/reset */ in set_mode()
1527 vc->vc_disp_ctrl = on_off; in set_mode()
1530 vc->vc_decim = on_off; in set_mode()
1534 set_kbd(vc, lnm); in set_mode()
1536 clr_kbd(vc, lnm); in set_mode()
1543 static void setterm_command(struct vc_data *vc) in setterm_command() argument
1545 switch(vc->vc_par[0]) { in setterm_command()
1547 if (vc->vc_can_do_color && in setterm_command()
1548 vc->vc_par[1] < 16) { in setterm_command()
1549 vc->vc_ulcolor = color_table[vc->vc_par[1]]; in setterm_command()
1550 if (vc->vc_underline) in setterm_command()
1551 update_attr(vc); in setterm_command()
1555 if (vc->vc_can_do_color && in setterm_command()
1556 vc->vc_par[1] < 16) { in setterm_command()
1557 vc->vc_halfcolor = color_table[vc->vc_par[1]]; in setterm_command()
1558 if (vc->vc_intensity == 0) in setterm_command()
1559 update_attr(vc); in setterm_command()
1563 vc->vc_def_color = vc->vc_attr; in setterm_command()
1564 if (vc->vc_hi_font_mask == 0x100) in setterm_command()
1565 vc->vc_def_color >>= 1; in setterm_command()
1566 default_attr(vc); in setterm_command()
1567 update_attr(vc); in setterm_command()
1570 blankinterval = ((vc->vc_par[1] < 60) ? vc->vc_par[1] : 60) * 60; in setterm_command()
1574 if (vc->vc_npar >= 1) in setterm_command()
1575 vc->vc_bell_pitch = vc->vc_par[1]; in setterm_command()
1577 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in setterm_command()
1580 if (vc->vc_npar >= 1) in setterm_command()
1581 vc->vc_bell_duration = (vc->vc_par[1] < 2000) ? in setterm_command()
1582 msecs_to_jiffies(vc->vc_par[1]) : 0; in setterm_command()
1584 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in setterm_command()
1587 if (vc->vc_par[1] >= 1 && vc_cons_allocated(vc->vc_par[1] - 1)) in setterm_command()
1588 set_console(vc->vc_par[1] - 1); in setterm_command()
1594 vesa_off_interval = ((vc->vc_par[1] < 60) ? vc->vc_par[1] : 60) * 60 * HZ; in setterm_command()
1600 if (vc->vc_npar >= 1 && vc->vc_par[1] >= 50 && in setterm_command()
1601 vc->vc_par[1] <= USHRT_MAX) in setterm_command()
1602 vc->vc_cur_blink_ms = vc->vc_par[1]; in setterm_command()
1604 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in setterm_command()
1610 static void csi_at(struct vc_data *vc, unsigned int nr) in csi_at() argument
1612 if (nr > vc->vc_cols - vc->vc_x) in csi_at()
1613 nr = vc->vc_cols - vc->vc_x; in csi_at()
1616 insert_char(vc, nr); in csi_at()
1620 static void csi_L(struct vc_data *vc, unsigned int nr) in csi_L() argument
1622 if (nr > vc->vc_rows - vc->vc_y) in csi_L()
1623 nr = vc->vc_rows - vc->vc_y; in csi_L()
1626 scrdown(vc, vc->vc_y, vc->vc_bottom, nr); in csi_L()
1627 vc->vc_need_wrap = 0; in csi_L()
1631 static void csi_P(struct vc_data *vc, unsigned int nr) in csi_P() argument
1633 if (nr > vc->vc_cols - vc->vc_x) in csi_P()
1634 nr = vc->vc_cols - vc->vc_x; in csi_P()
1637 delete_char(vc, nr); in csi_P()
1641 static void csi_M(struct vc_data *vc, unsigned int nr) in csi_M() argument
1643 if (nr > vc->vc_rows - vc->vc_y) in csi_M()
1644 nr = vc->vc_rows - vc->vc_y; in csi_M()
1647 scrup(vc, vc->vc_y, vc->vc_bottom, nr); in csi_M()
1648 vc->vc_need_wrap = 0; in csi_M()
1652 static void save_cur(struct vc_data *vc) in save_cur() argument
1654 vc->vc_saved_x = vc->vc_x; in save_cur()
1655 vc->vc_saved_y = vc->vc_y; in save_cur()
1656 vc->vc_s_intensity = vc->vc_intensity; in save_cur()
1657 vc->vc_s_italic = vc->vc_italic; in save_cur()
1658 vc->vc_s_underline = vc->vc_underline; in save_cur()
1659 vc->vc_s_blink = vc->vc_blink; in save_cur()
1660 vc->vc_s_reverse = vc->vc_reverse; in save_cur()
1661 vc->vc_s_charset = vc->vc_charset; in save_cur()
1662 vc->vc_s_color = vc->vc_color; in save_cur()
1663 vc->vc_saved_G0 = vc->vc_G0_charset; in save_cur()
1664 vc->vc_saved_G1 = vc->vc_G1_charset; in save_cur()
1668 static void restore_cur(struct vc_data *vc) in restore_cur() argument
1670 gotoxy(vc, vc->vc_saved_x, vc->vc_saved_y); in restore_cur()
1671 vc->vc_intensity = vc->vc_s_intensity; in restore_cur()
1672 vc->vc_italic = vc->vc_s_italic; in restore_cur()
1673 vc->vc_underline = vc->vc_s_underline; in restore_cur()
1674 vc->vc_blink = vc->vc_s_blink; in restore_cur()
1675 vc->vc_reverse = vc->vc_s_reverse; in restore_cur()
1676 vc->vc_charset = vc->vc_s_charset; in restore_cur()
1677 vc->vc_color = vc->vc_s_color; in restore_cur()
1678 vc->vc_G0_charset = vc->vc_saved_G0; in restore_cur()
1679 vc->vc_G1_charset = vc->vc_saved_G1; in restore_cur()
1680 vc->vc_translate = set_translate(vc->vc_charset ? vc->vc_G1_charset : vc->vc_G0_charset, vc); in restore_cur()
1681 update_attr(vc); in restore_cur()
1682 vc->vc_need_wrap = 0; in restore_cur()
1690 static void reset_terminal(struct vc_data *vc, int do_clear) in reset_terminal() argument
1692 vc->vc_top = 0; in reset_terminal()
1693 vc->vc_bottom = vc->vc_rows; in reset_terminal()
1694 vc->vc_state = ESnormal; in reset_terminal()
1695 vc->vc_ques = 0; in reset_terminal()
1696 vc->vc_translate = set_translate(LAT1_MAP, vc); in reset_terminal()
1697 vc->vc_G0_charset = LAT1_MAP; in reset_terminal()
1698 vc->vc_G1_charset = GRAF_MAP; in reset_terminal()
1699 vc->vc_charset = 0; in reset_terminal()
1700 vc->vc_need_wrap = 0; in reset_terminal()
1701 vc->vc_report_mouse = 0; in reset_terminal()
1702 vc->vc_utf = default_utf8; in reset_terminal()
1703 vc->vc_utf_count = 0; in reset_terminal()
1705 vc->vc_disp_ctrl = 0; in reset_terminal()
1706 vc->vc_toggle_meta = 0; in reset_terminal()
1708 vc->vc_decscnm = 0; in reset_terminal()
1709 vc->vc_decom = 0; in reset_terminal()
1710 vc->vc_decawm = 1; in reset_terminal()
1711 vc->vc_deccm = global_cursor_default; in reset_terminal()
1712 vc->vc_decim = 0; in reset_terminal()
1714 vt_reset_keyboard(vc->vc_num); in reset_terminal()
1716 vc->vc_cursor_type = cur_default; in reset_terminal()
1717 vc->vc_complement_mask = vc->vc_s_complement_mask; in reset_terminal()
1719 default_attr(vc); in reset_terminal()
1720 update_attr(vc); in reset_terminal()
1722 vc->vc_tab_stop[0] = 0x01010100; in reset_terminal()
1723 vc->vc_tab_stop[1] = in reset_terminal()
1724 vc->vc_tab_stop[2] = in reset_terminal()
1725 vc->vc_tab_stop[3] = in reset_terminal()
1726 vc->vc_tab_stop[4] = in reset_terminal()
1727 vc->vc_tab_stop[5] = in reset_terminal()
1728 vc->vc_tab_stop[6] = in reset_terminal()
1729 vc->vc_tab_stop[7] = 0x01010101; in reset_terminal()
1731 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in reset_terminal()
1732 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in reset_terminal()
1733 vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS; in reset_terminal()
1735 gotoxy(vc, 0, 0); in reset_terminal()
1736 save_cur(vc); in reset_terminal()
1738 csi_J(vc, 2); in reset_terminal()
1742 static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) in do_con_trol() argument
1748 if (vc->vc_state == ESosc && c>=8 && c<=13) /* ... except for OSC */ in do_con_trol()
1754 if (vc->vc_state == ESosc) in do_con_trol()
1755 vc->vc_state = ESnormal; in do_con_trol()
1756 else if (vc->vc_bell_duration) in do_con_trol()
1757 kd_mksound(vc->vc_bell_pitch, vc->vc_bell_duration); in do_con_trol()
1760 bs(vc); in do_con_trol()
1763 vc->vc_pos -= (vc->vc_x << 1); in do_con_trol()
1764 while (vc->vc_x < vc->vc_cols - 1) { in do_con_trol()
1765 vc->vc_x++; in do_con_trol()
1766 if (vc->vc_tab_stop[vc->vc_x >> 5] & (1 << (vc->vc_x & 31))) in do_con_trol()
1769 vc->vc_pos += (vc->vc_x << 1); in do_con_trol()
1770 notify_write(vc, '\t'); in do_con_trol()
1773 lf(vc); in do_con_trol()
1774 if (!is_kbd(vc, lnm)) in do_con_trol()
1777 cr(vc); in do_con_trol()
1780 vc->vc_charset = 1; in do_con_trol()
1781 vc->vc_translate = set_translate(vc->vc_G1_charset, vc); in do_con_trol()
1782 vc->vc_disp_ctrl = 1; in do_con_trol()
1785 vc->vc_charset = 0; in do_con_trol()
1786 vc->vc_translate = set_translate(vc->vc_G0_charset, vc); in do_con_trol()
1787 vc->vc_disp_ctrl = 0; in do_con_trol()
1790 vc->vc_state = ESnormal; in do_con_trol()
1793 vc->vc_state = ESesc; in do_con_trol()
1796 del(vc); in do_con_trol()
1799 vc->vc_state = ESsquare; in do_con_trol()
1802 switch(vc->vc_state) { in do_con_trol()
1804 vc->vc_state = ESnormal; in do_con_trol()
1807 vc->vc_state = ESsquare; in do_con_trol()
1810 vc->vc_state = ESnonstd; in do_con_trol()
1813 vc->vc_state = ESpercent; in do_con_trol()
1816 cr(vc); in do_con_trol()
1817 lf(vc); in do_con_trol()
1820 ri(vc); in do_con_trol()
1823 lf(vc); in do_con_trol()
1826 vc->vc_tab_stop[vc->vc_x >> 5] |= (1 << (vc->vc_x & 31)); in do_con_trol()
1832 save_cur(vc); in do_con_trol()
1835 restore_cur(vc); in do_con_trol()
1838 vc->vc_state = ESsetG0; in do_con_trol()
1841 vc->vc_state = ESsetG1; in do_con_trol()
1844 vc->vc_state = EShash; in do_con_trol()
1847 reset_terminal(vc, 1); in do_con_trol()
1850 clr_kbd(vc, kbdapplic); in do_con_trol()
1853 set_kbd(vc, kbdapplic); in do_con_trol()
1859 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) in do_con_trol()
1860 vc->vc_par[vc->vc_npar] = 0; in do_con_trol()
1861 vc->vc_npar = 0; in do_con_trol()
1862 vc->vc_state = ESpalette; in do_con_trol()
1865 reset_palette(vc); in do_con_trol()
1866 vc->vc_state = ESnormal; in do_con_trol()
1868 vc->vc_state = ESosc; in do_con_trol()
1870 vc->vc_state = ESnormal; in do_con_trol()
1874 vc->vc_par[vc->vc_npar++] = hex_to_bin(c); in do_con_trol()
1875 if (vc->vc_npar == 7) { in do_con_trol()
1876 int i = vc->vc_par[0] * 3, j = 1; in do_con_trol()
1877 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
1878 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
1879 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
1880 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
1881 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
1882 vc->vc_palette[i] += vc->vc_par[j]; in do_con_trol()
1883 set_palette(vc); in do_con_trol()
1884 vc->vc_state = ESnormal; in do_con_trol()
1887 vc->vc_state = ESnormal; in do_con_trol()
1890 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) in do_con_trol()
1891 vc->vc_par[vc->vc_npar] = 0; in do_con_trol()
1892 vc->vc_npar = 0; in do_con_trol()
1893 vc->vc_state = ESgetpars; in do_con_trol()
1895 vc->vc_state=ESfunckey; in do_con_trol()
1898 vc->vc_ques = (c == '?'); in do_con_trol()
1899 if (vc->vc_ques) in do_con_trol()
1902 if (c == ';' && vc->vc_npar < NPAR - 1) { in do_con_trol()
1903 vc->vc_npar++; in do_con_trol()
1906 vc->vc_par[vc->vc_npar] *= 10; in do_con_trol()
1907 vc->vc_par[vc->vc_npar] += c - '0'; in do_con_trol()
1910 vc->vc_state = ESnormal; in do_con_trol()
1913 set_mode(vc, 1); in do_con_trol()
1916 set_mode(vc, 0); in do_con_trol()
1919 if (vc->vc_ques) { in do_con_trol()
1920 if (vc->vc_par[0]) in do_con_trol()
1921 vc->vc_cursor_type = vc->vc_par[0] | (vc->vc_par[1] << 8) | (vc->vc_par[2] << 16); in do_con_trol()
1923 vc->vc_cursor_type = cur_default; in do_con_trol()
1928 if (vc->vc_ques) { in do_con_trol()
1930 if (vc->vc_par[0]) in do_con_trol()
1931 vc->vc_complement_mask = vc->vc_par[0] << 8 | vc->vc_par[1]; in do_con_trol()
1933 vc->vc_complement_mask = vc->vc_s_complement_mask; in do_con_trol()
1938 if (!vc->vc_ques) { in do_con_trol()
1939 if (vc->vc_par[0] == 5) in do_con_trol()
1941 else if (vc->vc_par[0] == 6) in do_con_trol()
1942 cursor_report(vc, tty); in do_con_trol()
1946 if (vc->vc_ques) { in do_con_trol()
1947 vc->vc_ques = 0; in do_con_trol()
1952 if (vc->vc_par[0]) in do_con_trol()
1953 vc->vc_par[0]--; in do_con_trol()
1954 gotoxy(vc, vc->vc_par[0], vc->vc_y); in do_con_trol()
1957 if (!vc->vc_par[0]) in do_con_trol()
1958 vc->vc_par[0]++; in do_con_trol()
1959 gotoxy(vc, vc->vc_x, vc->vc_y - vc->vc_par[0]); in do_con_trol()
1962 if (!vc->vc_par[0]) in do_con_trol()
1963 vc->vc_par[0]++; in do_con_trol()
1964 gotoxy(vc, vc->vc_x, vc->vc_y + vc->vc_par[0]); in do_con_trol()
1967 if (!vc->vc_par[0]) in do_con_trol()
1968 vc->vc_par[0]++; in do_con_trol()
1969 gotoxy(vc, vc->vc_x + vc->vc_par[0], vc->vc_y); in do_con_trol()
1972 if (!vc->vc_par[0]) in do_con_trol()
1973 vc->vc_par[0]++; in do_con_trol()
1974 gotoxy(vc, vc->vc_x - vc->vc_par[0], vc->vc_y); in do_con_trol()
1977 if (!vc->vc_par[0]) in do_con_trol()
1978 vc->vc_par[0]++; in do_con_trol()
1979 gotoxy(vc, 0, vc->vc_y + vc->vc_par[0]); in do_con_trol()
1982 if (!vc->vc_par[0]) in do_con_trol()
1983 vc->vc_par[0]++; in do_con_trol()
1984 gotoxy(vc, 0, vc->vc_y - vc->vc_par[0]); in do_con_trol()
1987 if (vc->vc_par[0]) in do_con_trol()
1988 vc->vc_par[0]--; in do_con_trol()
1989 gotoxay(vc, vc->vc_x ,vc->vc_par[0]); in do_con_trol()
1992 if (vc->vc_par[0]) in do_con_trol()
1993 vc->vc_par[0]--; in do_con_trol()
1994 if (vc->vc_par[1]) in do_con_trol()
1995 vc->vc_par[1]--; in do_con_trol()
1996 gotoxay(vc, vc->vc_par[1], vc->vc_par[0]); in do_con_trol()
1999 csi_J(vc, vc->vc_par[0]); in do_con_trol()
2002 csi_K(vc, vc->vc_par[0]); in do_con_trol()
2005 csi_L(vc, vc->vc_par[0]); in do_con_trol()
2008 csi_M(vc, vc->vc_par[0]); in do_con_trol()
2011 csi_P(vc, vc->vc_par[0]); in do_con_trol()
2014 if (!vc->vc_par[0]) in do_con_trol()
2018 if (!vc->vc_par[0]) in do_con_trol()
2019 vc->vc_tab_stop[vc->vc_x >> 5] &= ~(1 << (vc->vc_x & 31)); in do_con_trol()
2020 else if (vc->vc_par[0] == 3) { in do_con_trol()
2021 vc->vc_tab_stop[0] = in do_con_trol()
2022 vc->vc_tab_stop[1] = in do_con_trol()
2023 vc->vc_tab_stop[2] = in do_con_trol()
2024 vc->vc_tab_stop[3] = in do_con_trol()
2025 vc->vc_tab_stop[4] = in do_con_trol()
2026 vc->vc_tab_stop[5] = in do_con_trol()
2027 vc->vc_tab_stop[6] = in do_con_trol()
2028 vc->vc_tab_stop[7] = 0; in do_con_trol()
2032 csi_m(vc); in do_con_trol()
2036 if (vc->vc_par[0] < 4) in do_con_trol()
2037 vt_set_led_state(vc->vc_num, in do_con_trol()
2038 (vc->vc_par[0] < 3) ? vc->vc_par[0] : 4); in do_con_trol()
2041 if (!vc->vc_par[0]) in do_con_trol()
2042 vc->vc_par[0]++; in do_con_trol()
2043 if (!vc->vc_par[1]) in do_con_trol()
2044 vc->vc_par[1] = vc->vc_rows; in do_con_trol()
2046 if (vc->vc_par[0] < vc->vc_par[1] && in do_con_trol()
2047 vc->vc_par[1] <= vc->vc_rows) { in do_con_trol()
2048 vc->vc_top = vc->vc_par[0] - 1; in do_con_trol()
2049 vc->vc_bottom = vc->vc_par[1]; in do_con_trol()
2050 gotoxay(vc, 0, 0); in do_con_trol()
2054 save_cur(vc); in do_con_trol()
2057 restore_cur(vc); in do_con_trol()
2060 csi_X(vc, vc->vc_par[0]); in do_con_trol()
2063 csi_at(vc, vc->vc_par[0]); in do_con_trol()
2066 setterm_command(vc); in do_con_trol()
2071 vc->vc_state = ESnormal; in do_con_trol()
2074 vc->vc_utf = 0; in do_con_trol()
2078 vc->vc_utf = 1; in do_con_trol()
2083 vc->vc_state = ESnormal; in do_con_trol()
2086 vc->vc_state = ESnormal; in do_con_trol()
2089 vc->vc_video_erase_char = in do_con_trol()
2090 (vc->vc_video_erase_char & 0xff00) | 'E'; in do_con_trol()
2091 csi_J(vc, 2); in do_con_trol()
2092 vc->vc_video_erase_char = in do_con_trol()
2093 (vc->vc_video_erase_char & 0xff00) | ' '; in do_con_trol()
2094 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in do_con_trol()
2099 vc->vc_G0_charset = GRAF_MAP; in do_con_trol()
2101 vc->vc_G0_charset = LAT1_MAP; in do_con_trol()
2103 vc->vc_G0_charset = IBMPC_MAP; in do_con_trol()
2105 vc->vc_G0_charset = USER_MAP; in do_con_trol()
2106 if (vc->vc_charset == 0) in do_con_trol()
2107 vc->vc_translate = set_translate(vc->vc_G0_charset, vc); in do_con_trol()
2108 vc->vc_state = ESnormal; in do_con_trol()
2112 vc->vc_G1_charset = GRAF_MAP; in do_con_trol()
2114 vc->vc_G1_charset = LAT1_MAP; in do_con_trol()
2116 vc->vc_G1_charset = IBMPC_MAP; in do_con_trol()
2118 vc->vc_G1_charset = USER_MAP; in do_con_trol()
2119 if (vc->vc_charset == 1) in do_con_trol()
2120 vc->vc_translate = set_translate(vc->vc_G1_charset, vc); in do_con_trol()
2121 vc->vc_state = ESnormal; in do_con_trol()
2126 vc->vc_state = ESnormal; in do_con_trol()
2176 vc->vc_sw->con_putcs(vc, (u16 *)draw_from, (u16 *)draw_to - (u16 *)draw_from, vc->vc_y, draw_x); \ in do_con_write()
2184 struct vc_data *vc; in do_con_write() local
2198 vc = tty->driver_data; in do_con_write()
2199 if (vc == NULL) { in do_con_write()
2205 currcons = vc->vc_num; in do_con_write()
2213 himask = vc->vc_hi_font_mask; in do_con_write()
2217 if (IS_FG(vc)) in do_con_write()
2218 hide_cursor(vc); in do_con_write()
2220 param.vc = vc; in do_con_write()
2233 if (vc->vc_state != ESnormal) { in do_con_write()
2235 } else if (vc->vc_utf && !vc->vc_disp_ctrl) { in do_con_write()
2246 if (vc->vc_utf_count) { in do_con_write()
2247 vc->vc_utf_char = (vc->vc_utf_char << 6) | (c & 0x3f); in do_con_write()
2248 vc->vc_npar++; in do_con_write()
2249 if (--vc->vc_utf_count) { in do_con_write()
2254 c = vc->vc_utf_char; in do_con_write()
2256 if (c <= utf8_length_changes[vc->vc_npar - 1] || in do_con_write()
2257 c > utf8_length_changes[vc->vc_npar]) in do_con_write()
2261 vc->vc_utf_count = 0; in do_con_write()
2266 if (vc->vc_utf_count) { in do_con_write()
2269 vc->vc_utf_count = 0; in do_con_write()
2273 vc->vc_npar = 0; in do_con_write()
2275 vc->vc_utf_count = 1; in do_con_write()
2276 vc->vc_utf_char = (c & 0x1f); in do_con_write()
2278 vc->vc_utf_count = 2; in do_con_write()
2279 vc->vc_utf_char = (c & 0x0f); in do_con_write()
2281 vc->vc_utf_count = 3; in do_con_write()
2282 vc->vc_utf_char = (c & 0x07); in do_con_write()
2284 vc->vc_utf_count = 4; in do_con_write()
2285 vc->vc_utf_char = (c & 0x03); in do_con_write()
2287 vc->vc_utf_count = 5; in do_con_write()
2288 vc->vc_utf_char = (c & 0x01); in do_con_write()
2293 if (vc->vc_utf_count) { in do_con_write()
2307 tc = vc_translate(vc, c); in do_con_write()
2326 !(vc->vc_disp_ctrl ? (CTRL_ALWAYS >> c) & 1 : in do_con_write()
2327 vc->vc_utf || ((CTRL_ACTION >> c) & 1))) in do_con_write()
2328 && (c != 127 || vc->vc_disp_ctrl) in do_con_write()
2331 if (vc->vc_state == ESnormal && ok) { in do_con_write()
2332 if (vc->vc_utf && !vc->vc_disp_ctrl) { in do_con_write()
2337 tc = conv_uni_to_pc(vc, tc); in do_con_write()
2343 if ((!(vc->vc_utf && !vc->vc_disp_ctrl) || c < 128) && !(c & ~charmask)) { in do_con_write()
2352 tc = conv_uni_to_pc(vc, 0xfffd); in do_con_write()
2355 tc = conv_uni_to_pc(vc, '?'); in do_con_write()
2362 vc_attr = vc->vc_attr; in do_con_write()
2365 if (!vc->vc_can_do_color) { in do_con_write()
2366 vc_attr = (vc->vc_attr) ^ 0x08; in do_con_write()
2367 } else if (vc->vc_hi_font_mask == 0x100) { in do_con_write()
2368 … vc_attr = ((vc->vc_attr) & 0x11) | (((vc->vc_attr) & 0xe0) >> 4) | (((vc->vc_attr) & 0x0e) << 4); in do_con_write()
2370 … vc_attr = ((vc->vc_attr) & 0x88) | (((vc->vc_attr) & 0x70) >> 4) | (((vc->vc_attr) & 0x07) << 4); in do_con_write()
2376 if (vc->vc_need_wrap || vc->vc_decim) in do_con_write()
2378 if (vc->vc_need_wrap) { in do_con_write()
2379 cr(vc); in do_con_write()
2380 lf(vc); in do_con_write()
2382 if (vc->vc_decim) in do_con_write()
2383 insert_char(vc, 1); in do_con_write()
2387 (u16 *) vc->vc_pos); in do_con_write()
2388 if (DO_UPDATE(vc) && draw_x < 0) { in do_con_write()
2389 draw_x = vc->vc_x; in do_con_write()
2390 draw_from = vc->vc_pos; in do_con_write()
2392 if (vc->vc_x == vc->vc_cols - 1) { in do_con_write()
2393 vc->vc_need_wrap = vc->vc_decawm; in do_con_write()
2394 draw_to = vc->vc_pos + 2; in do_con_write()
2396 vc->vc_x++; in do_con_write()
2397 draw_to = (vc->vc_pos += 2); in do_con_write()
2402 tc = conv_uni_to_pc(vc, ' '); /* A space is printed in the second column */ in do_con_write()
2405 notify_write(vc, c); in do_con_write()
2421 do_con_trol(tty, vc, orig); in do_con_write()
2426 notify_update(vc); in do_con_write()
2460 struct vc_data *vc = vc_cons[fg_console].d; in console_callback() local
2462 if (vc->vc_mode == KD_TEXT) in console_callback()
2463 vc->vc_sw->con_scrolldelta(vc, scrollback_delta); in console_callback()
2477 struct vc_data *vc = vc_cons[fg_console].d; in set_console() local
2480 (vc->vt_mode.mode == VT_AUTO && vc->vc_mode == KD_GRAPHICS)) { in set_console()
2542 struct vc_data *vc = vc_cons[fg_console].d; in vt_console_print() local
2558 vc = vc_cons[kmsg_console - 1].d; in vt_console_print()
2562 myx = vc->vc_x; in vt_console_print()
2570 if (vc->vc_mode != KD_TEXT && !vt_force_oops_output(vc)) in vt_console_print()
2574 if (IS_FG(vc)) in vt_console_print()
2575 hide_cursor(vc); in vt_console_print()
2577 start = (ushort *)vc->vc_pos; in vt_console_print()
2583 if (c == 10 || c == 13 || c == 8 || vc->vc_need_wrap) { in vt_console_print()
2585 if (CON_IS_VISIBLE(vc)) in vt_console_print()
2586 vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x); in vt_console_print()
2587 vc->vc_x += cnt; in vt_console_print()
2588 if (vc->vc_need_wrap) in vt_console_print()
2589 vc->vc_x--; in vt_console_print()
2593 bs(vc); in vt_console_print()
2594 start = (ushort *)vc->vc_pos; in vt_console_print()
2595 myx = vc->vc_x; in vt_console_print()
2599 lf(vc); in vt_console_print()
2600 cr(vc); in vt_console_print()
2601 start = (ushort *)vc->vc_pos; in vt_console_print()
2602 myx = vc->vc_x; in vt_console_print()
2606 scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos); in vt_console_print()
2607 notify_write(vc, c); in vt_console_print()
2609 if (myx == vc->vc_cols - 1) { in vt_console_print()
2610 vc->vc_need_wrap = 1; in vt_console_print()
2613 vc->vc_pos += 2; in vt_console_print()
2617 if (CON_IS_VISIBLE(vc)) in vt_console_print()
2618 vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x); in vt_console_print()
2619 vc->vc_x += cnt; in vt_console_print()
2620 if (vc->vc_x == vc->vc_cols) { in vt_console_print()
2621 vc->vc_x--; in vt_console_print()
2622 vc->vc_need_wrap = 1; in vt_console_print()
2625 set_cursor(vc); in vt_console_print()
2626 notify_update(vc); in vt_console_print()
2811 struct vc_data *vc = tty->driver_data; in con_unthrottle() local
2813 wake_up_interruptible(&vc->paste_wait); in con_unthrottle()
2846 struct vc_data *vc; in con_flush_chars() local
2853 vc = tty->driver_data; in con_flush_chars()
2854 if (vc) in con_flush_chars()
2855 set_cursor(vc); in con_flush_chars()
2865 struct vc_data *vc; in con_install() local
2873 vc = vc_cons[currcons].d; in con_install()
2876 if (vc->port.tty) { in con_install()
2881 ret = tty_port_install(&vc->port, driver, tty); in con_install()
2885 tty->driver_data = vc; in con_install()
2886 vc->port.tty = tty; in con_install()
2892 if (vc->vc_utf) in con_install()
2915 struct vc_data *vc = tty->driver_data; in con_shutdown() local
2916 BUG_ON(vc == NULL); in con_shutdown()
2918 vc->port.tty = NULL; in con_shutdown()
2929 static void vc_init(struct vc_data *vc, unsigned int rows, in vc_init() argument
2934 vc->vc_cols = cols; in vc_init()
2935 vc->vc_rows = rows; in vc_init()
2936 vc->vc_size_row = cols << 1; in vc_init()
2937 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; in vc_init()
2939 set_origin(vc); in vc_init()
2940 vc->vc_pos = vc->vc_origin; in vc_init()
2941 reset_vc(vc); in vc_init()
2943 vc->vc_palette[k++] = default_red[j] ; in vc_init()
2944 vc->vc_palette[k++] = default_grn[j] ; in vc_init()
2945 vc->vc_palette[k++] = default_blu[j] ; in vc_init()
2947 vc->vc_def_color = default_color; in vc_init()
2948 vc->vc_ulcolor = default_underline_color; in vc_init()
2949 vc->vc_itcolor = default_italic_color; in vc_init()
2950 vc->vc_halfcolor = 0x08; /* grey */ in vc_init()
2951 init_waitqueue_head(&vc->paste_wait); in vc_init()
2952 reset_terminal(vc, do_clear); in vc_init()
2964 struct vc_data *vc; in con_init() local
2999 vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT); in con_init()
3001 tty_port_init(&vc->port); in con_init()
3002 visual_init(vc, currcons, 1); in con_init()
3003 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT); in con_init()
3004 vc_init(vc, vc->vc_rows, vc->vc_cols, in con_init()
3005 currcons || !vc->vc_sw->con_save_screen); in con_init()
3008 master_display_fg = vc = vc_cons[currcons].d; in con_init()
3009 set_origin(vc); in con_init()
3010 save_screen(vc); in con_init()
3011 gotoxy(vc, vc->vc_x, vc->vc_y); in con_init()
3012 csi_J(vc, 0); in con_init()
3013 update_screen(vc); in con_init()
3015 vc->vc_can_do_color ? "colour" : "mono", in con_init()
3016 display_desc, vc->vc_cols, vc->vc_rows); in con_init()
3152 struct vc_data *vc = vc_cons[i].d; in do_bind_con_driver() local
3159 if (!vc || !vc->vc_sw) in do_bind_con_driver()
3164 if (CON_IS_VISIBLE(vc)) { in do_bind_con_driver()
3166 save_screen(vc); in do_bind_con_driver()
3169 old_was_color = vc->vc_can_do_color; in do_bind_con_driver()
3170 vc->vc_sw->con_deinit(vc); in do_bind_con_driver()
3171 vc->vc_origin = (unsigned long)vc->vc_screenbuf; in do_bind_con_driver()
3172 visual_init(vc, i, 0); in do_bind_con_driver()
3173 set_origin(vc); in do_bind_con_driver()
3174 update_attr(vc); in do_bind_con_driver()
3180 if (old_was_color != vc->vc_can_do_color) in do_bind_con_driver()
3181 clear_buffer_attributes(vc); in do_bind_con_driver()
3188 struct vc_data *vc = vc_cons[j].d; in do_bind_con_driver() local
3191 vc->vc_can_do_color ? "colour" : "mono", in do_bind_con_driver()
3192 desc, vc->vc_cols, vc->vc_rows); in do_bind_con_driver()
3195 vc = vc_cons[k].d; in do_bind_con_driver()
3196 update_screen(vc); in do_bind_con_driver()
3487 int con_debug_enter(struct vc_data *vc) in con_debug_enter() argument
3494 saved_vc_mode = vc->vc_mode; in con_debug_enter()
3496 vc->vc_mode = KD_TEXT; in con_debug_enter()
3498 if (vc->vc_sw->con_debug_enter) in con_debug_enter()
3499 ret = vc->vc_sw->con_debug_enter(vc); in con_debug_enter()
3502 if (vc->vc_rows < 999) { in con_debug_enter()
3511 snprintf(lns, 4, "%i", vc->vc_rows); in con_debug_enter()
3515 if (vc->vc_cols < 999) { in con_debug_enter()
3524 snprintf(cols, 4, "%i", vc->vc_cols); in con_debug_enter()
3546 struct vc_data *vc; in con_debug_leave() local
3555 vc = vc_cons[fg_console].d; in con_debug_leave()
3556 if (vc->vc_sw->con_debug_leave) in con_debug_leave()
3557 ret = vc->vc_sw->con_debug_leave(vc); in con_debug_leave()
3808 struct vc_data *vc = vc_cons[fg_console].d; in do_blank_screen() local
3816 vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0); in do_blank_screen()
3823 hide_cursor(vc); in do_blank_screen()
3824 save_screen(vc); in do_blank_screen()
3825 vc->vc_sw->con_blank(vc, -1, 1); in do_blank_screen()
3828 set_origin(vc); in do_blank_screen()
3837 if (vc->vc_mode != KD_TEXT) { in do_blank_screen()
3842 hide_cursor(vc); in do_blank_screen()
3846 save_screen(vc); in do_blank_screen()
3848 i = vc->vc_sw->con_blank(vc, vesa_off_interval ? 1 : (vesa_blank_mode + 1), 0); in do_blank_screen()
3851 set_origin(vc); in do_blank_screen()
3860 vt_event_post(VT_EVENT_BLANK, vc->vc_num, vc->vc_num); in do_blank_screen()
3869 struct vc_data *vc; in do_unblank_screen() local
3889 vc = vc_cons[fg_console].d; in do_unblank_screen()
3891 if (vc->vc_mode != KD_TEXT && !vt_force_oops_output(vc)) in do_unblank_screen()
3900 if (vc->vc_sw->con_blank(vc, 0, leaving_gfx) || vt_force_oops_output(vc)) in do_unblank_screen()
3902 update_screen(vc); in do_unblank_screen()
3905 set_palette(vc); in do_unblank_screen()
3906 set_cursor(vc); in do_unblank_screen()
3907 vt_event_post(VT_EVENT_UNBLANK, vc->vc_num, vc->vc_num); in do_unblank_screen()
3969 static void set_palette(struct vc_data *vc) in set_palette() argument
3973 if (vc->vc_mode != KD_GRAPHICS) in set_palette()
3974 vc->vc_sw->con_set_palette(vc, color_table); in set_palette()
4030 void reset_palette(struct vc_data *vc) in reset_palette() argument
4034 vc->vc_palette[k++] = default_red[j]; in reset_palette()
4035 vc->vc_palette[k++] = default_grn[j]; in reset_palette()
4036 vc->vc_palette[k++] = default_blu[j]; in reset_palette()
4038 set_palette(vc); in reset_palette()
4056 static int con_font_get(struct vc_data *vc, struct console_font_op *op) in con_font_get() argument
4070 if (vc->vc_mode != KD_TEXT) in con_font_get()
4072 else if (vc->vc_sw->con_font_get) in con_font_get()
4073 rc = vc->vc_sw->con_font_get(vc, &font); in con_font_get()
4110 static int con_font_set(struct vc_data *vc, struct console_font_op *op) in con_font_set() argument
4116 if (vc->vc_mode != KD_TEXT) in con_font_set()
4154 if (vc->vc_mode != KD_TEXT) in con_font_set()
4156 else if (vc->vc_sw->con_font_set) in con_font_set()
4157 rc = vc->vc_sw->con_font_set(vc, &font, op->flags); in con_font_set()
4165 static int con_font_default(struct vc_data *vc, struct console_font_op *op) in con_font_default() argument
4181 if (vc->vc_mode != KD_TEXT) { in con_font_default()
4185 if (vc->vc_sw->con_font_default) in con_font_default()
4186 rc = vc->vc_sw->con_font_default(vc, &font, s); in con_font_default()
4197 static int con_font_copy(struct vc_data *vc, struct console_font_op *op) in con_font_copy() argument
4204 if (vc->vc_mode != KD_TEXT) in con_font_copy()
4206 else if (!vc->vc_sw->con_font_copy) in con_font_copy()
4210 else if (con == vc->vc_num) /* nothing to do */ in con_font_copy()
4213 rc = vc->vc_sw->con_font_copy(vc, con); in con_font_copy()
4218 int con_font_op(struct vc_data *vc, struct console_font_op *op) in con_font_op() argument
4222 return con_font_set(vc, op); in con_font_op()
4224 return con_font_get(vc, op); in con_font_op()
4226 return con_font_default(vc, op); in con_font_op()
4228 return con_font_copy(vc, op); in con_font_op()
4238 u16 screen_glyph(struct vc_data *vc, int offset) in screen_glyph() argument
4240 u16 w = scr_readw(screenpos(vc, offset, 1)); in screen_glyph()
4243 if (w & vc->vc_hi_font_mask) in screen_glyph()
4250 unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed) in screen_pos() argument
4252 return screenpos(vc, 2 * w_offset, viewed); in screen_pos()
4255 void getconsxy(struct vc_data *vc, unsigned char *p) in getconsxy() argument
4257 p[0] = vc->vc_x; in getconsxy()
4258 p[1] = vc->vc_y; in getconsxy()
4261 void putconsxy(struct vc_data *vc, unsigned char *p) in putconsxy() argument
4263 hide_cursor(vc); in putconsxy()
4264 gotoxy(vc, p[0], p[1]); in putconsxy()
4265 set_cursor(vc); in putconsxy()
4268 u16 vcs_scr_readw(struct vc_data *vc, const u16 *org) in vcs_scr_readw() argument
4270 if ((unsigned long)org == vc->vc_pos && softcursor_original != -1) in vcs_scr_readw()
4275 void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org) in vcs_scr_writew() argument
4278 if ((unsigned long)org == vc->vc_pos) { in vcs_scr_writew()
4280 add_softcursor(vc); in vcs_scr_writew()
4284 void vcs_scr_updated(struct vc_data *vc) in vcs_scr_updated() argument
4286 notify_update(vc); in vcs_scr_updated()