console_struct.h 6.8 KB

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