• Home
  • Raw
  • Download

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);
259 static void notify_write(struct vc_data *vc, unsigned int unicode) in notify_write() argument
261 struct vt_notifier_param param = { .vc = vc, .c = unicode }; in notify_write()
265 static void notify_update(struct vc_data *vc) in notify_update() argument
267 struct vt_notifier_param param = { .vc = vc }; in notify_update()
274 #define IS_FG(vc) ((vc)->vc_num == fg_console) argument
277 #define DO_UPDATE(vc) 0 argument
279 #define DO_UPDATE(vc) (CON_IS_VISIBLE(vc) && !console_blanked) argument
282 static inline unsigned short *screenpos(struct vc_data *vc, int offset, int viewed) in screenpos() argument
287 p = (unsigned short *)(vc->vc_origin + offset); in screenpos()
288 else if (!vc->vc_sw->con_screen_pos) in screenpos()
289 p = (unsigned short *)(vc->vc_visible_origin + offset); in screenpos()
291 p = vc->vc_sw->con_screen_pos(vc, offset); in screenpos()
310 static void scrup(struct vc_data *vc, unsigned int t, unsigned int b, int nr) in scrup() argument
316 if (b > vc->vc_rows || t >= b || nr < 1) in scrup()
318 if (CON_IS_VISIBLE(vc) && vc->vc_sw->con_scroll(vc, t, b, SM_UP, nr)) in scrup()
320 d = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t); in scrup()
321 s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * (t + nr)); in scrup()
322 scr_memmovew(d, s, (b - t - nr) * vc->vc_size_row); in scrup()
323 scr_memsetw(d + (b - t - nr) * vc->vc_cols, vc->vc_video_erase_char, in scrup()
324 vc->vc_size_row * nr); in scrup()
327 static void scrdown(struct vc_data *vc, unsigned int t, unsigned int b, int nr) in scrdown() argument
334 if (b > vc->vc_rows || t >= b || nr < 1) in scrdown()
336 if (CON_IS_VISIBLE(vc) && vc->vc_sw->con_scroll(vc, t, b, SM_DOWN, nr)) in scrdown()
338 s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t); in scrdown()
339 step = vc->vc_cols * nr; in scrdown()
340 scr_memmovew(s + step, s, (b - t - nr) * vc->vc_size_row); in scrdown()
341 scr_memsetw(s, vc->vc_video_erase_char, 2 * step); in scrdown()
344 static void do_update_region(struct vc_data *vc, unsigned long start, int count) in do_update_region() argument
351 if (!vc->vc_sw->con_getxy) { in do_update_region()
352 offset = (start - vc->vc_origin) / 2; in do_update_region()
353 xx = offset % vc->vc_cols; in do_update_region()
354 yy = offset / vc->vc_cols; in do_update_region()
357 start = vc->vc_sw->con_getxy(vc, start, &nxx, &nyy); in do_update_region()
364 while (xx < vc->vc_cols && count) { in do_update_region()
367 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); in do_update_region()
377 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); in do_update_region()
382 if (vc->vc_sw->con_getxy) { in do_update_region()
384 start = vc->vc_sw->con_getxy(vc, start, NULL, NULL); in do_update_region()
390 void update_region(struct vc_data *vc, unsigned long start, int count) in update_region() argument
394 if (DO_UPDATE(vc)) { in update_region()
395 hide_cursor(vc); in update_region()
396 do_update_region(vc, start, count); in update_region()
397 set_cursor(vc); in update_region()
403 static u8 build_attr(struct vc_data *vc, u8 _color, u8 _intensity, u8 _blink, in build_attr() argument
406 if (vc->vc_sw->con_build_attr) in build_attr()
407 return vc->vc_sw->con_build_attr(vc, _color, _intensity, in build_attr()
423 if (!vc->vc_can_do_color) in build_attr()
430 a = (a & 0xF0) | vc->vc_itcolor; in build_attr()
432 a = (a & 0xf0) | vc->vc_ulcolor; in build_attr()
434 a = (a & 0xf0) | vc->vc_ulcolor; in build_attr()
441 if (vc->vc_hi_font_mask == 0x100) in build_attr()
450 static void update_attr(struct vc_data *vc) in update_attr() argument
452 vc->vc_attr = build_attr(vc, vc->vc_color, vc->vc_intensity, in update_attr()
453 vc->vc_blink, vc->vc_underline, in update_attr()
454 vc->vc_reverse ^ vc->vc_decscnm, vc->vc_italic); in update_attr()
455vc->vc_video_erase_char = (build_attr(vc, vc->vc_color, 1, vc->vc_blink, 0, vc->vc_decscnm, 0) << … in update_attr()
459 void invert_screen(struct vc_data *vc, int offset, int count, int viewed) in invert_screen() argument
466 p = screenpos(vc, offset, viewed); in invert_screen()
467 if (vc->vc_sw->con_invert_region) in invert_screen()
468 vc->vc_sw->con_invert_region(vc, p, count); in invert_screen()
475 if (!vc->vc_can_do_color) { in invert_screen()
482 } else if (vc->vc_hi_font_mask == 0x100) { in invert_screen()
499 if (DO_UPDATE(vc)) in invert_screen()
500 do_update_region(vc, (unsigned long) p, count); in invert_screen()
501 notify_update(vc); in invert_screen()
505 void complement_pos(struct vc_data *vc, int offset) in complement_pos() argument
514 old_offset < vc->vc_screenbuf_size) { in complement_pos()
515 scr_writew(old, screenpos(vc, old_offset, 1)); in complement_pos()
516 if (DO_UPDATE(vc)) in complement_pos()
517 vc->vc_sw->con_putc(vc, old, oldy, oldx); in complement_pos()
518 notify_update(vc); in complement_pos()
524 offset < vc->vc_screenbuf_size) { in complement_pos()
527 p = screenpos(vc, offset, 1); in complement_pos()
529 new = old ^ vc->vc_complement_mask; in complement_pos()
531 if (DO_UPDATE(vc)) { in complement_pos()
532 oldx = (offset >> 1) % vc->vc_cols; in complement_pos()
533 oldy = (offset >> 1) / vc->vc_cols; in complement_pos()
534 vc->vc_sw->con_putc(vc, new, oldy, oldx); in complement_pos()
536 notify_update(vc); in complement_pos()
540 static void insert_char(struct vc_data *vc, unsigned int nr) in insert_char() argument
542 unsigned short *p = (unsigned short *) vc->vc_pos; in insert_char()
544 scr_memmovew(p + nr, p, (vc->vc_cols - vc->vc_x - nr) * 2); in insert_char()
545 scr_memsetw(p, vc->vc_video_erase_char, nr * 2); in insert_char()
546 vc->vc_need_wrap = 0; in insert_char()
547 if (DO_UPDATE(vc)) in insert_char()
548 do_update_region(vc, (unsigned long) p, in insert_char()
549 vc->vc_cols - vc->vc_x); in insert_char()
552 static void delete_char(struct vc_data *vc, unsigned int nr) in delete_char() argument
554 unsigned short *p = (unsigned short *) vc->vc_pos; in delete_char()
556 scr_memcpyw(p, p + nr, (vc->vc_cols - vc->vc_x - nr) * 2); in delete_char()
557 scr_memsetw(p + vc->vc_cols - vc->vc_x - nr, vc->vc_video_erase_char, in delete_char()
559 vc->vc_need_wrap = 0; in delete_char()
560 if (DO_UPDATE(vc)) in delete_char()
561 do_update_region(vc, (unsigned long) p, in delete_char()
562 vc->vc_cols - vc->vc_x); in delete_char()
567 static void add_softcursor(struct vc_data *vc) in add_softcursor() argument
569 int i = scr_readw((u16 *) vc->vc_pos); in add_softcursor()
570 u32 type = vc->vc_cursor_type; in add_softcursor()
579 scr_writew(i, (u16 *) vc->vc_pos); in add_softcursor()
580 if (DO_UPDATE(vc)) in add_softcursor()
581 vc->vc_sw->con_putc(vc, i, vc->vc_y, vc->vc_x); in add_softcursor()
584 static void hide_softcursor(struct vc_data *vc) in hide_softcursor() argument
587 scr_writew(softcursor_original, (u16 *)vc->vc_pos); in hide_softcursor()
588 if (DO_UPDATE(vc)) in hide_softcursor()
589 vc->vc_sw->con_putc(vc, softcursor_original, in hide_softcursor()
590 vc->vc_y, vc->vc_x); in hide_softcursor()
595 static void hide_cursor(struct vc_data *vc) in hide_cursor() argument
597 if (vc == sel_cons) in hide_cursor()
599 vc->vc_sw->con_cursor(vc, CM_ERASE); in hide_cursor()
600 hide_softcursor(vc); in hide_cursor()
603 static void set_cursor(struct vc_data *vc) in set_cursor() argument
605 if (!IS_FG(vc) || console_blanked || in set_cursor()
606 vc->vc_mode == KD_GRAPHICS) in set_cursor()
608 if (vc->vc_deccm) { in set_cursor()
609 if (vc == sel_cons) in set_cursor()
611 add_softcursor(vc); in set_cursor()
612 if ((vc->vc_cursor_type & 0x0f) != 1) in set_cursor()
613 vc->vc_sw->con_cursor(vc, CM_DRAW); in set_cursor()
615 hide_cursor(vc); in set_cursor()
618 static void set_origin(struct vc_data *vc) in set_origin() argument
622 if (!CON_IS_VISIBLE(vc) || in set_origin()
623 !vc->vc_sw->con_set_origin || in set_origin()
624 !vc->vc_sw->con_set_origin(vc)) in set_origin()
625 vc->vc_origin = (unsigned long)vc->vc_screenbuf; in set_origin()
626 vc->vc_visible_origin = vc->vc_origin; in set_origin()
627 vc->vc_scr_end = vc->vc_origin + vc->vc_screenbuf_size; in set_origin()
628 vc->vc_pos = vc->vc_origin + vc->vc_size_row * vc->vc_y + 2 * vc->vc_x; in set_origin()
631 static inline void save_screen(struct vc_data *vc) in save_screen() argument
635 if (vc->vc_sw->con_save_screen) in save_screen()
636 vc->vc_sw->con_save_screen(vc); in save_screen()
643 void clear_buffer_attributes(struct vc_data *vc) in clear_buffer_attributes() argument
645 unsigned short *p = (unsigned short *)vc->vc_origin; in clear_buffer_attributes()
646 int count = vc->vc_screenbuf_size / 2; in clear_buffer_attributes()
647 int mask = vc->vc_hi_font_mask | 0xff; in clear_buffer_attributes()
650 scr_writew((scr_readw(p)&mask) | (vc->vc_video_erase_char & ~mask), p); in clear_buffer_attributes()
654 void redraw_screen(struct vc_data *vc, int is_switch) in redraw_screen() argument
660 if (!vc) { in redraw_screen()
668 if (old_vc == vc) in redraw_screen()
670 if (!CON_IS_VISIBLE(vc)) in redraw_screen()
672 *vc->vc_display_fg = vc; in redraw_screen()
673 fg_console = vc->vc_num; in redraw_screen()
682 hide_cursor(vc); in redraw_screen()
688 int old_was_color = vc->vc_can_do_color; in redraw_screen()
690 set_origin(vc); in redraw_screen()
691 update = vc->vc_sw->con_switch(vc); in redraw_screen()
692 set_palette(vc); in redraw_screen()
699 if (old_was_color != vc->vc_can_do_color) { in redraw_screen()
700 update_attr(vc); in redraw_screen()
701 clear_buffer_attributes(vc); in redraw_screen()
705 if ((update && vc->vc_mode != KD_GRAPHICS) || in redraw_screen()
706 vt_force_oops_output(vc)) in redraw_screen()
707 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in redraw_screen()
709 set_cursor(vc); in redraw_screen()
713 notify_update(vc); in redraw_screen()
726 static void visual_init(struct vc_data *vc, int num, int init) in visual_init() argument
729 if (vc->vc_sw) in visual_init()
730 module_put(vc->vc_sw->owner); in visual_init()
731 vc->vc_sw = conswitchp; in visual_init()
734 vc->vc_sw = con_driver_map[num]; in visual_init()
736 __module_get(vc->vc_sw->owner); in visual_init()
737 vc->vc_num = num; in visual_init()
738 vc->vc_display_fg = &master_display_fg; in visual_init()
739 vc->vc_uni_pagedir_loc = &vc->vc_uni_pagedir; in visual_init()
740 vc->vc_uni_pagedir = NULL; in visual_init()
741 vc->vc_hi_font_mask = 0; in visual_init()
742 vc->vc_complement_mask = 0; in visual_init()
743 vc->vc_can_do_color = 0; in visual_init()
744 vc->vc_panic_force_write = false; in visual_init()
745 vc->vc_sw->con_init(vc, init); in visual_init()
746 if (!vc->vc_complement_mask) in visual_init()
747 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; in visual_init()
748 vc->vc_s_complement_mask = vc->vc_complement_mask; in visual_init()
749 vc->vc_size_row = vc->vc_cols << 1; in visual_init()
750 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; in visual_init()
760 struct vc_data *vc; in vc_allocate() local
773 param.vc = vc = kzalloc(sizeof(struct vc_data), GFP_KERNEL); in vc_allocate()
774 if (!vc) in vc_allocate()
776 vc_cons[currcons].d = vc; in vc_allocate()
777 tty_port_init(&vc->port); in vc_allocate()
779 visual_init(vc, currcons, 1); in vc_allocate()
780 if (!*vc->vc_uni_pagedir_loc) in vc_allocate()
781 con_set_default_unimap(vc); in vc_allocate()
782 vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size, GFP_KERNEL); in vc_allocate()
783 if (!vc->vc_screenbuf) { in vc_allocate()
784 kfree(vc); in vc_allocate()
794 vc_init(vc, vc->vc_rows, vc->vc_cols, 1); in vc_allocate()
801 static inline int resize_screen(struct vc_data *vc, int width, int height, in resize_screen() argument
807 if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_resize) in resize_screen()
808 err = vc->vc_sw->con_resize(vc, width, height, user); in resize_screen()
837 static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, in vc_do_resize() argument
849 if (!vc) in vc_do_resize()
852 user = vc->vc_resize_user; in vc_do_resize()
853 vc->vc_resize_user = 0; in vc_do_resize()
858 new_cols = (cols ? cols : vc->vc_cols); in vc_do_resize()
859 new_rows = (lines ? lines : vc->vc_rows); in vc_do_resize()
863 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) in vc_do_resize()
872 if (vc == sel_cons) in vc_do_resize()
875 old_rows = vc->vc_rows; in vc_do_resize()
876 old_row_size = vc->vc_size_row; in vc_do_resize()
878 err = resize_screen(vc, new_cols, new_rows, user); in vc_do_resize()
884 vc->vc_rows = new_rows; in vc_do_resize()
885 vc->vc_cols = new_cols; in vc_do_resize()
886 vc->vc_size_row = new_row_size; in vc_do_resize()
887 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
891 old_origin = vc->vc_origin; in vc_do_resize()
895 if (vc->vc_y > new_rows) { in vc_do_resize()
896 if (old_rows - vc->vc_y < new_rows) { in vc_do_resize()
907 old_origin += (vc->vc_y - new_rows/2) * old_row_size; in vc_do_resize()
913 update_attr(vc); in vc_do_resize()
920 vc->vc_video_erase_char, rrem); in vc_do_resize()
925 scr_memsetw((void *)new_origin, vc->vc_video_erase_char, in vc_do_resize()
927 kfree(vc->vc_screenbuf); in vc_do_resize()
928 vc->vc_screenbuf = newscreen; in vc_do_resize()
929 vc->vc_screenbuf_size = new_screen_size; in vc_do_resize()
930 set_origin(vc); in vc_do_resize()
933 vc->vc_top = 0; in vc_do_resize()
934 vc->vc_bottom = vc->vc_rows; in vc_do_resize()
935 gotoxy(vc, vc->vc_x, vc->vc_y); in vc_do_resize()
936 save_cur(vc); in vc_do_resize()
943 ws.ws_row = vc->vc_rows; in vc_do_resize()
944 ws.ws_col = vc->vc_cols; in vc_do_resize()
945 ws.ws_ypixel = vc->vc_scan_lines; in vc_do_resize()
949 if (CON_IS_VISIBLE(vc)) in vc_do_resize()
950 update_screen(vc); in vc_do_resize()
951 vt_event_post(VT_EVENT_RESIZE, vc->vc_num, vc->vc_num); in vc_do_resize()
967 int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows) in vc_resize() argument
969 return vc_do_resize(vc->port.tty, vc, cols, rows); in vc_resize()
986 struct vc_data *vc = tty->driver_data; in vt_resize() local
990 ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row); in vt_resize()
997 struct vc_data *vc = NULL; in vc_deallocate() local
1004 param.vc = vc = vc_cons[currcons].d; in vc_deallocate()
1007 vc->vc_sw->con_deinit(vc); in vc_deallocate()
1008 put_pid(vc->vt_pid); in vc_deallocate()
1009 module_put(vc->vc_sw->owner); in vc_deallocate()
1010 kfree(vc->vc_screenbuf); in vc_deallocate()
1013 return vc; in vc_deallocate()
1020 #define set_kbd(vc, x) vt_set_kbd_mode_bit((vc)->vc_num, (x)) argument
1021 #define clr_kbd(vc, x) vt_clr_kbd_mode_bit((vc)->vc_num, (x)) argument
1022 #define is_kbd(vc, x) vt_get_kbd_mode_bit((vc)->vc_num, (x)) argument
1055 static void gotoxy(struct vc_data *vc, int new_x, int new_y) in gotoxy() argument
1060 vc->vc_x = 0; in gotoxy()
1062 if (new_x >= vc->vc_cols) in gotoxy()
1063 vc->vc_x = vc->vc_cols - 1; in gotoxy()
1065 vc->vc_x = new_x; in gotoxy()
1068 if (vc->vc_decom) { in gotoxy()
1069 min_y = vc->vc_top; in gotoxy()
1070 max_y = vc->vc_bottom; in gotoxy()
1073 max_y = vc->vc_rows; in gotoxy()
1076 vc->vc_y = min_y; in gotoxy()
1078 vc->vc_y = max_y - 1; in gotoxy()
1080 vc->vc_y = new_y; in gotoxy()
1081 vc->vc_pos = vc->vc_origin + vc->vc_y * vc->vc_size_row + (vc->vc_x<<1); in gotoxy()
1082 vc->vc_need_wrap = 0; in gotoxy()
1086 static void gotoxay(struct vc_data *vc, int new_x, int new_y) in gotoxay() argument
1088 gotoxy(vc, new_x, vc->vc_decom ? (vc->vc_top + new_y) : new_y); in gotoxay()
1091 void scrollback(struct vc_data *vc, int lines) in scrollback() argument
1094 lines = vc->vc_rows / 2; in scrollback()
1098 void scrollfront(struct vc_data *vc, int lines) in scrollfront() argument
1101 lines = vc->vc_rows / 2; in scrollfront()
1105 static void lf(struct vc_data *vc) in lf() argument
1110 if (vc->vc_y + 1 == vc->vc_bottom) in lf()
1111 scrup(vc, vc->vc_top, vc->vc_bottom, 1); in lf()
1112 else if (vc->vc_y < vc->vc_rows - 1) { in lf()
1113 vc->vc_y++; in lf()
1114 vc->vc_pos += vc->vc_size_row; in lf()
1116 vc->vc_need_wrap = 0; in lf()
1117 notify_write(vc, '\n'); in lf()
1120 static void ri(struct vc_data *vc) in ri() argument
1125 if (vc->vc_y == vc->vc_top) in ri()
1126 scrdown(vc, vc->vc_top, vc->vc_bottom, 1); in ri()
1127 else if (vc->vc_y > 0) { in ri()
1128 vc->vc_y--; in ri()
1129 vc->vc_pos -= vc->vc_size_row; in ri()
1131 vc->vc_need_wrap = 0; in ri()
1134 static inline void cr(struct vc_data *vc) in cr() argument
1136 vc->vc_pos -= vc->vc_x << 1; in cr()
1137 vc->vc_need_wrap = vc->vc_x = 0; in cr()
1138 notify_write(vc, '\r'); in cr()
1141 static inline void bs(struct vc_data *vc) in bs() argument
1143 if (vc->vc_x) { in bs()
1144 vc->vc_pos -= 2; in bs()
1145 vc->vc_x--; in bs()
1146 vc->vc_need_wrap = 0; in bs()
1147 notify_write(vc, '\b'); in bs()
1151 static inline void del(struct vc_data *vc) in del() argument
1156 static void csi_J(struct vc_data *vc, int vpar) in csi_J() argument
1163 count = (vc->vc_scr_end - vc->vc_pos) >> 1; in csi_J()
1164 start = (unsigned short *)vc->vc_pos; in csi_J()
1167 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1; in csi_J()
1168 start = (unsigned short *)vc->vc_origin; in csi_J()
1171 scr_memsetw(vc->vc_screenbuf, vc->vc_video_erase_char, in csi_J()
1172 vc->vc_screenbuf_size); in csi_J()
1173 set_origin(vc); in csi_J()
1174 if (CON_IS_VISIBLE(vc)) in csi_J()
1175 update_screen(vc); in csi_J()
1178 count = vc->vc_cols * vc->vc_rows; in csi_J()
1179 start = (unsigned short *)vc->vc_origin; in csi_J()
1184 scr_memsetw(start, vc->vc_video_erase_char, 2 * count); in csi_J()
1185 if (DO_UPDATE(vc)) in csi_J()
1186 do_update_region(vc, (unsigned long) start, count); in csi_J()
1187 vc->vc_need_wrap = 0; in csi_J()
1190 static void csi_K(struct vc_data *vc, int vpar) in csi_K() argument
1197 count = vc->vc_cols - vc->vc_x; in csi_K()
1198 start = (unsigned short *)vc->vc_pos; in csi_K()
1201 start = (unsigned short *)(vc->vc_pos - (vc->vc_x << 1)); in csi_K()
1202 count = vc->vc_x + 1; in csi_K()
1205 start = (unsigned short *)(vc->vc_pos - (vc->vc_x << 1)); in csi_K()
1206 count = vc->vc_cols; in csi_K()
1211 scr_memsetw(start, vc->vc_video_erase_char, 2 * count); in csi_K()
1212 vc->vc_need_wrap = 0; in csi_K()
1213 if (DO_UPDATE(vc)) in csi_K()
1214 do_update_region(vc, (unsigned long) start, count); in csi_K()
1217 static void csi_X(struct vc_data *vc, int vpar) /* erase the following vpar positions */ in csi_X() argument
1223 count = (vpar > vc->vc_cols - vc->vc_x) ? (vc->vc_cols - vc->vc_x) : vpar; in csi_X()
1225 scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count); in csi_X()
1226 if (DO_UPDATE(vc)) in csi_X()
1227 vc->vc_sw->con_clear(vc, vc->vc_y, vc->vc_x, 1, count); in csi_X()
1228 vc->vc_need_wrap = 0; in csi_X()
1231 static void default_attr(struct vc_data *vc) in default_attr() argument
1233 vc->vc_intensity = 1; in default_attr()
1234 vc->vc_italic = 0; in default_attr()
1235 vc->vc_underline = 0; in default_attr()
1236 vc->vc_reverse = 0; in default_attr()
1237 vc->vc_blink = 0; in default_attr()
1238 vc->vc_color = vc->vc_def_color; in default_attr()
1263 static void rgb_foreground(struct vc_data *vc, struct rgb c) in rgb_foreground() argument
1274 hue = 0, vc->vc_intensity = 2; in rgb_foreground()
1276 vc->vc_intensity = (max > 0xaa) + 1; in rgb_foreground()
1277 vc->vc_color = (vc->vc_color & 0xf0) | hue; in rgb_foreground()
1280 static void rgb_background(struct vc_data *vc, struct rgb c) in rgb_background() argument
1283 vc->vc_color = (vc->vc_color & 0x0f) in rgb_background()
1288 static void csi_m(struct vc_data *vc) in csi_m() argument
1292 for (i = 0; i <= vc->vc_npar; i++) in csi_m()
1293 switch (vc->vc_par[i]) { in csi_m()
1295 default_attr(vc); in csi_m()
1298 vc->vc_intensity = 2; in csi_m()
1301 vc->vc_intensity = 0; in csi_m()
1304 vc->vc_italic = 1; in csi_m()
1307 vc->vc_underline = 1; in csi_m()
1310 vc->vc_blink = 1; in csi_m()
1313 vc->vc_reverse = 1; in csi_m()
1320 vc->vc_translate = set_translate(vc->vc_charset == 0 in csi_m()
1321 ? vc->vc_G0_charset in csi_m()
1322 : vc->vc_G1_charset, vc); in csi_m()
1323 vc->vc_disp_ctrl = 0; in csi_m()
1324 vc->vc_toggle_meta = 0; in csi_m()
1330 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1331 vc->vc_disp_ctrl = 1; in csi_m()
1332 vc->vc_toggle_meta = 0; in csi_m()
1338 vc->vc_translate = set_translate(IBMPC_MAP, vc); in csi_m()
1339 vc->vc_disp_ctrl = 1; in csi_m()
1340 vc->vc_toggle_meta = 1; in csi_m()
1344 vc->vc_intensity = 1; in csi_m()
1347 vc->vc_italic = 0; in csi_m()
1350 vc->vc_underline = 0; in csi_m()
1353 vc->vc_blink = 0; in csi_m()
1356 vc->vc_reverse = 0; in csi_m()
1368 if (i > vc->vc_npar) in csi_m()
1370 if (vc->vc_par[i] == 5 && /* 256 colours */ in csi_m()
1371 i < vc->vc_npar) { /* ubiquitous */ in csi_m()
1373 rgb_foreground(vc, in csi_m()
1374 rgb_from_256(vc->vc_par[i])); in csi_m()
1375 } else if (vc->vc_par[i] == 2 && /* 24 bit */ in csi_m()
1376 i <= vc->vc_npar + 3) {/* extremely rare */ in csi_m()
1377 struct rgb c = {r:vc->vc_par[i+1], in csi_m()
1378 g:vc->vc_par[i+2], in csi_m()
1379 b:vc->vc_par[i+3]}; in csi_m()
1380 rgb_foreground(vc, c); in csi_m()
1389 if (i > vc->vc_npar) in csi_m()
1391 if (vc->vc_par[i] == 5 && /* 256 colours */ in csi_m()
1392 i < vc->vc_npar) { in csi_m()
1394 rgb_background(vc, in csi_m()
1395 rgb_from_256(vc->vc_par[i])); in csi_m()
1396 } else if (vc->vc_par[i] == 2 && /* 24 bit */ in csi_m()
1397 i <= vc->vc_npar + 3) { in csi_m()
1398 struct rgb c = {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()
1401 rgb_background(vc, c); in csi_m()
1406 vc->vc_color = (vc->vc_def_color & 0x0f) | (vc->vc_color & 0xf0); in csi_m()
1409 vc->vc_color = (vc->vc_def_color & 0xf0) | (vc->vc_color & 0x0f); in csi_m()
1412 if (vc->vc_par[i] >= 30 && vc->vc_par[i] <= 37) in csi_m()
1413 vc->vc_color = color_table[vc->vc_par[i] - 30] in csi_m()
1414 | (vc->vc_color & 0xf0); in csi_m()
1415 else if (vc->vc_par[i] >= 40 && vc->vc_par[i] <= 47) in csi_m()
1416 vc->vc_color = (color_table[vc->vc_par[i] - 40] << 4) in csi_m()
1417 | (vc->vc_color & 0x0f); in csi_m()
1420 update_attr(vc); in csi_m()
1432 static void cursor_report(struct vc_data *vc, struct tty_struct *tty) in cursor_report() argument
1436 sprintf(buf, "\033[%d;%dR", vc->vc_y + (vc->vc_decom ? vc->vc_top + 1 : 1), vc->vc_x + 1); in cursor_report()
1466 static void set_mode(struct vc_data *vc, int on_off) in set_mode() argument
1470 for (i = 0; i <= vc->vc_npar; i++) in set_mode()
1471 if (vc->vc_ques) { in set_mode()
1472 switch(vc->vc_par[i]) { /* DEC private modes set/reset */ in set_mode()
1475 set_kbd(vc, decckm); in set_mode()
1477 clr_kbd(vc, decckm); in set_mode()
1480 vc->vc_deccolm = on_off; in set_mode()
1482 vc_resize(deccolm ? 132 : 80, vc->vc_rows); in set_mode()
1488 if (vc->vc_decscnm != on_off) { in set_mode()
1489 vc->vc_decscnm = on_off; in set_mode()
1490 invert_screen(vc, 0, vc->vc_screenbuf_size, 0); in set_mode()
1491 update_attr(vc); in set_mode()
1495 vc->vc_decom = on_off; in set_mode()
1496 gotoxay(vc, 0, 0); in set_mode()
1499 vc->vc_decawm = on_off; in set_mode()
1503 set_kbd(vc, decarm); in set_mode()
1505 clr_kbd(vc, decarm); in set_mode()
1508 vc->vc_report_mouse = on_off ? 1 : 0; in set_mode()
1511 vc->vc_deccm = on_off; in set_mode()
1514 vc->vc_report_mouse = on_off ? 2 : 0; in set_mode()
1518 switch(vc->vc_par[i]) { /* ANSI modes set/reset */ in set_mode()
1520 vc->vc_disp_ctrl = on_off; in set_mode()
1523 vc->vc_decim = on_off; in set_mode()
1527 set_kbd(vc, lnm); in set_mode()
1529 clr_kbd(vc, lnm); in set_mode()
1536 static void setterm_command(struct vc_data *vc) in setterm_command() argument
1538 switch(vc->vc_par[0]) { in setterm_command()
1540 if (vc->vc_can_do_color && in setterm_command()
1541 vc->vc_par[1] < 16) { in setterm_command()
1542 vc->vc_ulcolor = color_table[vc->vc_par[1]]; in setterm_command()
1543 if (vc->vc_underline) in setterm_command()
1544 update_attr(vc); in setterm_command()
1548 if (vc->vc_can_do_color && in setterm_command()
1549 vc->vc_par[1] < 16) { in setterm_command()
1550 vc->vc_halfcolor = color_table[vc->vc_par[1]]; in setterm_command()
1551 if (vc->vc_intensity == 0) in setterm_command()
1552 update_attr(vc); in setterm_command()
1556 vc->vc_def_color = vc->vc_attr; in setterm_command()
1557 if (vc->vc_hi_font_mask == 0x100) in setterm_command()
1558 vc->vc_def_color >>= 1; in setterm_command()
1559 default_attr(vc); in setterm_command()
1560 update_attr(vc); in setterm_command()
1563 blankinterval = ((vc->vc_par[1] < 60) ? vc->vc_par[1] : 60) * 60; in setterm_command()
1567 if (vc->vc_npar >= 1) in setterm_command()
1568 vc->vc_bell_pitch = vc->vc_par[1]; in setterm_command()
1570 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in setterm_command()
1573 if (vc->vc_npar >= 1) in setterm_command()
1574 vc->vc_bell_duration = (vc->vc_par[1] < 2000) ? in setterm_command()
1575 vc->vc_par[1] * HZ / 1000 : 0; in setterm_command()
1577 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in setterm_command()
1580 if (vc->vc_par[1] >= 1 && vc_cons_allocated(vc->vc_par[1] - 1)) in setterm_command()
1581 set_console(vc->vc_par[1] - 1); in setterm_command()
1587 vesa_off_interval = ((vc->vc_par[1] < 60) ? vc->vc_par[1] : 60) * 60 * HZ; in setterm_command()
1596 static void csi_at(struct vc_data *vc, unsigned int nr) in csi_at() argument
1598 if (nr > vc->vc_cols - vc->vc_x) in csi_at()
1599 nr = vc->vc_cols - vc->vc_x; in csi_at()
1602 insert_char(vc, nr); in csi_at()
1606 static void csi_L(struct vc_data *vc, unsigned int nr) in csi_L() argument
1608 if (nr > vc->vc_rows - vc->vc_y) in csi_L()
1609 nr = vc->vc_rows - vc->vc_y; in csi_L()
1612 scrdown(vc, vc->vc_y, vc->vc_bottom, nr); in csi_L()
1613 vc->vc_need_wrap = 0; in csi_L()
1617 static void csi_P(struct vc_data *vc, unsigned int nr) in csi_P() argument
1619 if (nr > vc->vc_cols - vc->vc_x) in csi_P()
1620 nr = vc->vc_cols - vc->vc_x; in csi_P()
1623 delete_char(vc, nr); in csi_P()
1627 static void csi_M(struct vc_data *vc, unsigned int nr) in csi_M() argument
1629 if (nr > vc->vc_rows - vc->vc_y) in csi_M()
1630 nr = vc->vc_rows - vc->vc_y; in csi_M()
1633 scrup(vc, vc->vc_y, vc->vc_bottom, nr); in csi_M()
1634 vc->vc_need_wrap = 0; in csi_M()
1638 static void save_cur(struct vc_data *vc) in save_cur() argument
1640 vc->vc_saved_x = vc->vc_x; in save_cur()
1641 vc->vc_saved_y = vc->vc_y; in save_cur()
1642 vc->vc_s_intensity = vc->vc_intensity; in save_cur()
1643 vc->vc_s_italic = vc->vc_italic; in save_cur()
1644 vc->vc_s_underline = vc->vc_underline; in save_cur()
1645 vc->vc_s_blink = vc->vc_blink; in save_cur()
1646 vc->vc_s_reverse = vc->vc_reverse; in save_cur()
1647 vc->vc_s_charset = vc->vc_charset; in save_cur()
1648 vc->vc_s_color = vc->vc_color; in save_cur()
1649 vc->vc_saved_G0 = vc->vc_G0_charset; in save_cur()
1650 vc->vc_saved_G1 = vc->vc_G1_charset; in save_cur()
1654 static void restore_cur(struct vc_data *vc) in restore_cur() argument
1656 gotoxy(vc, vc->vc_saved_x, vc->vc_saved_y); in restore_cur()
1657 vc->vc_intensity = vc->vc_s_intensity; in restore_cur()
1658 vc->vc_italic = vc->vc_s_italic; in restore_cur()
1659 vc->vc_underline = vc->vc_s_underline; in restore_cur()
1660 vc->vc_blink = vc->vc_s_blink; in restore_cur()
1661 vc->vc_reverse = vc->vc_s_reverse; in restore_cur()
1662 vc->vc_charset = vc->vc_s_charset; in restore_cur()
1663 vc->vc_color = vc->vc_s_color; in restore_cur()
1664 vc->vc_G0_charset = vc->vc_saved_G0; in restore_cur()
1665 vc->vc_G1_charset = vc->vc_saved_G1; in restore_cur()
1666 vc->vc_translate = set_translate(vc->vc_charset ? vc->vc_G1_charset : vc->vc_G0_charset, vc); in restore_cur()
1667 update_attr(vc); in restore_cur()
1668 vc->vc_need_wrap = 0; in restore_cur()
1676 static void reset_terminal(struct vc_data *vc, int do_clear) in reset_terminal() argument
1678 vc->vc_top = 0; in reset_terminal()
1679 vc->vc_bottom = vc->vc_rows; in reset_terminal()
1680 vc->vc_state = ESnormal; in reset_terminal()
1681 vc->vc_ques = 0; in reset_terminal()
1682 vc->vc_translate = set_translate(LAT1_MAP, vc); in reset_terminal()
1683 vc->vc_G0_charset = LAT1_MAP; in reset_terminal()
1684 vc->vc_G1_charset = GRAF_MAP; in reset_terminal()
1685 vc->vc_charset = 0; in reset_terminal()
1686 vc->vc_need_wrap = 0; in reset_terminal()
1687 vc->vc_report_mouse = 0; in reset_terminal()
1688 vc->vc_utf = default_utf8; in reset_terminal()
1689 vc->vc_utf_count = 0; in reset_terminal()
1691 vc->vc_disp_ctrl = 0; in reset_terminal()
1692 vc->vc_toggle_meta = 0; in reset_terminal()
1694 vc->vc_decscnm = 0; in reset_terminal()
1695 vc->vc_decom = 0; in reset_terminal()
1696 vc->vc_decawm = 1; in reset_terminal()
1697 vc->vc_deccm = global_cursor_default; in reset_terminal()
1698 vc->vc_decim = 0; in reset_terminal()
1700 vt_reset_keyboard(vc->vc_num); in reset_terminal()
1702 vc->vc_cursor_type = cur_default; in reset_terminal()
1703 vc->vc_complement_mask = vc->vc_s_complement_mask; in reset_terminal()
1705 default_attr(vc); in reset_terminal()
1706 update_attr(vc); in reset_terminal()
1708 vc->vc_tab_stop[0] = 0x01010100; in reset_terminal()
1709 vc->vc_tab_stop[1] = in reset_terminal()
1710 vc->vc_tab_stop[2] = in reset_terminal()
1711 vc->vc_tab_stop[3] = in reset_terminal()
1712 vc->vc_tab_stop[4] = in reset_terminal()
1713 vc->vc_tab_stop[5] = in reset_terminal()
1714 vc->vc_tab_stop[6] = in reset_terminal()
1715 vc->vc_tab_stop[7] = 0x01010101; in reset_terminal()
1717 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; in reset_terminal()
1718 vc->vc_bell_duration = DEFAULT_BELL_DURATION; in reset_terminal()
1720 gotoxy(vc, 0, 0); in reset_terminal()
1721 save_cur(vc); in reset_terminal()
1723 csi_J(vc, 2); in reset_terminal()
1727 static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) in do_con_trol() argument
1733 if (vc->vc_state == ESosc && c>=8 && c<=13) /* ... except for OSC */ in do_con_trol()
1739 if (vc->vc_state == ESosc) in do_con_trol()
1740 vc->vc_state = ESnormal; in do_con_trol()
1741 else if (vc->vc_bell_duration) in do_con_trol()
1742 kd_mksound(vc->vc_bell_pitch, vc->vc_bell_duration); in do_con_trol()
1745 bs(vc); in do_con_trol()
1748 vc->vc_pos -= (vc->vc_x << 1); in do_con_trol()
1749 while (vc->vc_x < vc->vc_cols - 1) { in do_con_trol()
1750 vc->vc_x++; in do_con_trol()
1751 if (vc->vc_tab_stop[vc->vc_x >> 5] & (1 << (vc->vc_x & 31))) in do_con_trol()
1754 vc->vc_pos += (vc->vc_x << 1); in do_con_trol()
1755 notify_write(vc, '\t'); in do_con_trol()
1758 lf(vc); in do_con_trol()
1759 if (!is_kbd(vc, lnm)) in do_con_trol()
1762 cr(vc); in do_con_trol()
1765 vc->vc_charset = 1; in do_con_trol()
1766 vc->vc_translate = set_translate(vc->vc_G1_charset, vc); in do_con_trol()
1767 vc->vc_disp_ctrl = 1; in do_con_trol()
1770 vc->vc_charset = 0; in do_con_trol()
1771 vc->vc_translate = set_translate(vc->vc_G0_charset, vc); in do_con_trol()
1772 vc->vc_disp_ctrl = 0; in do_con_trol()
1775 vc->vc_state = ESnormal; in do_con_trol()
1778 vc->vc_state = ESesc; in do_con_trol()
1781 del(vc); in do_con_trol()
1784 vc->vc_state = ESsquare; in do_con_trol()
1787 switch(vc->vc_state) { in do_con_trol()
1789 vc->vc_state = ESnormal; in do_con_trol()
1792 vc->vc_state = ESsquare; in do_con_trol()
1795 vc->vc_state = ESnonstd; in do_con_trol()
1798 vc->vc_state = ESpercent; in do_con_trol()
1801 cr(vc); in do_con_trol()
1802 lf(vc); in do_con_trol()
1805 ri(vc); in do_con_trol()
1808 lf(vc); in do_con_trol()
1811 vc->vc_tab_stop[vc->vc_x >> 5] |= (1 << (vc->vc_x & 31)); in do_con_trol()
1817 save_cur(vc); in do_con_trol()
1820 restore_cur(vc); in do_con_trol()
1823 vc->vc_state = ESsetG0; in do_con_trol()
1826 vc->vc_state = ESsetG1; in do_con_trol()
1829 vc->vc_state = EShash; in do_con_trol()
1832 reset_terminal(vc, 1); in do_con_trol()
1835 clr_kbd(vc, kbdapplic); in do_con_trol()
1838 set_kbd(vc, kbdapplic); in do_con_trol()
1844 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) in do_con_trol()
1845 vc->vc_par[vc->vc_npar] = 0; in do_con_trol()
1846 vc->vc_npar = 0; in do_con_trol()
1847 vc->vc_state = ESpalette; in do_con_trol()
1850 reset_palette(vc); in do_con_trol()
1851 vc->vc_state = ESnormal; in do_con_trol()
1853 vc->vc_state = ESosc; in do_con_trol()
1855 vc->vc_state = ESnormal; in do_con_trol()
1859 vc->vc_par[vc->vc_npar++] = hex_to_bin(c); in do_con_trol()
1860 if (vc->vc_npar == 7) { in do_con_trol()
1861 int i = vc->vc_par[0] * 3, j = 1; in do_con_trol()
1862 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
1863 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
1864 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
1865 vc->vc_palette[i++] += vc->vc_par[j++]; in do_con_trol()
1866 vc->vc_palette[i] = 16 * vc->vc_par[j++]; in do_con_trol()
1867 vc->vc_palette[i] += vc->vc_par[j]; in do_con_trol()
1868 set_palette(vc); in do_con_trol()
1869 vc->vc_state = ESnormal; in do_con_trol()
1872 vc->vc_state = ESnormal; in do_con_trol()
1875 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) in do_con_trol()
1876 vc->vc_par[vc->vc_npar] = 0; in do_con_trol()
1877 vc->vc_npar = 0; in do_con_trol()
1878 vc->vc_state = ESgetpars; in do_con_trol()
1880 vc->vc_state=ESfunckey; in do_con_trol()
1883 vc->vc_ques = (c == '?'); in do_con_trol()
1884 if (vc->vc_ques) in do_con_trol()
1887 if (c == ';' && vc->vc_npar < NPAR - 1) { in do_con_trol()
1888 vc->vc_npar++; in do_con_trol()
1891 vc->vc_par[vc->vc_npar] *= 10; in do_con_trol()
1892 vc->vc_par[vc->vc_npar] += c - '0'; in do_con_trol()
1895 vc->vc_state = ESnormal; in do_con_trol()
1898 set_mode(vc, 1); in do_con_trol()
1901 set_mode(vc, 0); in do_con_trol()
1904 if (vc->vc_ques) { in do_con_trol()
1905 if (vc->vc_par[0]) in do_con_trol()
1906 vc->vc_cursor_type = vc->vc_par[0] | (vc->vc_par[1] << 8) | (vc->vc_par[2] << 16); in do_con_trol()
1908 vc->vc_cursor_type = cur_default; in do_con_trol()
1913 if (vc->vc_ques) { in do_con_trol()
1915 if (vc->vc_par[0]) in do_con_trol()
1916 vc->vc_complement_mask = vc->vc_par[0] << 8 | vc->vc_par[1]; in do_con_trol()
1918 vc->vc_complement_mask = vc->vc_s_complement_mask; in do_con_trol()
1923 if (!vc->vc_ques) { in do_con_trol()
1924 if (vc->vc_par[0] == 5) in do_con_trol()
1926 else if (vc->vc_par[0] == 6) in do_con_trol()
1927 cursor_report(vc, tty); in do_con_trol()
1931 if (vc->vc_ques) { in do_con_trol()
1932 vc->vc_ques = 0; in do_con_trol()
1937 if (vc->vc_par[0]) in do_con_trol()
1938 vc->vc_par[0]--; in do_con_trol()
1939 gotoxy(vc, vc->vc_par[0], vc->vc_y); in do_con_trol()
1942 if (!vc->vc_par[0]) in do_con_trol()
1943 vc->vc_par[0]++; in do_con_trol()
1944 gotoxy(vc, vc->vc_x, vc->vc_y - vc->vc_par[0]); in do_con_trol()
1947 if (!vc->vc_par[0]) in do_con_trol()
1948 vc->vc_par[0]++; in do_con_trol()
1949 gotoxy(vc, vc->vc_x, vc->vc_y + vc->vc_par[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_x + 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_par[0], vc->vc_y); 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, 0, 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, 0, vc->vc_y - vc->vc_par[0]); in do_con_trol()
1972 if (vc->vc_par[0]) in do_con_trol()
1973 vc->vc_par[0]--; in do_con_trol()
1974 gotoxay(vc, vc->vc_x ,vc->vc_par[0]); in do_con_trol()
1977 if (vc->vc_par[0]) in do_con_trol()
1978 vc->vc_par[0]--; in do_con_trol()
1979 if (vc->vc_par[1]) in do_con_trol()
1980 vc->vc_par[1]--; in do_con_trol()
1981 gotoxay(vc, vc->vc_par[1], vc->vc_par[0]); in do_con_trol()
1984 csi_J(vc, vc->vc_par[0]); in do_con_trol()
1987 csi_K(vc, vc->vc_par[0]); in do_con_trol()
1990 csi_L(vc, vc->vc_par[0]); in do_con_trol()
1993 csi_M(vc, vc->vc_par[0]); in do_con_trol()
1996 csi_P(vc, vc->vc_par[0]); in do_con_trol()
1999 if (!vc->vc_par[0]) in do_con_trol()
2003 if (!vc->vc_par[0]) in do_con_trol()
2004 vc->vc_tab_stop[vc->vc_x >> 5] &= ~(1 << (vc->vc_x & 31)); in do_con_trol()
2005 else if (vc->vc_par[0] == 3) { in do_con_trol()
2006 vc->vc_tab_stop[0] = in do_con_trol()
2007 vc->vc_tab_stop[1] = in do_con_trol()
2008 vc->vc_tab_stop[2] = in do_con_trol()
2009 vc->vc_tab_stop[3] = in do_con_trol()
2010 vc->vc_tab_stop[4] = in do_con_trol()
2011 vc->vc_tab_stop[5] = in do_con_trol()
2012 vc->vc_tab_stop[6] = in do_con_trol()
2013 vc->vc_tab_stop[7] = 0; in do_con_trol()
2017 csi_m(vc); in do_con_trol()
2021 if (vc->vc_par[0] < 4) in do_con_trol()
2022 vt_set_led_state(vc->vc_num, in do_con_trol()
2023 (vc->vc_par[0] < 3) ? vc->vc_par[0] : 4); in do_con_trol()
2026 if (!vc->vc_par[0]) in do_con_trol()
2027 vc->vc_par[0]++; in do_con_trol()
2028 if (!vc->vc_par[1]) in do_con_trol()
2029 vc->vc_par[1] = vc->vc_rows; in do_con_trol()
2031 if (vc->vc_par[0] < vc->vc_par[1] && in do_con_trol()
2032 vc->vc_par[1] <= vc->vc_rows) { in do_con_trol()
2033 vc->vc_top = vc->vc_par[0] - 1; in do_con_trol()
2034 vc->vc_bottom = vc->vc_par[1]; in do_con_trol()
2035 gotoxay(vc, 0, 0); in do_con_trol()
2039 save_cur(vc); in do_con_trol()
2042 restore_cur(vc); in do_con_trol()
2045 csi_X(vc, vc->vc_par[0]); in do_con_trol()
2048 csi_at(vc, vc->vc_par[0]); in do_con_trol()
2051 setterm_command(vc); in do_con_trol()
2056 vc->vc_state = ESnormal; in do_con_trol()
2059 vc->vc_utf = 0; in do_con_trol()
2063 vc->vc_utf = 1; in do_con_trol()
2068 vc->vc_state = ESnormal; in do_con_trol()
2071 vc->vc_state = ESnormal; in do_con_trol()
2074 vc->vc_video_erase_char = in do_con_trol()
2075 (vc->vc_video_erase_char & 0xff00) | 'E'; in do_con_trol()
2076 csi_J(vc, 2); in do_con_trol()
2077 vc->vc_video_erase_char = in do_con_trol()
2078 (vc->vc_video_erase_char & 0xff00) | ' '; in do_con_trol()
2079 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); in do_con_trol()
2084 vc->vc_G0_charset = GRAF_MAP; in do_con_trol()
2086 vc->vc_G0_charset = LAT1_MAP; in do_con_trol()
2088 vc->vc_G0_charset = IBMPC_MAP; in do_con_trol()
2090 vc->vc_G0_charset = USER_MAP; in do_con_trol()
2091 if (vc->vc_charset == 0) in do_con_trol()
2092 vc->vc_translate = set_translate(vc->vc_G0_charset, vc); in do_con_trol()
2093 vc->vc_state = ESnormal; in do_con_trol()
2097 vc->vc_G1_charset = GRAF_MAP; in do_con_trol()
2099 vc->vc_G1_charset = LAT1_MAP; in do_con_trol()
2101 vc->vc_G1_charset = IBMPC_MAP; in do_con_trol()
2103 vc->vc_G1_charset = USER_MAP; in do_con_trol()
2104 if (vc->vc_charset == 1) in do_con_trol()
2105 vc->vc_translate = set_translate(vc->vc_G1_charset, vc); in do_con_trol()
2106 vc->vc_state = ESnormal; in do_con_trol()
2111 vc->vc_state = ESnormal; in do_con_trol()
2161 vc->vc_sw->con_putcs(vc, (u16 *)draw_from, (u16 *)draw_to - (u16 *)draw_from, vc->vc_y, draw_x); \ in do_con_write()
2169 struct vc_data *vc; in do_con_write() local
2183 vc = tty->driver_data; in do_con_write()
2184 if (vc == NULL) { in do_con_write()
2190 currcons = vc->vc_num; in do_con_write()
2198 himask = vc->vc_hi_font_mask; in do_con_write()
2202 if (IS_FG(vc)) in do_con_write()
2203 hide_cursor(vc); in do_con_write()
2205 param.vc = vc; in do_con_write()
2218 if (vc->vc_state != ESnormal) { in do_con_write()
2220 } else if (vc->vc_utf && !vc->vc_disp_ctrl) { in do_con_write()
2231 if (vc->vc_utf_count) { in do_con_write()
2232 vc->vc_utf_char = (vc->vc_utf_char << 6) | (c & 0x3f); in do_con_write()
2233 vc->vc_npar++; in do_con_write()
2234 if (--vc->vc_utf_count) { in do_con_write()
2239 c = vc->vc_utf_char; in do_con_write()
2241 if (c <= utf8_length_changes[vc->vc_npar - 1] || in do_con_write()
2242 c > utf8_length_changes[vc->vc_npar]) in do_con_write()
2246 vc->vc_utf_count = 0; in do_con_write()
2251 if (vc->vc_utf_count) { in do_con_write()
2254 vc->vc_utf_count = 0; in do_con_write()
2258 vc->vc_npar = 0; in do_con_write()
2260 vc->vc_utf_count = 1; in do_con_write()
2261 vc->vc_utf_char = (c & 0x1f); in do_con_write()
2263 vc->vc_utf_count = 2; in do_con_write()
2264 vc->vc_utf_char = (c & 0x0f); in do_con_write()
2266 vc->vc_utf_count = 3; in do_con_write()
2267 vc->vc_utf_char = (c & 0x07); in do_con_write()
2269 vc->vc_utf_count = 4; in do_con_write()
2270 vc->vc_utf_char = (c & 0x03); in do_con_write()
2272 vc->vc_utf_count = 5; in do_con_write()
2273 vc->vc_utf_char = (c & 0x01); in do_con_write()
2278 if (vc->vc_utf_count) { in do_con_write()
2292 tc = vc_translate(vc, c); in do_con_write()
2311 !(vc->vc_disp_ctrl ? (CTRL_ALWAYS >> c) & 1 : in do_con_write()
2312 vc->vc_utf || ((CTRL_ACTION >> c) & 1))) in do_con_write()
2313 && (c != 127 || vc->vc_disp_ctrl) in do_con_write()
2316 if (vc->vc_state == ESnormal && ok) { in do_con_write()
2317 if (vc->vc_utf && !vc->vc_disp_ctrl) { in do_con_write()
2322 tc = conv_uni_to_pc(vc, tc); in do_con_write()
2328 if ((!(vc->vc_utf && !vc->vc_disp_ctrl) || c < 128) && !(c & ~charmask)) { in do_con_write()
2337 tc = conv_uni_to_pc(vc, 0xfffd); in do_con_write()
2340 tc = conv_uni_to_pc(vc, '?'); in do_con_write()
2347 vc_attr = vc->vc_attr; in do_con_write()
2350 if (!vc->vc_can_do_color) { in do_con_write()
2351 vc_attr = (vc->vc_attr) ^ 0x08; in do_con_write()
2352 } else if (vc->vc_hi_font_mask == 0x100) { in do_con_write()
2353 … vc_attr = ((vc->vc_attr) & 0x11) | (((vc->vc_attr) & 0xe0) >> 4) | (((vc->vc_attr) & 0x0e) << 4); in do_con_write()
2355 … vc_attr = ((vc->vc_attr) & 0x88) | (((vc->vc_attr) & 0x70) >> 4) | (((vc->vc_attr) & 0x07) << 4); in do_con_write()
2361 if (vc->vc_need_wrap || vc->vc_decim) in do_con_write()
2363 if (vc->vc_need_wrap) { in do_con_write()
2364 cr(vc); in do_con_write()
2365 lf(vc); in do_con_write()
2367 if (vc->vc_decim) in do_con_write()
2368 insert_char(vc, 1); in do_con_write()
2372 (u16 *) vc->vc_pos); in do_con_write()
2373 if (DO_UPDATE(vc) && draw_x < 0) { in do_con_write()
2374 draw_x = vc->vc_x; in do_con_write()
2375 draw_from = vc->vc_pos; in do_con_write()
2377 if (vc->vc_x == vc->vc_cols - 1) { in do_con_write()
2378 vc->vc_need_wrap = vc->vc_decawm; in do_con_write()
2379 draw_to = vc->vc_pos + 2; in do_con_write()
2381 vc->vc_x++; in do_con_write()
2382 draw_to = (vc->vc_pos += 2); in do_con_write()
2387 tc = conv_uni_to_pc(vc, ' '); /* A space is printed in the second column */ in do_con_write()
2390 notify_write(vc, c); in do_con_write()
2406 do_con_trol(tty, vc, orig); in do_con_write()
2411 notify_update(vc); in do_con_write()
2445 struct vc_data *vc = vc_cons[fg_console].d; in console_callback() local
2447 if (vc->vc_mode == KD_TEXT) in console_callback()
2448 vc->vc_sw->con_scrolldelta(vc, scrollback_delta); in console_callback()
2462 struct vc_data *vc = vc_cons[fg_console].d; in set_console() local
2465 (vc->vt_mode.mode == VT_AUTO && vc->vc_mode == KD_GRAPHICS)) { in set_console()
2527 struct vc_data *vc = vc_cons[fg_console].d; in vt_console_print() local
2543 vc = vc_cons[kmsg_console - 1].d; in vt_console_print()
2547 myx = vc->vc_x; in vt_console_print()
2555 if (vc->vc_mode != KD_TEXT && !vt_force_oops_output(vc)) in vt_console_print()
2559 if (IS_FG(vc)) in vt_console_print()
2560 hide_cursor(vc); in vt_console_print()
2562 start = (ushort *)vc->vc_pos; in vt_console_print()
2568 if (c == 10 || c == 13 || c == 8 || vc->vc_need_wrap) { in vt_console_print()
2570 if (CON_IS_VISIBLE(vc)) in vt_console_print()
2571 vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x); in vt_console_print()
2572 vc->vc_x += cnt; in vt_console_print()
2573 if (vc->vc_need_wrap) in vt_console_print()
2574 vc->vc_x--; in vt_console_print()
2578 bs(vc); in vt_console_print()
2579 start = (ushort *)vc->vc_pos; in vt_console_print()
2580 myx = vc->vc_x; in vt_console_print()
2584 lf(vc); in vt_console_print()
2585 cr(vc); in vt_console_print()
2586 start = (ushort *)vc->vc_pos; in vt_console_print()
2587 myx = vc->vc_x; in vt_console_print()
2591 scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos); in vt_console_print()
2592 notify_write(vc, c); in vt_console_print()
2594 if (myx == vc->vc_cols - 1) { in vt_console_print()
2595 vc->vc_need_wrap = 1; in vt_console_print()
2598 vc->vc_pos += 2; in vt_console_print()
2602 if (CON_IS_VISIBLE(vc)) in vt_console_print()
2603 vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x); in vt_console_print()
2604 vc->vc_x += cnt; in vt_console_print()
2605 if (vc->vc_x == vc->vc_cols) { in vt_console_print()
2606 vc->vc_x--; in vt_console_print()
2607 vc->vc_need_wrap = 1; in vt_console_print()
2610 set_cursor(vc); in vt_console_print()
2611 notify_update(vc); in vt_console_print()
2796 struct vc_data *vc = tty->driver_data; in con_unthrottle() local
2798 wake_up_interruptible(&vc->paste_wait); in con_unthrottle()
2831 struct vc_data *vc; in con_flush_chars() local
2838 vc = tty->driver_data; in con_flush_chars()
2839 if (vc) in con_flush_chars()
2840 set_cursor(vc); in con_flush_chars()
2850 struct vc_data *vc; in con_install() local
2858 vc = vc_cons[currcons].d; in con_install()
2861 if (vc->port.tty) { in con_install()
2866 ret = tty_port_install(&vc->port, driver, tty); in con_install()
2870 tty->driver_data = vc; in con_install()
2871 vc->port.tty = tty; in con_install()
2877 if (vc->vc_utf) in con_install()
2900 struct vc_data *vc = tty->driver_data; in con_shutdown() local
2901 BUG_ON(vc == NULL); in con_shutdown()
2903 vc->port.tty = NULL; in con_shutdown()
2914 static void vc_init(struct vc_data *vc, unsigned int rows, in vc_init() argument
2919 vc->vc_cols = cols; in vc_init()
2920 vc->vc_rows = rows; in vc_init()
2921 vc->vc_size_row = cols << 1; in vc_init()
2922 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; in vc_init()
2924 set_origin(vc); in vc_init()
2925 vc->vc_pos = vc->vc_origin; in vc_init()
2926 reset_vc(vc); in vc_init()
2928 vc->vc_palette[k++] = default_red[j] ; in vc_init()
2929 vc->vc_palette[k++] = default_grn[j] ; in vc_init()
2930 vc->vc_palette[k++] = default_blu[j] ; in vc_init()
2932 vc->vc_def_color = default_color; in vc_init()
2933 vc->vc_ulcolor = default_underline_color; in vc_init()
2934 vc->vc_itcolor = default_italic_color; in vc_init()
2935 vc->vc_halfcolor = 0x08; /* grey */ in vc_init()
2936 init_waitqueue_head(&vc->paste_wait); in vc_init()
2937 reset_terminal(vc, do_clear); in vc_init()
2949 struct vc_data *vc; in con_init() local
2984 vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT); in con_init()
2986 tty_port_init(&vc->port); in con_init()
2987 visual_init(vc, currcons, 1); in con_init()
2988 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT); in con_init()
2989 vc_init(vc, vc->vc_rows, vc->vc_cols, in con_init()
2990 currcons || !vc->vc_sw->con_save_screen); in con_init()
2993 master_display_fg = vc = vc_cons[currcons].d; in con_init()
2994 set_origin(vc); in con_init()
2995 save_screen(vc); in con_init()
2996 gotoxy(vc, vc->vc_x, vc->vc_y); in con_init()
2997 csi_J(vc, 0); in con_init()
2998 update_screen(vc); in con_init()
3000 vc->vc_can_do_color ? "colour" : "mono", in con_init()
3001 display_desc, vc->vc_cols, vc->vc_rows); in con_init()
3130 struct vc_data *vc = vc_cons[i].d; in do_bind_con_driver() local
3137 if (!vc || !vc->vc_sw) in do_bind_con_driver()
3142 if (CON_IS_VISIBLE(vc)) { in do_bind_con_driver()
3144 save_screen(vc); in do_bind_con_driver()
3147 old_was_color = vc->vc_can_do_color; in do_bind_con_driver()
3148 vc->vc_sw->con_deinit(vc); in do_bind_con_driver()
3149 vc->vc_origin = (unsigned long)vc->vc_screenbuf; in do_bind_con_driver()
3150 visual_init(vc, i, 0); in do_bind_con_driver()
3151 set_origin(vc); in do_bind_con_driver()
3152 update_attr(vc); in do_bind_con_driver()
3158 if (old_was_color != vc->vc_can_do_color) in do_bind_con_driver()
3159 clear_buffer_attributes(vc); in do_bind_con_driver()
3166 struct vc_data *vc = vc_cons[j].d; in do_bind_con_driver() local
3169 vc->vc_can_do_color ? "colour" : "mono", in do_bind_con_driver()
3170 desc, vc->vc_cols, vc->vc_rows); in do_bind_con_driver()
3173 vc = vc_cons[k].d; in do_bind_con_driver()
3174 update_screen(vc); in do_bind_con_driver()
3192 struct vc_data *vc = vc_cons[i].d; in con_is_graphics() local
3194 if (vc && vc->vc_mode == KD_GRAPHICS) { in con_is_graphics()
3500 int con_debug_enter(struct vc_data *vc) in con_debug_enter() argument
3507 saved_vc_mode = vc->vc_mode; in con_debug_enter()
3509 vc->vc_mode = KD_TEXT; in con_debug_enter()
3511 if (vc->vc_sw->con_debug_enter) in con_debug_enter()
3512 ret = vc->vc_sw->con_debug_enter(vc); in con_debug_enter()
3515 if (vc->vc_rows < 999) { in con_debug_enter()
3524 snprintf(lns, 4, "%i", vc->vc_rows); in con_debug_enter()
3528 if (vc->vc_cols < 999) { in con_debug_enter()
3537 snprintf(cols, 4, "%i", vc->vc_cols); in con_debug_enter()
3559 struct vc_data *vc; in con_debug_leave() local
3568 vc = vc_cons[fg_console].d; in con_debug_leave()
3569 if (vc->vc_sw->con_debug_leave) in con_debug_leave()
3570 ret = vc->vc_sw->con_debug_leave(vc); in con_debug_leave()
3783 struct vc_data *vc = vc_cons[fg_console].d; in do_blank_screen() local
3791 vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0); in do_blank_screen()
3798 hide_cursor(vc); in do_blank_screen()
3799 save_screen(vc); in do_blank_screen()
3800 vc->vc_sw->con_blank(vc, -1, 1); in do_blank_screen()
3803 set_origin(vc); in do_blank_screen()
3812 if (vc->vc_mode != KD_TEXT) { in do_blank_screen()
3817 hide_cursor(vc); in do_blank_screen()
3821 save_screen(vc); in do_blank_screen()
3823 i = vc->vc_sw->con_blank(vc, vesa_off_interval ? 1 : (vesa_blank_mode + 1), 0); in do_blank_screen()
3826 set_origin(vc); in do_blank_screen()
3835 vt_event_post(VT_EVENT_BLANK, vc->vc_num, vc->vc_num); in do_blank_screen()
3844 struct vc_data *vc; in do_unblank_screen() local
3864 vc = vc_cons[fg_console].d; in do_unblank_screen()
3866 if (vc->vc_mode != KD_TEXT && !vt_force_oops_output(vc)) in do_unblank_screen()
3875 if (vc->vc_sw->con_blank(vc, 0, leaving_gfx) || vt_force_oops_output(vc)) in do_unblank_screen()
3877 update_screen(vc); in do_unblank_screen()
3880 set_palette(vc); in do_unblank_screen()
3881 set_cursor(vc); in do_unblank_screen()
3882 vt_event_post(VT_EVENT_UNBLANK, vc->vc_num, vc->vc_num); in do_unblank_screen()
3944 static void set_palette(struct vc_data *vc) in set_palette() argument
3948 if (vc->vc_mode != KD_GRAPHICS) in set_palette()
3949 vc->vc_sw->con_set_palette(vc, color_table); in set_palette()
4005 void reset_palette(struct vc_data *vc) in reset_palette() argument
4009 vc->vc_palette[k++] = default_red[j]; in reset_palette()
4010 vc->vc_palette[k++] = default_grn[j]; in reset_palette()
4011 vc->vc_palette[k++] = default_blu[j]; in reset_palette()
4013 set_palette(vc); in reset_palette()
4031 static int con_font_get(struct vc_data *vc, struct console_font_op *op) in con_font_get() argument
4045 if (vc->vc_mode != KD_TEXT) in con_font_get()
4047 else if (vc->vc_sw->con_font_get) in con_font_get()
4048 rc = vc->vc_sw->con_font_get(vc, &font); in con_font_get()
4085 static int con_font_set(struct vc_data *vc, struct console_font_op *op) in con_font_set() argument
4091 if (vc->vc_mode != KD_TEXT) in con_font_set()
4129 if (vc->vc_mode != KD_TEXT) in con_font_set()
4131 else if (vc->vc_sw->con_font_set) in con_font_set()
4132 rc = vc->vc_sw->con_font_set(vc, &font, op->flags); in con_font_set()
4140 static int con_font_default(struct vc_data *vc, struct console_font_op *op) in con_font_default() argument
4156 if (vc->vc_mode != KD_TEXT) { in con_font_default()
4160 if (vc->vc_sw->con_font_default) in con_font_default()
4161 rc = vc->vc_sw->con_font_default(vc, &font, s); in con_font_default()
4172 static int con_font_copy(struct vc_data *vc, struct console_font_op *op) in con_font_copy() argument
4179 if (vc->vc_mode != KD_TEXT) in con_font_copy()
4181 else if (!vc->vc_sw->con_font_copy) in con_font_copy()
4185 else if (con == vc->vc_num) /* nothing to do */ in con_font_copy()
4188 rc = vc->vc_sw->con_font_copy(vc, con); in con_font_copy()
4193 int con_font_op(struct vc_data *vc, struct console_font_op *op) in con_font_op() argument
4197 return con_font_set(vc, op); in con_font_op()
4199 return con_font_get(vc, op); in con_font_op()
4201 return con_font_default(vc, op); in con_font_op()
4203 return con_font_copy(vc, op); in con_font_op()
4213 u16 screen_glyph(struct vc_data *vc, int offset) in screen_glyph() argument
4215 u16 w = scr_readw(screenpos(vc, offset, 1)); in screen_glyph()
4218 if (w & vc->vc_hi_font_mask) in screen_glyph()
4225 unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed) in screen_pos() argument
4227 return screenpos(vc, 2 * w_offset, viewed); in screen_pos()
4230 void getconsxy(struct vc_data *vc, unsigned char *p) in getconsxy() argument
4232 p[0] = vc->vc_x; in getconsxy()
4233 p[1] = vc->vc_y; in getconsxy()
4236 void putconsxy(struct vc_data *vc, unsigned char *p) in putconsxy() argument
4238 hide_cursor(vc); in putconsxy()
4239 gotoxy(vc, p[0], p[1]); in putconsxy()
4240 set_cursor(vc); in putconsxy()
4243 u16 vcs_scr_readw(struct vc_data *vc, const u16 *org) in vcs_scr_readw() argument
4245 if ((unsigned long)org == vc->vc_pos && softcursor_original != -1) in vcs_scr_readw()
4250 void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org) in vcs_scr_writew() argument
4253 if ((unsigned long)org == vc->vc_pos) { in vcs_scr_writew()
4255 add_softcursor(vc); in vcs_scr_writew()
4259 void vcs_scr_updated(struct vc_data *vc) in vcs_scr_updated() argument
4261 notify_update(vc); in vcs_scr_updated()