Welcome to The Fiwix Project
A UNIX-like kernel for the i386 architecture
1 /* 2 * fiwix/include/fiwix/console.h 3 * 4 * Copyright 2018-2021, Jordi Sanfeliu. All rights reserved. 5 * Distributed under the terms of the Fiwix License. 6 */ 7 8 #ifndef _FIWIX_CONSOLE_H 9 #define _FIWIX_CONSOLE_H 10 11 #include <fiwix/vt.h> 12 13 #define NR_VCONSOLES 12 /* number of virtual consoles */ 14 15 #define VCONSOLES_MAJOR 4 /* virtual consoles major number */ 16 #define SYSCON_MAJOR 5 /* system console major number */ 17 18 /* Graphic Rendition Combination Modes */ 19 #define SGR_DEFAULT 0 /* back to the default rendition */ 20 #define SGR_BOLD 1 /* set bold */ 21 #define SGR_BLINK 5 /* set slowly blinking */ 22 #define SGR_REVERSE 7 /* set reverse video */ 23 #define SGR_BOLD_OFF 21 /* unset bold */ 24 #define SGR_BLINK_OFF 25 /* unset blinking */ 25 #define SGR_REVERSE_OFF 27 /* unset reverse video */ 26 27 #define SGR_BLACK_FG 30 /* set black foreground */ 28 #define SGR_RED_FG 31 /* set red foreground */ 29 #define SGR_GREEN_FG 32 /* set green foreground */ 30 #define SGR_BROWN_FG 33 /* set brown foreground */ 31 #define SGR_BLUE_FG 34 /* set blue foreground */ 32 #define SGR_MAGENTA_FG 35 /* set magenta foreground */ 33 #define SGR_CYAN_FG 36 /* set cyan foreground */ 34 #define SGR_WHITE_FG 37 /* set white foreground */ 35 36 #define SGR_DEFAULT_FG_U_ON 38 /* set def. fg color (underline on) */ 37 #define SGR_DEFAULT_FG_U_OFF 39 /* set def. fg color (underline off) */ 38 39 #define SGR_BLACK_BG 40 /* set black background */ 40 #define SGR_RED_BG 41 /* set red background */ 41 #define SGR_GREEN_BG 42 /* set green background */ 42 #define SGR_BROWN_BG 43 /* set brown background */ 43 #define SGR_BLUE_BG 44 /* set blue background */ 44 #define SGR_MAGENTA_BG 45 /* set magenta background */ 45 #define SGR_CYAN_BG 46 /* set cyan background */ 46 #define SGR_WHITE_BG 47 /* set white background */ 47 48 #define SGR_DEFAULT_BG 49 /* set default background color */ 49 50 #define NPARMS 16 51 #define BLANK_INTERVAL (0 * HZ) /* 0 seconds (no screen blank) */ 52 53 #define COLOR_BLACK 0x0000 54 #define COLOR_BLUE 0x0100 55 #define COLOR_GREEN 0x0200 56 #define COLOR_CYAN 0x0300 57 #define COLOR_RED 0x0400 58 #define COLOR_MAGENTA 0x0500 59 #define COLOR_BROWN 0x0600 60 #define COLOR_WHITE 0x0700 61 #define BG_BLACK 0x0000 62 #define BG_BLUE 0x1000 63 #define BG_GREEN 0x2000 64 #define BG_CYAN 0x3000 65 #define BG_RED 0x4000 66 #define BG_MAGENTA 0x5000 67 #define BG_BROWN 0x6000 68 #define BG_WHITE 0x7000 69 70 #define DEF_MODE (COLOR_WHITE | BG_BLACK) 71 #define BLANK_MEM (DEF_MODE | ' ') 72 73 #define SCREEN_COLS video.columns 74 #define SCREEN_LINES video.lines 75 #define SCREEN_SIZE (video.columns * video.lines) 76 #define VC_BUF_LINES (video.lines * SCREENS_LOG) 77 #define VC_BUF_SIZE (video.columns * VC_BUF_LINES) 78 79 #define SCROLL_UP 1 80 #define SCROLL_DOWN 2 81 82 #define BS 127 /* backspace */ 83 84 #define VPF_VGA 0x01 /* VGA text mode */ 85 #define VPF_VESAFB 0x02 /* x86 frame buffer */ 86 #define VPF_CURSOR_ON 0x04 /* draw cursor */ 87 88 #define ON 1 89 #define OFF 0 90 #define COND 2 91 92 /* console flags */ 93 #define CONSOLE_HAS_FOCUS 0x0001 94 #define CONSOLE_BLANKED 0x0002 95 96 97 extern short int current_cons; /* current console (/dev/tty1 ... /dev/tty12) */ 98 99 short int *vc_screen[NR_VCONSOLES + 1]; 100 101 /* 102 * This is the scrollback history buffer which is used only in the active 103 * vconsole. Everytime a vconsole is switched, the screen contents of the 104 * new vconsole is copied back to this buffer. Only the visible screen is 105 * copied, so switching vconsoles means losing the scrollback history. 106 */ 107 short int *vcbuf; 108 109 struct vconsole { 110 int x; /* current column */ 111 int y; /* current line */ 112 int top, lines, columns; 113 short int check_x; 114 unsigned char led_status; 115 unsigned char scrlock, numlock, capslock; 116 unsigned char esc, sbracket, semicolon, question; 117 int flags; 118 int parmv1, parmv2; 119 int nparms, parms[NPARMS]; 120 unsigned short int color_attr; 121 unsigned char bold, underline, blink, reverse; 122 int insert_mode; 123 unsigned char *vidmem; /* write here only when console has focus */ 124 short int *screen; /* the back-buffer of the screen */ 125 int saved_x, cursor_x; 126 int saved_y, cursor_y; 127 struct vt_mode vt_mode; 128 unsigned char vc_mode; 129 int switchto_tty; 130 struct tty *tty; 131 }; 132 133 struct video_parms { 134 int flags; 135 unsigned int *address; 136 int port; 137 int memsize; 138 unsigned char signature[32]; 139 int columns; 140 int lines; 141 int buf_y; 142 int buf_top; 143 int fb_version; 144 int fb_width; 145 int fb_height; 146 int fb_char_width; 147 int fb_char_height; 148 int fb_bpp; 149 int fb_pixelwidth; 150 int fb_pitch; 151 int fb_linesize; 152 int fb_size; /* size of screen based on resolution */ 153 int fb_vsize; /* size of screen based on columns x lines */ 154 155 /* formerly video driver operations */ 156 void (*put_char)(struct vconsole *, unsigned char); 157 void (*insert_char)(struct vconsole *); 158 void (*delete_char)(struct vconsole *); 159 void (*update_curpos)(struct vconsole *); 160 void (*show_cursor)(struct vconsole *, int); 161 void (*get_curpos)(struct vconsole *); 162 void (*write_screen)(struct vconsole *, int, int, short int); 163 void (*blank_screen)(struct vconsole *); 164 void (*scroll_screen)(struct vconsole *, int, int); 165 void (*restore_screen)(struct vconsole *); 166 void (*screen_on)(struct vconsole *); 167 void (*buf_scroll)(struct vconsole *, int); 168 void (*cursor_blink)(unsigned int); 169 }; 170 extern struct video_parms video; 171 172 void vconsole_reset(struct tty *); 173 void vconsole_write(struct tty *); 174 void vconsole_select(int); 175 void vconsole_select_final(int); 176 void vconsole_restore(struct vconsole *); 177 void unblank_screen(struct vconsole *); 178 void vconsole_start(struct tty *); 179 void vconsole_stop(struct tty *); 180 void vconsole_beep(void); 181 void vconsole_deltab(struct tty *); 182 void console_flush_log_buf(char *, unsigned int); 183 void console_init(void); 184 185 #endif /* _FIWIX_CONSOLE_H */