1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * console_struct.h 4 * 5 * Data structure describing single virtual console except for data 6 * used by vt.c. 7 * 8 * Fields marked with [#] must be set by the low-level driver. 9 * Fields marked with [!] can be changed by the low-level driver 10 * to achieve effects such as fast scrolling by changing the origin. 11 */ 12 13 #ifndef _LINUX_CONSOLE_STRUCT_H 14 #define _LINUX_CONSOLE_STRUCT_H 15 16 #include <linux/wait.h> 17 #include <linux/vt.h> 18 #include <linux/workqueue.h> 19 20 struct uni_pagedir; 21 struct uni_screen; 22 23 #define NPAR 16 24 25 enum vc_intensity { 26 VCI_HALF_BRIGHT, 27 VCI_NORMAL, 28 VCI_BOLD, 29 VCI_MASK = 0x3, 30 }; 31 32 /** 33 * struct vc_state -- state of a VC 34 * @x: cursor's x-position 35 * @y: cursor's y-position 36 * @color: foreground & background colors 37 * @Gx_charset: what's G0/G1 slot set to (like GRAF_MAP, LAT1_MAP) 38 * @charset: what character set to use (0=G0 or 1=G1) 39 * @intensity: see enum vc_intensity for values 40 * @reverse: reversed foreground/background colors 41 * 42 * These members are defined separately from struct vc_data as we save & 43 * restore them at times. 44 */ 45 struct vc_state { 46 unsigned int x, y; 47 48 unsigned char color; 49 50 unsigned char Gx_charset[2]; 51 unsigned int charset : 1; 52 53 /* attribute flags */ 54 enum vc_intensity intensity; 55 bool italic; 56 bool underline; 57 bool blink; 58 bool reverse; 59 }; 60 61 /* 62 * Example: vc_data of a console that was scrolled 3 lines down. 63 * 64 * Console buffer 65 * vc_screenbuf ---------> +----------------------+-. 66 * | initializing W | \ 67 * | initializing X | | 68 * | initializing Y | > scroll-back area 69 * | initializing Z | | 70 * | | / 71 * vc_visible_origin ---> ^+----------------------+-: 72 * (changes by scroll) || Welcome to linux | \ 73 * || | | 74 * vc_rows --->< | login: root | | visible on console 75 * || password: | > (vc_screenbuf_size is 76 * vc_origin -----------> || | | vc_size_row * vc_rows) 77 * (start when no scroll) || Last login: 12:28 | / 78 * v+----------------------+-: 79 * | Have a lot of fun... | \ 80 * vc_pos -----------------|--------v | > scroll-front area 81 * | ~ # cat_ | / 82 * vc_scr_end -----------> +----------------------+-: 83 * (vc_origin + | | \ EMPTY, to be filled by 84 * vc_screenbuf_size) | | / vc_video_erase_char 85 * +----------------------+-' 86 * <---- 2 * vc_cols -----> 87 * <---- vc_size_row -----> 88 * 89 * Note that every character in the console buffer is accompanied with an 90 * attribute in the buffer right after the character. This is not depicted 91 * in the figure. 92 */ 93 struct vc_data { 94 struct tty_port port; /* Upper level data */ 95 96 struct vc_state state, saved_state; 97 98 unsigned short vc_num; /* Console number */ 99 unsigned int vc_cols; /* [#] Console size */ 100 unsigned int vc_rows; 101 unsigned int vc_size_row; /* Bytes per row */ 102 unsigned int vc_scan_lines; /* # of scan lines */ 103 unsigned long vc_origin; /* [!] Start of real screen */ 104 unsigned long vc_scr_end; /* [!] End of real screen */ 105 unsigned long vc_visible_origin; /* [!] Top of visible window */ 106 unsigned int vc_top, vc_bottom; /* Scrolling region */ 107 const struct consw *vc_sw; 108 unsigned short *vc_screenbuf; /* In-memory character/attribute buffer */ 109 unsigned int vc_screenbuf_size; 110 unsigned char vc_mode; /* KD_TEXT, ... */ 111 /* attributes for all characters on screen */ 112 unsigned char vc_attr; /* Current attributes */ 113 unsigned char vc_def_color; /* Default colors */ 114 unsigned char vc_ulcolor; /* Color for underline mode */ 115 unsigned char vc_itcolor; 116 unsigned char vc_halfcolor; /* Color for half intensity mode */ 117 /* cursor */ 118 unsigned int vc_cursor_type; 119 unsigned short vc_complement_mask; /* [#] Xor mask for mouse pointer */ 120 unsigned short vc_s_complement_mask; /* Saved mouse pointer mask */ 121 unsigned long vc_pos; /* Cursor address */ 122 /* fonts */ 123 unsigned short vc_hi_font_mask; /* [#] Attribute set for upper 256 chars of font or 0 if not supported */ 124 struct console_font vc_font; /* Current VC font set */ 125 unsigned short vc_video_erase_char; /* Background erase character */ 126 /* VT terminal data */ 127 unsigned int vc_state; /* Escape sequence parser state */ 128 unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */ 129 /* data for manual vt switching */ 130 struct vt_mode vt_mode; 131 struct pid *vt_pid; 132 int vt_newvt; 133 wait_queue_head_t paste_wait; 134 /* mode flags */ 135 unsigned int vc_disp_ctrl : 1; /* Display chars < 32? */ 136 unsigned int vc_toggle_meta : 1; /* Toggle high bit? */ 137 unsigned int vc_decscnm : 1; /* Screen Mode */ 138 unsigned int vc_decom : 1; /* Origin Mode */ 139 unsigned int vc_decawm : 1; /* Autowrap Mode */ 140 unsigned int vc_deccm : 1; /* Cursor Visible */ 141 unsigned int vc_decim : 1; /* Insert Mode */ 142 /* misc */ 143 unsigned int vc_priv : 3; 144 unsigned int vc_need_wrap : 1; 145 unsigned int vc_can_do_color : 1; 146 unsigned int vc_report_mouse : 2; 147 unsigned char vc_utf : 1; /* Unicode UTF-8 encoding */ 148 unsigned char vc_utf_count; 149 int vc_utf_char; 150 unsigned int vc_tab_stop[8]; /* Tab stops. 256 columns. */ 151 unsigned char vc_palette[16*3]; /* Colour palette for VGA+ */ 152 unsigned short * vc_translate; 153 unsigned int vc_resize_user; /* resize request from user */ 154 unsigned int vc_bell_pitch; /* Console bell pitch */ 155 unsigned int vc_bell_duration; /* Console bell duration */ 156 unsigned short vc_cur_blink_ms; /* Cursor blink duration */ 157 struct vc_data **vc_display_fg; /* [!] Ptr to var holding fg console for this display */ 158 struct uni_pagedir *vc_uni_pagedir; 159 struct uni_pagedir **vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */ 160 struct uni_screen *vc_uni_screen; /* unicode screen content */ 161 /* additional information is in vt_kern.h */ 162 }; 163 164 struct vc { 165 struct vc_data *d; 166 struct work_struct SAK_work; 167 168 /* might add scrmem, kbd at some time, 169 to have everything in one place - the disadvantage 170 would be that vc_cons etc can no longer be static */ 171 }; 172 173 extern struct vc vc_cons [MAX_NR_CONSOLES]; 174 extern void vc_SAK(struct work_struct *work); 175 176 #define CUR_DEF 0 177 #define CUR_NONE 1 178 #define CUR_UNDERLINE 2 179 #define CUR_LOWER_THIRD 3 180 #define CUR_LOWER_HALF 4 181 #define CUR_TWO_THIRDS 5 182 #define CUR_BLOCK 6 183 #define CUR_HWMASK 0x0f 184 #define CUR_SWMASK 0xfff0 185 186 #define CUR_DEFAULT CUR_UNDERLINE 187 188 bool con_is_visible(const struct vc_data *vc); 189 190 #endif /* _LINUX_CONSOLE_STRUCT_H */ 191