Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * console_struct.h
0004  *
0005  * Data structure describing single virtual console except for data
0006  * used by vt.c.
0007  *
0008  * Fields marked with [#] must be set by the low-level driver.
0009  * Fields marked with [!] can be changed by the low-level driver
0010  * to achieve effects such as fast scrolling by changing the origin.
0011  */
0012 
0013 #ifndef _LINUX_CONSOLE_STRUCT_H
0014 #define _LINUX_CONSOLE_STRUCT_H
0015 
0016 #include <linux/wait.h>
0017 #include <linux/vt.h>
0018 #include <linux/workqueue.h>
0019 
0020 struct uni_pagedict;
0021 struct uni_screen;
0022 
0023 #define NPAR 16
0024 #define VC_TABSTOPS_COUNT   256U
0025 
0026 enum vc_intensity {
0027     VCI_HALF_BRIGHT,
0028     VCI_NORMAL,
0029     VCI_BOLD,
0030     VCI_MASK = 0x3,
0031 };
0032 
0033 /**
0034  * struct vc_state -- state of a VC
0035  * @x: cursor's x-position
0036  * @y: cursor's y-position
0037  * @color: foreground & background colors
0038  * @Gx_charset: what's G0/G1 slot set to (like GRAF_MAP, LAT1_MAP)
0039  * @charset: what character set to use (0=G0 or 1=G1)
0040  * @intensity: see enum vc_intensity for values
0041  * @reverse: reversed foreground/background colors
0042  *
0043  * These members are defined separately from struct vc_data as we save &
0044  * restore them at times.
0045  */
0046 struct vc_state {
0047     unsigned int    x, y;
0048 
0049     unsigned char   color;
0050 
0051     unsigned char   Gx_charset[2];
0052     unsigned int    charset     : 1;
0053 
0054     /* attribute flags */
0055     enum vc_intensity intensity;
0056     bool        italic;
0057     bool        underline;
0058     bool        blink;
0059     bool        reverse;
0060 };
0061 
0062 /*
0063  * Example: vc_data of a console that was scrolled 3 lines down.
0064  *
0065  *                              Console buffer
0066  * vc_screenbuf ---------> +----------------------+-.
0067  *                         | initializing W       |  \
0068  *                         | initializing X       |   |
0069  *                         | initializing Y       |    > scroll-back area
0070  *                         | initializing Z       |   |
0071  *                         |                      |  /
0072  * vc_visible_origin ---> ^+----------------------+-:
0073  * (changes by scroll)    || Welcome to linux     |  \
0074  *                        ||                      |   |
0075  *           vc_rows --->< | login: root          |   |  visible on console
0076  *                        || password:            |    > (vc_screenbuf_size is
0077  * vc_origin -----------> ||                      |   |   vc_size_row * vc_rows)
0078  * (start when no scroll) || Last login: 12:28    |  /
0079  *                        v+----------------------+-:
0080  *                         | Have a lot of fun... |  \
0081  * vc_pos -----------------|--------v             |   > scroll-front area
0082  *                         | ~ # cat_             |  /
0083  * vc_scr_end -----------> +----------------------+-:
0084  * (vc_origin +            |                      |  \ EMPTY, to be filled by
0085  *  vc_screenbuf_size)     |                      |  / vc_video_erase_char
0086  *                         +----------------------+-'
0087  *                         <---- 2 * vc_cols ----->
0088  *                         <---- vc_size_row ----->
0089  *
0090  * Note that every character in the console buffer is accompanied with an
0091  * attribute in the buffer right after the character. This is not depicted
0092  * in the figure.
0093  */
0094 struct vc_data {
0095     struct tty_port port;           /* Upper level data */
0096 
0097     struct vc_state state, saved_state;
0098 
0099     unsigned short  vc_num;         /* Console number */
0100     unsigned int    vc_cols;        /* [#] Console size */
0101     unsigned int    vc_rows;
0102     unsigned int    vc_size_row;        /* Bytes per row */
0103     unsigned int    vc_scan_lines;      /* # of scan lines */
0104     unsigned int    vc_cell_height;     /* CRTC character cell height */
0105     unsigned long   vc_origin;      /* [!] Start of real screen */
0106     unsigned long   vc_scr_end;     /* [!] End of real screen */
0107     unsigned long   vc_visible_origin;  /* [!] Top of visible window */
0108     unsigned int    vc_top, vc_bottom;  /* Scrolling region */
0109     const struct consw *vc_sw;
0110     unsigned short  *vc_screenbuf;      /* In-memory character/attribute buffer */
0111     unsigned int    vc_screenbuf_size;
0112     unsigned char   vc_mode;        /* KD_TEXT, ... */
0113     /* attributes for all characters on screen */
0114     unsigned char   vc_attr;        /* Current attributes */
0115     unsigned char   vc_def_color;       /* Default colors */
0116     unsigned char   vc_ulcolor;     /* Color for underline mode */
0117     unsigned char   vc_itcolor;
0118     unsigned char   vc_halfcolor;       /* Color for half intensity mode */
0119     /* cursor */
0120     unsigned int    vc_cursor_type;
0121     unsigned short  vc_complement_mask; /* [#] Xor mask for mouse pointer */
0122     unsigned short  vc_s_complement_mask;   /* Saved mouse pointer mask */
0123     unsigned long   vc_pos;         /* Cursor address */
0124     /* fonts */ 
0125     unsigned short  vc_hi_font_mask;    /* [#] Attribute set for upper 256 chars of font or 0 if not supported */
0126     struct console_font vc_font;        /* Current VC font set */
0127     unsigned short  vc_video_erase_char;    /* Background erase character */
0128     /* VT terminal data */
0129     unsigned int    vc_state;       /* Escape sequence parser state */
0130     unsigned int    vc_npar,vc_par[NPAR];   /* Parameters of current escape sequence */
0131     /* data for manual vt switching */
0132     struct vt_mode  vt_mode;
0133     struct pid  *vt_pid;
0134     int     vt_newvt;
0135     wait_queue_head_t paste_wait;
0136     /* mode flags */
0137     unsigned int    vc_disp_ctrl    : 1;    /* Display chars < 32? */
0138     unsigned int    vc_toggle_meta  : 1;    /* Toggle high bit? */
0139     unsigned int    vc_decscnm  : 1;    /* Screen Mode */
0140     unsigned int    vc_decom    : 1;    /* Origin Mode */
0141     unsigned int    vc_decawm   : 1;    /* Autowrap Mode */
0142     unsigned int    vc_deccm    : 1;    /* Cursor Visible */
0143     unsigned int    vc_decim    : 1;    /* Insert Mode */
0144     /* misc */
0145     unsigned int    vc_priv     : 3;
0146     unsigned int    vc_need_wrap    : 1;
0147     unsigned int    vc_can_do_color : 1;
0148     unsigned int    vc_report_mouse : 2;
0149     unsigned char   vc_utf      : 1;    /* Unicode UTF-8 encoding */
0150     unsigned char   vc_utf_count;
0151          int    vc_utf_char;
0152     DECLARE_BITMAP(vc_tab_stop, VC_TABSTOPS_COUNT); /* Tab stops. 256 columns. */
0153     unsigned char   vc_palette[16*3];       /* Colour palette for VGA+ */
0154     unsigned short * vc_translate;
0155     unsigned int    vc_resize_user;         /* resize request from user */
0156     unsigned int    vc_bell_pitch;      /* Console bell pitch */
0157     unsigned int    vc_bell_duration;   /* Console bell duration */
0158     unsigned short  vc_cur_blink_ms;    /* Cursor blink duration */
0159     struct vc_data **vc_display_fg;     /* [!] Ptr to var holding fg console for this display */
0160     struct uni_pagedict *uni_pagedict;
0161     struct uni_pagedict **uni_pagedict_loc; /* [!] Location of uni_pagedict variable for this console */
0162     struct uni_screen *vc_uni_screen;   /* unicode screen content */
0163     /* additional information is in vt_kern.h */
0164 };
0165 
0166 struct vc {
0167     struct vc_data *d;
0168     struct work_struct SAK_work;
0169 
0170     /* might add  scrmem, kbd  at some time,
0171        to have everything in one place */
0172 };
0173 
0174 extern struct vc vc_cons [MAX_NR_CONSOLES];
0175 extern void vc_SAK(struct work_struct *work);
0176 
0177 #define CUR_MAKE(size, change, set) ((size) | ((change) << 8) | \
0178         ((set) << 16))
0179 #define CUR_SIZE(c)      ((c) & 0x00000f)
0180 # define CUR_DEF                   0
0181 # define CUR_NONE                  1
0182 # define CUR_UNDERLINE                 2
0183 # define CUR_LOWER_THIRD               3
0184 # define CUR_LOWER_HALF                4
0185 # define CUR_TWO_THIRDS                5
0186 # define CUR_BLOCK                 6
0187 #define CUR_SW              0x000010
0188 #define CUR_ALWAYS_BG           0x000020
0189 #define CUR_INVERT_FG_BG        0x000040
0190 #define CUR_FG              0x000700
0191 #define CUR_BG              0x007000
0192 #define CUR_CHANGE(c)        ((c) & 0x00ff00)
0193 #define CUR_SET(c)      (((c) & 0xff0000) >> 8)
0194 
0195 bool con_is_visible(const struct vc_data *vc);
0196 
0197 #endif /* _LINUX_CONSOLE_STRUCT_H */