console_struct.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /* SPDX-License-Identifier: GPL-2.0 */
  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. #ifndef _LINUX_CONSOLE_STRUCT_H
  13. #define _LINUX_CONSOLE_STRUCT_H
  14. #include <linux/wait.h>
  15. #include <linux/vt.h>
  16. #include <linux/workqueue.h>
  17. struct uni_pagedir;
  18. struct uni_screen;
  19. #define NPAR 16
  20. #define VC_TABSTOPS_COUNT 256U
  21. enum vc_intensity {
  22. VCI_HALF_BRIGHT,
  23. VCI_NORMAL,
  24. VCI_BOLD,
  25. VCI_MASK = 0x3,
  26. };
  27. /**
  28. * struct vc_state -- state of a VC
  29. * @x: cursor's x-position
  30. * @y: cursor's y-position
  31. * @color: foreground & background colors
  32. * @Gx_charset: what's G0/G1 slot set to (like GRAF_MAP, LAT1_MAP)
  33. * @charset: what character set to use (0=G0 or 1=G1)
  34. * @intensity: see enum vc_intensity for values
  35. * @reverse: reversed foreground/background colors
  36. *
  37. * These members are defined separately from struct vc_data as we save &
  38. * restore them at times.
  39. */
  40. struct vc_state {
  41. unsigned int x, y;
  42. unsigned char color;
  43. unsigned char Gx_charset[2];
  44. unsigned int charset : 1;
  45. /* attribute flags */
  46. enum vc_intensity intensity;
  47. bool italic;
  48. bool underline;
  49. bool blink;
  50. bool reverse;
  51. };
  52. /*
  53. * Example: vc_data of a console that was scrolled 3 lines down.
  54. *
  55. * Console buffer
  56. * vc_screenbuf ---------> +----------------------+-.
  57. * | initializing W | \
  58. * | initializing X | |
  59. * | initializing Y | > scroll-back area
  60. * | initializing Z | |
  61. * | | /
  62. * vc_visible_origin ---> ^+----------------------+-:
  63. * (changes by scroll) || Welcome to linux | \
  64. * || | |
  65. * vc_rows --->< | login: root | | visible on console
  66. * || password: | > (vc_screenbuf_size is
  67. * vc_origin -----------> || | | vc_size_row * vc_rows)
  68. * (start when no scroll) || Last login: 12:28 | /
  69. * v+----------------------+-:
  70. * | Have a lot of fun... | \
  71. * vc_pos -----------------|--------v | > scroll-front area
  72. * | ~ # cat_ | /
  73. * vc_scr_end -----------> +----------------------+-:
  74. * (vc_origin + | | \ EMPTY, to be filled by
  75. * vc_screenbuf_size) | | / vc_video_erase_char
  76. * +----------------------+-'
  77. * <---- 2 * vc_cols ----->
  78. * <---- vc_size_row ----->
  79. *
  80. * Note that every character in the console buffer is accompanied with an
  81. * attribute in the buffer right after the character. This is not depicted
  82. * in the figure.
  83. */
  84. struct vc_data {
  85. struct tty_port port; /* Upper level data */
  86. struct vc_state state, saved_state;
  87. unsigned short vc_num; /* Console number */
  88. unsigned int vc_cols; /* [#] Console size */
  89. unsigned int vc_rows;
  90. unsigned int vc_size_row; /* Bytes per row */
  91. unsigned int vc_scan_lines; /* # of scan lines */
  92. unsigned int vc_cell_height; /* CRTC character cell height */
  93. unsigned long vc_origin; /* [!] Start of real screen */
  94. unsigned long vc_scr_end; /* [!] End of real screen */
  95. unsigned long vc_visible_origin; /* [!] Top of visible window */
  96. unsigned int vc_top, vc_bottom; /* Scrolling region */
  97. const struct consw *vc_sw;
  98. unsigned short *vc_screenbuf; /* In-memory character/attribute buffer */
  99. unsigned int vc_screenbuf_size;
  100. unsigned char vc_mode; /* KD_TEXT, ... */
  101. /* attributes for all characters on screen */
  102. unsigned char vc_attr; /* Current attributes */
  103. unsigned char vc_def_color; /* Default colors */
  104. unsigned char vc_ulcolor; /* Color for underline mode */
  105. unsigned char vc_itcolor;
  106. unsigned char vc_halfcolor; /* Color for half intensity mode */
  107. /* cursor */
  108. unsigned int vc_cursor_type;
  109. unsigned short vc_complement_mask; /* [#] Xor mask for mouse pointer */
  110. unsigned short vc_s_complement_mask; /* Saved mouse pointer mask */
  111. unsigned long vc_pos; /* Cursor address */
  112. /* fonts */
  113. unsigned short vc_hi_font_mask; /* [#] Attribute set for upper 256 chars of font or 0 if not supported */
  114. struct console_font vc_font; /* Current VC font set */
  115. unsigned short vc_video_erase_char; /* Background erase character */
  116. /* VT terminal data */
  117. unsigned int vc_state; /* Escape sequence parser state */
  118. unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */
  119. /* data for manual vt switching */
  120. struct vt_mode vt_mode;
  121. struct pid *vt_pid;
  122. int vt_newvt;
  123. wait_queue_head_t paste_wait;
  124. /* mode flags */
  125. unsigned int vc_disp_ctrl : 1; /* Display chars < 32? */
  126. unsigned int vc_toggle_meta : 1; /* Toggle high bit? */
  127. unsigned int vc_decscnm : 1; /* Screen Mode */
  128. unsigned int vc_decom : 1; /* Origin Mode */
  129. unsigned int vc_decawm : 1; /* Autowrap Mode */
  130. unsigned int vc_deccm : 1; /* Cursor Visible */
  131. unsigned int vc_decim : 1; /* Insert Mode */
  132. /* misc */
  133. unsigned int vc_priv : 3;
  134. unsigned int vc_need_wrap : 1;
  135. unsigned int vc_can_do_color : 1;
  136. unsigned int vc_report_mouse : 2;
  137. unsigned char vc_utf : 1; /* Unicode UTF-8 encoding */
  138. unsigned char vc_utf_count;
  139. int vc_utf_char;
  140. DECLARE_BITMAP(vc_tab_stop, VC_TABSTOPS_COUNT); /* Tab stops. 256 columns. */
  141. unsigned char vc_palette[16*3]; /* Colour palette for VGA+ */
  142. unsigned short * vc_translate;
  143. unsigned int vc_resize_user; /* resize request from user */
  144. unsigned int vc_bell_pitch; /* Console bell pitch */
  145. unsigned int vc_bell_duration; /* Console bell duration */
  146. unsigned short vc_cur_blink_ms; /* Cursor blink duration */
  147. struct vc_data **vc_display_fg; /* [!] Ptr to var holding fg console for this display */
  148. struct uni_pagedir *vc_uni_pagedir;
  149. struct uni_pagedir **vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */
  150. struct uni_screen *vc_uni_screen; /* unicode screen content */
  151. /* additional information is in vt_kern.h */
  152. };
  153. struct vc {
  154. struct vc_data *d;
  155. struct work_struct SAK_work;
  156. /* might add scrmem, kbd at some time,
  157. to have everything in one place */
  158. };
  159. extern struct vc vc_cons [MAX_NR_CONSOLES];
  160. extern void vc_SAK(struct work_struct *work);
  161. #define CUR_MAKE(size, change, set) ((size) | ((change) << 8) | \
  162. ((set) << 16))
  163. #define CUR_SIZE(c) ((c) & 0x00000f)
  164. # define CUR_DEF 0
  165. # define CUR_NONE 1
  166. # define CUR_UNDERLINE 2
  167. # define CUR_LOWER_THIRD 3
  168. # define CUR_LOWER_HALF 4
  169. # define CUR_TWO_THIRDS 5
  170. # define CUR_BLOCK 6
  171. #define CUR_SW 0x000010
  172. #define CUR_ALWAYS_BG 0x000020
  173. #define CUR_INVERT_FG_BG 0x000040
  174. #define CUR_FG 0x000700
  175. #define CUR_BG 0x007000
  176. #define CUR_CHANGE(c) ((c) & 0x00ff00)
  177. #define CUR_SET(c) (((c) & 0xff0000) >> 8)
  178. bool con_is_visible(const struct vc_data *vc);
  179. #endif /* _LINUX_CONSOLE_STRUCT_H */