xref: /linux-6.15/include/linux/console_struct.h (revision a4bedd01)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * console_struct.h
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  * Data structure describing single virtual console except for data
51da177e4SLinus Torvalds  * used by vt.c.
61da177e4SLinus Torvalds  *
71da177e4SLinus Torvalds  * Fields marked with [#] must be set by the low-level driver.
81da177e4SLinus Torvalds  * Fields marked with [!] can be changed by the low-level driver
91da177e4SLinus Torvalds  * to achieve effects such as fast scrolling by changing the origin.
101da177e4SLinus Torvalds  */
111da177e4SLinus Torvalds 
12217397d7SRobert P. J. Day #ifndef _LINUX_CONSOLE_STRUCT_H
13217397d7SRobert P. J. Day #define _LINUX_CONSOLE_STRUCT_H
14217397d7SRobert P. J. Day 
15a8f340e3SJon Smirl #include <linux/wait.h>
16e07dea98SAntonino A. Daplas #include <linux/vt.h>
178b6312f4SEric W. Biederman #include <linux/workqueue.h>
18e07dea98SAntonino A. Daplas 
191da177e4SLinus Torvalds struct vt_struct;
20e4bdab70STakashi Iwai struct uni_pagedir;
211da177e4SLinus Torvalds 
221da177e4SLinus Torvalds #define NPAR 16
231da177e4SLinus Torvalds 
24*a4bedd01SJiri Slaby /*
25*a4bedd01SJiri Slaby  * Example: vc_data of a console that was scrolled 3 lines down.
26*a4bedd01SJiri Slaby  *
27*a4bedd01SJiri Slaby  *                              Console buffer
28*a4bedd01SJiri Slaby  * vc_screenbuf ---------> +----------------------+-.
29*a4bedd01SJiri Slaby  *                         | initializing W       |  \
30*a4bedd01SJiri Slaby  *                         | initializing X       |   |
31*a4bedd01SJiri Slaby  *                         | initializing Y       |    > scroll-back area
32*a4bedd01SJiri Slaby  *                         | initializing Z       |   |
33*a4bedd01SJiri Slaby  *                         |                      |  /
34*a4bedd01SJiri Slaby  * vc_visible_origin ---> ^+----------------------+-:
35*a4bedd01SJiri Slaby  * (changes by scroll)    || Welcome to linux     |  \
36*a4bedd01SJiri Slaby  *                        ||                      |   |
37*a4bedd01SJiri Slaby  *           vc_rows --->< | login: root          |   |  visible on console
38*a4bedd01SJiri Slaby  *                        || password:            |    > (vc_screenbuf_size is
39*a4bedd01SJiri Slaby  * vc_origin -----------> ||                      |   |   vc_size_row * vc_rows)
40*a4bedd01SJiri Slaby  * (start when no scroll) || Last login: 12:28    |  /
41*a4bedd01SJiri Slaby  *                        v+----------------------+-:
42*a4bedd01SJiri Slaby  *                         | Have a lot of fun... |  \
43*a4bedd01SJiri Slaby  * vc_pos -----------------|--------v             |   > scroll-front area
44*a4bedd01SJiri Slaby  *                         | ~ # cat_             |  /
45*a4bedd01SJiri Slaby  * vc_scr_end -----------> +----------------------+-:
46*a4bedd01SJiri Slaby  * (vc_origin +            |                      |  \ EMPTY, to be filled by
47*a4bedd01SJiri Slaby  *  vc_screenbuf_size)     |                      |  / vc_video_erase_char
48*a4bedd01SJiri Slaby  *                         +----------------------+-'
49*a4bedd01SJiri Slaby  *                         <---- 2 * vc_cols ----->
50*a4bedd01SJiri Slaby  *                         <---- vc_size_row ----->
51*a4bedd01SJiri Slaby  *
52*a4bedd01SJiri Slaby  * Note that every character in the console buffer is accompanied with an
53*a4bedd01SJiri Slaby  * attribute in the buffer right after the character. This is not depicted
54*a4bedd01SJiri Slaby  * in the figure.
55*a4bedd01SJiri Slaby  */
561da177e4SLinus Torvalds struct vc_data {
57ff917ba4SAlan Cox 	struct tty_port port;			/* Upper level data */
58ff917ba4SAlan Cox 
591da177e4SLinus Torvalds 	unsigned short	vc_num;			/* Console number */
601da177e4SLinus Torvalds 	unsigned int	vc_cols;		/* [#] Console size */
611da177e4SLinus Torvalds 	unsigned int	vc_rows;
621da177e4SLinus Torvalds 	unsigned int	vc_size_row;		/* Bytes per row */
631da177e4SLinus Torvalds 	unsigned int	vc_scan_lines;		/* # of scan lines */
641da177e4SLinus Torvalds 	unsigned long	vc_origin;		/* [!] Start of real screen */
651da177e4SLinus Torvalds 	unsigned long	vc_scr_end;		/* [!] End of real screen */
661da177e4SLinus Torvalds 	unsigned long	vc_visible_origin;	/* [!] Top of visible window */
671da177e4SLinus Torvalds 	unsigned int	vc_top, vc_bottom;	/* Scrolling region */
681da177e4SLinus Torvalds 	const struct consw *vc_sw;
691da177e4SLinus Torvalds 	unsigned short	*vc_screenbuf;		/* In-memory character/attribute buffer */
701da177e4SLinus Torvalds 	unsigned int	vc_screenbuf_size;
711da177e4SLinus Torvalds 	unsigned char	vc_mode;		/* KD_TEXT, ... */
721da177e4SLinus Torvalds 	/* attributes for all characters on screen */
731da177e4SLinus Torvalds 	unsigned char	vc_attr;		/* Current attributes */
741da177e4SLinus Torvalds 	unsigned char	vc_def_color;		/* Default colors */
751da177e4SLinus Torvalds 	unsigned char	vc_color;		/* Foreground & background */
761da177e4SLinus Torvalds 	unsigned char	vc_s_color;		/* Saved foreground & background */
771da177e4SLinus Torvalds 	unsigned char	vc_ulcolor;		/* Color for underline mode */
78fa6ce9abSJan Engelhardt 	unsigned char   vc_itcolor;
791da177e4SLinus Torvalds 	unsigned char	vc_halfcolor;		/* Color for half intensity mode */
801da177e4SLinus Torvalds 	/* cursor */
811da177e4SLinus Torvalds 	unsigned int	vc_cursor_type;
821da177e4SLinus Torvalds 	unsigned short	vc_complement_mask;	/* [#] Xor mask for mouse pointer */
831da177e4SLinus Torvalds 	unsigned short	vc_s_complement_mask;	/* Saved mouse pointer mask */
841da177e4SLinus Torvalds 	unsigned int	vc_x, vc_y;		/* Cursor position */
851da177e4SLinus Torvalds 	unsigned int	vc_saved_x, vc_saved_y;
861da177e4SLinus Torvalds 	unsigned long	vc_pos;			/* Cursor address */
871da177e4SLinus Torvalds 	/* fonts */
881da177e4SLinus Torvalds 	unsigned short	vc_hi_font_mask;	/* [#] Attribute set for upper 256 chars of font or 0 if not supported */
891da177e4SLinus Torvalds 	struct console_font vc_font;		/* Current VC font set */
901da177e4SLinus Torvalds 	unsigned short	vc_video_erase_char;	/* Background erase character */
911da177e4SLinus Torvalds 	/* VT terminal data */
921da177e4SLinus Torvalds 	unsigned int	vc_state;		/* Escape sequence parser state */
931da177e4SLinus Torvalds 	unsigned int	vc_npar,vc_par[NPAR];	/* Parameters of current escape sequence */
941da177e4SLinus Torvalds 	/* data for manual vt switching */
951da177e4SLinus Torvalds 	struct vt_mode	vt_mode;
96bde0d2c9SEric W. Biederman 	struct pid 	*vt_pid;
971da177e4SLinus Torvalds 	int		vt_newvt;
981da177e4SLinus Torvalds 	wait_queue_head_t paste_wait;
991da177e4SLinus Torvalds 	/* mode flags */
1001da177e4SLinus Torvalds 	unsigned int	vc_charset	: 1;	/* Character set G0 / G1 */
1011da177e4SLinus Torvalds 	unsigned int	vc_s_charset	: 1;	/* Saved character set */
1021da177e4SLinus Torvalds 	unsigned int	vc_disp_ctrl	: 1;	/* Display chars < 32? */
1031da177e4SLinus Torvalds 	unsigned int	vc_toggle_meta	: 1;	/* Toggle high bit? */
1041da177e4SLinus Torvalds 	unsigned int	vc_decscnm	: 1;	/* Screen Mode */
1051da177e4SLinus Torvalds 	unsigned int	vc_decom	: 1;	/* Origin Mode */
1061da177e4SLinus Torvalds 	unsigned int	vc_decawm	: 1;	/* Autowrap Mode */
1071da177e4SLinus Torvalds 	unsigned int	vc_deccm	: 1;	/* Cursor Visible */
1081da177e4SLinus Torvalds 	unsigned int	vc_decim	: 1;	/* Insert Mode */
1091da177e4SLinus Torvalds 	unsigned int	vc_deccolm	: 1;	/* 80/132 Column Mode */
1101da177e4SLinus Torvalds 	/* attribute flags */
1111da177e4SLinus Torvalds 	unsigned int	vc_intensity	: 2;	/* 0=half-bright, 1=normal, 2=bold */
112fa6ce9abSJan Engelhardt 	unsigned int    vc_italic:1;
1131da177e4SLinus Torvalds 	unsigned int	vc_underline	: 1;
1141da177e4SLinus Torvalds 	unsigned int	vc_blink	: 1;
1151da177e4SLinus Torvalds 	unsigned int	vc_reverse	: 1;
1161da177e4SLinus Torvalds 	unsigned int	vc_s_intensity	: 2;	/* saved rendition */
117fa6ce9abSJan Engelhardt 	unsigned int    vc_s_italic:1;
1181da177e4SLinus Torvalds 	unsigned int	vc_s_underline	: 1;
1191da177e4SLinus Torvalds 	unsigned int	vc_s_blink	: 1;
1201da177e4SLinus Torvalds 	unsigned int	vc_s_reverse	: 1;
1211da177e4SLinus Torvalds 	/* misc */
1221da177e4SLinus Torvalds 	unsigned int	vc_ques		: 1;
1231da177e4SLinus Torvalds 	unsigned int	vc_need_wrap	: 1;
1241da177e4SLinus Torvalds 	unsigned int	vc_can_do_color	: 1;
1251da177e4SLinus Torvalds 	unsigned int	vc_report_mouse : 2;
1261da177e4SLinus Torvalds 	unsigned char	vc_utf		: 1;	/* Unicode UTF-8 encoding */
1271da177e4SLinus Torvalds 	unsigned char	vc_utf_count;
1281da177e4SLinus Torvalds 		 int	vc_utf_char;
1291da177e4SLinus Torvalds 	unsigned int	vc_tab_stop[8];		/* Tab stops. 256 columns. */
1301da177e4SLinus Torvalds 	unsigned char   vc_palette[16*3];       /* Colour palette for VGA+ */
1311da177e4SLinus Torvalds 	unsigned short * vc_translate;
1321da177e4SLinus Torvalds 	unsigned char 	vc_G0_charset;
1331da177e4SLinus Torvalds 	unsigned char 	vc_G1_charset;
1341da177e4SLinus Torvalds 	unsigned char 	vc_saved_G0;
1351da177e4SLinus Torvalds 	unsigned char 	vc_saved_G1;
136e400b6ecSAntonino A. Daplas 	unsigned int    vc_resize_user;         /* resize request from user */
1371da177e4SLinus Torvalds 	unsigned int	vc_bell_pitch;		/* Console bell pitch */
1381da177e4SLinus Torvalds 	unsigned int	vc_bell_duration;	/* Console bell duration */
139bd63364cSScot Doyle 	unsigned short	vc_cur_blink_ms;	/* Cursor blink duration */
1401da177e4SLinus Torvalds 	struct vc_data **vc_display_fg;		/* [!] Ptr to var holding fg console for this display */
141e4bdab70STakashi Iwai 	struct uni_pagedir *vc_uni_pagedir;
142e4bdab70STakashi Iwai 	struct uni_pagedir **vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */
1438fd4bd22SJesse Barnes 	bool vc_panic_force_write; /* when oops/panic this VC can accept forced output/blanking */
1441da177e4SLinus Torvalds 	/* additional information is in vt_kern.h */
1451da177e4SLinus Torvalds };
1461da177e4SLinus Torvalds 
1471da177e4SLinus Torvalds struct vc {
1481da177e4SLinus Torvalds 	struct vc_data *d;
1498b6312f4SEric W. Biederman 	struct work_struct SAK_work;
1501da177e4SLinus Torvalds 
1511da177e4SLinus Torvalds 	/* might add  scrmem, vt_struct, kbd  at some time,
1521da177e4SLinus Torvalds 	   to have everything in one place - the disadvantage
1531da177e4SLinus Torvalds 	   would be that vc_cons etc can no longer be static */
1541da177e4SLinus Torvalds };
1551da177e4SLinus Torvalds 
1561da177e4SLinus Torvalds extern struct vc vc_cons [MAX_NR_CONSOLES];
1578b6312f4SEric W. Biederman extern void vc_SAK(struct work_struct *work);
1581da177e4SLinus Torvalds 
1591da177e4SLinus Torvalds #define CUR_DEF		0
1601da177e4SLinus Torvalds #define CUR_NONE	1
1611da177e4SLinus Torvalds #define CUR_UNDERLINE	2
1621da177e4SLinus Torvalds #define CUR_LOWER_THIRD	3
1631da177e4SLinus Torvalds #define CUR_LOWER_HALF	4
1641da177e4SLinus Torvalds #define CUR_TWO_THIRDS	5
1651da177e4SLinus Torvalds #define CUR_BLOCK	6
1661da177e4SLinus Torvalds #define CUR_HWMASK	0x0f
1671da177e4SLinus Torvalds #define CUR_SWMASK	0xfff0
1681da177e4SLinus Torvalds 
1691da177e4SLinus Torvalds #define CUR_DEFAULT CUR_UNDERLINE
1701da177e4SLinus Torvalds 
1711da177e4SLinus Torvalds #define CON_IS_VISIBLE(conp) (*conp->vc_display_fg == conp)
172217397d7SRobert P. J. Day 
173217397d7SRobert P. J. Day #endif /* _LINUX_CONSOLE_STRUCT_H */
174