1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21da177e4SLinus Torvalds /* 31da177e4SLinus Torvalds * console_struct.h 41da177e4SLinus Torvalds * 51da177e4SLinus Torvalds * Data structure describing single virtual console except for data 61da177e4SLinus Torvalds * used by vt.c. 71da177e4SLinus Torvalds * 81da177e4SLinus Torvalds * Fields marked with [#] must be set by the low-level driver. 91da177e4SLinus Torvalds * Fields marked with [!] can be changed by the low-level driver 101da177e4SLinus Torvalds * to achieve effects such as fast scrolling by changing the origin. 111da177e4SLinus Torvalds */ 121da177e4SLinus Torvalds 13217397d7SRobert P. J. Day #ifndef _LINUX_CONSOLE_STRUCT_H 14217397d7SRobert P. J. Day #define _LINUX_CONSOLE_STRUCT_H 15217397d7SRobert P. J. Day 16a8f340e3SJon Smirl #include <linux/wait.h> 17e07dea98SAntonino A. Daplas #include <linux/vt.h> 188b6312f4SEric W. Biederman #include <linux/workqueue.h> 19e07dea98SAntonino A. Daplas 20e4bdab70STakashi Iwai struct uni_pagedir; 21d8ae7242SNicolas Pitre struct uni_screen; 221da177e4SLinus Torvalds 231da177e4SLinus Torvalds #define NPAR 16 241da177e4SLinus Torvalds 25a4bedd01SJiri Slaby /* 26a4bedd01SJiri Slaby * Example: vc_data of a console that was scrolled 3 lines down. 27a4bedd01SJiri Slaby * 28a4bedd01SJiri Slaby * Console buffer 29a4bedd01SJiri Slaby * vc_screenbuf ---------> +----------------------+-. 30a4bedd01SJiri Slaby * | initializing W | \ 31a4bedd01SJiri Slaby * | initializing X | | 32a4bedd01SJiri Slaby * | initializing Y | > scroll-back area 33a4bedd01SJiri Slaby * | initializing Z | | 34a4bedd01SJiri Slaby * | | / 35a4bedd01SJiri Slaby * vc_visible_origin ---> ^+----------------------+-: 36a4bedd01SJiri Slaby * (changes by scroll) || Welcome to linux | \ 37a4bedd01SJiri Slaby * || | | 38a4bedd01SJiri Slaby * vc_rows --->< | login: root | | visible on console 39a4bedd01SJiri Slaby * || password: | > (vc_screenbuf_size is 40a4bedd01SJiri Slaby * vc_origin -----------> || | | vc_size_row * vc_rows) 41a4bedd01SJiri Slaby * (start when no scroll) || Last login: 12:28 | / 42a4bedd01SJiri Slaby * v+----------------------+-: 43a4bedd01SJiri Slaby * | Have a lot of fun... | \ 44a4bedd01SJiri Slaby * vc_pos -----------------|--------v | > scroll-front area 45a4bedd01SJiri Slaby * | ~ # cat_ | / 46a4bedd01SJiri Slaby * vc_scr_end -----------> +----------------------+-: 47a4bedd01SJiri Slaby * (vc_origin + | | \ EMPTY, to be filled by 48a4bedd01SJiri Slaby * vc_screenbuf_size) | | / vc_video_erase_char 49a4bedd01SJiri Slaby * +----------------------+-' 50a4bedd01SJiri Slaby * <---- 2 * vc_cols -----> 51a4bedd01SJiri Slaby * <---- vc_size_row -----> 52a4bedd01SJiri Slaby * 53a4bedd01SJiri Slaby * Note that every character in the console buffer is accompanied with an 54a4bedd01SJiri Slaby * attribute in the buffer right after the character. This is not depicted 55a4bedd01SJiri Slaby * in the figure. 56a4bedd01SJiri Slaby */ 571da177e4SLinus Torvalds struct vc_data { 58ff917ba4SAlan Cox struct tty_port port; /* Upper level data */ 59ff917ba4SAlan Cox 601da177e4SLinus Torvalds unsigned short vc_num; /* Console number */ 611da177e4SLinus Torvalds unsigned int vc_cols; /* [#] Console size */ 621da177e4SLinus Torvalds unsigned int vc_rows; 631da177e4SLinus Torvalds unsigned int vc_size_row; /* Bytes per row */ 641da177e4SLinus Torvalds unsigned int vc_scan_lines; /* # of scan lines */ 651da177e4SLinus Torvalds unsigned long vc_origin; /* [!] Start of real screen */ 661da177e4SLinus Torvalds unsigned long vc_scr_end; /* [!] End of real screen */ 671da177e4SLinus Torvalds unsigned long vc_visible_origin; /* [!] Top of visible window */ 681da177e4SLinus Torvalds unsigned int vc_top, vc_bottom; /* Scrolling region */ 691da177e4SLinus Torvalds const struct consw *vc_sw; 701da177e4SLinus Torvalds unsigned short *vc_screenbuf; /* In-memory character/attribute buffer */ 711da177e4SLinus Torvalds unsigned int vc_screenbuf_size; 721da177e4SLinus Torvalds unsigned char vc_mode; /* KD_TEXT, ... */ 731da177e4SLinus Torvalds /* attributes for all characters on screen */ 741da177e4SLinus Torvalds unsigned char vc_attr; /* Current attributes */ 751da177e4SLinus Torvalds unsigned char vc_def_color; /* Default colors */ 761da177e4SLinus Torvalds unsigned char vc_color; /* Foreground & background */ 771da177e4SLinus Torvalds unsigned char vc_s_color; /* Saved foreground & background */ 781da177e4SLinus Torvalds unsigned char vc_ulcolor; /* Color for underline mode */ 79fa6ce9abSJan Engelhardt unsigned char vc_itcolor; 801da177e4SLinus Torvalds unsigned char vc_halfcolor; /* Color for half intensity mode */ 811da177e4SLinus Torvalds /* cursor */ 821da177e4SLinus Torvalds unsigned int vc_cursor_type; 831da177e4SLinus Torvalds unsigned short vc_complement_mask; /* [#] Xor mask for mouse pointer */ 841da177e4SLinus Torvalds unsigned short vc_s_complement_mask; /* Saved mouse pointer mask */ 851da177e4SLinus Torvalds unsigned int vc_x, vc_y; /* Cursor position */ 861da177e4SLinus Torvalds unsigned int vc_saved_x, vc_saved_y; 871da177e4SLinus Torvalds unsigned long vc_pos; /* Cursor address */ 881da177e4SLinus Torvalds /* fonts */ 891da177e4SLinus Torvalds unsigned short vc_hi_font_mask; /* [#] Attribute set for upper 256 chars of font or 0 if not supported */ 901da177e4SLinus Torvalds struct console_font vc_font; /* Current VC font set */ 911da177e4SLinus Torvalds unsigned short vc_video_erase_char; /* Background erase character */ 921da177e4SLinus Torvalds /* VT terminal data */ 931da177e4SLinus Torvalds unsigned int vc_state; /* Escape sequence parser state */ 941da177e4SLinus Torvalds unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */ 951da177e4SLinus Torvalds /* data for manual vt switching */ 961da177e4SLinus Torvalds struct vt_mode vt_mode; 97bde0d2c9SEric W. Biederman struct pid *vt_pid; 981da177e4SLinus Torvalds int vt_newvt; 991da177e4SLinus Torvalds wait_queue_head_t paste_wait; 1001da177e4SLinus Torvalds /* mode flags */ 1011da177e4SLinus Torvalds unsigned int vc_charset : 1; /* Character set G0 / G1 */ 1021da177e4SLinus Torvalds unsigned int vc_s_charset : 1; /* Saved character set */ 1031da177e4SLinus Torvalds unsigned int vc_disp_ctrl : 1; /* Display chars < 32? */ 1041da177e4SLinus Torvalds unsigned int vc_toggle_meta : 1; /* Toggle high bit? */ 1051da177e4SLinus Torvalds unsigned int vc_decscnm : 1; /* Screen Mode */ 1061da177e4SLinus Torvalds unsigned int vc_decom : 1; /* Origin Mode */ 1071da177e4SLinus Torvalds unsigned int vc_decawm : 1; /* Autowrap Mode */ 1081da177e4SLinus Torvalds unsigned int vc_deccm : 1; /* Cursor Visible */ 1091da177e4SLinus Torvalds unsigned int vc_decim : 1; /* Insert Mode */ 1101da177e4SLinus Torvalds /* attribute flags */ 1111da177e4SLinus Torvalds unsigned int vc_intensity : 2; /* 0=half-bright, 1=normal, 2=bold */ 112fa6ce9abSJan Engelhardt unsigned int vc_italic:1; 1131da177e4SLinus Torvalds unsigned int vc_underline : 1; 1141da177e4SLinus Torvalds unsigned int vc_blink : 1; 1151da177e4SLinus Torvalds unsigned int vc_reverse : 1; 1161da177e4SLinus Torvalds unsigned int vc_s_intensity : 2; /* saved rendition */ 117fa6ce9abSJan Engelhardt unsigned int vc_s_italic:1; 1181da177e4SLinus Torvalds unsigned int vc_s_underline : 1; 1191da177e4SLinus Torvalds unsigned int vc_s_blink : 1; 1201da177e4SLinus Torvalds unsigned int vc_s_reverse : 1; 1211da177e4SLinus Torvalds /* misc */ 1221da177e4SLinus Torvalds unsigned int vc_ques : 1; 1231da177e4SLinus Torvalds unsigned int vc_need_wrap : 1; 1241da177e4SLinus Torvalds unsigned int vc_can_do_color : 1; 1251da177e4SLinus Torvalds unsigned int vc_report_mouse : 2; 1261da177e4SLinus Torvalds unsigned char vc_utf : 1; /* Unicode UTF-8 encoding */ 1271da177e4SLinus Torvalds unsigned char vc_utf_count; 1281da177e4SLinus Torvalds int vc_utf_char; 1291da177e4SLinus Torvalds unsigned int vc_tab_stop[8]; /* Tab stops. 256 columns. */ 1301da177e4SLinus Torvalds unsigned char vc_palette[16*3]; /* Colour palette for VGA+ */ 1311da177e4SLinus Torvalds unsigned short * vc_translate; 1321da177e4SLinus Torvalds unsigned char vc_G0_charset; 1331da177e4SLinus Torvalds unsigned char vc_G1_charset; 1341da177e4SLinus Torvalds unsigned char vc_saved_G0; 1351da177e4SLinus Torvalds unsigned char vc_saved_G1; 136e400b6ecSAntonino A. Daplas unsigned int vc_resize_user; /* resize request from user */ 1371da177e4SLinus Torvalds unsigned int vc_bell_pitch; /* Console bell pitch */ 1381da177e4SLinus Torvalds unsigned int vc_bell_duration; /* Console bell duration */ 139bd63364cSScot Doyle unsigned short vc_cur_blink_ms; /* Cursor blink duration */ 1401da177e4SLinus Torvalds struct vc_data **vc_display_fg; /* [!] Ptr to var holding fg console for this display */ 141e4bdab70STakashi Iwai struct uni_pagedir *vc_uni_pagedir; 142e4bdab70STakashi Iwai struct uni_pagedir **vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */ 143d8ae7242SNicolas Pitre struct uni_screen *vc_uni_screen; /* unicode screen content */ 1448fd4bd22SJesse Barnes bool vc_panic_force_write; /* when oops/panic this VC can accept forced output/blanking */ 1451da177e4SLinus Torvalds /* additional information is in vt_kern.h */ 1461da177e4SLinus Torvalds }; 1471da177e4SLinus Torvalds 1481da177e4SLinus Torvalds struct vc { 1491da177e4SLinus Torvalds struct vc_data *d; 1508b6312f4SEric W. Biederman struct work_struct SAK_work; 1511da177e4SLinus Torvalds 152*f4c6fbc9SAdam Borowski /* might add scrmem, kbd at some time, 1531da177e4SLinus Torvalds to have everything in one place - the disadvantage 1541da177e4SLinus Torvalds would be that vc_cons etc can no longer be static */ 1551da177e4SLinus Torvalds }; 1561da177e4SLinus Torvalds 1571da177e4SLinus Torvalds extern struct vc vc_cons [MAX_NR_CONSOLES]; 1588b6312f4SEric W. Biederman extern void vc_SAK(struct work_struct *work); 1591da177e4SLinus Torvalds 1601da177e4SLinus Torvalds #define CUR_DEF 0 1611da177e4SLinus Torvalds #define CUR_NONE 1 1621da177e4SLinus Torvalds #define CUR_UNDERLINE 2 1631da177e4SLinus Torvalds #define CUR_LOWER_THIRD 3 1641da177e4SLinus Torvalds #define CUR_LOWER_HALF 4 1651da177e4SLinus Torvalds #define CUR_TWO_THIRDS 5 1661da177e4SLinus Torvalds #define CUR_BLOCK 6 1671da177e4SLinus Torvalds #define CUR_HWMASK 0x0f 1681da177e4SLinus Torvalds #define CUR_SWMASK 0xfff0 1691da177e4SLinus Torvalds 1701da177e4SLinus Torvalds #define CUR_DEFAULT CUR_UNDERLINE 1711da177e4SLinus Torvalds 1726ca8dfd7SJiri Slaby static inline bool con_is_visible(const struct vc_data *vc) 1736ca8dfd7SJiri Slaby { 1746ca8dfd7SJiri Slaby return *vc->vc_display_fg == vc; 1756ca8dfd7SJiri Slaby } 176217397d7SRobert P. J. Day 177217397d7SRobert P. J. Day #endif /* _LINUX_CONSOLE_STRUCT_H */ 178