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