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 204173f018SJiri Slaby struct uni_pagedict; 211da177e4SLinus Torvalds 221da177e4SLinus Torvalds #define NPAR 16 23dbee4cffSJiri Slaby #define VC_TABSTOPS_COUNT 256U 241da177e4SLinus Torvalds 25b84ae3dcSJiri Slaby enum vc_intensity { 26b84ae3dcSJiri Slaby VCI_HALF_BRIGHT, 27b84ae3dcSJiri Slaby VCI_NORMAL, 28b84ae3dcSJiri Slaby VCI_BOLD, 29b84ae3dcSJiri Slaby VCI_MASK = 0x3, 30b84ae3dcSJiri Slaby }; 31b84ae3dcSJiri Slaby 3228bc24fcSJiri Slaby /** 3328bc24fcSJiri Slaby * struct vc_state -- state of a VC 3428bc24fcSJiri Slaby * @x: cursor's x-position 3528bc24fcSJiri Slaby * @y: cursor's y-position 3628bc24fcSJiri Slaby * @color: foreground & background colors 37b70ec4d9SJiri Slaby * @Gx_charset: what's G0/G1 slot set to (like GRAF_MAP, LAT1_MAP) 3828bc24fcSJiri Slaby * @charset: what character set to use (0=G0 or 1=G1) 39b84ae3dcSJiri Slaby * @intensity: see enum vc_intensity for values 4028bc24fcSJiri Slaby * @reverse: reversed foreground/background colors 4128bc24fcSJiri Slaby * 4228bc24fcSJiri Slaby * These members are defined separately from struct vc_data as we save & 4328bc24fcSJiri Slaby * restore them at times. 4428bc24fcSJiri Slaby */ 4528bc24fcSJiri Slaby struct vc_state { 4628bc24fcSJiri Slaby unsigned int x, y; 4728bc24fcSJiri Slaby 4828bc24fcSJiri Slaby unsigned char color; 4928bc24fcSJiri Slaby 50b70ec4d9SJiri Slaby unsigned char Gx_charset[2]; 5128bc24fcSJiri Slaby unsigned int charset : 1; 5228bc24fcSJiri Slaby 5328bc24fcSJiri Slaby /* attribute flags */ 54b84ae3dcSJiri Slaby enum vc_intensity intensity; 5577bc14f2SJiri Slaby bool italic; 5677bc14f2SJiri Slaby bool underline; 5777bc14f2SJiri Slaby bool blink; 5877bc14f2SJiri Slaby bool reverse; 5928bc24fcSJiri Slaby }; 6028bc24fcSJiri Slaby 61a4bedd01SJiri Slaby /* 62a4bedd01SJiri Slaby * Example: vc_data of a console that was scrolled 3 lines down. 63a4bedd01SJiri Slaby * 64a4bedd01SJiri Slaby * Console buffer 65a4bedd01SJiri Slaby * vc_screenbuf ---------> +----------------------+-. 66a4bedd01SJiri Slaby * | initializing W | \ 67a4bedd01SJiri Slaby * | initializing X | | 68a4bedd01SJiri Slaby * | initializing Y | > scroll-back area 69a4bedd01SJiri Slaby * | initializing Z | | 70a4bedd01SJiri Slaby * | | / 71a4bedd01SJiri Slaby * vc_visible_origin ---> ^+----------------------+-: 72a4bedd01SJiri Slaby * (changes by scroll) || Welcome to linux | \ 73a4bedd01SJiri Slaby * || | | 74a4bedd01SJiri Slaby * vc_rows --->< | login: root | | visible on console 75a4bedd01SJiri Slaby * || password: | > (vc_screenbuf_size is 76a4bedd01SJiri Slaby * vc_origin -----------> || | | vc_size_row * vc_rows) 77a4bedd01SJiri Slaby * (start when no scroll) || Last login: 12:28 | / 78a4bedd01SJiri Slaby * v+----------------------+-: 79a4bedd01SJiri Slaby * | Have a lot of fun... | \ 80a4bedd01SJiri Slaby * vc_pos -----------------|--------v | > scroll-front area 81a4bedd01SJiri Slaby * | ~ # cat_ | / 82a4bedd01SJiri Slaby * vc_scr_end -----------> +----------------------+-: 83a4bedd01SJiri Slaby * (vc_origin + | | \ EMPTY, to be filled by 84a4bedd01SJiri Slaby * vc_screenbuf_size) | | / vc_video_erase_char 85a4bedd01SJiri Slaby * +----------------------+-' 86a4bedd01SJiri Slaby * <---- 2 * vc_cols -----> 87a4bedd01SJiri Slaby * <---- vc_size_row -----> 88a4bedd01SJiri Slaby * 89a4bedd01SJiri Slaby * Note that every character in the console buffer is accompanied with an 90a4bedd01SJiri Slaby * attribute in the buffer right after the character. This is not depicted 91a4bedd01SJiri Slaby * in the figure. 92a4bedd01SJiri Slaby */ 931da177e4SLinus Torvalds struct vc_data { 94ff917ba4SAlan Cox struct tty_port port; /* Upper level data */ 95ff917ba4SAlan Cox 9628bc24fcSJiri Slaby struct vc_state state, saved_state; 9728bc24fcSJiri Slaby 981da177e4SLinus Torvalds unsigned short vc_num; /* Console number */ 991da177e4SLinus Torvalds unsigned int vc_cols; /* [#] Console size */ 1001da177e4SLinus Torvalds unsigned int vc_rows; 1011da177e4SLinus Torvalds unsigned int vc_size_row; /* Bytes per row */ 1021da177e4SLinus Torvalds unsigned int vc_scan_lines; /* # of scan lines */ 103860dafa9SMaciej W. Rozycki unsigned int vc_cell_height; /* CRTC character cell height */ 1041da177e4SLinus Torvalds unsigned long vc_origin; /* [!] Start of real screen */ 1051da177e4SLinus Torvalds unsigned long vc_scr_end; /* [!] End of real screen */ 1061da177e4SLinus Torvalds unsigned long vc_visible_origin; /* [!] Top of visible window */ 1071da177e4SLinus Torvalds unsigned int vc_top, vc_bottom; /* Scrolling region */ 1081da177e4SLinus Torvalds const struct consw *vc_sw; 1091da177e4SLinus Torvalds unsigned short *vc_screenbuf; /* In-memory character/attribute buffer */ 1101da177e4SLinus Torvalds unsigned int vc_screenbuf_size; 1111da177e4SLinus Torvalds unsigned char vc_mode; /* KD_TEXT, ... */ 1121da177e4SLinus Torvalds /* attributes for all characters on screen */ 1131da177e4SLinus Torvalds unsigned char vc_attr; /* Current attributes */ 1141da177e4SLinus Torvalds unsigned char vc_def_color; /* Default colors */ 1151da177e4SLinus Torvalds unsigned char vc_ulcolor; /* Color for underline mode */ 116fa6ce9abSJan Engelhardt unsigned char vc_itcolor; 1171da177e4SLinus Torvalds unsigned char vc_halfcolor; /* Color for half intensity mode */ 1181da177e4SLinus Torvalds /* cursor */ 1191da177e4SLinus Torvalds unsigned int vc_cursor_type; 1201da177e4SLinus Torvalds unsigned short vc_complement_mask; /* [#] Xor mask for mouse pointer */ 1211da177e4SLinus Torvalds unsigned short vc_s_complement_mask; /* Saved mouse pointer mask */ 1221da177e4SLinus Torvalds unsigned long vc_pos; /* Cursor address */ 1231da177e4SLinus Torvalds /* fonts */ 1241da177e4SLinus Torvalds unsigned short vc_hi_font_mask; /* [#] Attribute set for upper 256 chars of font or 0 if not supported */ 1251da177e4SLinus Torvalds struct console_font vc_font; /* Current VC font set */ 1261da177e4SLinus Torvalds unsigned short vc_video_erase_char; /* Background erase character */ 1271da177e4SLinus Torvalds /* VT terminal data */ 1281da177e4SLinus Torvalds unsigned int vc_state; /* Escape sequence parser state */ 1291da177e4SLinus Torvalds unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */ 1301da177e4SLinus Torvalds /* data for manual vt switching */ 1311da177e4SLinus Torvalds struct vt_mode vt_mode; 132bde0d2c9SEric W. Biederman struct pid *vt_pid; 1331da177e4SLinus Torvalds int vt_newvt; 1341da177e4SLinus Torvalds wait_queue_head_t paste_wait; 1351da177e4SLinus Torvalds /* mode flags */ 1361da177e4SLinus Torvalds unsigned int vc_disp_ctrl : 1; /* Display chars < 32? */ 1371da177e4SLinus Torvalds unsigned int vc_toggle_meta : 1; /* Toggle high bit? */ 1381da177e4SLinus Torvalds unsigned int vc_decscnm : 1; /* Screen Mode */ 1391da177e4SLinus Torvalds unsigned int vc_decom : 1; /* Origin Mode */ 1401da177e4SLinus Torvalds unsigned int vc_decawm : 1; /* Autowrap Mode */ 1411da177e4SLinus Torvalds unsigned int vc_deccm : 1; /* Cursor Visible */ 1421da177e4SLinus Torvalds unsigned int vc_decim : 1; /* Insert Mode */ 1431da177e4SLinus Torvalds /* misc */ 1442ff5c5a1SMartin Hostettler unsigned int vc_priv : 3; 1451da177e4SLinus Torvalds unsigned int vc_need_wrap : 1; 1461da177e4SLinus Torvalds unsigned int vc_can_do_color : 1; 1471da177e4SLinus Torvalds unsigned int vc_report_mouse : 2; 1481da177e4SLinus Torvalds unsigned char vc_utf : 1; /* Unicode UTF-8 encoding */ 1491da177e4SLinus Torvalds unsigned char vc_utf_count; 1501da177e4SLinus Torvalds int vc_utf_char; 151dbee4cffSJiri Slaby DECLARE_BITMAP(vc_tab_stop, VC_TABSTOPS_COUNT); /* Tab stops. 256 columns. */ 1521da177e4SLinus Torvalds unsigned char vc_palette[16*3]; /* Colour palette for VGA+ */ 1531da177e4SLinus Torvalds unsigned short * vc_translate; 1541da177e4SLinus Torvalds unsigned int vc_bell_pitch; /* Console bell pitch */ 1551da177e4SLinus Torvalds unsigned int vc_bell_duration; /* Console bell duration */ 156bd63364cSScot Doyle unsigned short vc_cur_blink_ms; /* Cursor blink duration */ 1571da177e4SLinus Torvalds struct vc_data **vc_display_fg; /* [!] Ptr to var holding fg console for this display */ 1588da443b1SJiri Slaby struct uni_pagedict *uni_pagedict; 1598da443b1SJiri Slaby struct uni_pagedict **uni_pagedict_loc; /* [!] Location of uni_pagedict variable for this console */ 160*feb36abbSJiri Slaby (SUSE) u32 **vc_uni_lines; /* unicode screen content */ 1611da177e4SLinus Torvalds /* additional information is in vt_kern.h */ 1621da177e4SLinus Torvalds }; 1631da177e4SLinus Torvalds 1641da177e4SLinus Torvalds struct vc { 1651da177e4SLinus Torvalds struct vc_data *d; 1668b6312f4SEric W. Biederman struct work_struct SAK_work; 1671da177e4SLinus Torvalds 168f4c6fbc9SAdam Borowski /* might add scrmem, kbd at some time, 1697d4a3112SJiri Slaby to have everything in one place */ 1701da177e4SLinus Torvalds }; 1711da177e4SLinus Torvalds 1721da177e4SLinus Torvalds extern struct vc vc_cons [MAX_NR_CONSOLES]; 1738b6312f4SEric W. Biederman extern void vc_SAK(struct work_struct *work); 1741da177e4SLinus Torvalds 1754dfa3c54SJiri Slaby #define CUR_MAKE(size, change, set) ((size) | ((change) << 8) | \ 1764dfa3c54SJiri Slaby ((set) << 16)) 1774dfa3c54SJiri Slaby #define CUR_SIZE(c) ((c) & 0x00000f) 1781da177e4SLinus Torvalds # define CUR_DEF 0 1791da177e4SLinus Torvalds # define CUR_NONE 1 1801da177e4SLinus Torvalds # define CUR_UNDERLINE 2 1811da177e4SLinus Torvalds # define CUR_LOWER_THIRD 3 1821da177e4SLinus Torvalds # define CUR_LOWER_HALF 4 1831da177e4SLinus Torvalds # define CUR_TWO_THIRDS 5 1841da177e4SLinus Torvalds # define CUR_BLOCK 6 1854dfa3c54SJiri Slaby #define CUR_SW 0x000010 1864dfa3c54SJiri Slaby #define CUR_ALWAYS_BG 0x000020 1874dfa3c54SJiri Slaby #define CUR_INVERT_FG_BG 0x000040 1884dfa3c54SJiri Slaby #define CUR_FG 0x000700 1894dfa3c54SJiri Slaby #define CUR_BG 0x007000 1904dfa3c54SJiri Slaby #define CUR_CHANGE(c) ((c) & 0x00ff00) 1914dfa3c54SJiri Slaby #define CUR_SET(c) (((c) & 0xff0000) >> 8) 1921da177e4SLinus Torvalds 193ddde3c18SDaniel Vetter bool con_is_visible(const struct vc_data *vc); 194217397d7SRobert P. J. Day 195217397d7SRobert P. J. Day #endif /* _LINUX_CONSOLE_STRUCT_H */ 196