xref: /linux-6.15/include/linux/console_struct.h (revision 28bc24fc)
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 
20e4bdab70STakashi Iwai struct uni_pagedir;
21d8ae7242SNicolas Pitre struct uni_screen;
221da177e4SLinus Torvalds 
231da177e4SLinus Torvalds #define NPAR 16
241da177e4SLinus Torvalds 
25*28bc24fcSJiri Slaby /**
26*28bc24fcSJiri Slaby  * struct vc_state -- state of a VC
27*28bc24fcSJiri Slaby  * @x: cursor's x-position
28*28bc24fcSJiri Slaby  * @y: cursor's y-position
29*28bc24fcSJiri Slaby  * @color: foreground & background colors
30*28bc24fcSJiri Slaby  * @G0_charset: what's G0 slot set to (like GRAF_MAP, LAT1_MAP)
31*28bc24fcSJiri Slaby  * @G1_charset: what's G1 slot set to (like GRAF_MAP, LAT1_MAP)
32*28bc24fcSJiri Slaby  * @charset: what character set to use (0=G0 or 1=G1)
33*28bc24fcSJiri Slaby  * @intensity: 0=half-bright, 1=normal, 2=bold
34*28bc24fcSJiri Slaby  * @reverse: reversed foreground/background colors
35*28bc24fcSJiri Slaby  *
36*28bc24fcSJiri Slaby  * These members are defined separately from struct vc_data as we save &
37*28bc24fcSJiri Slaby  * restore them at times.
38*28bc24fcSJiri Slaby  */
39*28bc24fcSJiri Slaby struct vc_state {
40*28bc24fcSJiri Slaby 	unsigned int	x, y;
41*28bc24fcSJiri Slaby 
42*28bc24fcSJiri Slaby 	unsigned char	color;
43*28bc24fcSJiri Slaby 
44*28bc24fcSJiri Slaby 	unsigned char	G0_charset;
45*28bc24fcSJiri Slaby 	unsigned char	G1_charset;
46*28bc24fcSJiri Slaby 	unsigned int	charset		: 1;
47*28bc24fcSJiri Slaby 
48*28bc24fcSJiri Slaby 	/* attribute flags */
49*28bc24fcSJiri Slaby 	unsigned int	intensity	: 2;
50*28bc24fcSJiri Slaby 	unsigned int	italic		: 1;
51*28bc24fcSJiri Slaby 	unsigned int	underline	: 1;
52*28bc24fcSJiri Slaby 	unsigned int	blink		: 1;
53*28bc24fcSJiri Slaby 	unsigned int	reverse		: 1;
54*28bc24fcSJiri Slaby };
55*28bc24fcSJiri Slaby 
56a4bedd01SJiri Slaby /*
57a4bedd01SJiri Slaby  * Example: vc_data of a console that was scrolled 3 lines down.
58a4bedd01SJiri Slaby  *
59a4bedd01SJiri Slaby  *                              Console buffer
60a4bedd01SJiri Slaby  * vc_screenbuf ---------> +----------------------+-.
61a4bedd01SJiri Slaby  *                         | initializing W       |  \
62a4bedd01SJiri Slaby  *                         | initializing X       |   |
63a4bedd01SJiri Slaby  *                         | initializing Y       |    > scroll-back area
64a4bedd01SJiri Slaby  *                         | initializing Z       |   |
65a4bedd01SJiri Slaby  *                         |                      |  /
66a4bedd01SJiri Slaby  * vc_visible_origin ---> ^+----------------------+-:
67a4bedd01SJiri Slaby  * (changes by scroll)    || Welcome to linux     |  \
68a4bedd01SJiri Slaby  *                        ||                      |   |
69a4bedd01SJiri Slaby  *           vc_rows --->< | login: root          |   |  visible on console
70a4bedd01SJiri Slaby  *                        || password:            |    > (vc_screenbuf_size is
71a4bedd01SJiri Slaby  * vc_origin -----------> ||                      |   |   vc_size_row * vc_rows)
72a4bedd01SJiri Slaby  * (start when no scroll) || Last login: 12:28    |  /
73a4bedd01SJiri Slaby  *                        v+----------------------+-:
74a4bedd01SJiri Slaby  *                         | Have a lot of fun... |  \
75a4bedd01SJiri Slaby  * vc_pos -----------------|--------v             |   > scroll-front area
76a4bedd01SJiri Slaby  *                         | ~ # cat_             |  /
77a4bedd01SJiri Slaby  * vc_scr_end -----------> +----------------------+-:
78a4bedd01SJiri Slaby  * (vc_origin +            |                      |  \ EMPTY, to be filled by
79a4bedd01SJiri Slaby  *  vc_screenbuf_size)     |                      |  / vc_video_erase_char
80a4bedd01SJiri Slaby  *                         +----------------------+-'
81a4bedd01SJiri Slaby  *                         <---- 2 * vc_cols ----->
82a4bedd01SJiri Slaby  *                         <---- vc_size_row ----->
83a4bedd01SJiri Slaby  *
84a4bedd01SJiri Slaby  * Note that every character in the console buffer is accompanied with an
85a4bedd01SJiri Slaby  * attribute in the buffer right after the character. This is not depicted
86a4bedd01SJiri Slaby  * in the figure.
87a4bedd01SJiri Slaby  */
881da177e4SLinus Torvalds struct vc_data {
89ff917ba4SAlan Cox 	struct tty_port port;			/* Upper level data */
90ff917ba4SAlan Cox 
91*28bc24fcSJiri Slaby 	struct vc_state state, saved_state;
92*28bc24fcSJiri Slaby 
931da177e4SLinus Torvalds 	unsigned short	vc_num;			/* Console number */
941da177e4SLinus Torvalds 	unsigned int	vc_cols;		/* [#] Console size */
951da177e4SLinus Torvalds 	unsigned int	vc_rows;
961da177e4SLinus Torvalds 	unsigned int	vc_size_row;		/* Bytes per row */
971da177e4SLinus Torvalds 	unsigned int	vc_scan_lines;		/* # of scan lines */
981da177e4SLinus Torvalds 	unsigned long	vc_origin;		/* [!] Start of real screen */
991da177e4SLinus Torvalds 	unsigned long	vc_scr_end;		/* [!] End of real screen */
1001da177e4SLinus Torvalds 	unsigned long	vc_visible_origin;	/* [!] Top of visible window */
1011da177e4SLinus Torvalds 	unsigned int	vc_top, vc_bottom;	/* Scrolling region */
1021da177e4SLinus Torvalds 	const struct consw *vc_sw;
1031da177e4SLinus Torvalds 	unsigned short	*vc_screenbuf;		/* In-memory character/attribute buffer */
1041da177e4SLinus Torvalds 	unsigned int	vc_screenbuf_size;
1051da177e4SLinus Torvalds 	unsigned char	vc_mode;		/* KD_TEXT, ... */
1061da177e4SLinus Torvalds 	/* attributes for all characters on screen */
1071da177e4SLinus Torvalds 	unsigned char	vc_attr;		/* Current attributes */
1081da177e4SLinus Torvalds 	unsigned char	vc_def_color;		/* Default colors */
1091da177e4SLinus Torvalds 	unsigned char	vc_ulcolor;		/* Color for underline mode */
110fa6ce9abSJan Engelhardt 	unsigned char   vc_itcolor;
1111da177e4SLinus Torvalds 	unsigned char	vc_halfcolor;		/* Color for half intensity mode */
1121da177e4SLinus Torvalds 	/* cursor */
1131da177e4SLinus Torvalds 	unsigned int	vc_cursor_type;
1141da177e4SLinus Torvalds 	unsigned short	vc_complement_mask;	/* [#] Xor mask for mouse pointer */
1151da177e4SLinus Torvalds 	unsigned short	vc_s_complement_mask;	/* Saved mouse pointer mask */
1161da177e4SLinus Torvalds 	unsigned long	vc_pos;			/* Cursor address */
1171da177e4SLinus Torvalds 	/* fonts */
1181da177e4SLinus Torvalds 	unsigned short	vc_hi_font_mask;	/* [#] Attribute set for upper 256 chars of font or 0 if not supported */
1191da177e4SLinus Torvalds 	struct console_font vc_font;		/* Current VC font set */
1201da177e4SLinus Torvalds 	unsigned short	vc_video_erase_char;	/* Background erase character */
1211da177e4SLinus Torvalds 	/* VT terminal data */
1221da177e4SLinus Torvalds 	unsigned int	vc_state;		/* Escape sequence parser state */
1231da177e4SLinus Torvalds 	unsigned int	vc_npar,vc_par[NPAR];	/* Parameters of current escape sequence */
1241da177e4SLinus Torvalds 	/* data for manual vt switching */
1251da177e4SLinus Torvalds 	struct vt_mode	vt_mode;
126bde0d2c9SEric W. Biederman 	struct pid 	*vt_pid;
1271da177e4SLinus Torvalds 	int		vt_newvt;
1281da177e4SLinus Torvalds 	wait_queue_head_t paste_wait;
1291da177e4SLinus Torvalds 	/* mode flags */
1301da177e4SLinus Torvalds 	unsigned int	vc_disp_ctrl	: 1;	/* Display chars < 32? */
1311da177e4SLinus Torvalds 	unsigned int	vc_toggle_meta	: 1;	/* Toggle high bit? */
1321da177e4SLinus Torvalds 	unsigned int	vc_decscnm	: 1;	/* Screen Mode */
1331da177e4SLinus Torvalds 	unsigned int	vc_decom	: 1;	/* Origin Mode */
1341da177e4SLinus Torvalds 	unsigned int	vc_decawm	: 1;	/* Autowrap Mode */
1351da177e4SLinus Torvalds 	unsigned int	vc_deccm	: 1;	/* Cursor Visible */
1361da177e4SLinus Torvalds 	unsigned int	vc_decim	: 1;	/* Insert Mode */
1371da177e4SLinus Torvalds 	/* misc */
1382ff5c5a1SMartin Hostettler 	unsigned int	vc_priv		: 3;
1391da177e4SLinus Torvalds 	unsigned int	vc_need_wrap	: 1;
1401da177e4SLinus Torvalds 	unsigned int	vc_can_do_color	: 1;
1411da177e4SLinus Torvalds 	unsigned int	vc_report_mouse : 2;
1421da177e4SLinus Torvalds 	unsigned char	vc_utf		: 1;	/* Unicode UTF-8 encoding */
1431da177e4SLinus Torvalds 	unsigned char	vc_utf_count;
1441da177e4SLinus Torvalds 		 int	vc_utf_char;
1451da177e4SLinus Torvalds 	unsigned int	vc_tab_stop[8];		/* Tab stops. 256 columns. */
1461da177e4SLinus Torvalds 	unsigned char   vc_palette[16*3];       /* Colour palette for VGA+ */
1471da177e4SLinus Torvalds 	unsigned short * vc_translate;
148e400b6ecSAntonino A. Daplas 	unsigned int    vc_resize_user;         /* resize request from user */
1491da177e4SLinus Torvalds 	unsigned int	vc_bell_pitch;		/* Console bell pitch */
1501da177e4SLinus Torvalds 	unsigned int	vc_bell_duration;	/* Console bell duration */
151bd63364cSScot Doyle 	unsigned short	vc_cur_blink_ms;	/* Cursor blink duration */
1521da177e4SLinus Torvalds 	struct vc_data **vc_display_fg;		/* [!] Ptr to var holding fg console for this display */
153e4bdab70STakashi Iwai 	struct uni_pagedir *vc_uni_pagedir;
154e4bdab70STakashi Iwai 	struct uni_pagedir **vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */
155d8ae7242SNicolas Pitre 	struct uni_screen *vc_uni_screen;	/* unicode screen content */
1561da177e4SLinus Torvalds 	/* additional information is in vt_kern.h */
1571da177e4SLinus Torvalds };
1581da177e4SLinus Torvalds 
1591da177e4SLinus Torvalds struct vc {
1601da177e4SLinus Torvalds 	struct vc_data *d;
1618b6312f4SEric W. Biederman 	struct work_struct SAK_work;
1621da177e4SLinus Torvalds 
163f4c6fbc9SAdam Borowski 	/* might add  scrmem, kbd  at some time,
1641da177e4SLinus Torvalds 	   to have everything in one place - the disadvantage
1651da177e4SLinus Torvalds 	   would be that vc_cons etc can no longer be static */
1661da177e4SLinus Torvalds };
1671da177e4SLinus Torvalds 
1681da177e4SLinus Torvalds extern struct vc vc_cons [MAX_NR_CONSOLES];
1698b6312f4SEric W. Biederman extern void vc_SAK(struct work_struct *work);
1701da177e4SLinus Torvalds 
1711da177e4SLinus Torvalds #define CUR_DEF		0
1721da177e4SLinus Torvalds #define CUR_NONE	1
1731da177e4SLinus Torvalds #define CUR_UNDERLINE	2
1741da177e4SLinus Torvalds #define CUR_LOWER_THIRD	3
1751da177e4SLinus Torvalds #define CUR_LOWER_HALF	4
1761da177e4SLinus Torvalds #define CUR_TWO_THIRDS	5
1771da177e4SLinus Torvalds #define CUR_BLOCK	6
1781da177e4SLinus Torvalds #define CUR_HWMASK	0x0f
1791da177e4SLinus Torvalds #define CUR_SWMASK	0xfff0
1801da177e4SLinus Torvalds 
1811da177e4SLinus Torvalds #define CUR_DEFAULT CUR_UNDERLINE
1821da177e4SLinus Torvalds 
183ddde3c18SDaniel Vetter bool con_is_visible(const struct vc_data *vc);
184217397d7SRobert P. J. Day 
185217397d7SRobert P. J. Day #endif /* _LINUX_CONSOLE_STRUCT_H */
186