]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - include/linux/console_struct.h
Merge tag 'kernel.sys.v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner...
[mirror_ubuntu-jammy-kernel.git] / include / linux / console_struct.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1da177e4
LT
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
217397d7
RD
13#ifndef _LINUX_CONSOLE_STRUCT_H
14#define _LINUX_CONSOLE_STRUCT_H
15
a8f340e3 16#include <linux/wait.h>
e07dea98 17#include <linux/vt.h>
8b6312f4 18#include <linux/workqueue.h>
e07dea98 19
e4bdab70 20struct uni_pagedir;
d8ae7242 21struct uni_screen;
1da177e4
LT
22
23#define NPAR 16
dbee4cff 24#define VC_TABSTOPS_COUNT 256U
1da177e4 25
b84ae3dc
JS
26enum vc_intensity {
27 VCI_HALF_BRIGHT,
28 VCI_NORMAL,
29 VCI_BOLD,
30 VCI_MASK = 0x3,
31};
32
28bc24fc
JS
33/**
34 * struct vc_state -- state of a VC
35 * @x: cursor's x-position
36 * @y: cursor's y-position
37 * @color: foreground & background colors
b70ec4d9 38 * @Gx_charset: what's G0/G1 slot set to (like GRAF_MAP, LAT1_MAP)
28bc24fc 39 * @charset: what character set to use (0=G0 or 1=G1)
b84ae3dc 40 * @intensity: see enum vc_intensity for values
28bc24fc
JS
41 * @reverse: reversed foreground/background colors
42 *
43 * These members are defined separately from struct vc_data as we save &
44 * restore them at times.
45 */
46struct vc_state {
47 unsigned int x, y;
48
49 unsigned char color;
50
b70ec4d9 51 unsigned char Gx_charset[2];
28bc24fc
JS
52 unsigned int charset : 1;
53
54 /* attribute flags */
b84ae3dc 55 enum vc_intensity intensity;
77bc14f2
JS
56 bool italic;
57 bool underline;
58 bool blink;
59 bool reverse;
28bc24fc
JS
60};
61
a4bedd01
JS
62/*
63 * Example: vc_data of a console that was scrolled 3 lines down.
64 *
65 * Console buffer
66 * vc_screenbuf ---------> +----------------------+-.
67 * | initializing W | \
68 * | initializing X | |
69 * | initializing Y | > scroll-back area
70 * | initializing Z | |
71 * | | /
72 * vc_visible_origin ---> ^+----------------------+-:
73 * (changes by scroll) || Welcome to linux | \
74 * || | |
75 * vc_rows --->< | login: root | | visible on console
76 * || password: | > (vc_screenbuf_size is
77 * vc_origin -----------> || | | vc_size_row * vc_rows)
78 * (start when no scroll) || Last login: 12:28 | /
79 * v+----------------------+-:
80 * | Have a lot of fun... | \
81 * vc_pos -----------------|--------v | > scroll-front area
82 * | ~ # cat_ | /
83 * vc_scr_end -----------> +----------------------+-:
84 * (vc_origin + | | \ EMPTY, to be filled by
85 * vc_screenbuf_size) | | / vc_video_erase_char
86 * +----------------------+-'
87 * <---- 2 * vc_cols ----->
88 * <---- vc_size_row ----->
89 *
90 * Note that every character in the console buffer is accompanied with an
91 * attribute in the buffer right after the character. This is not depicted
92 * in the figure.
93 */
1da177e4 94struct vc_data {
ff917ba4
AC
95 struct tty_port port; /* Upper level data */
96
28bc24fc
JS
97 struct vc_state state, saved_state;
98
1da177e4
LT
99 unsigned short vc_num; /* Console number */
100 unsigned int vc_cols; /* [#] Console size */
101 unsigned int vc_rows;
102 unsigned int vc_size_row; /* Bytes per row */
103 unsigned int vc_scan_lines; /* # of scan lines */
860dafa9 104 unsigned int vc_cell_height; /* CRTC character cell height */
1da177e4
LT
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 */
1da177e4 116 unsigned char vc_ulcolor; /* Color for underline mode */
fa6ce9ab 117 unsigned char vc_itcolor;
1da177e4
LT
118 unsigned char vc_halfcolor; /* Color for half intensity mode */
119 /* cursor */
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 */
1da177e4
LT
123 unsigned long vc_pos; /* Cursor address */
124 /* fonts */
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 */
1da177e4
LT
131 /* data for manual vt switching */
132 struct vt_mode vt_mode;
bde0d2c9 133 struct pid *vt_pid;
1da177e4
LT
134 int vt_newvt;
135 wait_queue_head_t paste_wait;
136 /* mode flags */
1da177e4
LT
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 */
1da177e4 144 /* misc */
2ff5c5a1 145 unsigned int vc_priv : 3;
1da177e4
LT
146 unsigned int vc_need_wrap : 1;
147 unsigned int vc_can_do_color : 1;
148 unsigned int vc_report_mouse : 2;
1da177e4
LT
149 unsigned char vc_utf : 1; /* Unicode UTF-8 encoding */
150 unsigned char vc_utf_count;
151 int vc_utf_char;
dbee4cff 152 DECLARE_BITMAP(vc_tab_stop, VC_TABSTOPS_COUNT); /* Tab stops. 256 columns. */
1da177e4
LT
153 unsigned char vc_palette[16*3]; /* Colour palette for VGA+ */
154 unsigned short * vc_translate;
e400b6ec 155 unsigned int vc_resize_user; /* resize request from user */
1da177e4
LT
156 unsigned int vc_bell_pitch; /* Console bell pitch */
157 unsigned int vc_bell_duration; /* Console bell duration */
bd63364c 158 unsigned short vc_cur_blink_ms; /* Cursor blink duration */
1da177e4 159 struct vc_data **vc_display_fg; /* [!] Ptr to var holding fg console for this display */
e4bdab70
TI
160 struct uni_pagedir *vc_uni_pagedir;
161 struct uni_pagedir **vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */
d8ae7242 162 struct uni_screen *vc_uni_screen; /* unicode screen content */
1da177e4
LT
163 /* additional information is in vt_kern.h */
164};
165
166struct vc {
167 struct vc_data *d;
8b6312f4 168 struct work_struct SAK_work;
1da177e4 169
f4c6fbc9 170 /* might add scrmem, kbd at some time,
7d4a3112 171 to have everything in one place */
1da177e4
LT
172};
173
174extern struct vc vc_cons [MAX_NR_CONSOLES];
8b6312f4 175extern void vc_SAK(struct work_struct *work);
1da177e4 176
4dfa3c54
JS
177#define CUR_MAKE(size, change, set) ((size) | ((change) << 8) | \
178 ((set) << 16))
179#define CUR_SIZE(c) ((c) & 0x00000f)
180# define CUR_DEF 0
181# define CUR_NONE 1
182# define CUR_UNDERLINE 2
183# define CUR_LOWER_THIRD 3
184# define CUR_LOWER_HALF 4
185# define CUR_TWO_THIRDS 5
186# define CUR_BLOCK 6
187#define CUR_SW 0x000010
188#define CUR_ALWAYS_BG 0x000020
189#define CUR_INVERT_FG_BG 0x000040
190#define CUR_FG 0x000700
191#define CUR_BG 0x007000
192#define CUR_CHANGE(c) ((c) & 0x00ff00)
193#define CUR_SET(c) (((c) & 0xff0000) >> 8)
1da177e4 194
ddde3c18 195bool con_is_visible(const struct vc_data *vc);
217397d7
RD
196
197#endif /* _LINUX_CONSOLE_STRUCT_H */