syscons.c (6512) | syscons.c (6628) |
---|---|
1/*- 2 * Copyright (c) 1992-1995 S�ren Schmidt | 1/*- 2 * Copyright (c) 1992-1995 S�ren Schmidt |
3 * Copyright (c) 1990 The Regents of the University of California. | |
4 * All rights reserved. 5 * | 3 * All rights reserved. 4 * |
6 * This code is derived from software contributed to Berkeley by 7 * William Jolitz and Don Ahn. 8 * | |
9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright | 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright |
13 * notice, this list of conditions and the following disclaimer, | 9 * notice, this list of conditions and the following disclaimer |
14 * in this position and unchanged. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. | 10 * in this position and unchanged. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. |
18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the University of 21 * California, Berkeley and its contributors. 22 * 4. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. | 14 * 3. The name of the author may not be used to endorse or promote products 15 * derived from this software withough specific prior written permission |
25 * | 16 * |
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. | 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
37 * | 27 * |
38 * $Id: syscons.c,v 1.102 1995/02/14 14:37:53 sos Exp $ | 28 * $Id$ |
39 */ 40 41#include "sc.h" | 29 */ 30 31#include "sc.h" |
42 | |
43#if NSC > 0 | 32#if NSC > 0 |
44 | |
45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/conf.h> 48#include <sys/ioctl.h> 49#include <sys/proc.h> 50#include <sys/user.h> 51#include <sys/tty.h> 52#include <sys/uio.h> --- 10 unchanged lines hidden (view full) --- 63#include <machine/frame.h> 64#include <machine/pc/display.h> 65 66#include <i386/isa/isa.h> 67#include <i386/isa/isa_device.h> 68#include <i386/isa/timerreg.h> 69#include <i386/isa/kbdtables.h> 70#include <i386/i386/cons.h> | 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/conf.h> 36#include <sys/ioctl.h> 37#include <sys/proc.h> 38#include <sys/user.h> 39#include <sys/tty.h> 40#include <sys/uio.h> --- 10 unchanged lines hidden (view full) --- 51#include <machine/frame.h> 52#include <machine/pc/display.h> 53 54#include <i386/isa/isa.h> 55#include <i386/isa/isa_device.h> 56#include <i386/isa/timerreg.h> 57#include <i386/isa/kbdtables.h> 58#include <i386/i386/cons.h> |
59#include <i386/isa/syscons.h> |
|
71 72#if !defined(MAXCONS) 73#define MAXCONS 16 74#endif 75#include "apm.h" 76#if NAPM > 0 77#include "machine/apm_bios.h" 78#endif 79 80/* this may break on older VGA's but is usefull on real 32 bit systems */ | 60 61#if !defined(MAXCONS) 62#define MAXCONS 16 63#endif 64#include "apm.h" 65#if NAPM > 0 66#include "machine/apm_bios.h" 67#endif 68 69/* this may break on older VGA's but is usefull on real 32 bit systems */ |
81#define bcopyw bcopy | 70#define bcopyw bcopy |
82 | 71 |
83/* vm things */ 84#define ISMAPPED(pa, width) \ 85 (((pa) <= (u_long)0x1000 - (width)) \ 86 || ((pa) >= 0xa0000 && (pa) <= 0x100000 - (width))) 87#define pa_to_va(pa) (KERNBASE + (pa)) /* works if ISMAPPED(pa...) */ 88 89/* printable chars */ 90#define PRINTABLE(ch) (ch>0x1B || (ch>0x0d && ch<0x1b) || ch<0x07) 91 92/* status flags */ 93#define LOCK_KEY_MASK 0x0000F 94#define LED_MASK 0x00007 95#define UNKNOWN_MODE 0x00010 96#define KBD_RAW_MODE 0x00020 97#define SWITCH_WAIT_REL 0x00040 98#define SWITCH_WAIT_ACQ 0x00080 99#define BUFFER_SAVED 0x00100 100#define CURSOR_ENABLED 0x00200 101#define CURSOR_SHOWN 0x00400 102#define MOUSE_ENABLED 0x00800 103#define UPDATE_MOUSE 0x01000 104#define UPDATE_SCREEN 0x02000 105 106/* configuration flags */ 107#define VISUAL_BELL 0x00001 108#define BLINK_CURSOR 0x00002 109#define CHAR_CURSOR 0x00004 110 111/* video hardware memory addresses */ 112#define VIDEOMEM 0x000A0000 113 114/* misc defines */ 115#define FALSE 0 116#define TRUE 1 117#define MAX_ESC_PAR 5 118#define LOAD 1 119#define SAVE 0 120#define COL 80 121#define ROW 25 122#define BELL_DURATION 5 123#define BELL_PITCH 800 124#define TIMER_FREQ 1193182 /* should be in isa.h */ 125#define CONSOLE_BUFSIZE 1024 126#define PCBURST 128 127#define FONT_8 0x001 128#define FONT_14 0x002 129#define FONT_16 0x004 130#define HISTORY_SIZE 100*80 131 132/* defines related to hardware addresses */ 133#define MONO_BASE 0x3B4 /* crt controller base mono */ 134#define COLOR_BASE 0x3D4 /* crt controller base color */ 135#define MISC 0x3C2 /* misc output register */ 136#define ATC IO_VGA+0x00 /* attribute controller */ 137#define TSIDX IO_VGA+0x04 /* timing sequencer idx */ 138#define TSREG IO_VGA+0x05 /* timing sequencer data */ 139#define PIXMASK IO_VGA+0x06 /* pixel write mask */ 140#define PALRADR IO_VGA+0x07 /* palette read address */ 141#define PALWADR IO_VGA+0x08 /* palette write address */ 142#define PALDATA IO_VGA+0x09 /* palette data register */ 143#define GDCIDX IO_VGA+0x0E /* graph data controller idx */ 144#define GDCREG IO_VGA+0x0F /* graph data controller data */ 145 146/* special characters */ 147#define cntlc 0x03 148#define cntld 0x04 149#define bs 0x08 150#define lf 0x0a 151#define cr 0x0d 152#define del 0x7f 153 154typedef struct term_stat { 155 int esc; /* processing escape sequence */ 156 int num_param; /* # of parameters to ESC */ 157 int last_param; /* last parameter # */ 158 int param[MAX_ESC_PAR]; /* contains ESC parameters */ 159 int cur_attr; /* current attributes */ 160 int std_attr; /* normal attributes */ 161 int rev_attr; /* reverse attributes */ 162} term_stat; 163 164typedef struct scr_stat { 165 u_short *scr_buf; /* buffer when off screen */ 166 int xpos; /* current X position */ 167 int ypos; /* current Y position */ 168 int xsize; /* X size */ 169 int ysize; /* Y size */ 170 term_stat term; /* terminal emulation stuff */ 171 int status; /* status (bitfield) */ 172 u_short *cursor_pos; /* cursor buffer position */ 173 u_short cursor_saveunder; /* saved chars under cursor */ 174 char cursor_start; /* cursor start line # */ 175 char cursor_end; /* cursor end line # */ 176 u_short *mouse_pos; /* mouse buffer position */ 177 u_short *mouse_oldpos; /* mouse old buffer position */ 178 u_short mouse_saveunder[4]; /* saved chars under mouse */ 179 short mouse_xpos; /* mouse x coordinate */ 180 short mouse_ypos; /* mouse y coordinate */ 181 u_char mouse_cursor[128]; /* mouse cursor bitmap store */ 182 u_short bell_duration; 183 u_short bell_pitch; 184 u_char border; /* border color */ 185 u_char mode; /* mode */ 186 u_char font; /* font on this screen */ 187 pid_t pid; /* pid of controlling proc */ 188 struct proc *proc; /* proc* of controlling proc */ 189 struct vt_mode smode; /* switch mode */ 190 u_short *history; /* circular history buffer */ 191 u_short *history_head; /* current head position */ 192 u_short *history_pos; /* position shown on screen */ 193 u_short *history_save; /* save area index */ 194 int history_size; /* size of history buffer */ 195#if NAPM > 0 196 struct apmhook r_hook; /* reconfiguration support */ 197#endif /* NAPM > 0 */ 198} scr_stat; 199 200typedef struct default_attr { 201 int std_attr; /* normal attributes */ 202 int rev_attr; /* reverse attributes */ 203} default_attr; 204 | |
205static default_attr user_default = { | 72static default_attr user_default = { |
206 (FG_LIGHTGREY | BG_BLACK) << 8, 207 (FG_BLACK | BG_LIGHTGREY) << 8 | 73 (FG_LIGHTGREY | BG_BLACK) << 8, 74 (FG_BLACK | BG_LIGHTGREY) << 8 |
208}; 209 210static default_attr kernel_default = { | 75}; 76 77static default_attr kernel_default = { |
211 (FG_WHITE | BG_BLACK) << 8, 212 (FG_BLACK | BG_LIGHTGREY) << 8 | 78 (FG_WHITE | BG_BLACK) << 8, 79 (FG_BLACK | BG_LIGHTGREY) << 8 |
213}; 214 | 80}; 81 |
215static scr_stat main_console; 216static scr_stat *console[MAXCONS]; 217static scr_stat *cur_console; 218static scr_stat *new_scp, *old_scp; 219static term_stat kernel_console; 220static default_attr *current_default; 221static char init_done = FALSE; 222static char switch_in_progress = FALSE; 223static char blink_in_progress = FALSE; 224static char write_in_progress = FALSE; 225static u_int crtc_addr = MONO_BASE; 226static char crtc_vga = FALSE; 227static u_char shfts = 0, ctls = 0, alts = 0, agrs = 0, metas = 0; 228static u_char nlkcnt = 0, clkcnt = 0, slkcnt = 0, alkcnt = 0; 229static char *font_8 = NULL, *font_14 = NULL, *font_16 = NULL; 230static int fonts_loaded = 0; 231static char palette[3*256]; 232static const u_int n_fkey_tab = sizeof(fkey_tab) / sizeof(*fkey_tab); | 82static scr_stat main_console; 83static scr_stat *console[MAXCONS]; 84 scr_stat *cur_console; 85static scr_stat *new_scp, *old_scp; 86static term_stat kernel_console; 87static default_attr *current_default; 88static char init_done = FALSE; 89static char switch_in_progress = FALSE; 90static char blink_in_progress = FALSE; 91static char write_in_progress = FALSE; 92 u_int crtc_addr = MONO_BASE; 93static char crtc_vga = FALSE; 94static u_char shfts = 0, ctls = 0, alts = 0, agrs = 0, metas = 0; 95static u_char nlkcnt = 0, clkcnt = 0, slkcnt = 0, alkcnt = 0; 96static char *font_8 = NULL, *font_14 = NULL, *font_16 = NULL; 97static int fonts_loaded = 0; 98 char palette[3*256]; 99static const u_int n_fkey_tab = sizeof(fkey_tab) / sizeof(*fkey_tab); |
233#if ASYNCH | 100#if ASYNCH |
234static u_char kbd_reply = 0; | 101static u_char kbd_reply = 0; |
235#endif | 102#endif |
236static int delayed_next_scr = FALSE; 237static int configuration = 0; /* current setup */ 238static long scrn_blank_time = 0; /* screen saver timeout value */ 239static int scrn_blanked = FALSE; /* screen saver active flag */ 240static int scrn_saver = 0; /* screen saver routine */ 241static long scrn_time_stamp; 242static u_char scr_map[256]; 243static char *video_mode_ptr = NULL; 244static u_short mouse_and_mask[16] = { 245 0xc000, 0xe000, 0xf000, 0xf800, 0xfc00, 0xfe00, 0xff00, 0xff80, 246 0xfe00, 0x1e00, 0x1f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000 247 }; 248static u_short mouse_or_mask[16] = { 249 0x0000, 0x4000, 0x6000, 0x7000, 0x7800, 0x7c00, 0x7e00, 0x6800, 250 0x0c00, 0x0c00, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, 0x0000 251 }; | 103static int delayed_next_scr = FALSE; 104static int configuration = 0; /* current setup */ 105static long scrn_blank_time = 0; /* screen saver timeout value */ 106 int scrn_blanked = FALSE; /* screen saver active flag */ 107static int scrn_saver = 0; /* screen saver routine */ 108static long scrn_time_stamp; 109 u_char scr_map[256]; 110static char *video_mode_ptr = NULL; |
252 | 111 |
253/* function prototypes */ 254int scprobe(struct isa_device *dev); 255int scattach(struct isa_device *dev); 256int scopen(dev_t dev, int flag, int mode, struct proc *p); 257int scclose(dev_t dev, int flag, int mode, struct proc *p); 258int scread(dev_t dev, struct uio *uio, int flag); 259int scwrite(dev_t dev, struct uio *uio, int flag); 260int scparam(struct tty *tp, struct termios *t); 261int scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p); 262void scxint(dev_t dev); 263void scstart(struct tty *tp); 264void pccnprobe(struct consdev *cp); 265void pccninit(struct consdev *cp); 266void pccnputc(dev_t dev, char c); 267int pccngetc(dev_t dev); 268int pccncheckc(dev_t dev); 269void scintr(int unit); 270int pcmmap(dev_t dev, int offset, int nprot); 271static void scinit(void); 272static void scput(u_char c); 273static u_int scgetc(int noblock); 274static struct tty *get_tty_ptr(dev_t dev); 275static scr_stat *get_scr_stat(dev_t dev); 276static scr_stat *alloc_scp(); 277static void init_scp(scr_stat *scp); 278static int get_scr_num(); 279static void scrn_timer(); 280static void clear_screen(scr_stat *scp); 281static int switch_scr(scr_stat *scp, u_int next_scr); 282static void exchange_scr(void); 283static inline void move_crsr(scr_stat *scp, int x, int y); 284static void scan_esc(scr_stat *scp, u_char c); 285static inline void draw_cursor(scr_stat *scp, int show); 286static void ansi_put(scr_stat *scp, u_char *buf, int len); 287static u_char *get_fstr(u_int c, u_int *len); 288static void update_leds(int which); 289static void history_to_screen(scr_stat *scp); 290static int history_up_line(scr_stat *scp); 291static int history_down_line(scr_stat *scp); 292static void kbd_wait(void); 293static void kbd_cmd(u_char command); 294static void set_mode(scr_stat *scp); 295static void set_border(int color); 296static void set_vgaregs(char *modetable); 297static void set_font_mode(); 298static void set_normal_mode(); 299static void copy_font(int operation, int font_type, char* font_image); 300static void draw_mouse_image(scr_stat *scp); 301static void save_palette(void); 302static void load_palette(void); 303static void do_bell(scr_stat *scp, int pitch, int duration); 304static void blink_screen(scr_stat *scp); 305 306/* available screen savers */ 307static void none_saver(int blank); 308static void blank_saver(int blank); 309static void fade_saver(int blank); 310static void star_saver(int blank); 311static void snake_saver(int blank); 312static void green_saver(int blank); 313 314static const struct { 315 char *name; 316 void (*routine)(); 317} screen_savers[] = { 318 { "none", none_saver }, /* 0 */ 319 { "blank", blank_saver }, /* 1 */ 320 { "fade", fade_saver }, /* 2 */ 321 { "star", star_saver }, /* 3 */ 322 { "snake", snake_saver }, /* 4 */ 323 { "green", green_saver }, /* 5 */ | 112static u_short mouse_and_mask[16] = { 113 0xc000, 0xe000, 0xf000, 0xf800, 0xfc00, 0xfe00, 0xff00, 0xff80, 114 0xfe00, 0x1e00, 0x1f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000 |
324}; | 115}; |
325#define SCRN_SAVER(arg) (*screen_savers[scrn_saver].routine)(arg) 326#define NUM_SCRN_SAVERS (sizeof(screen_savers) / sizeof(screen_savers[0])) 327#define WRAPHIST(scp, pointer, offset)\ 328 ((scp->history) + ((((pointer) - (scp->history)) + (scp->history_size)\ 329 + (offset)) % (scp->history_size))) | 116static u_short mouse_or_mask[16] = { 117 0x0000, 0x4000, 0x6000, 0x7000, 0x7800, 0x7c00, 0x7e00, 0x6800, 118 0x0c00, 0x0c00, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, 0x0000 119}; |
330 | 120 |
121void none_saver(int blank) { } 122void (*current_saver)() = none_saver; 123 |
|
331/* OS specific stuff */ 332#ifdef not_yet_done | 124/* OS specific stuff */ 125#ifdef not_yet_done |
333#define VIRTUAL_TTY(x) (sccons[x] = ttymalloc(sccons[x])) 334struct CONSOLE_TTY (sccons[MAXCONS] = ttymalloc(sccons[MAXCONS])) 335struct tty *sccons[MAXCONS+1]; | 126#define VIRTUAL_TTY(x) (sccons[x] = ttymalloc(sccons[x])) 127struct CONSOLE_TTY (sccons[MAXCONS] = ttymalloc(sccons[MAXCONS])) 128struct tty *sccons[MAXCONS+1]; |
336#else | 129#else |
337#define VIRTUAL_TTY(x) &sccons[x] 338#define CONSOLE_TTY &sccons[MAXCONS] 339struct tty sccons[MAXCONS+1]; | 130#define VIRTUAL_TTY(x) &sccons[x] 131#define CONSOLE_TTY &sccons[MAXCONS] 132struct tty sccons[MAXCONS+1]; |
340#endif | 133#endif |
341#define MONO_BUF pa_to_va(0xB0000) 342#define CGA_BUF pa_to_va(0xB8000) 343u_short *Crtat = (u_short *)MONO_BUF; | 134#define MONO_BUF pa_to_va(0xB0000) 135#define CGA_BUF pa_to_va(0xB8000) 136u_short *Crtat = (u_short *)MONO_BUF; |
344 | 137 |
345struct isa_driver scdriver = { 346 scprobe, scattach, "sc", 1 | 138#define WRAPHIST(scp, pointer, offset)\ 139 ((scp->history) + ((((pointer) - (scp->history)) + (scp->history_size)\ 140 + (offset)) % (scp->history_size))) 141 142struct isa_driver scdriver = { 143 scprobe, scattach, "sc", 1 |
347}; 348 349int 350scprobe(struct isa_device *dev) 351{ | 144}; 145 146int 147scprobe(struct isa_device *dev) 148{ |
352 int i, retries = 5; 353 unsigned char val; | 149 int i, retries = 5; 150 unsigned char val; |
354 | 151 |
355 /* Enable interrupts and keyboard controller */ 356 kbd_wait(); 357 outb(KB_STAT, KB_WRITE); 358 kbd_wait(); 359 outb(KB_DATA, KB_MODE); | 152 /* Enable interrupts and keyboard controller */ 153 kbd_wait(); 154 outb(KB_STAT, KB_WRITE); 155 kbd_wait(); 156 outb(KB_DATA, KB_MODE); |
360 | 157 |
361 /* flush any noise in the buffer */ 362 while (inb(KB_STAT) & KB_BUF_FULL) { 363 DELAY(10); 364 (void) inb(KB_DATA); 365 } | 158 /* flush any noise in the buffer */ 159 while (inb(KB_STAT) & KB_BUF_FULL) { 160 DELAY(10); 161 (void) inb(KB_DATA); 162 } |
366 | 163 |
367 /* Reset keyboard hardware */ 368 while (retries--) { 369 kbd_wait(); 370 outb(KB_DATA, KB_RESET); 371 for (i=0; i<100000; i++) { 372 DELAY(10); 373 val = inb(KB_DATA); 374 if (val == KB_ACK || val == KB_ECHO) 375 goto gotres; 376 if (val == KB_RESEND) 377 break; 378 } | 164 /* Reset keyboard hardware */ 165 while (retries--) { 166 kbd_wait(); 167 outb(KB_DATA, KB_RESET); 168 for (i=0; i<100000; i++) { 169 DELAY(10); 170 val = inb(KB_DATA); 171 if (val == KB_ACK || val == KB_ECHO) 172 goto gotres; 173 if (val == KB_RESEND) 174 break; |
379 } | 175 } |
176 } |
|
380gotres: | 177gotres: |
381 if (!retries) 382 printf("scprobe: keyboard won't accept RESET command\n"); 383 else { | 178 if (!retries) 179 printf("scprobe: keyboard won't accept RESET command\n"); 180 else { |
384gotack: | 181gotack: |
385 DELAY(10); 386 while ((inb(KB_STAT) & KB_BUF_FULL) == 0) DELAY(10); 387 DELAY(10); 388 val = inb(KB_DATA); 389 if (val == KB_ACK) 390 goto gotack; 391 if (val != KB_RESET_DONE) 392 printf("scprobe: keyboard RESET failed %02x\n", val); 393 } | 182 DELAY(10); 183 while ((inb(KB_STAT) & KB_BUF_FULL) == 0) DELAY(10); 184 DELAY(10); 185 val = inb(KB_DATA); 186 if (val == KB_ACK) 187 goto gotack; 188 if (val != KB_RESET_DONE) 189 printf("scprobe: keyboard RESET failed %02x\n", val); 190 } |
394#ifdef XT_KEYBOARD | 191#ifdef XT_KEYBOARD |
395 kbd_wait(); 396 outb(KB_DATA, 0xF0); 397 kbd_wait(); 398 outb(KB_DATA, 1) 399 kbd_wait(); | 192 kbd_wait(); 193 outb(KB_DATA, 0xF0); 194 kbd_wait(); 195 outb(KB_DATA, 1) 196 kbd_wait(); |
400#endif /* XT_KEYBOARD */ | 197#endif /* XT_KEYBOARD */ |
401 return (IO_KBDSIZE); | 198 return (IO_KBDSIZE); |
402} 403 | 199} 200 |
404static struct kern_devconf kdc_sc[NSC] = { { 405 0, 0, 0, /* filled in by dev_attach */ 406 "sc", 0, { MDDT_ISA, 0, "tty" }, 407 isa_generic_externalize, 0, 0, ISA_EXTERNALLEN, 408 &kdc_isa0, /* parent */ 409 0, /* parentdata */ 410 DC_BUSY, /* the console is almost always busy */ 411 "Graphics console" 412} }; | 201static struct kern_devconf kdc_sc[NSC] = { 202 0, 0, 0, /* filled in by dev_attach */ 203 "sc", 0, { MDDT_ISA, 0, "tty" }, 204 isa_generic_externalize, 0, 0, ISA_EXTERNALLEN, 205 &kdc_isa0, /* parent */ 206 0, /* parentdata */ 207 DC_BUSY, /* the console is almost always busy */ 208 "Graphics console" 209}; |
413 414static inline void 415sc_registerdev(struct isa_device *id) 416{ | 210 211static inline void 212sc_registerdev(struct isa_device *id) 213{ |
417 if(id->id_unit) 418 kdc_sc[id->id_unit] = kdc_sc[0]; 419 kdc_sc[id->id_unit].kdc_unit = id->id_unit; 420 kdc_sc[id->id_unit].kdc_isa = id; 421 dev_attach(&kdc_sc[id->id_unit]); | 214 if(id->id_unit) 215 kdc_sc[id->id_unit] = kdc_sc[0]; 216 kdc_sc[id->id_unit].kdc_unit = id->id_unit; 217 kdc_sc[id->id_unit].kdc_isa = id; 218 dev_attach(&kdc_sc[id->id_unit]); |
422} 423 | 219} 220 |
424#if NAPM > 0 425/* ARGSUSED */ 426static int 427pcresume(void *dummy) 428{ 429 shfts = 0; 430 ctls = 0; 431 alts = 0; 432 agrs = 0; 433 metas = 0; 434 return 0; 435} 436#endif /* NAPM > 0 */ 437 438 | |
439int 440scattach(struct isa_device *dev) 441{ | 221int 222scattach(struct isa_device *dev) 223{ |
442 scr_stat *scp; | 224 scr_stat *scp; |
443 | 225 |
444 scinit(); 445 configuration = dev->id_flags; 446 printf("sc%d: ", dev->id_unit); 447 if (crtc_vga) 448 if (crtc_addr == MONO_BASE) 449 printf("VGA mono"); 450 else 451 printf("VGA color"); 452 else 453 if (crtc_addr == MONO_BASE) 454 printf("MDA/hercules"); 455 else 456 printf("CGA/EGA"); 457 printf(" <%d virtual consoles, flags=0x%x>\n", 458 MAXCONS, configuration); 459 scp = console[0]; 460 scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short), 461 M_DEVBUF, M_NOWAIT); 462 /* copy screen to buffer */ 463 bcopyw(Crtat, scp->scr_buf, scp->xsize * scp->ysize * sizeof(u_short)); 464 scp->cursor_pos = scp->scr_buf + scp->xpos + scp->ypos * scp->xsize; 465 scp->mouse_pos = scp->scr_buf; | 226 scinit(); 227 configuration = dev->id_flags; 228 printf("sc%d: ", dev->id_unit); 229 if (crtc_vga) 230 if (crtc_addr == MONO_BASE) 231 printf("VGA mono"); 232 else 233 printf("VGA color"); 234 else 235 if (crtc_addr == MONO_BASE) 236 printf("MDA/hercules"); 237 else 238 printf("CGA/EGA"); 239 printf(" <%d virtual consoles, flags=0x%x>\n", MAXCONS, configuration); 240 scp = console[0]; 241 scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short), 242 M_DEVBUF, M_NOWAIT); 243 /* copy screen to buffer */ 244 bcopyw(Crtat, scp->scr_buf, scp->xsize * scp->ysize * sizeof(u_short)); 245 scp->cursor_pos = scp->scr_buf + scp->xpos + scp->ypos * scp->xsize; 246 scp->mouse_pos = scp->scr_buf; |
466 | 247 |
467 /* initialize history buffer & pointers */ 468 scp->history_head = scp->history_pos = scp->history = 469 (u_short *)malloc(scp->history_size*sizeof(u_short), 470 M_DEVBUF, M_NOWAIT); 471 bzero(scp->history_head, scp->history_size*sizeof(u_short)); | 248 /* initialize history buffer & pointers */ 249 scp->history_head = scp->history_pos = scp->history = 250 (u_short *)malloc(scp->history_size*sizeof(u_short), 251 M_DEVBUF, M_NOWAIT); 252 bzero(scp->history_head, scp->history_size*sizeof(u_short)); |
472 | 253 |
473 if (crtc_vga) { 474 font_8 = (char *)malloc(8*256, M_DEVBUF, M_NOWAIT); 475 font_14 = (char *)malloc(14*256, M_DEVBUF, M_NOWAIT); 476 font_16 = (char *)malloc(16*256, M_DEVBUF, M_NOWAIT); 477 copy_font(SAVE, FONT_16, font_16); 478 fonts_loaded = FONT_16; 479 scp->font = FONT_16; 480 save_palette(); 481 } | 254 if (crtc_vga) { 255 font_8 = (char *)malloc(8*256, M_DEVBUF, M_NOWAIT); 256 font_14 = (char *)malloc(14*256, M_DEVBUF, M_NOWAIT); 257 font_16 = (char *)malloc(16*256, M_DEVBUF, M_NOWAIT); 258 copy_font(SAVE, FONT_16, font_16); 259 fonts_loaded = FONT_16; 260 scp->font = FONT_16; 261 save_palette(); 262 } |
482 | 263 |
483 /* get screen update going */ 484 scrn_timer(); | 264 /* get screen update going */ 265 scrn_timer(); |
485 | 266 |
486 update_leds(scp->status); 487 sc_registerdev(dev); | 267 update_leds(scp->status); 268 sc_registerdev(dev); |
488#if NAPM > 0 | 269#if NAPM > 0 |
489 scp->r_hook.ah_fun = pcresume; 490 scp->r_hook.ah_arg = NULL; 491 scp->r_hook.ah_name = "pccons keyboard"; 492 scp->r_hook.ah_order = APM_MID_ORDER; 493 apm_hook_establish(APM_HOOK_RESUME , &scp->r_hook); 494#endif /* NAPM > 0*/ 495 return 0; | 270 scp->r_hook.ah_fun = pcresume; 271 scp->r_hook.ah_arg = NULL; 272 scp->r_hook.ah_name = "system keyboard"; 273 scp->r_hook.ah_order = APM_MID_ORDER; 274 apm_hook_establish(APM_HOOK_RESUME , &scp->r_hook); 275#endif 276 return 0; |
496} 497 498static struct tty 499*get_tty_ptr(dev_t dev) 500{ | 277} 278 279static struct tty 280*get_tty_ptr(dev_t dev) 281{ |
501 int unit = minor(dev); | 282 int unit = minor(dev); |
502 | 283 |
503 if (unit > MAXCONS || unit < 0) 504 return(NULL); 505 if (unit == MAXCONS) 506 return CONSOLE_TTY; 507 return VIRTUAL_TTY(unit); | 284 if (unit > MAXCONS || unit < 0) 285 return(NULL); 286 if (unit == MAXCONS) 287 return CONSOLE_TTY; 288 return VIRTUAL_TTY(unit); |
508} 509 510static scr_stat 511*get_scr_stat(dev_t dev) 512{ | 289} 290 291static scr_stat 292*get_scr_stat(dev_t dev) 293{ |
513 int unit = minor(dev); | 294 int unit = minor(dev); |
514 | 295 |
515 if (unit > MAXCONS || unit < 0) 516 return(NULL); 517 if (unit == MAXCONS) 518 return console[0]; 519 return console[unit]; | 296 if (unit > MAXCONS || unit < 0) 297 return(NULL); 298 if (unit == MAXCONS) 299 return console[0]; 300 return console[unit]; |
520} 521 522static int 523get_scr_num() 524{ | 301} 302 303static int 304get_scr_num() 305{ |
525 int i = 0; | 306 int i = 0; |
526 | 307 |
527 while ((i < MAXCONS) && (cur_console != console[i])) i++; 528 return i < MAXCONS ? i : 0; | 308 while ((i < MAXCONS) && (cur_console != console[i])) 309 i++; 310 return i < MAXCONS ? i : 0; |
529} 530 531int 532scopen(dev_t dev, int flag, int mode, struct proc *p) 533{ | 311} 312 313int 314scopen(dev_t dev, int flag, int mode, struct proc *p) 315{ |
534 struct tty *tp = get_tty_ptr(dev); | 316 struct tty *tp = get_tty_ptr(dev); |
535 | 317 |
536 if (!tp) 537 return(ENXIO); | 318 if (!tp) 319 return(ENXIO); |
538 | 320 |
539 tp->t_oproc = scstart; 540 tp->t_param = scparam; 541 tp->t_dev = dev; 542 if (!(tp->t_state & TS_ISOPEN)) { 543 ttychars(tp); 544 tp->t_iflag = TTYDEF_IFLAG; 545 tp->t_oflag = TTYDEF_OFLAG; 546 tp->t_cflag = TTYDEF_CFLAG; 547 tp->t_lflag = TTYDEF_LFLAG; 548 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; 549 scparam(tp, &tp->t_termios); 550 ttsetwater(tp); 551 } else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) 552 return(EBUSY); 553 tp->t_state |= TS_CARR_ON; 554 tp->t_cflag |= CLOCAL; 555 if (!console[minor(dev)]) 556 console[minor(dev)] = alloc_scp(); 557 return((*linesw[tp->t_line].l_open)(dev, tp)); | 321 tp->t_oproc = scstart; 322 tp->t_param = scparam; 323 tp->t_dev = dev; 324 if (!(tp->t_state & TS_ISOPEN)) { 325 ttychars(tp); 326 tp->t_iflag = TTYDEF_IFLAG; 327 tp->t_oflag = TTYDEF_OFLAG; 328 tp->t_cflag = TTYDEF_CFLAG; 329 tp->t_lflag = TTYDEF_LFLAG; 330 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; 331 scparam(tp, &tp->t_termios); 332 ttsetwater(tp); 333 } 334 else 335 if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) 336 return(EBUSY); 337 tp->t_state |= TS_CARR_ON; 338 tp->t_cflag |= CLOCAL; 339 if (!console[minor(dev)]) 340 console[minor(dev)] = alloc_scp(); 341 return((*linesw[tp->t_line].l_open)(dev, tp)); |
558} 559 560int 561scclose(dev_t dev, int flag, int mode, struct proc *p) 562{ | 342} 343 344int 345scclose(dev_t dev, int flag, int mode, struct proc *p) 346{ |
563 struct tty *tp = get_tty_ptr(dev); 564 struct scr_stat *scp; | 347 struct tty *tp = get_tty_ptr(dev); 348 struct scr_stat *scp; |
565 | 349 |
566 if (!tp) 567 return(ENXIO); 568 if (minor(dev) < MAXCONS) { 569 scp = get_scr_stat(tp->t_dev); 570 if (scp->status & SWITCH_WAIT_ACQ) 571 wakeup((caddr_t)&scp->smode); | 350 if (!tp) 351 return(ENXIO); 352 if (minor(dev) < MAXCONS) { 353 scp = get_scr_stat(tp->t_dev); 354 if (scp->status & SWITCH_WAIT_ACQ) 355 wakeup((caddr_t)&scp->smode); |
572#if not_yet_done | 356#if not_yet_done |
573 if (scp == &main_console) { 574 scp->pid = 0; 575 scp->proc = NULL; 576 scp->smode.mode = VT_AUTO; 577 } 578 else { 579 free(scp->scr_buf, M_DEVBUF); 580 free(scp->history, M_DEVBUF); 581 free(scp, M_DEVBUF); 582 console[minor(dev)] = NULL; 583 } | 357 if (scp == &main_console) { 358 scp->pid = 0; 359 scp->proc = NULL; 360 scp->smode.mode = VT_AUTO; 361 } 362 else { 363 free(scp->scr_buf, M_DEVBUF); 364 free(scp->history, M_DEVBUF); 365 free(scp, M_DEVBUF); 366 console[minor(dev)] = NULL; 367 } |
584#else | 368#else |
585 scp->pid = 0; 586 scp->proc = NULL; 587 scp->smode.mode = VT_AUTO; | 369 scp->pid = 0; 370 scp->proc = NULL; 371 scp->smode.mode = VT_AUTO; |
588#endif | 372#endif |
589 } 590 (*linesw[tp->t_line].l_close)(tp, flag); 591 ttyclose(tp); 592 return(0); | 373 } 374 (*linesw[tp->t_line].l_close)(tp, flag); 375 ttyclose(tp); 376 return(0); |
593} 594 595int 596scread(dev_t dev, struct uio *uio, int flag) 597{ | 377} 378 379int 380scread(dev_t dev, struct uio *uio, int flag) 381{ |
598 struct tty *tp = get_tty_ptr(dev); | 382 struct tty *tp = get_tty_ptr(dev); |
599 | 383 |
600 if (!tp) 601 return(ENXIO); 602 return((*linesw[tp->t_line].l_read)(tp, uio, flag)); | 384 if (!tp) 385 return(ENXIO); 386 return((*linesw[tp->t_line].l_read)(tp, uio, flag)); |
603} 604 605int 606scwrite(dev_t dev, struct uio *uio, int flag) 607{ | 387} 388 389int 390scwrite(dev_t dev, struct uio *uio, int flag) 391{ |
608 struct tty *tp = get_tty_ptr(dev); | 392 struct tty *tp = get_tty_ptr(dev); |
609 | 393 |
610 if (!tp) 611 return(ENXIO); 612 return((*linesw[tp->t_line].l_write)(tp, uio, flag)); | 394 if (!tp) 395 return(ENXIO); 396 return((*linesw[tp->t_line].l_write)(tp, uio, flag)); |
613} 614 615void 616scintr(int unit) 617{ | 397} 398 399void 400scintr(int unit) 401{ |
618 static struct tty *cur_tty; 619 int c, len; 620 u_char *cp; | 402 static struct tty *cur_tty; 403 int c, len; 404 u_char *cp; |
621 | 405 |
622 /* make screensaver happy */ 623 scrn_time_stamp = time.tv_sec; 624 if (scrn_blanked) { 625 SCRN_SAVER(FALSE); 626 cur_console->status |= UPDATE_SCREEN; 627 } | 406 /* make screensaver happy */ 407 scrn_time_stamp = time.tv_sec; 408 if (scrn_blanked) { 409 (*current_saver)(FALSE); 410 cur_console->status |= UPDATE_SCREEN; 411 } |
628 | 412 |
629 c = scgetc(1); | 413 c = scgetc(1); |
630 | 414 |
631 cur_tty = VIRTUAL_TTY(get_scr_num()); 632 if (!(cur_tty->t_state & TS_ISOPEN)) 633 if (!((cur_tty = CONSOLE_TTY)->t_state & TS_ISOPEN)) 634 return; | 415 cur_tty = VIRTUAL_TTY(get_scr_num()); 416 if (!(cur_tty->t_state & TS_ISOPEN)) 417 if (!((cur_tty = CONSOLE_TTY)->t_state & TS_ISOPEN)) 418 return; |
635 | 419 |
636 switch (c & 0xff00) { 637 case 0x0000: /* normal key */ 638 (*linesw[cur_tty->t_line].l_rint)(c & 0xFF, cur_tty); 639 break; 640 case NOKEY: /* nothing there */ 641 break; 642 case FKEY: /* function key, return string */ 643 if (cp = get_fstr((u_int)c, (u_int *)&len)) { 644 while (len-- > 0) 645 (*linesw[cur_tty->t_line].l_rint) 646 (*cp++ & 0xFF, cur_tty); 647 } 648 break; 649 case MKEY: /* meta is active, prepend ESC */ 650 (*linesw[cur_tty->t_line].l_rint)(0x1b, cur_tty); 651 (*linesw[cur_tty->t_line].l_rint)(c & 0xFF, cur_tty); 652 break; 653 case BKEY: /* backtab fixed sequence (esc [ Z) */ 654 (*linesw[cur_tty->t_line].l_rint)(0x1b, cur_tty); 655 (*linesw[cur_tty->t_line].l_rint)('[', cur_tty); 656 (*linesw[cur_tty->t_line].l_rint)('Z', cur_tty); 657 break; 658 } | 420 switch (c & 0xff00) { 421 case 0x0000: /* normal key */ 422 (*linesw[cur_tty->t_line].l_rint)(c & 0xFF, cur_tty); 423 break; 424 case NOKEY: /* nothing there */ 425 break; 426 case FKEY: /* function key, return string */ 427 if (cp = get_fstr((u_int)c, (u_int *)&len)) { 428 while (len-- > 0) 429 (*linesw[cur_tty->t_line].l_rint)(*cp++ & 0xFF, cur_tty); 430 } 431 break; 432 case MKEY: /* meta is active, prepend ESC */ 433 (*linesw[cur_tty->t_line].l_rint)(0x1b, cur_tty); 434 (*linesw[cur_tty->t_line].l_rint)(c & 0xFF, cur_tty); 435 break; 436 case BKEY: /* backtab fixed sequence (esc [ Z) */ 437 (*linesw[cur_tty->t_line].l_rint)(0x1b, cur_tty); 438 (*linesw[cur_tty->t_line].l_rint)('[', cur_tty); 439 (*linesw[cur_tty->t_line].l_rint)('Z', cur_tty); 440 break; 441 } |
659} 660 661int 662scparam(struct tty *tp, struct termios *t) 663{ | 442} 443 444int 445scparam(struct tty *tp, struct termios *t) 446{ |
664 int cflag = t->c_cflag; 665 666 /* and copy to tty */ 667 tp->t_ispeed = t->c_ispeed; 668 tp->t_ospeed = t->c_ospeed; 669 tp->t_cflag = cflag; 670 return 0; | 447 tp->t_ispeed = t->c_ispeed; 448 tp->t_ospeed = t->c_ospeed; 449 tp->t_cflag = t->c_cflag; 450 return 0; |
671} 672 673int 674scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) 675{ | 451} 452 453int 454scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) 455{ |
676 int i, error; 677 struct tty *tp; 678 struct trapframe *fp; 679 scr_stat *scp; | 456 int i, error; 457 struct tty *tp; 458 struct trapframe *fp; 459 scr_stat *scp; |
680 | 460 |
681 tp = get_tty_ptr(dev); 682 if (!tp) 683 return ENXIO; 684 scp = get_scr_stat(tp->t_dev); | 461 tp = get_tty_ptr(dev); 462 if (!tp) 463 return ENXIO; 464 scp = get_scr_stat(tp->t_dev); |
685 | 465 |
686 switch (cmd) { /* process console hardware related ioctl's */ | 466 switch (cmd) { /* process console hardware related ioctl's */ |
687 | 467 |
688 case GIO_ATTR: /* get current attributes */ 689 *(int*)data = scp->term.cur_attr; 690 return 0; | 468 case GIO_ATTR: /* get current attributes */ 469 *(int*)data = scp->term.cur_attr; 470 return 0; |
691 | 471 |
692 case GIO_COLOR: /* is this a color console ? */ 693 if (crtc_addr == COLOR_BASE) 694 *(int*)data = 1; 695 else 696 *(int*)data = 0; 697 return 0; 698 699 case CONS_CURRENT: /* get current adapter type */ 700 if (crtc_vga) 701 *(int*)data = KD_VGA; 702 else 703 if (crtc_addr == MONO_BASE) 704 *(int*)data = KD_MONO; 705 else 706 *(int*)data = KD_CGA; 707 return 0; | 472 case GIO_COLOR: /* is this a color console ? */ 473 if (crtc_addr == COLOR_BASE) 474 *(int*)data = 1; 475 else 476 *(int*)data = 0; 477 return 0; 478 479 case CONS_CURRENT: /* get current adapter type */ 480 if (crtc_vga) 481 *(int*)data = KD_VGA; 482 else 483 if (crtc_addr == MONO_BASE) 484 *(int*)data = KD_MONO; 485 else 486 *(int*)data = KD_CGA; 487 return 0; |
708 | 488 |
709 case CONS_GET: /* get current video mode */ 710 *(int*)data = scp->mode; 711 return 0; | 489 case CONS_GET: /* get current video mode */ 490 *(int*)data = scp->mode; 491 return 0; |
712 | 492 |
713 case CONS_BLANKTIME: /* set screen saver timeout (0 = no saver) */ 714 scrn_blank_time = *(int*)data; 715 return 0; | 493 case CONS_BLANKTIME: /* set screen saver timeout (0 = no saver) */ 494 scrn_blank_time = *(int*)data; 495 return 0; |
716 | 496 |
717#define SAVER(p) ((ssaver_t *)(p)) 718 case CONS_SSAVER: /* set screen saver */ 719 if (SAVER(data)->num < 0 720 || SAVER(data)->num >= NUM_SCRN_SAVERS) 721 return EIO; 722 if (scrn_blanked) { 723 SCRN_SAVER(FALSE); 724 cur_console->status |= UPDATE_SCREEN; 725 } 726 scrn_saver = SAVER(data)->num; 727 scrn_blank_time = SAVER(data)->time; 728 return 0; | 497 case CONS_CURSORTYPE: /* set cursor type blink/noblink */ 498 if ((*(int*)data) & 0x01) 499 configuration |= BLINK_CURSOR; 500 else 501 configuration &= ~BLINK_CURSOR; 502 if ((*(int*)data) & 0x02) 503 configuration |= CHAR_CURSOR; 504 else 505 configuration &= ~CHAR_CURSOR; 506 return 0; |
729 | 507 |
730 case CONS_GSAVER: /* get screen saver info */ 731 if (SAVER(data)->num < 0) 732 SAVER(data)->num = scrn_saver; 733 else if (SAVER(data)->num >= NUM_SCRN_SAVERS) 734 return EIO; 735 SAVER(data)->time = scrn_blank_time; 736 strcpy(SAVER(data)->name, screen_savers[SAVER(data)->num].name); 737 return 0; | 508 case CONS_BELLTYPE: /* set bell type sound/visual */ 509 if (*data) 510 configuration |= VISUAL_BELL; 511 else 512 configuration &= ~VISUAL_BELL; 513 return 0; |
738 | 514 |
739 case CONS_CURSORTYPE: /* set cursor type blink/noblink */ 740 if ((*(int*)data) & 0x01) 741 configuration |= BLINK_CURSOR; 742 else 743 configuration &= ~BLINK_CURSOR; 744 if ((*(int*)data) & 0x02) 745 configuration |= CHAR_CURSOR; 746 else 747 configuration &= ~CHAR_CURSOR; 748 return 0; | 515 case CONS_HISTORY: /* set history size */ 516 if (*data) { 517 free(scp->history, M_DEVBUF); 518 scp->history_size = *(int*)data; 519 if (scp->history_size < scp->ysize) 520 scp->history = NULL; 521 else { 522 scp->history_size *= scp->xsize; 523 scp->history_head = scp->history_pos = scp->history = 524 (u_short *)malloc(scp->history_size*sizeof(u_short), 525 M_DEVBUF, M_NOWAIT); 526 bzero(scp->history_head, scp->history_size*sizeof(u_short)); 527 } 528 return 0; 529 } 530 else 531 return EINVAL; |
749 | 532 |
750 case CONS_BELLTYPE: /* set bell type sound/visual */ 751 if (*data) 752 configuration |= VISUAL_BELL; 753 else 754 configuration &= ~VISUAL_BELL; 755 return 0; | 533 case CONS_MOUSECTL: /* control mouse arrow */ 534 { 535 mouse_info_t *mouse = (mouse_info_t*)data; 536 int fontsize; |
756 | 537 |
757 case CONS_HISTORY: /* set history size */ 758 if (*data) { 759 free(scp->history, M_DEVBUF); 760 scp->history_size = *(int*)data; 761 if (scp->history_size < scp->ysize) 762 scp->history = NULL; 763 else { 764 scp->history_size *= scp->xsize; 765 scp->history_head = scp->history_pos = scp->history = 766 (u_short *)malloc(scp->history_size*sizeof(u_short), 767 M_DEVBUF, M_NOWAIT); 768 bzero(scp->history_head, 769 scp->history_size*sizeof(u_short)); 770 } 771 return 0; 772 } 773 else 774 return EINVAL; | 538 switch (scp->font) { 539 default: 540 case FONT_8: 541 fontsize = 8; break; 542 case FONT_14: 543 fontsize = 14; break; 544 case FONT_16: 545 fontsize = 16; break; 546 } 547 switch (mouse->operation) { 548 case MOUSE_SHOW: 549 if (!(scp->status & MOUSE_ENABLED)) { 550 scp->mouse_oldpos = Crtat + (scp->mouse_pos - scp->scr_buf); 551 scp->status |= (UPDATE_MOUSE | MOUSE_ENABLED); 552 } 553 else 554 return EINVAL; 555 break; |
775 | 556 |
776 case CONS_MOUSECTL: 777 { 778 mouse_info_t *mouse = (mouse_info_t*)data; 779 int fontsize; | 557 case MOUSE_HIDE: 558 if (scp->status & MOUSE_ENABLED) { 559 scp->status &= ~MOUSE_ENABLED; 560 scp->status |= UPDATE_MOUSE; 561 } 562 else 563 return EINVAL; 564 break; |
780 | 565 |
781 switch (scp->font) { 782 default: 783 case FONT_8: 784 fontsize = 8; break; 785 case FONT_14: 786 fontsize = 14; break; 787 case FONT_16: 788 fontsize = 16; break; 789 } 790 switch (mouse->operation) { 791 case MOUSE_SHOW: 792 if (!(scp->status & MOUSE_ENABLED)) { 793 scp->mouse_oldpos = 794 Crtat + (scp->mouse_pos - scp->scr_buf); 795 scp->status |= (UPDATE_MOUSE | MOUSE_ENABLED); 796 } 797 else 798 return EINVAL; 799 break; | 566 case MOUSE_MOVEABS: 567 scp->mouse_xpos = mouse->x; 568 scp->mouse_ypos = mouse->y; 569 goto set_mouse_pos; |
800 | 570 |
801 case MOUSE_HIDE: 802 if (scp->status & MOUSE_ENABLED) { 803 scp->status &= ~MOUSE_ENABLED; 804 scp->status |= UPDATE_MOUSE; 805 } 806 else 807 return EINVAL; 808 break; 809 810 case MOUSE_MOVEABS: 811 scp->mouse_xpos = mouse->x; 812 scp->mouse_ypos = mouse->y; 813 goto set_mouse_pos; 814 815 case MOUSE_MOVEREL: 816 scp->mouse_xpos += mouse->x; 817 scp->mouse_ypos += mouse->y; | 571 case MOUSE_MOVEREL: 572 scp->mouse_xpos += mouse->x; 573 scp->mouse_ypos += mouse->y; |
818set_mouse_pos: | 574set_mouse_pos: |
819 if (scp->mouse_xpos < 0) 820 scp->mouse_xpos = 0; 821 if (scp->mouse_ypos < 0) 822 scp->mouse_ypos = 0; 823 if (scp->mouse_xpos >= scp->xsize*8) 824 scp->mouse_xpos = (scp->xsize*8)-1; 825 if (scp->mouse_ypos >= scp->ysize*fontsize) 826 scp->mouse_ypos = (scp->ysize*fontsize)-1; 827 scp->mouse_pos = scp->scr_buf + 828 (scp->mouse_ypos/fontsize)*scp->xsize + 829 scp->mouse_xpos/8; 830 if (scp->status & MOUSE_ENABLED) 831 scp->status |= UPDATE_MOUSE; 832 break; | 575 if (scp->mouse_xpos < 0) 576 scp->mouse_xpos = 0; 577 if (scp->mouse_ypos < 0) 578 scp->mouse_ypos = 0; 579 if (scp->mouse_xpos >= scp->xsize*8) 580 scp->mouse_xpos = (scp->xsize*8)-1; 581 if (scp->mouse_ypos >= scp->ysize*fontsize) 582 scp->mouse_ypos = (scp->ysize*fontsize)-1; 583 scp->mouse_pos = scp->scr_buf + 584 (scp->mouse_ypos/fontsize)*scp->xsize + scp->mouse_xpos/8; 585 if (scp->status & MOUSE_ENABLED) 586 scp->status |= UPDATE_MOUSE; 587 break; |
833 | 588 |
834 case MOUSE_GETPOS: 835 mouse->x = scp->mouse_xpos; 836 mouse->y = scp->mouse_ypos; 837 return 0; | 589 case MOUSE_GETPOS: 590 mouse->x = scp->mouse_xpos; 591 mouse->y = scp->mouse_ypos; 592 return 0; |
838 | 593 |
839 default: 840 return EINVAL; 841 } 842 /* make screensaver happy */ 843 if (scp == cur_console) { 844 scrn_time_stamp = time.tv_sec; 845 if (scrn_blanked) { 846 SCRN_SAVER(FALSE); 847 scp->status |= UPDATE_SCREEN; 848 } 849 } 850 return 0; | 594 default: 595 return EINVAL; |
851 } | 596 } |
597 /* make screensaver happy */ 598 if (scp == cur_console) { 599 scrn_time_stamp = time.tv_sec; 600 if (scrn_blanked) { 601 (*current_saver)(FALSE); 602 scp->status |= UPDATE_SCREEN; 603 } 604 } 605 return 0; 606 } |
|
852 | 607 |
853 case CONS_GETINFO: /* get current (virtual) console info */ 854 { 855 vid_info_t *ptr = (vid_info_t*)data; 856 if (ptr->size == sizeof(struct vid_info)) { 857 ptr->m_num = get_scr_num(); 858 ptr->mv_col = scp->xpos; 859 ptr->mv_row = scp->ypos; 860 ptr->mv_csz = scp->xsize; 861 ptr->mv_rsz = scp->ysize; 862 ptr->mv_norm.fore = (scp->term.std_attr & 0x0f00)>>8; 863 ptr->mv_norm.back = (scp->term.std_attr & 0xf000)>>12; 864 ptr->mv_rev.fore = (scp->term.rev_attr & 0x0f00)>>8; 865 ptr->mv_rev.back = (scp->term.rev_attr & 0xf000)>>12; 866 ptr->mv_grfc.fore = 0; /* not supported */ 867 ptr->mv_grfc.back = 0; /* not supported */ 868 ptr->mv_ovscan = scp->border; 869 ptr->mk_keylock = scp->status & LOCK_KEY_MASK; 870 return 0; 871 } 872 return EINVAL; | 608 case CONS_GETINFO: /* get current (virtual) console info */ 609 { 610 vid_info_t *ptr = (vid_info_t*)data; 611 if (ptr->size == sizeof(struct vid_info)) { 612 ptr->m_num = get_scr_num(); 613 ptr->mv_col = scp->xpos; 614 ptr->mv_row = scp->ypos; 615 ptr->mv_csz = scp->xsize; 616 ptr->mv_rsz = scp->ysize; 617 ptr->mv_norm.fore = (scp->term.std_attr & 0x0f00)>>8; 618 ptr->mv_norm.back = (scp->term.std_attr & 0xf000)>>12; 619 ptr->mv_rev.fore = (scp->term.rev_attr & 0x0f00)>>8; 620 ptr->mv_rev.back = (scp->term.rev_attr & 0xf000)>>12; 621 ptr->mv_grfc.fore = 0; /* not supported */ 622 ptr->mv_grfc.back = 0; /* not supported */ 623 ptr->mv_ovscan = scp->border; 624 ptr->mk_keylock = scp->status & LOCK_KEY_MASK; 625 return 0; |
873 } | 626 } |
627 return EINVAL; 628 } |
|
874 | 629 |
875 case CONS_GETVERS: /* get version number */ 876 *(int*)data = 0x200; /* version 2.0 */ 877 return 0; | 630 case CONS_GETVERS: /* get version number */ 631 *(int*)data = 0x200; /* version 2.0 */ 632 return 0; |
878 | 633 |
879 case SW_VGA_C40x25: case SW_VGA_C80x25: /* VGA TEXT MODES */ 880 case SW_VGA_M80x25: 881 case SW_VGA_C80x30: case SW_VGA_M80x30: 882 case SW_VGA_C80x50: case SW_VGA_M80x50: 883 case SW_VGA_C80x60: case SW_VGA_M80x60: 884 case SW_B40x25: case SW_C40x25: 885 case SW_B80x25: case SW_C80x25: 886 case SW_ENH_B40x25: case SW_ENH_C40x25: 887 case SW_ENH_B80x25: case SW_ENH_C80x25: 888 case SW_ENH_B80x43: case SW_ENH_C80x43: | 634 /* VGA TEXT MODES */ 635 case SW_VGA_C40x25: 636 case SW_VGA_C80x25: case SW_VGA_M80x25: 637 case SW_VGA_C80x30: case SW_VGA_M80x30: 638 case SW_VGA_C80x50: case SW_VGA_M80x50: 639 case SW_VGA_C80x60: case SW_VGA_M80x60: 640 case SW_B40x25: case SW_C40x25: 641 case SW_B80x25: case SW_C80x25: 642 case SW_ENH_B40x25: case SW_ENH_C40x25: 643 case SW_ENH_B80x25: case SW_ENH_C80x25: 644 case SW_ENH_B80x43: case SW_ENH_C80x43: |
889 | 645 |
890 if (!crtc_vga || video_mode_ptr == NULL) 891 return ENXIO; 892 switch (cmd & 0xff) { 893 case M_VGA_C80x60: case M_VGA_M80x60: 894 if (!(fonts_loaded & FONT_8)) 895 return EINVAL; 896 scp->xsize = 80; 897 scp->ysize = 60; 898 break; 899 case M_VGA_C80x50: case M_VGA_M80x50: 900 if (!(fonts_loaded & FONT_8)) 901 return EINVAL; 902 scp->xsize = 80; 903 scp->ysize = 50; 904 break; 905 case M_ENH_B80x43: case M_ENH_C80x43: 906 if (!(fonts_loaded & FONT_8)) 907 return EINVAL; 908 scp->xsize = 80; 909 scp->ysize = 43; 910 break; 911 case M_VGA_C80x30: case M_VGA_M80x30: 912 scp->xsize = 80; 913 scp->ysize = 30; 914 break; 915 default: 916 if ((cmd & 0xff) > M_VGA_CG320) 917 return EINVAL; 918 else 919 scp->xsize = *(video_mode_ptr+((cmd&0xff)*64)); 920 scp->ysize = *(video_mode_ptr+((cmd&0xff)*64)+1)+1; 921 break; 922 } 923 scp->mode = cmd & 0xff; 924 scp->status &= ~UNKNOWN_MODE; /* text mode */ 925 free(scp->scr_buf, M_DEVBUF); 926 scp->scr_buf = (u_short *)malloc(scp->xsize * scp->ysize * 927 sizeof(u_short), M_DEVBUF, M_NOWAIT); 928 if (scp == cur_console) 929 set_mode(scp); 930 clear_screen(scp); 931 if (tp->t_winsize.ws_col != scp->xsize 932 || tp->t_winsize.ws_row != scp->ysize) { 933 tp->t_winsize.ws_col = scp->xsize; 934 tp->t_winsize.ws_row = scp->ysize; 935 pgsignal(tp->t_pgrp, SIGWINCH, 1); 936 } 937 return 0; | 646 if (!crtc_vga || video_mode_ptr == NULL) 647 return ENXIO; 648 switch (cmd & 0xff) { 649 case M_VGA_C80x60: case M_VGA_M80x60: 650 if (!(fonts_loaded & FONT_8)) 651 return EINVAL; 652 scp->xsize = 80; 653 scp->ysize = 60; 654 break; 655 case M_VGA_C80x50: case M_VGA_M80x50: 656 if (!(fonts_loaded & FONT_8)) 657 return EINVAL; 658 scp->xsize = 80; 659 scp->ysize = 50; 660 break; 661 case M_ENH_B80x43: case M_ENH_C80x43: 662 if (!(fonts_loaded & FONT_8)) 663 return EINVAL; 664 scp->xsize = 80; 665 scp->ysize = 43; 666 break; 667 case M_VGA_C80x30: case M_VGA_M80x30: 668 scp->xsize = 80; 669 scp->ysize = 30; 670 break; 671 default: 672 if ((cmd & 0xff) > M_VGA_CG320) 673 return EINVAL; 674 else 675 scp->xsize = *(video_mode_ptr+((cmd&0xff)*64)); 676 scp->ysize = *(video_mode_ptr+((cmd&0xff)*64)+1)+1; 677 break; 678 } 679 scp->mode = cmd & 0xff; 680 scp->status &= ~UNKNOWN_MODE; /* text mode */ 681 free(scp->scr_buf, M_DEVBUF); 682 scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short), 683 M_DEVBUF, M_NOWAIT); 684 if (scp == cur_console) 685 set_mode(scp); 686 clear_screen(scp); 687 if (tp->t_winsize.ws_col != scp->xsize 688 || tp->t_winsize.ws_row != scp->ysize) { 689 tp->t_winsize.ws_col = scp->xsize; 690 tp->t_winsize.ws_row = scp->ysize; 691 pgsignal(tp->t_pgrp, SIGWINCH, 1); 692 } 693 return 0; |
938 | 694 |
939 /* GRAPHICS MODES */ 940 case SW_BG320: case SW_CG320: case SW_BG640: 941 case SW_CG320_D: case SW_CG640_E: 942 case SW_CG640x350: case SW_ENH_CG640: 943 case SW_BG640x480: case SW_CG640x480: case SW_VGA_CG320: | 695 /* GRAPHICS MODES */ 696 case SW_BG320: case SW_BG640: 697 case SW_CG320: case SW_CG320_D: case SW_CG640_E: 698 case SW_CG640x350: case SW_ENH_CG640: 699 case SW_BG640x480: case SW_CG640x480: case SW_VGA_CG320: |
944 | 700 |
945 if (!crtc_vga || video_mode_ptr == NULL) 946 return ENXIO; 947 scp->mode = cmd & 0xFF; 948 scp->status |= UNKNOWN_MODE; /* graphics mode */ 949 scp->xsize = (*(video_mode_ptr + (scp->mode*64))) * 8; 950 scp->ysize = (*(video_mode_ptr + (scp->mode*64) + 1) + 1) 951 * (*(video_mode_ptr + (scp->mode*64) + 2)); 952 set_mode(scp); 953 /* clear_graphics();*/ | 701 if (!crtc_vga || video_mode_ptr == NULL) 702 return ENXIO; 703 scp->mode = cmd & 0xFF; 704 scp->status |= UNKNOWN_MODE; /* graphics mode */ 705 scp->xsize = (*(video_mode_ptr + (scp->mode*64))) * 8; 706 scp->ysize = (*(video_mode_ptr + (scp->mode*64) + 1) + 1) * 707 (*(video_mode_ptr + (scp->mode*64) + 2)); 708 set_mode(scp); 709 /* clear_graphics();*/ |
954 | 710 |
955 if (tp->t_winsize.ws_xpixel != scp->xsize 956 || tp->t_winsize.ws_ypixel != scp->ysize) { 957 tp->t_winsize.ws_xpixel = scp->xsize; 958 tp->t_winsize.ws_ypixel = scp->ysize; 959 pgsignal(tp->t_pgrp, SIGWINCH, 1); 960 } | 711 if (tp->t_winsize.ws_xpixel != scp->xsize 712 || tp->t_winsize.ws_ypixel != scp->ysize) { 713 tp->t_winsize.ws_xpixel = scp->xsize; 714 tp->t_winsize.ws_ypixel = scp->ysize; 715 pgsignal(tp->t_pgrp, SIGWINCH, 1); 716 } 717 return 0; 718 719 case VT_SETMODE: /* set screen switcher mode */ 720 bcopy(data, &scp->smode, sizeof(struct vt_mode)); 721 if (scp->smode.mode == VT_PROCESS) { 722 scp->proc = p; 723 scp->pid = scp->proc->p_pid; 724 } 725 return 0; 726 727 case VT_GETMODE: /* get screen switcher mode */ 728 bcopy(&scp->smode, data, sizeof(struct vt_mode)); 729 return 0; 730 731 case VT_RELDISP: /* screen switcher ioctl */ 732 switch(*data) { 733 case VT_FALSE: /* user refuses to release screen, abort */ 734 if (scp == old_scp && (scp->status & SWITCH_WAIT_REL)) { 735 old_scp->status &= ~SWITCH_WAIT_REL; 736 switch_in_progress = FALSE; |
961 return 0; | 737 return 0; |
738 } 739 return EINVAL; |
|
962 | 740 |
963 case VT_SETMODE: /* set screen switcher mode */ 964 bcopy(data, &scp->smode, sizeof(struct vt_mode)); 965 if (scp->smode.mode == VT_PROCESS) { 966 scp->proc = p; 967 scp->pid = scp->proc->p_pid; | 741 case VT_TRUE: /* user has released screen, go on */ 742 if (scp == old_scp && (scp->status & SWITCH_WAIT_REL)) { 743 scp->status &= ~SWITCH_WAIT_REL; 744 exchange_scr(); 745 if (new_scp->smode.mode == VT_PROCESS) { 746 new_scp->status |= SWITCH_WAIT_ACQ; 747 psignal(new_scp->proc, new_scp->smode.acqsig); |
968 } | 748 } |
749 else 750 switch_in_progress = FALSE; |
|
969 return 0; | 751 return 0; |
970 971 case VT_GETMODE: /* get screen switcher mode */ 972 bcopy(&scp->smode, data, sizeof(struct vt_mode)); | 752 } 753 return EINVAL; 754 755 case VT_ACKACQ: /* acquire acknowledged, switch completed */ 756 if (scp == new_scp && (scp->status & SWITCH_WAIT_ACQ)) { 757 scp->status &= ~SWITCH_WAIT_ACQ; 758 switch_in_progress = FALSE; |
973 return 0; | 759 return 0; |
974 975 case VT_RELDISP: /* screen switcher ioctl */ 976 switch(*data) { 977 case VT_FALSE: /* user refuses to release screen, abort */ 978 if (scp == old_scp && (scp->status & SWITCH_WAIT_REL)) { 979 old_scp->status &= ~SWITCH_WAIT_REL; 980 switch_in_progress = FALSE; 981 return 0; 982 } 983 return EINVAL; | 760 } 761 return EINVAL; |
984 | 762 |
985 case VT_TRUE: /* user has released screen, go on */ 986 if (scp == old_scp && (scp->status & SWITCH_WAIT_REL)) { 987 scp->status &= ~SWITCH_WAIT_REL; 988 exchange_scr(); 989 if (new_scp->smode.mode == VT_PROCESS) { 990 new_scp->status |= SWITCH_WAIT_ACQ; 991 psignal(new_scp->proc, 992 new_scp->smode.acqsig); 993 } 994 else 995 switch_in_progress = FALSE; 996 return 0; 997 } 998 return EINVAL; | 763 default: 764 return EINVAL; 765 } 766 /* NOT REACHED */ |
999 | 767 |
1000 case VT_ACKACQ: /* acquire acknowledged, switch completed */ 1001 if (scp == new_scp && (scp->status & SWITCH_WAIT_ACQ)) { 1002 scp->status &= ~SWITCH_WAIT_ACQ; 1003 switch_in_progress = FALSE; 1004 return 0; 1005 } 1006 return EINVAL; | 768 case VT_OPENQRY: /* return free virtual console */ 769 for (i = 0; i < MAXCONS; i++) { 770 tp = VIRTUAL_TTY(i); 771 if (!(tp->t_state & TS_ISOPEN)) { 772 *data = i + 1; 773 return 0; 774 } 775 } 776 return EINVAL; |
1007 | 777 |
1008 default: 1009 return EINVAL; 1010 } 1011 /* NOT REACHED */ | 778 case VT_ACTIVATE: /* switch to screen *data */ 779 return switch_scr(scp, (*data) - 1); |
1012 | 780 |
1013 case VT_OPENQRY: /* return free virtual console */ 1014 for (i = 0; i < MAXCONS; i++) { 1015 tp = VIRTUAL_TTY(i); 1016 if (!(tp->t_state & TS_ISOPEN)) { 1017 *data = i + 1; 1018 return 0; 1019 } 1020 } 1021 return EINVAL; | 781 case VT_WAITACTIVE: /* wait for switch to occur */ 782 if (*data > MAXCONS || *data < 0) 783 return EINVAL; 784 if (minor(dev) == (*data) - 1) 785 return 0; 786 if (*data == 0) { 787 if (scp == cur_console) 788 return 0; 789 } 790 else 791 scp = console[(*data) - 1]; 792 while ((error=tsleep((caddr_t)&scp->smode, PZERO|PCATCH, 793 "waitvt", 0)) == ERESTART) ; 794 return error; |
1022 | 795 |
1023 case VT_ACTIVATE: /* switch to screen *data */ 1024 return switch_scr(scp, (*data) - 1); | 796 case VT_GETACTIVE: 797 *data = get_scr_num()+1; 798 return 0; |
1025 | 799 |
1026 case VT_WAITACTIVE: /* wait for switch to occur */ 1027 if (*data > MAXCONS || *data < 0) 1028 return EINVAL; 1029 if (minor(dev) == (*data) - 1) 1030 return 0; 1031 if (*data == 0) { 1032 if (scp == cur_console) 1033 return 0; 1034 } 1035 else 1036 scp = console[(*data) - 1]; 1037 while ((error=tsleep((caddr_t)&scp->smode, PZERO|PCATCH, 1038 "waitvt", 0)) == ERESTART) ; 1039 return error; | 800 case KDENABIO: /* allow io operations */ 801 fp = (struct trapframe *)p->p_md.md_regs; 802 fp->tf_eflags |= PSL_IOPL; 803 return 0; |
1040 | 804 |
1041 case VT_GETACTIVE: 1042 *data = get_scr_num()+1; 1043 return 0; | 805 case KDDISABIO: /* disallow io operations (default) */ 806 fp = (struct trapframe *)p->p_md.md_regs; 807 fp->tf_eflags &= ~PSL_IOPL; 808 return 0; |
1044 | 809 |
1045 case KDENABIO: /* allow io operations */ 1046 fp = (struct trapframe *)p->p_md.md_regs; 1047 fp->tf_eflags |= PSL_IOPL; 1048 return 0; | 810 case KDSETMODE: /* set current mode of this (virtual) console */ 811 switch (*data) { 812 case KD_TEXT: /* switch to TEXT (known) mode */ 813 /* restore fonts & palette ! */ 814 if (crtc_vga) { 815 if (fonts_loaded & FONT_8) 816 copy_font(LOAD, FONT_8, font_8); 817 if (fonts_loaded & FONT_14) 818 copy_font(LOAD, FONT_14, font_14); 819 if (fonts_loaded & FONT_16) 820 copy_font(LOAD, FONT_16, font_16); 821 load_palette(); 822 } 823 /* FALL THROUGH */ |
1049 | 824 |
1050 case KDDISABIO: /* disallow io operations (default) */ 1051 fp = (struct trapframe *)p->p_md.md_regs; 1052 fp->tf_eflags &= ~PSL_IOPL; 1053 return 0; | 825 case KD_TEXT1: /* switch to TEXT (known) mode */ 826 /* no restore fonts & palette */ 827 scp->status &= ~UNKNOWN_MODE; 828 if (crtc_vga && video_mode_ptr) 829 set_mode(scp); 830 clear_screen(scp); 831 return 0; |
1054 | 832 |
1055 case KDSETMODE: /* set current mode of this (virtual) console */ 1056 switch (*data) { 1057 case KD_TEXT: /* switch to TEXT (known) mode */ 1058 /* restore fonts & palette ! */ 1059 if (crtc_vga) { 1060 if (fonts_loaded & FONT_8) 1061 copy_font(LOAD, FONT_8, font_8); 1062 if (fonts_loaded & FONT_14) 1063 copy_font(LOAD, FONT_14, font_14); 1064 if (fonts_loaded & FONT_16) 1065 copy_font(LOAD, FONT_16, font_16); 1066 load_palette(); 1067 } 1068 /* FALL THROUGH */ | 833 case KD_GRAPHICS: /* switch to GRAPHICS (unknown) mode */ 834 scp->status |= UNKNOWN_MODE; 835 return 0; 836 default: 837 return EINVAL; 838 } 839 /* NOT REACHED */ |
1069 | 840 |
1070 case KD_TEXT1: /* switch to TEXT (known) mode */ 1071 /* no restore fonts & palette */ 1072 scp->status &= ~UNKNOWN_MODE; 1073 if (crtc_vga && video_mode_ptr) 1074 set_mode(scp); 1075 clear_screen(scp); 1076 return 0; | 841 case KDGETMODE: /* get current mode of this (virtual) console */ 842 *data = (scp->status & UNKNOWN_MODE) ? KD_GRAPHICS : KD_TEXT; 843 return 0; |
1077 | 844 |
1078 case KD_GRAPHICS:/* switch to GRAPHICS (unknown) mode */ 1079 scp->status |= UNKNOWN_MODE; 1080 return 0; 1081 default: 1082 return EINVAL; 1083 } 1084 /* NOT REACHED */ | 845 case KDSBORDER: /* set border color of this (virtual) console */ 846 if (!crtc_vga) 847 return ENXIO; 848 scp->border = *data; 849 if (scp == cur_console) 850 set_border(scp->border); 851 return 0; |
1085 | 852 |
1086 case KDGETMODE: /* get current mode of this (virtual) console */ 1087 *data = (scp->status & UNKNOWN_MODE) ? KD_GRAPHICS : KD_TEXT; 1088 return 0; | 853 case KDSKBSTATE: /* set keyboard state (locks) */ 854 if (*data >= 0 && *data <= LOCK_KEY_MASK) { 855 scp->status &= ~LOCK_KEY_MASK; 856 scp->status |= *data; 857 if (scp == cur_console) 858 update_leds(scp->status); 859 return 0; 860 } 861 return EINVAL; |
1089 | 862 |
1090 case KDSBORDER: /* set border color of this (virtual) console */ 1091 if (!crtc_vga) 1092 return ENXIO; 1093 scp->border = *data; 1094 if (scp == cur_console) 1095 set_border(scp->border); 1096 return 0; | 863 case KDGKBSTATE: /* get keyboard state (locks) */ 864 *data = scp->status & LOCK_KEY_MASK; 865 return 0; |
1097 | 866 |
1098 case KDSKBSTATE: /* set keyboard state (locks) */ 1099 if (*data >= 0 && *data <= LOCK_KEY_MASK) { 1100 scp->status &= ~LOCK_KEY_MASK; 1101 scp->status |= *data; 1102 if (scp == cur_console) 1103 update_leds(scp->status); 1104 return 0; 1105 } 1106 return EINVAL; | 867 case KDSETRAD: /* set keyboard repeat & delay rates */ 868 if (*data & 0x80) 869 return EINVAL; 870 i = spltty(); 871 kbd_cmd(KB_SETRAD); 872 kbd_cmd(*data); 873 splx(i); 874 return 0; |
1107 | 875 |
1108 case KDGKBSTATE: /* get keyboard state (locks) */ 1109 *data = scp->status & LOCK_KEY_MASK; 1110 return 0; | 876 case KDSKBMODE: /* set keyboard mode */ 877 switch (*data) { 878 case K_RAW: /* switch to RAW scancode mode */ 879 scp->status |= KBD_RAW_MODE; 880 return 0; |
1111 | 881 |
1112 case KDSETRAD: /* set keyboard repeat & delay rates */ 1113 if (*data & 0x80) 1114 return EINVAL; 1115 i = spltty(); 1116 kbd_cmd(KB_SETRAD); 1117 kbd_cmd(*data); 1118 splx(i); 1119 return 0; | 882 case K_XLATE: /* switch to XLT ascii mode */ 883 if (scp == cur_console && scp->status == KBD_RAW_MODE) 884 shfts = ctls = alts = agrs = metas = 0; 885 scp->status &= ~KBD_RAW_MODE; 886 return 0; 887 default: 888 return EINVAL; 889 } 890 /* NOT REACHED */ |
1120 | 891 |
1121 case KDSKBMODE: /* set keyboard mode */ 1122 switch (*data) { 1123 case K_RAW: /* switch to RAW scancode mode */ 1124 scp->status |= KBD_RAW_MODE; 1125 return 0; | 892 case KDGKBMODE: /* get keyboard mode */ 893 *data = (scp->status & KBD_RAW_MODE) ? K_RAW : K_XLATE; 894 return 0; |
1126 | 895 |
1127 case K_XLATE: /* switch to XLT ascii mode */ 1128 if (scp == cur_console && scp->status == KBD_RAW_MODE) 1129 shfts = ctls = alts = agrs = metas = 0; 1130 scp->status &= ~KBD_RAW_MODE; 1131 return 0; 1132 default: 1133 return EINVAL; 1134 } 1135 /* NOT REACHED */ | 896 case KDMKTONE: /* sound the bell */ 897 if (*(int*)data) 898 do_bell(scp, (*(int*)data)&0xffff, 899 (((*(int*)data)>>16)&0xffff)*hz/1000); 900 else 901 do_bell(scp, scp->bell_pitch, scp->bell_duration); 902 return 0; |
1136 | 903 |
1137 case KDGKBMODE: /* get keyboard mode */ 1138 *data = (scp->status & KBD_RAW_MODE) ? K_RAW : K_XLATE; 1139 return 0; | 904 case KIOCSOUND: /* make tone (*data) hz */ 905 if (scp == cur_console) { 906 if (*(int*)data) { 907 int pitch = TIMER_FREQ/(*(int*)data); |
1140 | 908 |
1141 case KDMKTONE: /* sound the bell */ 1142 if (*(int*)data) { 1143 do_bell(scp, (*(int*)data)&0xffff, 1144 (((*(int*)data)>>16)&0xffff)*hz/1000); 1145 } 1146 else 1147 do_bell(scp, scp->bell_pitch, scp->bell_duration); 1148 return 0; | 909 /* set command for counter 2, 2 byte write */ 910 if (acquire_timer2(TIMER_16BIT|TIMER_SQWAVE)) 911 return EBUSY; |
1149 | 912 |
1150 case KIOCSOUND: /* make tone (*data) hz */ 1151 if (scp == cur_console) { 1152 if (*(int*)data) { 1153 int pitch = TIMER_FREQ/(*(int*)data); 1154 /* set command for counter 2, 2 byte write */ 1155 if (acquire_timer2(TIMER_16BIT|TIMER_SQWAVE)) { 1156 return EBUSY; 1157 } 1158 /* set pitch */ 1159 outb(TIMER_CNTR2, pitch); 1160 outb(TIMER_CNTR2, (pitch>>8)); 1161 /* enable counter 2 output to speaker */ 1162 outb(IO_PPI, inb(IO_PPI) | 3); 1163 } 1164 else { 1165 /* disable counter 2 output to speaker */ 1166 outb(IO_PPI, inb(IO_PPI) & 0xFC); 1167 release_timer2(); 1168 } 1169 } 1170 return 0; | 913 /* set pitch */ 914 outb(TIMER_CNTR2, pitch); 915 outb(TIMER_CNTR2, (pitch>>8)); |
1171 | 916 |
1172 case KDGKBTYPE: /* get keyboard type */ 1173 *data = 0; /* type not known (yet) */ 1174 return 0; | 917 /* enable counter 2 output to speaker */ 918 outb(IO_PPI, inb(IO_PPI) | 3); 919 } 920 else { 921 /* disable counter 2 output to speaker */ 922 outb(IO_PPI, inb(IO_PPI) & 0xFC); 923 release_timer2(); 924 } 925 } 926 return 0; |
1175 | 927 |
1176 case KDSETLED: /* set keyboard LED status */ 1177 if (*data >= 0 && *data <= LED_MASK) { 1178 scp->status &= ~LED_MASK; 1179 scp->status |= *data; 1180 if (scp == cur_console) 1181 update_leds(scp->status); 1182 return 0; 1183 } 1184 return EINVAL; | 928 case KDGKBTYPE: /* get keyboard type */ 929 *data = 0; /* type not known (yet) */ 930 return 0; |
1185 | 931 |
1186 case KDGETLED: /* get keyboard LED status */ 1187 *data = scp->status & LED_MASK; 1188 return 0; | 932 case KDSETLED: /* set keyboard LED status */ 933 if (*data >= 0 && *data <= LED_MASK) { 934 scp->status &= ~LED_MASK; 935 scp->status |= *data; 936 if (scp == cur_console) 937 update_leds(scp->status); 938 return 0; 939 } 940 return EINVAL; |
1189 | 941 |
1190 case GETFKEY: /* get functionkey string */ 1191 if (*(u_short*)data < n_fkey_tab) { 1192 fkeyarg_t *ptr = (fkeyarg_t*)data; 1193 bcopy(&fkey_tab[ptr->keynum].str, 1194 ptr->keydef, 1195 fkey_tab[ptr->keynum].len); 1196 ptr->flen = fkey_tab[ptr->keynum].len; 1197 return 0; 1198 } 1199 else 1200 return EINVAL; | 942 case KDGETLED: /* get keyboard LED status */ 943 *data = scp->status & LED_MASK; 944 return 0; |
1201 | 945 |
1202 case SETFKEY: /* set functionkey string */ 1203 if (*(u_short*)data < n_fkey_tab) { 1204 fkeyarg_t *ptr = (fkeyarg_t*)data; 1205 bcopy(ptr->keydef, 1206 &fkey_tab[ptr->keynum].str, 1207 min(ptr->flen, MAXFK)); 1208 fkey_tab[ptr->keynum].len = min(ptr->flen, MAXFK); 1209 return 0; 1210 } 1211 else 1212 return EINVAL; | 946 case GETFKEY: /* get functionkey string */ 947 if (*(u_short*)data < n_fkey_tab) { 948 fkeyarg_t *ptr = (fkeyarg_t*)data; 949 bcopy(&fkey_tab[ptr->keynum].str, ptr->keydef, 950 fkey_tab[ptr->keynum].len); 951 ptr->flen = fkey_tab[ptr->keynum].len; 952 return 0; 953 } 954 else 955 return EINVAL; |
1213 | 956 |
1214 case GIO_SCRNMAP: /* get output translation table */ 1215 bcopy(&scr_map, data, sizeof(scr_map)); 1216 return 0; | 957 case SETFKEY: /* set functionkey string */ 958 if (*(u_short*)data < n_fkey_tab) { 959 fkeyarg_t *ptr = (fkeyarg_t*)data; 960 bcopy(ptr->keydef, &fkey_tab[ptr->keynum].str, 961 min(ptr->flen, MAXFK)); 962 fkey_tab[ptr->keynum].len = min(ptr->flen, MAXFK); 963 return 0; 964 } 965 else 966 return EINVAL; |
1217 | 967 |
1218 case PIO_SCRNMAP: /* set output translation table */ 1219 bcopy(data, &scr_map, sizeof(scr_map)); 1220 return 0; | 968 case GIO_SCRNMAP: /* get output translation table */ 969 bcopy(&scr_map, data, sizeof(scr_map)); 970 return 0; |
1221 | 971 |
1222 case GIO_KEYMAP: /* get keyboard translation table */ 1223 bcopy(&key_map, data, sizeof(key_map)); 1224 return 0; | 972 case PIO_SCRNMAP: /* set output translation table */ 973 bcopy(data, &scr_map, sizeof(scr_map)); 974 return 0; |
1225 | 975 |
1226 case PIO_KEYMAP: /* set keyboard translation table */ 1227 bcopy(data, &key_map, sizeof(key_map)); 1228 return 0; | 976 case GIO_KEYMAP: /* get keyboard translation table */ 977 bcopy(&key_map, data, sizeof(key_map)); 978 return 0; |
1229 | 979 |
1230 case PIO_FONT8x8: /* set 8x8 dot font */ 1231 if (!crtc_vga) 1232 return ENXIO; 1233 bcopy(data, font_8, 8*256); 1234 fonts_loaded |= FONT_8; 1235 copy_font(LOAD, FONT_8, font_8); 1236 return 0; | 980 case PIO_KEYMAP: /* set keyboard translation table */ 981 bcopy(data, &key_map, sizeof(key_map)); 982 return 0; |
1237 | 983 |
1238 case GIO_FONT8x8: /* get 8x8 dot font */ 1239 if (!crtc_vga) 1240 return ENXIO; 1241 if (fonts_loaded & FONT_8) { 1242 bcopy(font_8, data, 8*256); 1243 return 0; 1244 } 1245 else 1246 return ENXIO; | 984 case PIO_FONT8x8: /* set 8x8 dot font */ 985 if (!crtc_vga) 986 return ENXIO; 987 bcopy(data, font_8, 8*256); 988 fonts_loaded |= FONT_8; 989 copy_font(LOAD, FONT_8, font_8); 990 return 0; |
1247 | 991 |
1248 case PIO_FONT8x14: /* set 8x14 dot font */ 1249 if (!crtc_vga) 1250 return ENXIO; 1251 bcopy(data, font_14, 14*256); 1252 fonts_loaded |= FONT_14; 1253 copy_font(LOAD, FONT_14, font_14); 1254 return 0; | 992 case GIO_FONT8x8: /* get 8x8 dot font */ 993 if (!crtc_vga) 994 return ENXIO; 995 if (fonts_loaded & FONT_8) { 996 bcopy(font_8, data, 8*256); 997 return 0; 998 } 999 else 1000 return ENXIO; |
1255 | 1001 |
1256 case GIO_FONT8x14: /* get 8x14 dot font */ 1257 if (!crtc_vga) 1258 return ENXIO; 1259 if (fonts_loaded & FONT_14) { 1260 bcopy(font_14, data, 14*256); 1261 return 0; 1262 } 1263 else 1264 return ENXIO; | 1002 case PIO_FONT8x14: /* set 8x14 dot font */ 1003 if (!crtc_vga) 1004 return ENXIO; 1005 bcopy(data, font_14, 14*256); 1006 fonts_loaded |= FONT_14; 1007 copy_font(LOAD, FONT_14, font_14); 1008 return 0; |
1265 | 1009 |
1266 case PIO_FONT8x16: /* set 8x16 dot font */ 1267 if (!crtc_vga) 1268 return ENXIO; 1269 bcopy(data, font_16, 16*256); 1270 fonts_loaded |= FONT_16; 1271 copy_font(LOAD, FONT_16, font_16); 1272 return 0; | 1010 case GIO_FONT8x14: /* get 8x14 dot font */ 1011 if (!crtc_vga) 1012 return ENXIO; 1013 if (fonts_loaded & FONT_14) { 1014 bcopy(font_14, data, 14*256); 1015 return 0; 1016 } 1017 else 1018 return ENXIO; |
1273 | 1019 |
1274 case GIO_FONT8x16: /* get 8x16 dot font */ 1275 if (!crtc_vga) 1276 return ENXIO; 1277 if (fonts_loaded & FONT_16) { 1278 bcopy(font_16, data, 16*256); 1279 return 0; 1280 } 1281 else 1282 return ENXIO; 1283 default: 1284 break; 1285 } 1286 1287 error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); 1288 if (error >= 0) 1289 return(error); 1290 error = ttioctl(tp, cmd, data, flag); 1291 if (error >= 0) 1292 return(error); 1293 return(ENOTTY); | 1020 case PIO_FONT8x16: /* set 8x16 dot font */ 1021 if (!crtc_vga) 1022 return ENXIO; 1023 bcopy(data, font_16, 16*256); 1024 fonts_loaded |= FONT_16; 1025 copy_font(LOAD, FONT_16, font_16); 1026 return 0; 1027 1028 case GIO_FONT8x16: /* get 8x16 dot font */ 1029 if (!crtc_vga) 1030 return ENXIO; 1031 if (fonts_loaded & FONT_16) { 1032 bcopy(font_16, data, 16*256); 1033 return 0; 1034 } 1035 else 1036 return ENXIO; 1037 default: 1038 break; 1039 } 1040 1041 error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); 1042 if (error >= 0) 1043 return(error); 1044 error = ttioctl(tp, cmd, data, flag); 1045 if (error >= 0) 1046 return(error); 1047 return(ENOTTY); |
1294} 1295 1296void 1297scxint(dev_t dev) 1298{ | 1048} 1049 1050void 1051scxint(dev_t dev) 1052{ |
1299 struct tty *tp = get_tty_ptr(dev); | 1053 struct tty *tp = get_tty_ptr(dev); |
1300 | 1054 |
1301 if (!tp) 1302 return; 1303 tp->t_state &= ~TS_BUSY; 1304 if (tp->t_line) 1305 (*linesw[tp->t_line].l_start)(tp); 1306 else 1307 scstart(tp); | 1055 if (!tp) 1056 return; 1057 tp->t_state &= ~TS_BUSY; 1058 if (tp->t_line) 1059 (*linesw[tp->t_line].l_start)(tp); 1060 else 1061 scstart(tp); |
1308} 1309 1310void 1311scstart(struct tty *tp) 1312{ | 1062} 1063 1064void 1065scstart(struct tty *tp) 1066{ |
1313 struct clist *rbp; 1314 int i, s, len; 1315 u_char buf[PCBURST]; 1316 scr_stat *scp = get_scr_stat(tp->t_dev); | 1067 struct clist *rbp; 1068 int i, s, len; 1069 u_char buf[PCBURST]; 1070 scr_stat *scp = get_scr_stat(tp->t_dev); |
1317 | 1071 |
1318 if (scp->status & SLKED || blink_in_progress) 1319 return; | 1072 if (scp->status & SLKED || blink_in_progress) 1073 return; 1074 s = spltty(); 1075 if (!(tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP))) { 1076 tp->t_state |= TS_BUSY; 1077 splx(s); 1078 rbp = &tp->t_outq; 1079 while (rbp->c_cc) { 1080 len = q_to_b(rbp, buf, PCBURST); 1081 ansi_put(scp, buf, len); 1082 } 1083 scp->status |= UPDATE_SCREEN; |
1320 s = spltty(); | 1084 s = spltty(); |
1321 if (!(tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP))) { 1322 tp->t_state |= TS_BUSY; 1323 splx(s); 1324 rbp = &tp->t_outq; 1325 /* scp->status &= ~CURSOR_ENABLED; */ 1326 while (rbp->c_cc) { 1327 len = q_to_b(rbp, buf, PCBURST); 1328 ansi_put(scp, buf, len); 1329 } 1330 /* scp->status |= (CURSOR_ENABLED | UPDATE_SCREEN); */ 1331 scp->status |= UPDATE_SCREEN; 1332 s = spltty(); 1333 tp->t_state &= ~TS_BUSY; 1334 if (rbp->c_cc <= tp->t_lowat) { 1335 if (tp->t_state & TS_ASLEEP) { 1336 tp->t_state &= ~TS_ASLEEP; 1337 wakeup((caddr_t)rbp); 1338 } 1339 selwakeup(&tp->t_wsel); 1340 } | 1085 tp->t_state &= ~TS_BUSY; 1086 if (rbp->c_cc <= tp->t_lowat) { 1087 if (tp->t_state & TS_ASLEEP) { 1088 tp->t_state &= ~TS_ASLEEP; 1089 wakeup((caddr_t)rbp); 1090 } 1091 selwakeup(&tp->t_wsel); |
1341 } | 1092 } |
1342 splx(s); | 1093 } 1094 splx(s); |
1343} 1344 | 1095} 1096 |
1097#if NAPM > 0 1098static int 1099scresume(void *dummy) 1100{ 1101 shfts = 0; 1102 ctls = 0; 1103 alts = 0; 1104 agrs = 0; 1105 metas = 0; 1106 return 0; 1107} 1108#endif 1109 |
|
1345void 1346pccnprobe(struct consdev *cp) 1347{ | 1110void 1111pccnprobe(struct consdev *cp) 1112{ |
1348 int maj; | 1113 int maj; |
1349 | 1114 |
1350 /* locate the major number */ 1351 for (maj = 0; maj < nchrdev; maj++) 1352 if ((void*)cdevsw[maj].d_open == (void*)scopen) 1353 break; | 1115 /* locate the major number */ 1116 for (maj = 0; maj < nchrdev; maj++) 1117 if ((void*)cdevsw[maj].d_open == (void*)scopen) 1118 break; |
1354 | 1119 |
1355 /* initialize required fields */ 1356 cp->cn_dev = makedev(maj, MAXCONS); 1357 cp->cn_pri = CN_INTERNAL; | 1120 /* initialize required fields */ 1121 cp->cn_dev = makedev(maj, MAXCONS); 1122 cp->cn_pri = CN_INTERNAL; |
1358} 1359 1360void 1361pccninit(struct consdev *cp) 1362{ | 1123} 1124 1125void 1126pccninit(struct consdev *cp) 1127{ |
1363 scinit(); | 1128 scinit(); |
1364} 1365 1366void 1367pccnputc(dev_t dev, char c) 1368{ | 1129} 1130 1131void 1132pccnputc(dev_t dev, char c) 1133{ |
1369 if (c == '\n') 1370 scput('\r'); 1371 scput(c); | 1134 scr_stat *scp = console[0]; 1135 term_stat save = scp->term; 1136 1137 scp->term = kernel_console; 1138 current_default = &kernel_default; 1139 if (scp->scr_buf == Crtat) 1140 draw_cursor(scp, FALSE); 1141 if (c == '\n') 1142 ansi_put(scp, "\r\n", 2); 1143 else 1144 ansi_put(scp, &c, 1); 1145 scp->status |= UPDATE_SCREEN; 1146 kernel_console = scp->term; 1147 current_default = &user_default; 1148 scp->term = save; 1149 if (scp == cur_console /* && scrn_timer not running */) { 1150 if (scp->scr_buf != Crtat) { 1151 bcopyw(scp->scr_buf, Crtat, 1152 (scp->xsize*scp->ysize)*sizeof(u_short)); 1153 scp->status &= ~CURSOR_SHOWN; 1154 } 1155 draw_cursor(scp, TRUE); 1156 scp->status &= ~UPDATE_SCREEN; 1157 } |
1372} 1373 1374int 1375pccngetc(dev_t dev) 1376{ | 1158} 1159 1160int 1161pccngetc(dev_t dev) 1162{ |
1377 int s = spltty(); /* block scintr while we poll */ 1378 int c = scgetc(0); 1379 splx(s); 1380 return(c); | 1163 int s = spltty(); /* block scintr while we poll */ 1164 int c = scgetc(0); 1165 splx(s); 1166 return(c); |
1381} 1382 1383int 1384pccncheckc(dev_t dev) 1385{ | 1167} 1168 1169int 1170pccncheckc(dev_t dev) 1171{ |
1386 return (scgetc(1) & 0xff); | 1172 return (scgetc(1) & 0xff); |
1387} 1388 1389static void | 1173} 1174 1175static void |
1390none_saver(int blank) 1391{ 1392} 1393 1394static void 1395fade_saver(int blank) 1396{ 1397 static int count = 0; 1398 int i; 1399 1400 if (blank) { 1401 scrn_blanked = 1; 1402 if (count < 64) { 1403 outb(PIXMASK, 0xFF); /* no pixelmask */ 1404 outb(PALWADR, 0x00); 1405 outb(PALDATA, 0); 1406 outb(PALDATA, 0); 1407 outb(PALDATA, 0); 1408 for (i = 3; i < 768; i++) { 1409 if (palette[i] - count > 15) 1410 outb(PALDATA, palette[i]-count); 1411 else 1412 outb(PALDATA, 15); 1413 } 1414 inb(crtc_addr+6); /* reset flip/flop */ 1415 outb(ATC, 0x20); /* enable palette */ 1416 count++; 1417 } 1418 } 1419 else { 1420 load_palette(); 1421 count = scrn_blanked = 0; 1422 } 1423} 1424 1425static void 1426blank_saver(int blank) 1427{ 1428 u_char val; 1429 if (blank) { 1430 scrn_blanked = 1; 1431 outb(TSIDX, 0x01); val = inb(TSREG); 1432 outb(TSIDX, 0x01); outb(TSREG, val | 0x20); 1433 } 1434 else { 1435 outb(TSIDX, 0x01); val = inb(TSREG); 1436 outb(TSIDX, 0x01); outb(TSREG, val & 0xDF); 1437 scrn_blanked = 0; 1438 } 1439} 1440 1441static void 1442green_saver(int blank) 1443{ 1444 u_char val; 1445 if (blank) { 1446 scrn_blanked = 1; 1447 outb(TSIDX, 0x01); val = inb(TSREG); 1448 outb(TSIDX, 0x01); outb(TSREG, val | 0x20); 1449 outb(crtc_addr, 0x17); val = inb(crtc_addr + 1); 1450 outb(crtc_addr + 1, val & ~0x80); 1451 } 1452 else { 1453 outb(TSIDX, 0x01); val = inb(TSREG); 1454 outb(TSIDX, 0x01); outb(TSREG, val & 0xDF); 1455 outb(crtc_addr, 0x17); val = inb(crtc_addr + 1); 1456 outb(crtc_addr + 1, val | 0x80); 1457 scrn_blanked = 0; 1458 } 1459} 1460 1461#define NUM_STARS 50 1462 1463/* 1464 * Alternate saver that got its inspiration from a well known utility 1465 * package for an inferior^H^H^H^H^H^Hfamous OS. 1466 */ 1467static void 1468star_saver(int blank) 1469{ 1470 scr_stat *scp = cur_console; 1471 int cell, i; 1472 char pattern[] = {"...........++++*** "}; 1473 char colors[] = {FG_DARKGREY, FG_LIGHTGREY, 1474 FG_WHITE, FG_LIGHTCYAN}; 1475 static u_short stars[NUM_STARS][2]; 1476 1477 if (blank) { 1478 if (!scrn_blanked) { 1479 scrn_blanked = 1; 1480 fillw((FG_LIGHTGREY|BG_BLACK)<<8|scr_map[0x20], Crtat, 1481 scp->xsize * scp->ysize); 1482 set_border(0); 1483 for(i=0; i<NUM_STARS; i++) { 1484 stars[i][0] = 1485 random() % (scp->xsize*scp->ysize); 1486 stars[i][1] = 0; 1487 } 1488 } 1489 cell = random() % NUM_STARS; 1490 *((u_short*)(Crtat + stars[cell][0])) = 1491 scr_map[pattern[stars[cell][1]]] | 1492 colors[random()%sizeof(colors)] << 8; 1493 if ((stars[cell][1]+=(random()%4)) >= sizeof(pattern)-1) { 1494 stars[cell][0] = random() % (scp->xsize*scp->ysize); 1495 stars[cell][1] = 0; 1496 } 1497 } 1498 else { 1499 if (scrn_blanked) { 1500 set_border(scp->border); 1501 scrn_blanked = 0; 1502 } 1503 } 1504} 1505 1506static void 1507snake_saver(int blank) 1508{ 1509 const char saves[] = {"FreeBSD-2.0"}; 1510 static u_char *savs[sizeof(saves)-1]; 1511 static int dirx, diry; 1512 int f; 1513 scr_stat *scp = cur_console; 1514 1515 if (blank) { 1516 if (!scrn_blanked) { 1517 fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20], 1518 Crtat, scp->xsize * scp->ysize); 1519 set_border(0); 1520 dirx = (scp->xpos ? 1 : -1); 1521 diry = (scp->ypos ? 1522 scp->xsize : -scp->xsize); 1523 for (f=0; f< sizeof(saves)-1; f++) 1524 savs[f] = (u_char *)Crtat + 2 * 1525 (scp->xpos+scp->ypos*scp->xsize); 1526 *(savs[0]) = scr_map[*saves]; 1527 f = scp->ysize * scp->xsize + 5; 1528 outb(crtc_addr, 14); 1529 outb(crtc_addr+1, f >> 8); 1530 outb(crtc_addr, 15); 1531 outb(crtc_addr+1, f & 0xff); 1532 scrn_blanked = 1; 1533 } 1534 if (scrn_blanked++ < 4) 1535 return; 1536 scrn_blanked = 1; 1537 *(savs[sizeof(saves)-2]) = scr_map[0x20]; 1538 for (f=sizeof(saves)-2; f > 0; f--) 1539 savs[f] = savs[f-1]; 1540 f = (savs[0] - (u_char *)Crtat) / 2; 1541 if ((f % scp->xsize) == 0 || 1542 (f % scp->xsize) == scp->xsize - 1 || 1543 (random() % 50) == 0) 1544 dirx = -dirx; 1545 if ((f / scp->xsize) == 0 || 1546 (f / scp->xsize) == scp->ysize - 1 || 1547 (random() % 20) == 0) 1548 diry = -diry; 1549 savs[0] += 2*dirx + 2*diry; 1550 for (f=sizeof(saves)-2; f>=0; f--) 1551 *(savs[f]) = scr_map[saves[f]]; 1552 } 1553 else { 1554 if (scrn_blanked) { 1555 set_border(scp->border); 1556 scrn_blanked = 0; 1557 } 1558 } 1559} 1560 1561static void | |
1562scrn_timer() 1563{ 1564 static int cursor_blinkrate; 1565 scr_stat *scp = cur_console; 1566 1567 /* should we just return ? */ 1568 if ((scp->status&UNKNOWN_MODE) || blink_in_progress || switch_in_progress) { 1569 timeout((timeout_func_t)scrn_timer, 0, hz/10); 1570 return; 1571 } | 1176scrn_timer() 1177{ 1178 static int cursor_blinkrate; 1179 scr_stat *scp = cur_console; 1180 1181 /* should we just return ? */ 1182 if ((scp->status&UNKNOWN_MODE) || blink_in_progress || switch_in_progress) { 1183 timeout((timeout_func_t)scrn_timer, 0, hz/10); 1184 return; 1185 } |
1572 | 1186 |
1573 if (!scrn_blanked) { 1574 /* update entire screen image */ 1575 if (scp->status & UPDATE_SCREEN) { 1576 bcopyw(scp->scr_buf, Crtat, scp->xsize*scp->ysize*sizeof(u_short)); 1577 scp->status &= ~CURSOR_SHOWN; 1578 } | 1187 if (!scrn_blanked) { 1188 /* update entire screen image */ 1189 if (scp->status & UPDATE_SCREEN) { 1190 bcopyw(scp->scr_buf, Crtat, scp->xsize*scp->ysize*sizeof(u_short)); 1191 scp->status &= ~CURSOR_SHOWN; 1192 } |
1579 /* update "pseudo" mouse */ | 1193 /* update "pseudo" mouse arrow */ |
1580 if ((scp->status & MOUSE_ENABLED) && 1581 ((scp->status & UPDATE_MOUSE) || (scp->status & UPDATE_SCREEN))) 1582 draw_mouse_image(scp); 1583 1584 /* update cursor image */ 1585 if (scp->status & CURSOR_ENABLED) 1586 draw_cursor(scp, 1587 !(configuration&BLINK_CURSOR) || !(cursor_blinkrate++&0x04)); 1588 1589 /* signal update done */ 1590 scp->status &= ~UPDATE_SCREEN; 1591 } 1592 if (scrn_blank_time && (time.tv_sec>scrn_time_stamp+scrn_blank_time)) | 1194 if ((scp->status & MOUSE_ENABLED) && 1195 ((scp->status & UPDATE_MOUSE) || (scp->status & UPDATE_SCREEN))) 1196 draw_mouse_image(scp); 1197 1198 /* update cursor image */ 1199 if (scp->status & CURSOR_ENABLED) 1200 draw_cursor(scp, 1201 !(configuration&BLINK_CURSOR) || !(cursor_blinkrate++&0x04)); 1202 1203 /* signal update done */ 1204 scp->status &= ~UPDATE_SCREEN; 1205 } 1206 if (scrn_blank_time && (time.tv_sec>scrn_time_stamp+scrn_blank_time)) |
1593 SCRN_SAVER(TRUE); | 1207 (*current_saver)(TRUE); |
1594 timeout((timeout_func_t)scrn_timer, 0, hz/25); 1595} | 1208 timeout((timeout_func_t)scrn_timer, 0, hz/25); 1209} |
1596 | 1210 |
1597static void 1598clear_screen(scr_stat *scp) 1599{ | 1211static void 1212clear_screen(scr_stat *scp) 1213{ |
1600 move_crsr(scp, 0, 0); 1601 fillw(scp->term.cur_attr | scr_map[0x20], scp->scr_buf, 1602 scp->xsize * scp->ysize); | 1214 move_crsr(scp, 0, 0); 1215 fillw(scp->term.cur_attr | scr_map[0x20], scp->scr_buf, 1216 scp->xsize * scp->ysize); |
1603} 1604 1605static int 1606switch_scr(scr_stat *scp, u_int next_scr) 1607{ | 1217} 1218 1219static int 1220switch_scr(scr_stat *scp, u_int next_scr) 1221{ |
1608 if (switch_in_progress && (cur_console->proc != pfind(cur_console->pid))) 1609 switch_in_progress = FALSE; | 1222 if (switch_in_progress && (cur_console->proc != pfind(cur_console->pid))) 1223 switch_in_progress = FALSE; |
1610 | 1224 |
1611 if (next_scr >= MAXCONS || switch_in_progress 1612 || (cur_console->smode.mode == VT_AUTO && cur_console->status & UNKNOWN_MODE)) { 1613 do_bell(scp, BELL_PITCH, BELL_DURATION); 1614 return EINVAL; 1615 } | 1225 if (next_scr >= MAXCONS || switch_in_progress || 1226 (cur_console->smode.mode == VT_AUTO 1227 && cur_console->status & UNKNOWN_MODE)) { 1228 do_bell(scp, BELL_PITCH, BELL_DURATION); 1229 return EINVAL; 1230 } |
1616 | 1231 |
1617 /* is the wanted virtual console open ? */ 1618 if (next_scr) { 1619 struct tty *tp = VIRTUAL_TTY(next_scr); 1620 if (!(tp->t_state & TS_ISOPEN)) { 1621 do_bell(scp, BELL_PITCH, BELL_DURATION); 1622 return EINVAL; 1623 } | 1232 /* is the wanted virtual console open ? */ 1233 if (next_scr) { 1234 struct tty *tp = VIRTUAL_TTY(next_scr); 1235 if (!(tp->t_state & TS_ISOPEN)) { 1236 do_bell(scp, BELL_PITCH, BELL_DURATION); 1237 return EINVAL; |
1624 } | 1238 } |
1625 /* delay switch if actively updating screen */ 1626 if (write_in_progress || blink_in_progress) { 1627 delayed_next_scr = next_scr+1; 1628 return 0; 1629 } 1630 switch_in_progress = TRUE; 1631 old_scp = cur_console; 1632 new_scp = console[next_scr]; 1633 wakeup((caddr_t)&new_scp->smode); 1634 if (new_scp == old_scp) { 1635 switch_in_progress = FALSE; 1636 delayed_next_scr = FALSE; 1637 return 0; 1638 } 1639 1640 /* has controlling process died? */ 1641 if (old_scp->proc && (old_scp->proc != pfind(old_scp->pid))) 1642 old_scp->smode.mode = VT_AUTO; 1643 if (new_scp->proc && (new_scp->proc != pfind(new_scp->pid))) 1644 new_scp->smode.mode = VT_AUTO; | 1239 } 1240 /* delay switch if actively updating screen */ 1241 if (write_in_progress || blink_in_progress) { 1242 delayed_next_scr = next_scr+1; 1243 return 0; 1244 } 1245 switch_in_progress = TRUE; 1246 old_scp = cur_console; 1247 new_scp = console[next_scr]; 1248 wakeup((caddr_t)&new_scp->smode); 1249 if (new_scp == old_scp) { 1250 switch_in_progress = FALSE; 1251 delayed_next_scr = FALSE; 1252 return 0; 1253 } 1254 1255 /* has controlling process died? */ 1256 if (old_scp->proc && (old_scp->proc != pfind(old_scp->pid))) 1257 old_scp->smode.mode = VT_AUTO; 1258 if (new_scp->proc && (new_scp->proc != pfind(new_scp->pid))) 1259 new_scp->smode.mode = VT_AUTO; |
1645 | 1260 |
1646 /* check the modes and switch approbiatly */ 1647 if (old_scp->smode.mode == VT_PROCESS) { 1648 old_scp->status |= SWITCH_WAIT_REL; 1649 psignal(old_scp->proc, old_scp->smode.relsig); | 1261 /* check the modes and switch approbiatly */ 1262 if (old_scp->smode.mode == VT_PROCESS) { 1263 old_scp->status |= SWITCH_WAIT_REL; 1264 psignal(old_scp->proc, old_scp->smode.relsig); 1265 } 1266 else { 1267 exchange_scr(); 1268 if (new_scp->smode.mode == VT_PROCESS) { 1269 new_scp->status |= SWITCH_WAIT_ACQ; 1270 psignal(new_scp->proc, new_scp->smode.acqsig); |
1650 } | 1271 } |
1651 else { 1652 exchange_scr(); 1653 if (new_scp->smode.mode == VT_PROCESS) { 1654 new_scp->status |= SWITCH_WAIT_ACQ; 1655 psignal(new_scp->proc, new_scp->smode.acqsig); 1656 } 1657 else 1658 switch_in_progress = FALSE; 1659 } 1660 return 0; | 1272 else 1273 switch_in_progress = FALSE; 1274 } 1275 return 0; |
1661} 1662 1663static void 1664exchange_scr(void) 1665{ | 1276} 1277 1278static void 1279exchange_scr(void) 1280{ |
1666 move_crsr(old_scp, old_scp->xpos, old_scp->ypos); 1667 cur_console = new_scp; 1668 if (old_scp->mode != new_scp->mode || (old_scp->status & UNKNOWN_MODE)){ 1669 if (crtc_vga && video_mode_ptr) 1670 set_mode(new_scp); 1671 } 1672 move_crsr(new_scp, new_scp->xpos, new_scp->ypos); 1673 if ((old_scp->status & UNKNOWN_MODE) && crtc_vga) { 1674 if (fonts_loaded & FONT_8) 1675 copy_font(LOAD, FONT_8, font_8); 1676 if (fonts_loaded & FONT_14) 1677 copy_font(LOAD, FONT_14, font_14); 1678 if (fonts_loaded & FONT_16) 1679 copy_font(LOAD, FONT_16, font_16); 1680 load_palette(); 1681 } 1682 if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE) 1683 shfts = ctls = alts = agrs = metas = 0; 1684 update_leds(new_scp->status); 1685 delayed_next_scr = FALSE; 1686 new_scp->status |= UPDATE_SCREEN; | 1281 move_crsr(old_scp, old_scp->xpos, old_scp->ypos); 1282 cur_console = new_scp; 1283 if (old_scp->mode != new_scp->mode || (old_scp->status & UNKNOWN_MODE)){ 1284 if (crtc_vga && video_mode_ptr) 1285 set_mode(new_scp); 1286 } 1287 move_crsr(new_scp, new_scp->xpos, new_scp->ypos); 1288 if ((old_scp->status & UNKNOWN_MODE) && crtc_vga) { 1289 if (fonts_loaded & FONT_8) 1290 copy_font(LOAD, FONT_8, font_8); 1291 if (fonts_loaded & FONT_14) 1292 copy_font(LOAD, FONT_14, font_14); 1293 if (fonts_loaded & FONT_16) 1294 copy_font(LOAD, FONT_16, font_16); 1295 load_palette(); 1296 } 1297 if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE) 1298 shfts = ctls = alts = agrs = metas = 0; 1299 update_leds(new_scp->status); 1300 delayed_next_scr = FALSE; 1301 bcopyw(new_scp->scr_buf, Crtat, 1302 (new_scp->xsize*new_scp->ysize)*sizeof(u_short)); 1303 new_scp->status &= ~CURSOR_SHOWN; |
1687} 1688 1689static inline void 1690move_crsr(scr_stat *scp, int x, int y) 1691{ | 1304} 1305 1306static inline void 1307move_crsr(scr_stat *scp, int x, int y) 1308{ |
1692 if (x < 0 || y < 0 || x >= scp->xsize || y >= scp->ysize) 1693 return; 1694 scp->xpos = x; 1695 scp->ypos = y; 1696 scp->cursor_pos = scp->scr_buf + scp->ypos * scp->xsize + scp->xpos; | 1309 if (x < 0 || y < 0 || x >= scp->xsize || y >= scp->ysize) 1310 return; 1311 scp->xpos = x; 1312 scp->ypos = y; 1313 scp->cursor_pos = scp->scr_buf + scp->ypos * scp->xsize + scp->xpos; |
1697} 1698 1699static void 1700scan_esc(scr_stat *scp, u_char c) 1701{ | 1314} 1315 1316static void 1317scan_esc(scr_stat *scp, u_char c) 1318{ |
1702 static u_char ansi_col[16] = 1703 {0, 4, 2, 6, 1, 5, 3, 7, 8, 12, 10, 14, 9, 13, 11, 15}; 1704 int i, n; 1705 u_short *src, *dst, count; | 1319 static u_char ansi_col[16] = 1320 {0, 4, 2, 6, 1, 5, 3, 7, 8, 12, 10, 14, 9, 13, 11, 15}; 1321 int i, n; 1322 u_short *src, *dst, count; |
1706 | 1323 |
1707 if (scp->term.esc == 1) { 1708 switch (c) { | 1324 if (scp->term.esc == 1) { 1325 switch (c) { |
1709 | 1326 |
1710 case '[': /* Start ESC [ sequence */ 1711 scp->term.esc = 2; 1712 scp->term.last_param = -1; 1713 for (i = scp->term.num_param; i < MAX_ESC_PAR; i++) 1714 scp->term.param[i] = 1; 1715 scp->term.num_param = 0; 1716 return; | 1327 case '[': /* Start ESC [ sequence */ 1328 scp->term.esc = 2; 1329 scp->term.last_param = -1; 1330 for (i = scp->term.num_param; i < MAX_ESC_PAR; i++) 1331 scp->term.param[i] = 1; 1332 scp->term.num_param = 0; 1333 return; |
1717 | 1334 |
1718 case 'M': /* Move cursor up 1 line, scroll if at top */ 1719 if (scp->ypos > 0) 1720 move_crsr(scp, scp->xpos, scp->ypos - 1); 1721 else { 1722 bcopyw(scp->scr_buf, 1723 scp->scr_buf + scp->xsize, 1724 (scp->ysize - 1) * scp->xsize * 1725 sizeof(u_short)); 1726 fillw(scp->term.cur_attr | scr_map[0x20], 1727 scp->scr_buf, scp->xsize); 1728 } 1729 break; | 1335 case 'M': /* Move cursor up 1 line, scroll if at top */ 1336 if (scp->ypos > 0) 1337 move_crsr(scp, scp->xpos, scp->ypos - 1); 1338 else { 1339 bcopyw(scp->scr_buf, scp->scr_buf + scp->xsize, 1340 (scp->ysize - 1) * scp->xsize * sizeof(u_short)); 1341 fillw(scp->term.cur_attr | scr_map[0x20], 1342 scp->scr_buf, scp->xsize); 1343 } 1344 break; |
1730#if notyet | 1345#if notyet |
1731 case 'Q': 1732 scp->term.esc = 4; 1733 break; | 1346 case 'Q': 1347 scp->term.esc = 4; 1348 break; |
1734#endif | 1349#endif |
1735 case 'c': /* Clear screen & home */ 1736 clear_screen(scp); 1737 break; 1738 } | 1350 case 'c': /* Clear screen & home */ 1351 clear_screen(scp); 1352 break; |
1739 } | 1353 } |
1740 else if (scp->term.esc == 2) { 1741 if (c >= '0' && c <= '9') { 1742 if (scp->term.num_param < MAX_ESC_PAR) { 1743 if (scp->term.last_param != scp->term.num_param) { 1744 scp->term.last_param = scp->term.num_param; 1745 scp->term.param[scp->term.num_param] = 0; 1746 } 1747 else 1748 scp->term.param[scp->term.num_param] *= 10; 1749 scp->term.param[scp->term.num_param] += c - '0'; 1750 return; 1751 } 1752 } 1753 scp->term.num_param = scp->term.last_param + 1; 1754 switch (c) { | 1354 } 1355 else if (scp->term.esc == 2) { 1356 if (c >= '0' && c <= '9') { 1357 if (scp->term.num_param < MAX_ESC_PAR) { 1358 if (scp->term.last_param != scp->term.num_param) { 1359 scp->term.last_param = scp->term.num_param; 1360 scp->term.param[scp->term.num_param] = 0; 1361 } 1362 else 1363 scp->term.param[scp->term.num_param] *= 10; 1364 scp->term.param[scp->term.num_param] += c - '0'; 1365 return; 1366 } 1367 } 1368 scp->term.num_param = scp->term.last_param + 1; 1369 switch (c) { |
1755 | 1370 |
1756 case ';': 1757 if (scp->term.num_param < MAX_ESC_PAR) 1758 return; 1759 break; | 1371 case ';': 1372 if (scp->term.num_param < MAX_ESC_PAR) 1373 return; 1374 break; |
1760 | 1375 |
1761 case '=': 1762 scp->term.esc = 3; 1763 scp->term.last_param = -1; 1764 for (i = scp->term.num_param; i < MAX_ESC_PAR; i++) 1765 scp->term.param[i] = 1; 1766 scp->term.num_param = 0; 1767 return; | 1376 case '=': 1377 scp->term.esc = 3; 1378 scp->term.last_param = -1; 1379 for (i = scp->term.num_param; i < MAX_ESC_PAR; i++) 1380 scp->term.param[i] = 1; 1381 scp->term.num_param = 0; 1382 return; |
1768 | 1383 |
1769 case 'A': /* up n rows */ 1770 n = scp->term.param[0]; if (n < 1) n = 1; 1771 move_crsr(scp, scp->xpos, scp->ypos - n); 1772 break; | 1384 case 'A': /* up n rows */ 1385 n = scp->term.param[0]; if (n < 1) n = 1; 1386 move_crsr(scp, scp->xpos, scp->ypos - n); 1387 break; |
1773 | 1388 |
1774 case 'B': /* down n rows */ 1775 n = scp->term.param[0]; if (n < 1) n = 1; 1776 move_crsr(scp, scp->xpos, scp->ypos + n); 1777 break; | 1389 case 'B': /* down n rows */ 1390 n = scp->term.param[0]; if (n < 1) n = 1; 1391 move_crsr(scp, scp->xpos, scp->ypos + n); 1392 break; |
1778 | 1393 |
1779 case 'C': /* right n columns */ 1780 n = scp->term.param[0]; if (n < 1) n = 1; 1781 move_crsr(scp, scp->xpos + n, scp->ypos); 1782 break; | 1394 case 'C': /* right n columns */ 1395 n = scp->term.param[0]; if (n < 1) n = 1; 1396 move_crsr(scp, scp->xpos + n, scp->ypos); 1397 break; |
1783 | 1398 |
1784 case 'D': /* left n columns */ 1785 n = scp->term.param[0]; if (n < 1) n = 1; 1786 move_crsr(scp, scp->xpos - n, scp->ypos); 1787 break; | 1399 case 'D': /* left n columns */ 1400 n = scp->term.param[0]; if (n < 1) n = 1; 1401 move_crsr(scp, scp->xpos - n, scp->ypos); 1402 break; |
1788 | 1403 |
1789 case 'E': /* cursor to start of line n lines down */ 1790 n = scp->term.param[0]; if (n < 1) n = 1; 1791 move_crsr(scp, 0, scp->ypos + n); 1792 break; | 1404 case 'E': /* cursor to start of line n lines down */ 1405 n = scp->term.param[0]; if (n < 1) n = 1; 1406 move_crsr(scp, 0, scp->ypos + n); 1407 break; |
1793 | 1408 |
1794 case 'F': /* cursor to start of line n lines up */ 1795 n = scp->term.param[0]; if (n < 1) n = 1; 1796 move_crsr(scp, 0, scp->ypos - n); 1797 break; | 1409 case 'F': /* cursor to start of line n lines up */ 1410 n = scp->term.param[0]; if (n < 1) n = 1; 1411 move_crsr(scp, 0, scp->ypos - n); 1412 break; |
1798 | 1413 |
1799 case 'f': /* System V consoles .. */ 1800 case 'H': /* Cursor move */ 1801 if (scp->term.num_param == 0) 1802 move_crsr(scp, 0, 0); 1803 else if (scp->term.num_param == 2) 1804 move_crsr(scp, scp->term.param[1] - 1, 1805 scp->term.param[0] - 1); 1806 break; | 1414 case 'f': /* Cursor move */ 1415 case 'H': 1416 if (scp->term.num_param == 0) 1417 move_crsr(scp, 0, 0); 1418 else if (scp->term.num_param == 2) 1419 move_crsr(scp, scp->term.param[1] - 1, scp->term.param[0] - 1); 1420 break; |
1807 | 1421 |
1808 case 'J': /* Clear all or part of display */ 1809 if (scp->term.num_param == 0) 1810 n = 0; 1811 else 1812 n = scp->term.param[0]; 1813 switch (n) { 1814 case 0: /* clear form cursor to end of display */ 1815 fillw(scp->term.cur_attr | scr_map[0x20], 1816 scp->cursor_pos, scp->scr_buf + 1817 scp->xsize * scp->ysize - 1818 scp->cursor_pos); 1819 break; 1820 case 1: /* clear from beginning of display to cursor */ 1821 fillw(scp->term.cur_attr | scr_map[0x20], 1822 scp->scr_buf, 1823 scp->cursor_pos - scp->scr_buf); 1824 break; 1825 case 2: /* clear entire display */ 1826 clear_screen(scp); 1827 break; 1828 } 1829 break; | 1422 case 'J': /* Clear all or part of display */ 1423 if (scp->term.num_param == 0) 1424 n = 0; 1425 else 1426 n = scp->term.param[0]; 1427 switch (n) { 1428 case 0: /* clear form cursor to end of display */ 1429 fillw(scp->term.cur_attr | scr_map[0x20], 1430 scp->cursor_pos, 1431 scp->scr_buf + scp->xsize * scp->ysize - scp->cursor_pos); 1432 break; 1433 case 1: /* clear from beginning of display to cursor */ 1434 fillw(scp->term.cur_attr | scr_map[0x20], 1435 scp->scr_buf, 1436 scp->cursor_pos - scp->scr_buf); 1437 break; 1438 case 2: /* clear entire display */ 1439 clear_screen(scp); 1440 break; 1441 } 1442 break; |
1830 | 1443 |
1831 case 'K': /* Clear all or part of line */ 1832 if (scp->term.num_param == 0) 1833 n = 0; 1834 else 1835 n = scp->term.param[0]; 1836 switch (n) { 1837 case 0: /* clear form cursor to end of line */ 1838 fillw(scp->term.cur_attr | scr_map[0x20], 1839 scp->cursor_pos, scp->xsize - scp->xpos); 1840 break; 1841 case 1: /* clear from beginning of line to cursor */ 1842 fillw(scp->term.cur_attr|scr_map[0x20], 1843 scp->cursor_pos - (scp->xsize - scp->xpos), 1844 (scp->xsize - scp->xpos) + 1); 1845 break; 1846 case 2: /* clear entire line */ 1847 fillw(scp->term.cur_attr|scr_map[0x20], 1848 scp->cursor_pos - (scp->xsize - scp->xpos), 1849 scp->xsize); 1850 break; 1851 } 1852 break; | 1444 case 'K': /* Clear all or part of line */ 1445 if (scp->term.num_param == 0) 1446 n = 0; 1447 else 1448 n = scp->term.param[0]; 1449 switch (n) { 1450 case 0: /* clear form cursor to end of line */ 1451 fillw(scp->term.cur_attr | scr_map[0x20], 1452 scp->cursor_pos, 1453 scp->xsize - scp->xpos); 1454 break; 1455 case 1: /* clear from beginning of line to cursor */ 1456 fillw(scp->term.cur_attr|scr_map[0x20], 1457 scp->cursor_pos - (scp->xsize - scp->xpos), 1458 (scp->xsize - scp->xpos) + 1); 1459 break; 1460 case 2: /* clear entire line */ 1461 fillw(scp->term.cur_attr|scr_map[0x20], 1462 scp->cursor_pos - (scp->xsize - scp->xpos), 1463 scp->xsize); 1464 break; 1465 } 1466 break; |
1853 | 1467 |
1854 case 'L': /* Insert n lines */ 1855 n = scp->term.param[0]; if (n < 1) n = 1; 1856 if (n > scp->ysize - scp->ypos) 1857 n = scp->ysize - scp->ypos; 1858 src = scp->scr_buf + scp->ypos * scp->xsize; 1859 dst = src + n * scp->xsize; 1860 count = scp->ysize - (scp->ypos + n); 1861 bcopyw(src, dst, count * scp->xsize * sizeof(u_short)); 1862 fillw(scp->term.cur_attr | scr_map[0x20], src, 1863 n * scp->xsize); 1864 break; | 1468 case 'L': /* Insert n lines */ 1469 n = scp->term.param[0]; if (n < 1) n = 1; 1470 if (n > scp->ysize - scp->ypos) 1471 n = scp->ysize - scp->ypos; 1472 src = scp->scr_buf + scp->ypos * scp->xsize; 1473 dst = src + n * scp->xsize; 1474 count = scp->ysize - (scp->ypos + n); 1475 bcopyw(src, dst, count * scp->xsize * sizeof(u_short)); 1476 fillw(scp->term.cur_attr | scr_map[0x20], src, 1477 n * scp->xsize); 1478 break; |
1865 | 1479 |
1866 case 'M': /* Delete n lines */ 1867 n = scp->term.param[0]; if (n < 1) n = 1; 1868 if (n > scp->ysize - scp->ypos) 1869 n = scp->ysize - scp->ypos; 1870 dst = scp->scr_buf + scp->ypos * scp->xsize; 1871 src = dst + n * scp->xsize; 1872 count = scp->ysize - (scp->ypos + n); 1873 bcopyw(src, dst, count * scp->xsize * sizeof(u_short)); 1874 src = dst + count * scp->xsize; 1875 fillw(scp->term.cur_attr | scr_map[0x20], src, 1876 n * scp->xsize); 1877 break; | 1480 case 'M': /* Delete n lines */ 1481 n = scp->term.param[0]; if (n < 1) n = 1; 1482 if (n > scp->ysize - scp->ypos) 1483 n = scp->ysize - scp->ypos; 1484 dst = scp->scr_buf + scp->ypos * scp->xsize; 1485 src = dst + n * scp->xsize; 1486 count = scp->ysize - (scp->ypos + n); 1487 bcopyw(src, dst, count * scp->xsize * sizeof(u_short)); 1488 src = dst + count * scp->xsize; 1489 fillw(scp->term.cur_attr | scr_map[0x20], src, 1490 n * scp->xsize); 1491 break; |
1878 | 1492 |
1879 case 'P': /* Delete n chars */ 1880 n = scp->term.param[0]; if (n < 1) n = 1; 1881 if (n > scp->xsize - scp->xpos) 1882 n = scp->xsize - scp->xpos; 1883 dst = scp->cursor_pos; 1884 src = dst + n; 1885 count = scp->xsize - (scp->xpos + n); 1886 bcopyw(src, dst, count * sizeof(u_short)); 1887 src = dst + count; 1888 fillw(scp->term.cur_attr | scr_map[0x20], src, n); 1889 break; | 1493 case 'P': /* Delete n chars */ 1494 n = scp->term.param[0]; if (n < 1) n = 1; 1495 if (n > scp->xsize - scp->xpos) 1496 n = scp->xsize - scp->xpos; 1497 dst = scp->cursor_pos; 1498 src = dst + n; 1499 count = scp->xsize - (scp->xpos + n); 1500 bcopyw(src, dst, count * sizeof(u_short)); 1501 src = dst + count; 1502 fillw(scp->term.cur_attr | scr_map[0x20], src, n); 1503 break; |
1890 | 1504 |
1891 case '@': /* Insert n chars */ 1892 n = scp->term.param[0]; if (n < 1) n = 1; 1893 if (n > scp->xsize - scp->xpos) 1894 n = scp->xsize - scp->xpos; 1895 src = scp->cursor_pos; 1896 dst = src + n; 1897 count = scp->xsize - (scp->xpos + n); 1898 bcopyw(src, dst, count * sizeof(u_short)); 1899 fillw(scp->term.cur_attr | scr_map[0x20], src, n); 1900 break; | 1505 case '@': /* Insert n chars */ 1506 n = scp->term.param[0]; if (n < 1) n = 1; 1507 if (n > scp->xsize - scp->xpos) 1508 n = scp->xsize - scp->xpos; 1509 src = scp->cursor_pos; 1510 dst = src + n; 1511 count = scp->xsize - (scp->xpos + n); 1512 bcopyw(src, dst, count * sizeof(u_short)); 1513 fillw(scp->term.cur_attr | scr_map[0x20], src, n); 1514 break; |
1901 | 1515 |
1902 case 'S': /* scroll up n lines */ 1903 n = scp->term.param[0]; if (n < 1) n = 1; 1904 if (n > scp->ysize) 1905 n = scp->ysize; 1906 bcopyw(scp->scr_buf + (scp->xsize * n), 1907 scp->scr_buf, 1908 scp->xsize * (scp->ysize - n) * 1909 sizeof(u_short)); 1910 fillw(scp->term.cur_attr | scr_map[0x20], 1911 scp->scr_buf + scp->xsize * 1912 (scp->ysize - n), 1913 scp->xsize * n); 1914 break; | 1516 case 'S': /* scroll up n lines */ 1517 n = scp->term.param[0]; if (n < 1) n = 1; 1518 if (n > scp->ysize) 1519 n = scp->ysize; 1520 bcopyw(scp->scr_buf + (scp->xsize * n), 1521 scp->scr_buf, 1522 scp->xsize * (scp->ysize - n) * sizeof(u_short)); 1523 fillw(scp->term.cur_attr | scr_map[0x20], 1524 scp->scr_buf + scp->xsize * (scp->ysize - n), 1525 scp->xsize * n); 1526 break; |
1915 | 1527 |
1916 case 'T': /* scroll down n lines */ 1917 n = scp->term.param[0]; if (n < 1) n = 1; 1918 if (n > scp->ysize) 1919 n = scp->ysize; 1920 bcopyw(scp->scr_buf, 1921 scp->scr_buf + (scp->xsize * n), 1922 scp->xsize * (scp->ysize - n) * 1923 sizeof(u_short)); 1924 fillw(scp->term.cur_attr | scr_map[0x20], 1925 scp->scr_buf, scp->xsize * n); 1926 break; | 1528 case 'T': /* scroll down n lines */ 1529 n = scp->term.param[0]; if (n < 1) n = 1; 1530 if (n > scp->ysize) 1531 n = scp->ysize; 1532 bcopyw(scp->scr_buf, 1533 scp->scr_buf + (scp->xsize * n), 1534 scp->xsize * (scp->ysize - n) * 1535 sizeof(u_short)); 1536 fillw(scp->term.cur_attr | scr_map[0x20], 1537 scp->scr_buf, scp->xsize * n); 1538 break; |
1927 | 1539 |
1928 case 'X': /* delete n characters in line */ 1929 n = scp->term.param[0]; if (n < 1) n = 1; 1930 if (n > scp->xsize - scp->xpos) 1931 n = scp->xsize - scp->xpos; 1932 fillw(scp->term.cur_attr | scr_map[0x20], 1933 scp->scr_buf + scp->xpos + 1934 ((scp->xsize*scp->ypos) * sizeof(u_short)), n); 1935 break; | 1540 case 'X': /* delete n characters in line */ 1541 n = scp->term.param[0]; if (n < 1) n = 1; 1542 if (n > scp->xsize - scp->xpos) 1543 n = scp->xsize - scp->xpos; 1544 fillw(scp->term.cur_attr | scr_map[0x20], 1545 scp->scr_buf + scp->xpos + 1546 ((scp->xsize*scp->ypos) * sizeof(u_short)), n); 1547 break; |
1936 | 1548 |
1937 case 'Z': /* move n tabs backwards */ 1938 n = scp->term.param[0]; if (n < 1) n = 1; 1939 if ((i = scp->xpos & 0xf8) == scp->xpos) 1940 i -= 8*n; 1941 else 1942 i -= 8*(n-1); 1943 if (i < 0) 1944 i = 0; 1945 move_crsr(scp, i, scp->ypos); 1946 break; | 1549 case 'Z': /* move n tabs backwards */ 1550 n = scp->term.param[0]; if (n < 1) n = 1; 1551 if ((i = scp->xpos & 0xf8) == scp->xpos) 1552 i -= 8*n; 1553 else 1554 i -= 8*(n-1); 1555 if (i < 0) 1556 i = 0; 1557 move_crsr(scp, i, scp->ypos); 1558 break; |
1947 | 1559 |
1948 case '`': /* move cursor to column n */ 1949 n = scp->term.param[0]; if (n < 1) n = 1; 1950 move_crsr(scp, n - 1, scp->ypos); 1951 break; | 1560 case '`': /* move cursor to column n */ 1561 n = scp->term.param[0]; if (n < 1) n = 1; 1562 move_crsr(scp, n - 1, scp->ypos); 1563 break; |
1952 | 1564 |
1953 case 'a': /* move cursor n columns to the right */ 1954 n = scp->term.param[0]; if (n < 1) n = 1; 1955 move_crsr(scp, scp->xpos + n, scp->ypos); 1956 break; | 1565 case 'a': /* move cursor n columns to the right */ 1566 n = scp->term.param[0]; if (n < 1) n = 1; 1567 move_crsr(scp, scp->xpos + n, scp->ypos); 1568 break; |
1957 | 1569 |
1958 case 'd': /* move cursor to row n */ 1959 n = scp->term.param[0]; if (n < 1) n = 1; 1960 move_crsr(scp, scp->xpos, n - 1); 1961 break; | 1570 case 'd': /* move cursor to row n */ 1571 n = scp->term.param[0]; if (n < 1) n = 1; 1572 move_crsr(scp, scp->xpos, n - 1); 1573 break; |
1962 | 1574 |
1963 case 'e': /* move cursor n rows down */ 1964 n = scp->term.param[0]; if (n < 1) n = 1; 1965 move_crsr(scp, scp->xpos, scp->ypos + n); 1966 break; | 1575 case 'e': /* move cursor n rows down */ 1576 n = scp->term.param[0]; if (n < 1) n = 1; 1577 move_crsr(scp, scp->xpos, scp->ypos + n); 1578 break; |
1967 | 1579 |
1968 case 'm': /* change attribute */ 1969 if (scp->term.num_param == 0) { 1970 scp->term.cur_attr = scp->term.std_attr; 1971 break; 1972 } 1973 for (i = 0; i < scp->term.num_param; i++) { 1974 switch (n = scp->term.param[i]) { 1975 case 0: /* back to normal */ 1976 scp->term.cur_attr = scp->term.std_attr; 1977 break; 1978 case 1: /* highlight (bold) */ 1979 scp->term.cur_attr &= 0xFF00; 1980 scp->term.cur_attr |= 0x0800; 1981 break; 1982 case 4: /* highlight (underline) */ 1983 scp->term.cur_attr &= 0xFF00; 1984 scp->term.cur_attr |= 0x0800; 1985 break; 1986 case 5: /* blink */ 1987 scp->term.cur_attr &= 0xFF00; 1988 scp->term.cur_attr |= 0x8000; 1989 break; 1990 case 7: /* reverse video */ 1991 scp->term.cur_attr = scp->term.rev_attr; 1992 break; 1993 case 30: case 31: /* set fg color */ 1994 case 32: case 33: case 34: 1995 case 35: case 36: case 37: 1996 scp->term.cur_attr = 1997 (scp->term.cur_attr & 0xF8FF) 1998 | (ansi_col[(n-30) & 7] << 8); 1999 break; 2000 case 40: case 41: /* set bg color */ 2001 case 42: case 43: case 44: 2002 case 45: case 46: case 47: 2003 scp->term.cur_attr = 2004 (scp->term.cur_attr & 0x8FFF) 2005 | (ansi_col[(n-40) & 7] << 12); 2006 break; 2007 } 2008 } 2009 break; | 1580 case 'm': /* change attribute */ 1581 if (scp->term.num_param == 0) { 1582 scp->term.cur_attr = scp->term.std_attr; 1583 break; 1584 } 1585 for (i = 0; i < scp->term.num_param; i++) { 1586 switch (n = scp->term.param[i]) { 1587 case 0: /* back to normal */ 1588 scp->term.cur_attr = scp->term.std_attr; 1589 break; 1590 case 1: /* highlight (bold) */ 1591 scp->term.cur_attr &= 0xFF00; 1592 scp->term.cur_attr |= 0x0800; 1593 break; 1594 case 4: /* highlight (underline) */ 1595 scp->term.cur_attr &= 0xFF00; 1596 scp->term.cur_attr |= 0x0800; 1597 break; 1598 case 5: /* blink */ 1599 scp->term.cur_attr &= 0xFF00; 1600 scp->term.cur_attr |= 0x8000; 1601 break; 1602 case 7: /* reverse video */ 1603 scp->term.cur_attr = scp->term.rev_attr; 1604 break; 1605 case 30: case 31: /* set fg color */ 1606 case 32: case 33: case 34: 1607 case 35: case 36: case 37: 1608 scp->term.cur_attr = 1609 (scp->term.cur_attr&0xF8FF) | (ansi_col[(n-30)&7]<<8); 1610 break; 1611 case 40: case 41: /* set bg color */ 1612 case 42: case 43: case 44: 1613 case 45: case 46: case 47: 1614 scp->term.cur_attr = 1615 (scp->term.cur_attr&0x8FFF) | (ansi_col[(n-40)&7]<<12); 1616 break; 1617 } 1618 } 1619 break; |
2010 | 1620 |
2011 case 'x': 2012 if (scp->term.num_param == 0) 2013 n = 0; 2014 else 2015 n = scp->term.param[0]; 2016 switch (n) { 2017 case 0: /* reset attributes */ 2018 scp->term.cur_attr = scp->term.std_attr = 2019 current_default->std_attr; 2020 scp->term.rev_attr = current_default->rev_attr; 2021 break; 2022 case 1: /* set ansi background */ 2023 scp->term.cur_attr = scp->term.std_attr = 2024 (scp->term.std_attr & 0x0F00) | 2025 (ansi_col[(scp->term.param[1])&0x0F]<<12); 2026 break; 2027 case 2: /* set ansi foreground */ 2028 scp->term.cur_attr = scp->term.std_attr = 2029 (scp->term.std_attr & 0xF000) | 2030 (ansi_col[(scp->term.param[1])&0x0F]<<8); 2031 break; 2032 case 3: /* set ansi attribute directly */ 2033 scp->term.cur_attr = scp->term.std_attr = 2034 (scp->term.param[1]&0xFF)<<8; 2035 break; 2036 case 5: /* set ansi reverse video background */ 2037 scp->term.rev_attr = 2038 (scp->term.rev_attr & 0x0F00) | 2039 (ansi_col[(scp->term.param[1])&0x0F]<<12); 2040 break; 2041 case 6: /* set ansi reverse video foreground */ 2042 scp->term.rev_attr = 2043 (scp->term.rev_attr & 0xF000) | 2044 (ansi_col[(scp->term.param[1])&0x0F]<<8); 2045 break; 2046 case 7: /* set ansi reverse video directly */ 2047 scp->term.rev_attr = 2048 (scp->term.param[1]&0xFF)<<8; 2049 break; 2050 } 2051 break; | 1621 case 'x': 1622 if (scp->term.num_param == 0) 1623 n = 0; 1624 else 1625 n = scp->term.param[0]; 1626 switch (n) { 1627 case 0: /* reset attributes */ 1628 scp->term.cur_attr = scp->term.std_attr = 1629 current_default->std_attr; 1630 scp->term.rev_attr = current_default->rev_attr; 1631 break; 1632 case 1: /* set ansi background */ 1633 scp->term.cur_attr = scp->term.std_attr = 1634 (scp->term.std_attr & 0x0F00) | 1635 (ansi_col[(scp->term.param[1])&0x0F]<<12); 1636 break; 1637 case 2: /* set ansi foreground */ 1638 scp->term.cur_attr = scp->term.std_attr = 1639 (scp->term.std_attr & 0xF000) | 1640 (ansi_col[(scp->term.param[1])&0x0F]<<8); 1641 break; 1642 case 3: /* set ansi attribute directly */ 1643 scp->term.cur_attr = scp->term.std_attr = 1644 (scp->term.param[1]&0xFF)<<8; 1645 break; 1646 case 5: /* set ansi reverse video background */ 1647 scp->term.rev_attr = 1648 (scp->term.rev_attr & 0x0F00) | 1649 (ansi_col[(scp->term.param[1])&0x0F]<<12); 1650 break; 1651 case 6: /* set ansi reverse video foreground */ 1652 scp->term.rev_attr = 1653 (scp->term.rev_attr & 0xF000) | 1654 (ansi_col[(scp->term.param[1])&0x0F]<<8); 1655 break; 1656 case 7: /* set ansi reverse video directly */ 1657 scp->term.rev_attr = 1658 (scp->term.param[1]&0xFF)<<8; 1659 break; 1660 } 1661 break; |
2052 | 1662 |
2053 case 'z': /* switch to (virtual) console n */ 2054 if (scp->term.num_param == 1) 2055 switch_scr(scp, scp->term.param[0]); 2056 break; 2057 } | 1663 case 'z': /* switch to (virtual) console n */ 1664 if (scp->term.num_param == 1) 1665 switch_scr(scp, scp->term.param[0]); 1666 break; |
2058 } | 1667 } |
2059 else if (scp->term.esc == 3) { 2060 if (c >= '0' && c <= '9') { 2061 if (scp->term.num_param < MAX_ESC_PAR) { 2062 if (scp->term.last_param != scp->term.num_param) { 2063 scp->term.last_param = scp->term.num_param; 2064 scp->term.param[scp->term.num_param] = 0; 2065 } 2066 else 2067 scp->term.param[scp->term.num_param] *= 10; 2068 scp->term.param[scp->term.num_param] += c - '0'; 2069 return; 2070 } 2071 } 2072 scp->term.num_param = scp->term.last_param + 1; 2073 switch (c) { | 1668 } 1669 else if (scp->term.esc == 3) { 1670 if (c >= '0' && c <= '9') { 1671 if (scp->term.num_param < MAX_ESC_PAR) { 1672 if (scp->term.last_param != scp->term.num_param) { 1673 scp->term.last_param = scp->term.num_param; 1674 scp->term.param[scp->term.num_param] = 0; 1675 } 1676 else 1677 scp->term.param[scp->term.num_param] *= 10; 1678 scp->term.param[scp->term.num_param] += c - '0'; 1679 return; 1680 } 1681 } 1682 scp->term.num_param = scp->term.last_param + 1; 1683 switch (c) { |
2074 | 1684 |
2075 case ';': 2076 if (scp->term.num_param < MAX_ESC_PAR) 2077 return; 2078 break; | 1685 case ';': 1686 if (scp->term.num_param < MAX_ESC_PAR) 1687 return; 1688 break; |
2079 | 1689 |
2080 case 'A': /* set display border color */ 2081 if (scp->term.num_param == 1) 2082 scp->border=scp->term.param[0] & 0xff; 2083 if (scp == cur_console) 2084 set_border(scp->border); 2085 break; | 1690 case 'A': /* set display border color */ 1691 if (scp->term.num_param == 1) 1692 scp->border=scp->term.param[0] & 0xff; 1693 if (scp == cur_console) 1694 set_border(scp->border); 1695 break; |
2086 | 1696 |
2087 case 'B': /* set bell pitch and duration */ 2088 if (scp->term.num_param == 2) { 2089 scp->bell_pitch = scp->term.param[0]; 2090 scp->bell_duration = scp->term.param[1]*10; 2091 } 2092 break; | 1697 case 'B': /* set bell pitch and duration */ 1698 if (scp->term.num_param == 2) { 1699 scp->bell_pitch = scp->term.param[0]; 1700 scp->bell_duration = scp->term.param[1]*10; 1701 } 1702 break; |
2093 | 1703 |
2094 case 'C': /* set cursor type & shape */ 2095 if (scp->term.num_param == 1) { 2096 if (scp->term.param[0] & 0x01) 2097 configuration |= BLINK_CURSOR; 2098 else 2099 configuration &= ~BLINK_CURSOR; 2100 if (scp->term.param[0] & 0x02) 2101 configuration |= CHAR_CURSOR; 2102 else 2103 configuration &= ~CHAR_CURSOR; 2104 } 2105 else if (scp->term.num_param == 2) { 2106 scp->cursor_start = scp->term.param[0] & 0x1F; 2107 scp->cursor_end = scp->term.param[1] & 0x1F; 2108 } 2109 break; | 1704 case 'C': /* set cursor type & shape */ 1705 if (scp->term.num_param == 1) { 1706 if (scp->term.param[0] & 0x01) 1707 configuration |= BLINK_CURSOR; 1708 else 1709 configuration &= ~BLINK_CURSOR; 1710 if (scp->term.param[0] & 0x02) 1711 configuration |= CHAR_CURSOR; 1712 else 1713 configuration &= ~CHAR_CURSOR; 1714 } 1715 else if (scp->term.num_param == 2) { 1716 scp->cursor_start = scp->term.param[0] & 0x1F; 1717 scp->cursor_end = scp->term.param[1] & 0x1F; 1718 } 1719 break; |
2110 | 1720 |
2111 case 'F': /* set ansi foreground */ 2112 if (scp->term.num_param == 1) 2113 scp->term.cur_attr = scp->term.std_attr = 2114 (scp->term.std_attr & 0xF000) 2115 | ((scp->term.param[0] & 0x0F) << 8); 2116 break; | 1721 case 'F': /* set ansi foreground */ 1722 if (scp->term.num_param == 1) 1723 scp->term.cur_attr = scp->term.std_attr = 1724 (scp->term.std_attr & 0xF000) 1725 | ((scp->term.param[0] & 0x0F) << 8); 1726 break; |
2117 | 1727 |
2118 case 'G': /* set ansi background */ 2119 if (scp->term.num_param == 1) 2120 scp->term.cur_attr = scp->term.std_attr = 2121 (scp->term.std_attr & 0x0F00) 2122 | ((scp->term.param[0] & 0x0F) << 12); 2123 break; | 1728 case 'G': /* set ansi background */ 1729 if (scp->term.num_param == 1) 1730 scp->term.cur_attr = scp->term.std_attr = 1731 (scp->term.std_attr & 0x0F00) 1732 | ((scp->term.param[0] & 0x0F) << 12); 1733 break; |
2124 | 1734 |
2125 case 'H': /* set ansi reverse video foreground */ 2126 if (scp->term.num_param == 1) 2127 scp->term.rev_attr = 2128 (scp->term.rev_attr & 0xF000) 2129 | ((scp->term.param[0] & 0x0F) << 8); 2130 break; | 1735 case 'H': /* set ansi reverse video foreground */ 1736 if (scp->term.num_param == 1) 1737 scp->term.rev_attr = 1738 (scp->term.rev_attr & 0xF000) 1739 | ((scp->term.param[0] & 0x0F) << 8); 1740 break; |
2131 | 1741 |
2132 case 'I': /* set ansi reverse video background */ 2133 if (scp->term.num_param == 1) 2134 scp->term.rev_attr = 2135 (scp->term.rev_attr & 0x0F00) 2136 | ((scp->term.param[0] & 0x0F) << 12); 2137 break; 2138 } | 1742 case 'I': /* set ansi reverse video background */ 1743 if (scp->term.num_param == 1) 1744 scp->term.rev_attr = 1745 (scp->term.rev_attr & 0x0F00) 1746 | ((scp->term.param[0] & 0x0F) << 12); 1747 break; |
2139 } | 1748 } |
2140 scp->term.esc = 0; | 1749 } 1750 scp->term.esc = 0; |
2141} 2142 2143static inline void 2144draw_cursor(scr_stat *scp, int show) 2145{ | 1751} 1752 1753static inline void 1754draw_cursor(scr_stat *scp, int show) 1755{ |
2146 if (show && !(scp->status & CURSOR_SHOWN)) { 2147 u_short cursor_image = *(Crtat + (scp->cursor_pos - scp->scr_buf)); | 1756 if (show && !(scp->status & CURSOR_SHOWN)) { 1757 u_short cursor_image = *(Crtat + (scp->cursor_pos - scp->scr_buf)); |
2148 | 1758 |
2149 scp->cursor_saveunder = cursor_image; 2150 if (configuration & CHAR_CURSOR) 2151 cursor_image = (cursor_image & 0xff00) | '_'; 2152 else { 2153 if ((cursor_image & 0x7000) == 0x7000) { 2154 cursor_image &= 0x8fff; 2155 if(!(cursor_image & 0x0700)) 2156 cursor_image |= 0x0700; 2157 } else { 2158 cursor_image |= 0x7000; 2159 if ((cursor_image & 0x0700) == 0x0700) 2160 cursor_image &= 0xf0ff; 2161 } 2162 } 2163 *(Crtat + (scp->cursor_pos - scp->scr_buf)) = cursor_image; 2164 scp->status |= CURSOR_SHOWN; | 1759 scp->cursor_saveunder = cursor_image; 1760 if (configuration & CHAR_CURSOR) 1761 cursor_image = (cursor_image & 0xff00) | '_'; 1762 else { 1763 if ((cursor_image & 0x7000) == 0x7000) { 1764 cursor_image &= 0x8fff; 1765 if(!(cursor_image & 0x0700)) 1766 cursor_image |= 0x0f00; 1767 } else { 1768 cursor_image |= 0x7000; 1769 if ((cursor_image & 0x0f00) == 0x0f00) 1770 cursor_image &= 0xf0ff; 1771 } |
2165 } | 1772 } |
2166 if (!show && (scp->status & CURSOR_SHOWN)) { 2167 *(Crtat+(scp->cursor_pos-scp->scr_buf)) = scp->cursor_saveunder; 2168 scp->status &= ~CURSOR_SHOWN; 2169 } | 1773 *(Crtat + (scp->cursor_pos - scp->scr_buf)) = cursor_image; 1774 scp->status |= CURSOR_SHOWN; 1775 } 1776 if (!show && (scp->status & CURSOR_SHOWN)) { 1777 *(Crtat+(scp->cursor_pos-scp->scr_buf)) = scp->cursor_saveunder; 1778 scp->status &= ~CURSOR_SHOWN; 1779 } |
2170} 2171 2172static void 2173ansi_put(scr_stat *scp, u_char *buf, int len) 2174{ | 1780} 1781 1782static void 1783ansi_put(scr_stat *scp, u_char *buf, int len) 1784{ |
2175 u_char *ptr = buf; | 1785 u_char *ptr = buf; |
2176 | 1786 |
2177 if (scp->status & UNKNOWN_MODE) 2178 return; | 1787 if (scp->status & UNKNOWN_MODE) 1788 return; |
2179 | 1789 |
2180 /* make screensaver happy */ 2181 if (scp == cur_console) { 2182 scrn_time_stamp = time.tv_sec; 2183 if (scrn_blanked) 2184 SCRN_SAVER(FALSE); 2185 } 2186 write_in_progress++; | 1790 /* make screensaver happy */ 1791 if (scp == cur_console) { 1792 scrn_time_stamp = time.tv_sec; 1793 if (scrn_blanked) 1794 (*current_saver)(FALSE); 1795 } 1796 write_in_progress++; |
2187outloop: | 1797outloop: |
2188 if (scp->term.esc) { 2189 scan_esc(scp, *ptr++); 2190 len--; | 1798 if (scp->term.esc) { 1799 scan_esc(scp, *ptr++); 1800 len--; 1801 } 1802 else if (PRINTABLE(*ptr)) { /* Print only printables */ 1803 do { 1804 *scp->cursor_pos++ = (scp->term.cur_attr | scr_map[*ptr++]); 1805 scp->xpos++; 1806 len--; 1807 } while (len && PRINTABLE(*ptr) && (scp->xpos < scp->xsize)); 1808 if (scp->xpos >= scp->xsize) { 1809 scp->xpos = 0; 1810 scp->ypos++; |
2191 } | 1811 } |
2192 else if (PRINTABLE(*ptr)) { /* Print only printables */ 2193 do { 2194 *scp->cursor_pos++ = 2195 (scp->term.cur_attr | scr_map[*ptr++]); 2196 scp->xpos++; 2197 len--; 2198 } while (len && PRINTABLE(*ptr) && (scp->xpos < scp->xsize)); 2199 if (scp->xpos >= scp->xsize) { 2200 scp->xpos = 0; 2201 scp->ypos++; 2202 } 2203 } 2204 else { 2205 switch(*ptr) { 2206 case 0x07: 2207 do_bell(scp, scp->bell_pitch, scp->bell_duration); 2208 break; 2209 case 0x08: /* non-destructive backspace */ 2210 if (scp->cursor_pos > scp->scr_buf) { 2211 scp->cursor_pos--; 2212 if (scp->xpos > 0) 2213 scp->xpos--; 2214 else { 2215 scp->xpos += scp->xsize - 1; 2216 scp->ypos--; 2217 } 2218 } 2219 break; 2220 case 0x09: /* non-destructive tab */ 2221 { 2222 int i = 8 - scp->xpos % 8u; | 1812 } 1813 else { 1814 switch(*ptr) { 1815 case 0x07: 1816 do_bell(scp, scp->bell_pitch, scp->bell_duration); 1817 break; |
2223 | 1818 |
2224 scp->cursor_pos += i; 2225 if ((scp->xpos += i) >= scp->xsize) { 2226 scp->xpos = 0; 2227 scp->ypos++; 2228 } 2229 } 2230 break; 2231 case 0x0a: /* newline, same pos */ 2232 scp->cursor_pos += scp->xsize; 2233 scp->ypos++; 2234 break; 2235 case 0x0c: /* form feed, clears screen */ 2236 clear_screen(scp); 2237 break; 2238 case 0x0d: /* return, return to pos 0 */ 2239 scp->cursor_pos -= scp->xpos; 2240 scp->xpos = 0; 2241 break; 2242 case 0x1b: /* start escape sequence */ 2243 scp->term.esc = 1; 2244 scp->term.num_param = 0; 2245 break; | 1819 case 0x08: /* non-destructive backspace */ 1820 if (scp->cursor_pos > scp->scr_buf) { 1821 scp->cursor_pos--; 1822 if (scp->xpos > 0) 1823 scp->xpos--; 1824 else { 1825 scp->xpos += scp->xsize - 1; 1826 scp->ypos--; |
2246 } | 1827 } |
2247 ptr++; len--; 2248 } 2249 /* do we have to scroll ?? */ 2250 if (scp->cursor_pos >= scp->scr_buf + scp->ysize * scp->xsize) { 2251 if (scp->history) { 2252 bcopyw(scp->scr_buf, scp->history_head, 2253 scp->xsize * sizeof(u_short)); | 1828 } 1829 break; |
2254 | 1830 |
2255 scp->history_head += scp->xsize; 2256 if (scp->history_head + scp->xsize > 2257 scp->history + scp->history_size) 2258 scp->history_head = scp->history; | 1831 case 0x09: /* non-destructive tab */ 1832 { 1833 int i = 8 - scp->xpos % 8u; 1834 1835 scp->cursor_pos += i; 1836 if ((scp->xpos += i) >= scp->xsize) { 1837 scp->xpos = 0; 1838 scp->ypos++; 1839 } |
2259 } | 1840 } |
2260 bcopyw(scp->scr_buf + scp->xsize, scp->scr_buf, 2261 scp->xsize * (scp->ysize - 1) * sizeof(u_short)); 2262 fillw(scp->term.cur_attr | scr_map[0x20], 2263 scp->scr_buf + scp->xsize * (scp->ysize - 1), 2264 scp->xsize); 2265 scp->cursor_pos -= scp->xsize; 2266 scp->ypos--; | 1841 break; 1842 1843 case 0x0a: /* newline, same pos */ 1844 scp->cursor_pos += scp->xsize; 1845 scp->ypos++; 1846 break; 1847 1848 case 0x0c: /* form feed, clears screen */ 1849 clear_screen(scp); 1850 break; 1851 1852 case 0x0d: /* return, return to pos 0 */ 1853 scp->cursor_pos -= scp->xpos; 1854 scp->xpos = 0; 1855 break; 1856 1857 case 0x1b: /* start escape sequence */ 1858 scp->term.esc = 1; 1859 scp->term.num_param = 0; 1860 break; |
2267 } | 1861 } |
2268 if (len) 2269 goto outloop; 2270 write_in_progress--; 2271 if (delayed_next_scr) 2272 switch_scr(scp, delayed_next_scr - 1); | 1862 ptr++; len--; 1863 } 1864 /* do we have to scroll ?? */ 1865 if (scp->cursor_pos >= scp->scr_buf + scp->ysize * scp->xsize) { 1866 if (scp->history) { 1867 bcopyw(scp->scr_buf, scp->history_head, 1868 scp->xsize * sizeof(u_short)); 1869 scp->history_head += scp->xsize; 1870 if (scp->history_head + scp->xsize > 1871 scp->history + scp->history_size) 1872 scp->history_head = scp->history; 1873 } 1874 bcopyw(scp->scr_buf + scp->xsize, scp->scr_buf, 1875 scp->xsize * (scp->ysize - 1) * sizeof(u_short)); 1876 fillw(scp->term.cur_attr | scr_map[0x20], 1877 scp->scr_buf + scp->xsize * (scp->ysize - 1), 1878 scp->xsize); 1879 scp->cursor_pos -= scp->xsize; 1880 scp->ypos--; 1881 } 1882 if (len) 1883 goto outloop; 1884 write_in_progress--; 1885 if (delayed_next_scr) 1886 switch_scr(scp, delayed_next_scr - 1); |
2273} 2274 2275static void 2276scinit(void) 2277{ | 1887} 1888 1889static void 1890scinit(void) 1891{ |
2278 u_short volatile *cp = Crtat + (CGA_BUF-MONO_BUF)/sizeof(u_short), was; 2279 unsigned hw_cursor; 2280 int i; | 1892 u_short volatile *cp = Crtat + (CGA_BUF-MONO_BUF)/sizeof(u_short), was; 1893 unsigned hw_cursor; 1894 int i; |
2281 | 1895 |
2282 if (init_done) 2283 return; 2284 init_done = TRUE; 2285 /* 2286 * Crtat initialized to point to MONO buffer, if not present change 2287 * to CGA_BUF offset. ONLY add the difference since locore.s adds 2288 * in the remapped offset at the "right" time 2289 */ 2290 was = *cp; 2291 *cp = (u_short) 0xA55A; 2292 if (*cp != 0xA55A) 2293 crtc_addr = MONO_BASE; 2294 else { 2295 *cp = was; 2296 crtc_addr = COLOR_BASE; 2297 Crtat = Crtat + (CGA_BUF-MONO_BUF)/sizeof(u_short); 2298 } | 1896 if (init_done) 1897 return; 1898 init_done = TRUE; 1899 /* 1900 * Crtat initialized to point to MONO buffer, if not present change 1901 * to CGA_BUF offset. ONLY add the difference since locore.s adds 1902 * in the remapped offset at the "right" time 1903 */ 1904 was = *cp; 1905 *cp = (u_short) 0xA55A; 1906 if (*cp != 0xA55A) 1907 crtc_addr = MONO_BASE; 1908 else { 1909 *cp = was; 1910 crtc_addr = COLOR_BASE; 1911 Crtat = Crtat + (CGA_BUF-MONO_BUF)/sizeof(u_short); 1912 } |
2299 | 1913 |
2300 /* extract cursor location */ 2301 outb(crtc_addr,14); 2302 hw_cursor = inb(crtc_addr+1)<<8 ; 2303 outb(crtc_addr,15); 2304 hw_cursor |= inb(crtc_addr+1); | 1914 /* extract cursor location */ 1915 outb(crtc_addr,14); 1916 hw_cursor = inb(crtc_addr+1)<<8 ; 1917 outb(crtc_addr,15); 1918 hw_cursor |= inb(crtc_addr+1); |
2305 | 1919 |
2306 /* move hardware cursor out of the way */ 2307 outb(crtc_addr,14); 2308 outb(crtc_addr+1, 0xff); 2309 outb(crtc_addr,15); 2310 outb(crtc_addr+1, 0xff); | 1920 /* move hardware cursor out of the way */ 1921 outb(crtc_addr,14); 1922 outb(crtc_addr+1, 0xff); 1923 outb(crtc_addr,15); 1924 outb(crtc_addr+1, 0xff); |
2311 | 1925 |
2312 /* is this a VGA or higher ? */ 2313 outb(crtc_addr, 7); 2314 if (inb(crtc_addr) == 7) { 2315 u_long pa; 2316 u_long segoff; | 1926 /* is this a VGA or higher ? */ 1927 outb(crtc_addr, 7); 1928 if (inb(crtc_addr) == 7) { 1929 u_long pa; 1930 u_long segoff; |
2317 | 1931 |
2318 crtc_vga = TRUE; | 1932 crtc_vga = TRUE; |
2319 | 1933 |
2320 /* 2321 * Get the BIOS video mode pointer. 2322 */ 2323 segoff = *(u_long *)pa_to_va(0x4a8); 2324 pa = (((segoff & 0xffff0000) >> 12) + (segoff & 0xffff)); 2325 if (ISMAPPED(pa, sizeof(u_long))) { 2326 segoff = *(u_long *)pa_to_va(pa); 2327 pa = (((segoff & 0xffff0000) >> 12) 2328 + (segoff & 0xffff)); 2329 if (ISMAPPED(pa, 64)) 2330 video_mode_ptr = (char *)pa_to_va(pa); 2331 } | 1934 /* 1935 * Get the BIOS video mode pointer. 1936 */ 1937 segoff = *(u_long *)pa_to_va(0x4a8); 1938 pa = (((segoff & 0xffff0000) >> 12) + (segoff & 0xffff)); 1939 if (ISMAPPED(pa, sizeof(u_long))) { 1940 segoff = *(u_long *)pa_to_va(pa); 1941 pa = (((segoff & 0xffff0000) >> 12) + (segoff & 0xffff)); 1942 if (ISMAPPED(pa, 64)) 1943 video_mode_ptr = (char *)pa_to_va(pa); |
2332 } | 1944 } |
2333 current_default = &user_default; 2334 console[0] = &main_console; 2335 init_scp(console[0]); 2336 console[0]->scr_buf = console[0]->mouse_pos = Crtat; 2337 console[0]->cursor_pos = Crtat + hw_cursor; 2338 console[0]->xpos = hw_cursor % COL; 2339 console[0]->ypos = hw_cursor / COL; 2340 cur_console = console[0]; 2341 for (i=1; i<MAXCONS; i++) 2342 console[i] = NULL; 2343 kernel_console.esc = 0; 2344 kernel_console.std_attr = kernel_default.std_attr; 2345 kernel_console.rev_attr = kernel_default.rev_attr; 2346 kernel_console.cur_attr = kernel_default.std_attr; 2347 /* initialize mapscrn array to a one to one map */ 2348 for (i=0; i<sizeof(scr_map); i++) 2349 scr_map[i] = i; | 1945 } 1946 current_default = &user_default; 1947 console[0] = &main_console; 1948 init_scp(console[0]); 1949 console[0]->scr_buf = console[0]->mouse_pos = Crtat; 1950 console[0]->cursor_pos = Crtat + hw_cursor; 1951 console[0]->xpos = hw_cursor % COL; 1952 console[0]->ypos = hw_cursor / COL; 1953 cur_console = console[0]; 1954 for (i=1; i<MAXCONS; i++) 1955 console[i] = NULL; 1956 kernel_console.esc = 0; 1957 kernel_console.std_attr = kernel_default.std_attr; 1958 kernel_console.rev_attr = kernel_default.rev_attr; 1959 kernel_console.cur_attr = kernel_default.std_attr; 1960 /* initialize mapscrn array to a one to one map */ 1961 for (i=0; i<sizeof(scr_map); i++) 1962 scr_map[i] = i; |
2350} 2351 2352static scr_stat 2353*alloc_scp() 2354{ | 1963} 1964 1965static scr_stat 1966*alloc_scp() 1967{ |
2355 scr_stat *scp; | 1968 scr_stat *scp; |
2356 | 1969 |
2357 scp = (scr_stat *)malloc(sizeof(scr_stat), M_DEVBUF, M_NOWAIT); 2358 init_scp(scp); 2359 scp->scr_buf = scp->cursor_pos = scp->scr_buf = scp->mouse_pos = 2360 (u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short), 2361 M_DEVBUF, M_NOWAIT); 2362 scp->history_head = scp->history_pos = scp->history = 2363 (u_short *)malloc(scp->history_size*sizeof(u_short), 2364 M_DEVBUF, M_NOWAIT); 2365 bzero(scp->history_head, scp->history_size*sizeof(u_short)); 2366 if (crtc_vga && video_mode_ptr) 2367 set_mode(scp); 2368 clear_screen(scp); 2369 return scp; | 1970 scp = (scr_stat *)malloc(sizeof(scr_stat), M_DEVBUF, M_NOWAIT); 1971 init_scp(scp); 1972 scp->scr_buf = scp->cursor_pos = scp->scr_buf = scp->mouse_pos = 1973 (u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short), 1974 M_DEVBUF, M_NOWAIT); 1975 scp->history_head = scp->history_pos = scp->history = 1976 (u_short *)malloc(scp->history_size*sizeof(u_short), 1977 M_DEVBUF, M_NOWAIT); 1978 bzero(scp->history_head, scp->history_size*sizeof(u_short)); 1979 if (crtc_vga && video_mode_ptr) 1980 set_mode(scp); 1981 clear_screen(scp); 1982 return scp; |
2370} 2371 2372static void 2373init_scp(scr_stat *scp) 2374{ | 1983} 1984 1985static void 1986init_scp(scr_stat *scp) 1987{ |
2375 scp->mode = M_VGA_C80x25; 2376 scp->font = FONT_16; 2377 scp->xsize = COL; 2378 scp->ysize = ROW; 2379 scp->term.esc = 0; 2380 scp->term.std_attr = current_default->std_attr; 2381 scp->term.rev_attr = current_default->rev_attr; 2382 scp->term.cur_attr = scp->term.std_attr; 2383 scp->border = BG_BLACK; 2384 scp->cursor_start = -1; 2385 scp->cursor_end = -1; 2386 scp->mouse_xpos = scp->mouse_ypos = 0; 2387 scp->bell_pitch = BELL_PITCH; 2388 scp->bell_duration = BELL_DURATION; 2389 scp->status = (*(char *)pa_to_va(0x417) & 0x20) ? NLKED : 0; 2390 scp->status |= CURSOR_ENABLED; 2391 scp->pid = 0; 2392 scp->proc = NULL; 2393 scp->smode.mode = VT_AUTO; 2394 scp->history_head = scp->history_pos = scp->history = NULL; 2395 scp->history_size = HISTORY_SIZE; | 1988 scp->mode = M_VGA_C80x25; 1989 scp->font = FONT_16; 1990 scp->xsize = COL; 1991 scp->ysize = ROW; 1992 scp->term.esc = 0; 1993 scp->term.std_attr = current_default->std_attr; 1994 scp->term.rev_attr = current_default->rev_attr; 1995 scp->term.cur_attr = scp->term.std_attr; 1996 scp->border = BG_BLACK; 1997 scp->cursor_start = -1; 1998 scp->cursor_end = -1; 1999 scp->mouse_xpos = scp->mouse_ypos = 0; 2000 scp->bell_pitch = BELL_PITCH; 2001 scp->bell_duration = BELL_DURATION; 2002 scp->status = (*(char *)pa_to_va(0x417) & 0x20) ? NLKED : 0; 2003 scp->status |= CURSOR_ENABLED; 2004 scp->pid = 0; 2005 scp->proc = NULL; 2006 scp->smode.mode = VT_AUTO; 2007 scp->history_head = scp->history_pos = scp->history = NULL; 2008 scp->history_size = HISTORY_SIZE; |
2396} 2397 | 2009} 2010 |
2398static void 2399scput(u_char c) 2400{ 2401 scr_stat *scp; 2402 term_stat save; 2403 2404 scp = console[0]; 2405 save = scp->term; 2406 scp->term = kernel_console; 2407 current_default = &kernel_default; 2408 if (scp->scr_buf == Crtat) 2409 draw_cursor(scp, FALSE); 2410 ansi_put(scp, &c, 1); 2411 scp->status |= UPDATE_SCREEN; 2412 kernel_console = scp->term; 2413 current_default = &user_default; 2414 scp->term = save; 2415 if (scp == cur_console /* && scrn_timer not running */) { 2416 if (scp->scr_buf != Crtat) { 2417 bcopyw(scp->scr_buf, Crtat, 2418 (scp->xsize*scp->ysize)*sizeof(u_short)); 2419 scp->status &= ~CURSOR_SHOWN; 2420 } 2421 draw_cursor(scp, TRUE); 2422 scp->status &= ~UPDATE_SCREEN; 2423 } 2424} 2425 | |
2426static u_char 2427*get_fstr(u_int c, u_int *len) 2428{ | 2011static u_char 2012*get_fstr(u_int c, u_int *len) 2013{ |
2429 u_int i; | 2014 u_int i; |
2430 | 2015 |
2431 if (!(c & FKEY)) 2432 return(NULL); 2433 i = (c & 0xFF) - F_FN; 2434 if (i > n_fkey_tab) 2435 return(NULL); 2436 *len = fkey_tab[i].len; 2437 return(fkey_tab[i].str); | 2016 if (!(c & FKEY)) 2017 return(NULL); 2018 i = (c & 0xFF) - F_FN; 2019 if (i > n_fkey_tab) 2020 return(NULL); 2021 *len = fkey_tab[i].len; 2022 return(fkey_tab[i].str); |
2438} 2439 2440static void 2441update_leds(int which) 2442{ | 2023} 2024 2025static void 2026update_leds(int which) 2027{ |
2443 int s; 2444 static u_char xlate_leds[8] = { 0, 4, 2, 6, 1, 5, 3, 7 }; | 2028 int s; 2029 static u_char xlate_leds[8] = { 0, 4, 2, 6, 1, 5, 3, 7 }; |
2445 | 2030 |
2446 /* replace CAPS led with ALTGR led for ALTGR keyboards */ 2447 if (key_map.n_keys > ALTGR_OFFSET) { 2448 if (which & ALKED) 2449 which |= CLKED; 2450 else 2451 which &= ~CLKED; 2452 } 2453 s = spltty(); 2454 kbd_cmd(KB_SETLEDS); 2455 kbd_cmd(xlate_leds[which & LED_MASK]); 2456 splx(s); | 2031 /* replace CAPS led with ALTGR led for ALTGR keyboards */ 2032 if (key_map.n_keys > ALTGR_OFFSET) { 2033 if (which & ALKED) 2034 which |= CLKED; 2035 else 2036 which &= ~CLKED; 2037 } 2038 s = spltty(); 2039 kbd_cmd(KB_SETLEDS); 2040 kbd_cmd(xlate_leds[which & LED_MASK]); 2041 splx(s); |
2457} 2458 2459static void 2460history_to_screen(scr_stat *scp) 2461{ | 2042} 2043 2044static void 2045history_to_screen(scr_stat *scp) 2046{ |
2462 int i; | 2047 int i; |
2463 | 2048 |
2464 scp->status &= ~UPDATE_SCREEN; 2465 for (i=0; i<scp->ysize; i++) 2466 bcopyw(scp->history + (((scp->history_pos - scp->history) + 2467 scp->history_size-((i+1)*scp->xsize))%scp->history_size), 2468 scp->scr_buf + (scp->xsize * (scp->ysize-1 - i)), 2469 scp->xsize * sizeof(u_short)); 2470 scp->status |= UPDATE_SCREEN; | 2049 scp->status &= ~UPDATE_SCREEN; 2050 for (i=0; i<scp->ysize; i++) 2051 bcopyw(scp->history + (((scp->history_pos - scp->history) + 2052 scp->history_size-((i+1)*scp->xsize))%scp->history_size), 2053 scp->scr_buf + (scp->xsize * (scp->ysize-1 - i)), 2054 scp->xsize * sizeof(u_short)); 2055 scp->status |= UPDATE_SCREEN; |
2471} 2472 2473static int 2474history_up_line(scr_stat *scp) 2475{ | 2056} 2057 2058static int 2059history_up_line(scr_stat *scp) 2060{ |
2476 if (WRAPHIST(scp, scp->history_pos, -(scp->xsize*scp->ysize)) != 2477 scp->history_head) { 2478 scp->history_pos = WRAPHIST(scp, scp->history_pos, -scp->xsize); 2479 history_to_screen(scp); 2480 return 0; 2481 } 2482 else 2483 return -1; | 2061 if (WRAPHIST(scp, scp->history_pos, -(scp->xsize*scp->ysize)) != 2062 scp->history_head) { 2063 scp->history_pos = WRAPHIST(scp, scp->history_pos, -scp->xsize); 2064 history_to_screen(scp); 2065 return 0; 2066 } 2067 else 2068 return -1; |
2484} 2485 2486static int 2487history_down_line(scr_stat *scp) 2488{ | 2069} 2070 2071static int 2072history_down_line(scr_stat *scp) 2073{ |
2489 if (scp->history_pos != scp->history_head) { 2490 scp->history_pos = WRAPHIST(scp, scp->history_pos, scp->xsize); 2491 history_to_screen(scp); 2492 return 0; 2493 } 2494 else 2495 return -1; | 2074 if (scp->history_pos != scp->history_head) { 2075 scp->history_pos = WRAPHIST(scp, scp->history_pos, scp->xsize); 2076 history_to_screen(scp); 2077 return 0; 2078 } 2079 else 2080 return -1; |
2496} 2497 2498/* 2499 * scgetc(noblock) - get character from keyboard. 2500 * If noblock = 0 wait until a key is pressed. 2501 * Else return NOKEY. 2502 */ 2503u_int 2504scgetc(int noblock) 2505{ | 2081} 2082 2083/* 2084 * scgetc(noblock) - get character from keyboard. 2085 * If noblock = 0 wait until a key is pressed. 2086 * Else return NOKEY. 2087 */ 2088u_int 2089scgetc(int noblock) 2090{ |
2506 u_char scancode, keycode; 2507 u_int state, action; 2508 struct key_t *key; 2509 static u_char esc_flag = 0, compose = 0; 2510 static u_int chr = 0; | 2091 u_char scancode, keycode; 2092 u_int state, action; 2093 struct key_t *key; 2094 static u_char esc_flag = 0, compose = 0; 2095 static u_int chr = 0; |
2511 2512next_code: | 2096 2097next_code: |
2513 kbd_wait(); 2514 /* First see if there is something in the keyboard port */ 2515 if (inb(KB_STAT) & KB_BUF_FULL) 2516 scancode = inb(KB_DATA); 2517 else if (noblock) 2518 return(NOKEY); 2519 else 2520 goto next_code; | 2098 kbd_wait(); 2099 /* First see if there is something in the keyboard port */ 2100 if (inb(KB_STAT) & KB_BUF_FULL) 2101 scancode = inb(KB_DATA); 2102 else if (noblock) 2103 return(NOKEY); 2104 else 2105 goto next_code; |
2521 | 2106 |
2522 if (cur_console->status & KBD_RAW_MODE) 2523 return scancode; | 2107 if (cur_console->status & KBD_RAW_MODE) 2108 return scancode; |
2524#if ASYNCH | 2109#if ASYNCH |
2525 if (scancode == KB_ACK || scancode == KB_RESEND) { 2526 kbd_reply = scancode; 2527 if (noblock) 2528 return(NOKEY); 2529 goto next_code; 2530 } | 2110 if (scancode == KB_ACK || scancode == KB_RESEND) { 2111 kbd_reply = scancode; 2112 if (noblock) 2113 return(NOKEY); 2114 goto next_code; 2115 } |
2531#endif | 2116#endif |
2532 keycode = scancode & 0x7F; 2533 switch (esc_flag) { 2534 case 0x00: /* normal scancode */ 2535 switch(scancode) { 2536 case 0xB8: /* left alt (compose key) */ 2537 if (compose) { 2538 compose = 0; 2539 if (chr > 255) { 2540 do_bell(cur_console, 2541 BELL_PITCH, BELL_DURATION); 2542 chr = 0; 2543 } 2544 } 2545 break; 2546 case 0x38: 2547 if (!compose) { 2548 compose = 1; 2549 chr = 0; 2550 } 2551 break; 2552 case 0xE0: 2553 case 0xE1: 2554 esc_flag = scancode; 2555 goto next_code; | 2117 keycode = scancode & 0x7F; 2118 switch (esc_flag) { 2119 case 0x00: /* normal scancode */ 2120 switch(scancode) { 2121 case 0xB8: /* left alt (compose key) */ 2122 if (compose) { 2123 compose = 0; 2124 if (chr > 255) { 2125 do_bell(cur_console, 2126 BELL_PITCH, BELL_DURATION); 2127 chr = 0; |
2556 } | 2128 } |
2557 break; 2558 case 0xE0: /* 0xE0 prefix */ 2559 esc_flag = 0; 2560 switch (keycode) { 2561 case 0x1C: /* right enter key */ 2562 keycode = 0x59; 2563 break; 2564 case 0x1D: /* right ctrl key */ 2565 keycode = 0x5A; 2566 break; 2567 case 0x35: /* keypad divide key */ 2568 keycode = 0x5B; 2569 break; 2570 case 0x37: /* print scrn key */ 2571 keycode = 0x5C; 2572 break; 2573 case 0x38: /* right alt key (alt gr) */ 2574 keycode = 0x5D; 2575 break; 2576 case 0x47: /* grey home key */ 2577 keycode = 0x5E; 2578 break; 2579 case 0x48: /* grey up arrow key */ 2580 keycode = 0x5F; 2581 break; 2582 case 0x49: /* grey page up key */ 2583 keycode = 0x60; 2584 break; 2585 case 0x4B: /* grey left arrow key */ 2586 keycode = 0x61; 2587 break; 2588 case 0x4D: /* grey right arrow key */ 2589 keycode = 0x62; 2590 break; 2591 case 0x4F: /* grey end key */ 2592 keycode = 0x63; 2593 break; 2594 case 0x50: /* grey down arrow key */ 2595 keycode = 0x64; 2596 break; 2597 case 0x51: /* grey page down key */ 2598 keycode = 0x65; 2599 break; 2600 case 0x52: /* grey insert key */ 2601 keycode = 0x66; 2602 break; 2603 case 0x53: /* grey delete key */ 2604 keycode = 0x67; 2605 break; | 2129 } 2130 break; 2131 case 0x38: 2132 if (!compose) { 2133 compose = 1; 2134 chr = 0; 2135 } 2136 break; 2137 case 0xE0: 2138 case 0xE1: 2139 esc_flag = scancode; 2140 goto next_code; 2141 } 2142 break; 2143 case 0xE0: /* 0xE0 prefix */ 2144 esc_flag = 0; 2145 switch (keycode) { 2146 case 0x1C: /* right enter key */ 2147 keycode = 0x59; 2148 break; 2149 case 0x1D: /* right ctrl key */ 2150 keycode = 0x5A; 2151 break; 2152 case 0x35: /* keypad divide key */ 2153 keycode = 0x5B; 2154 break; 2155 case 0x37: /* print scrn key */ 2156 keycode = 0x5C; 2157 break; 2158 case 0x38: /* right alt key (alt gr) */ 2159 keycode = 0x5D; 2160 break; 2161 case 0x47: /* grey home key */ 2162 keycode = 0x5E; 2163 break; 2164 case 0x48: /* grey up arrow key */ 2165 keycode = 0x5F; 2166 break; 2167 case 0x49: /* grey page up key */ 2168 keycode = 0x60; 2169 break; 2170 case 0x4B: /* grey left arrow key */ 2171 keycode = 0x61; 2172 break; 2173 case 0x4D: /* grey right arrow key */ 2174 keycode = 0x62; 2175 break; 2176 case 0x4F: /* grey end key */ 2177 keycode = 0x63; 2178 break; 2179 case 0x50: /* grey down arrow key */ 2180 keycode = 0x64; 2181 break; 2182 case 0x51: /* grey page down key */ 2183 keycode = 0x65; 2184 break; 2185 case 0x52: /* grey insert key */ 2186 keycode = 0x66; 2187 break; 2188 case 0x53: /* grey delete key */ 2189 keycode = 0x67; 2190 break; |
2606 | 2191 |
2607 /* the following 3 are only used on the MS "Natural" keyboard */ 2608 case 0x5b: /* left Window key */ 2609 keycode = 0x69; 2610 break; 2611 case 0x5c: /* right Window key */ 2612 keycode = 0x6a; 2613 break; 2614 case 0x5d: /* menu key */ 2615 keycode = 0x6b; 2616 break; 2617 default: /* ignore everything else */ 2618 goto next_code; 2619 } 2620 break; 2621 case 0xE1: /* 0xE1 prefix */ 2622 esc_flag = 0; 2623 if (keycode == 0x1D) 2624 esc_flag = 0x1D; 2625 goto next_code; 2626 /* NOT REACHED */ 2627 case 0x1D: /* pause / break */ 2628 esc_flag = 0; 2629 if (keycode != 0x45) 2630 goto next_code; 2631 keycode = 0x68; 2632 break; | 2192 /* the following 3 are only used on the MS "Natural" keyboard */ 2193 case 0x5b: /* left Window key */ 2194 keycode = 0x69; 2195 break; 2196 case 0x5c: /* right Window key */ 2197 keycode = 0x6a; 2198 break; 2199 case 0x5d: /* menu key */ 2200 keycode = 0x6b; 2201 break; 2202 default: /* ignore everything else */ 2203 goto next_code; |
2633 } | 2204 } |
2205 break; 2206 case 0xE1: /* 0xE1 prefix */ 2207 esc_flag = 0; 2208 if (keycode == 0x1D) 2209 esc_flag = 0x1D; 2210 goto next_code; 2211 /* NOT REACHED */ 2212 case 0x1D: /* pause / break */ 2213 esc_flag = 0; 2214 if (keycode != 0x45) 2215 goto next_code; 2216 keycode = 0x68; 2217 break; 2218 } |
|
2634 | 2219 |
2635 /* if scroll-lock pressed allow history browsing */ 2636 if (cur_console->history && cur_console->status & SLKED) { 2637 int i; | 2220 /* if scroll-lock pressed allow history browsing */ 2221 if (cur_console->history && cur_console->status & SLKED) { 2222 int i; |
2638 | 2223 |
2639 cur_console->status &= ~CURSOR_ENABLED; 2640 if (!(cur_console->status & BUFFER_SAVED)) { 2641 cur_console->status |= BUFFER_SAVED; 2642 cur_console->history_save = cur_console->history_head; 2643 /* copy screen into top of history buffer */ 2644 for (i=0; i<cur_console->ysize; i++) { 2645 bcopyw(cur_console->scr_buf + (cur_console->xsize * i), 2646 cur_console->history_head, 2647 cur_console->xsize * sizeof(u_short)); | 2224 cur_console->status &= ~CURSOR_ENABLED; 2225 if (!(cur_console->status & BUFFER_SAVED)) { 2226 cur_console->status |= BUFFER_SAVED; 2227 cur_console->history_save = cur_console->history_head; |
2648 | 2228 |
2649 cur_console->history_head += cur_console->xsize; 2650 if (cur_console->history_head + cur_console->xsize > 2651 cur_console->history + cur_console->history_size) 2652 cur_console->history_head=cur_console->history; 2653 } 2654 cur_console->history_pos = cur_console->history_head; 2655 history_to_screen(cur_console); 2656 } 2657 switch (scancode) { 2658 case 0x47: /* home key */ 2659 cur_console->history_pos = cur_console->history_head; 2660 history_to_screen(cur_console); 2661 goto next_code; | 2229 /* copy screen into top of history buffer */ 2230 for (i=0; i<cur_console->ysize; i++) { 2231 bcopyw(cur_console->scr_buf + (cur_console->xsize * i), 2232 cur_console->history_head, 2233 cur_console->xsize * sizeof(u_short)); 2234 cur_console->history_head += cur_console->xsize; 2235 if (cur_console->history_head + cur_console->xsize > 2236 cur_console->history + cur_console->history_size) 2237 cur_console->history_head=cur_console->history; 2238 } 2239 cur_console->history_pos = cur_console->history_head; 2240 history_to_screen(cur_console); 2241 } 2242 switch (scancode) { 2243 case 0x47: /* home key */ 2244 cur_console->history_pos = cur_console->history_head; 2245 history_to_screen(cur_console); 2246 goto next_code; |
2662 | 2247 |
2663 case 0x4F: /* end key */ 2664 cur_console->history_pos = 2665 WRAPHIST(cur_console, cur_console->history_head, 2666 cur_console->xsize*cur_console->ysize); 2667 history_to_screen(cur_console); 2668 goto next_code; | 2248 case 0x4F: /* end key */ 2249 cur_console->history_pos = 2250 WRAPHIST(cur_console, cur_console->history_head, 2251 cur_console->xsize*cur_console->ysize); 2252 history_to_screen(cur_console); 2253 goto next_code; |
2669 | 2254 |
2670 case 0x48: /* up arrow key */ 2671 if (history_up_line(cur_console)) 2672 do_bell(cur_console, BELL_PITCH, BELL_DURATION); 2673 goto next_code; | 2255 case 0x48: /* up arrow key */ 2256 if (history_up_line(cur_console)) 2257 do_bell(cur_console, BELL_PITCH, BELL_DURATION); 2258 goto next_code; |
2674 | 2259 |
2675 case 0x50: /* down arrow key */ 2676 if (history_down_line(cur_console)) 2677 do_bell(cur_console, BELL_PITCH, BELL_DURATION); 2678 goto next_code; | 2260 case 0x50: /* down arrow key */ 2261 if (history_down_line(cur_console)) 2262 do_bell(cur_console, BELL_PITCH, BELL_DURATION); 2263 goto next_code; |
2679 | 2264 |
2680 case 0x49: /* page up key */ 2681 for (i=0; i<cur_console->ysize; i++) 2682 if (history_up_line(cur_console)) { 2683 do_bell(cur_console, BELL_PITCH, BELL_DURATION); 2684 break; 2685 } 2686 goto next_code; | 2265 case 0x49: /* page up key */ 2266 for (i=0; i 2267 if (history_up_line(cur_console)) { 2268 do_bell(cur_console, BELL_PITCH, BELL_DURATION); 2269 break; 2270 } 2271 goto next_code; |
2687 | 2272 |
2688 case 0x51: /* page down key */ 2689 for (i=0; i<cur_console->ysize; i++) 2690 if (history_down_line(cur_console)) { 2691 do_bell(cur_console, BELL_PITCH, BELL_DURATION); 2692 break; 2693 } 2694 goto next_code; 2695 } | 2273 case 0x51: /* page down key */ 2274 for (i=0; i 2275 if (history_down_line(cur_console)) { 2276 do_bell(cur_console, BELL_PITCH, BELL_DURATION); 2277 break; 2278 } 2279 goto next_code; |
2696 } | 2280 } |
2281 } |
|
2697 | 2282 |
2698 if (compose) { 2699 switch (scancode) { 2700 /* key pressed process it */ 2701 case 0x47: case 0x48: case 0x49: /* keypad 7,8,9 */ 2702 chr = (scancode - 0x40) + chr*10; 2703 goto next_code; 2704 case 0x4B: case 0x4C: case 0x4D: /* keypad 4,5,6 */ 2705 chr = (scancode - 0x47) + chr*10; 2706 goto next_code; 2707 case 0x4F: case 0x50: case 0x51: /* keypad 1,2,3 */ 2708 chr = (scancode - 0x4E) + chr*10; 2709 goto next_code; 2710 case 0x52: /* keypad 0 */ 2711 chr *= 10; 2712 goto next_code; | 2283 if (compose) { 2284 switch (scancode) { 2285 /* key pressed process it */ 2286 case 0x47: case 0x48: case 0x49: /* keypad 7,8,9 */ 2287 chr = (scancode - 0x40) + chr*10; 2288 goto next_code; 2289 case 0x4B: case 0x4C: case 0x4D: /* keypad 4,5,6 */ 2290 chr = (scancode - 0x47) + chr*10; 2291 goto next_code; 2292 case 0x4F: case 0x50: case 0x51: /* keypad 1,2,3 */ 2293 chr = (scancode - 0x4E) + chr*10; 2294 goto next_code; 2295 case 0x52: /* keypad 0 */ 2296 chr *= 10; 2297 goto next_code; |
2713 | 2298 |
2714 /* key release, no interest here */ 2715 case 0xC7: case 0xC8: case 0xC9: /* keypad 7,8,9 */ 2716 case 0xCB: case 0xCC: case 0xCD: /* keypad 4,5,6 */ 2717 case 0xCF: case 0xD0: case 0xD1: /* keypad 1,2,3 */ 2718 case 0xD2: /* keypad 0 */ 2719 goto next_code; | 2299 /* key release, no interest here */ 2300 case 0xC7: case 0xC8: case 0xC9: /* keypad 7,8,9 */ 2301 case 0xCB: case 0xCC: case 0xCD: /* keypad 4,5,6 */ 2302 case 0xCF: case 0xD0: case 0xD1: /* keypad 1,2,3 */ 2303 case 0xD2: /* keypad 0 */ 2304 goto next_code; |
2720 | 2305 |
2721 case 0x38: /* left alt key */ 2722 break; 2723 default: 2724 if (chr) { 2725 compose = chr = 0; 2726 do_bell(cur_console, BELL_PITCH, BELL_DURATION); 2727 goto next_code; 2728 } 2729 break; 2730 } | 2306 case 0x38: /* left alt key */ 2307 break; 2308 default: 2309 if (chr) { 2310 compose = chr = 0; 2311 do_bell(cur_console, BELL_PITCH, BELL_DURATION); 2312 goto next_code; 2313 } 2314 break; |
2731 } | 2315 } |
2732 2733 state = (shfts ? 1 : 0 ) | (2 * (ctls ? 1 : 0)) | (4 * (alts ? 1 : 0)); 2734 if ((!agrs && (cur_console->status & ALKED)) 2735 || (agrs && !(cur_console->status & ALKED))) 2736 keycode += ALTGR_OFFSET; 2737 key = &key_map.key[keycode]; 2738 if ( ((key->flgs & FLAG_LOCK_C) && (cur_console->status & CLKED)) 2739 || ((key->flgs & FLAG_LOCK_N) && (cur_console->status & NLKED)) ) 2740 state ^= 1; | 2316 } 2317 2318 state = (shfts ? 1 : 0 ) | (2 * (ctls ? 1 : 0)) | (4 * (alts ? 1 : 0)); 2319 if ((!agrs && (cur_console->status & ALKED)) 2320 || (agrs && !(cur_console->status & ALKED))) 2321 keycode += ALTGR_OFFSET; 2322 key = &key_map.key[keycode]; 2323 if ( ((key->flgs & FLAG_LOCK_C) && (cur_console->status & CLKED)) 2324 || ((key->flgs & FLAG_LOCK_N) && (cur_console->status & NLKED)) ) 2325 state ^= 1; |
2741 | 2326 |
2742 /* Check for make/break */ 2743 action = key->map[state]; 2744 if (scancode & 0x80) { /* key released */ 2745 if (key->spcl & 0x80) { 2746 switch (action) { 2747 case LSH: 2748 shfts &= ~1; 2749 break; 2750 case RSH: 2751 shfts &= ~2; 2752 break; 2753 case LCTR: 2754 ctls &= ~1; 2755 break; 2756 case RCTR: 2757 ctls &= ~2; 2758 break; 2759 case LALT: 2760 alts &= ~1; 2761 break; 2762 case RALT: 2763 alts &= ~2; 2764 break; 2765 case NLK: 2766 nlkcnt = 0; 2767 break; 2768 case CLK: 2769 clkcnt = 0; 2770 break; 2771 case SLK: 2772 slkcnt = 0; 2773 break; 2774 case ASH: 2775 agrs = 0; 2776 break; 2777 case ALK: 2778 alkcnt = 0; 2779 break; 2780 case META: 2781 metas = 0; 2782 break; | 2327 /* Check for make/break */ 2328 action = key->map[state]; 2329 if (scancode & 0x80) { /* key released */ 2330 if (key->spcl & 0x80) { 2331 switch (action) { 2332 case LSH: 2333 shfts &= ~1; 2334 break; 2335 case RSH: 2336 shfts &= ~2; 2337 break; 2338 case LCTR: 2339 ctls &= ~1; 2340 break; 2341 case RCTR: 2342 ctls &= ~2; 2343 break; 2344 case LALT: 2345 alts &= ~1; 2346 break; 2347 case RALT: 2348 alts &= ~2; 2349 break; 2350 case NLK: 2351 nlkcnt = 0; 2352 break; 2353 case CLK: 2354 clkcnt = 0; 2355 break; 2356 case SLK: 2357 slkcnt = 0; 2358 break; 2359 case ASH: 2360 agrs = 0; 2361 break; 2362 case ALK: 2363 alkcnt = 0; 2364 break; 2365 case META: 2366 metas = 0; 2367 break; 2368 } 2369 } 2370 if (chr && !compose) { 2371 action = chr; 2372 chr = 0; 2373 return(action); 2374 } 2375 } else { 2376 /* key pressed */ 2377 if (key->spcl & (0x80>>state)) { 2378 switch (action) { 2379 /* LOCKING KEYS */ 2380 case NLK: 2381 if (!nlkcnt) { 2382 nlkcnt++; 2383 if (cur_console->status & NLKED) 2384 cur_console->status &= ~NLKED; 2385 else 2386 cur_console->status |= NLKED; 2387 update_leds(cur_console->status); 2388 } 2389 break; 2390 case CLK: 2391 if (!clkcnt) { 2392 clkcnt++; 2393 if (cur_console->status & CLKED) 2394 cur_console->status &= ~CLKED; 2395 else 2396 cur_console->status |= CLKED; 2397 update_leds(cur_console->status); 2398 } 2399 break; 2400 case SLK: 2401 if (!slkcnt) { 2402 slkcnt++; 2403 if (cur_console->status & SLKED) { 2404 cur_console->status &= ~SLKED; 2405 if (cur_console->status & BUFFER_SAVED){ 2406 int i; 2407 u_short *ptr = cur_console->history_save; 2408 2409 for (i=0; i<cur_console->ysize; i++) { 2410 bcopyw(ptr, 2411 cur_console->scr_buf + 2412 (cur_console->xsize*i), 2413 cur_console->xsize * sizeof(u_short)); 2414 ptr += cur_console->xsize; 2415 if (ptr + cur_console->xsize > 2416 cur_console->history + 2417 cur_console->history_size) 2418 ptr = cur_console->history; 2419 } 2420 cur_console->status&=~BUFFER_SAVED; 2421 cur_console->history_head=cur_console->history_save; 2422 cur_console->status|=(CURSOR_ENABLED|UPDATE_SCREEN); |
2783 } | 2423 } |
2424 scstart(VIRTUAL_TTY(get_scr_num())); 2425 } 2426 else 2427 cur_console->status |= SLKED; 2428 update_leds(cur_console->status); |
|
2784 } | 2429 } |
2785 if (chr && !compose) { 2786 action = chr; 2787 chr = 0; 2788 return(action); | 2430 break; 2431 case ALK: 2432 if (!alkcnt) { 2433 alkcnt++; 2434 if (cur_console->status & ALKED) 2435 cur_console->status &= ~ALKED; 2436 else 2437 cur_console->status |= ALKED; 2438 update_leds(cur_console->status); |
2789 } | 2439 } |
2790 } else { 2791 /* key pressed */ 2792 if (key->spcl & (0x80>>state)) { 2793 switch (action) { 2794 /* LOCKING KEYS */ 2795 case NLK: 2796 if (!nlkcnt) { 2797 nlkcnt++; 2798 if (cur_console->status & NLKED) 2799 cur_console->status &= ~NLKED; 2800 else 2801 cur_console->status |= NLKED; 2802 update_leds(cur_console->status); 2803 } 2804 break; 2805 case CLK: 2806 if (!clkcnt) { 2807 clkcnt++; 2808 if (cur_console->status & CLKED) 2809 cur_console->status &= ~CLKED; 2810 else 2811 cur_console->status |= CLKED; 2812 update_leds(cur_console->status); 2813 } 2814 break; 2815 case SLK: 2816 if (!slkcnt) { 2817 slkcnt++; 2818 if (cur_console->status & SLKED) { 2819 cur_console->status &= ~SLKED; 2820 if (cur_console->status & BUFFER_SAVED){ 2821 int i; 2822 for (i=0; i<cur_console->ysize; i++) { 2823 bcopyw(cur_console->history_save+(cur_console->xsize*i), 2824 cur_console->scr_buf + (cur_console->xsize * i), 2825 cur_console->xsize * sizeof(u_short)); 2826 } 2827 cur_console->status&=~BUFFER_SAVED; 2828 cur_console->history_head = 2829 cur_console->history_save; 2830 cur_console->status |= 2831 (CURSOR_ENABLED|UPDATE_SCREEN); 2832 } 2833 scstart(VIRTUAL_TTY(get_scr_num())); 2834 } 2835 else 2836 cur_console->status |= SLKED; 2837 update_leds(cur_console->status); 2838 } 2839 break; 2840 case ALK: 2841 if (!alkcnt) { 2842 alkcnt++; 2843 if (cur_console->status & ALKED) 2844 cur_console->status &= ~ALKED; 2845 else 2846 cur_console->status |= ALKED; 2847 update_leds(cur_console->status); 2848 } 2849 break; | 2440 break; |
2850 | 2441 |
2851 /* NON-LOCKING KEYS */ 2852 case NOP: 2853 break; 2854 case RBT: 2855 shutdown_nice(); 2856 break; 2857 case SUSP: | 2442 /* NON-LOCKING KEYS */ 2443 case NOP: 2444 break; 2445 case RBT: 2446 shutdown_nice(); 2447 break; 2448 case SUSP: |
2858#if NAPM > 0 | 2449#if NAPM > 0 |
2859 apm_suspend(); | 2450 apm_suspend(); |
2860#endif | 2451#endif |
2861 break; | 2452 break; |
2862 | 2453 |
2863 case DBG: 2864#ifdef DDB /* try to switch to console 0 */ 2865 if (cur_console->smode.mode == VT_AUTO && 2866 console[0]->smode.mode == VT_AUTO) 2867 switch_scr(cur_console, 0); 2868 Debugger("manual escape to debugger"); 2869 return(NOKEY); | 2454 case DBG: 2455#ifdef DDB /* try to switch to console 0 */ 2456 if (cur_console->smode.mode == VT_AUTO && 2457 console[0]->smode.mode == VT_AUTO) 2458 switch_scr(cur_console, 0); 2459 Debugger("manual escape to debugger"); 2460 return(NOKEY); |
2870#else | 2461#else |
2871 printf("No debugger in kernel\n"); | 2462 printf("No debugger in kernel\n"); |
2872#endif | 2463#endif |
2873 break; 2874 case LSH: 2875 shfts |= 1; 2876 break; 2877 case RSH: 2878 shfts |= 2; 2879 break; 2880 case LCTR: 2881 ctls |= 1; 2882 break; 2883 case RCTR: 2884 ctls |= 2; 2885 break; 2886 case LALT: 2887 alts |= 1; 2888 break; 2889 case RALT: 2890 alts |= 2; 2891 break; 2892 case ASH: 2893 agrs = 1; 2894 break; 2895 case META: 2896 metas = 1; 2897 break; 2898 case NEXT: 2899 switch_scr(cur_console, 2900 (get_scr_num() + 1) % MAXCONS); 2901 break; 2902 case BTAB: 2903 return(BKEY); 2904 default: 2905 if (action >= F_SCR && action <= L_SCR) { 2906 switch_scr(cur_console, action - F_SCR); 2907 break; 2908 } 2909 if (action >= F_FN && action <= L_FN) 2910 action |= FKEY; 2911 return(action); 2912 } | 2464 break; 2465 case LSH: 2466 shfts |= 1; 2467 break; 2468 case RSH: 2469 shfts |= 2; 2470 break; 2471 case LCTR: 2472 ctls |= 1; 2473 break; 2474 case RCTR: 2475 ctls |= 2; 2476 break; 2477 case LALT: 2478 alts |= 1; 2479 break; 2480 case RALT: 2481 alts |= 2; 2482 break; 2483 case ASH: 2484 agrs = 1; 2485 break; 2486 case META: 2487 metas = 1; 2488 break; 2489 case NEXT: 2490 switch_scr(cur_console, (get_scr_num() + 1) % MAXCONS); 2491 break; 2492 case BTAB: 2493 return(BKEY); 2494 default: 2495 if (action >= F_SCR && action <= L_SCR) { 2496 switch_scr(cur_console, action - F_SCR); 2497 break; |
2913 } | 2498 } |
2914 else { 2915 if (metas) 2916 action |= MKEY; 2917 return(action); 2918 } | 2499 if (action >= F_FN && action <= L_FN) 2500 action |= FKEY; 2501 return(action); 2502 } |
2919 } | 2503 } |
2920 goto next_code; | 2504 else { 2505 if (metas) 2506 action |= MKEY; 2507 return(action); 2508 } 2509 } 2510 goto next_code; |
2921} 2922 2923int 2924scmmap(dev_t dev, int offset, int nprot) 2925{ | 2511} 2512 2513int 2514scmmap(dev_t dev, int offset, int nprot) 2515{ |
2926 if (offset > 0x20000 - PAGE_SIZE) 2927 return -1; 2928 return i386_btop((VIDEOMEM + offset)); | 2516 if (offset > 0x20000 - PAGE_SIZE) 2517 return -1; 2518 return i386_btop((VIDEOMEM + offset)); |
2929} 2930 2931static void 2932kbd_wait(void) 2933{ | 2519} 2520 2521static void 2522kbd_wait(void) 2523{ |
2934 int i = 1000; | 2524 int i = 1000; |
2935 | 2525 |
2936 while (i--) { 2937 if ((inb(KB_STAT) & KB_READY) == 0) 2938 break; 2939 DELAY (10); 2940 } | 2526 while (i--) { 2527 if ((inb(KB_STAT) & KB_READY) == 0) 2528 break; 2529 DELAY (10); 2530 } |
2941} 2942 2943static void 2944kbd_cmd(u_char command) 2945{ | 2531} 2532 2533static void 2534kbd_cmd(u_char command) 2535{ |
2946 int retry = 5; 2947 do { 2948 int i = 100000; | 2536 int retry = 5; 2537 do { 2538 int i = 100000; |
2949 | 2539 |
2950 kbd_wait(); | 2540 kbd_wait(); |
2951#if ASYNCH | 2541#if ASYNCH |
2952 kbd_reply = 0; 2953 outb(KB_DATA, command); 2954 while (i--) { 2955 if (kbd_reply == KB_ACK) 2956 return; 2957 if (kbd_reply == KB_RESEND) 2958 break; 2959 } | 2542 kbd_reply = 0; 2543 outb(KB_DATA, command); 2544 while (i--) { 2545 if (kbd_reply == KB_ACK) 2546 return; 2547 if (kbd_reply == KB_RESEND) 2548 break; 2549 } |
2960#else | 2550#else |
2961 outb(KB_DATA, command); 2962 while (i--) { 2963 if (inb(KB_STAT) & KB_BUF_FULL) { 2964 int val; 2965 DELAY(10); 2966 val = inb(KB_DATA); 2967 if (val == KB_ACK) 2968 return; 2969 if (val == KB_RESEND) 2970 break; 2971 } 2972 } | 2551 outb(KB_DATA, command); 2552 while (i--) { 2553 if (inb(KB_STAT) & KB_BUF_FULL) { 2554 int val; 2555 DELAY(10); 2556 val = inb(KB_DATA); 2557 if (val == KB_ACK) 2558 return; 2559 if (val == KB_RESEND) 2560 break; 2561 } 2562 } |
2973#endif | 2563#endif |
2974 } while (retry--); | 2564 } while (retry--); |
2975} 2976 2977static void 2978set_mode(scr_stat *scp) 2979{ | 2565} 2566 2567static void 2568set_mode(scr_stat *scp) 2569{ |
2980 char *modetable; 2981 char special_modetable[64]; 2982 int mode, font_size; | 2570 char *modetable; 2571 char special_modetable[64]; 2572 int mode, font_size; |
2983 | 2573 |
2984 if (scp != cur_console) 2985 return; | 2574 if (scp != cur_console) 2575 return; |
2986 | 2576 |
2987 /* setup video hardware for the given mode */ 2988 switch (scp->mode) { 2989 case M_VGA_M80x60: 2990 bcopyw(video_mode_ptr+(64*M_VGA_M80x25),&special_modetable, 64); 2991 goto special_80x60; | 2577 /* setup video hardware for the given mode */ 2578 switch (scp->mode) { 2579 case M_VGA_M80x60: 2580 bcopyw(video_mode_ptr+(64*M_VGA_M80x25),&special_modetable, 64); 2581 goto special_80x60; |
2992 | 2582 |
2993 case M_VGA_C80x60: 2994 bcopyw(video_mode_ptr+(64*M_VGA_C80x25),&special_modetable, 64); 2995special_80x60: special_modetable[2] = 0x08; 2996 special_modetable[19] = 0x47; 2997 goto special_480l; | 2583 case M_VGA_C80x60: 2584 bcopyw(video_mode_ptr+(64*M_VGA_C80x25),&special_modetable, 64); 2585special_80x60: 2586 special_modetable[2] = 0x08; 2587 special_modetable[19] = 0x47; 2588 goto special_480l; |
2998 | 2589 |
2999 case M_VGA_M80x30: 3000 bcopyw(video_mode_ptr+(64*M_VGA_M80x25),&special_modetable, 64); 3001 goto special_80x30; | 2590 case M_VGA_M80x30: 2591 bcopyw(video_mode_ptr+(64*M_VGA_M80x25),&special_modetable, 64); 2592 goto special_80x30; |
3002 | 2593 |
3003 case M_VGA_C80x30: 3004 bcopyw(video_mode_ptr+(64*M_VGA_C80x25),&special_modetable, 64); 3005special_80x30: special_modetable[19] = 0x4f; 3006special_480l: special_modetable[9] |= 0xc0; 3007 special_modetable[16] = 0x08; 3008 special_modetable[17] = 0x3e; 3009 special_modetable[26] = 0xea; 3010 special_modetable[28] = 0xdf; 3011 special_modetable[31] = 0xe7; 3012 special_modetable[32] = 0x04; 3013 modetable = special_modetable; 3014 goto setup_mode; | 2594 case M_VGA_C80x30: 2595 bcopyw(video_mode_ptr+(64*M_VGA_C80x25),&special_modetable, 64); 2596special_80x30: 2597 special_modetable[19] = 0x4f; 2598special_480l: 2599 special_modetable[9] |= 0xc0; 2600 special_modetable[16] = 0x08; 2601 special_modetable[17] = 0x3e; 2602 special_modetable[26] = 0xea; 2603 special_modetable[28] = 0xdf; 2604 special_modetable[31] = 0xe7; 2605 special_modetable[32] = 0x04; 2606 modetable = special_modetable; 2607 goto setup_mode; |
3015 | 2608 |
3016 case M_ENH_B80x43: 3017 bcopyw(video_mode_ptr+(64*M_ENH_B80x25),&special_modetable, 64); 3018 goto special_80x43; | 2609 case M_ENH_B80x43: 2610 bcopyw(video_mode_ptr+(64*M_ENH_B80x25),&special_modetable, 64); 2611 goto special_80x43; |
3019 | 2612 |
3020 case M_ENH_C80x43: 3021 bcopyw(video_mode_ptr+(64*M_ENH_C80x25),&special_modetable, 64); 3022special_80x43: special_modetable[28] = 87; 3023 goto special_80x50; | 2613 case M_ENH_C80x43: 2614 bcopyw(video_mode_ptr+(64*M_ENH_C80x25),&special_modetable, 64); 2615special_80x43: 2616 special_modetable[28] = 87; 2617 goto special_80x50; |
3024 | 2618 |
3025 case M_VGA_M80x50: 3026 bcopyw(video_mode_ptr+(64*M_VGA_M80x25),&special_modetable, 64); 3027 goto special_80x50; | 2619 case M_VGA_M80x50: 2620 bcopyw(video_mode_ptr+(64*M_VGA_M80x25),&special_modetable, 64); 2621 goto special_80x50; |
3028 | 2622 |
3029 case M_VGA_C80x50: 3030 bcopyw(video_mode_ptr+(64*M_VGA_C80x25),&special_modetable, 64); 3031special_80x50: special_modetable[2] = 8; 3032 special_modetable[19] = 7; 3033 modetable = special_modetable; 3034 goto setup_mode; | 2623 case M_VGA_C80x50: 2624 bcopyw(video_mode_ptr+(64*M_VGA_C80x25),&special_modetable, 64); 2625special_80x50: 2626 special_modetable[2] = 8; 2627 special_modetable[19] = 7; 2628 modetable = special_modetable; 2629 goto setup_mode; |
3035 | 2630 |
3036 case M_VGA_C40x25: case M_VGA_C80x25: /* VGA TEXT MODES */ 3037 case M_VGA_M80x25: 3038 case M_B40x25: case M_C40x25: 3039 case M_B80x25: case M_C80x25: 3040 case M_ENH_B40x25: case M_ENH_C40x25: 3041 case M_ENH_B80x25: case M_ENH_C80x25: | 2631 case M_VGA_C40x25: case M_VGA_C80x25: 2632 case M_VGA_M80x25: 2633 case M_B40x25: case M_C40x25: 2634 case M_B80x25: case M_C80x25: 2635 case M_ENH_B40x25: case M_ENH_C40x25: 2636 case M_ENH_B80x25: case M_ENH_C80x25: |
3042 | 2637 |
3043 modetable = video_mode_ptr + (scp->mode * 64); | 2638 modetable = video_mode_ptr + (scp->mode * 64); |
3044setup_mode: | 2639setup_mode: |
3045 set_vgaregs(modetable); 3046 font_size = *(modetable + 2); | 2640 set_vgaregs(modetable); 2641 font_size = *(modetable + 2); |
3047 | 2642 |
3048 /* set font type (size) */ 3049 switch (font_size) { 3050 case 0x10: 3051 outb(TSIDX, 0x03); outb(TSREG, 0x00); /* font 0 */ 3052 scp->font = FONT_16; 3053 break; 3054 case 0x0E: 3055 outb(TSIDX, 0x03); outb(TSREG, 0x05); /* font 1 */ 3056 scp->font = FONT_14; 3057 break; 3058 default: 3059 case 0x08: 3060 outb(TSIDX, 0x03); outb(TSREG, 0x0A); /* font 2 */ 3061 scp->font = FONT_8; 3062 break; 3063 } 3064 break; | 2643 /* set font type (size) */ 2644 switch (font_size) { 2645 case 0x10: 2646 outb(TSIDX, 0x03); outb(TSREG, 0x00); /* font 0 */ 2647 scp->font = FONT_16; 2648 break; 2649 case 0x0E: 2650 outb(TSIDX, 0x03); outb(TSREG, 0x05); /* font 1 */ 2651 scp->font = FONT_14; 2652 break; 2653 default: 2654 case 0x08: 2655 outb(TSIDX, 0x03); outb(TSREG, 0x0A); /* font 2 */ 2656 scp->font = FONT_8; 2657 break; 2658 } 2659 break; |
3065 | 2660 |
3066 case M_BG320: case M_CG320: case M_BG640: 3067 case M_CG320_D: case M_CG640_E: 3068 case M_CG640x350: case M_ENH_CG640: 3069 case M_BG640x480: case M_CG640x480: case M_VGA_CG320: | 2661 case M_BG320: case M_CG320: case M_BG640: 2662 case M_CG320_D: case M_CG640_E: 2663 case M_CG640x350: case M_ENH_CG640: 2664 case M_BG640x480: case M_CG640x480: case M_VGA_CG320: |
3070 | 2665 |
3071 set_vgaregs(video_mode_ptr + (scp->mode * 64)); 3072 break; | 2666 set_vgaregs(video_mode_ptr + (scp->mode * 64)); 2667 break; |
3073 | 2668 |
3074 default: 3075 /* call user defined function XXX */ 3076 break; 3077 } | 2669 default: 2670 /* call user defined function XXX */ 2671 break; 2672 } |
3078 | 2673 |
3079 /* set border color for this (virtual) console */ 3080 set_border(scp->border); 3081 return; | 2674 /* set border color for this (virtual) console */ 2675 set_border(scp->border); 2676 return; |
3082} 3083 | 2677} 2678 |
3084static void | 2679void |
3085set_border(int color) 3086{ | 2680set_border(int color) 2681{ |
3087 inb(crtc_addr+6); /* reset flip-flop */ 3088 outb(ATC, 0x11); outb(ATC, color); 3089 inb(crtc_addr+6); /* reset flip-flop */ 3090 outb(ATC, 0x20); /* enable Palette */ | 2682 inb(crtc_addr+6); /* reset flip-flop */ 2683 outb(ATC, 0x11); outb(ATC, color); 2684 inb(crtc_addr+6); /* reset flip-flop */ 2685 outb(ATC, 0x20); /* enable Palette */ |
3091} 3092 3093static void 3094set_vgaregs(char *modetable) 3095{ | 2686} 2687 2688static void 2689set_vgaregs(char *modetable) 2690{ |
3096 int i, s = splhigh(); | 2691 int i, s = splhigh(); |
3097 | 2692 |
3098 outb(TSIDX, 0x00); outb(TSREG, 0x01); /* stop sequencer */ 3099 outb(TSIDX, 0x07); outb(TSREG, 0x00); /* unlock registers */ 3100 for (i=0; i<4; i++) { /* program sequencer */ 3101 outb(TSIDX, i+1); 3102 outb(TSREG, modetable[i+5]); 3103 } 3104 outb(MISC, modetable[9]); /* set dot-clock */ 3105 outb(TSIDX, 0x00); outb(TSREG, 0x03); /* start sequencer */ 3106 outb(crtc_addr, 0x11); 3107 outb(crtc_addr+1, inb(crtc_addr+1) & 0x7F); 3108 for (i=0; i<25; i++) { /* program crtc */ 3109 outb(crtc_addr, i); 3110 if (i == 14 || i == 15) /* no hardware cursor */ 3111 outb(crtc_addr+1, 0xff); 3112 else 3113 outb(crtc_addr+1, modetable[i+10]); 3114 } 3115 inb(crtc_addr+6); /* reset flip-flop */ 3116 for (i=0; i<20; i++) { /* program attribute ctrl */ 3117 outb(ATC, i); 3118 outb(ATC, modetable[i+35]); 3119 } 3120 for (i=0; i<9; i++) { /* program graph data ctrl */ 3121 outb(GDCIDX, i); 3122 outb(GDCREG, modetable[i+55]); 3123 } 3124 inb(crtc_addr+6); /* reset flip-flop */ 3125 outb(ATC ,0x20); /* enable palette */ 3126 splx(s); | 2693 outb(TSIDX, 0x00); outb(TSREG, 0x01); /* stop sequencer */ 2694 outb(TSIDX, 0x07); outb(TSREG, 0x00); /* unlock registers */ 2695 for (i=0; i<4; i++) { /* program sequencer */ 2696 outb(TSIDX, i+1); 2697 outb(TSREG, modetable[i+5]); 2698 } 2699 outb(MISC, modetable[9]); /* set dot-clock */ 2700 outb(TSIDX, 0x00); outb(TSREG, 0x03); /* start sequencer */ 2701 outb(crtc_addr, 0x11); 2702 outb(crtc_addr+1, inb(crtc_addr+1) & 0x7F); 2703 for (i=0; i<25; i++) { /* program crtc */ 2704 outb(crtc_addr, i); 2705 if (i == 14 || i == 15) /* no hardware cursor */ 2706 outb(crtc_addr+1, 0xff); 2707 else 2708 outb(crtc_addr+1, modetable[i+10]); 2709 } 2710 inb(crtc_addr+6); /* reset flip-flop */ 2711 for (i=0; i<20; i++) { /* program attribute ctrl */ 2712 outb(ATC, i); 2713 outb(ATC, modetable[i+35]); 2714 } 2715 for (i=0; i<9; i++) { /* program graph data ctrl */ 2716 outb(GDCIDX, i); 2717 outb(GDCREG, modetable[i+55]); 2718 } 2719 inb(crtc_addr+6); /* reset flip-flop */ 2720 outb(ATC ,0x20); /* enable palette */ 2721 splx(s); |
3127} 3128 3129static void 3130set_font_mode() 3131{ | 2722} 2723 2724static void 2725set_font_mode() 2726{ |
3132 /* setup vga for loading fonts (graphics plane mode) */ 3133 inb(crtc_addr+6); /* reset flip/flop */ 3134 outb(ATC, 0x30); outb(ATC, 0x01); | 2727 /* setup vga for loading fonts (graphics plane mode) */ 2728 inb(crtc_addr+6); 2729 outb(ATC, 0x30); outb(ATC, 0x01); |
3135#if SLOW_VGA | 2730#if SLOW_VGA |
3136 outb(TSIDX, 0x02); outb(TSREG, 0x04); 3137 outb(TSIDX, 0x04); outb(TSREG, 0x06); 3138 outb(GDCIDX, 0x04); outb(GDCREG, 0x02); 3139 outb(GDCIDX, 0x05); outb(GDCREG, 0x00); 3140 outb(GDCIDX, 0x06); outb(GDCREG, 0x05); | 2731 outb(TSIDX, 0x02); outb(TSREG, 0x04); 2732 outb(TSIDX, 0x04); outb(TSREG, 0x06); 2733 outb(GDCIDX, 0x04); outb(GDCREG, 0x02); 2734 outb(GDCIDX, 0x05); outb(GDCREG, 0x00); 2735 outb(GDCIDX, 0x06); outb(GDCREG, 0x05); |
3141#else | 2736#else |
3142 outw(TSIDX, 0x0402); 3143 outw(TSIDX, 0x0604); 3144 outw(GDCIDX, 0x0204); 3145 outw(GDCIDX, 0x0005); 3146 outw(GDCIDX, 0x0506); /* addr = a0000, 64kb */ | 2737 outw(TSIDX, 0x0402); 2738 outw(TSIDX, 0x0604); 2739 outw(GDCIDX, 0x0204); 2740 outw(GDCIDX, 0x0005); 2741 outw(GDCIDX, 0x0506); /* addr = a0000, 64kb */ |
3147#endif 3148} 3149 3150static void 3151set_normal_mode() 3152{ | 2742#endif 2743} 2744 2745static void 2746set_normal_mode() 2747{ |
3153 int s = splhigh(); | 2748 int s = splhigh(); |
3154 | 2749 |
3155 /* setup vga for normal operation mode again */ 3156 inb(crtc_addr+6); /* reset flip/flop */ 3157 outb(ATC, 0x30); outb(ATC, 0x0C); | 2750 /* setup vga for normal operation mode again */ 2751 inb(crtc_addr+6); 2752 outb(ATC, 0x30); outb(ATC, 0x0C); |
3158#if SLOW_VGA | 2753#if SLOW_VGA |
3159 outb(TSIDX, 0x02); outb(TSREG, 0x03); 3160 outb(TSIDX, 0x04); outb(TSREG, 0x02); 3161 outb(GDCIDX, 0x04); outb(GDCREG, 0x00); 3162 outb(GDCIDX, 0x05); outb(GDCREG, 0x10); 3163 if (crtc_addr == MONO_BASE) { 3164 outb(GDCIDX, 0x06); outb(GDCREG, 0x0A); /* addr = b0000, 32kb */ 3165 } 3166 else { 3167 outb(GDCIDX, 0x06); outb(GDCREG, 0x0E); /* addr = b8000, 32kb */ 3168 } | 2754 outb(TSIDX, 0x02); outb(TSREG, 0x03); 2755 outb(TSIDX, 0x04); outb(TSREG, 0x02); 2756 outb(GDCIDX, 0x04); outb(GDCREG, 0x00); 2757 outb(GDCIDX, 0x05); outb(GDCREG, 0x10); 2758 if (crtc_addr == MONO_BASE) { 2759 outb(GDCIDX, 0x06); outb(GDCREG, 0x0A); /* addr = b0000, 32kb */ 2760 } 2761 else { 2762 outb(GDCIDX, 0x06); outb(GDCREG, 0x0E); /* addr = b8000, 32kb */ 2763 } |
3169#else | 2764#else |
3170 outw(TSIDX, 0x0302); 3171 outw(TSIDX, 0x0204); 3172 outw(GDCIDX, 0x0004); 3173 outw(GDCIDX, 0x1005); 3174 if (crtc_addr == MONO_BASE) 3175 outw(GDCIDX, 0x0A06); /* addr = b0000, 32kb */ 3176 else 3177 outw(GDCIDX, 0x0E06); /* addr = b8000, 32kb */ | 2765 outw(TSIDX, 0x0302); 2766 outw(TSIDX, 0x0204); 2767 outw(GDCIDX, 0x0004); 2768 outw(GDCIDX, 0x1005); 2769 if (crtc_addr == MONO_BASE) 2770 outw(GDCIDX, 0x0A06); /* addr = b0000, 32kb */ 2771 else 2772 outw(GDCIDX, 0x0E06); /* addr = b8000, 32kb */ |
3178#endif | 2773#endif |
3179 splx(s); | 2774 splx(s); |
3180} 3181 3182static void 3183copy_font(int operation, int font_type, char* font_image) 3184{ | 2775} 2776 2777static void 2778copy_font(int operation, int font_type, char* font_image) 2779{ |
3185 int ch, line, segment, fontsize; 3186 u_char val; | 2780 int ch, line, segment, fontsize; 2781 u_char val; |
3187 | 2782 |
3188 switch (font_type) { 3189 default: 3190 case FONT_8: 3191 segment = 0x8000; 3192 fontsize = 8; 3193 break; 3194 case FONT_14: 3195 segment = 0x4000; 3196 fontsize = 14; 3197 break; 3198 case FONT_16: 3199 segment = 0x0000; 3200 fontsize = 16; 3201 break; 3202 } 3203 outb(TSIDX, 0x01); val = inb(TSREG); /* disable screen */ 3204 outb(TSIDX, 0x01); outb(TSREG, val | 0x20); 3205 set_font_mode(); 3206 for (ch=0; ch < 256; ch++) 3207 for (line=0; line < fontsize; line++) 3208 if (operation) 3209 *(char *)pa_to_va(VIDEOMEM+(segment)+(ch*32)+line) = 3210 font_image[(ch*fontsize)+line]; 3211 else 3212 font_image[(ch*fontsize)+line] = 3213 *(char *)pa_to_va(VIDEOMEM+(segment)+(ch*32)+line); 3214 set_normal_mode(); 3215 outb(TSIDX, 0x01); outb(TSREG, val & 0xDF); /* enable screen */ | 2783 switch (font_type) { 2784 default: 2785 case FONT_8: 2786 segment = 0x8000; 2787 fontsize = 8; 2788 break; 2789 case FONT_14: 2790 segment = 0x4000; 2791 fontsize = 14; 2792 break; 2793 case FONT_16: 2794 segment = 0x0000; 2795 fontsize = 16; 2796 break; 2797 } 2798 outb(TSIDX, 0x01); val = inb(TSREG); /* disable screen */ 2799 outb(TSIDX, 0x01); outb(TSREG, val | 0x20); 2800 set_font_mode(); 2801 for (ch=0; ch < 256; ch++) 2802 for (line=0; line < fontsize; line++) 2803 if (operation) 2804 *(char *)pa_to_va(VIDEOMEM+(segment)+(ch*32)+line) = 2805 font_image[(ch*fontsize)+line]; 2806 else 2807 font_image[(ch*fontsize)+line] = 2808 *(char *)pa_to_va(VIDEOMEM+(segment)+(ch*32)+line); 2809 set_normal_mode(); 2810 outb(TSIDX, 0x01); outb(TSREG, val & 0xDF); /* enable screen */ |
3216} 3217 3218static void 3219draw_mouse_image(scr_stat *scp) 3220{ | 2811} 2812 2813static void 2814draw_mouse_image(scr_stat *scp) 2815{ |
3221 caddr_t address; 3222 int i, font_size; 3223 char *font_buffer; 3224 u_short buffer[32]; 3225 u_short xoffset, yoffset; 3226 u_short *crt_pos = Crtat + (scp->mouse_pos - scp->scr_buf); | 2816 caddr_t address; 2817 int i, font_size; 2818 char *font_buffer; 2819 u_short buffer[32]; 2820 u_short xoffset, yoffset; 2821 u_short *crt_pos = Crtat + (scp->mouse_pos - scp->scr_buf); |
3227 | 2822 |
3228 xoffset = scp->mouse_xpos % 8; 3229 switch (scp->font) { 3230 default: 3231 case FONT_8: 3232 font_size = 8; 3233 font_buffer = font_8; 3234 yoffset = scp->mouse_ypos % 8; 3235 address = (caddr_t)VIDEOMEM+0x8000; 3236 break; 3237 case FONT_14: 3238 font_size = 14; 3239 font_buffer = font_14; 3240 yoffset = scp->mouse_ypos % 14; 3241 address = (caddr_t)VIDEOMEM+0x4000; 3242 break; 3243 case FONT_16: 3244 font_size = 16; 3245 font_buffer = font_16; 3246 yoffset = scp->mouse_ypos % 16; 3247 address = (caddr_t)VIDEOMEM; 3248 break; 3249 } | 2823 xoffset = scp->mouse_xpos % 8; 2824 switch (scp->font) { 2825 default: 2826 case FONT_8: 2827 font_size = 8; 2828 font_buffer = font_8; 2829 yoffset = scp->mouse_ypos % 8; 2830 address = (caddr_t)VIDEOMEM+0x8000; 2831 break; 2832 case FONT_14: 2833 font_size = 14; 2834 font_buffer = font_14; 2835 yoffset = scp->mouse_ypos % 14; 2836 address = (caddr_t)VIDEOMEM+0x4000; 2837 break; 2838 case FONT_16: 2839 font_size = 16; 2840 font_buffer = font_16; 2841 yoffset = scp->mouse_ypos % 16; 2842 address = (caddr_t)VIDEOMEM; 2843 break; 2844 } |
3250 | 2845 |
3251 bcopyw(font_buffer+((*(scp->mouse_pos) & 0xff)*font_size), 3252 &scp->mouse_cursor[0], font_size); 3253 bcopyw(font_buffer+((*(scp->mouse_pos+1) & 0xff)*font_size), 3254 &scp->mouse_cursor[32], font_size); 3255 bcopyw(font_buffer+((*(scp->mouse_pos+scp->xsize) & 0xff)*font_size), 3256 &scp->mouse_cursor[64], font_size); 3257 bcopyw(font_buffer+((*(scp->mouse_pos+scp->xsize+1) & 0xff)*font_size), 3258 &scp->mouse_cursor[96], font_size); | 2846 bcopyw(font_buffer+((*(scp->mouse_pos) & 0xff)*font_size), 2847 &scp->mouse_cursor[0], font_size); 2848 bcopyw(font_buffer+((*(scp->mouse_pos+1) & 0xff)*font_size), 2849 &scp->mouse_cursor[32], font_size); 2850 bcopyw(font_buffer+((*(scp->mouse_pos+scp->xsize) & 0xff)*font_size), 2851 &scp->mouse_cursor[64], font_size); 2852 bcopyw(font_buffer+((*(scp->mouse_pos+scp->xsize+1) & 0xff)*font_size), 2853 &scp->mouse_cursor[96], font_size); |
3259 | 2854 |
3260 for (i=0; i<font_size; i++) { 3261 buffer[i] = 3262 scp->mouse_cursor[i]<<8 | scp->mouse_cursor[i+32]; 3263 buffer[i+font_size] = 3264 scp->mouse_cursor[i+64]<<8 | scp->mouse_cursor[i+96]; | 2855 for (i=0; i<font_size; i++) { 2856 buffer[i] = scp->mouse_cursor[i]<<8 | scp->mouse_cursor[i+32]; 2857 buffer[i+font_size]=scp->mouse_cursor[i+64]<<8|scp->mouse_cursor[i+96]; 2858 } 2859 for (i=0; i<16; i++) { 2860 buffer[i+yoffset] = 2861 ( buffer[i+yoffset] & ~(mouse_and_mask[i] >> xoffset)) 2862 | (mouse_or_mask[i] >> xoffset); 2863 } 2864 for (i=0; i<font_size; i++) { 2865 scp->mouse_cursor[i] = (buffer[i] & 0xff00) >> 8; 2866 scp->mouse_cursor[i+32] = buffer[i] & 0xff; 2867 scp->mouse_cursor[i+64] = (buffer[i+font_size] & 0xff00) >> 8; 2868 scp->mouse_cursor[i+96] = buffer[i+font_size] & 0xff; 2869 } 2870 /* 2871 * if we didn't update entire screen, restore old mouse position 2872 * and check if we overwrote the cursor location.. 2873 */ 2874 if ((scp->status & UPDATE_MOUSE) && !(scp->status & UPDATE_SCREEN)) { 2875 u_short *ptr = scp->scr_buf + (scp->mouse_oldpos - Crtat); 2876 2877 if (crt_pos != scp->mouse_oldpos) { 2878 *(scp->mouse_oldpos) = scp->mouse_saveunder[0]; 2879 *(scp->mouse_oldpos+1) = scp->mouse_saveunder[1]; 2880 *(scp->mouse_oldpos+scp->xsize) = scp->mouse_saveunder[2]; 2881 *(scp->mouse_oldpos+scp->xsize+1) = scp->mouse_saveunder[3]; |
3265 } | 2882 } |
3266 for (i=0; i<16; i++) { 3267 buffer[i+yoffset] = 3268 ( buffer[i+yoffset] 3269 & ~(mouse_and_mask[i] >> xoffset)) 3270 | (mouse_or_mask[i] >> xoffset); 3271 } 3272 for (i=0; i<font_size; i++) { 3273 scp->mouse_cursor[i] = (buffer[i] & 0xff00) >> 8; 3274 scp->mouse_cursor[i+32] = buffer[i] & 0xff; 3275 scp->mouse_cursor[i+64] = (buffer[i+font_size] & 0xff00) >> 8; 3276 scp->mouse_cursor[i+96] = buffer[i+font_size] & 0xff; 3277 } 3278 /* 3279 * if we didn't update entire screen, restore old mouse position 3280 * and check if we overwrote the cursor location.. 3281 */ 3282 if ((scp->status & UPDATE_MOUSE) && !(scp->status & UPDATE_SCREEN)) { 3283 u_short *ptr = scp->scr_buf + (scp->mouse_oldpos - Crtat); 3284 if (crt_pos != scp->mouse_oldpos) { 3285 *(scp->mouse_oldpos) = scp->mouse_saveunder[0]; 3286 *(scp->mouse_oldpos+1) = scp->mouse_saveunder[1]; 3287 *(scp->mouse_oldpos+scp->xsize) = scp->mouse_saveunder[2]; 3288 *(scp->mouse_oldpos+scp->xsize+1) = scp->mouse_saveunder[3]; 3289 } 3290 scp->mouse_saveunder[0] = *(scp->mouse_pos); 3291 scp->mouse_saveunder[1] = *(scp->mouse_pos+1); 3292 scp->mouse_saveunder[2] = *(scp->mouse_pos+scp->xsize); 3293 scp->mouse_saveunder[3] = *(scp->mouse_pos+scp->xsize+1); 3294 if ((scp->cursor_pos == (ptr)) || 3295 (scp->cursor_pos == (ptr+1)) || 3296 (scp->cursor_pos == (ptr+scp->xsize)) || 3297 (scp->cursor_pos == (ptr+scp->xsize+1)) || 3298 (scp->cursor_pos == (scp->mouse_pos)) || 3299 (scp->cursor_pos == (scp->mouse_pos+1)) || 3300 (scp->cursor_pos == (scp->mouse_pos+scp->xsize)) || 3301 (scp->cursor_pos == (scp->mouse_pos+scp->xsize+1))) 3302 scp->status &= ~CURSOR_SHOWN; 3303 } 3304 scp->mouse_oldpos = crt_pos; 3305 while (!(inb(crtc_addr+6) & 0x08)) /* wait for vertical retrace */ ; 3306 *(crt_pos) = *(scp->mouse_pos)&0xff00|0xd0; 3307 *(crt_pos+1) = *(scp->mouse_pos+1)&0xff00|0xd1; 3308 *(crt_pos+scp->xsize) = *(scp->mouse_pos+scp->xsize)&0xff00|0xd2; 3309 *(crt_pos+scp->xsize+1) = *(scp->mouse_pos+scp->xsize+1)&0xff00|0xd3; 3310 set_font_mode(); 3311 bcopy(scp->mouse_cursor, 3312 (char *)pa_to_va(address) + 0xd0 * 32, 128); 3313 set_normal_mode(); | 2883 scp->mouse_saveunder[0] = *(scp->mouse_pos); 2884 scp->mouse_saveunder[1] = *(scp->mouse_pos+1); 2885 scp->mouse_saveunder[2] = *(scp->mouse_pos+scp->xsize); 2886 scp->mouse_saveunder[3] = *(scp->mouse_pos+scp->xsize+1); 2887 if ((scp->cursor_pos == (ptr)) || 2888 (scp->cursor_pos == (ptr+1)) || 2889 (scp->cursor_pos == (ptr+scp->xsize)) || 2890 (scp->cursor_pos == (ptr+scp->xsize+1)) || 2891 (scp->cursor_pos == (scp->mouse_pos)) || 2892 (scp->cursor_pos == (scp->mouse_pos+1)) || 2893 (scp->cursor_pos == (scp->mouse_pos+scp->xsize)) || 2894 (scp->cursor_pos == (scp->mouse_pos+scp->xsize+1))) 2895 scp->status &= ~CURSOR_SHOWN; 2896 } 2897 scp->mouse_oldpos = crt_pos; 2898 while (!(inb(crtc_addr+6) & 0x08)) /* wait for vertical retrace */ ; 2899 *(crt_pos) = *(scp->mouse_pos)&0xff00|0xd0; 2900 *(crt_pos+1) = *(scp->mouse_pos+1)&0xff00|0xd1; 2901 *(crt_pos+scp->xsize) = *(scp->mouse_pos+scp->xsize)&0xff00|0xd2; 2902 *(crt_pos+scp->xsize+1) = *(scp->mouse_pos+scp->xsize+1)&0xff00|0xd3; 2903 set_font_mode(); 2904 bcopy(scp->mouse_cursor, (char *)pa_to_va(address) + 0xd0 * 32, 128); 2905 set_normal_mode(); |
3314} 3315 3316static void 3317save_palette(void) 3318{ | 2906} 2907 2908static void 2909save_palette(void) 2910{ |
3319 int i; | 2911 int i; |
3320 | 2912 |
3321 outb(PALRADR, 0x00); 3322 for (i=0x00; i<0x300; i++) 3323 palette[i] = inb(PALDATA); 3324 inb(crtc_addr+6); /* reset flip/flop */ | 2913 outb(PALRADR, 0x00); 2914 for (i=0x00; i<0x300; i++) 2915 palette[i] = inb(PALDATA); 2916 inb(crtc_addr+6); /* reset flip/flop */ |
3325} 3326 | 2917} 2918 |
3327static void | 2919void |
3328load_palette(void) 3329{ | 2920load_palette(void) 2921{ |
3330 int i; | 2922 int i; |
3331 | 2923 |
3332 outb(PIXMASK, 0xFF); /* no pixelmask */ 3333 outb(PALWADR, 0x00); 3334 for (i=0x00; i<0x300; i++) 3335 outb(PALDATA, palette[i]); 3336 inb(crtc_addr+6); /* reset flip/flop */ 3337 outb(ATC, 0x20); /* enable palette */ | 2924 outb(PIXMASK, 0xFF); /* no pixelmask */ 2925 outb(PALWADR, 0x00); 2926 for (i=0x00; i<0x300; i++) 2927 outb(PALDATA, palette[i]); 2928 inb(crtc_addr+6); /* reset flip/flop */ 2929 outb(ATC, 0x20); /* enable palette */ |
3338} 3339 3340static void 3341do_bell(scr_stat *scp, int pitch, int duration) 3342{ | 2930} 2931 2932static void 2933do_bell(scr_stat *scp, int pitch, int duration) 2934{ |
3343 if (scp == cur_console) { 3344 if (configuration & VISUAL_BELL) { 3345 if (blink_in_progress) 3346 return; 3347 blink_in_progress = 4; 3348 blink_screen(scp); 3349 timeout((timeout_func_t)blink_screen, scp, hz/10); 3350 } 3351 else 3352 sysbeep(pitch, duration); 3353 } | 2935 if (scp == cur_console) { 2936 if (configuration & VISUAL_BELL) { 2937 if (blink_in_progress) 2938 return; 2939 blink_in_progress = 4; 2940 blink_screen(scp); 2941 timeout((timeout_func_t)blink_screen, scp, hz/10); 2942 } 2943 else 2944 sysbeep(pitch, duration); 2945 } |
3354} 3355 3356static void 3357blink_screen(scr_stat *scp) 3358{ | 2946} 2947 2948static void 2949blink_screen(scr_stat *scp) 2950{ |
3359 if (blink_in_progress > 1) { 3360 if (blink_in_progress & 1) 3361 fillw(kernel_default.std_attr | scr_map[0x20], 3362 Crtat, scp->xsize * scp->ysize); 3363 else 3364 fillw(kernel_default.rev_attr | scr_map[0x20], 3365 Crtat, scp->xsize * scp->ysize); 3366 blink_in_progress--; 3367 timeout((timeout_func_t)blink_screen, scp, hz/10); 3368 } 3369 else { 3370 scp->status |= UPDATE_SCREEN; 3371 blink_in_progress = FALSE; 3372 if (delayed_next_scr) 3373 switch_scr(scp, delayed_next_scr - 1); 3374 } | 2951 if (blink_in_progress > 1) { 2952 if (blink_in_progress & 1) 2953 fillw(kernel_default.std_attr | scr_map[0x20], 2954 Crtat, scp->xsize * scp->ysize); 2955 else 2956 fillw(kernel_default.rev_attr | scr_map[0x20], 2957 Crtat, scp->xsize * scp->ysize); 2958 blink_in_progress--; 2959 timeout((timeout_func_t)blink_screen, scp, hz/10); 2960 } 2961 else { 2962 scp->status |= UPDATE_SCREEN; 2963 blink_in_progress = FALSE; 2964 if (delayed_next_scr) 2965 switch_scr(scp, delayed_next_scr - 1); 2966 } |
3375} 3376 3377#endif /* NSC */ | 2967} 2968 2969#endif /* NSC */ |