Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Robert P. J. Day | 217397d | 2007-06-08 13:47:07 -0700 | [diff] [blame] | 13 | #ifndef _LINUX_CONSOLE_STRUCT_H |
| 14 | #define _LINUX_CONSOLE_STRUCT_H |
| 15 | |
Jon Smirl | a8f340e | 2006-07-10 04:44:12 -0700 | [diff] [blame] | 16 | #include <linux/wait.h> |
Antonino A. Daplas | e07dea9 | 2005-11-07 01:00:51 -0800 | [diff] [blame] | 17 | #include <linux/vt.h> |
Eric W. Biederman | 8b6312f | 2007-02-10 01:44:34 -0800 | [diff] [blame] | 18 | #include <linux/workqueue.h> |
Antonino A. Daplas | e07dea9 | 2005-11-07 01:00:51 -0800 | [diff] [blame] | 19 | |
Takashi Iwai | e4bdab7 | 2014-05-13 12:09:28 +0200 | [diff] [blame] | 20 | struct uni_pagedir; |
Nicolas Pitre | d8ae724 | 2018-06-26 23:56:40 -0400 | [diff] [blame] | 21 | struct uni_screen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
| 23 | #define NPAR 16 |
| 24 | |
Jiri Slaby | a4bedd0 | 2016-06-23 13:34:24 +0200 | [diff] [blame] | 25 | /* |
| 26 | * Example: vc_data of a console that was scrolled 3 lines down. |
| 27 | * |
| 28 | * Console buffer |
| 29 | * vc_screenbuf ---------> +----------------------+-. |
| 30 | * | initializing W | \ |
| 31 | * | initializing X | | |
| 32 | * | initializing Y | > scroll-back area |
| 33 | * | initializing Z | | |
| 34 | * | | / |
| 35 | * vc_visible_origin ---> ^+----------------------+-: |
| 36 | * (changes by scroll) || Welcome to linux | \ |
| 37 | * || | | |
| 38 | * vc_rows --->< | login: root | | visible on console |
| 39 | * || password: | > (vc_screenbuf_size is |
| 40 | * vc_origin -----------> || | | vc_size_row * vc_rows) |
| 41 | * (start when no scroll) || Last login: 12:28 | / |
| 42 | * v+----------------------+-: |
| 43 | * | Have a lot of fun... | \ |
| 44 | * vc_pos -----------------|--------v | > scroll-front area |
| 45 | * | ~ # cat_ | / |
| 46 | * vc_scr_end -----------> +----------------------+-: |
| 47 | * (vc_origin + | | \ EMPTY, to be filled by |
| 48 | * vc_screenbuf_size) | | / vc_video_erase_char |
| 49 | * +----------------------+-' |
| 50 | * <---- 2 * vc_cols -----> |
| 51 | * <---- vc_size_row -----> |
| 52 | * |
| 53 | * Note that every character in the console buffer is accompanied with an |
| 54 | * attribute in the buffer right after the character. This is not depicted |
| 55 | * in the figure. |
| 56 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | struct vc_data { |
Alan Cox | ff917ba | 2010-06-01 22:52:55 +0200 | [diff] [blame] | 58 | struct tty_port port; /* Upper level data */ |
| 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | unsigned short vc_num; /* Console number */ |
| 61 | unsigned int vc_cols; /* [#] Console size */ |
| 62 | unsigned int vc_rows; |
| 63 | unsigned int vc_size_row; /* Bytes per row */ |
| 64 | unsigned int vc_scan_lines; /* # of scan lines */ |
| 65 | unsigned long vc_origin; /* [!] Start of real screen */ |
| 66 | unsigned long vc_scr_end; /* [!] End of real screen */ |
| 67 | unsigned long vc_visible_origin; /* [!] Top of visible window */ |
| 68 | unsigned int vc_top, vc_bottom; /* Scrolling region */ |
| 69 | const struct consw *vc_sw; |
| 70 | unsigned short *vc_screenbuf; /* In-memory character/attribute buffer */ |
| 71 | unsigned int vc_screenbuf_size; |
| 72 | unsigned char vc_mode; /* KD_TEXT, ... */ |
| 73 | /* attributes for all characters on screen */ |
| 74 | unsigned char vc_attr; /* Current attributes */ |
| 75 | unsigned char vc_def_color; /* Default colors */ |
| 76 | unsigned char vc_color; /* Foreground & background */ |
| 77 | unsigned char vc_s_color; /* Saved foreground & background */ |
| 78 | unsigned char vc_ulcolor; /* Color for underline mode */ |
Jan Engelhardt | fa6ce9a | 2007-05-08 00:38:04 -0700 | [diff] [blame] | 79 | unsigned char vc_itcolor; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | unsigned char vc_halfcolor; /* Color for half intensity mode */ |
| 81 | /* cursor */ |
| 82 | unsigned int vc_cursor_type; |
| 83 | unsigned short vc_complement_mask; /* [#] Xor mask for mouse pointer */ |
| 84 | unsigned short vc_s_complement_mask; /* Saved mouse pointer mask */ |
| 85 | unsigned int vc_x, vc_y; /* Cursor position */ |
| 86 | unsigned int vc_saved_x, vc_saved_y; |
| 87 | unsigned long vc_pos; /* Cursor address */ |
| 88 | /* fonts */ |
| 89 | unsigned short vc_hi_font_mask; /* [#] Attribute set for upper 256 chars of font or 0 if not supported */ |
| 90 | struct console_font vc_font; /* Current VC font set */ |
| 91 | unsigned short vc_video_erase_char; /* Background erase character */ |
| 92 | /* VT terminal data */ |
| 93 | unsigned int vc_state; /* Escape sequence parser state */ |
| 94 | unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | /* data for manual vt switching */ |
| 96 | struct vt_mode vt_mode; |
Eric W. Biederman | bde0d2c | 2006-10-02 02:17:14 -0700 | [diff] [blame] | 97 | struct pid *vt_pid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | int vt_newvt; |
| 99 | wait_queue_head_t paste_wait; |
| 100 | /* mode flags */ |
| 101 | unsigned int vc_charset : 1; /* Character set G0 / G1 */ |
| 102 | unsigned int vc_s_charset : 1; /* Saved character set */ |
| 103 | unsigned int vc_disp_ctrl : 1; /* Display chars < 32? */ |
| 104 | unsigned int vc_toggle_meta : 1; /* Toggle high bit? */ |
| 105 | unsigned int vc_decscnm : 1; /* Screen Mode */ |
| 106 | unsigned int vc_decom : 1; /* Origin Mode */ |
| 107 | unsigned int vc_decawm : 1; /* Autowrap Mode */ |
| 108 | unsigned int vc_deccm : 1; /* Cursor Visible */ |
| 109 | unsigned int vc_decim : 1; /* Insert Mode */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | /* attribute flags */ |
| 111 | unsigned int vc_intensity : 2; /* 0=half-bright, 1=normal, 2=bold */ |
Jan Engelhardt | fa6ce9a | 2007-05-08 00:38:04 -0700 | [diff] [blame] | 112 | unsigned int vc_italic:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | unsigned int vc_underline : 1; |
| 114 | unsigned int vc_blink : 1; |
| 115 | unsigned int vc_reverse : 1; |
| 116 | unsigned int vc_s_intensity : 2; /* saved rendition */ |
Jan Engelhardt | fa6ce9a | 2007-05-08 00:38:04 -0700 | [diff] [blame] | 117 | unsigned int vc_s_italic:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | unsigned int vc_s_underline : 1; |
| 119 | unsigned int vc_s_blink : 1; |
| 120 | unsigned int vc_s_reverse : 1; |
| 121 | /* misc */ |
Martin Hostettler | 2ff5c5a | 2018-12-15 15:34:20 +0100 | [diff] [blame] | 122 | unsigned int vc_priv : 3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | unsigned int vc_need_wrap : 1; |
| 124 | unsigned int vc_can_do_color : 1; |
| 125 | unsigned int vc_report_mouse : 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | unsigned char vc_utf : 1; /* Unicode UTF-8 encoding */ |
| 127 | unsigned char vc_utf_count; |
| 128 | int vc_utf_char; |
| 129 | unsigned int vc_tab_stop[8]; /* Tab stops. 256 columns. */ |
| 130 | unsigned char vc_palette[16*3]; /* Colour palette for VGA+ */ |
| 131 | unsigned short * vc_translate; |
| 132 | unsigned char vc_G0_charset; |
| 133 | unsigned char vc_G1_charset; |
| 134 | unsigned char vc_saved_G0; |
| 135 | unsigned char vc_saved_G1; |
Antonino A. Daplas | e400b6e | 2007-10-16 01:29:35 -0700 | [diff] [blame] | 136 | unsigned int vc_resize_user; /* resize request from user */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | unsigned int vc_bell_pitch; /* Console bell pitch */ |
| 138 | unsigned int vc_bell_duration; /* Console bell duration */ |
Scot Doyle | bd63364 | 2015-03-26 13:54:39 +0000 | [diff] [blame] | 139 | unsigned short vc_cur_blink_ms; /* Cursor blink duration */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | struct vc_data **vc_display_fg; /* [!] Ptr to var holding fg console for this display */ |
Takashi Iwai | e4bdab7 | 2014-05-13 12:09:28 +0200 | [diff] [blame] | 141 | struct uni_pagedir *vc_uni_pagedir; |
| 142 | struct uni_pagedir **vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */ |
Nicolas Pitre | d8ae724 | 2018-06-26 23:56:40 -0400 | [diff] [blame] | 143 | struct uni_screen *vc_uni_screen; /* unicode screen content */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | /* additional information is in vt_kern.h */ |
| 145 | }; |
| 146 | |
| 147 | struct vc { |
| 148 | struct vc_data *d; |
Eric W. Biederman | 8b6312f | 2007-02-10 01:44:34 -0800 | [diff] [blame] | 149 | struct work_struct SAK_work; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | |
Adam Borowski | f4c6fbc | 2018-07-18 05:03:22 +0200 | [diff] [blame] | 151 | /* might add scrmem, kbd at some time, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | to have everything in one place - the disadvantage |
| 153 | would be that vc_cons etc can no longer be static */ |
| 154 | }; |
| 155 | |
| 156 | extern struct vc vc_cons [MAX_NR_CONSOLES]; |
Eric W. Biederman | 8b6312f | 2007-02-10 01:44:34 -0800 | [diff] [blame] | 157 | extern void vc_SAK(struct work_struct *work); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
| 159 | #define CUR_DEF 0 |
| 160 | #define CUR_NONE 1 |
| 161 | #define CUR_UNDERLINE 2 |
| 162 | #define CUR_LOWER_THIRD 3 |
| 163 | #define CUR_LOWER_HALF 4 |
| 164 | #define CUR_TWO_THIRDS 5 |
| 165 | #define CUR_BLOCK 6 |
| 166 | #define CUR_HWMASK 0x0f |
| 167 | #define CUR_SWMASK 0xfff0 |
| 168 | |
| 169 | #define CUR_DEFAULT CUR_UNDERLINE |
| 170 | |
Daniel Vetter | ddde3c1 | 2019-05-28 11:02:35 +0200 | [diff] [blame] | 171 | bool con_is_visible(const struct vc_data *vc); |
Robert P. J. Day | 217397d | 2007-06-08 13:47:07 -0700 | [diff] [blame] | 172 | |
| 173 | #endif /* _LINUX_CONSOLE_STRUCT_H */ |