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