1993-07-26 21:21:11 +00:00
|
|
|
|
/*-
|
1995-01-12 11:47:05 +00:00
|
|
|
|
* Copyright (c) 1992-1995 S<EFBFBD>ren Schmidt
|
1993-07-26 21:21:11 +00:00
|
|
|
|
* Copyright (c) 1990 The Regents of the University of California.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
|
* William Jolitz and Don Ahn.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
|
* are met:
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
1995-01-28 22:18:05 +00:00
|
|
|
|
* notice, this list of conditions and the following disclaimer,
|
1994-09-29 08:29:21 +00:00
|
|
|
|
* in this position and unchanged.
|
1993-07-26 21:21:11 +00:00
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
|
* without specific prior written permission.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
|
*
|
1995-02-17 02:22:57 +00:00
|
|
|
|
* $Id: syscons.c,v 1.102 1995/02/14 14:37:53 sos Exp $
|
1993-07-26 21:21:11 +00:00
|
|
|
|
*/
|
|
|
|
|
|
1994-08-13 03:50:34 +00:00
|
|
|
|
#include "sc.h"
|
|
|
|
|
|
|
|
|
|
#if NSC > 0
|
|
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
1994-05-25 09:21:21 +00:00
|
|
|
|
#include <sys/systm.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
|
#include <sys/conf.h>
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
#include <sys/proc.h>
|
|
|
|
|
#include <sys/user.h>
|
|
|
|
|
#include <sys/tty.h>
|
|
|
|
|
#include <sys/uio.h>
|
|
|
|
|
#include <sys/callout.h>
|
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
|
#include <sys/errno.h>
|
|
|
|
|
#include <sys/malloc.h>
|
1994-10-23 21:28:03 +00:00
|
|
|
|
#include <sys/devconf.h>
|
|
|
|
|
|
1994-10-26 21:51:22 +00:00
|
|
|
|
#include <machine/clock.h>
|
1994-08-17 19:32:23 +00:00
|
|
|
|
#include <machine/console.h>
|
|
|
|
|
#include <machine/psl.h>
|
|
|
|
|
#include <machine/frame.h>
|
|
|
|
|
#include <machine/pc/display.h>
|
1994-10-23 21:28:03 +00:00
|
|
|
|
|
1994-08-13 03:50:34 +00:00
|
|
|
|
#include <i386/isa/isa.h>
|
|
|
|
|
#include <i386/isa/isa_device.h>
|
|
|
|
|
#include <i386/isa/timerreg.h>
|
1994-08-17 08:51:59 +00:00
|
|
|
|
#include <i386/isa/kbdtables.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
|
#include <i386/i386/cons.h>
|
1993-10-28 05:27:36 +00:00
|
|
|
|
|
1995-01-12 11:47:05 +00:00
|
|
|
|
#if !defined(MAXCONS)
|
1995-01-28 22:18:05 +00:00
|
|
|
|
#define MAXCONS 16
|
1994-12-31 17:09:58 +00:00
|
|
|
|
#endif
|
1995-02-17 02:22:57 +00:00
|
|
|
|
#include "apm.h"
|
|
|
|
|
#if NAPM > 0
|
|
|
|
|
#include "machine/apm_bios.h"
|
|
|
|
|
#endif
|
1994-12-31 17:09:58 +00:00
|
|
|
|
|
1995-01-12 11:47:05 +00:00
|
|
|
|
/* this may break on older VGA's but is usefull on real 32 bit systems */
|
|
|
|
|
#define bcopyw bcopy
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
1994-10-26 21:51:22 +00:00
|
|
|
|
/* vm things */
|
|
|
|
|
#define ISMAPPED(pa, width) \
|
|
|
|
|
(((pa) <= (u_long)0x1000 - (width)) \
|
|
|
|
|
|| ((pa) >= 0xa0000 && (pa) <= 0x100000 - (width)))
|
|
|
|
|
#define pa_to_va(pa) (KERNBASE + (pa)) /* works if ISMAPPED(pa...) */
|
|
|
|
|
|
1995-02-03 21:09:44 +00:00
|
|
|
|
/* printable chars */
|
|
|
|
|
#define PRINTABLE(ch) (ch>0x1B || (ch>0x0d && ch<0x1b) || ch<0x07)
|
|
|
|
|
|
1993-07-26 21:21:11 +00:00
|
|
|
|
/* status flags */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
#define LOCK_KEY_MASK 0x0000F
|
|
|
|
|
#define LED_MASK 0x00007
|
1993-07-26 21:21:11 +00:00
|
|
|
|
#define UNKNOWN_MODE 0x00010
|
|
|
|
|
#define KBD_RAW_MODE 0x00020
|
|
|
|
|
#define SWITCH_WAIT_REL 0x00040
|
|
|
|
|
#define SWITCH_WAIT_ACQ 0x00080
|
1995-01-12 11:47:05 +00:00
|
|
|
|
#define BUFFER_SAVED 0x00100
|
1995-01-28 22:18:05 +00:00
|
|
|
|
#define CURSOR_ENABLED 0x00200
|
1995-01-30 21:36:32 +00:00
|
|
|
|
#define CURSOR_SHOWN 0x00400
|
|
|
|
|
#define MOUSE_ENABLED 0x00800
|
1995-02-01 21:56:32 +00:00
|
|
|
|
#define UPDATE_MOUSE 0x01000
|
|
|
|
|
#define UPDATE_SCREEN 0x02000
|
1995-01-12 11:47:05 +00:00
|
|
|
|
|
|
|
|
|
/* configuration flags */
|
1995-01-20 08:35:32 +00:00
|
|
|
|
#define VISUAL_BELL 0x00001
|
1995-01-28 22:18:05 +00:00
|
|
|
|
#define BLINK_CURSOR 0x00002
|
|
|
|
|
#define CHAR_CURSOR 0x00004
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
1994-02-01 06:22:29 +00:00
|
|
|
|
/* video hardware memory addresses */
|
1993-07-26 21:21:11 +00:00
|
|
|
|
#define VIDEOMEM 0x000A0000
|
|
|
|
|
|
|
|
|
|
/* misc defines */
|
1995-01-28 22:18:05 +00:00
|
|
|
|
#define FALSE 0
|
|
|
|
|
#define TRUE 1
|
1994-08-17 08:51:59 +00:00
|
|
|
|
#define MAX_ESC_PAR 5
|
|
|
|
|
#define LOAD 1
|
|
|
|
|
#define SAVE 0
|
1993-07-26 21:21:11 +00:00
|
|
|
|
#define COL 80
|
|
|
|
|
#define ROW 25
|
1994-02-01 06:22:29 +00:00
|
|
|
|
#define BELL_DURATION 5
|
1993-10-28 05:27:36 +00:00
|
|
|
|
#define BELL_PITCH 800
|
|
|
|
|
#define TIMER_FREQ 1193182 /* should be in isa.h */
|
1994-08-17 08:51:59 +00:00
|
|
|
|
#define CONSOLE_BUFSIZE 1024
|
|
|
|
|
#define PCBURST 128
|
1995-01-20 08:35:32 +00:00
|
|
|
|
#define FONT_8 0x001
|
|
|
|
|
#define FONT_14 0x002
|
|
|
|
|
#define FONT_16 0x004
|
1995-01-12 11:47:05 +00:00
|
|
|
|
#define HISTORY_SIZE 100*80
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
|
|
|
|
/* defines related to hardware addresses */
|
|
|
|
|
#define MONO_BASE 0x3B4 /* crt controller base mono */
|
|
|
|
|
#define COLOR_BASE 0x3D4 /* crt controller base color */
|
1994-09-15 07:26:40 +00:00
|
|
|
|
#define MISC 0x3C2 /* misc output register */
|
1993-09-08 22:11:48 +00:00
|
|
|
|
#define ATC IO_VGA+0x00 /* attribute controller */
|
|
|
|
|
#define TSIDX IO_VGA+0x04 /* timing sequencer idx */
|
|
|
|
|
#define TSREG IO_VGA+0x05 /* timing sequencer data */
|
|
|
|
|
#define PIXMASK IO_VGA+0x06 /* pixel write mask */
|
|
|
|
|
#define PALRADR IO_VGA+0x07 /* palette read address */
|
|
|
|
|
#define PALWADR IO_VGA+0x08 /* palette write address */
|
|
|
|
|
#define PALDATA IO_VGA+0x09 /* palette data register */
|
|
|
|
|
#define GDCIDX IO_VGA+0x0E /* graph data controller idx */
|
|
|
|
|
#define GDCREG IO_VGA+0x0F /* graph data controller data */
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
1994-02-01 06:22:29 +00:00
|
|
|
|
/* special characters */
|
|
|
|
|
#define cntlc 0x03
|
|
|
|
|
#define cntld 0x04
|
|
|
|
|
#define bs 0x08
|
|
|
|
|
#define lf 0x0a
|
|
|
|
|
#define cr 0x0d
|
|
|
|
|
#define del 0x7f
|
|
|
|
|
|
1993-07-30 02:20:26 +00:00
|
|
|
|
typedef struct term_stat {
|
1993-07-26 21:21:11 +00:00
|
|
|
|
int esc; /* processing escape sequence */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
int num_param; /* # of parameters to ESC */
|
|
|
|
|
int last_param; /* last parameter # */
|
|
|
|
|
int param[MAX_ESC_PAR]; /* contains ESC parameters */
|
|
|
|
|
int cur_attr; /* current attributes */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
int std_attr; /* normal attributes */
|
|
|
|
|
int rev_attr; /* reverse attributes */
|
|
|
|
|
} term_stat;
|
|
|
|
|
|
|
|
|
|
typedef struct scr_stat {
|
1994-02-01 06:22:29 +00:00
|
|
|
|
u_short *scr_buf; /* buffer when off screen */
|
|
|
|
|
int xpos; /* current X position */
|
|
|
|
|
int ypos; /* current Y position */
|
|
|
|
|
int xsize; /* X size */
|
|
|
|
|
int ysize; /* Y size */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
term_stat term; /* terminal emulation stuff */
|
1995-01-28 22:18:05 +00:00
|
|
|
|
int status; /* status (bitfield) */
|
1995-01-20 08:35:32 +00:00
|
|
|
|
u_short *cursor_pos; /* cursor buffer position */
|
1995-02-01 21:56:32 +00:00
|
|
|
|
u_short cursor_saveunder; /* saved chars under cursor */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
char cursor_start; /* cursor start line # */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
char cursor_end; /* cursor end line # */
|
1995-01-20 08:35:32 +00:00
|
|
|
|
u_short *mouse_pos; /* mouse buffer position */
|
1995-02-01 21:56:32 +00:00
|
|
|
|
u_short *mouse_oldpos; /* mouse old buffer position */
|
|
|
|
|
u_short mouse_saveunder[4]; /* saved chars under mouse */
|
|
|
|
|
short mouse_xpos; /* mouse x coordinate */
|
|
|
|
|
short mouse_ypos; /* mouse y coordinate */
|
1995-01-20 08:35:32 +00:00
|
|
|
|
u_char mouse_cursor[128]; /* mouse cursor bitmap store */
|
1993-07-26 21:21:11 +00:00
|
|
|
|
u_short bell_duration;
|
|
|
|
|
u_short bell_pitch;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
u_char border; /* border color */
|
|
|
|
|
u_char mode; /* mode */
|
1995-01-28 22:18:05 +00:00
|
|
|
|
u_char font; /* font on this screen */
|
1993-07-26 21:21:11 +00:00
|
|
|
|
pid_t pid; /* pid of controlling proc */
|
|
|
|
|
struct proc *proc; /* proc* of controlling proc */
|
|
|
|
|
struct vt_mode smode; /* switch mode */
|
1995-02-01 21:56:32 +00:00
|
|
|
|
u_short *history; /* circular history buffer */
|
|
|
|
|
u_short *history_head; /* current head position */
|
|
|
|
|
u_short *history_pos; /* position shown on screen */
|
|
|
|
|
u_short *history_save; /* save area index */
|
|
|
|
|
int history_size; /* size of history buffer */
|
1995-02-17 02:22:57 +00:00
|
|
|
|
#if NAPM > 0
|
|
|
|
|
struct apmhook r_hook; /* reconfiguration support */
|
|
|
|
|
#endif /* NAPM > 0 */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
} scr_stat;
|
|
|
|
|
|
|
|
|
|
typedef struct default_attr {
|
|
|
|
|
int std_attr; /* normal attributes */
|
|
|
|
|
int rev_attr; /* reverse attributes */
|
|
|
|
|
} default_attr;
|
|
|
|
|
|
|
|
|
|
static default_attr user_default = {
|
|
|
|
|
(FG_LIGHTGREY | BG_BLACK) << 8,
|
|
|
|
|
(FG_BLACK | BG_LIGHTGREY) << 8
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static default_attr kernel_default = {
|
|
|
|
|
(FG_WHITE | BG_BLACK) << 8,
|
|
|
|
|
(FG_BLACK | BG_LIGHTGREY) << 8
|
|
|
|
|
};
|
|
|
|
|
|
1995-01-12 11:47:05 +00:00
|
|
|
|
static scr_stat main_console;
|
|
|
|
|
static scr_stat *console[MAXCONS];
|
|
|
|
|
static scr_stat *cur_console;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
static scr_stat *new_scp, *old_scp;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
static term_stat kernel_console;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
static default_attr *current_default;
|
1995-02-05 23:44:25 +00:00
|
|
|
|
static char init_done = FALSE;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
static char switch_in_progress = FALSE;
|
|
|
|
|
static char blink_in_progress = FALSE;
|
|
|
|
|
static char write_in_progress = FALSE;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
static u_int crtc_addr = MONO_BASE;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
static char crtc_vga = FALSE;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
static u_char shfts = 0, ctls = 0, alts = 0, agrs = 0, metas = 0;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
static u_char nlkcnt = 0, clkcnt = 0, slkcnt = 0, alkcnt = 0;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static char *font_8 = NULL, *font_14 = NULL, *font_16 = NULL;
|
|
|
|
|
static int fonts_loaded = 0;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
static char palette[3*256];
|
|
|
|
|
static const u_int n_fkey_tab = sizeof(fkey_tab) / sizeof(*fkey_tab);
|
1994-08-17 08:51:59 +00:00
|
|
|
|
#if ASYNCH
|
|
|
|
|
static u_char kbd_reply = 0;
|
|
|
|
|
#endif
|
1995-02-05 23:44:25 +00:00
|
|
|
|
static int delayed_next_scr = FALSE;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
static int configuration = 0; /* current setup */
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static long scrn_blank_time = 0; /* screen saver timeout value */
|
1995-02-01 21:56:32 +00:00
|
|
|
|
static int scrn_blanked = FALSE; /* screen saver active flag */
|
1994-02-04 10:36:15 +00:00
|
|
|
|
static int scrn_saver = 0; /* screen saver routine */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
static long scrn_time_stamp;
|
|
|
|
|
static u_char scr_map[256];
|
1994-10-26 21:51:22 +00:00
|
|
|
|
static char *video_mode_ptr = NULL;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
static u_short mouse_and_mask[16] = {
|
|
|
|
|
0xc000, 0xe000, 0xf000, 0xf800, 0xfc00, 0xfe00, 0xff00, 0xff80,
|
|
|
|
|
0xfe00, 0x1e00, 0x1f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000
|
|
|
|
|
};
|
|
|
|
|
static u_short mouse_or_mask[16] = {
|
|
|
|
|
0x0000, 0x4000, 0x6000, 0x7000, 0x7800, 0x7c00, 0x7e00, 0x6800,
|
|
|
|
|
0x0c00, 0x0c00, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, 0x0000
|
|
|
|
|
};
|
1994-08-17 08:51:59 +00:00
|
|
|
|
|
1993-07-26 21:21:11 +00:00
|
|
|
|
/* function prototypes */
|
1995-01-20 08:35:32 +00:00
|
|
|
|
int scprobe(struct isa_device *dev);
|
|
|
|
|
int scattach(struct isa_device *dev);
|
|
|
|
|
int scopen(dev_t dev, int flag, int mode, struct proc *p);
|
|
|
|
|
int scclose(dev_t dev, int flag, int mode, struct proc *p);
|
|
|
|
|
int scread(dev_t dev, struct uio *uio, int flag);
|
|
|
|
|
int scwrite(dev_t dev, struct uio *uio, int flag);
|
|
|
|
|
int scparam(struct tty *tp, struct termios *t);
|
|
|
|
|
int scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p);
|
|
|
|
|
void scxint(dev_t dev);
|
|
|
|
|
void scstart(struct tty *tp);
|
1994-02-01 06:22:29 +00:00
|
|
|
|
void pccnprobe(struct consdev *cp);
|
|
|
|
|
void pccninit(struct consdev *cp);
|
1993-11-27 06:32:41 +00:00
|
|
|
|
void pccnputc(dev_t dev, char c);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
int pccngetc(dev_t dev);
|
1994-10-20 00:08:31 +00:00
|
|
|
|
int pccncheckc(dev_t dev);
|
1994-02-01 06:22:29 +00:00
|
|
|
|
void scintr(int unit);
|
1993-10-28 05:27:36 +00:00
|
|
|
|
int pcmmap(dev_t dev, int offset, int nprot);
|
1994-02-01 06:22:29 +00:00
|
|
|
|
static void scinit(void);
|
|
|
|
|
static void scput(u_char c);
|
|
|
|
|
static u_int scgetc(int noblock);
|
1993-10-28 05:27:36 +00:00
|
|
|
|
static struct tty *get_tty_ptr(dev_t dev);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
static scr_stat *get_scr_stat(dev_t dev);
|
1995-01-12 11:47:05 +00:00
|
|
|
|
static scr_stat *alloc_scp();
|
|
|
|
|
static void init_scp(scr_stat *scp);
|
1994-02-01 06:22:29 +00:00
|
|
|
|
static int get_scr_num();
|
1995-01-12 11:47:05 +00:00
|
|
|
|
static void scrn_timer();
|
1993-07-26 21:21:11 +00:00
|
|
|
|
static void clear_screen(scr_stat *scp);
|
1995-01-12 11:47:05 +00:00
|
|
|
|
static int switch_scr(scr_stat *scp, u_int next_scr);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
static void exchange_scr(void);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
static inline void move_crsr(scr_stat *scp, int x, int y);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
static void scan_esc(scr_stat *scp, u_char c);
|
1995-02-01 21:56:32 +00:00
|
|
|
|
static inline void draw_cursor(scr_stat *scp, int show);
|
1995-01-20 08:35:32 +00:00
|
|
|
|
static void ansi_put(scr_stat *scp, u_char *buf, int len);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
static u_char *get_fstr(u_int c, u_int *len);
|
1993-11-27 06:32:41 +00:00
|
|
|
|
static void update_leds(int which);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
static void history_to_screen(scr_stat *scp);
|
|
|
|
|
static int history_up_line(scr_stat *scp);
|
|
|
|
|
static int history_down_line(scr_stat *scp);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
static void kbd_wait(void);
|
|
|
|
|
static void kbd_cmd(u_char command);
|
|
|
|
|
static void set_mode(scr_stat *scp);
|
|
|
|
|
static void set_border(int color);
|
1994-09-15 07:26:40 +00:00
|
|
|
|
static void set_vgaregs(char *modetable);
|
1995-01-20 08:35:32 +00:00
|
|
|
|
static void set_font_mode();
|
|
|
|
|
static void set_normal_mode();
|
|
|
|
|
static void copy_font(int operation, int font_type, char* font_image);
|
|
|
|
|
static void draw_mouse_image(scr_stat *scp);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
static void save_palette(void);
|
|
|
|
|
static void load_palette(void);
|
1995-01-12 11:47:05 +00:00
|
|
|
|
static void do_bell(scr_stat *scp, int pitch, int duration);
|
|
|
|
|
static void blink_screen(scr_stat *scp);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
1994-02-04 10:36:15 +00:00
|
|
|
|
/* available screen savers */
|
1995-01-28 22:18:05 +00:00
|
|
|
|
static void none_saver(int blank);
|
|
|
|
|
static void blank_saver(int blank);
|
|
|
|
|
static void fade_saver(int blank);
|
|
|
|
|
static void star_saver(int blank);
|
|
|
|
|
static void snake_saver(int blank);
|
|
|
|
|
static void green_saver(int blank);
|
1994-02-04 10:36:15 +00:00
|
|
|
|
|
|
|
|
|
static const struct {
|
|
|
|
|
char *name;
|
|
|
|
|
void (*routine)();
|
|
|
|
|
} screen_savers[] = {
|
|
|
|
|
{ "none", none_saver }, /* 0 */
|
|
|
|
|
{ "blank", blank_saver }, /* 1 */
|
|
|
|
|
{ "fade", fade_saver }, /* 2 */
|
|
|
|
|
{ "star", star_saver }, /* 3 */
|
|
|
|
|
{ "snake", snake_saver }, /* 4 */
|
1994-09-15 07:26:40 +00:00
|
|
|
|
{ "green", green_saver }, /* 5 */
|
1994-02-04 10:36:15 +00:00
|
|
|
|
};
|
|
|
|
|
#define SCRN_SAVER(arg) (*screen_savers[scrn_saver].routine)(arg)
|
|
|
|
|
#define NUM_SCRN_SAVERS (sizeof(screen_savers) / sizeof(screen_savers[0]))
|
1995-01-28 22:18:05 +00:00
|
|
|
|
#define WRAPHIST(scp, pointer, offset)\
|
|
|
|
|
((scp->history) + ((((pointer) - (scp->history)) + (scp->history_size)\
|
|
|
|
|
+ (offset)) % (scp->history_size)))
|
1994-02-04 10:36:15 +00:00
|
|
|
|
|
1994-02-01 06:22:29 +00:00
|
|
|
|
/* OS specific stuff */
|
1995-01-28 22:18:05 +00:00
|
|
|
|
#ifdef not_yet_done
|
1995-01-20 08:35:32 +00:00
|
|
|
|
#define VIRTUAL_TTY(x) (sccons[x] = ttymalloc(sccons[x]))
|
1995-01-28 22:18:05 +00:00
|
|
|
|
struct CONSOLE_TTY (sccons[MAXCONS] = ttymalloc(sccons[MAXCONS]))
|
|
|
|
|
struct tty *sccons[MAXCONS+1];
|
1994-05-25 09:21:21 +00:00
|
|
|
|
#else
|
1995-01-20 08:35:32 +00:00
|
|
|
|
#define VIRTUAL_TTY(x) &sccons[x]
|
1995-01-28 22:18:05 +00:00
|
|
|
|
#define CONSOLE_TTY &sccons[MAXCONS]
|
|
|
|
|
struct tty sccons[MAXCONS+1];
|
1994-05-25 09:21:21 +00:00
|
|
|
|
#endif
|
1994-10-26 21:51:22 +00:00
|
|
|
|
#define MONO_BUF pa_to_va(0xB0000)
|
|
|
|
|
#define CGA_BUF pa_to_va(0xB8000)
|
1994-08-17 08:51:59 +00:00
|
|
|
|
u_short *Crtat = (u_short *)MONO_BUF;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
|
1993-07-26 21:21:11 +00:00
|
|
|
|
struct isa_driver scdriver = {
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scprobe, scattach, "sc", 1
|
1993-07-30 02:20:26 +00:00
|
|
|
|
};
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
int
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scprobe(struct isa_device *dev)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1994-08-17 08:51:59 +00:00
|
|
|
|
int i, retries = 5;
|
|
|
|
|
unsigned char val;
|
|
|
|
|
|
1993-07-26 21:21:11 +00:00
|
|
|
|
/* Enable interrupts and keyboard controller */
|
|
|
|
|
kbd_wait();
|
|
|
|
|
outb(KB_STAT, KB_WRITE);
|
1994-08-17 08:51:59 +00:00
|
|
|
|
kbd_wait();
|
|
|
|
|
outb(KB_DATA, KB_MODE);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
/* flush any noise in the buffer */
|
|
|
|
|
while (inb(KB_STAT) & KB_BUF_FULL) {
|
|
|
|
|
DELAY(10);
|
|
|
|
|
(void) inb(KB_DATA);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Reset keyboard hardware */
|
|
|
|
|
while (retries--) {
|
|
|
|
|
kbd_wait();
|
|
|
|
|
outb(KB_DATA, KB_RESET);
|
|
|
|
|
for (i=0; i<100000; i++) {
|
|
|
|
|
DELAY(10);
|
|
|
|
|
val = inb(KB_DATA);
|
|
|
|
|
if (val == KB_ACK || val == KB_ECHO)
|
|
|
|
|
goto gotres;
|
|
|
|
|
if (val == KB_RESEND)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gotres:
|
|
|
|
|
if (!retries)
|
|
|
|
|
printf("scprobe: keyboard won't accept RESET command\n");
|
|
|
|
|
else {
|
|
|
|
|
gotack:
|
|
|
|
|
DELAY(10);
|
|
|
|
|
while ((inb(KB_STAT) & KB_BUF_FULL) == 0) DELAY(10);
|
|
|
|
|
DELAY(10);
|
|
|
|
|
val = inb(KB_DATA);
|
|
|
|
|
if (val == KB_ACK)
|
|
|
|
|
goto gotack;
|
|
|
|
|
if (val != KB_RESET_DONE)
|
|
|
|
|
printf("scprobe: keyboard RESET failed %02x\n", val);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
1994-12-26 17:50:18 +00:00
|
|
|
|
#ifdef XT_KEYBOARD
|
1994-12-31 20:34:19 +00:00
|
|
|
|
kbd_wait();
|
|
|
|
|
outb(KB_DATA, 0xF0);
|
|
|
|
|
kbd_wait();
|
|
|
|
|
outb(KB_DATA, 1)
|
1994-12-26 17:50:18 +00:00
|
|
|
|
kbd_wait();
|
|
|
|
|
#endif /* XT_KEYBOARD */
|
1993-08-28 13:26:30 +00:00
|
|
|
|
return (IO_KBDSIZE);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-10-23 21:28:03 +00:00
|
|
|
|
static struct kern_devconf kdc_sc[NSC] = { {
|
|
|
|
|
0, 0, 0, /* filled in by dev_attach */
|
|
|
|
|
"sc", 0, { MDDT_ISA, 0, "tty" },
|
|
|
|
|
isa_generic_externalize, 0, 0, ISA_EXTERNALLEN,
|
|
|
|
|
&kdc_isa0, /* parent */
|
|
|
|
|
0, /* parentdata */
|
1995-01-28 22:18:05 +00:00
|
|
|
|
DC_BUSY, /* the console is almost always busy */
|
1994-10-24 21:36:38 +00:00
|
|
|
|
"Graphics console"
|
1994-10-23 21:28:03 +00:00
|
|
|
|
} };
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
sc_registerdev(struct isa_device *id)
|
|
|
|
|
{
|
|
|
|
|
if(id->id_unit)
|
|
|
|
|
kdc_sc[id->id_unit] = kdc_sc[0];
|
|
|
|
|
kdc_sc[id->id_unit].kdc_unit = id->id_unit;
|
|
|
|
|
kdc_sc[id->id_unit].kdc_isa = id;
|
|
|
|
|
dev_attach(&kdc_sc[id->id_unit]);
|
|
|
|
|
}
|
|
|
|
|
|
1995-02-17 02:22:57 +00:00
|
|
|
|
#if NAPM > 0
|
|
|
|
|
/* ARGSUSED */
|
|
|
|
|
static int
|
|
|
|
|
pcresume(void *dummy)
|
|
|
|
|
{
|
|
|
|
|
shfts = 0;
|
|
|
|
|
ctls = 0;
|
|
|
|
|
alts = 0;
|
|
|
|
|
agrs = 0;
|
|
|
|
|
metas = 0;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
#endif /* NAPM > 0 */
|
|
|
|
|
|
1994-10-23 21:28:03 +00:00
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
int
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scattach(struct isa_device *dev)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1995-02-03 21:09:44 +00:00
|
|
|
|
scr_stat *scp;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scinit();
|
1995-01-12 11:47:05 +00:00
|
|
|
|
configuration = dev->id_flags;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
printf("sc%d: ", dev->id_unit);
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (crtc_vga)
|
|
|
|
|
if (crtc_addr == MONO_BASE)
|
1993-09-28 00:01:18 +00:00
|
|
|
|
printf("VGA mono");
|
1993-07-30 02:20:26 +00:00
|
|
|
|
else
|
1993-09-28 00:01:18 +00:00
|
|
|
|
printf("VGA color");
|
1993-07-30 02:20:26 +00:00
|
|
|
|
else
|
|
|
|
|
if (crtc_addr == MONO_BASE)
|
1993-09-28 00:01:18 +00:00
|
|
|
|
printf("MDA/hercules");
|
1993-07-30 02:20:26 +00:00
|
|
|
|
else
|
1993-09-28 00:01:18 +00:00
|
|
|
|
printf("CGA/EGA");
|
1995-01-28 22:18:05 +00:00
|
|
|
|
printf(" <%d virtual consoles, flags=0x%x>\n",
|
1995-01-12 11:47:05 +00:00
|
|
|
|
MAXCONS, configuration);
|
1995-02-03 21:09:44 +00:00
|
|
|
|
scp = console[0];
|
1995-01-28 22:18:05 +00:00
|
|
|
|
scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short),
|
1995-02-01 21:56:32 +00:00
|
|
|
|
M_DEVBUF, M_NOWAIT);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
/* copy screen to buffer */
|
|
|
|
|
bcopyw(Crtat, scp->scr_buf, scp->xsize * scp->ysize * sizeof(u_short));
|
|
|
|
|
scp->cursor_pos = scp->scr_buf + scp->xpos + scp->ypos * scp->xsize;
|
|
|
|
|
scp->mouse_pos = scp->scr_buf;
|
|
|
|
|
|
1995-02-03 21:09:44 +00:00
|
|
|
|
/* initialize history buffer & pointers */
|
1995-01-28 22:18:05 +00:00
|
|
|
|
scp->history_head = scp->history_pos = scp->history =
|
|
|
|
|
(u_short *)malloc(scp->history_size*sizeof(u_short),
|
1995-01-20 08:35:32 +00:00
|
|
|
|
M_DEVBUF, M_NOWAIT);
|
1995-01-30 21:36:32 +00:00
|
|
|
|
bzero(scp->history_head, scp->history_size*sizeof(u_short));
|
1995-02-03 21:09:44 +00:00
|
|
|
|
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if (crtc_vga) {
|
1994-08-17 08:51:59 +00:00
|
|
|
|
font_8 = (char *)malloc(8*256, M_DEVBUF, M_NOWAIT);
|
|
|
|
|
font_14 = (char *)malloc(14*256, M_DEVBUF, M_NOWAIT);
|
|
|
|
|
font_16 = (char *)malloc(16*256, M_DEVBUF, M_NOWAIT);
|
1995-01-20 08:35:32 +00:00
|
|
|
|
copy_font(SAVE, FONT_16, font_16);
|
|
|
|
|
fonts_loaded = FONT_16;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
scp->font = FONT_16;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
save_palette();
|
|
|
|
|
}
|
1995-02-03 21:09:44 +00:00
|
|
|
|
|
|
|
|
|
/* get screen update going */
|
1995-01-12 11:47:05 +00:00
|
|
|
|
scrn_timer();
|
1995-02-03 21:09:44 +00:00
|
|
|
|
|
1995-01-28 22:18:05 +00:00
|
|
|
|
update_leds(scp->status);
|
1994-10-23 21:28:03 +00:00
|
|
|
|
sc_registerdev(dev);
|
1995-02-17 02:22:57 +00:00
|
|
|
|
#if NAPM > 0
|
|
|
|
|
scp->r_hook.ah_fun = pcresume;
|
|
|
|
|
scp->r_hook.ah_arg = NULL;
|
|
|
|
|
scp->r_hook.ah_name = "pccons keyboard";
|
|
|
|
|
scp->r_hook.ah_order = APM_MID_ORDER;
|
|
|
|
|
apm_hook_establish(APM_HOOK_RESUME , &scp->r_hook);
|
|
|
|
|
#endif /* NAPM > 0*/
|
1994-02-01 06:22:29 +00:00
|
|
|
|
return 0;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static struct tty
|
|
|
|
|
*get_tty_ptr(dev_t dev)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1993-10-28 05:27:36 +00:00
|
|
|
|
int unit = minor(dev);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (unit > MAXCONS || unit < 0)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return(NULL);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (unit == MAXCONS)
|
|
|
|
|
return CONSOLE_TTY;
|
|
|
|
|
return VIRTUAL_TTY(unit);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static scr_stat
|
|
|
|
|
*get_scr_stat(dev_t dev)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1993-10-28 05:27:36 +00:00
|
|
|
|
int unit = minor(dev);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (unit > MAXCONS || unit < 0)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return(NULL);
|
1995-02-05 23:44:25 +00:00
|
|
|
|
if (unit == MAXCONS)
|
1995-01-28 22:18:05 +00:00
|
|
|
|
return console[0];
|
|
|
|
|
return console[unit];
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static int
|
|
|
|
|
get_scr_num()
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
1995-01-12 11:47:05 +00:00
|
|
|
|
while ((i < MAXCONS) && (cur_console != console[i])) i++;
|
|
|
|
|
return i < MAXCONS ? i : 0;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
int
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scopen(dev_t dev, int flag, int mode, struct proc *p)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1993-10-28 05:27:36 +00:00
|
|
|
|
struct tty *tp = get_tty_ptr(dev);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
|
|
|
|
if (!tp)
|
|
|
|
|
return(ENXIO);
|
1994-02-01 06:22:29 +00:00
|
|
|
|
|
1995-01-20 08:35:32 +00:00
|
|
|
|
tp->t_oproc = scstart;
|
|
|
|
|
tp->t_param = scparam;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
tp->t_dev = dev;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (!(tp->t_state & TS_ISOPEN)) {
|
1993-07-26 21:21:11 +00:00
|
|
|
|
ttychars(tp);
|
|
|
|
|
tp->t_iflag = TTYDEF_IFLAG;
|
|
|
|
|
tp->t_oflag = TTYDEF_OFLAG;
|
|
|
|
|
tp->t_cflag = TTYDEF_CFLAG;
|
|
|
|
|
tp->t_lflag = TTYDEF_LFLAG;
|
|
|
|
|
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scparam(tp, &tp->t_termios);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
ttsetwater(tp);
|
1995-01-12 11:47:05 +00:00
|
|
|
|
} else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return(EBUSY);
|
|
|
|
|
tp->t_state |= TS_CARR_ON;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
tp->t_cflag |= CLOCAL;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
if (!console[minor(dev)])
|
|
|
|
|
console[minor(dev)] = alloc_scp();
|
1994-02-01 06:22:29 +00:00
|
|
|
|
return((*linesw[tp->t_line].l_open)(dev, tp));
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
int
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scclose(dev_t dev, int flag, int mode, struct proc *p)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1993-10-28 05:27:36 +00:00
|
|
|
|
struct tty *tp = get_tty_ptr(dev);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
struct scr_stat *scp;
|
|
|
|
|
|
|
|
|
|
if (!tp)
|
|
|
|
|
return(ENXIO);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (minor(dev) < MAXCONS) {
|
|
|
|
|
scp = get_scr_stat(tp->t_dev);
|
|
|
|
|
if (scp->status & SWITCH_WAIT_ACQ)
|
|
|
|
|
wakeup((caddr_t)&scp->smode);
|
|
|
|
|
#if not_yet_done
|
|
|
|
|
if (scp == &main_console) {
|
|
|
|
|
scp->pid = 0;
|
|
|
|
|
scp->proc = NULL;
|
|
|
|
|
scp->smode.mode = VT_AUTO;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
free(scp->scr_buf, M_DEVBUF);
|
|
|
|
|
free(scp->history, M_DEVBUF);
|
|
|
|
|
free(scp, M_DEVBUF);
|
|
|
|
|
console[minor(dev)] = NULL;
|
|
|
|
|
}
|
|
|
|
|
#else
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scp->pid = 0;
|
|
|
|
|
scp->proc = NULL;
|
|
|
|
|
scp->smode.mode = VT_AUTO;
|
|
|
|
|
#endif
|
1995-01-28 22:18:05 +00:00
|
|
|
|
}
|
|
|
|
|
(*linesw[tp->t_line].l_close)(tp, flag);
|
|
|
|
|
ttyclose(tp);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
int
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scread(dev_t dev, struct uio *uio, int flag)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1993-10-28 05:27:36 +00:00
|
|
|
|
struct tty *tp = get_tty_ptr(dev);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
|
|
|
|
if (!tp)
|
|
|
|
|
return(ENXIO);
|
|
|
|
|
return((*linesw[tp->t_line].l_read)(tp, uio, flag));
|
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
int
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scwrite(dev_t dev, struct uio *uio, int flag)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1993-10-28 05:27:36 +00:00
|
|
|
|
struct tty *tp = get_tty_ptr(dev);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
|
|
|
|
if (!tp)
|
|
|
|
|
return(ENXIO);
|
|
|
|
|
return((*linesw[tp->t_line].l_write)(tp, uio, flag));
|
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
void
|
|
|
|
|
scintr(int unit)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1994-02-01 06:22:29 +00:00
|
|
|
|
static struct tty *cur_tty;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
int c, len;
|
|
|
|
|
u_char *cp;
|
|
|
|
|
|
1993-07-30 02:20:26 +00:00
|
|
|
|
/* make screensaver happy */
|
|
|
|
|
scrn_time_stamp = time.tv_sec;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (scrn_blanked) {
|
|
|
|
|
SCRN_SAVER(FALSE);
|
1995-02-01 21:56:32 +00:00
|
|
|
|
cur_console->status |= UPDATE_SCREEN;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
}
|
1993-10-28 05:27:36 +00:00
|
|
|
|
|
1994-02-01 06:22:29 +00:00
|
|
|
|
c = scgetc(1);
|
|
|
|
|
|
|
|
|
|
cur_tty = VIRTUAL_TTY(get_scr_num());
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (!(cur_tty->t_state & TS_ISOPEN))
|
|
|
|
|
if (!((cur_tty = CONSOLE_TTY)->t_state & TS_ISOPEN))
|
|
|
|
|
return;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
|
|
|
|
|
switch (c & 0xff00) {
|
|
|
|
|
case 0x0000: /* normal key */
|
|
|
|
|
(*linesw[cur_tty->t_line].l_rint)(c & 0xFF, cur_tty);
|
|
|
|
|
break;
|
|
|
|
|
case NOKEY: /* nothing there */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
break;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
case FKEY: /* function key, return string */
|
|
|
|
|
if (cp = get_fstr((u_int)c, (u_int *)&len)) {
|
|
|
|
|
while (len-- > 0)
|
|
|
|
|
(*linesw[cur_tty->t_line].l_rint)
|
|
|
|
|
(*cp++ & 0xFF, cur_tty);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case MKEY: /* meta is active, prepend ESC */
|
|
|
|
|
(*linesw[cur_tty->t_line].l_rint)(0x1b, cur_tty);
|
|
|
|
|
(*linesw[cur_tty->t_line].l_rint)(c & 0xFF, cur_tty);
|
|
|
|
|
break;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
case BKEY: /* backtab fixed sequence (esc [ Z) */
|
|
|
|
|
(*linesw[cur_tty->t_line].l_rint)(0x1b, cur_tty);
|
|
|
|
|
(*linesw[cur_tty->t_line].l_rint)('[', cur_tty);
|
|
|
|
|
(*linesw[cur_tty->t_line].l_rint)('Z', cur_tty);
|
|
|
|
|
break;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
int
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scparam(struct tty *tp, struct termios *t)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
|
|
|
|
int cflag = t->c_cflag;
|
|
|
|
|
|
|
|
|
|
/* and copy to tty */
|
|
|
|
|
tp->t_ispeed = t->c_ispeed;
|
|
|
|
|
tp->t_ospeed = t->c_ospeed;
|
|
|
|
|
tp->t_cflag = cflag;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
return 0;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
int
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1993-09-28 00:01:18 +00:00
|
|
|
|
int i, error;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
struct tty *tp;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
struct trapframe *fp;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
scr_stat *scp;
|
|
|
|
|
|
1993-10-28 05:27:36 +00:00
|
|
|
|
tp = get_tty_ptr(dev);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
if (!tp)
|
1993-07-30 02:20:26 +00:00
|
|
|
|
return ENXIO;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
scp = get_scr_stat(tp->t_dev);
|
|
|
|
|
|
|
|
|
|
switch (cmd) { /* process console hardware related ioctl's */
|
|
|
|
|
|
1994-10-17 22:12:06 +00:00
|
|
|
|
case GIO_ATTR: /* get current attributes */
|
|
|
|
|
*(int*)data = scp->term.cur_attr;
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case GIO_COLOR: /* is this a color console ? */
|
|
|
|
|
if (crtc_addr == COLOR_BASE)
|
|
|
|
|
*(int*)data = 1;
|
|
|
|
|
else
|
|
|
|
|
*(int*)data = 0;
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case CONS_CURRENT: /* get current adapter type */
|
|
|
|
|
if (crtc_vga)
|
|
|
|
|
*(int*)data = KD_VGA;
|
|
|
|
|
else
|
|
|
|
|
if (crtc_addr == MONO_BASE)
|
|
|
|
|
*(int*)data = KD_MONO;
|
|
|
|
|
else
|
|
|
|
|
*(int*)data = KD_CGA;
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case CONS_GET: /* get current video mode */
|
|
|
|
|
*(int*)data = scp->mode;
|
|
|
|
|
return 0;
|
|
|
|
|
|
1993-07-26 21:21:11 +00:00
|
|
|
|
case CONS_BLANKTIME: /* set screen saver timeout (0 = no saver) */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
scrn_blank_time = *(int*)data;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return 0;
|
1994-09-15 07:26:40 +00:00
|
|
|
|
|
|
|
|
|
#define SAVER(p) ((ssaver_t *)(p))
|
1994-02-04 10:36:15 +00:00
|
|
|
|
case CONS_SSAVER: /* set screen saver */
|
1994-09-15 07:26:40 +00:00
|
|
|
|
if (SAVER(data)->num < 0
|
|
|
|
|
|| SAVER(data)->num >= NUM_SCRN_SAVERS)
|
1994-02-04 10:36:15 +00:00
|
|
|
|
return EIO;
|
1995-02-05 23:44:25 +00:00
|
|
|
|
if (scrn_blanked) {
|
|
|
|
|
SCRN_SAVER(FALSE);
|
|
|
|
|
cur_console->status |= UPDATE_SCREEN;
|
|
|
|
|
}
|
1994-09-15 07:26:40 +00:00
|
|
|
|
scrn_saver = SAVER(data)->num;
|
|
|
|
|
scrn_blank_time = SAVER(data)->time;
|
1994-02-04 10:36:15 +00:00
|
|
|
|
return 0;
|
1994-09-15 07:26:40 +00:00
|
|
|
|
|
1994-02-04 10:36:15 +00:00
|
|
|
|
case CONS_GSAVER: /* get screen saver info */
|
1994-09-15 07:26:40 +00:00
|
|
|
|
if (SAVER(data)->num < 0)
|
|
|
|
|
SAVER(data)->num = scrn_saver;
|
|
|
|
|
else if (SAVER(data)->num >= NUM_SCRN_SAVERS)
|
1994-02-04 10:36:15 +00:00
|
|
|
|
return EIO;
|
1994-09-15 07:26:40 +00:00
|
|
|
|
SAVER(data)->time = scrn_blank_time;
|
|
|
|
|
strcpy(SAVER(data)->name, screen_savers[SAVER(data)->num].name);
|
1994-02-04 10:36:15 +00:00
|
|
|
|
return 0;
|
1994-09-15 07:26:40 +00:00
|
|
|
|
|
1995-01-12 11:47:05 +00:00
|
|
|
|
case CONS_CURSORTYPE: /* set cursor type blink/noblink */
|
1995-02-03 21:09:44 +00:00
|
|
|
|
if ((*(int*)data) & 0x01)
|
1995-01-12 11:47:05 +00:00
|
|
|
|
configuration |= BLINK_CURSOR;
|
|
|
|
|
else
|
|
|
|
|
configuration &= ~BLINK_CURSOR;
|
1995-02-03 21:09:44 +00:00
|
|
|
|
if ((*(int*)data) & 0x02)
|
|
|
|
|
configuration |= CHAR_CURSOR;
|
|
|
|
|
else
|
|
|
|
|
configuration &= ~CHAR_CURSOR;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case CONS_BELLTYPE: /* set bell type sound/visual */
|
|
|
|
|
if (*data)
|
|
|
|
|
configuration |= VISUAL_BELL;
|
|
|
|
|
else
|
|
|
|
|
configuration &= ~VISUAL_BELL;
|
|
|
|
|
return 0;
|
|
|
|
|
|
1995-01-20 08:35:32 +00:00
|
|
|
|
case CONS_HISTORY: /* set history size */
|
|
|
|
|
if (*data) {
|
1995-01-30 21:36:32 +00:00
|
|
|
|
free(scp->history, M_DEVBUF);
|
|
|
|
|
scp->history_size = *(int*)data;
|
|
|
|
|
if (scp->history_size < scp->ysize)
|
|
|
|
|
scp->history = NULL;
|
|
|
|
|
else {
|
|
|
|
|
scp->history_size *= scp->xsize;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scp->history_head = scp->history_pos = scp->history =
|
1995-01-30 21:36:32 +00:00
|
|
|
|
(u_short *)malloc(scp->history_size*sizeof(u_short),
|
|
|
|
|
M_DEVBUF, M_NOWAIT);
|
|
|
|
|
bzero(scp->history_head,
|
|
|
|
|
scp->history_size*sizeof(u_short));
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
|
|
case CONS_MOUSECTL:
|
|
|
|
|
{
|
|
|
|
|
mouse_info_t *mouse = (mouse_info_t*)data;
|
|
|
|
|
int fontsize;
|
|
|
|
|
|
|
|
|
|
switch (scp->font) {
|
|
|
|
|
default:
|
|
|
|
|
case FONT_8:
|
|
|
|
|
fontsize = 8; break;
|
|
|
|
|
case FONT_14:
|
|
|
|
|
fontsize = 14; break;
|
|
|
|
|
case FONT_16:
|
|
|
|
|
fontsize = 16; break;
|
|
|
|
|
}
|
|
|
|
|
switch (mouse->operation) {
|
|
|
|
|
case MOUSE_SHOW:
|
|
|
|
|
if (!(scp->status & MOUSE_ENABLED)) {
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->mouse_oldpos =
|
|
|
|
|
Crtat + (scp->mouse_pos - scp->scr_buf);
|
|
|
|
|
scp->status |= (UPDATE_MOUSE | MOUSE_ENABLED);
|
1995-01-20 08:35:32 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return EINVAL;
|
|
|
|
|
break;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
|
1995-01-20 08:35:32 +00:00
|
|
|
|
case MOUSE_HIDE:
|
|
|
|
|
if (scp->status & MOUSE_ENABLED) {
|
|
|
|
|
scp->status &= ~MOUSE_ENABLED;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->status |= UPDATE_MOUSE;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return EINVAL;
|
|
|
|
|
break;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
|
1995-01-20 08:35:32 +00:00
|
|
|
|
case MOUSE_MOVEABS:
|
|
|
|
|
scp->mouse_xpos = mouse->x;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->mouse_ypos = mouse->y;
|
|
|
|
|
goto set_mouse_pos;
|
|
|
|
|
|
1995-01-20 08:35:32 +00:00
|
|
|
|
case MOUSE_MOVEREL:
|
|
|
|
|
scp->mouse_xpos += mouse->x;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->mouse_ypos += mouse->y;
|
|
|
|
|
set_mouse_pos:
|
|
|
|
|
if (scp->mouse_xpos < 0)
|
|
|
|
|
scp->mouse_xpos = 0;
|
|
|
|
|
if (scp->mouse_ypos < 0)
|
|
|
|
|
scp->mouse_ypos = 0;
|
|
|
|
|
if (scp->mouse_xpos >= scp->xsize*8)
|
|
|
|
|
scp->mouse_xpos = (scp->xsize*8)-1;
|
|
|
|
|
if (scp->mouse_ypos >= scp->ysize*fontsize)
|
|
|
|
|
scp->mouse_ypos = (scp->ysize*fontsize)-1;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
scp->mouse_pos = scp->scr_buf +
|
1995-01-20 08:35:32 +00:00
|
|
|
|
(scp->mouse_ypos/fontsize)*scp->xsize +
|
|
|
|
|
scp->mouse_xpos/8;
|
|
|
|
|
if (scp->status & MOUSE_ENABLED)
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->status |= UPDATE_MOUSE;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
break;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
|
1995-01-20 08:35:32 +00:00
|
|
|
|
case MOUSE_GETPOS:
|
|
|
|
|
mouse->x = scp->mouse_xpos;
|
|
|
|
|
mouse->y = scp->mouse_ypos;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
1995-01-20 08:35:32 +00:00
|
|
|
|
default:
|
|
|
|
|
return EINVAL;
|
|
|
|
|
}
|
1995-02-01 21:56:32 +00:00
|
|
|
|
/* make screensaver happy */
|
|
|
|
|
if (scp == cur_console) {
|
|
|
|
|
scrn_time_stamp = time.tv_sec;
|
1995-02-05 23:44:25 +00:00
|
|
|
|
if (scrn_blanked) {
|
1995-02-01 21:56:32 +00:00
|
|
|
|
SCRN_SAVER(FALSE);
|
1995-02-05 23:44:25 +00:00
|
|
|
|
scp->status |= UPDATE_SCREEN;
|
|
|
|
|
}
|
1995-02-01 21:56:32 +00:00
|
|
|
|
}
|
1995-01-20 08:35:32 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1994-10-17 22:12:06 +00:00
|
|
|
|
case CONS_GETINFO: /* get current (virtual) console info */
|
|
|
|
|
{
|
|
|
|
|
vid_info_t *ptr = (vid_info_t*)data;
|
|
|
|
|
if (ptr->size == sizeof(struct vid_info)) {
|
|
|
|
|
ptr->m_num = get_scr_num();
|
|
|
|
|
ptr->mv_col = scp->xpos;
|
|
|
|
|
ptr->mv_row = scp->ypos;
|
|
|
|
|
ptr->mv_csz = scp->xsize;
|
|
|
|
|
ptr->mv_rsz = scp->ysize;
|
|
|
|
|
ptr->mv_norm.fore = (scp->term.std_attr & 0x0f00)>>8;
|
|
|
|
|
ptr->mv_norm.back = (scp->term.std_attr & 0xf000)>>12;
|
|
|
|
|
ptr->mv_rev.fore = (scp->term.rev_attr & 0x0f00)>>8;
|
|
|
|
|
ptr->mv_rev.back = (scp->term.rev_attr & 0xf000)>>12;
|
|
|
|
|
ptr->mv_grfc.fore = 0; /* not supported */
|
|
|
|
|
ptr->mv_grfc.back = 0; /* not supported */
|
|
|
|
|
ptr->mv_ovscan = scp->border;
|
|
|
|
|
ptr->mk_keylock = scp->status & LOCK_KEY_MASK;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case CONS_GETVERS: /* get version number */
|
1995-01-12 11:47:05 +00:00
|
|
|
|
*(int*)data = 0x200; /* version 2.0 */
|
1994-10-17 22:12:06 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
1995-02-01 21:56:32 +00:00
|
|
|
|
case SW_VGA_C40x25: case SW_VGA_C80x25: /* VGA TEXT MODES */
|
|
|
|
|
case SW_VGA_M80x25:
|
|
|
|
|
case SW_VGA_C80x30: case SW_VGA_M80x30:
|
|
|
|
|
case SW_VGA_C80x50: case SW_VGA_M80x50:
|
|
|
|
|
case SW_VGA_C80x60: case SW_VGA_M80x60:
|
|
|
|
|
case SW_B40x25: case SW_C40x25:
|
|
|
|
|
case SW_B80x25: case SW_C80x25:
|
|
|
|
|
case SW_ENH_B40x25: case SW_ENH_C40x25:
|
|
|
|
|
case SW_ENH_B80x25: case SW_ENH_C80x25:
|
|
|
|
|
case SW_ENH_B80x43: case SW_ENH_C80x43:
|
|
|
|
|
|
|
|
|
|
if (!crtc_vga || video_mode_ptr == NULL)
|
|
|
|
|
return ENXIO;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
switch (cmd & 0xff) {
|
|
|
|
|
case M_VGA_C80x60: case M_VGA_M80x60:
|
1995-01-20 08:35:32 +00:00
|
|
|
|
if (!(fonts_loaded & FONT_8))
|
1994-09-27 01:50:07 +00:00
|
|
|
|
return EINVAL;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
scp->xsize = 80;
|
|
|
|
|
scp->ysize = 60;
|
1994-09-27 01:50:07 +00:00
|
|
|
|
break;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
case M_VGA_C80x50: case M_VGA_M80x50:
|
1995-01-20 08:35:32 +00:00
|
|
|
|
if (!(fonts_loaded & FONT_8))
|
1994-09-27 01:50:07 +00:00
|
|
|
|
return EINVAL;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
scp->xsize = 80;
|
|
|
|
|
scp->ysize = 50;
|
1994-09-27 01:50:07 +00:00
|
|
|
|
break;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
case M_ENH_B80x43: case M_ENH_C80x43:
|
1995-01-20 08:35:32 +00:00
|
|
|
|
if (!(fonts_loaded & FONT_8))
|
1994-09-27 01:50:07 +00:00
|
|
|
|
return EINVAL;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
scp->xsize = 80;
|
|
|
|
|
scp->ysize = 43;
|
|
|
|
|
break;
|
|
|
|
|
case M_VGA_C80x30: case M_VGA_M80x30:
|
|
|
|
|
scp->xsize = 80;
|
|
|
|
|
scp->ysize = 30;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if ((cmd & 0xff) > M_VGA_CG320)
|
|
|
|
|
return EINVAL;
|
|
|
|
|
else
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->xsize = *(video_mode_ptr+((cmd&0xff)*64));
|
|
|
|
|
scp->ysize = *(video_mode_ptr+((cmd&0xff)*64)+1)+1;
|
1994-09-27 01:50:07 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
1995-01-12 11:47:05 +00:00
|
|
|
|
scp->mode = cmd & 0xff;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->status &= ~UNKNOWN_MODE; /* text mode */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
free(scp->scr_buf, M_DEVBUF);
|
1995-01-12 11:47:05 +00:00
|
|
|
|
scp->scr_buf = (u_short *)malloc(scp->xsize * scp->ysize *
|
|
|
|
|
sizeof(u_short), M_DEVBUF, M_NOWAIT);
|
1994-09-15 07:26:40 +00:00
|
|
|
|
if (scp == cur_console)
|
1995-02-01 21:56:32 +00:00
|
|
|
|
set_mode(scp);
|
|
|
|
|
clear_screen(scp);
|
1994-09-15 07:26:40 +00:00
|
|
|
|
if (tp->t_winsize.ws_col != scp->xsize
|
|
|
|
|
|| tp->t_winsize.ws_row != scp->ysize) {
|
|
|
|
|
tp->t_winsize.ws_col = scp->xsize;
|
|
|
|
|
tp->t_winsize.ws_row = scp->ysize;
|
|
|
|
|
pgsignal(tp->t_pgrp, SIGWINCH, 1);
|
1994-08-17 08:51:59 +00:00
|
|
|
|
}
|
1995-02-01 21:56:32 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* GRAPHICS MODES */
|
|
|
|
|
case SW_BG320: case SW_CG320: case SW_BG640:
|
|
|
|
|
case SW_CG320_D: case SW_CG640_E:
|
|
|
|
|
case SW_CG640x350: case SW_ENH_CG640:
|
|
|
|
|
case SW_BG640x480: case SW_CG640x480: case SW_VGA_CG320:
|
|
|
|
|
|
|
|
|
|
if (!crtc_vga || video_mode_ptr == NULL)
|
|
|
|
|
return ENXIO;
|
|
|
|
|
scp->mode = cmd & 0xFF;
|
|
|
|
|
scp->status |= UNKNOWN_MODE; /* graphics mode */
|
|
|
|
|
scp->xsize = (*(video_mode_ptr + (scp->mode*64))) * 8;
|
|
|
|
|
scp->ysize = (*(video_mode_ptr + (scp->mode*64) + 1) + 1)
|
|
|
|
|
* (*(video_mode_ptr + (scp->mode*64) + 2));
|
|
|
|
|
set_mode(scp);
|
|
|
|
|
/* clear_graphics();*/
|
1995-01-12 11:47:05 +00:00
|
|
|
|
|
1994-11-17 22:03:18 +00:00
|
|
|
|
if (tp->t_winsize.ws_xpixel != scp->xsize
|
|
|
|
|
|| tp->t_winsize.ws_ypixel != scp->ysize) {
|
|
|
|
|
tp->t_winsize.ws_xpixel = scp->xsize;
|
|
|
|
|
tp->t_winsize.ws_ypixel = scp->ysize;
|
|
|
|
|
pgsignal(tp->t_pgrp, SIGWINCH, 1);
|
|
|
|
|
}
|
1995-02-01 21:56:32 +00:00
|
|
|
|
return 0;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
|
|
|
|
case VT_SETMODE: /* set screen switcher mode */
|
|
|
|
|
bcopy(data, &scp->smode, sizeof(struct vt_mode));
|
|
|
|
|
if (scp->smode.mode == VT_PROCESS) {
|
|
|
|
|
scp->proc = p;
|
|
|
|
|
scp->pid = scp->proc->p_pid;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case VT_GETMODE: /* get screen switcher mode */
|
|
|
|
|
bcopy(&scp->smode, data, sizeof(struct vt_mode));
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case VT_RELDISP: /* screen switcher ioctl */
|
|
|
|
|
switch(*data) {
|
|
|
|
|
case VT_FALSE: /* user refuses to release screen, abort */
|
|
|
|
|
if (scp == old_scp && (scp->status & SWITCH_WAIT_REL)) {
|
|
|
|
|
old_scp->status &= ~SWITCH_WAIT_REL;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
switch_in_progress = FALSE;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
|
|
case VT_TRUE: /* user has released screen, go on */
|
|
|
|
|
if (scp == old_scp && (scp->status & SWITCH_WAIT_REL)) {
|
|
|
|
|
scp->status &= ~SWITCH_WAIT_REL;
|
|
|
|
|
exchange_scr();
|
|
|
|
|
if (new_scp->smode.mode == VT_PROCESS) {
|
|
|
|
|
new_scp->status |= SWITCH_WAIT_ACQ;
|
|
|
|
|
psignal(new_scp->proc,
|
|
|
|
|
new_scp->smode.acqsig);
|
|
|
|
|
}
|
|
|
|
|
else
|
1995-01-28 22:18:05 +00:00
|
|
|
|
switch_in_progress = FALSE;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
|
|
case VT_ACKACQ: /* acquire acknowledged, switch completed */
|
|
|
|
|
if (scp == new_scp && (scp->status & SWITCH_WAIT_ACQ)) {
|
|
|
|
|
scp->status &= ~SWITCH_WAIT_ACQ;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
switch_in_progress = FALSE;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return EINVAL;
|
|
|
|
|
}
|
|
|
|
|
/* NOT REACHED */
|
|
|
|
|
|
1993-09-28 00:01:18 +00:00
|
|
|
|
case VT_OPENQRY: /* return free virtual console */
|
1995-02-01 21:56:32 +00:00
|
|
|
|
for (i = 0; i < MAXCONS; i++) {
|
1994-02-01 06:22:29 +00:00
|
|
|
|
tp = VIRTUAL_TTY(i);
|
1995-02-01 21:56:32 +00:00
|
|
|
|
if (!(tp->t_state & TS_ISOPEN)) {
|
|
|
|
|
*data = i + 1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
1994-02-01 06:22:29 +00:00
|
|
|
|
}
|
1995-02-01 21:56:32 +00:00
|
|
|
|
return EINVAL;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
|
|
|
|
case VT_ACTIVATE: /* switch to screen *data */
|
1995-01-12 11:47:05 +00:00
|
|
|
|
return switch_scr(scp, (*data) - 1);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
|
|
|
|
case VT_WAITACTIVE: /* wait for switch to occur */
|
1995-01-12 11:47:05 +00:00
|
|
|
|
if (*data > MAXCONS || *data < 0)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return EINVAL;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
if (minor(dev) == (*data) - 1)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return 0;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
if (*data == 0) {
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if (scp == cur_console)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
1995-01-12 11:47:05 +00:00
|
|
|
|
scp = console[(*data) - 1];
|
|
|
|
|
while ((error=tsleep((caddr_t)&scp->smode, PZERO|PCATCH,
|
|
|
|
|
"waitvt", 0)) == ERESTART) ;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return error;
|
|
|
|
|
|
1993-10-28 05:27:36 +00:00
|
|
|
|
case VT_GETACTIVE:
|
1994-02-01 06:22:29 +00:00
|
|
|
|
*data = get_scr_num()+1;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
1993-07-26 21:21:11 +00:00
|
|
|
|
case KDENABIO: /* allow io operations */
|
1995-02-01 21:56:32 +00:00
|
|
|
|
fp = (struct trapframe *)p->p_md.md_regs;
|
|
|
|
|
fp->tf_eflags |= PSL_IOPL;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case KDDISABIO: /* disallow io operations (default) */
|
1995-02-01 21:56:32 +00:00
|
|
|
|
fp = (struct trapframe *)p->p_md.md_regs;
|
|
|
|
|
fp->tf_eflags &= ~PSL_IOPL;
|
|
|
|
|
return 0;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
1995-02-01 21:56:32 +00:00
|
|
|
|
case KDSETMODE: /* set current mode of this (virtual) console */
|
1993-07-26 21:21:11 +00:00
|
|
|
|
switch (*data) {
|
|
|
|
|
case KD_TEXT: /* switch to TEXT (known) mode */
|
|
|
|
|
/* restore fonts & palette ! */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (crtc_vga) {
|
1995-01-20 08:35:32 +00:00
|
|
|
|
if (fonts_loaded & FONT_8)
|
|
|
|
|
copy_font(LOAD, FONT_8, font_8);
|
|
|
|
|
if (fonts_loaded & FONT_14)
|
|
|
|
|
copy_font(LOAD, FONT_14, font_14);
|
|
|
|
|
if (fonts_loaded & FONT_16)
|
|
|
|
|
copy_font(LOAD, FONT_16, font_16);
|
1993-07-30 02:20:26 +00:00
|
|
|
|
load_palette();
|
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
/* FALL THROUGH */
|
|
|
|
|
|
|
|
|
|
case KD_TEXT1: /* switch to TEXT (known) mode */
|
|
|
|
|
/* no restore fonts & palette */
|
|
|
|
|
scp->status &= ~UNKNOWN_MODE;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
if (crtc_vga && video_mode_ptr)
|
1995-01-12 11:47:05 +00:00
|
|
|
|
set_mode(scp);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
clear_screen(scp);
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case KD_GRAPHICS:/* switch to GRAPHICS (unknown) mode */
|
|
|
|
|
scp->status |= UNKNOWN_MODE;
|
|
|
|
|
return 0;
|
|
|
|
|
default:
|
|
|
|
|
return EINVAL;
|
|
|
|
|
}
|
|
|
|
|
/* NOT REACHED */
|
|
|
|
|
|
|
|
|
|
case KDGETMODE: /* get current mode of this (virtual) console */
|
|
|
|
|
*data = (scp->status & UNKNOWN_MODE) ? KD_GRAPHICS : KD_TEXT;
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case KDSBORDER: /* set border color of this (virtual) console */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (!crtc_vga)
|
|
|
|
|
return ENXIO;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
scp->border = *data;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if (scp == cur_console)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
set_border(scp->border);
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case KDSKBSTATE: /* set keyboard state (locks) */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (*data >= 0 && *data <= LOCK_KEY_MASK) {
|
1993-07-26 21:21:11 +00:00
|
|
|
|
scp->status &= ~LOCK_KEY_MASK;
|
|
|
|
|
scp->status |= *data;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if (scp == cur_console)
|
1994-04-01 18:33:12 +00:00
|
|
|
|
update_leds(scp->status);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
|
|
case KDGKBSTATE: /* get keyboard state (locks) */
|
|
|
|
|
*data = scp->status & LOCK_KEY_MASK;
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case KDSETRAD: /* set keyboard repeat & delay rates */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (*data & 0x80)
|
|
|
|
|
return EINVAL;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
i = spltty();
|
|
|
|
|
kbd_cmd(KB_SETRAD);
|
|
|
|
|
kbd_cmd(*data);
|
|
|
|
|
splx(i);
|
1994-02-01 06:22:29 +00:00
|
|
|
|
return 0;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
|
|
|
|
case KDSKBMODE: /* set keyboard mode */
|
|
|
|
|
switch (*data) {
|
|
|
|
|
case K_RAW: /* switch to RAW scancode mode */
|
|
|
|
|
scp->status |= KBD_RAW_MODE;
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case K_XLATE: /* switch to XLT ascii mode */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (scp == cur_console && scp->status == KBD_RAW_MODE)
|
|
|
|
|
shfts = ctls = alts = agrs = metas = 0;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
scp->status &= ~KBD_RAW_MODE;
|
|
|
|
|
return 0;
|
|
|
|
|
default:
|
|
|
|
|
return EINVAL;
|
|
|
|
|
}
|
|
|
|
|
/* NOT REACHED */
|
|
|
|
|
|
|
|
|
|
case KDGKBMODE: /* get keyboard mode */
|
|
|
|
|
*data = (scp->status & KBD_RAW_MODE) ? K_RAW : K_XLATE;
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case KDMKTONE: /* sound the bell */
|
1995-01-12 11:47:05 +00:00
|
|
|
|
if (*(int*)data) {
|
1995-02-01 21:56:32 +00:00
|
|
|
|
do_bell(scp, (*(int*)data)&0xffff,
|
1995-01-12 11:47:05 +00:00
|
|
|
|
(((*(int*)data)>>16)&0xffff)*hz/1000);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
do_bell(scp, scp->bell_pitch, scp->bell_duration);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case KIOCSOUND: /* make tone (*data) hz */
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if (scp == cur_console) {
|
1993-07-26 21:21:11 +00:00
|
|
|
|
if (*(int*)data) {
|
1993-10-28 05:27:36 +00:00
|
|
|
|
int pitch = TIMER_FREQ/(*(int*)data);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
/* set command for counter 2, 2 byte write */
|
1994-04-21 14:22:26 +00:00
|
|
|
|
if (acquire_timer2(TIMER_16BIT|TIMER_SQWAVE)) {
|
|
|
|
|
return EBUSY;
|
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
/* set pitch */
|
1993-10-28 05:27:36 +00:00
|
|
|
|
outb(TIMER_CNTR2, pitch);
|
|
|
|
|
outb(TIMER_CNTR2, (pitch>>8));
|
1994-04-21 14:22:26 +00:00
|
|
|
|
/* enable counter 2 output to speaker */
|
1994-04-26 09:09:57 +00:00
|
|
|
|
outb(IO_PPI, inb(IO_PPI) | 3);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
1994-04-21 14:22:26 +00:00
|
|
|
|
/* disable counter 2 output to speaker */
|
1994-04-26 09:09:57 +00:00
|
|
|
|
outb(IO_PPI, inb(IO_PPI) & 0xFC);
|
1994-04-21 14:22:26 +00:00
|
|
|
|
release_timer2();
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case KDGKBTYPE: /* get keyboard type */
|
|
|
|
|
*data = 0; /* type not known (yet) */
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case KDSETLED: /* set keyboard LED status */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (*data >= 0 && *data <= LED_MASK) {
|
|
|
|
|
scp->status &= ~LED_MASK;
|
|
|
|
|
scp->status |= *data;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if (scp == cur_console)
|
1994-04-01 18:33:12 +00:00
|
|
|
|
update_leds(scp->status);
|
1993-07-30 02:20:26 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return EINVAL;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
|
|
|
|
case KDGETLED: /* get keyboard LED status */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
*data = scp->status & LED_MASK;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case GETFKEY: /* get functionkey string */
|
|
|
|
|
if (*(u_short*)data < n_fkey_tab) {
|
1995-02-01 21:56:32 +00:00
|
|
|
|
fkeyarg_t *ptr = (fkeyarg_t*)data;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
bcopy(&fkey_tab[ptr->keynum].str,
|
|
|
|
|
ptr->keydef,
|
|
|
|
|
fkey_tab[ptr->keynum].len);
|
|
|
|
|
ptr->flen = fkey_tab[ptr->keynum].len;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
|
|
case SETFKEY: /* set functionkey string */
|
|
|
|
|
if (*(u_short*)data < n_fkey_tab) {
|
1995-02-01 21:56:32 +00:00
|
|
|
|
fkeyarg_t *ptr = (fkeyarg_t*)data;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
bcopy(ptr->keydef,
|
|
|
|
|
&fkey_tab[ptr->keynum].str,
|
|
|
|
|
min(ptr->flen, MAXFK));
|
|
|
|
|
fkey_tab[ptr->keynum].len = min(ptr->flen, MAXFK);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
|
|
case GIO_SCRNMAP: /* get output translation table */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
bcopy(&scr_map, data, sizeof(scr_map));
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case PIO_SCRNMAP: /* set output translation table */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
bcopy(data, &scr_map, sizeof(scr_map));
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case GIO_KEYMAP: /* get keyboard translation table */
|
|
|
|
|
bcopy(&key_map, data, sizeof(key_map));
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case PIO_KEYMAP: /* set keyboard translation table */
|
|
|
|
|
bcopy(data, &key_map, sizeof(key_map));
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case PIO_FONT8x8: /* set 8x8 dot font */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (!crtc_vga)
|
|
|
|
|
return ENXIO;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
bcopy(data, font_8, 8*256);
|
1995-01-20 08:35:32 +00:00
|
|
|
|
fonts_loaded |= FONT_8;
|
|
|
|
|
copy_font(LOAD, FONT_8, font_8);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case GIO_FONT8x8: /* get 8x8 dot font */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (!crtc_vga)
|
|
|
|
|
return ENXIO;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
if (fonts_loaded & FONT_8) {
|
1994-08-17 08:51:59 +00:00
|
|
|
|
bcopy(font_8, data, 8*256);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return ENXIO;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
|
|
|
|
case PIO_FONT8x14: /* set 8x14 dot font */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (!crtc_vga)
|
|
|
|
|
return ENXIO;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
bcopy(data, font_14, 14*256);
|
1995-01-20 08:35:32 +00:00
|
|
|
|
fonts_loaded |= FONT_14;
|
|
|
|
|
copy_font(LOAD, FONT_14, font_14);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case GIO_FONT8x14: /* get 8x14 dot font */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (!crtc_vga)
|
|
|
|
|
return ENXIO;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
if (fonts_loaded & FONT_14) {
|
1994-08-17 08:51:59 +00:00
|
|
|
|
bcopy(font_14, data, 14*256);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return ENXIO;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
|
|
|
|
case PIO_FONT8x16: /* set 8x16 dot font */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (!crtc_vga)
|
|
|
|
|
return ENXIO;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
bcopy(data, font_16, 16*256);
|
1995-01-20 08:35:32 +00:00
|
|
|
|
fonts_loaded |= FONT_16;
|
|
|
|
|
copy_font(LOAD, FONT_16, font_16);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case GIO_FONT8x16: /* get 8x16 dot font */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (!crtc_vga)
|
|
|
|
|
return ENXIO;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
if (fonts_loaded & FONT_16) {
|
1994-08-17 08:51:59 +00:00
|
|
|
|
bcopy(font_16, data, 16*256);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return ENXIO;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
1994-05-25 09:21:21 +00:00
|
|
|
|
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
if (error >= 0)
|
|
|
|
|
return(error);
|
|
|
|
|
error = ttioctl(tp, cmd, data, flag);
|
|
|
|
|
if (error >= 0)
|
|
|
|
|
return(error);
|
|
|
|
|
return(ENOTTY);
|
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
void
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scxint(dev_t dev)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1994-02-01 06:22:29 +00:00
|
|
|
|
struct tty *tp = get_tty_ptr(dev);
|
1993-10-28 05:27:36 +00:00
|
|
|
|
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (!tp)
|
1993-10-28 05:27:36 +00:00
|
|
|
|
return;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
tp->t_state &= ~TS_BUSY;
|
|
|
|
|
if (tp->t_line)
|
|
|
|
|
(*linesw[tp->t_line].l_start)(tp);
|
1993-10-28 05:27:36 +00:00
|
|
|
|
else
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scstart(tp);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
void
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scstart(struct tty *tp)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1993-10-28 05:27:36 +00:00
|
|
|
|
struct clist *rbp;
|
|
|
|
|
int i, s, len;
|
|
|
|
|
u_char buf[PCBURST];
|
|
|
|
|
scr_stat *scp = get_scr_stat(tp->t_dev);
|
|
|
|
|
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (scp->status & SLKED || blink_in_progress)
|
1993-10-28 05:27:36 +00:00
|
|
|
|
return;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
s = spltty();
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if (!(tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP))) {
|
|
|
|
|
tp->t_state |= TS_BUSY;
|
|
|
|
|
splx(s);
|
|
|
|
|
rbp = &tp->t_outq;
|
1995-02-07 11:53:27 +00:00
|
|
|
|
/* scp->status &= ~CURSOR_ENABLED; */
|
1994-08-01 10:38:19 +00:00
|
|
|
|
while (rbp->c_cc) {
|
1995-01-20 08:35:32 +00:00
|
|
|
|
len = q_to_b(rbp, buf, PCBURST);
|
|
|
|
|
ansi_put(scp, buf, len);
|
1994-08-01 10:38:19 +00:00
|
|
|
|
}
|
1995-02-07 11:53:27 +00:00
|
|
|
|
/* scp->status |= (CURSOR_ENABLED | UPDATE_SCREEN); */
|
|
|
|
|
scp->status |= UPDATE_SCREEN;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
s = spltty();
|
|
|
|
|
tp->t_state &= ~TS_BUSY;
|
|
|
|
|
if (rbp->c_cc <= tp->t_lowat) {
|
|
|
|
|
if (tp->t_state & TS_ASLEEP) {
|
|
|
|
|
tp->t_state &= ~TS_ASLEEP;
|
|
|
|
|
wakeup((caddr_t)rbp);
|
|
|
|
|
}
|
|
|
|
|
selwakeup(&tp->t_wsel);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
splx(s);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
void
|
|
|
|
|
pccnprobe(struct consdev *cp)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
|
|
|
|
int maj;
|
|
|
|
|
|
|
|
|
|
/* locate the major number */
|
|
|
|
|
for (maj = 0; maj < nchrdev; maj++)
|
1995-01-20 08:35:32 +00:00
|
|
|
|
if ((void*)cdevsw[maj].d_open == (void*)scopen)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* initialize required fields */
|
1995-01-28 22:18:05 +00:00
|
|
|
|
cp->cn_dev = makedev(maj, MAXCONS);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
cp->cn_pri = CN_INTERNAL;
|
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
void
|
|
|
|
|
pccninit(struct consdev *cp)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1993-10-28 05:27:36 +00:00
|
|
|
|
scinit();
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
void
|
|
|
|
|
pccnputc(dev_t dev, char c)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
|
|
|
|
if (c == '\n')
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scput('\r');
|
|
|
|
|
scput(c);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
int
|
|
|
|
|
pccngetc(dev_t dev)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1994-02-01 06:22:29 +00:00
|
|
|
|
int s = spltty(); /* block scintr while we poll */
|
|
|
|
|
int c = scgetc(0);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
splx(s);
|
|
|
|
|
return(c);
|
|
|
|
|
}
|
|
|
|
|
|
1994-10-20 00:08:31 +00:00
|
|
|
|
int
|
|
|
|
|
pccncheckc(dev_t dev)
|
|
|
|
|
{
|
|
|
|
|
return (scgetc(1) & 0xff);
|
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
1995-01-28 22:18:05 +00:00
|
|
|
|
none_saver(int blank)
|
1994-02-04 10:36:15 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
1995-01-28 22:18:05 +00:00
|
|
|
|
fade_saver(int blank)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1994-02-01 06:22:29 +00:00
|
|
|
|
static int count = 0;
|
|
|
|
|
int i;
|
|
|
|
|
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (blank) {
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scrn_blanked = 1;
|
|
|
|
|
if (count < 64) {
|
1995-02-01 21:56:32 +00:00
|
|
|
|
outb(PIXMASK, 0xFF); /* no pixelmask */
|
|
|
|
|
outb(PALWADR, 0x00);
|
|
|
|
|
outb(PALDATA, 0);
|
|
|
|
|
outb(PALDATA, 0);
|
|
|
|
|
outb(PALDATA, 0);
|
|
|
|
|
for (i = 3; i < 768; i++) {
|
|
|
|
|
if (palette[i] - count > 15)
|
|
|
|
|
outb(PALDATA, palette[i]-count);
|
1994-02-01 06:22:29 +00:00
|
|
|
|
else
|
1995-02-01 21:56:32 +00:00
|
|
|
|
outb(PALDATA, 15);
|
1994-02-01 06:22:29 +00:00
|
|
|
|
}
|
|
|
|
|
inb(crtc_addr+6); /* reset flip/flop */
|
|
|
|
|
outb(ATC, 0x20); /* enable palette */
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
load_palette();
|
1995-01-28 22:18:05 +00:00
|
|
|
|
count = scrn_blanked = 0;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1993-07-30 02:20:26 +00:00
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
1995-01-28 22:18:05 +00:00
|
|
|
|
blank_saver(int blank)
|
1994-02-04 10:36:15 +00:00
|
|
|
|
{
|
1994-02-01 06:22:29 +00:00
|
|
|
|
u_char val;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (blank) {
|
1993-07-30 02:20:26 +00:00
|
|
|
|
scrn_blanked = 1;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
outb(TSIDX, 0x01); val = inb(TSREG);
|
1993-07-30 02:20:26 +00:00
|
|
|
|
outb(TSIDX, 0x01); outb(TSREG, val | 0x20);
|
|
|
|
|
}
|
|
|
|
|
else {
|
1995-02-01 21:56:32 +00:00
|
|
|
|
outb(TSIDX, 0x01); val = inb(TSREG);
|
1993-07-30 02:20:26 +00:00
|
|
|
|
outb(TSIDX, 0x01); outb(TSREG, val & 0xDF);
|
o Restore removed hardware cursor support and make it _default_
case, software cursor now optional case. Driver must provide
raw things (what hardware do for us, exactly) as default case,
all driver features must be _optional_. Modern VGAs have internal
configuration utilities to set cursor shape/blinking which stored
into cards ROM, and syscons nuke out such features completely
by forcing software cursor. Moreover, software cursor is hard
to distinguish on standouted (or near standouted) fields and
tends to disappearse from the screen.
Set "flags 0x4" to enable software cursor now.
o Cleanup screen savers.
o Don't draw cursor if saver or blinker is active.
o Duplicated code moved to functons.
o Add more checks for blinker in progress, character lost otherwise
when blinker restore old contents.
o Reduce blinking counter to 3, too slow in old variant.
o Fix timeout code in scrn_timer(), old variant can reenter iself,
if action takes too long time.
o Disable visual bell for scroll lock mode, saved screen
becomes overwritted otherwise.
1995-01-26 04:56:25 +00:00
|
|
|
|
scrn_blanked = 0;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
}
|
1994-02-04 10:36:15 +00:00
|
|
|
|
}
|
1993-07-30 02:20:26 +00:00
|
|
|
|
|
1994-09-15 07:26:40 +00:00
|
|
|
|
static void
|
1995-01-28 22:18:05 +00:00
|
|
|
|
green_saver(int blank)
|
1994-09-15 07:26:40 +00:00
|
|
|
|
{
|
|
|
|
|
u_char val;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (blank) {
|
1994-09-15 07:26:40 +00:00
|
|
|
|
scrn_blanked = 1;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
outb(TSIDX, 0x01); val = inb(TSREG);
|
1994-09-15 07:26:40 +00:00
|
|
|
|
outb(TSIDX, 0x01); outb(TSREG, val | 0x20);
|
|
|
|
|
outb(crtc_addr, 0x17); val = inb(crtc_addr + 1);
|
|
|
|
|
outb(crtc_addr + 1, val & ~0x80);
|
|
|
|
|
}
|
|
|
|
|
else {
|
1995-02-01 21:56:32 +00:00
|
|
|
|
outb(TSIDX, 0x01); val = inb(TSREG);
|
1994-09-15 07:26:40 +00:00
|
|
|
|
outb(TSIDX, 0x01); outb(TSREG, val & 0xDF);
|
1995-02-01 21:56:32 +00:00
|
|
|
|
outb(crtc_addr, 0x17); val = inb(crtc_addr + 1);
|
|
|
|
|
outb(crtc_addr + 1, val | 0x80);
|
o Restore removed hardware cursor support and make it _default_
case, software cursor now optional case. Driver must provide
raw things (what hardware do for us, exactly) as default case,
all driver features must be _optional_. Modern VGAs have internal
configuration utilities to set cursor shape/blinking which stored
into cards ROM, and syscons nuke out such features completely
by forcing software cursor. Moreover, software cursor is hard
to distinguish on standouted (or near standouted) fields and
tends to disappearse from the screen.
Set "flags 0x4" to enable software cursor now.
o Cleanup screen savers.
o Don't draw cursor if saver or blinker is active.
o Duplicated code moved to functons.
o Add more checks for blinker in progress, character lost otherwise
when blinker restore old contents.
o Reduce blinking counter to 3, too slow in old variant.
o Fix timeout code in scrn_timer(), old variant can reenter iself,
if action takes too long time.
o Disable visual bell for scroll lock mode, saved screen
becomes overwritted otherwise.
1995-01-26 04:56:25 +00:00
|
|
|
|
scrn_blanked = 0;
|
1994-09-15 07:26:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
#define NUM_STARS 50
|
1994-02-01 06:22:29 +00:00
|
|
|
|
|
1993-07-30 02:20:26 +00:00
|
|
|
|
/*
|
|
|
|
|
* Alternate saver that got its inspiration from a well known utility
|
1994-08-17 08:51:59 +00:00
|
|
|
|
* package for an inferior^H^H^H^H^H^Hfamous OS.
|
1993-07-30 02:20:26 +00:00
|
|
|
|
*/
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
1995-01-28 22:18:05 +00:00
|
|
|
|
star_saver(int blank)
|
1993-07-30 02:20:26 +00:00
|
|
|
|
{
|
1993-10-28 05:27:36 +00:00
|
|
|
|
scr_stat *scp = cur_console;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
int cell, i;
|
|
|
|
|
char pattern[] = {"...........++++*** "};
|
|
|
|
|
char colors[] = {FG_DARKGREY, FG_LIGHTGREY,
|
|
|
|
|
FG_WHITE, FG_LIGHTCYAN};
|
|
|
|
|
static u_short stars[NUM_STARS][2];
|
|
|
|
|
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (blank) {
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (!scrn_blanked) {
|
o Restore removed hardware cursor support and make it _default_
case, software cursor now optional case. Driver must provide
raw things (what hardware do for us, exactly) as default case,
all driver features must be _optional_. Modern VGAs have internal
configuration utilities to set cursor shape/blinking which stored
into cards ROM, and syscons nuke out such features completely
by forcing software cursor. Moreover, software cursor is hard
to distinguish on standouted (or near standouted) fields and
tends to disappearse from the screen.
Set "flags 0x4" to enable software cursor now.
o Cleanup screen savers.
o Don't draw cursor if saver or blinker is active.
o Duplicated code moved to functons.
o Add more checks for blinker in progress, character lost otherwise
when blinker restore old contents.
o Reduce blinking counter to 3, too slow in old variant.
o Fix timeout code in scrn_timer(), old variant can reenter iself,
if action takes too long time.
o Disable visual bell for scroll lock mode, saved screen
becomes overwritted otherwise.
1995-01-26 04:56:25 +00:00
|
|
|
|
scrn_blanked = 1;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
fillw((FG_LIGHTGREY|BG_BLACK)<<8|scr_map[0x20], Crtat,
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->xsize * scp->ysize);
|
1993-07-30 02:20:26 +00:00
|
|
|
|
set_border(0);
|
1995-02-01 21:56:32 +00:00
|
|
|
|
for(i=0; i<NUM_STARS; i++) {
|
|
|
|
|
stars[i][0] =
|
1994-08-17 08:51:59 +00:00
|
|
|
|
random() % (scp->xsize*scp->ysize);
|
1995-02-01 21:56:32 +00:00
|
|
|
|
stars[i][1] = 0;
|
|
|
|
|
}
|
1993-07-30 02:20:26 +00:00
|
|
|
|
}
|
1995-02-01 21:56:32 +00:00
|
|
|
|
cell = random() % NUM_STARS;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
*((u_short*)(Crtat + stars[cell][0])) =
|
|
|
|
|
scr_map[pattern[stars[cell][1]]] |
|
1995-02-01 21:56:32 +00:00
|
|
|
|
colors[random()%sizeof(colors)] << 8;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
if ((stars[cell][1]+=(random()%4)) >= sizeof(pattern)-1) {
|
1995-02-01 21:56:32 +00:00
|
|
|
|
stars[cell][0] = random() % (scp->xsize*scp->ysize);
|
|
|
|
|
stars[cell][1] = 0;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (scrn_blanked) {
|
|
|
|
|
set_border(scp->border);
|
|
|
|
|
scrn_blanked = 0;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
1995-01-28 22:18:05 +00:00
|
|
|
|
snake_saver(int blank)
|
1994-02-01 10:43:02 +00:00
|
|
|
|
{
|
1994-08-17 08:51:59 +00:00
|
|
|
|
const char saves[] = {"FreeBSD-2.0"};
|
1994-02-01 10:43:02 +00:00
|
|
|
|
static u_char *savs[sizeof(saves)-1];
|
|
|
|
|
static int dirx, diry;
|
|
|
|
|
int f;
|
|
|
|
|
scr_stat *scp = cur_console;
|
|
|
|
|
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (blank) {
|
1994-02-01 10:43:02 +00:00
|
|
|
|
if (!scrn_blanked) {
|
|
|
|
|
fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20],
|
1994-02-01 11:13:49 +00:00
|
|
|
|
Crtat, scp->xsize * scp->ysize);
|
1994-02-01 10:43:02 +00:00
|
|
|
|
set_border(0);
|
1994-02-01 11:13:49 +00:00
|
|
|
|
dirx = (scp->xpos ? 1 : -1);
|
|
|
|
|
diry = (scp->ypos ?
|
|
|
|
|
scp->xsize : -scp->xsize);
|
1994-02-01 10:43:02 +00:00
|
|
|
|
for (f=0; f< sizeof(saves)-1; f++)
|
|
|
|
|
savs[f] = (u_char *)Crtat + 2 *
|
1994-02-01 11:13:49 +00:00
|
|
|
|
(scp->xpos+scp->ypos*scp->xsize);
|
1994-02-01 10:43:02 +00:00
|
|
|
|
*(savs[0]) = scr_map[*saves];
|
1995-01-28 22:18:05 +00:00
|
|
|
|
f = scp->ysize * scp->xsize + 5;
|
|
|
|
|
outb(crtc_addr, 14);
|
|
|
|
|
outb(crtc_addr+1, f >> 8);
|
|
|
|
|
outb(crtc_addr, 15);
|
|
|
|
|
outb(crtc_addr+1, f & 0xff);
|
|
|
|
|
scrn_blanked = 1;
|
1994-02-01 10:43:02 +00:00
|
|
|
|
}
|
|
|
|
|
if (scrn_blanked++ < 4)
|
|
|
|
|
return;
|
|
|
|
|
scrn_blanked = 1;
|
|
|
|
|
*(savs[sizeof(saves)-2]) = scr_map[0x20];
|
|
|
|
|
for (f=sizeof(saves)-2; f > 0; f--)
|
|
|
|
|
savs[f] = savs[f-1];
|
|
|
|
|
f = (savs[0] - (u_char *)Crtat) / 2;
|
1994-02-01 11:13:49 +00:00
|
|
|
|
if ((f % scp->xsize) == 0 ||
|
|
|
|
|
(f % scp->xsize) == scp->xsize - 1 ||
|
1994-08-17 08:51:59 +00:00
|
|
|
|
(random() % 50) == 0)
|
1994-02-01 10:43:02 +00:00
|
|
|
|
dirx = -dirx;
|
1994-02-01 11:13:49 +00:00
|
|
|
|
if ((f / scp->xsize) == 0 ||
|
|
|
|
|
(f / scp->xsize) == scp->ysize - 1 ||
|
1994-08-17 08:51:59 +00:00
|
|
|
|
(random() % 20) == 0)
|
1994-02-01 10:43:02 +00:00
|
|
|
|
diry = -diry;
|
|
|
|
|
savs[0] += 2*dirx + 2*diry;
|
|
|
|
|
for (f=sizeof(saves)-2; f>=0; f--)
|
|
|
|
|
*(savs[f]) = scr_map[saves[f]];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (scrn_blanked) {
|
|
|
|
|
set_border(scp->border);
|
|
|
|
|
scrn_blanked = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
1995-01-28 22:18:05 +00:00
|
|
|
|
scrn_timer()
|
o Restore removed hardware cursor support and make it _default_
case, software cursor now optional case. Driver must provide
raw things (what hardware do for us, exactly) as default case,
all driver features must be _optional_. Modern VGAs have internal
configuration utilities to set cursor shape/blinking which stored
into cards ROM, and syscons nuke out such features completely
by forcing software cursor. Moreover, software cursor is hard
to distinguish on standouted (or near standouted) fields and
tends to disappearse from the screen.
Set "flags 0x4" to enable software cursor now.
o Cleanup screen savers.
o Don't draw cursor if saver or blinker is active.
o Duplicated code moved to functons.
o Add more checks for blinker in progress, character lost otherwise
when blinker restore old contents.
o Reduce blinking counter to 3, too slow in old variant.
o Fix timeout code in scrn_timer(), old variant can reenter iself,
if action takes too long time.
o Disable visual bell for scroll lock mode, saved screen
becomes overwritted otherwise.
1995-01-26 04:56:25 +00:00
|
|
|
|
{
|
1995-02-01 21:56:32 +00:00
|
|
|
|
static int cursor_blinkrate;
|
|
|
|
|
scr_stat *scp = cur_console;
|
o Restore removed hardware cursor support and make it _default_
case, software cursor now optional case. Driver must provide
raw things (what hardware do for us, exactly) as default case,
all driver features must be _optional_. Modern VGAs have internal
configuration utilities to set cursor shape/blinking which stored
into cards ROM, and syscons nuke out such features completely
by forcing software cursor. Moreover, software cursor is hard
to distinguish on standouted (or near standouted) fields and
tends to disappearse from the screen.
Set "flags 0x4" to enable software cursor now.
o Cleanup screen savers.
o Don't draw cursor if saver or blinker is active.
o Duplicated code moved to functons.
o Add more checks for blinker in progress, character lost otherwise
when blinker restore old contents.
o Reduce blinking counter to 3, too slow in old variant.
o Fix timeout code in scrn_timer(), old variant can reenter iself,
if action takes too long time.
o Disable visual bell for scroll lock mode, saved screen
becomes overwritted otherwise.
1995-01-26 04:56:25 +00:00
|
|
|
|
|
1995-02-01 21:56:32 +00:00
|
|
|
|
/* should we just return ? */
|
1995-02-05 23:44:25 +00:00
|
|
|
|
if ((scp->status&UNKNOWN_MODE) || blink_in_progress || switch_in_progress) {
|
1995-02-01 21:56:32 +00:00
|
|
|
|
timeout((timeout_func_t)scrn_timer, 0, hz/10);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!scrn_blanked) {
|
|
|
|
|
/* update entire screen image */
|
|
|
|
|
if (scp->status & UPDATE_SCREEN) {
|
|
|
|
|
bcopyw(scp->scr_buf, Crtat, scp->xsize*scp->ysize*sizeof(u_short));
|
|
|
|
|
scp->status &= ~CURSOR_SHOWN;
|
|
|
|
|
}
|
|
|
|
|
/* update "pseudo" mouse */
|
|
|
|
|
if ((scp->status & MOUSE_ENABLED) &&
|
|
|
|
|
((scp->status & UPDATE_MOUSE) || (scp->status & UPDATE_SCREEN)))
|
|
|
|
|
draw_mouse_image(scp);
|
1995-02-05 23:44:25 +00:00
|
|
|
|
|
1995-02-01 21:56:32 +00:00
|
|
|
|
/* update cursor image */
|
1995-02-05 23:44:25 +00:00
|
|
|
|
if (scp->status & CURSOR_ENABLED)
|
|
|
|
|
draw_cursor(scp,
|
|
|
|
|
!(configuration&BLINK_CURSOR) || !(cursor_blinkrate++&0x04));
|
|
|
|
|
|
|
|
|
|
/* signal update done */
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->status &= ~UPDATE_SCREEN;
|
|
|
|
|
}
|
|
|
|
|
if (scrn_blank_time && (time.tv_sec>scrn_time_stamp+scrn_blank_time))
|
|
|
|
|
SCRN_SAVER(TRUE);
|
|
|
|
|
timeout((timeout_func_t)scrn_timer, 0, hz/25);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
1995-02-01 21:56:32 +00:00
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
|
|
|
|
clear_screen(scr_stat *scp)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
|
|
|
|
move_crsr(scp, 0, 0);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
fillw(scp->term.cur_attr | scr_map[0x20], scp->scr_buf,
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->xsize * scp->ysize);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static int
|
1995-01-12 11:47:05 +00:00
|
|
|
|
switch_scr(scr_stat *scp, u_int next_scr)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1995-02-07 11:53:27 +00:00
|
|
|
|
if (switch_in_progress && (cur_console->proc != pfind(cur_console->pid)))
|
1995-01-28 22:18:05 +00:00
|
|
|
|
switch_in_progress = FALSE;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
|
1995-02-01 21:56:32 +00:00
|
|
|
|
if (next_scr >= MAXCONS || switch_in_progress
|
1995-02-07 11:53:27 +00:00
|
|
|
|
|| (cur_console->smode.mode == VT_AUTO && cur_console->status & UNKNOWN_MODE)) {
|
1995-01-12 11:47:05 +00:00
|
|
|
|
do_bell(scp, BELL_PITCH, BELL_DURATION);
|
1993-11-23 18:20:52 +00:00
|
|
|
|
return EINVAL;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
1994-02-01 06:22:29 +00:00
|
|
|
|
|
|
|
|
|
/* is the wanted virtual console open ? */
|
|
|
|
|
if (next_scr) {
|
|
|
|
|
struct tty *tp = VIRTUAL_TTY(next_scr);
|
|
|
|
|
if (!(tp->t_state & TS_ISOPEN)) {
|
1995-01-12 11:47:05 +00:00
|
|
|
|
do_bell(scp, BELL_PITCH, BELL_DURATION);
|
1994-02-01 06:22:29 +00:00
|
|
|
|
return EINVAL;
|
|
|
|
|
}
|
|
|
|
|
}
|
1995-01-12 11:47:05 +00:00
|
|
|
|
/* delay switch if actively updating screen */
|
|
|
|
|
if (write_in_progress || blink_in_progress) {
|
1994-08-17 08:51:59 +00:00
|
|
|
|
delayed_next_scr = next_scr+1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
1995-01-28 22:18:05 +00:00
|
|
|
|
switch_in_progress = TRUE;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
old_scp = cur_console;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
new_scp = console[next_scr];
|
1993-10-28 05:27:36 +00:00
|
|
|
|
wakeup((caddr_t)&new_scp->smode);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
if (new_scp == old_scp) {
|
1995-01-28 22:18:05 +00:00
|
|
|
|
switch_in_progress = FALSE;
|
1995-02-05 23:44:25 +00:00
|
|
|
|
delayed_next_scr = FALSE;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* has controlling process died? */
|
|
|
|
|
if (old_scp->proc && (old_scp->proc != pfind(old_scp->pid)))
|
|
|
|
|
old_scp->smode.mode = VT_AUTO;
|
|
|
|
|
if (new_scp->proc && (new_scp->proc != pfind(new_scp->pid)))
|
|
|
|
|
new_scp->smode.mode = VT_AUTO;
|
|
|
|
|
|
|
|
|
|
/* check the modes and switch approbiatly */
|
|
|
|
|
if (old_scp->smode.mode == VT_PROCESS) {
|
|
|
|
|
old_scp->status |= SWITCH_WAIT_REL;
|
|
|
|
|
psignal(old_scp->proc, old_scp->smode.relsig);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
exchange_scr();
|
|
|
|
|
if (new_scp->smode.mode == VT_PROCESS) {
|
|
|
|
|
new_scp->status |= SWITCH_WAIT_ACQ;
|
|
|
|
|
psignal(new_scp->proc, new_scp->smode.acqsig);
|
|
|
|
|
}
|
|
|
|
|
else
|
1995-01-28 22:18:05 +00:00
|
|
|
|
switch_in_progress = FALSE;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
|
|
|
|
exchange_scr(void)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1994-02-01 06:22:29 +00:00
|
|
|
|
move_crsr(old_scp, old_scp->xpos, old_scp->ypos);
|
1993-10-28 05:27:36 +00:00
|
|
|
|
cur_console = new_scp;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
if (old_scp->mode != new_scp->mode || (old_scp->status & UNKNOWN_MODE)){
|
1995-02-01 21:56:32 +00:00
|
|
|
|
if (crtc_vga && video_mode_ptr)
|
1995-01-12 11:47:05 +00:00
|
|
|
|
set_mode(new_scp);
|
|
|
|
|
}
|
1994-02-01 06:22:29 +00:00
|
|
|
|
move_crsr(new_scp, new_scp->xpos, new_scp->ypos);
|
1994-04-12 00:05:23 +00:00
|
|
|
|
if ((old_scp->status & UNKNOWN_MODE) && crtc_vga) {
|
1995-01-20 08:35:32 +00:00
|
|
|
|
if (fonts_loaded & FONT_8)
|
|
|
|
|
copy_font(LOAD, FONT_8, font_8);
|
|
|
|
|
if (fonts_loaded & FONT_14)
|
|
|
|
|
copy_font(LOAD, FONT_14, font_14);
|
|
|
|
|
if (fonts_loaded & FONT_16)
|
|
|
|
|
copy_font(LOAD, FONT_16, font_16);
|
1994-04-12 00:05:23 +00:00
|
|
|
|
load_palette();
|
|
|
|
|
}
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE)
|
|
|
|
|
shfts = ctls = alts = agrs = metas = 0;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
update_leds(new_scp->status);
|
|
|
|
|
delayed_next_scr = FALSE;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
new_scp->status |= UPDATE_SCREEN;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-01-28 22:18:05 +00:00
|
|
|
|
static inline void
|
1994-08-17 08:51:59 +00:00
|
|
|
|
move_crsr(scr_stat *scp, int x, int y)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (x < 0 || y < 0 || x >= scp->xsize || y >= scp->ysize)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->xpos = x;
|
|
|
|
|
scp->ypos = y;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
scp->cursor_pos = scp->scr_buf + scp->ypos * scp->xsize + scp->xpos;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
|
|
|
|
scan_esc(scr_stat *scp, u_char c)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
|
|
|
|
static u_char ansi_col[16] =
|
|
|
|
|
{0, 4, 2, 6, 1, 5, 3, 7, 8, 12, 10, 14, 9, 13, 11, 15};
|
1993-07-30 02:20:26 +00:00
|
|
|
|
int i, n;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
u_short *src, *dst, count;
|
|
|
|
|
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (scp->term.esc == 1) {
|
1993-07-26 21:21:11 +00:00
|
|
|
|
switch (c) {
|
|
|
|
|
|
|
|
|
|
case '[': /* Start ESC [ sequence */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
scp->term.esc = 2;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->term.last_param = -1;
|
|
|
|
|
for (i = scp->term.num_param; i < MAX_ESC_PAR; i++)
|
|
|
|
|
scp->term.param[i] = 1;
|
|
|
|
|
scp->term.num_param = 0;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case 'M': /* Move cursor up 1 line, scroll if at top */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (scp->ypos > 0)
|
|
|
|
|
move_crsr(scp, scp->xpos, scp->ypos - 1);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
else {
|
1995-01-28 22:18:05 +00:00
|
|
|
|
bcopyw(scp->scr_buf,
|
|
|
|
|
scp->scr_buf + scp->xsize,
|
1995-01-03 16:56:05 +00:00
|
|
|
|
(scp->ysize - 1) * scp->xsize *
|
|
|
|
|
sizeof(u_short));
|
1994-02-01 06:22:29 +00:00
|
|
|
|
fillw(scp->term.cur_attr | scr_map[0x20],
|
1995-01-28 22:18:05 +00:00
|
|
|
|
scp->scr_buf, scp->xsize);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
#if notyet
|
|
|
|
|
case 'Q':
|
1993-07-30 02:20:26 +00:00
|
|
|
|
scp->term.esc = 4;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
case 'c': /* Clear screen & home */
|
|
|
|
|
clear_screen(scp);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
1993-07-30 02:20:26 +00:00
|
|
|
|
else if (scp->term.esc == 2) {
|
1993-07-26 21:21:11 +00:00
|
|
|
|
if (c >= '0' && c <= '9') {
|
1995-01-12 11:47:05 +00:00
|
|
|
|
if (scp->term.num_param < MAX_ESC_PAR) {
|
|
|
|
|
if (scp->term.last_param != scp->term.num_param) {
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->term.last_param = scp->term.num_param;
|
|
|
|
|
scp->term.param[scp->term.num_param] = 0;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
1995-01-12 11:47:05 +00:00
|
|
|
|
else
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->term.param[scp->term.num_param] *= 10;
|
|
|
|
|
scp->term.param[scp->term.num_param] += c - '0';
|
|
|
|
|
return;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->term.num_param = scp->term.last_param + 1;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
switch (c) {
|
|
|
|
|
|
|
|
|
|
case ';':
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (scp->term.num_param < MAX_ESC_PAR)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '=':
|
1993-07-30 02:20:26 +00:00
|
|
|
|
scp->term.esc = 3;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->term.last_param = -1;
|
|
|
|
|
for (i = scp->term.num_param; i < MAX_ESC_PAR; i++)
|
|
|
|
|
scp->term.param[i] = 1;
|
|
|
|
|
scp->term.num_param = 0;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case 'A': /* up n rows */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
|
|
|
|
move_crsr(scp, scp->xpos, scp->ypos - n);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'B': /* down n rows */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
|
|
|
|
move_crsr(scp, scp->xpos, scp->ypos + n);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'C': /* right n columns */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
|
|
|
|
move_crsr(scp, scp->xpos + n, scp->ypos);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'D': /* left n columns */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
|
|
|
|
move_crsr(scp, scp->xpos - n, scp->ypos);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'E': /* cursor to start of line n lines down */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
|
|
|
|
move_crsr(scp, 0, scp->ypos + n);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'F': /* cursor to start of line n lines up */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
|
|
|
|
move_crsr(scp, 0, scp->ypos - n);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'f': /* System V consoles .. */
|
|
|
|
|
case 'H': /* Cursor move */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (scp->term.num_param == 0)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
move_crsr(scp, 0, 0);
|
1994-02-01 06:22:29 +00:00
|
|
|
|
else if (scp->term.num_param == 2)
|
|
|
|
|
move_crsr(scp, scp->term.param[1] - 1,
|
|
|
|
|
scp->term.param[0] - 1);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'J': /* Clear all or part of display */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (scp->term.num_param == 0)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
n = 0;
|
|
|
|
|
else
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0];
|
1993-07-26 21:21:11 +00:00
|
|
|
|
switch (n) {
|
|
|
|
|
case 0: /* clear form cursor to end of display */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
fillw(scp->term.cur_attr | scr_map[0x20],
|
1995-01-28 22:18:05 +00:00
|
|
|
|
scp->cursor_pos, scp->scr_buf +
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->xsize * scp->ysize -
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scp->cursor_pos);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 1: /* clear from beginning of display to cursor */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
fillw(scp->term.cur_attr | scr_map[0x20],
|
1995-01-28 22:18:05 +00:00
|
|
|
|
scp->scr_buf,
|
|
|
|
|
scp->cursor_pos - scp->scr_buf);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2: /* clear entire display */
|
|
|
|
|
clear_screen(scp);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'K': /* Clear all or part of line */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (scp->term.num_param == 0)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
n = 0;
|
|
|
|
|
else
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0];
|
1993-07-26 21:21:11 +00:00
|
|
|
|
switch (n) {
|
|
|
|
|
case 0: /* clear form cursor to end of line */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
fillw(scp->term.cur_attr | scr_map[0x20],
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scp->cursor_pos, scp->xsize - scp->xpos);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 1: /* clear from beginning of line to cursor */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
fillw(scp->term.cur_attr|scr_map[0x20],
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scp->cursor_pos - (scp->xsize - scp->xpos),
|
1994-02-01 06:22:29 +00:00
|
|
|
|
(scp->xsize - scp->xpos) + 1);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2: /* clear entire line */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
fillw(scp->term.cur_attr|scr_map[0x20],
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scp->cursor_pos - (scp->xsize - scp->xpos),
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->xsize);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'L': /* Insert n lines */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
|
|
|
|
if (n > scp->ysize - scp->ypos)
|
|
|
|
|
n = scp->ysize - scp->ypos;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
src = scp->scr_buf + scp->ypos * scp->xsize;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
dst = src + n * scp->xsize;
|
|
|
|
|
count = scp->ysize - (scp->ypos + n);
|
1995-01-03 16:56:05 +00:00
|
|
|
|
bcopyw(src, dst, count * scp->xsize * sizeof(u_short));
|
1994-02-01 06:22:29 +00:00
|
|
|
|
fillw(scp->term.cur_attr | scr_map[0x20], src,
|
|
|
|
|
n * scp->xsize);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'M': /* Delete n lines */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
|
|
|
|
if (n > scp->ysize - scp->ypos)
|
|
|
|
|
n = scp->ysize - scp->ypos;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
dst = scp->scr_buf + scp->ypos * scp->xsize;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
src = dst + n * scp->xsize;
|
|
|
|
|
count = scp->ysize - (scp->ypos + n);
|
1995-01-03 16:56:05 +00:00
|
|
|
|
bcopyw(src, dst, count * scp->xsize * sizeof(u_short));
|
1994-02-01 06:22:29 +00:00
|
|
|
|
src = dst + count * scp->xsize;
|
|
|
|
|
fillw(scp->term.cur_attr | scr_map[0x20], src,
|
|
|
|
|
n * scp->xsize);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'P': /* Delete n chars */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
|
|
|
|
if (n > scp->xsize - scp->xpos)
|
|
|
|
|
n = scp->xsize - scp->xpos;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
dst = scp->cursor_pos;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
src = dst + n;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
count = scp->xsize - (scp->xpos + n);
|
1995-01-03 16:56:05 +00:00
|
|
|
|
bcopyw(src, dst, count * sizeof(u_short));
|
1993-07-26 21:21:11 +00:00
|
|
|
|
src = dst + count;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
fillw(scp->term.cur_attr | scr_map[0x20], src, n);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '@': /* Insert n chars */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
|
|
|
|
if (n > scp->xsize - scp->xpos)
|
|
|
|
|
n = scp->xsize - scp->xpos;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
src = scp->cursor_pos;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
dst = src + n;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
count = scp->xsize - (scp->xpos + n);
|
1995-01-03 16:56:05 +00:00
|
|
|
|
bcopyw(src, dst, count * sizeof(u_short));
|
1994-02-01 06:22:29 +00:00
|
|
|
|
fillw(scp->term.cur_attr | scr_map[0x20], src, n);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'S': /* scroll up n lines */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
1994-11-21 17:59:29 +00:00
|
|
|
|
if (n > scp->ysize)
|
|
|
|
|
n = scp->ysize;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
bcopyw(scp->scr_buf + (scp->xsize * n),
|
|
|
|
|
scp->scr_buf,
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->xsize * (scp->ysize - n) *
|
1993-07-30 02:20:26 +00:00
|
|
|
|
sizeof(u_short));
|
1994-02-01 06:22:29 +00:00
|
|
|
|
fillw(scp->term.cur_attr | scr_map[0x20],
|
1995-01-28 22:18:05 +00:00
|
|
|
|
scp->scr_buf + scp->xsize *
|
1994-11-21 14:36:02 +00:00
|
|
|
|
(scp->ysize - n),
|
|
|
|
|
scp->xsize * n);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'T': /* scroll down n lines */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
1994-11-21 17:59:29 +00:00
|
|
|
|
if (n > scp->ysize)
|
|
|
|
|
n = scp->ysize;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
bcopyw(scp->scr_buf,
|
|
|
|
|
scp->scr_buf + (scp->xsize * n),
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->xsize * (scp->ysize - n) *
|
1993-07-30 02:20:26 +00:00
|
|
|
|
sizeof(u_short));
|
1994-04-26 09:09:57 +00:00
|
|
|
|
fillw(scp->term.cur_attr | scr_map[0x20],
|
1995-01-28 22:18:05 +00:00
|
|
|
|
scp->scr_buf, scp->xsize * n);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'X': /* delete n characters in line */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
1994-04-26 09:09:57 +00:00
|
|
|
|
if (n > scp->xsize - scp->xpos)
|
|
|
|
|
n = scp->xsize - scp->xpos;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
fillw(scp->term.cur_attr | scr_map[0x20],
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->scr_buf + scp->xpos +
|
1994-02-01 06:22:29 +00:00
|
|
|
|
((scp->xsize*scp->ypos) * sizeof(u_short)), n);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'Z': /* move n tabs backwards */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
|
|
|
|
if ((i = scp->xpos & 0xf8) == scp->xpos)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
i -= 8*n;
|
|
|
|
|
else
|
|
|
|
|
i -= 8*(n-1);
|
|
|
|
|
if (i < 0)
|
|
|
|
|
i = 0;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
move_crsr(scp, i, scp->ypos);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '`': /* move cursor to column n */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
1995-01-13 03:19:22 +00:00
|
|
|
|
move_crsr(scp, n - 1, scp->ypos);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'a': /* move cursor n columns to the right */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
|
|
|
|
move_crsr(scp, scp->xpos + n, scp->ypos);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'd': /* move cursor to row n */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
1995-01-13 03:19:22 +00:00
|
|
|
|
move_crsr(scp, scp->xpos, n - 1);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'e': /* move cursor n rows down */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0]; if (n < 1) n = 1;
|
|
|
|
|
move_crsr(scp, scp->xpos, scp->ypos + n);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'm': /* change attribute */
|
1994-08-17 08:51:59 +00:00
|
|
|
|
if (scp->term.num_param == 0) {
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->term.cur_attr = scp->term.std_attr;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < scp->term.num_param; i++) {
|
|
|
|
|
switch (n = scp->term.param[i]) {
|
|
|
|
|
case 0: /* back to normal */
|
|
|
|
|
scp->term.cur_attr = scp->term.std_attr;
|
|
|
|
|
break;
|
|
|
|
|
case 1: /* highlight (bold) */
|
|
|
|
|
scp->term.cur_attr &= 0xFF00;
|
|
|
|
|
scp->term.cur_attr |= 0x0800;
|
|
|
|
|
break;
|
|
|
|
|
case 4: /* highlight (underline) */
|
|
|
|
|
scp->term.cur_attr &= 0xFF00;
|
|
|
|
|
scp->term.cur_attr |= 0x0800;
|
|
|
|
|
break;
|
|
|
|
|
case 5: /* blink */
|
|
|
|
|
scp->term.cur_attr &= 0xFF00;
|
|
|
|
|
scp->term.cur_attr |= 0x8000;
|
|
|
|
|
break;
|
|
|
|
|
case 7: /* reverse video */
|
|
|
|
|
scp->term.cur_attr = scp->term.rev_attr;
|
|
|
|
|
break;
|
|
|
|
|
case 30: case 31: /* set fg color */
|
|
|
|
|
case 32: case 33: case 34:
|
|
|
|
|
case 35: case 36: case 37:
|
|
|
|
|
scp->term.cur_attr =
|
|
|
|
|
(scp->term.cur_attr & 0xF8FF)
|
|
|
|
|
| (ansi_col[(n-30) & 7] << 8);
|
|
|
|
|
break;
|
|
|
|
|
case 40: case 41: /* set bg color */
|
|
|
|
|
case 42: case 43: case 44:
|
|
|
|
|
case 45: case 46: case 47:
|
|
|
|
|
scp->term.cur_attr =
|
|
|
|
|
(scp->term.cur_attr & 0x8FFF)
|
|
|
|
|
| (ansi_col[(n-40) & 7] << 12);
|
|
|
|
|
break;
|
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'x':
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (scp->term.num_param == 0)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
n = 0;
|
|
|
|
|
else
|
1994-02-01 06:22:29 +00:00
|
|
|
|
n = scp->term.param[0];
|
1993-07-26 21:21:11 +00:00
|
|
|
|
switch (n) {
|
|
|
|
|
case 0: /* reset attributes */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->term.cur_attr = scp->term.std_attr =
|
1995-01-12 11:47:05 +00:00
|
|
|
|
current_default->std_attr;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
scp->term.rev_attr = current_default->rev_attr;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 1: /* set ansi background */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->term.cur_attr = scp->term.std_attr =
|
1995-01-12 11:47:05 +00:00
|
|
|
|
(scp->term.std_attr & 0x0F00) |
|
|
|
|
|
(ansi_col[(scp->term.param[1])&0x0F]<<12);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2: /* set ansi foreground */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->term.cur_attr = scp->term.std_attr =
|
1995-01-12 11:47:05 +00:00
|
|
|
|
(scp->term.std_attr & 0xF000) |
|
|
|
|
|
(ansi_col[(scp->term.param[1])&0x0F]<<8);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 3: /* set ansi attribute directly */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->term.cur_attr = scp->term.std_attr =
|
1995-01-12 11:47:05 +00:00
|
|
|
|
(scp->term.param[1]&0xFF)<<8;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 5: /* set ansi reverse video background */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
scp->term.rev_attr =
|
1995-01-12 11:47:05 +00:00
|
|
|
|
(scp->term.rev_attr & 0x0F00) |
|
|
|
|
|
(ansi_col[(scp->term.param[1])&0x0F]<<12);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 6: /* set ansi reverse video foreground */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
scp->term.rev_attr =
|
1995-01-12 11:47:05 +00:00
|
|
|
|
(scp->term.rev_attr & 0xF000) |
|
|
|
|
|
(ansi_col[(scp->term.param[1])&0x0F]<<8);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 7: /* set ansi reverse video directly */
|
1995-01-12 11:47:05 +00:00
|
|
|
|
scp->term.rev_attr =
|
|
|
|
|
(scp->term.param[1]&0xFF)<<8;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'z': /* switch to (virtual) console n */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (scp->term.num_param == 1)
|
1995-01-12 11:47:05 +00:00
|
|
|
|
switch_scr(scp, scp->term.param[0]);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
1993-07-30 02:20:26 +00:00
|
|
|
|
else if (scp->term.esc == 3) {
|
1993-07-26 21:21:11 +00:00
|
|
|
|
if (c >= '0' && c <= '9') {
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (scp->term.num_param < MAX_ESC_PAR) {
|
|
|
|
|
if (scp->term.last_param != scp->term.num_param) {
|
|
|
|
|
scp->term.last_param = scp->term.num_param;
|
|
|
|
|
scp->term.param[scp->term.num_param] = 0;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
1995-01-28 22:18:05 +00:00
|
|
|
|
else
|
|
|
|
|
scp->term.param[scp->term.num_param] *= 10;
|
|
|
|
|
scp->term.param[scp->term.num_param] += c - '0';
|
|
|
|
|
return;
|
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->term.num_param = scp->term.last_param + 1;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
switch (c) {
|
|
|
|
|
|
|
|
|
|
case ';':
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (scp->term.num_param < MAX_ESC_PAR)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'A': /* set display border color */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (scp->term.num_param == 1)
|
|
|
|
|
scp->border=scp->term.param[0] & 0xff;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if (scp == cur_console)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
set_border(scp->border);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'B': /* set bell pitch and duration */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (scp->term.num_param == 2) {
|
|
|
|
|
scp->bell_pitch = scp->term.param[0];
|
|
|
|
|
scp->bell_duration = scp->term.param[1]*10;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
1995-01-12 11:47:05 +00:00
|
|
|
|
case 'C': /* set cursor type & shape */
|
|
|
|
|
if (scp->term.num_param == 1) {
|
|
|
|
|
if (scp->term.param[0] & 0x01)
|
|
|
|
|
configuration |= BLINK_CURSOR;
|
|
|
|
|
else
|
|
|
|
|
configuration &= ~BLINK_CURSOR;
|
1995-02-03 21:09:44 +00:00
|
|
|
|
if (scp->term.param[0] & 0x02)
|
|
|
|
|
configuration |= CHAR_CURSOR;
|
|
|
|
|
else
|
|
|
|
|
configuration &= ~CHAR_CURSOR;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
}
|
1995-01-28 22:18:05 +00:00
|
|
|
|
else if (scp->term.num_param == 2) {
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->cursor_start = scp->term.param[0] & 0x1F;
|
|
|
|
|
scp->cursor_end = scp->term.param[1] & 0x1F;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'F': /* set ansi foreground */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (scp->term.num_param == 1)
|
|
|
|
|
scp->term.cur_attr = scp->term.std_attr =
|
1993-07-30 02:20:26 +00:00
|
|
|
|
(scp->term.std_attr & 0xF000)
|
1994-02-01 06:22:29 +00:00
|
|
|
|
| ((scp->term.param[0] & 0x0F) << 8);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'G': /* set ansi background */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (scp->term.num_param == 1)
|
|
|
|
|
scp->term.cur_attr = scp->term.std_attr =
|
1993-07-30 02:20:26 +00:00
|
|
|
|
(scp->term.std_attr & 0x0F00)
|
1994-02-01 06:22:29 +00:00
|
|
|
|
| ((scp->term.param[0] & 0x0F) << 12);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'H': /* set ansi reverse video foreground */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (scp->term.num_param == 1)
|
1993-07-30 02:20:26 +00:00
|
|
|
|
scp->term.rev_attr =
|
|
|
|
|
(scp->term.rev_attr & 0xF000)
|
1994-02-01 06:22:29 +00:00
|
|
|
|
| ((scp->term.param[0] & 0x0F) << 8);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'I': /* set ansi reverse video background */
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (scp->term.num_param == 1)
|
1993-07-30 02:20:26 +00:00
|
|
|
|
scp->term.rev_attr =
|
|
|
|
|
(scp->term.rev_attr & 0x0F00)
|
1994-02-01 06:22:29 +00:00
|
|
|
|
| ((scp->term.param[0] & 0x0F) << 12);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
1993-07-30 02:20:26 +00:00
|
|
|
|
scp->term.esc = 0;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-01-28 22:18:05 +00:00
|
|
|
|
static inline void
|
1995-02-01 21:56:32 +00:00
|
|
|
|
draw_cursor(scr_stat *scp, int show)
|
1995-01-12 11:47:05 +00:00
|
|
|
|
{
|
1995-02-01 21:56:32 +00:00
|
|
|
|
if (show && !(scp->status & CURSOR_SHOWN)) {
|
1995-02-05 23:44:25 +00:00
|
|
|
|
u_short cursor_image = *(Crtat + (scp->cursor_pos - scp->scr_buf));
|
1995-02-01 21:56:32 +00:00
|
|
|
|
|
|
|
|
|
scp->cursor_saveunder = cursor_image;
|
1995-02-03 21:09:44 +00:00
|
|
|
|
if (configuration & CHAR_CURSOR)
|
|
|
|
|
cursor_image = (cursor_image & 0xff00) | '_';
|
|
|
|
|
else {
|
|
|
|
|
if ((cursor_image & 0x7000) == 0x7000) {
|
|
|
|
|
cursor_image &= 0x8fff;
|
|
|
|
|
if(!(cursor_image & 0x0700))
|
1995-02-14 14:37:53 +00:00
|
|
|
|
cursor_image |= 0x0700;
|
1995-02-03 21:09:44 +00:00
|
|
|
|
} else {
|
|
|
|
|
cursor_image |= 0x7000;
|
1995-02-14 14:37:53 +00:00
|
|
|
|
if ((cursor_image & 0x0700) == 0x0700)
|
1995-02-03 21:09:44 +00:00
|
|
|
|
cursor_image &= 0xf0ff;
|
|
|
|
|
}
|
1995-02-01 21:56:32 +00:00
|
|
|
|
}
|
1995-02-05 23:44:25 +00:00
|
|
|
|
*(Crtat + (scp->cursor_pos - scp->scr_buf)) = cursor_image;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->status |= CURSOR_SHOWN;
|
|
|
|
|
}
|
|
|
|
|
if (!show && (scp->status & CURSOR_SHOWN)) {
|
|
|
|
|
*(Crtat+(scp->cursor_pos-scp->scr_buf)) = scp->cursor_saveunder;
|
|
|
|
|
scp->status &= ~CURSOR_SHOWN;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
1995-01-20 08:35:32 +00:00
|
|
|
|
ansi_put(scr_stat *scp, u_char *buf, int len)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1995-01-20 08:35:32 +00:00
|
|
|
|
u_char *ptr = buf;
|
|
|
|
|
|
1993-07-26 21:21:11 +00:00
|
|
|
|
if (scp->status & UNKNOWN_MODE)
|
|
|
|
|
return;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
|
1993-07-30 02:20:26 +00:00
|
|
|
|
/* make screensaver happy */
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if (scp == cur_console) {
|
1993-07-30 02:20:26 +00:00
|
|
|
|
scrn_time_stamp = time.tv_sec;
|
|
|
|
|
if (scrn_blanked)
|
1995-01-28 22:18:05 +00:00
|
|
|
|
SCRN_SAVER(FALSE);
|
1993-07-30 02:20:26 +00:00
|
|
|
|
}
|
1995-01-12 11:47:05 +00:00
|
|
|
|
write_in_progress++;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
outloop:
|
|
|
|
|
if (scp->term.esc) {
|
|
|
|
|
scan_esc(scp, *ptr++);
|
|
|
|
|
len--;
|
|
|
|
|
}
|
1995-02-03 21:09:44 +00:00
|
|
|
|
else if (PRINTABLE(*ptr)) { /* Print only printables */
|
1995-01-20 08:35:32 +00:00
|
|
|
|
do {
|
|
|
|
|
*scp->cursor_pos++ =
|
|
|
|
|
(scp->term.cur_attr | scr_map[*ptr++]);
|
|
|
|
|
scp->xpos++;
|
|
|
|
|
len--;
|
1995-02-03 21:09:44 +00:00
|
|
|
|
} while (len && PRINTABLE(*ptr) && (scp->xpos < scp->xsize));
|
1995-01-20 08:35:32 +00:00
|
|
|
|
if (scp->xpos >= scp->xsize) {
|
1994-02-01 06:22:29 +00:00
|
|
|
|
scp->xpos = 0;
|
|
|
|
|
scp->ypos++;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
1995-01-20 08:35:32 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
switch(*ptr) {
|
|
|
|
|
case 0x07:
|
|
|
|
|
do_bell(scp, scp->bell_pitch, scp->bell_duration);
|
|
|
|
|
break;
|
1995-02-03 21:09:44 +00:00
|
|
|
|
case 0x08: /* non-destructive backspace */
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (scp->cursor_pos > scp->scr_buf) {
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scp->cursor_pos--;
|
|
|
|
|
if (scp->xpos > 0)
|
|
|
|
|
scp->xpos--;
|
|
|
|
|
else {
|
|
|
|
|
scp->xpos += scp->xsize - 1;
|
|
|
|
|
scp->ypos--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
1995-02-03 21:09:44 +00:00
|
|
|
|
case 0x09: /* non-destructive tab */
|
1995-02-01 21:56:32 +00:00
|
|
|
|
{
|
|
|
|
|
int i = 8 - scp->xpos % 8u;
|
|
|
|
|
|
|
|
|
|
scp->cursor_pos += i;
|
|
|
|
|
if ((scp->xpos += i) >= scp->xsize) {
|
|
|
|
|
scp->xpos = 0;
|
|
|
|
|
scp->ypos++;
|
|
|
|
|
}
|
|
|
|
|
}
|
1995-01-20 08:35:32 +00:00
|
|
|
|
break;
|
1995-02-03 21:09:44 +00:00
|
|
|
|
case 0x0a: /* newline, same pos */
|
|
|
|
|
scp->cursor_pos += scp->xsize;
|
|
|
|
|
scp->ypos++;
|
|
|
|
|
break;
|
|
|
|
|
case 0x0c: /* form feed, clears screen */
|
|
|
|
|
clear_screen(scp);
|
|
|
|
|
break;
|
|
|
|
|
case 0x0d: /* return, return to pos 0 */
|
|
|
|
|
scp->cursor_pos -= scp->xpos;
|
|
|
|
|
scp->xpos = 0;
|
|
|
|
|
break;
|
|
|
|
|
case 0x1b: /* start escape sequence */
|
|
|
|
|
scp->term.esc = 1;
|
|
|
|
|
scp->term.num_param = 0;
|
|
|
|
|
break;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
}
|
|
|
|
|
ptr++; len--;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
1995-01-12 11:47:05 +00:00
|
|
|
|
/* do we have to scroll ?? */
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (scp->cursor_pos >= scp->scr_buf + scp->ysize * scp->xsize) {
|
1995-01-20 08:35:32 +00:00
|
|
|
|
if (scp->history) {
|
1995-01-28 22:18:05 +00:00
|
|
|
|
bcopyw(scp->scr_buf, scp->history_head,
|
|
|
|
|
scp->xsize * sizeof(u_short));
|
|
|
|
|
|
|
|
|
|
scp->history_head += scp->xsize;
|
|
|
|
|
if (scp->history_head + scp->xsize >
|
|
|
|
|
scp->history + scp->history_size)
|
|
|
|
|
scp->history_head = scp->history;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
}
|
1995-01-28 22:18:05 +00:00
|
|
|
|
bcopyw(scp->scr_buf + scp->xsize, scp->scr_buf,
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->xsize * (scp->ysize - 1) * sizeof(u_short));
|
1995-01-20 08:35:32 +00:00
|
|
|
|
fillw(scp->term.cur_attr | scr_map[0x20],
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->scr_buf + scp->xsize * (scp->ysize - 1),
|
|
|
|
|
scp->xsize);
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scp->cursor_pos -= scp->xsize;
|
|
|
|
|
scp->ypos--;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
1995-01-20 08:35:32 +00:00
|
|
|
|
if (len)
|
|
|
|
|
goto outloop;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
write_in_progress--;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
if (delayed_next_scr)
|
1995-01-12 11:47:05 +00:00
|
|
|
|
switch_scr(scp, delayed_next_scr - 1);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
|
|
|
|
scinit(void)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1993-09-08 22:11:48 +00:00
|
|
|
|
u_short volatile *cp = Crtat + (CGA_BUF-MONO_BUF)/sizeof(u_short), was;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
unsigned hw_cursor;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
int i;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
1995-01-20 08:35:32 +00:00
|
|
|
|
if (init_done)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return;
|
1995-02-05 23:44:25 +00:00
|
|
|
|
init_done = TRUE;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
/*
|
|
|
|
|
* Crtat initialized to point to MONO buffer, if not present change
|
1995-02-07 11:53:27 +00:00
|
|
|
|
* to CGA_BUF offset. ONLY add the difference since locore.s adds
|
1994-02-01 06:22:29 +00:00
|
|
|
|
* in the remapped offset at the "right" time
|
1993-07-26 21:21:11 +00:00
|
|
|
|
*/
|
|
|
|
|
was = *cp;
|
|
|
|
|
*cp = (u_short) 0xA55A;
|
1994-10-18 03:34:53 +00:00
|
|
|
|
if (*cp != 0xA55A)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
crtc_addr = MONO_BASE;
|
1994-10-18 03:34:53 +00:00
|
|
|
|
else {
|
1993-07-26 21:21:11 +00:00
|
|
|
|
*cp = was;
|
|
|
|
|
crtc_addr = COLOR_BASE;
|
|
|
|
|
Crtat = Crtat + (CGA_BUF-MONO_BUF)/sizeof(u_short);
|
|
|
|
|
}
|
1993-07-30 02:20:26 +00:00
|
|
|
|
|
1995-01-12 11:47:05 +00:00
|
|
|
|
/* extract cursor location */
|
1993-07-26 21:21:11 +00:00
|
|
|
|
outb(crtc_addr,14);
|
1995-01-20 08:35:32 +00:00
|
|
|
|
hw_cursor = inb(crtc_addr+1)<<8 ;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
outb(crtc_addr,15);
|
1995-01-20 08:35:32 +00:00
|
|
|
|
hw_cursor |= inb(crtc_addr+1);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
1995-01-28 22:18:05 +00:00
|
|
|
|
/* move hardware cursor out of the way */
|
|
|
|
|
outb(crtc_addr,14);
|
|
|
|
|
outb(crtc_addr+1, 0xff);
|
|
|
|
|
outb(crtc_addr,15);
|
|
|
|
|
outb(crtc_addr+1, 0xff);
|
1995-01-12 11:47:05 +00:00
|
|
|
|
|
1993-07-30 02:20:26 +00:00
|
|
|
|
/* is this a VGA or higher ? */
|
|
|
|
|
outb(crtc_addr, 7);
|
1994-09-15 07:26:40 +00:00
|
|
|
|
if (inb(crtc_addr) == 7) {
|
1994-10-26 21:51:22 +00:00
|
|
|
|
u_long pa;
|
|
|
|
|
u_long segoff;
|
|
|
|
|
|
1995-01-28 22:18:05 +00:00
|
|
|
|
crtc_vga = TRUE;
|
1994-10-26 21:51:22 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Get the BIOS video mode pointer.
|
|
|
|
|
*/
|
|
|
|
|
segoff = *(u_long *)pa_to_va(0x4a8);
|
|
|
|
|
pa = (((segoff & 0xffff0000) >> 12) + (segoff & 0xffff));
|
|
|
|
|
if (ISMAPPED(pa, sizeof(u_long))) {
|
|
|
|
|
segoff = *(u_long *)pa_to_va(pa);
|
|
|
|
|
pa = (((segoff & 0xffff0000) >> 12)
|
|
|
|
|
+ (segoff & 0xffff));
|
|
|
|
|
if (ISMAPPED(pa, 64))
|
|
|
|
|
video_mode_ptr = (char *)pa_to_va(pa);
|
|
|
|
|
}
|
1994-09-15 07:26:40 +00:00
|
|
|
|
}
|
1993-07-30 02:20:26 +00:00
|
|
|
|
current_default = &user_default;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
console[0] = &main_console;
|
|
|
|
|
init_scp(console[0]);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
console[0]->scr_buf = console[0]->mouse_pos = Crtat;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
console[0]->cursor_pos = Crtat + hw_cursor;
|
|
|
|
|
console[0]->xpos = hw_cursor % COL;
|
|
|
|
|
console[0]->ypos = hw_cursor / COL;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
cur_console = console[0];
|
|
|
|
|
for (i=1; i<MAXCONS; i++)
|
|
|
|
|
console[i] = NULL;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
kernel_console.esc = 0;
|
|
|
|
|
kernel_console.std_attr = kernel_default.std_attr;
|
|
|
|
|
kernel_console.rev_attr = kernel_default.rev_attr;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
kernel_console.cur_attr = kernel_default.std_attr;
|
|
|
|
|
/* initialize mapscrn array to a one to one map */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
for (i=0; i<sizeof(scr_map); i++)
|
|
|
|
|
scr_map[i] = i;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-01-12 11:47:05 +00:00
|
|
|
|
static scr_stat
|
|
|
|
|
*alloc_scp()
|
|
|
|
|
{
|
|
|
|
|
scr_stat *scp;
|
|
|
|
|
|
|
|
|
|
scp = (scr_stat *)malloc(sizeof(scr_stat), M_DEVBUF, M_NOWAIT);
|
|
|
|
|
init_scp(scp);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
scp->scr_buf = scp->cursor_pos = scp->scr_buf = scp->mouse_pos =
|
1995-01-20 08:35:32 +00:00
|
|
|
|
(u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short),
|
|
|
|
|
M_DEVBUF, M_NOWAIT);
|
|
|
|
|
scp->history_head = scp->history_pos = scp->history =
|
1995-01-28 22:18:05 +00:00
|
|
|
|
(u_short *)malloc(scp->history_size*sizeof(u_short),
|
1995-01-20 08:35:32 +00:00
|
|
|
|
M_DEVBUF, M_NOWAIT);
|
1995-01-30 21:36:32 +00:00
|
|
|
|
bzero(scp->history_head, scp->history_size*sizeof(u_short));
|
1995-02-01 21:56:32 +00:00
|
|
|
|
if (crtc_vga && video_mode_ptr)
|
1995-01-12 11:47:05 +00:00
|
|
|
|
set_mode(scp);
|
|
|
|
|
clear_screen(scp);
|
|
|
|
|
return scp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
init_scp(scr_stat *scp)
|
|
|
|
|
{
|
|
|
|
|
scp->mode = M_VGA_C80x25;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scp->font = FONT_16;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
scp->xsize = COL;
|
|
|
|
|
scp->ysize = ROW;
|
|
|
|
|
scp->term.esc = 0;
|
|
|
|
|
scp->term.std_attr = current_default->std_attr;
|
|
|
|
|
scp->term.rev_attr = current_default->rev_attr;
|
|
|
|
|
scp->term.cur_attr = scp->term.std_attr;
|
|
|
|
|
scp->border = BG_BLACK;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
scp->cursor_start = -1;
|
|
|
|
|
scp->cursor_end = -1;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scp->mouse_xpos = scp->mouse_ypos = 0;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
scp->bell_pitch = BELL_PITCH;
|
|
|
|
|
scp->bell_duration = BELL_DURATION;
|
|
|
|
|
scp->status = (*(char *)pa_to_va(0x417) & 0x20) ? NLKED : 0;
|
1995-02-07 11:53:27 +00:00
|
|
|
|
scp->status |= CURSOR_ENABLED;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
scp->pid = 0;
|
|
|
|
|
scp->proc = NULL;
|
|
|
|
|
scp->smode.mode = VT_AUTO;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scp->history_head = scp->history_pos = scp->history = NULL;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
scp->history_size = HISTORY_SIZE;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
|
|
|
|
scput(u_char c)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1995-02-05 23:44:25 +00:00
|
|
|
|
scr_stat *scp;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
term_stat save;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
1995-02-05 23:44:25 +00:00
|
|
|
|
scp = console[0];
|
1995-01-20 08:35:32 +00:00
|
|
|
|
save = scp->term;
|
|
|
|
|
scp->term = kernel_console;
|
|
|
|
|
current_default = &kernel_default;
|
1995-02-07 11:53:27 +00:00
|
|
|
|
if (scp->scr_buf == Crtat)
|
|
|
|
|
draw_cursor(scp, FALSE);
|
1995-01-20 08:35:32 +00:00
|
|
|
|
ansi_put(scp, &c, 1);
|
1995-02-07 11:53:27 +00:00
|
|
|
|
scp->status |= UPDATE_SCREEN;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
kernel_console = scp->term;
|
|
|
|
|
current_default = &user_default;
|
|
|
|
|
scp->term = save;
|
1995-02-07 11:53:27 +00:00
|
|
|
|
if (scp == cur_console /* && scrn_timer not running */) {
|
|
|
|
|
if (scp->scr_buf != Crtat) {
|
|
|
|
|
bcopyw(scp->scr_buf, Crtat,
|
|
|
|
|
(scp->xsize*scp->ysize)*sizeof(u_short));
|
|
|
|
|
scp->status &= ~CURSOR_SHOWN;
|
|
|
|
|
}
|
1995-02-05 23:44:25 +00:00
|
|
|
|
draw_cursor(scp, TRUE);
|
1995-02-07 11:53:27 +00:00
|
|
|
|
scp->status &= ~UPDATE_SCREEN;
|
1995-02-05 23:44:25 +00:00
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static u_char
|
|
|
|
|
*get_fstr(u_int c, u_int *len)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
|
|
|
|
u_int i;
|
|
|
|
|
|
|
|
|
|
if (!(c & FKEY))
|
|
|
|
|
return(NULL);
|
|
|
|
|
i = (c & 0xFF) - F_FN;
|
|
|
|
|
if (i > n_fkey_tab)
|
|
|
|
|
return(NULL);
|
|
|
|
|
*len = fkey_tab[i].len;
|
|
|
|
|
return(fkey_tab[i].str);
|
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
|
|
|
|
update_leds(int which)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1994-08-17 08:51:59 +00:00
|
|
|
|
int s;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
static u_char xlate_leds[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
1994-04-01 18:33:12 +00:00
|
|
|
|
/* replace CAPS led with ALTGR led for ALTGR keyboards */
|
|
|
|
|
if (key_map.n_keys > ALTGR_OFFSET) {
|
|
|
|
|
if (which & ALKED)
|
|
|
|
|
which |= CLKED;
|
|
|
|
|
else
|
|
|
|
|
which &= ~CLKED;
|
|
|
|
|
}
|
1994-08-17 08:51:59 +00:00
|
|
|
|
s = spltty();
|
|
|
|
|
kbd_cmd(KB_SETLEDS);
|
|
|
|
|
kbd_cmd(xlate_leds[which & LED_MASK]);
|
|
|
|
|
splx(s);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
1994-02-01 06:22:29 +00:00
|
|
|
|
|
1995-01-28 22:18:05 +00:00
|
|
|
|
static void
|
|
|
|
|
history_to_screen(scr_stat *scp)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->status &= ~UPDATE_SCREEN;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
for (i=0; i<scp->ysize; i++)
|
|
|
|
|
bcopyw(scp->history + (((scp->history_pos - scp->history) +
|
|
|
|
|
scp->history_size-((i+1)*scp->xsize))%scp->history_size),
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->scr_buf + (scp->xsize * (scp->ysize-1 - i)),
|
1995-01-28 22:18:05 +00:00
|
|
|
|
scp->xsize * sizeof(u_short));
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->status |= UPDATE_SCREEN;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
history_up_line(scr_stat *scp)
|
|
|
|
|
{
|
|
|
|
|
if (WRAPHIST(scp, scp->history_pos, -(scp->xsize*scp->ysize)) !=
|
|
|
|
|
scp->history_head) {
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->history_pos = WRAPHIST(scp, scp->history_pos, -scp->xsize);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
history_to_screen(scp);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
1995-02-01 21:56:32 +00:00
|
|
|
|
return -1;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
history_down_line(scr_stat *scp)
|
|
|
|
|
{
|
|
|
|
|
if (scp->history_pos != scp->history_head) {
|
|
|
|
|
scp->history_pos = WRAPHIST(scp, scp->history_pos, scp->xsize);
|
|
|
|
|
history_to_screen(scp);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
1995-02-01 21:56:32 +00:00
|
|
|
|
return -1;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
1993-07-26 21:21:11 +00:00
|
|
|
|
/*
|
1994-08-17 08:51:59 +00:00
|
|
|
|
* scgetc(noblock) - get character from keyboard.
|
|
|
|
|
* If noblock = 0 wait until a key is pressed.
|
|
|
|
|
* Else return NOKEY.
|
1993-07-26 21:21:11 +00:00
|
|
|
|
*/
|
1994-08-17 08:51:59 +00:00
|
|
|
|
u_int
|
|
|
|
|
scgetc(int noblock)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1994-08-17 08:51:59 +00:00
|
|
|
|
u_char scancode, keycode;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
u_int state, action;
|
|
|
|
|
struct key_t *key;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
static u_char esc_flag = 0, compose = 0;
|
|
|
|
|
static u_int chr = 0;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
|
|
|
|
next_code:
|
|
|
|
|
kbd_wait();
|
|
|
|
|
/* First see if there is something in the keyboard port */
|
|
|
|
|
if (inb(KB_STAT) & KB_BUF_FULL)
|
1994-08-17 08:51:59 +00:00
|
|
|
|
scancode = inb(KB_DATA);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
else if (noblock)
|
1993-10-28 05:27:36 +00:00
|
|
|
|
return(NOKEY);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
else
|
|
|
|
|
goto next_code;
|
|
|
|
|
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if (cur_console->status & KBD_RAW_MODE)
|
1994-08-17 08:51:59 +00:00
|
|
|
|
return scancode;
|
|
|
|
|
#if ASYNCH
|
|
|
|
|
if (scancode == KB_ACK || scancode == KB_RESEND) {
|
|
|
|
|
kbd_reply = scancode;
|
|
|
|
|
if (noblock)
|
|
|
|
|
return(NOKEY);
|
|
|
|
|
goto next_code;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
keycode = scancode & 0x7F;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
switch (esc_flag) {
|
|
|
|
|
case 0x00: /* normal scancode */
|
1994-08-17 08:51:59 +00:00
|
|
|
|
switch(scancode) {
|
|
|
|
|
case 0xB8: /* left alt (compose key) */
|
|
|
|
|
if (compose) {
|
1993-07-30 02:20:26 +00:00
|
|
|
|
compose = 0;
|
|
|
|
|
if (chr > 255) {
|
1995-01-12 11:47:05 +00:00
|
|
|
|
do_bell(cur_console,
|
|
|
|
|
BELL_PITCH, BELL_DURATION);
|
1993-07-30 02:20:26 +00:00
|
|
|
|
chr = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
1994-08-17 08:51:59 +00:00
|
|
|
|
break;
|
|
|
|
|
case 0x38:
|
|
|
|
|
if (!compose) {
|
|
|
|
|
compose = 1;
|
|
|
|
|
chr = 0;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
case 0xE0:
|
|
|
|
|
case 0xE1:
|
|
|
|
|
esc_flag = scancode;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
goto next_code;
|
|
|
|
|
}
|
|
|
|
|
break;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
case 0xE0: /* 0xE0 prefix */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
esc_flag = 0;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
switch (keycode) {
|
|
|
|
|
case 0x1C: /* right enter key */
|
|
|
|
|
keycode = 0x59;
|
1993-09-08 22:11:48 +00:00
|
|
|
|
break;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
case 0x1D: /* right ctrl key */
|
|
|
|
|
keycode = 0x5A;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 0x35: /* keypad divide key */
|
1994-08-17 08:51:59 +00:00
|
|
|
|
keycode = 0x5B;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 0x37: /* print scrn key */
|
1994-08-17 08:51:59 +00:00
|
|
|
|
keycode = 0x5C;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 0x38: /* right alt key (alt gr) */
|
1994-08-17 08:51:59 +00:00
|
|
|
|
keycode = 0x5D;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 0x47: /* grey home key */
|
1994-08-17 08:51:59 +00:00
|
|
|
|
keycode = 0x5E;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 0x48: /* grey up arrow key */
|
1994-08-17 08:51:59 +00:00
|
|
|
|
keycode = 0x5F;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 0x49: /* grey page up key */
|
1994-08-17 08:51:59 +00:00
|
|
|
|
keycode = 0x60;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
case 0x4B: /* grey left arrow key */
|
|
|
|
|
keycode = 0x61;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
case 0x4D: /* grey right arrow key */
|
|
|
|
|
keycode = 0x62;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
case 0x4F: /* grey end key */
|
|
|
|
|
keycode = 0x63;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 0x50: /* grey down arrow key */
|
1994-08-17 08:51:59 +00:00
|
|
|
|
keycode = 0x64;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 0x51: /* grey page down key */
|
1994-08-17 08:51:59 +00:00
|
|
|
|
keycode = 0x65;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 0x52: /* grey insert key */
|
1994-08-17 08:51:59 +00:00
|
|
|
|
keycode = 0x66;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 0x53: /* grey delete key */
|
1994-08-17 08:51:59 +00:00
|
|
|
|
keycode = 0x67;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
1994-11-17 22:03:18 +00:00
|
|
|
|
|
|
|
|
|
/* the following 3 are only used on the MS "Natural" keyboard */
|
1995-02-01 21:56:32 +00:00
|
|
|
|
case 0x5b: /* left Window key */
|
|
|
|
|
keycode = 0x69;
|
|
|
|
|
break;
|
|
|
|
|
case 0x5c: /* right Window key */
|
|
|
|
|
keycode = 0x6a;
|
|
|
|
|
break;
|
|
|
|
|
case 0x5d: /* menu key */
|
|
|
|
|
keycode = 0x6b;
|
|
|
|
|
break;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
default: /* ignore everything else */
|
1993-07-26 21:21:11 +00:00
|
|
|
|
goto next_code;
|
|
|
|
|
}
|
1993-07-30 02:20:26 +00:00
|
|
|
|
break;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
case 0xE1: /* 0xE1 prefix */
|
1993-07-30 02:20:26 +00:00
|
|
|
|
esc_flag = 0;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
if (keycode == 0x1D)
|
1993-07-30 02:20:26 +00:00
|
|
|
|
esc_flag = 0x1D;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
goto next_code;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
/* NOT REACHED */
|
|
|
|
|
case 0x1D: /* pause / break */
|
|
|
|
|
esc_flag = 0;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
if (keycode != 0x45)
|
1993-07-30 02:20:26 +00:00
|
|
|
|
goto next_code;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
keycode = 0x68;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
break;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-01-12 11:47:05 +00:00
|
|
|
|
/* if scroll-lock pressed allow history browsing */
|
1995-01-30 21:36:32 +00:00
|
|
|
|
if (cur_console->history && cur_console->status & SLKED) {
|
1995-01-28 22:18:05 +00:00
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
cur_console->status &= ~CURSOR_ENABLED;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
if (!(cur_console->status & BUFFER_SAVED)) {
|
1995-01-28 22:18:05 +00:00
|
|
|
|
cur_console->status |= BUFFER_SAVED;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
cur_console->history_save = cur_console->history_head;
|
|
|
|
|
/* copy screen into top of history buffer */
|
|
|
|
|
for (i=0; i<cur_console->ysize; i++) {
|
|
|
|
|
bcopyw(cur_console->scr_buf + (cur_console->xsize * i),
|
1995-01-28 22:18:05 +00:00
|
|
|
|
cur_console->history_head,
|
1995-02-01 21:56:32 +00:00
|
|
|
|
cur_console->xsize * sizeof(u_short));
|
1995-01-28 22:18:05 +00:00
|
|
|
|
|
1995-02-01 21:56:32 +00:00
|
|
|
|
cur_console->history_head += cur_console->xsize;
|
|
|
|
|
if (cur_console->history_head + cur_console->xsize >
|
|
|
|
|
cur_console->history + cur_console->history_size)
|
|
|
|
|
cur_console->history_head=cur_console->history;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
}
|
|
|
|
|
cur_console->history_pos = cur_console->history_head;
|
1995-01-30 21:36:32 +00:00
|
|
|
|
history_to_screen(cur_console);
|
1995-01-12 11:47:05 +00:00
|
|
|
|
}
|
|
|
|
|
switch (scancode) {
|
1995-01-28 22:18:05 +00:00
|
|
|
|
case 0x47: /* home key */
|
|
|
|
|
cur_console->history_pos = cur_console->history_head;
|
|
|
|
|
history_to_screen(cur_console);
|
|
|
|
|
goto next_code;
|
|
|
|
|
|
|
|
|
|
case 0x4F: /* end key */
|
|
|
|
|
cur_console->history_pos =
|
|
|
|
|
WRAPHIST(cur_console, cur_console->history_head,
|
|
|
|
|
cur_console->xsize*cur_console->ysize);
|
|
|
|
|
history_to_screen(cur_console);
|
|
|
|
|
goto next_code;
|
|
|
|
|
|
|
|
|
|
case 0x48: /* up arrow key */
|
|
|
|
|
if (history_up_line(cur_console))
|
1995-02-01 21:56:32 +00:00
|
|
|
|
do_bell(cur_console, BELL_PITCH, BELL_DURATION);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
goto next_code;
|
|
|
|
|
|
1995-01-12 11:47:05 +00:00
|
|
|
|
case 0x50: /* down arrow key */
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (history_down_line(cur_console))
|
1995-02-01 21:56:32 +00:00
|
|
|
|
do_bell(cur_console, BELL_PITCH, BELL_DURATION);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
goto next_code;
|
|
|
|
|
|
|
|
|
|
case 0x49: /* page up key */
|
|
|
|
|
for (i=0; i<cur_console->ysize; i++)
|
1995-02-01 21:56:32 +00:00
|
|
|
|
if (history_up_line(cur_console)) {
|
|
|
|
|
do_bell(cur_console, BELL_PITCH, BELL_DURATION);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
break;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
}
|
|
|
|
|
goto next_code;
|
|
|
|
|
|
1995-01-28 22:18:05 +00:00
|
|
|
|
case 0x51: /* page down key */
|
|
|
|
|
for (i=0; i<cur_console->ysize; i++)
|
1995-02-01 21:56:32 +00:00
|
|
|
|
if (history_down_line(cur_console)) {
|
|
|
|
|
do_bell(cur_console, BELL_PITCH, BELL_DURATION);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
break;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
}
|
|
|
|
|
goto next_code;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (compose) {
|
1994-08-17 08:51:59 +00:00
|
|
|
|
switch (scancode) {
|
|
|
|
|
/* key pressed process it */
|
|
|
|
|
case 0x47: case 0x48: case 0x49: /* keypad 7,8,9 */
|
|
|
|
|
chr = (scancode - 0x40) + chr*10;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
goto next_code;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
case 0x4B: case 0x4C: case 0x4D: /* keypad 4,5,6 */
|
|
|
|
|
chr = (scancode - 0x47) + chr*10;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
goto next_code;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
case 0x4F: case 0x50: case 0x51: /* keypad 1,2,3 */
|
|
|
|
|
chr = (scancode - 0x4E) + chr*10;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
goto next_code;
|
|
|
|
|
case 0x52: /* keypad 0 */
|
1994-08-17 08:51:59 +00:00
|
|
|
|
chr *= 10;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
goto next_code;
|
1994-08-17 08:51:59 +00:00
|
|
|
|
|
|
|
|
|
/* key release, no interest here */
|
|
|
|
|
case 0xC7: case 0xC8: case 0xC9: /* keypad 7,8,9 */
|
|
|
|
|
case 0xCB: case 0xCC: case 0xCD: /* keypad 4,5,6 */
|
|
|
|
|
case 0xCF: case 0xD0: case 0xD1: /* keypad 1,2,3 */
|
|
|
|
|
case 0xD2: /* keypad 0 */
|
|
|
|
|
goto next_code;
|
|
|
|
|
|
1993-07-30 02:20:26 +00:00
|
|
|
|
case 0x38: /* left alt key */
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (chr) {
|
|
|
|
|
compose = chr = 0;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
do_bell(cur_console, BELL_PITCH, BELL_DURATION);
|
1993-07-30 02:20:26 +00:00
|
|
|
|
goto next_code;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1993-07-26 21:21:11 +00:00
|
|
|
|
state = (shfts ? 1 : 0 ) | (2 * (ctls ? 1 : 0)) | (4 * (alts ? 1 : 0));
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if ((!agrs && (cur_console->status & ALKED))
|
|
|
|
|
|| (agrs && !(cur_console->status & ALKED)))
|
1994-08-17 08:51:59 +00:00
|
|
|
|
keycode += ALTGR_OFFSET;
|
|
|
|
|
key = &key_map.key[keycode];
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if ( ((key->flgs & FLAG_LOCK_C) && (cur_console->status & CLKED))
|
|
|
|
|
|| ((key->flgs & FLAG_LOCK_N) && (cur_console->status & NLKED)) )
|
1993-07-26 21:21:11 +00:00
|
|
|
|
state ^= 1;
|
|
|
|
|
|
|
|
|
|
/* Check for make/break */
|
|
|
|
|
action = key->map[state];
|
1994-08-17 08:51:59 +00:00
|
|
|
|
if (scancode & 0x80) { /* key released */
|
1993-07-26 21:21:11 +00:00
|
|
|
|
if (key->spcl & 0x80) {
|
|
|
|
|
switch (action) {
|
|
|
|
|
case LSH:
|
|
|
|
|
shfts &= ~1;
|
|
|
|
|
break;
|
|
|
|
|
case RSH:
|
|
|
|
|
shfts &= ~2;
|
|
|
|
|
break;
|
|
|
|
|
case LCTR:
|
|
|
|
|
ctls &= ~1;
|
|
|
|
|
break;
|
|
|
|
|
case RCTR:
|
|
|
|
|
ctls &= ~2;
|
|
|
|
|
break;
|
|
|
|
|
case LALT:
|
|
|
|
|
alts &= ~1;
|
|
|
|
|
break;
|
|
|
|
|
case RALT:
|
|
|
|
|
alts &= ~2;
|
|
|
|
|
break;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
case NLK:
|
|
|
|
|
nlkcnt = 0;
|
|
|
|
|
break;
|
|
|
|
|
case CLK:
|
|
|
|
|
clkcnt = 0;
|
|
|
|
|
break;
|
|
|
|
|
case SLK:
|
|
|
|
|
slkcnt = 0;
|
|
|
|
|
break;
|
|
|
|
|
case ASH:
|
|
|
|
|
agrs = 0;
|
|
|
|
|
break;
|
1993-09-29 00:42:10 +00:00
|
|
|
|
case ALK:
|
|
|
|
|
alkcnt = 0;
|
|
|
|
|
break;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
case META:
|
|
|
|
|
metas = 0;
|
|
|
|
|
break;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (chr && !compose) {
|
|
|
|
|
action = chr;
|
|
|
|
|
chr = 0;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
return(action);
|
1993-07-30 02:20:26 +00:00
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
} else {
|
1993-07-30 02:20:26 +00:00
|
|
|
|
/* key pressed */
|
1993-07-26 21:21:11 +00:00
|
|
|
|
if (key->spcl & (0x80>>state)) {
|
|
|
|
|
switch (action) {
|
|
|
|
|
/* LOCKING KEYS */
|
|
|
|
|
case NLK:
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (!nlkcnt) {
|
|
|
|
|
nlkcnt++;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if (cur_console->status & NLKED)
|
|
|
|
|
cur_console->status &= ~NLKED;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
else
|
1993-10-28 05:27:36 +00:00
|
|
|
|
cur_console->status |= NLKED;
|
1994-04-01 18:33:12 +00:00
|
|
|
|
update_leds(cur_console->status);
|
1993-07-30 02:20:26 +00:00
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case CLK:
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (!clkcnt) {
|
|
|
|
|
clkcnt++;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if (cur_console->status & CLKED)
|
|
|
|
|
cur_console->status &= ~CLKED;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
else
|
1993-10-28 05:27:36 +00:00
|
|
|
|
cur_console->status |= CLKED;
|
1994-04-01 18:33:12 +00:00
|
|
|
|
update_leds(cur_console->status);
|
1993-07-30 02:20:26 +00:00
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case SLK:
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (!slkcnt) {
|
1995-01-12 11:47:05 +00:00
|
|
|
|
slkcnt++;
|
|
|
|
|
if (cur_console->status & SLKED) {
|
|
|
|
|
cur_console->status &= ~SLKED;
|
|
|
|
|
if (cur_console->status & BUFFER_SAVED){
|
1995-02-01 21:56:32 +00:00
|
|
|
|
int i;
|
|
|
|
|
for (i=0; i<cur_console->ysize; i++) {
|
|
|
|
|
bcopyw(cur_console->history_save+(cur_console->xsize*i),
|
|
|
|
|
cur_console->scr_buf + (cur_console->xsize * i),
|
|
|
|
|
cur_console->xsize * sizeof(u_short));
|
|
|
|
|
}
|
1995-01-12 11:47:05 +00:00
|
|
|
|
cur_console->status&=~BUFFER_SAVED;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
cur_console->history_head =
|
1995-02-01 21:56:32 +00:00
|
|
|
|
cur_console->history_save;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
cur_console->status |=
|
1995-02-01 21:56:32 +00:00
|
|
|
|
(CURSOR_ENABLED|UPDATE_SCREEN);
|
1995-01-12 11:47:05 +00:00
|
|
|
|
}
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scstart(VIRTUAL_TTY(get_scr_num()));
|
1995-01-12 11:47:05 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
1995-02-01 21:56:32 +00:00
|
|
|
|
cur_console->status |= SLKED;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
update_leds(cur_console->status);
|
1993-07-30 02:20:26 +00:00
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
case ALK:
|
1993-07-30 02:20:26 +00:00
|
|
|
|
if (!alkcnt) {
|
|
|
|
|
alkcnt++;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
if (cur_console->status & ALKED)
|
|
|
|
|
cur_console->status &= ~ALKED;
|
|
|
|
|
else
|
|
|
|
|
cur_console->status |= ALKED;
|
1994-04-01 18:33:12 +00:00
|
|
|
|
update_leds(cur_console->status);
|
1993-07-30 02:20:26 +00:00
|
|
|
|
}
|
1995-02-01 21:56:32 +00:00
|
|
|
|
break;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
|
1993-07-26 21:21:11 +00:00
|
|
|
|
/* NON-LOCKING KEYS */
|
1993-10-28 05:27:36 +00:00
|
|
|
|
case NOP:
|
|
|
|
|
break;
|
|
|
|
|
case RBT:
|
1994-01-18 05:33:34 +00:00
|
|
|
|
shutdown_nice();
|
1993-10-28 05:27:36 +00:00
|
|
|
|
break;
|
1994-10-01 02:56:21 +00:00
|
|
|
|
case SUSP:
|
1995-02-17 02:22:57 +00:00
|
|
|
|
#if NAPM > 0
|
|
|
|
|
apm_suspend();
|
|
|
|
|
#endif
|
1994-10-01 02:56:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
1993-10-28 05:27:36 +00:00
|
|
|
|
case DBG:
|
1994-08-27 16:14:39 +00:00
|
|
|
|
#ifdef DDB /* try to switch to console 0 */
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if (cur_console->smode.mode == VT_AUTO &&
|
1995-02-01 21:56:32 +00:00
|
|
|
|
console[0]->smode.mode == VT_AUTO)
|
1995-01-12 11:47:05 +00:00
|
|
|
|
switch_scr(cur_console, 0);
|
1994-02-01 15:09:10 +00:00
|
|
|
|
Debugger("manual escape to debugger");
|
1993-10-28 05:27:36 +00:00
|
|
|
|
return(NOKEY);
|
|
|
|
|
#else
|
|
|
|
|
printf("No debugger in kernel\n");
|
|
|
|
|
#endif
|
|
|
|
|
break;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
case LSH:
|
|
|
|
|
shfts |= 1;
|
|
|
|
|
break;
|
|
|
|
|
case RSH:
|
|
|
|
|
shfts |= 2;
|
|
|
|
|
break;
|
|
|
|
|
case LCTR:
|
|
|
|
|
ctls |= 1;
|
|
|
|
|
break;
|
|
|
|
|
case RCTR:
|
|
|
|
|
ctls |= 2;
|
|
|
|
|
break;
|
|
|
|
|
case LALT:
|
|
|
|
|
alts |= 1;
|
|
|
|
|
break;
|
|
|
|
|
case RALT:
|
|
|
|
|
alts |= 2;
|
|
|
|
|
break;
|
1993-07-30 02:20:26 +00:00
|
|
|
|
case ASH:
|
|
|
|
|
agrs = 1;
|
|
|
|
|
break;
|
1993-10-28 05:27:36 +00:00
|
|
|
|
case META:
|
|
|
|
|
metas = 1;
|
|
|
|
|
break;
|
|
|
|
|
case NEXT:
|
1995-01-12 11:47:05 +00:00
|
|
|
|
switch_scr(cur_console,
|
|
|
|
|
(get_scr_num() + 1) % MAXCONS);
|
1993-07-30 02:20:26 +00:00
|
|
|
|
break;
|
1994-11-19 23:17:48 +00:00
|
|
|
|
case BTAB:
|
1995-01-28 22:18:05 +00:00
|
|
|
|
return(BKEY);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
default:
|
|
|
|
|
if (action >= F_SCR && action <= L_SCR) {
|
1995-01-12 11:47:05 +00:00
|
|
|
|
switch_scr(cur_console, action - F_SCR);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if (action >= F_FN && action <= L_FN)
|
|
|
|
|
action |= FKEY;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return(action);
|
|
|
|
|
}
|
|
|
|
|
}
|
1993-10-28 05:27:36 +00:00
|
|
|
|
else {
|
|
|
|
|
if (metas)
|
|
|
|
|
action |= MKEY;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
return(action);
|
1993-10-28 05:27:36 +00:00
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
goto next_code;
|
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
int
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scmmap(dev_t dev, int offset, int nprot)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1994-12-27 08:43:06 +00:00
|
|
|
|
if (offset > 0x20000 - PAGE_SIZE)
|
|
|
|
|
return -1;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return i386_btop((VIDEOMEM + offset));
|
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
|
|
|
|
kbd_wait(void)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1994-08-17 08:51:59 +00:00
|
|
|
|
int i = 1000;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
while (i--) {
|
1993-07-26 21:21:11 +00:00
|
|
|
|
if ((inb(KB_STAT) & KB_READY) == 0)
|
|
|
|
|
break;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
DELAY (10);
|
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
|
|
|
|
kbd_cmd(u_char command)
|
1994-02-01 06:22:29 +00:00
|
|
|
|
{
|
1994-08-17 08:51:59 +00:00
|
|
|
|
int retry = 5;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
do {
|
1994-08-17 08:51:59 +00:00
|
|
|
|
int i = 100000;
|
|
|
|
|
|
|
|
|
|
kbd_wait();
|
|
|
|
|
#if ASYNCH
|
|
|
|
|
kbd_reply = 0;
|
|
|
|
|
outb(KB_DATA, command);
|
|
|
|
|
while (i--) {
|
|
|
|
|
if (kbd_reply == KB_ACK)
|
|
|
|
|
return;
|
|
|
|
|
if (kbd_reply == KB_RESEND)
|
|
|
|
|
break;
|
1994-02-01 06:22:29 +00:00
|
|
|
|
}
|
1994-08-17 08:51:59 +00:00
|
|
|
|
#else
|
|
|
|
|
outb(KB_DATA, command);
|
|
|
|
|
while (i--) {
|
|
|
|
|
if (inb(KB_STAT) & KB_BUF_FULL) {
|
|
|
|
|
int val;
|
|
|
|
|
DELAY(10);
|
|
|
|
|
val = inb(KB_DATA);
|
|
|
|
|
if (val == KB_ACK)
|
|
|
|
|
return;
|
|
|
|
|
if (val == KB_RESEND)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
} while (retry--);
|
1994-02-01 06:22:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
|
|
|
|
set_mode(scr_stat *scp)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1994-09-15 07:26:40 +00:00
|
|
|
|
char *modetable;
|
|
|
|
|
char special_modetable[64];
|
|
|
|
|
int mode, font_size;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
1993-10-28 05:27:36 +00:00
|
|
|
|
if (scp != cur_console)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* setup video hardware for the given mode */
|
1994-09-15 07:26:40 +00:00
|
|
|
|
switch (scp->mode) {
|
1995-01-12 11:47:05 +00:00
|
|
|
|
case M_VGA_M80x60:
|
|
|
|
|
bcopyw(video_mode_ptr+(64*M_VGA_M80x25),&special_modetable, 64);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
goto special_80x60;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
|
|
|
|
|
case M_VGA_C80x60:
|
|
|
|
|
bcopyw(video_mode_ptr+(64*M_VGA_C80x25),&special_modetable, 64);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
special_80x60: special_modetable[2] = 0x08;
|
|
|
|
|
special_modetable[19] = 0x47;
|
|
|
|
|
goto special_480l;
|
1994-09-15 07:26:40 +00:00
|
|
|
|
|
1995-02-01 21:56:32 +00:00
|
|
|
|
case M_VGA_M80x30:
|
1995-01-12 11:47:05 +00:00
|
|
|
|
bcopyw(video_mode_ptr+(64*M_VGA_M80x25),&special_modetable, 64);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
goto special_80x30;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
|
1995-02-01 21:56:32 +00:00
|
|
|
|
case M_VGA_C80x30:
|
1995-01-12 11:47:05 +00:00
|
|
|
|
bcopyw(video_mode_ptr+(64*M_VGA_C80x25),&special_modetable, 64);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
special_80x30: special_modetable[19] = 0x4f;
|
1995-02-05 23:44:25 +00:00
|
|
|
|
special_480l: special_modetable[9] |= 0xc0;
|
|
|
|
|
special_modetable[16] = 0x08;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
special_modetable[17] = 0x3e;
|
|
|
|
|
special_modetable[26] = 0xea;
|
|
|
|
|
special_modetable[28] = 0xdf;
|
|
|
|
|
special_modetable[31] = 0xe7;
|
|
|
|
|
special_modetable[32] = 0x04;
|
1994-09-15 07:26:40 +00:00
|
|
|
|
modetable = special_modetable;
|
|
|
|
|
goto setup_mode;
|
|
|
|
|
|
1995-02-01 21:56:32 +00:00
|
|
|
|
case M_ENH_B80x43:
|
1995-01-12 11:47:05 +00:00
|
|
|
|
bcopyw(video_mode_ptr+(64*M_ENH_B80x25),&special_modetable, 64);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
goto special_80x43;
|
1994-09-15 07:26:40 +00:00
|
|
|
|
|
|
|
|
|
case M_ENH_C80x43:
|
1995-01-12 11:47:05 +00:00
|
|
|
|
bcopyw(video_mode_ptr+(64*M_ENH_C80x25),&special_modetable, 64);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
special_80x43: special_modetable[28] = 87;
|
|
|
|
|
goto special_80x50;
|
1994-09-15 07:26:40 +00:00
|
|
|
|
|
1995-01-28 22:18:05 +00:00
|
|
|
|
case M_VGA_M80x50:
|
1995-01-12 11:47:05 +00:00
|
|
|
|
bcopyw(video_mode_ptr+(64*M_VGA_M80x25),&special_modetable, 64);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
goto special_80x50;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
|
1995-02-01 21:56:32 +00:00
|
|
|
|
case M_VGA_C80x50:
|
1995-01-12 11:47:05 +00:00
|
|
|
|
bcopyw(video_mode_ptr+(64*M_VGA_C80x25),&special_modetable, 64);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
special_80x50: special_modetable[2] = 8;
|
|
|
|
|
special_modetable[19] = 7;
|
1995-01-12 11:47:05 +00:00
|
|
|
|
modetable = special_modetable;
|
|
|
|
|
goto setup_mode;
|
|
|
|
|
|
1995-02-01 21:56:32 +00:00
|
|
|
|
case M_VGA_C40x25: case M_VGA_C80x25: /* VGA TEXT MODES */
|
1994-09-15 07:26:40 +00:00
|
|
|
|
case M_VGA_M80x25:
|
1995-02-01 21:56:32 +00:00
|
|
|
|
case M_B40x25: case M_C40x25:
|
|
|
|
|
case M_B80x25: case M_C80x25:
|
|
|
|
|
case M_ENH_B40x25: case M_ENH_C40x25:
|
|
|
|
|
case M_ENH_B80x25: case M_ENH_C80x25:
|
1994-09-15 07:26:40 +00:00
|
|
|
|
|
1994-10-26 21:51:22 +00:00
|
|
|
|
modetable = video_mode_ptr + (scp->mode * 64);
|
1994-09-15 07:26:40 +00:00
|
|
|
|
setup_mode:
|
|
|
|
|
set_vgaregs(modetable);
|
|
|
|
|
font_size = *(modetable + 2);
|
1995-01-12 11:47:05 +00:00
|
|
|
|
|
1994-09-15 07:26:40 +00:00
|
|
|
|
/* set font type (size) */
|
1995-02-01 21:56:32 +00:00
|
|
|
|
switch (font_size) {
|
|
|
|
|
case 0x10:
|
|
|
|
|
outb(TSIDX, 0x03); outb(TSREG, 0x00); /* font 0 */
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scp->font = FONT_16;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
break;
|
|
|
|
|
case 0x0E:
|
|
|
|
|
outb(TSIDX, 0x03); outb(TSREG, 0x05); /* font 1 */
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scp->font = FONT_14;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
case 0x08:
|
|
|
|
|
outb(TSIDX, 0x03); outb(TSREG, 0x0A); /* font 2 */
|
1995-01-20 08:35:32 +00:00
|
|
|
|
scp->font = FONT_8;
|
1995-02-01 21:56:32 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
1994-09-15 07:26:40 +00:00
|
|
|
|
|
|
|
|
|
case M_BG320: case M_CG320: case M_BG640:
|
|
|
|
|
case M_CG320_D: case M_CG640_E:
|
|
|
|
|
case M_CG640x350: case M_ENH_CG640:
|
|
|
|
|
case M_BG640x480: case M_CG640x480: case M_VGA_CG320:
|
|
|
|
|
|
1995-02-01 21:56:32 +00:00
|
|
|
|
set_vgaregs(video_mode_ptr + (scp->mode * 64));
|
1993-07-26 21:21:11 +00:00
|
|
|
|
break;
|
1994-09-15 07:26:40 +00:00
|
|
|
|
|
1993-07-26 21:21:11 +00:00
|
|
|
|
default:
|
1994-09-15 07:26:40 +00:00
|
|
|
|
/* call user defined function XXX */
|
1993-10-28 05:27:36 +00:00
|
|
|
|
break;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set border color for this (virtual) console */
|
|
|
|
|
set_border(scp->border);
|
1993-07-30 02:20:26 +00:00
|
|
|
|
return;
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
|
|
|
|
set_border(int color)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
|
|
|
|
inb(crtc_addr+6); /* reset flip-flop */
|
|
|
|
|
outb(ATC, 0x11); outb(ATC, color);
|
1995-02-01 21:56:32 +00:00
|
|
|
|
inb(crtc_addr+6); /* reset flip-flop */
|
|
|
|
|
outb(ATC, 0x20); /* enable Palette */
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-09-15 07:26:40 +00:00
|
|
|
|
static void
|
|
|
|
|
set_vgaregs(char *modetable)
|
|
|
|
|
{
|
|
|
|
|
int i, s = splhigh();
|
|
|
|
|
|
|
|
|
|
outb(TSIDX, 0x00); outb(TSREG, 0x01); /* stop sequencer */
|
|
|
|
|
outb(TSIDX, 0x07); outb(TSREG, 0x00); /* unlock registers */
|
|
|
|
|
for (i=0; i<4; i++) { /* program sequencer */
|
|
|
|
|
outb(TSIDX, i+1);
|
|
|
|
|
outb(TSREG, modetable[i+5]);
|
|
|
|
|
}
|
|
|
|
|
outb(MISC, modetable[9]); /* set dot-clock */
|
|
|
|
|
outb(TSIDX, 0x00); outb(TSREG, 0x03); /* start sequencer */
|
|
|
|
|
outb(crtc_addr, 0x11);
|
|
|
|
|
outb(crtc_addr+1, inb(crtc_addr+1) & 0x7F);
|
|
|
|
|
for (i=0; i<25; i++) { /* program crtc */
|
|
|
|
|
outb(crtc_addr, i);
|
1995-01-12 11:47:05 +00:00
|
|
|
|
if (i == 14 || i == 15) /* no hardware cursor */
|
|
|
|
|
outb(crtc_addr+1, 0xff);
|
|
|
|
|
else
|
|
|
|
|
outb(crtc_addr+1, modetable[i+10]);
|
1994-09-15 07:26:40 +00:00
|
|
|
|
}
|
|
|
|
|
inb(crtc_addr+6); /* reset flip-flop */
|
|
|
|
|
for (i=0; i<20; i++) { /* program attribute ctrl */
|
|
|
|
|
outb(ATC, i);
|
|
|
|
|
outb(ATC, modetable[i+35]);
|
|
|
|
|
}
|
|
|
|
|
for (i=0; i<9; i++) { /* program graph data ctrl */
|
|
|
|
|
outb(GDCIDX, i);
|
|
|
|
|
outb(GDCREG, modetable[i+55]);
|
|
|
|
|
}
|
|
|
|
|
inb(crtc_addr+6); /* reset flip-flop */
|
|
|
|
|
outb(ATC ,0x20); /* enable palette */
|
|
|
|
|
splx(s);
|
|
|
|
|
}
|
1994-08-17 08:51:59 +00:00
|
|
|
|
|
1995-01-20 08:35:32 +00:00
|
|
|
|
static void
|
|
|
|
|
set_font_mode()
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
|
|
|
|
/* setup vga for loading fonts (graphics plane mode) */
|
|
|
|
|
inb(crtc_addr+6); /* reset flip/flop */
|
|
|
|
|
outb(ATC, 0x30); outb(ATC, 0x01);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
#if SLOW_VGA
|
1993-07-26 21:21:11 +00:00
|
|
|
|
outb(TSIDX, 0x02); outb(TSREG, 0x04);
|
|
|
|
|
outb(TSIDX, 0x04); outb(TSREG, 0x06);
|
|
|
|
|
outb(GDCIDX, 0x04); outb(GDCREG, 0x02);
|
|
|
|
|
outb(GDCIDX, 0x05); outb(GDCREG, 0x00);
|
1995-01-20 08:35:32 +00:00
|
|
|
|
outb(GDCIDX, 0x06); outb(GDCREG, 0x05);
|
|
|
|
|
#else
|
|
|
|
|
outw(TSIDX, 0x0402);
|
|
|
|
|
outw(TSIDX, 0x0604);
|
|
|
|
|
outw(GDCIDX, 0x0204);
|
|
|
|
|
outw(GDCIDX, 0x0005);
|
|
|
|
|
outw(GDCIDX, 0x0506); /* addr = a0000, 64kb */
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_normal_mode()
|
|
|
|
|
{
|
|
|
|
|
int s = splhigh();
|
|
|
|
|
|
|
|
|
|
/* setup vga for normal operation mode again */
|
1993-07-26 21:21:11 +00:00
|
|
|
|
inb(crtc_addr+6); /* reset flip/flop */
|
|
|
|
|
outb(ATC, 0x30); outb(ATC, 0x0C);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
#if SLOW_VGA
|
1993-07-26 21:21:11 +00:00
|
|
|
|
outb(TSIDX, 0x02); outb(TSREG, 0x03);
|
|
|
|
|
outb(TSIDX, 0x04); outb(TSREG, 0x02);
|
|
|
|
|
outb(GDCIDX, 0x04); outb(GDCREG, 0x00);
|
|
|
|
|
outb(GDCIDX, 0x05); outb(GDCREG, 0x10);
|
|
|
|
|
if (crtc_addr == MONO_BASE) {
|
|
|
|
|
outb(GDCIDX, 0x06); outb(GDCREG, 0x0A); /* addr = b0000, 32kb */
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
outb(GDCIDX, 0x06); outb(GDCREG, 0x0E); /* addr = b8000, 32kb */
|
|
|
|
|
}
|
1995-01-20 08:35:32 +00:00
|
|
|
|
#else
|
|
|
|
|
outw(TSIDX, 0x0302);
|
|
|
|
|
outw(TSIDX, 0x0204);
|
|
|
|
|
outw(GDCIDX, 0x0004);
|
|
|
|
|
outw(GDCIDX, 0x1005);
|
|
|
|
|
if (crtc_addr == MONO_BASE)
|
|
|
|
|
outw(GDCIDX, 0x0A06); /* addr = b0000, 32kb */
|
|
|
|
|
else
|
|
|
|
|
outw(GDCIDX, 0x0E06); /* addr = b8000, 32kb */
|
|
|
|
|
#endif
|
1993-07-30 02:20:26 +00:00
|
|
|
|
splx(s);
|
1995-01-20 08:35:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
copy_font(int operation, int font_type, char* font_image)
|
|
|
|
|
{
|
1995-02-01 21:56:32 +00:00
|
|
|
|
int ch, line, segment, fontsize;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
u_char val;
|
|
|
|
|
|
|
|
|
|
switch (font_type) {
|
|
|
|
|
default:
|
|
|
|
|
case FONT_8:
|
|
|
|
|
segment = 0x8000;
|
|
|
|
|
fontsize = 8;
|
|
|
|
|
break;
|
|
|
|
|
case FONT_14:
|
|
|
|
|
segment = 0x4000;
|
|
|
|
|
fontsize = 14;
|
|
|
|
|
break;
|
|
|
|
|
case FONT_16:
|
|
|
|
|
segment = 0x0000;
|
|
|
|
|
fontsize = 16;
|
|
|
|
|
break;
|
|
|
|
|
}
|
1995-02-01 21:56:32 +00:00
|
|
|
|
outb(TSIDX, 0x01); val = inb(TSREG); /* disable screen */
|
1995-01-20 08:35:32 +00:00
|
|
|
|
outb(TSIDX, 0x01); outb(TSREG, val | 0x20);
|
|
|
|
|
set_font_mode();
|
1995-02-01 21:56:32 +00:00
|
|
|
|
for (ch=0; ch < 256; ch++)
|
1995-01-20 08:35:32 +00:00
|
|
|
|
for (line=0; line < fontsize; line++)
|
|
|
|
|
if (operation)
|
|
|
|
|
*(char *)pa_to_va(VIDEOMEM+(segment)+(ch*32)+line) =
|
|
|
|
|
font_image[(ch*fontsize)+line];
|
|
|
|
|
else
|
|
|
|
|
font_image[(ch*fontsize)+line] =
|
|
|
|
|
*(char *)pa_to_va(VIDEOMEM+(segment)+(ch*32)+line);
|
|
|
|
|
set_normal_mode();
|
|
|
|
|
outb(TSIDX, 0x01); outb(TSREG, val & 0xDF); /* enable screen */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
draw_mouse_image(scr_stat *scp)
|
|
|
|
|
{
|
|
|
|
|
caddr_t address;
|
|
|
|
|
int i, font_size;
|
|
|
|
|
char *font_buffer;
|
1995-01-30 21:36:32 +00:00
|
|
|
|
u_short buffer[32];
|
|
|
|
|
u_short xoffset, yoffset;
|
|
|
|
|
u_short *crt_pos = Crtat + (scp->mouse_pos - scp->scr_buf);
|
1995-01-20 08:35:32 +00:00
|
|
|
|
|
|
|
|
|
xoffset = scp->mouse_xpos % 8;
|
|
|
|
|
switch (scp->font) {
|
|
|
|
|
default:
|
|
|
|
|
case FONT_8:
|
|
|
|
|
font_size = 8;
|
|
|
|
|
font_buffer = font_8;
|
|
|
|
|
yoffset = scp->mouse_ypos % 8;
|
|
|
|
|
address = (caddr_t)VIDEOMEM+0x8000;
|
|
|
|
|
break;
|
|
|
|
|
case FONT_14:
|
|
|
|
|
font_size = 14;
|
|
|
|
|
font_buffer = font_14;
|
|
|
|
|
yoffset = scp->mouse_ypos % 14;
|
|
|
|
|
address = (caddr_t)VIDEOMEM+0x4000;
|
|
|
|
|
break;
|
|
|
|
|
case FONT_16:
|
|
|
|
|
font_size = 16;
|
|
|
|
|
font_buffer = font_16;
|
|
|
|
|
yoffset = scp->mouse_ypos % 16;
|
|
|
|
|
address = (caddr_t)VIDEOMEM;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
1995-02-01 21:56:32 +00:00
|
|
|
|
bcopyw(font_buffer+((*(scp->mouse_pos) & 0xff)*font_size),
|
1995-01-20 08:35:32 +00:00
|
|
|
|
&scp->mouse_cursor[0], font_size);
|
1995-02-01 21:56:32 +00:00
|
|
|
|
bcopyw(font_buffer+((*(scp->mouse_pos+1) & 0xff)*font_size),
|
1995-01-20 08:35:32 +00:00
|
|
|
|
&scp->mouse_cursor[32], font_size);
|
1995-02-01 21:56:32 +00:00
|
|
|
|
bcopyw(font_buffer+((*(scp->mouse_pos+scp->xsize) & 0xff)*font_size),
|
1995-01-20 08:35:32 +00:00
|
|
|
|
&scp->mouse_cursor[64], font_size);
|
1995-02-01 21:56:32 +00:00
|
|
|
|
bcopyw(font_buffer+((*(scp->mouse_pos+scp->xsize+1) & 0xff)*font_size),
|
1995-01-20 08:35:32 +00:00
|
|
|
|
&scp->mouse_cursor[96], font_size);
|
|
|
|
|
|
|
|
|
|
for (i=0; i<font_size; i++) {
|
|
|
|
|
buffer[i] =
|
|
|
|
|
scp->mouse_cursor[i]<<8 | scp->mouse_cursor[i+32];
|
|
|
|
|
buffer[i+font_size] =
|
|
|
|
|
scp->mouse_cursor[i+64]<<8 | scp->mouse_cursor[i+96];
|
|
|
|
|
}
|
|
|
|
|
for (i=0; i<16; i++) {
|
|
|
|
|
buffer[i+yoffset] =
|
|
|
|
|
( buffer[i+yoffset]
|
|
|
|
|
& ~(mouse_and_mask[i] >> xoffset))
|
|
|
|
|
| (mouse_or_mask[i] >> xoffset);
|
|
|
|
|
}
|
|
|
|
|
for (i=0; i<font_size; i++) {
|
|
|
|
|
scp->mouse_cursor[i] = (buffer[i] & 0xff00) >> 8;
|
|
|
|
|
scp->mouse_cursor[i+32] = buffer[i] & 0xff;
|
|
|
|
|
scp->mouse_cursor[i+64] = (buffer[i+font_size] & 0xff00) >> 8;
|
|
|
|
|
scp->mouse_cursor[i+96] = buffer[i+font_size] & 0xff;
|
|
|
|
|
}
|
1995-02-01 21:56:32 +00:00
|
|
|
|
/*
|
|
|
|
|
* if we didn't update entire screen, restore old mouse position
|
|
|
|
|
* and check if we overwrote the cursor location..
|
|
|
|
|
*/
|
|
|
|
|
if ((scp->status & UPDATE_MOUSE) && !(scp->status & UPDATE_SCREEN)) {
|
|
|
|
|
u_short *ptr = scp->scr_buf + (scp->mouse_oldpos - Crtat);
|
|
|
|
|
if (crt_pos != scp->mouse_oldpos) {
|
|
|
|
|
*(scp->mouse_oldpos) = scp->mouse_saveunder[0];
|
|
|
|
|
*(scp->mouse_oldpos+1) = scp->mouse_saveunder[1];
|
|
|
|
|
*(scp->mouse_oldpos+scp->xsize) = scp->mouse_saveunder[2];
|
|
|
|
|
*(scp->mouse_oldpos+scp->xsize+1) = scp->mouse_saveunder[3];
|
|
|
|
|
}
|
|
|
|
|
scp->mouse_saveunder[0] = *(scp->mouse_pos);
|
|
|
|
|
scp->mouse_saveunder[1] = *(scp->mouse_pos+1);
|
|
|
|
|
scp->mouse_saveunder[2] = *(scp->mouse_pos+scp->xsize);
|
|
|
|
|
scp->mouse_saveunder[3] = *(scp->mouse_pos+scp->xsize+1);
|
|
|
|
|
if ((scp->cursor_pos == (ptr)) ||
|
|
|
|
|
(scp->cursor_pos == (ptr+1)) ||
|
|
|
|
|
(scp->cursor_pos == (ptr+scp->xsize)) ||
|
|
|
|
|
(scp->cursor_pos == (ptr+scp->xsize+1)) ||
|
|
|
|
|
(scp->cursor_pos == (scp->mouse_pos)) ||
|
|
|
|
|
(scp->cursor_pos == (scp->mouse_pos+1)) ||
|
|
|
|
|
(scp->cursor_pos == (scp->mouse_pos+scp->xsize)) ||
|
|
|
|
|
(scp->cursor_pos == (scp->mouse_pos+scp->xsize+1)))
|
|
|
|
|
scp->status &= ~CURSOR_SHOWN;
|
|
|
|
|
}
|
|
|
|
|
scp->mouse_oldpos = crt_pos;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
while (!(inb(crtc_addr+6) & 0x08)) /* wait for vertical retrace */ ;
|
1995-02-03 21:09:44 +00:00
|
|
|
|
*(crt_pos) = *(scp->mouse_pos)&0xff00|0xd0;
|
|
|
|
|
*(crt_pos+1) = *(scp->mouse_pos+1)&0xff00|0xd1;
|
|
|
|
|
*(crt_pos+scp->xsize) = *(scp->mouse_pos+scp->xsize)&0xff00|0xd2;
|
|
|
|
|
*(crt_pos+scp->xsize+1) = *(scp->mouse_pos+scp->xsize+1)&0xff00|0xd3;
|
1995-01-20 08:35:32 +00:00
|
|
|
|
set_font_mode();
|
|
|
|
|
bcopy(scp->mouse_cursor,
|
1995-02-03 21:09:44 +00:00
|
|
|
|
(char *)pa_to_va(address) + 0xd0 * 32, 128);
|
1995-01-20 08:35:32 +00:00
|
|
|
|
set_normal_mode();
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-01-12 11:47:05 +00:00
|
|
|
|
static void
|
|
|
|
|
save_palette(void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
1995-02-01 21:56:32 +00:00
|
|
|
|
outb(PALRADR, 0x00);
|
|
|
|
|
for (i=0x00; i<0x300; i++)
|
|
|
|
|
palette[i] = inb(PALDATA);
|
1995-01-12 11:47:05 +00:00
|
|
|
|
inb(crtc_addr+6); /* reset flip/flop */
|
|
|
|
|
}
|
|
|
|
|
|
1994-08-17 08:51:59 +00:00
|
|
|
|
static void
|
|
|
|
|
load_palette(void)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
1995-02-01 21:56:32 +00:00
|
|
|
|
outb(PIXMASK, 0xFF); /* no pixelmask */
|
|
|
|
|
outb(PALWADR, 0x00);
|
|
|
|
|
for (i=0x00; i<0x300; i++)
|
|
|
|
|
outb(PALDATA, palette[i]);
|
1993-07-26 21:21:11 +00:00
|
|
|
|
inb(crtc_addr+6); /* reset flip/flop */
|
|
|
|
|
outb(ATC, 0x20); /* enable palette */
|
|
|
|
|
}
|
|
|
|
|
|
1995-01-12 11:47:05 +00:00
|
|
|
|
static void
|
|
|
|
|
do_bell(scr_stat *scp, int pitch, int duration)
|
1993-07-26 21:21:11 +00:00
|
|
|
|
{
|
1995-01-12 11:47:05 +00:00
|
|
|
|
if (scp == cur_console) {
|
|
|
|
|
if (configuration & VISUAL_BELL) {
|
1995-01-28 22:18:05 +00:00
|
|
|
|
if (blink_in_progress)
|
1995-01-12 11:47:05 +00:00
|
|
|
|
return;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
blink_in_progress = 4;
|
1995-02-03 21:09:44 +00:00
|
|
|
|
blink_screen(scp);
|
1995-01-12 11:47:05 +00:00
|
|
|
|
timeout((timeout_func_t)blink_screen, scp, hz/10);
|
1995-01-28 22:18:05 +00:00
|
|
|
|
}
|
1995-01-12 11:47:05 +00:00
|
|
|
|
else
|
|
|
|
|
sysbeep(pitch, duration);
|
|
|
|
|
}
|
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
|
1995-01-12 11:47:05 +00:00
|
|
|
|
static void
|
|
|
|
|
blink_screen(scr_stat *scp)
|
|
|
|
|
{
|
|
|
|
|
if (blink_in_progress > 1) {
|
|
|
|
|
if (blink_in_progress & 1)
|
|
|
|
|
fillw(kernel_default.std_attr | scr_map[0x20],
|
1995-01-28 22:18:05 +00:00
|
|
|
|
Crtat, scp->xsize * scp->ysize);
|
1995-01-12 11:47:05 +00:00
|
|
|
|
else
|
|
|
|
|
fillw(kernel_default.rev_attr | scr_map[0x20],
|
1995-01-28 22:18:05 +00:00
|
|
|
|
Crtat, scp->xsize * scp->ysize);
|
1995-01-12 11:47:05 +00:00
|
|
|
|
blink_in_progress--;
|
|
|
|
|
timeout((timeout_func_t)blink_screen, scp, hz/10);
|
|
|
|
|
}
|
|
|
|
|
else {
|
1995-02-01 21:56:32 +00:00
|
|
|
|
scp->status |= UPDATE_SCREEN;
|
1995-01-28 22:18:05 +00:00
|
|
|
|
blink_in_progress = FALSE;
|
1995-02-05 23:44:25 +00:00
|
|
|
|
if (delayed_next_scr)
|
|
|
|
|
switch_scr(scp, delayed_next_scr - 1);
|
1995-01-12 11:47:05 +00:00
|
|
|
|
}
|
1993-07-26 21:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* NSC */
|