Lines Matching refs:vc
139 struct vc vc_cons [MAX_NR_CONSOLES];
146 static void vc_init(struct vc_data *vc, unsigned int rows,
148 static void gotoxy(struct vc_data *vc, int new_x, int new_y);
149 static void save_cur(struct vc_data *vc);
150 static void reset_terminal(struct vc_data *vc, int do_clear);
153 static void set_cursor(struct vc_data *vc);
154 static void hide_cursor(struct vc_data *vc);
157 static void set_palette(struct vc_data *vc);
261 static void notify_write(struct vc_data *vc, unsigned int unicode) in notify_write() argument
263 struct vt_notifier_param param = { .vc = vc, .c = unicode }; in notify_write()
267 static void notify_update(struct vc_data *vc) in notify_update() argument
269 struct vt_notifier_param param = { .vc = vc }; in notify_update()
276 #define IS_FG(vc) ((vc)->vc_num == fg_console) argument
279 #define DO_UPDATE(vc) 0 argument
281 #define DO_UPDATE(vc) (CON_IS_VISIBLE(vc) && !console_blanked) argument
284 static inline unsigned short *screenpos(struct vc_data *vc, int offset, int viewed) in screenpos() argument
289 p = (unsigned short *)(vc->vc_origin + offset); in screenpos()
290 else if (!vc->vc_sw->con_screen_pos) in screenpos()
291 p = (unsigned short *)(vc->vc_visible_origin + offset); in screenpos()
293 p = vc->vc_sw->con_screen_pos(vc, offset); in screenpos()
312 static void scrup(struct vc_data *vc, unsigned int t, unsigned int b, int nr) in scrup() argument
318 if (b > vc->vc_rows || t >= b || nr < 1) in scrup()
320 if (CON_IS_VISIBLE(vc) && vc->vc_sw->con_scroll(vc, t, b, SM_UP, nr)) in scrup()
322 d = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t); in scrup()
323 s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * (t + nr)); in scrup()
324 scr_memmovew(d, s, (b - t - nr) * vc->vc_size_row); in scrup()
325 scr_memsetw(d + (b - t - nr) * vc->vc_cols, vc->vc_video_erase_char, in scrup()
326 vc->vc_size_row * nr); in scrup()
329 static void scrdown(struct vc_data *vc, unsigned int t, unsigned int b, int nr) in scrdown() argument
336 if (b > vc->vc_rows || t >= b || nr < 1) in scrdown()
338 if (CON_IS_VISIBLE(vc) && vc->vc_sw->con_scroll(vc, t, b, SM_DOWN, nr)) in scrdown()
340 s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t); in scrdown()
341 step = vc->vc_cols * nr; in scrdown()
342 scr_memmovew(s + step, s, (b - t - nr) * vc->vc_size_row); in scrdown()
343 scr_memsetw(s, vc->vc_video_erase_char, 2 * step); in scrdown()
346 static void do_update_region(struct vc_data *vc, unsigned long start, int count) in do_update_region() argument
353 if (!vc->vc_sw->con_getxy) { in do_update_region()
354 offset = (start - vc->vc_origin) / 2; in do_update_region()
355 xx = offset % vc->vc_cols; in do_update_region()
356 yy = offset / vc->vc_cols; in do_update_region()
359 start = vc->vc_sw->con_getxy(vc, start, &nxx, &nyy); in do_update_region()
366 while (xx < vc->vc_cols && count) { in do_update_region()
369 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); in do_update_region()
379 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); in do_update_region()
384 if (vc->vc_sw->con_getxy) { in do_update_region()
386 start = vc->vc_sw->con_getxy(vc, start, NULL, NULL); in do_update_region()
392 void update_region(struct vc_data *vc, unsigned long start, int count) in update_region() argument
396 if (DO_UPDATE(vc)) { in update_region()
397 hide_cursor(vc); in update_region()
398 do_update_region(vc, start, count); in update_region()
399 set_cursor(vc); in update_region()
405 static u8 build_attr(struct vc_data *vc, u8 _color, u8 _intensity, u8 _blink, in build_attr() argument
408 if (vc->vc_sw->con_build_attr) in build_attr()
409 return vc->vc_sw->con_build_attr(vc, _color, _intensity, in build_attr()
425 if (!vc->vc_can_do_color) in build_attr()
432 a = (a & 0xF0) | vc->vc_itcolor; in build_attr()
434 a = (a & 0xf0) | vc->vc_ulcolor; in build_attr()
436 a = (a & 0xf0) | vc->vc_ulcolor; in build_attr()
443 if (vc->vc_hi_font_mask == 0x100) in build_attr()
452 static void update_attr(struct vc_data *vc) in update_attr() argument
454 vc->vc_attr = build_attr(vc, vc->vc_color, vc->vc_intensity, in update_attr()
455 vc->vc_blink, vc->vc_underline, in update_attr()
456 vc->vc_reverse ^ vc->vc_decscnm, vc->vc_italic); in update_attr()
457 …vc->vc_video_erase_char = (build_attr(vc, vc->vc_color, 1, vc->vc_blink, 0, vc->vc_decscnm, 0) << … in update_attr()
461 void invert_screen(struct vc_data *vc, int offset, int count, int viewed) in invert_screen() argument
468 p = screenpos(vc, offset, viewed); in invert_screen()
469 if (vc->vc_sw->con_invert_region) in invert_screen()
470 vc->vc_sw->con_invert_region(vc, p, count); in invert_screen()
477 if (!vc->vc_can_do_color) { in invert_screen()
484 } else if (vc->vc_hi_font_mask == 0x100) { in invert_screen()
501 if (DO_UPDATE(vc)) in invert_screen()
502 do_update_region(vc, (unsigned long) p, count); in invert_screen()
503 notify_update(vc); in invert_screen()
507 void complement_pos(struct vc_data *vc, int offset) in complement_pos() argument
516 old_offset < vc->vc_screenbuf_size) { in complement_pos()
517 scr_writew(old, screenpos(vc, old_offset, 1)); in complement_pos()
518 if (DO_UPDATE(vc)) in complement_pos()
519 vc->vc_sw->con_putc(vc, old, oldy, oldx); in complement_pos()
520 notify_update(vc); in complement_pos()
526 offset < vc->vc_screenbuf_size) { in complement_pos()
529 p = screenpos(vc, offset, 1); in complement_pos()
531 new = old ^ vc->vc_complement_mask; in complement_pos()
533 if (DO_UPDATE(vc)) { in complement_pos()
534 oldx = (offset >> 1) % vc->vc_cols; in complement_pos()
535 oldy = (offset >> 1) / vc->vc_cols; in complement_pos()
536 vc->vc_sw->con_putc(vc, new, oldy, oldx); in complement_pos()
538 notify_update(vc); in complement_pos()
542 static void insert_char(struct vc_data *vc, unsigned int nr) in insert_char() argument
544 unsigned short *p = (unsigned short *) vc->vc_pos; in insert_char()
546 scr_memmovew(p + nr, p, (vc->vc_cols - vc->vc_x - nr) * 2); in insert_char()
547 scr_memsetw(p, vc->vc_video_erase_char, nr * 2); in insert_char()
548 vc->vc_need_wrap = 0; in insert_char()
549 if (DO_UPDATE(vc)) in insert_char()
550 do_update_region(vc, (unsigned long) p, in insert_char()
551 vc->vc_cols - vc->vc_x); in insert_char()
554 static void delete_char(struct vc_data *vc, unsigned int nr) in delete_char() argument
556 unsigned short *p = (unsigned short *) vc->vc_pos; in delete_char()
558 scr_memcpyw(p, p + nr, (vc->vc_cols - vc->vc_x - nr) * 2); in delete_char()
559 scr_memsetw(p + vc->vc_cols - vc->vc_x - nr, vc->vc_video_erase_char, in delete_char()
561 vc->vc_need_wrap = 0; in delete_char()
562 if (DO_UPDATE(vc)) in delete_char()
563 do_update_region(vc, (unsigned long) p, in delete_char()
564 vc->vc_cols - vc->vc_x); in delete_char()
569 static void add_softcursor(struct vc_data *vc) in add_softcursor() argument
571 int i = scr_readw((u16 *) vc->vc_pos); in add_softcursor()
572 u32 type = vc->vc_cursor_type; in add_softcursor()
581 scr_writew(i, (u16 *) vc->vc_pos); in add_softcursor()
582 if (DO_UPDATE(vc)) in add_softcursor()
583 vc->vc_sw->con_putc(vc, i, vc->vc_y, vc->vc_x); in add_softcursor()
586 static void hide_softcursor(struct vc_data *vc) in hide_softcursor() argument
589 scr_writew(softcursor_original, (u16 *)vc->vc_pos); in hide_softcursor()
590 if (DO_UPDATE(vc)) in hide_softcursor()
591 vc->vc_sw->con_putc(vc, softcursor_original, in hide_softcursor()
592 vc->vc_y, vc->vc_x); in hide_softcursor()
597 static void hide_cursor(struct vc_data *vc) in hide_cursor() argument
599 if (vc == sel_cons) in hide_cursor()
601 vc->vc_sw->con_cursor(vc, CM_ERASE); in hide_cursor()
602 hide_softcursor(vc); in hide_cursor()
605 static void set_cursor(struct vc_data *vc) in set_cursor() argument
607 if (!IS_FG(vc) || console_blanked || in set_cursor()
608 vc->vc_mode == KD_GRAPHICS) in set_cursor()
610 if (vc->vc_deccm) { in set_cursor()
611 if (vc == sel_cons) in set_cursor()
613 add_softcursor(vc); in set_cursor()
614 if ((vc->vc_cursor_type & 0x0f) != 1) in set_cursor()
615 vc->vc_sw->con_cursor(vc, CM_DRAW); in set_cursor()
617 hide_cursor(vc); in set_cursor()
620 static void set_origin(struct vc_data *vc) in set_origin() argument
624 if (!CON_IS_VISIBLE(vc) || in set_origin()
625 !vc->vc_sw->con_set_origin || in set_origin()
626 !vc->vc_sw->con_set_origin(vc)) in set_origin()
627 vc->vc_origin = (unsigned long)vc->vc_screenbuf; in set_origin()
628 vc->vc_visible_origin = vc->vc_origin; in set_origin()
629 vc->vc_scr_end = vc->vc_origin + vc->vc_screenbuf_size; in set_origin()
630 vc->vc_pos = vc->vc_origin + vc->vc_size_row * vc->vc_y + 2 * vc->vc_x; in set_origin()
633 static inline void save_screen(struct vc_data *vc) in save_screen() argument
637 if (vc->vc_sw->con_save_screen) in save_screen()
638 vc->vc_sw->con_save_screen(vc); in save_screen()
645 void clear_buffer_attributes(struct vc_data *vc) in clear_buffer_attributes() argument
647 unsigned short *p = (unsigned short *)vc->vc_origin; in clear_buffer_attributes()
648 int count = vc->vc_screenbuf_size / 2; in clear_buffer_attributes()
649 int mask = vc->vc_hi_font_mask | 0xff; in clear_buffer_attributes()
652 scr_writew((scr_readw(p)&mask) | (vc->vc_video_erase_char & ~mask), p); in clear_buffer_attributes()
656 void redraw_screen(struct vc_data *vc, int is_switch) in redraw_screen() argument
662 if (!vc) { in redraw_screen()
670 if (old_vc == vc) in redraw_screen()
672 if (!CON_IS_VISIBLE(vc)) in redraw_screen()
674 *vc->vc_display_fg = vc; in redraw_screen()
675 fg_console = vc->vc_num; in redraw_screen()
684 hide_cursor(vc); in redraw_screen()
690 int old_was_color = vc->vc_can_do_color; in redraw_screen()
692 set_origin(vc); in redraw_screen()
693 update = vc->vc_sw->con_switch(vc); in redraw_screen()
694 set_palette(vc); in redraw_screen()
701 if (old_was_color != vc->vc_can_do_color) { in redraw_screen()
702 update_attr(vc); in redraw_screen()
703 clear_buffer_attributes(vc); in redraw_screen()
707 if ((update && vc->vc_mode != KD_GRAPHICS) || in redraw_screen()
708 vt_force_oops_output(vc)) in redraw_screen()
709 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in redraw_screen()
711 set_cursor(vc); in redraw_screen()
715 notify_update(vc); in redraw_screen()
728 static void visual_init(struct vc_data *vc, int num, int init) in visual_init() argument
731 if (vc->vc_sw) in visual_init()
732 module_put(vc->vc_sw->owner); in visual_init()
733 vc->vc_sw = conswitchp; in visual_init()
736 vc->vc_sw = con_driver_map[num]; in visual_init()
738 __module_get(vc->vc_sw->owner); in visual_init()
739 vc->vc_num = num; in visual_init()
740 vc->vc_display_fg = &master_display_fg; in visual_init()
741 vc->vc_uni_pagedir_loc = &vc->vc_uni_pagedir; in visual_init()
742 vc->vc_uni_pagedir = NULL; in visual_init()
743 vc->vc_hi_font_mask = 0; in visual_init()
744 vc->vc_complement_mask = 0; in visual_init()
745 vc->vc_can_do_color = 0; in visual_init()
746 vc->vc_panic_force_write = false; in visual_init()
747 vc->vc_sw->con_init(vc, init); in visual_init()
748 if (!vc->vc_complement_mask) in visual_init()
749 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; in visual_init()
750 vc->vc_s_complement_mask = vc->vc_complement_mask; in visual_init()
751 vc->vc_size_row = vc->vc_cols << 1; in visual_init()
752 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; in visual_init()
762 struct vc_data *vc; in vc_allocate() local
775 param.vc = vc = kzalloc(sizeof(struct vc_data), GFP_KERNEL); in vc_allocate()
776 if (!vc) in vc_allocate()
778 vc_cons[currcons].d = vc; in vc_allocate()
779 tty_port_init(&vc->port); in vc_allocate()
781 visual_init(vc, currcons, 1); in vc_allocate()
782 if (!*vc->vc_uni_pagedir_loc) in vc_allocate()
783 con_set_default_unimap(vc); in vc_allocate()
784 vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size, GFP_KERNEL); in vc_allocate()
785 if (!vc->vc_screenbuf) { in vc_allocate()
786 kfree(vc); in vc_allocate()
796 vc_init(vc, vc->vc_rows, vc->vc_cols, 1); in vc_allocate()
803 static inline int resize_screen(struct vc_data *vc, int width, int height, in resize_screen() argument
809 if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_resize) in resize_screen()
810 err = vc->vc_sw->con_resize(vc, width, height, user); in resize_screen()
839 static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, in vc_do_resize() argument
851 if (!vc) in vc_do_resize()
854 user = vc->vc_resize_user; in vc_do_resize()
855 vc->vc_resize_user = 0; in vc_do_resize()
860 new_cols = (cols ? cols : vc->vc_cols); in vc_do_resize()
861 new_rows = (lines ? lines : vc->vc_rows); in vc_do_resize()
865 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) in vc_do_resize()
872 old_rows = vc->vc_rows; in vc_do_resize()
873 old_row_size = vc->vc_size_row; in vc_do_resize()
875 err = resize_screen(vc, new_cols, new_rows, user); in vc_do_resize()
881 vc->vc_rows = new_rows; in vc_do_resize()
882 vc->vc_cols = new_cols; in vc_do_resize()
883 vc->vc_size_row = new_row_size; in vc_do_resize()
884 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
888 old_origin = vc->vc_origin; in vc_do_resize()
892 if (vc->vc_y > new_rows) { in vc_do_resize()
893 if (old_rows - vc->vc_y < new_rows) { in vc_do_resize()
904 old_origin += (vc->vc_y - new_rows/2) * old_row_size; in vc_do_resize()
910 update_attr(vc); in vc_do_resize()
917 vc->vc_video_erase_char, rrem); in vc_do_resize()
922 scr_memsetw((void *)new_origin, vc->vc_video_erase_char, in vc_do_resize()
924 kfree(vc->vc_screenbuf); in vc_do_resize()
925 vc->vc_screenbuf = newscreen; in vc_do_resize()
926 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
927 set_origin(vc); in vc_do_resize()
930 vc->vc_top = 0; in vc_do_resize()
931 vc->vc_bottom = vc->vc_rows; in vc_do_resize()
932 gotoxy(vc, vc->vc_x, vc->vc_y); in vc_do_resize()
933 save_cur(vc); in vc_do_resize()
940 ws.ws_row = vc->vc_rows; in vc_do_resize()
941 ws.ws_col = vc->vc_cols; in vc_do_resize()
942 ws.ws_ypixel = vc->vc_scan_lines; in vc_do_resize()
946 if (CON_IS_VISIBLE(vc)) in vc_do_resize()
947 update_screen(vc); in vc_do_resize()
948 vt_event_post(VT_EVENT_RESIZE, vc->vc_num, vc->vc_num); in vc_do_resize()
964 int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows) in vc_resize() argument
966 return vc_do_resize(vc->port.tty, vc, cols, rows); in vc_resize()
983 struct vc_data *vc = tty->driver_data; in vt_resize() local
987 ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row); in vt_resize()
994 struct vc_data *vc = NULL; in vc_deallocate() local
1001 param.vc = vc = vc_cons[currcons].d; in vc_deallocate()
1004 vc->vc_sw->con_deinit(vc); in vc_deallocate()
1005 put_pid(vc->vt_pid); in vc_deallocate()
1006 module_put(vc->vc_sw->owner); in vc_deallocate()
1007 kfree(vc->vc_screenbuf); in vc_deallocate()
1010 return vc; in vc_deallocate()
1017 #define set_kbd(vc, x) vt_set_kbd_mode_bit((vc)->vc_num, (x)) argument
1018 #define clr_kbd(vc, x) vt_clr_kbd_mode_bit((vc)->vc_num, (x)) argument
1019 #define is_kbd(vc, x) vt_get_kbd_mode_bit((vc)->vc_num, (x)) argument
1052 static void gotoxy(struct vc_data *vc, int new_x, int new_y) in gotoxy() argument
1057 vc->vc_x = 0; in gotoxy()
1059 if (new_x >= vc->vc_cols) in gotoxy()
1060 vc->vc_x = vc->vc_cols - 1; in gotoxy()
1062 vc->vc_x = new_x; in gotoxy()
1065 if (vc->vc_decom) { in gotoxy()
1066 min_y = vc->vc_top; in gotoxy()
1067 max_y = vc->vc_bottom; in gotoxy()
1070 max_y = vc->vc_rows; in gotoxy()
1073 vc->vc_y = min_y; in gotoxy()
1075 vc->vc_y = max_y - 1; in gotoxy()
1077 vc->vc_y = new_y; in gotoxy()
1078 vc->vc_pos = vc->vc_origin + vc->vc_y * vc->vc_size_row + (vc->vc_x<<1); in gotoxy()
1079 vc->vc_need_wrap = 0; in gotoxy()
1083 static void gotoxay(struct vc_data *vc, int new_x, int new_y) in gotoxay() argument
1085 gotoxy(vc, new_x, vc->vc_decom ? (vc->vc_top + new_y) : new_y); in gotoxay()
1088 void scrollback(struct vc_data *vc, int lines) in scrollback() argument
1091 lines = vc->vc_rows / 2; in scrollback()
1095 void scrollfront(struct vc_data *vc, int lines) in scrollfront() argument
1098 lines = vc->vc_rows / 2; in scrollfront()
1102 static void lf(struct vc_data *vc) in lf() argument
1107 if (vc->vc_y + 1 == vc->vc_bottom) in lf()
1108 scrup(vc, vc->vc_top, vc->vc_bottom, 1); in lf()
1109 else if (vc->vc_y < vc->vc_rows - 1) { in lf()
1110 vc->vc_y++; in lf()
1111 vc->vc_pos += vc->vc_size_row; in lf()
1113 vc->vc_need_wrap = 0; in lf()
1114 notify_write(vc, '\n'); in lf()
1117 static void ri(struct vc_data *vc) in ri() argument
1122 if (vc->vc_y == vc->vc_top) in ri()
1123 scrdown(vc, vc->vc_top, vc->vc_bottom, 1); in ri()
1124 else if (vc->vc_y > 0) { in ri()
1125 vc->vc_y--; in ri()
1126 vc->vc_pos -= vc->vc_size_row; in ri()
1128 vc->vc_need_wrap = 0; in ri()
1131 static inline void cr(struct vc_data *vc) in cr() argument
1133 vc->vc_pos -= vc->vc_x << 1; in cr()
1134 vc->vc_need_wrap = vc->vc_x = 0; in cr()
1135 notify_write(vc, '\r'); in cr()
1138 static inline void bs(struct vc_data *vc) in bs() argument
1140 if (vc->vc_x) { in bs()
1141 vc->vc_pos -= 2; in bs()
1142 vc->vc_x--; in bs()
1143 vc->vc_need_wrap = 0; in bs()
1144 notify_write(vc, '\b'); in bs()
1148 static inline void del(struct vc_data *vc) in del() argument
1153 static void csi_J(struct vc_data *vc, int vpar) in csi_J() argument
1160 count = (vc->vc_scr_end - vc->vc_pos) >> 1; in csi_J()
1161 start = (unsigned short *)vc->vc_pos; in csi_J()
1164 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1; in csi_J()
1165 start = (unsigned short *)vc->vc_origin; in csi_J()
1168 scr_memsetw(vc->vc_screenbuf, vc->vc_video_erase_char, in csi_J()
1169 vc->vc_screenbuf_size >> 1); in csi_J()
1170 set_origin(vc); in csi_J()
1171 if (CON_IS_VISIBLE(vc)) in csi_J()
1172 update_screen(vc); in csi_J()
1175 count = vc->vc_cols * vc->vc_rows; in csi_J()
1176 start = (unsigned short *)vc->vc_origin; in csi_J()
1181 scr_memsetw(start, vc->vc_video_erase_char, 2 * count); in csi_J()
1182 if (DO_UPDATE(vc)) in csi_J()
1183 do_update_region(vc, (unsigned long) start, count); in csi_J()
1184 vc->vc_need_wrap = 0; in csi_J()
1187 static void csi_K(struct vc_data *vc, int vpar) in csi_K() argument
1194 count = vc->vc_cols - vc->vc_x; in csi_K()
1195 start = (unsigned short *)vc->vc_pos; in csi_K()
1198 start = (unsigned short *)(vc->vc_pos - (vc->vc_x << 1)); in csi_K()
1199 count = vc->vc_x + 1; in csi_K()
1202 start = (unsigned short *)(vc->vc_pos - (vc->vc_x << 1)); in csi_K()
1203 count = vc->vc_cols; in csi_K()
1208 scr_memsetw(start, vc->vc_video_erase_char, 2 * count); in csi_K()
1209 vc->vc_need_wrap = 0; in csi_K()
1210 if (DO_UPDATE(vc)) in csi_K()
1211 do_update_region(vc, (unsigned long) start, count); in csi_K()
1214 static void csi_X(struct vc_data *vc, int vpar) /* erase the following vpar positions */ in csi_X() argument
1220 count = (vpar > vc->vc_cols - vc->vc_x) ? (vc->vc_cols - vc->vc_x) : vpar; in csi_X()
1222 scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count); in csi_X()
1223 if (DO_UPDATE(vc)) in csi_X()
1224 vc->vc_sw->con_clear(vc, vc->vc_y, vc->vc_x, 1, count); in csi_X()
1225 vc->vc_need_wrap = 0; in csi_X()
1228 static void default_attr(struct vc_data *vc) in default_attr() argument
1230 vc->vc_intensity = 1; in default_attr()
1231 vc->vc_italic = 0; in default_attr()
1232 vc->vc_underline = 0; in default_attr()
1233 vc->vc_reverse = 0; in default_attr()
1234 vc->vc_blink = 0; in default_attr()
1235 vc->vc_color = vc->vc_def_color; in default_attr()
1260 static void rgb_foreground(struct vc_data *vc, struct rgb c) in rgb_foreground() argument
1271 hue = 0, vc->vc_intensity = 2; in rgb_foreground()
1273 vc->vc_intensity = (max > 0xaa) + 1; in rgb_foreground()
1274 vc->vc_color = (vc->vc_color & 0xf0) | hue; in rgb_foreground()
1277 static void rgb_background(struct vc_data *vc, struct rgb c) in rgb_background() argument
1280 vc->vc_color = (vc->vc_color & 0x0f) in rgb_background()
1285 static void csi_m(struct vc_data *vc) in csi_m() argument
1289 for (i = 0; i <= vc->vc_npar; i++) in csi_m()
1290 switch (vc->vc_par[i]) { in csi_m()
1292 default_attr(vc); in csi_m()
1295 vc->vc_intensity = 2; in csi_m()
1298 vc->vc_intensity = 0; in csi_m()
1301 vc->vc_italic = 1; in csi_m()
1304 vc->vc_underline = 1; in csi_m()
1307 vc->vc_blink = 1; in csi_m()
1310 vc->vc_reverse = 1; in csi_m()
1317 vc->vc_translate = set_translate(vc->vc_charset == 0 in csi_m()
1318 ? vc->vc_G0_charset in csi_m()
1319 : vc->vc_G1_charset, vc); in csi_m()
1320 vc->vc_disp_ctrl = 0; in csi_m()
1321 vc->vc_toggle_meta = 0; in csi_m()
1327 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1328 vc->vc_disp_ctrl = 1; in csi_m()
1329 vc->vc_toggle_meta = 0; in csi_m()
1335 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1336 vc->vc_disp_ctrl = 1; in csi_m()
1337 vc->vc_toggle_meta = 1; in csi_m()
1341 vc->vc_intensity = 1; in csi_m()
1344 vc->vc_italic = 0; in csi_m()
1347 vc->vc_underline = 0; in csi_m()
1350 vc->vc_blink = 0; in csi_m()
1353 vc->vc_reverse = 0; in csi_m()
1365 if (i > vc->vc_npar) in csi_m()
1367 if (vc->vc_par[i] == 5 && /* 256 colours */ in csi_m()
1368 i < vc->vc_npar) { /* ubiquitous */ in csi_m()
1370 rgb_foreground(vc, in csi_m()
1371 rgb_from_256(vc->vc_par[i])); in csi_m()
1372 } else if (vc->vc_par[i] == 2 && /* 24 bit */ in csi_m()
1373 i <= vc->vc_npar + 3) {/* extremely rare */ in csi_m()
1375 .r = vc->vc_par[i + 1], in csi_m()
1376 .g = vc->vc_par[i + 2], in csi_m()
1377 .b = vc->vc_par[i + 3], in csi_m()
1379 rgb_foreground(vc, c); in csi_m()
1388 if (i > vc->vc_npar) in csi_m()
1390 if (vc->vc_par[i] == 5 && /* 256 colours */ in csi_m()
1391 i < vc->vc_npar) { in csi_m()
1393 rgb_background(vc, in csi_m()
1394 rgb_from_256(vc->vc_par[i])); in csi_m()
1395 } else if (vc->vc_par[i] == 2 && /* 24 bit */ in csi_m()
1396 i <= vc->vc_npar + 3) { in csi_m()
1398 .r = vc->vc_par[i + 1], in csi_m()
1399 .g = vc->vc_par[i + 2], in csi_m()
1400 .b = vc->vc_par[i + 3], in csi_m()
1402 rgb_background(vc, c); in csi_m()
1407 vc->vc_color = (vc->vc_def_color & 0x0f) | (vc->vc_color & 0xf0); in csi_m()
1410 vc->vc_color = (vc->vc_def_color & 0xf0) | (vc->vc_color & 0x0f); in csi_m()
1413 if (vc->vc_par[i] >= 30 && vc->vc_par[i] <= 37) in csi_m()
1414 vc->vc_color = color_table[vc->vc_par[i] - 30] in csi_m()
1415 | (vc->vc_color & 0xf0); in csi_m()
1416 else if (vc->vc_par[i] >= 40 && vc->vc_par[i] <= 47) in csi_m()
1417 vc->vc_color = (color_table[vc->vc_par[i] - 40] << 4) in csi_m()
1418 | (vc->vc_color & 0x0f); in csi_m()
1421 update_attr(vc); in csi_m()
1433 static void cursor_report(struct vc_data *vc, struct tty_struct *tty) in cursor_report() argument
1437 sprintf(buf, "\033[%d;%dR", vc->vc_y + (vc->vc_decom ? vc->vc_top + 1 : 1), vc->vc_x + 1); in cursor_report()
1467 static void set_mode(struct vc_data *vc, int on_off) in set_mode() argument
1471 for (i = 0; i <= vc->vc_npar; i++) in set_mode()
1472 if (vc->vc_ques) { in set_mode()
1473 switch(vc->vc_par[i]) { /* DEC private modes set/reset */ in set_mode()
1476 set_kbd(vc, decckm); in set_mode()
1478 clr_kbd(vc, decckm); in set_mode()
1481 vc->vc_deccolm = on_off; in set_mode()
1483 vc_resize(deccolm ? 132 : 80, vc->vc_rows); in set_mode()
1489 if (vc->vc_decscnm != on_off) { in set_mode()
1490 vc->vc_decscnm = on_off; in set_mode()
1491 invert_screen(vc, 0, vc->vc_screenbuf_size, 0); in set_mode()
1492 update_attr(vc); in set_mode()
1496 vc->vc_decom = on_off; in set_mode()
1497 gotoxay(vc, 0, 0); in set_mode()
1500 vc->vc_decawm = on_off; in set_mode()
1504 set_kbd(vc, decarm); in set_mode()
1506 clr_kbd(vc, decarm); in set_mode()
1509 vc->vc_report_mouse = on_off ? 1 : 0; in set_mode()
1512 vc->vc_deccm = on_off; in set_mode()
1515 vc->vc_report_mouse = on_off ? 2 : 0; in set_mode()
1519 switch(vc->vc_par[i]) { /* ANSI modes set/reset */ in set_mode()
1521 vc->vc_disp_ctrl = on_off; in set_mode()
1524 vc->vc_decim = on_off; in set_mode()
1528 set_kbd(vc, lnm); in set_mode()
1530 clr_kbd(vc, lnm); in set_mode()
1537 static void setterm_command(struct vc_data *vc) in setterm_command() argument
1539 switch(vc->vc_par[0]) { in setterm_command()
1541 if (vc->vc_can_do_color && in setterm_command()
1542 vc->vc_par[1] < 16) { in setterm_command()
1543 vc->vc_ulcolor = color_table[vc->vc_par[1]]; in setterm_command()
1544 if (vc->vc_underline) in setterm_command()
1545 update_attr(vc); in setterm_command()
1549 if (vc->vc_can_do_color && in setterm_command()
1550 vc->vc_par[1] < 16) { in setterm_command()
1551 vc->vc_halfcolor = color_table[vc->vc_par[1]]; in setterm_command()
1552 if (vc->vc_intensity == 0) in setterm_command()
1553 update_attr(vc); in setterm_command()
1557 vc->vc_def_color = vc->vc_attr; in setterm_command()
1558 if (vc->vc_hi_font_mask == 0x100) in setterm_command()
1559 vc->vc_def_color >>= 1; in setterm_command()
1560 default_attr(vc); in setterm_command()
1561 update_attr(vc); in setterm_command()
1564 blankinterval = ((vc->vc_par[1] < 60) ? vc->vc_par[1] : 60) * 60; in setterm_command()
1568 if (vc->vc_npar >= 1) in setterm_command()
1569 vc->vc_bell_pitch = vc->vc_par[1]; in setterm_command()
1571 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in setterm_command()
1574 if (vc->vc_npar >= 1) in setterm_command()
1575 vc->vc_bell_duration = (vc->vc_par[1] < 2000) ? in setterm_command()
1576 msecs_to_jiffies(vc->vc_par[1]) : 0; in setterm_command()
1578 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in setterm_command()
1581 if (vc->vc_par[1] >= 1 && vc_cons_allocated(vc->vc_par[1] - 1)) in setterm_command()
1582 set_console(vc->vc_par[1] - 1); in setterm_command()
1588 vesa_off_interval = ((vc->vc_par[1] < 60) ? vc->vc_par[1] : 60) * 60 * HZ; in setterm_command()
1597 static void csi_at(struct vc_data *vc, unsigned int nr) in csi_at() argument
1599 if (nr > vc->vc_cols - vc->vc_x) in csi_at()
1600 nr = vc->vc_cols - vc->vc_x; in csi_at()
1603 insert_char(vc, nr); in csi_at()
1607 static void csi_L(struct vc_data *vc, unsigned int nr) in csi_L() argument
1609 if (nr > vc->vc_rows - vc->vc_y) in csi_L()
1610 nr = vc->vc_rows - vc->vc_y; in csi_L()
1613 scrdown(vc, vc->vc_y, vc->vc_bottom, nr); in csi_L()
1614 vc->vc_need_wrap = 0; in csi_L()
1618 static void csi_P(struct vc_data *vc, unsigned int nr) in csi_P() argument
1620 if (nr > vc->vc_cols - vc->vc_x) in csi_P()
1621 nr = vc->vc_cols - vc->vc_x; in csi_P()
1624 delete_char(vc, nr); in csi_P()
1628 static void csi_M(struct vc_data *vc, unsigned int nr) in csi_M() argument
1630 if (nr > vc->vc_rows - vc->vc_y) in csi_M()
1631 nr = vc->vc_rows - vc->vc_y; in csi_M()
1634 scrup(vc, vc->vc_y, vc->vc_bottom, nr); in csi_M()
1635 vc->vc_need_wrap = 0; in csi_M()
1639 static void save_cur(struct vc_data *vc) in save_cur() argument
1641 vc->vc_saved_x = vc->vc_x; in save_cur()
1642 vc->vc_saved_y = vc->vc_y; in save_cur()
1643 vc->vc_s_intensity = vc->vc_intensity; in save_cur()
1644 vc->vc_s_italic = vc->vc_italic; in save_cur()
1645 vc->vc_s_underline = vc->vc_underline; in save_cur()
1646 vc->vc_s_blink = vc->vc_blink; in save_cur()
1647 vc->vc_s_reverse = vc->vc_reverse; in save_cur()
1648 vc->vc_s_charset = vc->vc_charset; in save_cur()
1649 vc->vc_s_color = vc->vc_color; in save_cur()
1650 vc->vc_saved_G0 = vc->vc_G0_charset; in save_cur()
1651 vc->vc_saved_G1 = vc->vc_G1_charset; in save_cur()
1655 static void restore_cur(struct vc_data *vc) in restore_cur() argument
1657 gotoxy(vc, vc->vc_saved_x, vc->vc_saved_y); in restore_cur()
1658 vc->vc_intensity = vc->vc_s_intensity; in restore_cur()
1659 vc->vc_italic = vc->vc_s_italic; in restore_cur()
1660 vc->vc_underline = vc->vc_s_underline; in restore_cur()
1661 vc->vc_blink = vc->vc_s_blink; in restore_cur()
1662 vc->vc_reverse = vc->vc_s_reverse; in restore_cur()
1663 vc->vc_charset = vc->vc_s_charset; in restore_cur()
1664 vc->vc_color = vc->vc_s_color; in restore_cur()
1665 vc->vc_G0_charset = vc->vc_saved_G0; in restore_cur()
1666 vc->vc_G1_charset = vc->vc_saved_G1; in restore_cur()
1667 vc->vc_translate = set_translate(vc->vc_charset ? vc->vc_G1_charset : vc->vc_G0_charset, vc); in restore_cur()
1668 update_attr(vc); in restore_cur()
1669 vc->vc_need_wrap = 0; in restore_cur()
1677 static void reset_terminal(struct vc_data *vc, int do_clear) in reset_terminal() argument
1679 vc->vc_top = 0; in reset_terminal()
1680 vc->vc_bottom = vc->vc_rows; in reset_terminal()
1681 vc->vc_state = ESnormal; in reset_terminal()
1682 vc->vc_ques = 0; in reset_terminal()
1683 vc->vc_translate = set_translate(LAT1_MAP, vc); in reset_terminal()
1684 vc->vc_G0_charset = LAT1_MAP; in reset_terminal()
1685 vc->vc_G1_charset = GRAF_MAP; in reset_terminal()
1686 vc->vc_charset = 0; in reset_terminal()
1687 vc->vc_need_wrap = 0; in reset_terminal()
1688 vc->vc_report_mouse = 0; in reset_terminal()
1689 vc->vc_utf = default_utf8; in reset_terminal()
1690 vc->vc_utf_count = 0; in reset_terminal()
1692 vc->vc_disp_ctrl = 0; in reset_terminal()
1693 vc->vc_toggle_meta = 0; in reset_terminal()
1695 vc->vc_decscnm = 0; in reset_terminal()
1696 vc->vc_decom = 0; in reset_terminal()
1697 vc->vc_decawm = 1; in reset_terminal()
1698 vc->vc_deccm = global_cursor_default; in reset_terminal()
1699 vc->vc_decim = 0; in reset_terminal()
1701 vt_reset_keyboard(vc->vc_num); in reset_terminal()
1703 vc->vc_cursor_type = cur_default; in reset_terminal()
1704 vc->vc_complement_mask = vc->vc_s_complement_mask; in reset_terminal()
1706 default_attr(vc); in reset_terminal()
1707 update_attr(vc); in reset_terminal()
1709 vc->vc_tab_stop[0] = 0x01010100; in reset_terminal()
1710 vc->vc_tab_stop[1] = in reset_terminal()
1711 vc->vc_tab_stop[2] = in reset_terminal()
1712 vc->vc_tab_stop[3] = in reset_terminal()
1713 vc->vc_tab_stop[4] = in reset_terminal()
1714 vc->vc_tab_stop[5] = in reset_terminal()
1715 vc->vc_tab_stop[6] = in reset_terminal()
1716 vc->vc_tab_stop[7] = 0x01010101; in reset_terminal()
1718 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in reset_terminal()
1719 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in reset_terminal()
1721 gotoxy(vc, 0, 0); in reset_terminal()
1722 save_cur(vc); in reset_terminal()
1724 csi_J(vc, 2); in reset_terminal()
1728 static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) in do_con_trol() argument
1734 if (vc->vc_state == ESosc && c>=8 && c<=13) /* ... except for OSC */ in do_con_trol()
1740 if (vc->vc_state == ESosc) in do_con_trol()
1741 vc->vc_state = ESnormal; in do_con_trol()
1742 else if (vc->vc_bell_duration) in do_con_trol()
1743 kd_mksound(vc->vc_bell_pitch, vc->vc_bell_duration); in do_con_trol()
1746 bs(vc); in do_con_trol()
1749 vc->vc_pos -= (vc->vc_x << 1); in do_con_trol()
1750 while (vc->vc_x < vc->vc_cols - 1) { in do_con_trol()
1751 vc->vc_x++; in do_con_trol()
1752 if (vc->vc_tab_stop[vc->vc_x >> 5] & (1 << (vc->vc_x & 31))) in do_con_trol()
1755 vc->vc_pos += (vc->vc_x << 1); in do_con_trol()
1756 notify_write(vc, '\t'); in do_con_trol()
1759 lf(vc); in do_con_trol()
1760 if (!is_kbd(vc, lnm)) in do_con_trol()
1763 cr(vc); in do_con_trol()
1766 vc->vc_charset = 1; in do_con_trol()
1767 vc->vc_translate = set_translate(vc->vc_G1_charset, vc); in do_con_trol()
1768 vc->vc_disp_ctrl = 1; in do_con_trol()
1771 vc->vc_charset = 0; in do_con_trol()
1772 vc->vc_translate = set_translate(vc->vc_G0_charset, vc); in do_con_trol()
1773 vc->vc_disp_ctrl = 0; in do_con_trol()
1776 vc->vc_state = ESnormal; in do_con_trol()
1779 vc->vc_state = ESesc; in do_con_trol()
1782 del(vc); in do_con_trol()
1785 vc->vc_state = ESsquare; in do_con_trol()
1788 switch(vc->vc_state) { in do_con_trol()
1790 vc->vc_state = ESnormal; in do_con_trol()
1793 vc->vc_state = ESsquare; in do_con_trol()
1796 vc->vc_state = ESnonstd; in do_con_trol()
1799 vc->vc_state = ESpercent; in do_con_trol()
1802 cr(vc); in do_con_trol()
1803 lf(vc); in do_con_trol()
1806 ri(vc); in do_con_trol()
1809 lf(vc); in do_con_trol()
1812 vc->vc_tab_stop[vc->vc_x >> 5] |= (1 << (vc->vc_x & 31)); in do_con_trol()
1818 save_cur(vc); in do_con_trol()
1821 restore_cur(vc); in do_con_trol()
1824 vc->vc_state = ESsetG0; in do_con_trol()
1827 vc->vc_state = ESsetG1; in do_con_trol()
1830 vc->vc_state = EShash; in do_con_trol()
1833 reset_terminal(vc, 1); in do_con_trol()
1836 clr_kbd(vc, kbdapplic); in do_con_trol()
1839 set_kbd(vc, kbdapplic); in do_con_trol()
1845 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) in do_con_trol()
1846 vc->vc_par[vc->vc_npar] = 0; in do_con_trol()
1847 vc->vc_npar = 0; in do_con_trol()
1848 vc->vc_state = ESpalette; in do_con_trol()
1851 reset_palette(vc); in do_con_trol()
1852 vc->vc_state = ESnormal; in do_con_trol()
1854 vc->vc_state = ESosc; in do_con_trol()
1856 vc->vc_state = ESnormal; in do_con_trol()
1860 vc->vc_par[vc->vc_npar++] = hex_to_bin(c); in do_con_trol()
1861 if (vc->vc_npar == 7) { in do_con_trol()
1862 int i = vc->vc_par[0] * 3, j = 1; in do_con_trol()
1863 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
1864 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
1865 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
1866 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
1867 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
1868 vc->vc_palette[i] += vc->vc_par[j]; in do_con_trol()
1869 set_palette(vc); in do_con_trol()
1870 vc->vc_state = ESnormal; in do_con_trol()
1873 vc->vc_state = ESnormal; in do_con_trol()
1876 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) in do_con_trol()
1877 vc->vc_par[vc->vc_npar] = 0; in do_con_trol()
1878 vc->vc_npar = 0; in do_con_trol()
1879 vc->vc_state = ESgetpars; in do_con_trol()
1881 vc->vc_state=ESfunckey; in do_con_trol()
1884 vc->vc_ques = (c == '?'); in do_con_trol()
1885 if (vc->vc_ques) in do_con_trol()
1888 if (c == ';' && vc->vc_npar < NPAR - 1) { in do_con_trol()
1889 vc->vc_npar++; in do_con_trol()
1892 vc->vc_par[vc->vc_npar] *= 10; in do_con_trol()
1893 vc->vc_par[vc->vc_npar] += c - '0'; in do_con_trol()
1896 vc->vc_state = ESnormal; in do_con_trol()
1899 set_mode(vc, 1); in do_con_trol()
1902 set_mode(vc, 0); in do_con_trol()
1905 if (vc->vc_ques) { in do_con_trol()
1906 if (vc->vc_par[0]) in do_con_trol()
1907 vc->vc_cursor_type = vc->vc_par[0] | (vc->vc_par[1] << 8) | (vc->vc_par[2] << 16); in do_con_trol()
1909 vc->vc_cursor_type = cur_default; in do_con_trol()
1914 if (vc->vc_ques) { in do_con_trol()
1916 if (vc->vc_par[0]) in do_con_trol()
1917 vc->vc_complement_mask = vc->vc_par[0] << 8 | vc->vc_par[1]; in do_con_trol()
1919 vc->vc_complement_mask = vc->vc_s_complement_mask; in do_con_trol()
1924 if (!vc->vc_ques) { in do_con_trol()
1925 if (vc->vc_par[0] == 5) in do_con_trol()
1927 else if (vc->vc_par[0] == 6) in do_con_trol()
1928 cursor_report(vc, tty); in do_con_trol()
1932 if (vc->vc_ques) { in do_con_trol()
1933 vc->vc_ques = 0; in do_con_trol()
1938 if (vc->vc_par[0]) in do_con_trol()
1939 vc->vc_par[0]--; in do_con_trol()
1940 gotoxy(vc, vc->vc_par[0], vc->vc_y); in do_con_trol()
1943 if (!vc->vc_par[0]) in do_con_trol()
1944 vc->vc_par[0]++; in do_con_trol()
1945 gotoxy(vc, vc->vc_x, vc->vc_y - vc->vc_par[0]); in do_con_trol()
1948 if (!vc->vc_par[0]) in do_con_trol()
1949 vc->vc_par[0]++; in do_con_trol()
1950 gotoxy(vc, vc->vc_x, vc->vc_y + vc->vc_par[0]); in do_con_trol()
1953 if (!vc->vc_par[0]) in do_con_trol()
1954 vc->vc_par[0]++; in do_con_trol()
1955 gotoxy(vc, vc->vc_x + vc->vc_par[0], vc->vc_y); in do_con_trol()
1958 if (!vc->vc_par[0]) in do_con_trol()
1959 vc->vc_par[0]++; in do_con_trol()
1960 gotoxy(vc, vc->vc_x - vc->vc_par[0], vc->vc_y); in do_con_trol()
1963 if (!vc->vc_par[0]) in do_con_trol()
1964 vc->vc_par[0]++; in do_con_trol()
1965 gotoxy(vc, 0, vc->vc_y + vc->vc_par[0]); in do_con_trol()
1968 if (!vc->vc_par[0]) in do_con_trol()
1969 vc->vc_par[0]++; in do_con_trol()
1970 gotoxy(vc, 0, vc->vc_y - vc->vc_par[0]); in do_con_trol()
1973 if (vc->vc_par[0]) in do_con_trol()
1974 vc->vc_par[0]--; in do_con_trol()
1975 gotoxay(vc, vc->vc_x ,vc->vc_par[0]); in do_con_trol()
1978 if (vc->vc_par[0]) in do_con_trol()
1979 vc->vc_par[0]--; in do_con_trol()
1980 if (vc->vc_par[1]) in do_con_trol()
1981 vc->vc_par[1]--; in do_con_trol()
1982 gotoxay(vc, vc->vc_par[1], vc->vc_par[0]); in do_con_trol()
1985 csi_J(vc, vc->vc_par[0]); in do_con_trol()
1988 csi_K(vc, vc->vc_par[0]); in do_con_trol()
1991 csi_L(vc, vc->vc_par[0]); in do_con_trol()
1994 csi_M(vc, vc->vc_par[0]); in do_con_trol()
1997 csi_P(vc, vc->vc_par[0]); in do_con_trol()
2000 if (!vc->vc_par[0]) in do_con_trol()
2004 if (!vc->vc_par[0]) in do_con_trol()
2005 vc->vc_tab_stop[vc->vc_x >> 5] &= ~(1 << (vc->vc_x & 31)); in do_con_trol()
2006 else if (vc->vc_par[0] == 3) { in do_con_trol()
2007 vc->vc_tab_stop[0] = in do_con_trol()
2008 vc->vc_tab_stop[1] = in do_con_trol()
2009 vc->vc_tab_stop[2] = in do_con_trol()
2010 vc->vc_tab_stop[3] = in do_con_trol()
2011 vc->vc_tab_stop[4] = in do_con_trol()
2012 vc->vc_tab_stop[5] = in do_con_trol()
2013 vc->vc_tab_stop[6] = in do_con_trol()
2014 vc->vc_tab_stop[7] = 0; in do_con_trol()
2018 csi_m(vc); in do_con_trol()
2022 if (vc->vc_par[0] < 4) in do_con_trol()
2023 vt_set_led_state(vc->vc_num, in do_con_trol()
2024 (vc->vc_par[0] < 3) ? vc->vc_par[0] : 4); in do_con_trol()
2027 if (!vc->vc_par[0]) in do_con_trol()
2028 vc->vc_par[0]++; in do_con_trol()
2029 if (!vc->vc_par[1]) in do_con_trol()
2030 vc->vc_par[1] = vc->vc_rows; in do_con_trol()
2032 if (vc->vc_par[0] < vc->vc_par[1] && in do_con_trol()
2033 vc->vc_par[1] <= vc->vc_rows) { in do_con_trol()
2034 vc->vc_top = vc->vc_par[0] - 1; in do_con_trol()
2035 vc->vc_bottom = vc->vc_par[1]; in do_con_trol()
2036 gotoxay(vc, 0, 0); in do_con_trol()
2040 save_cur(vc); in do_con_trol()
2043 restore_cur(vc); in do_con_trol()
2046 csi_X(vc, vc->vc_par[0]); in do_con_trol()
2049 csi_at(vc, vc->vc_par[0]); in do_con_trol()
2052 setterm_command(vc); in do_con_trol()
2057 vc->vc_state = ESnormal; in do_con_trol()
2060 vc->vc_utf = 0; in do_con_trol()
2064 vc->vc_utf = 1; in do_con_trol()
2069 vc->vc_state = ESnormal; in do_con_trol()
2072 vc->vc_state = ESnormal; in do_con_trol()
2075 vc->vc_video_erase_char = in do_con_trol()
2076 (vc->vc_video_erase_char & 0xff00) | 'E'; in do_con_trol()
2077 csi_J(vc, 2); in do_con_trol()
2078 vc->vc_video_erase_char = in do_con_trol()
2079 (vc->vc_video_erase_char & 0xff00) | ' '; in do_con_trol()
2080 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in do_con_trol()
2085 vc->vc_G0_charset = GRAF_MAP; in do_con_trol()
2087 vc->vc_G0_charset = LAT1_MAP; in do_con_trol()
2089 vc->vc_G0_charset = IBMPC_MAP; in do_con_trol()
2091 vc->vc_G0_charset = USER_MAP; in do_con_trol()
2092 if (vc->vc_charset == 0) in do_con_trol()
2093 vc->vc_translate = set_translate(vc->vc_G0_charset, vc); in do_con_trol()
2094 vc->vc_state = ESnormal; in do_con_trol()
2098 vc->vc_G1_charset = GRAF_MAP; in do_con_trol()
2100 vc->vc_G1_charset = LAT1_MAP; in do_con_trol()
2102 vc->vc_G1_charset = IBMPC_MAP; in do_con_trol()
2104 vc->vc_G1_charset = USER_MAP; in do_con_trol()
2105 if (vc->vc_charset == 1) in do_con_trol()
2106 vc->vc_translate = set_translate(vc->vc_G1_charset, vc); in do_con_trol()
2107 vc->vc_state = ESnormal; in do_con_trol()
2112 vc->vc_state = ESnormal; in do_con_trol()
2162 vc->vc_sw->con_putcs(vc, (u16 *)draw_from, (u16 *)draw_to - (u16 *)draw_from, vc->vc_y, draw_x); \ in do_con_write()
2170 struct vc_data *vc; in do_con_write() local
2184 vc = tty->driver_data; in do_con_write()
2185 if (vc == NULL) { in do_con_write()
2191 currcons = vc->vc_num; in do_con_write()
2199 himask = vc->vc_hi_font_mask; in do_con_write()
2203 if (IS_FG(vc)) in do_con_write()
2204 hide_cursor(vc); in do_con_write()
2206 param.vc = vc; in do_con_write()
2219 if (vc->vc_state != ESnormal) { in do_con_write()
2221 } else if (vc->vc_utf && !vc->vc_disp_ctrl) { in do_con_write()
2232 if (vc->vc_utf_count) { in do_con_write()
2233 vc->vc_utf_char = (vc->vc_utf_char << 6) | (c & 0x3f); in do_con_write()
2234 vc->vc_npar++; in do_con_write()
2235 if (--vc->vc_utf_count) { in do_con_write()
2240 c = vc->vc_utf_char; in do_con_write()
2242 if (c <= utf8_length_changes[vc->vc_npar - 1] || in do_con_write()
2243 c > utf8_length_changes[vc->vc_npar]) in do_con_write()
2247 vc->vc_utf_count = 0; in do_con_write()
2252 if (vc->vc_utf_count) { in do_con_write()
2255 vc->vc_utf_count = 0; in do_con_write()
2259 vc->vc_npar = 0; in do_con_write()
2261 vc->vc_utf_count = 1; in do_con_write()
2262 vc->vc_utf_char = (c & 0x1f); in do_con_write()
2264 vc->vc_utf_count = 2; in do_con_write()
2265 vc->vc_utf_char = (c & 0x0f); in do_con_write()
2267 vc->vc_utf_count = 3; in do_con_write()
2268 vc->vc_utf_char = (c & 0x07); in do_con_write()
2270 vc->vc_utf_count = 4; in do_con_write()
2271 vc->vc_utf_char = (c & 0x03); in do_con_write()
2273 vc->vc_utf_count = 5; in do_con_write()
2274 vc->vc_utf_char = (c & 0x01); in do_con_write()
2279 if (vc->vc_utf_count) { in do_con_write()
2293 tc = vc_translate(vc, c); in do_con_write()
2312 !(vc->vc_disp_ctrl ? (CTRL_ALWAYS >> c) & 1 : in do_con_write()
2313 vc->vc_utf || ((CTRL_ACTION >> c) & 1))) in do_con_write()
2314 && (c != 127 || vc->vc_disp_ctrl) in do_con_write()
2317 if (vc->vc_state == ESnormal && ok) { in do_con_write()
2318 if (vc->vc_utf && !vc->vc_disp_ctrl) { in do_con_write()
2323 tc = conv_uni_to_pc(vc, tc); in do_con_write()
2329 if ((!(vc->vc_utf && !vc->vc_disp_ctrl) || c < 128) && !(c & ~charmask)) { in do_con_write()
2338 tc = conv_uni_to_pc(vc, 0xfffd); in do_con_write()
2341 tc = conv_uni_to_pc(vc, '?'); in do_con_write()
2348 vc_attr = vc->vc_attr; in do_con_write()
2351 if (!vc->vc_can_do_color) { in do_con_write()
2352 vc_attr = (vc->vc_attr) ^ 0x08; in do_con_write()
2353 } else if (vc->vc_hi_font_mask == 0x100) { in do_con_write()
2354 … vc_attr = ((vc->vc_attr) & 0x11) | (((vc->vc_attr) & 0xe0) >> 4) | (((vc->vc_attr) & 0x0e) << 4); in do_con_write()
2356 … vc_attr = ((vc->vc_attr) & 0x88) | (((vc->vc_attr) & 0x70) >> 4) | (((vc->vc_attr) & 0x07) << 4); in do_con_write()
2362 if (vc->vc_need_wrap || vc->vc_decim) in do_con_write()
2364 if (vc->vc_need_wrap) { in do_con_write()
2365 cr(vc); in do_con_write()
2366 lf(vc); in do_con_write()
2368 if (vc->vc_decim) in do_con_write()
2369 insert_char(vc, 1); in do_con_write()
2373 (u16 *) vc->vc_pos); in do_con_write()
2374 if (DO_UPDATE(vc) && draw_x < 0) { in do_con_write()
2375 draw_x = vc->vc_x; in do_con_write()
2376 draw_from = vc->vc_pos; in do_con_write()
2378 if (vc->vc_x == vc->vc_cols - 1) { in do_con_write()
2379 vc->vc_need_wrap = vc->vc_decawm; in do_con_write()
2380 draw_to = vc->vc_pos + 2; in do_con_write()
2382 vc->vc_x++; in do_con_write()
2383 draw_to = (vc->vc_pos += 2); in do_con_write()
2388 tc = conv_uni_to_pc(vc, ' '); /* A space is printed in the second column */ in do_con_write()
2391 notify_write(vc, c); in do_con_write()
2407 do_con_trol(tty, vc, orig); in do_con_write()
2412 notify_update(vc); in do_con_write()
2446 struct vc_data *vc = vc_cons[fg_console].d; in console_callback() local
2448 if (vc->vc_mode == KD_TEXT) in console_callback()
2449 vc->vc_sw->con_scrolldelta(vc, scrollback_delta); in console_callback()
2463 struct vc_data *vc = vc_cons[fg_console].d; in set_console() local
2466 (vc->vt_mode.mode == VT_AUTO && vc->vc_mode == KD_GRAPHICS)) { in set_console()
2528 struct vc_data *vc = vc_cons[fg_console].d; in vt_console_print() local
2544 vc = vc_cons[kmsg_console - 1].d; in vt_console_print()
2548 myx = vc->vc_x; in vt_console_print()
2556 if (vc->vc_mode != KD_TEXT && !vt_force_oops_output(vc)) in vt_console_print()
2560 if (IS_FG(vc)) in vt_console_print()
2561 hide_cursor(vc); in vt_console_print()
2563 start = (ushort *)vc->vc_pos; in vt_console_print()
2569 if (c == 10 || c == 13 || c == 8 || vc->vc_need_wrap) { in vt_console_print()
2571 if (CON_IS_VISIBLE(vc)) in vt_console_print()
2572 vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x); in vt_console_print()
2573 vc->vc_x += cnt; in vt_console_print()
2574 if (vc->vc_need_wrap) in vt_console_print()
2575 vc->vc_x--; in vt_console_print()
2579 bs(vc); in vt_console_print()
2580 start = (ushort *)vc->vc_pos; in vt_console_print()
2581 myx = vc->vc_x; in vt_console_print()
2585 lf(vc); in vt_console_print()
2586 cr(vc); in vt_console_print()
2587 start = (ushort *)vc->vc_pos; in vt_console_print()
2588 myx = vc->vc_x; in vt_console_print()
2592 scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos); in vt_console_print()
2593 notify_write(vc, c); in vt_console_print()
2595 if (myx == vc->vc_cols - 1) { in vt_console_print()
2596 vc->vc_need_wrap = 1; in vt_console_print()
2599 vc->vc_pos += 2; in vt_console_print()
2603 if (CON_IS_VISIBLE(vc)) in vt_console_print()
2604 vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x); in vt_console_print()
2605 vc->vc_x += cnt; in vt_console_print()
2606 if (vc->vc_x == vc->vc_cols) { in vt_console_print()
2607 vc->vc_x--; in vt_console_print()
2608 vc->vc_need_wrap = 1; in vt_console_print()
2611 set_cursor(vc); in vt_console_print()
2612 notify_update(vc); in vt_console_print()
2797 struct vc_data *vc = tty->driver_data; in con_unthrottle() local
2799 wake_up_interruptible(&vc->paste_wait); in con_unthrottle()
2832 struct vc_data *vc; in con_flush_chars() local
2839 vc = tty->driver_data; in con_flush_chars()
2840 if (vc) in con_flush_chars()
2841 set_cursor(vc); in con_flush_chars()
2851 struct vc_data *vc; in con_install() local
2859 vc = vc_cons[currcons].d; in con_install()
2862 if (vc->port.tty) { in con_install()
2867 ret = tty_port_install(&vc->port, driver, tty); in con_install()
2871 tty->driver_data = vc; in con_install()
2872 vc->port.tty = tty; in con_install()
2878 if (vc->vc_utf) in con_install()
2901 struct vc_data *vc = tty->driver_data; in con_shutdown() local
2902 BUG_ON(vc == NULL); in con_shutdown()
2904 vc->port.tty = NULL; in con_shutdown()
2915 static void vc_init(struct vc_data *vc, unsigned int rows, in vc_init() argument
2920 vc->vc_cols = cols; in vc_init()
2921 vc->vc_rows = rows; in vc_init()
2922 vc->vc_size_row = cols << 1; in vc_init()
2923 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; in vc_init()
2925 set_origin(vc); in vc_init()
2926 vc->vc_pos = vc->vc_origin; in vc_init()
2927 reset_vc(vc); in vc_init()
2929 vc->vc_palette[k++] = default_red[j] ; in vc_init()
2930 vc->vc_palette[k++] = default_grn[j] ; in vc_init()
2931 vc->vc_palette[k++] = default_blu[j] ; in vc_init()
2933 vc->vc_def_color = default_color; in vc_init()
2934 vc->vc_ulcolor = default_underline_color; in vc_init()
2935 vc->vc_itcolor = default_italic_color; in vc_init()
2936 vc->vc_halfcolor = 0x08; /* grey */ in vc_init()
2937 init_waitqueue_head(&vc->paste_wait); in vc_init()
2938 reset_terminal(vc, do_clear); in vc_init()
2950 struct vc_data *vc; in con_init() local
2985 vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT); in con_init()
2987 tty_port_init(&vc->port); in con_init()
2988 visual_init(vc, currcons, 1); in con_init()
2989 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT); in con_init()
2990 vc_init(vc, vc->vc_rows, vc->vc_cols, in con_init()
2991 currcons || !vc->vc_sw->con_save_screen); in con_init()
2994 master_display_fg = vc = vc_cons[currcons].d; in con_init()
2995 set_origin(vc); in con_init()
2996 save_screen(vc); in con_init()
2997 gotoxy(vc, vc->vc_x, vc->vc_y); in con_init()
2998 csi_J(vc, 0); in con_init()
2999 update_screen(vc); in con_init()
3001 vc->vc_can_do_color ? "colour" : "mono", in con_init()
3002 display_desc, vc->vc_cols, vc->vc_rows); in con_init()
3138 struct vc_data *vc = vc_cons[i].d; in do_bind_con_driver() local
3145 if (!vc || !vc->vc_sw) in do_bind_con_driver()
3150 if (CON_IS_VISIBLE(vc)) { in do_bind_con_driver()
3152 save_screen(vc); in do_bind_con_driver()
3155 old_was_color = vc->vc_can_do_color; in do_bind_con_driver()
3156 vc->vc_sw->con_deinit(vc); in do_bind_con_driver()
3157 vc->vc_origin = (unsigned long)vc->vc_screenbuf; in do_bind_con_driver()
3158 visual_init(vc, i, 0); in do_bind_con_driver()
3159 set_origin(vc); in do_bind_con_driver()
3160 update_attr(vc); in do_bind_con_driver()
3166 if (old_was_color != vc->vc_can_do_color) in do_bind_con_driver()
3167 clear_buffer_attributes(vc); in do_bind_con_driver()
3174 struct vc_data *vc = vc_cons[j].d; in do_bind_con_driver() local
3177 vc->vc_can_do_color ? "colour" : "mono", in do_bind_con_driver()
3178 desc, vc->vc_cols, vc->vc_rows); in do_bind_con_driver()
3181 vc = vc_cons[k].d; in do_bind_con_driver()
3182 update_screen(vc); in do_bind_con_driver()
3200 struct vc_data *vc = vc_cons[i].d; in con_is_graphics() local
3202 if (vc && vc->vc_mode == KD_GRAPHICS) { in con_is_graphics()
3491 int con_debug_enter(struct vc_data *vc) in con_debug_enter() argument
3498 saved_vc_mode = vc->vc_mode; in con_debug_enter()
3500 vc->vc_mode = KD_TEXT; in con_debug_enter()
3502 if (vc->vc_sw->con_debug_enter) in con_debug_enter()
3503 ret = vc->vc_sw->con_debug_enter(vc); in con_debug_enter()
3506 if (vc->vc_rows < 999) { in con_debug_enter()
3515 snprintf(lns, 4, "%i", vc->vc_rows); in con_debug_enter()
3519 if (vc->vc_cols < 999) { in con_debug_enter()
3528 snprintf(cols, 4, "%i", vc->vc_cols); in con_debug_enter()
3550 struct vc_data *vc; in con_debug_leave() local
3559 vc = vc_cons[fg_console].d; in con_debug_leave()
3560 if (vc->vc_sw->con_debug_leave) in con_debug_leave()
3561 ret = vc->vc_sw->con_debug_leave(vc); in con_debug_leave()
3773 struct vc_data *vc = vc_cons[fg_console].d; in do_blank_screen() local
3781 vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0); in do_blank_screen()
3788 hide_cursor(vc); in do_blank_screen()
3789 save_screen(vc); in do_blank_screen()
3790 vc->vc_sw->con_blank(vc, -1, 1); in do_blank_screen()
3793 set_origin(vc); in do_blank_screen()
3802 if (vc->vc_mode != KD_TEXT) { in do_blank_screen()
3807 hide_cursor(vc); in do_blank_screen()
3811 save_screen(vc); in do_blank_screen()
3813 i = vc->vc_sw->con_blank(vc, vesa_off_interval ? 1 : (vesa_blank_mode + 1), 0); in do_blank_screen()
3816 set_origin(vc); in do_blank_screen()
3825 vt_event_post(VT_EVENT_BLANK, vc->vc_num, vc->vc_num); in do_blank_screen()
3834 struct vc_data *vc; in do_unblank_screen() local
3854 vc = vc_cons[fg_console].d; in do_unblank_screen()
3856 if (vc->vc_mode != KD_TEXT && !vt_force_oops_output(vc)) in do_unblank_screen()
3865 if (vc->vc_sw->con_blank(vc, 0, leaving_gfx) || vt_force_oops_output(vc)) in do_unblank_screen()
3867 update_screen(vc); in do_unblank_screen()
3870 set_palette(vc); in do_unblank_screen()
3871 set_cursor(vc); in do_unblank_screen()
3872 vt_event_post(VT_EVENT_UNBLANK, vc->vc_num, vc->vc_num); in do_unblank_screen()
3934 static void set_palette(struct vc_data *vc) in set_palette() argument
3938 if (vc->vc_mode != KD_GRAPHICS) in set_palette()
3939 vc->vc_sw->con_set_palette(vc, color_table); in set_palette()
3995 void reset_palette(struct vc_data *vc) in reset_palette() argument
3999 vc->vc_palette[k++] = default_red[j]; in reset_palette()
4000 vc->vc_palette[k++] = default_grn[j]; in reset_palette()
4001 vc->vc_palette[k++] = default_blu[j]; in reset_palette()
4003 set_palette(vc); in reset_palette()
4021 static int con_font_get(struct vc_data *vc, struct console_font_op *op) in con_font_get() argument
4035 if (vc->vc_mode != KD_TEXT) in con_font_get()
4037 else if (vc->vc_sw->con_font_get) in con_font_get()
4038 rc = vc->vc_sw->con_font_get(vc, &font); in con_font_get()
4075 static int con_font_set(struct vc_data *vc, struct console_font_op *op) in con_font_set() argument
4081 if (vc->vc_mode != KD_TEXT) in con_font_set()
4119 if (vc->vc_mode != KD_TEXT) in con_font_set()
4121 else if (vc->vc_sw->con_font_set) in con_font_set()
4122 rc = vc->vc_sw->con_font_set(vc, &font, op->flags); in con_font_set()
4130 static int con_font_default(struct vc_data *vc, struct console_font_op *op) in con_font_default() argument
4146 if (vc->vc_mode != KD_TEXT) { in con_font_default()
4150 if (vc->vc_sw->con_font_default) in con_font_default()
4151 rc = vc->vc_sw->con_font_default(vc, &font, s); in con_font_default()
4162 static int con_font_copy(struct vc_data *vc, struct console_font_op *op) in con_font_copy() argument
4169 if (vc->vc_mode != KD_TEXT) in con_font_copy()
4171 else if (!vc->vc_sw->con_font_copy) in con_font_copy()
4175 else if (con == vc->vc_num) /* nothing to do */ in con_font_copy()
4178 rc = vc->vc_sw->con_font_copy(vc, con); in con_font_copy()
4183 int con_font_op(struct vc_data *vc, struct console_font_op *op) in con_font_op() argument
4187 return con_font_set(vc, op); in con_font_op()
4189 return con_font_get(vc, op); in con_font_op()
4191 return con_font_default(vc, op); in con_font_op()
4193 return con_font_copy(vc, op); in con_font_op()
4203 u16 screen_glyph(struct vc_data *vc, int offset) in screen_glyph() argument
4205 u16 w = scr_readw(screenpos(vc, offset, 1)); in screen_glyph()
4208 if (w & vc->vc_hi_font_mask) in screen_glyph()
4215 unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed) in screen_pos() argument
4217 return screenpos(vc, 2 * w_offset, viewed); in screen_pos()
4220 void getconsxy(struct vc_data *vc, unsigned char *p) in getconsxy() argument
4222 p[0] = vc->vc_x; in getconsxy()
4223 p[1] = vc->vc_y; in getconsxy()
4226 void putconsxy(struct vc_data *vc, unsigned char *p) in putconsxy() argument
4228 hide_cursor(vc); in putconsxy()
4229 gotoxy(vc, p[0], p[1]); in putconsxy()
4230 set_cursor(vc); in putconsxy()
4233 u16 vcs_scr_readw(struct vc_data *vc, const u16 *org) in vcs_scr_readw() argument
4235 if ((unsigned long)org == vc->vc_pos && softcursor_original != -1) in vcs_scr_readw()
4240 void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org) in vcs_scr_writew() argument
4243 if ((unsigned long)org == vc->vc_pos) { in vcs_scr_writew()
4245 add_softcursor(vc); in vcs_scr_writew()
4249 void vcs_scr_updated(struct vc_data *vc) in vcs_scr_updated() argument
4251 notify_update(vc); in vcs_scr_updated()