console_struct.h 6.8 KB

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