diff options
author | hm <hm@FreeBSD.org> | 2000-03-26 09:17:14 +0000 |
---|---|---|
committer | hm <hm@FreeBSD.org> | 2000-03-26 09:17:14 +0000 |
commit | 375cbf5596e8d045c44dc76a28d1d6134684586b (patch) | |
tree | 0a50a25d5220a201bb6df7d5e1ea8079637c6085 /sys | |
parent | 84f48a134013e4b9419f828094900bb7cb213cf1 (diff) | |
download | FreeBSD-src-375cbf5596e8d045c44dc76a28d1d6134684586b.zip FreeBSD-src-375cbf5596e8d045c44dc76a28d1d6134684586b.tar.gz |
Substantially cleanup of the pcvt kernel part. This cleanup does
not introduce (hopefully) any functional changes but gets rid of
the #ifdef spaghetti pcvt suffered from more and more over the
years.
Several no more used parts of the source were removed, others
which are used by default are now non-optional components:
PCVT_NETBSD removed completety
PCVT_FREEBSD removed option, code is now standard
PCVT_KBD_FIFO removed option, code is now standard
PCVT_EMU_MOUSE removed completety
PCVT_SW0CNOUTP removed completety
PCVT_PORTIO_DELAY obsolete, removed
PCVT_KEYBDID removed option, code is now standard
PCVT_SIGWINCH removed option, code is now standard
PCVT_PALFLICKER removed completety
PCVT_WAITRETRACE removed completety
PCVT_NOFASTSCROLL removed option, code is now standard
PCVT_USL_VT_COMPAT removed the "old" non-vt Xserver code completely,
depending on XSERVER, this code is now standard.
Pcvt userland cleanup will follow as well as newbusifying the
kernel part.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_conf.h | 243 | ||||
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_drv.c | 995 | ||||
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_ext.c | 108 | ||||
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_hdr.h | 583 | ||||
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_kbd.c | 956 | ||||
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_kbd.h | 179 | ||||
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_out.c | 23 | ||||
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_sup.c | 286 | ||||
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_tbl.h | 4 | ||||
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_vtf.c | 31 |
10 files changed, 407 insertions, 3001 deletions
diff --git a/sys/i386/isa/pcvt/pcvt_conf.h b/sys/i386/isa/pcvt/pcvt_conf.h index 3af4e52..2e5bffe 100644 --- a/sys/i386/isa/pcvt/pcvt_conf.h +++ b/sys/i386/isa/pcvt/pcvt_conf.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Hellmuth Michaelis + * Copyright (c) 1999, 2000 Hellmuth Michaelis * * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -39,122 +39,20 @@ * pcvt_conf.h VT220 driver global configuration file * ------------------------------------------------------ * - * Last Edit-Date: [Mon Dec 27 14:09:58 1999] + * Last Edit-Date: [Sun Mar 26 10:38:19 2000] * * $FreeBSD$ * *---------------------------------------------------------------------------*/ -/*--------------------------------------------------------------------------- - * - * from: Onno van der Linden c/o frank@fwi.uva.nl - * - * Here's an idea how to automatically detect the version of NetBSD pcvt is - * being compiled on: - * - * NetBSD 0.8 : NetBSD0_8 defined in <sys/param.h> - * NetBSD 0.9 : NetBSD0_9 defined in <sys/param.h> - * NetBSD 1.0 : NetBSD1_0 defined as 1 in <sys/param.h> - * NetBSD 1.0A: NetBSD1_0 defined as 2 in <sys/param.h> - * - * The NetBSDx_y defines are mutual exclusive. - * - * This leads to something like this in pcvt_hdr.h (#elif is possible too): - * - *---------------------------------------------------------------------------*/ - -#ifdef NetBSD0_8 -#define PCVT_NETBSD 8 -#endif - -#ifdef NetBSD0_9 -#define PCVT_NETBSD 9 -#endif - -#ifdef NetBSD1_0 -#if NetBSD1_0 > 1 -#define PCVT_NETBSD 199 -#else -#define PCVT_NETBSD 100 -#endif -#endif - -/*--------------------------------------------------------------------------- - * Note that each of the options below should rather be overriden by the - * kernel config file instead of this .h file - this allows for different - * definitions in different kernels compiled at the same machine - * - * The convention is as follows: - * - * options "PCVT_FOO=1" - enables the option - * options "PCVT_FOO" - is a synonym for the above - * options "PCVT_FOO=0" - disables the option - * - * omitting an option defaults to what is shown below - * - * exceptions from this rule are i.e.: - * - * options "PCVT_NSCREENS=x" - * options "PCVT_SCANSET=x" - * options "PCVT_UPDATEFAST=x" - * options "PCVT_UPDATESLOW=x" - * options "PCVT_SYSBEEPF=x" - * - * which are always numeric! - *---------------------------------------------------------------------------*/ - -/* -------------------------------------------------------------------- */ -/* -------------------- OPERATING SYSTEM ------------------------------ */ -/* -------------------------------------------------------------------- */ - -/* - * one of the following options must be set in the kernel config file: - * - *======================================================================* - * N e t B S D * - *======================================================================* - * - * options "PCVT_NETBSD=xxx" enables support for NetBSD - * - * select: - * PCVT_NETBSD = 9 for NetBSD 0.9 - * PCVT_NETBSD = 99 for PRE-1.0 NetBSD-current - * PCVT_NETBSD = 100 for NetBSD 1.0 - * PCVT_NETBSD = 199 for PRE-2.0 NetBSD-current - * - * - *======================================================================* - * F r e e B S D * - *======================================================================* - * - * options "PCVT_FREEBSD=xxx" enables support for FreeBSD - * - * select: - * PCVT_FREEBSD = 102 for 1.0 release (actually 1.0.2) - * PCVT_FREEBSD = 110 for FreeBSD 1.1-Release - * PCVT_FREEBSD = 115 for FreeBSD 1.1.5.1-Release - * PCVT_FREEBSD = 200 for FreeBSD 2.0-Release - * PCVT_FREEBSD = 210 for FreeBSD 2.1-Release - * - */ - /* -------------------------------------------------------------------- */ /* ---------------- USER PREFERENCE DRIVER OPTIONS -------------------- */ /* -------------------------------------------------------------------- */ -/*----------------------------------------------------------------------*/ -/* NOTE: if FAT_CURSOR is defined, a block cursor is used instead of */ -/* the cursor shape we got from the BIOS, see pcvt_out.c */ -/*----------------------------------------------------------------------*/ - #if !defined PCVT_NSCREENS /* ---------- DEFAULT: 8 -------------- */ # define PCVT_NSCREENS 8 /* this option defines how many virtual */ #endif /* screens you want to have in your */ - /* system. each screen allocates memory,*/ - /* so you can't have an unlimited num- */ - /* ber...; the value is intented to be */ - /* compile-time overridable by a config */ - /* options "PCVT_NSCREENS=x" line */ + /* system. */ #if !defined PCVT_VT220KEYB /* ---------- DEFAULT: OFF ------------ */ # define PCVT_VT220KEYB 0 /* this compiles a more vt220-like */ @@ -190,24 +88,6 @@ /* into modern operating systems and */ /* was commented out by default ... */ -#if !defined PCVT_KBD_FIFO /* ---------- DEFAULT: ON ------------- */ -# define PCVT_KBD_FIFO 1 /* this enables Keyboad fifo so that we */ -#elif PCVT_KBD_FIFO != 0 /* are not any longer forced to switch */ -# undef PCVT_KBD_FIFO /* off tty interrupts while switching */ -# define PCVT_KBD_FIFO 1 /* virtual screens - AND loosing chars */ -#endif /* on the serial lines is gone :-) */ - -#if PCVT_KBD_FIFO - -# if !defined PCVT_KBD_FIFO_SZ /* ---------- DEFAULT: 256 ------------ */ -# define PCVT_KBD_FIFO_SZ 256 /* this specifies the size of the above */ -# elif PCVT_KBD_FIFO_SZ < 16 /* mentioned keyboard buffer. buffer */ -# undef PCVT_KBD_FIFO_SZ /* overflows are logged via syslog, so */ -# define PCVT_KBD_FIFO_SZ 256 /* have a look at /var/log/messages */ -# endif - -#endif /* PCVT_KBD_FIFO */ - #if !defined PCVT_USEKBDSEC /* ---------- DEFAULT: ON ------------- */ # define PCVT_USEKBDSEC 1 /* do not set the COMMAND_INHOVR bit */ #elif PCVT_USEKBDSEC != 0 /* (1 = override security lock inhibit) */ @@ -227,14 +107,6 @@ /* compatibility (24 lines) by using */ /* the scon utility at runtime */ -#if !defined PCVT_EMU_MOUSE /* ---------- DEFAULT: OFF ------------ */ -# define PCVT_EMU_MOUSE 0 /* emulate a mouse systems mouse via */ -#elif PCVT_EMU_MOUSE != 0 /* the keypad; this is experimental */ -# undef PCVT_EMU_MOUSE /* code intented to be used on note- */ -# define PCVT_EMU_MOUSE 1 /* books in conjunction with XFree86; */ -#endif /* look at the comments in pcvt_kbd.c */ - /* if you are interested in testing it. */ - #if !defined PCVT_META_ESC /* ---------- DEFAULT: OFF ------------ */ # define PCVT_META_ESC 0 /* if ON, send the sequence "ESC key" */ #elif PCVT_META_ESC != 0 /* for a meta-shifted key; if OFF, */ @@ -242,13 +114,6 @@ # define PCVT_META_ESC 1 /* added. */ #endif -#if !defined PCVT_SW0CNOUTP /* ---------- DEFAULT: OFF ------------ */ -# define PCVT_SW0CNOUTP 0 /* if ON, on console/kernel output the */ -#elif PCVT_SW0CNOUTP != 0 /* current screen is switched to screen */ -# undef PCVT_SW0CNOUTP /* 0 if not already at screen 0. */ -# define PCVT_SW0CNOUTP 1 /* CAUTION: CURRENTLY THIS CAUSES AN X- */ -#endif /* SESSION TO CLUTTER VIDEO MEMORY !!!! */ - /* -------------------------------------------------------------------- */ /* -------------------- DRIVER DEBUGGING ------------------------------ */ /* -------------------------------------------------------------------- */ @@ -274,20 +139,6 @@ # define PCVT_NO_LED_UPDATE 1 /* wards. If you experience Problems */ #endif /* like this, try to enable this option */ -#if !defined PCVT_PORTIO_DELAY /* ---------- DEFAULT: ON ------------- */ -# define PCVT_PORTIO_DELAY 1 /* Defining PCVT_PORTIO_DELAY lets pcvt */ -#elif PCVT_PORTIO_DELAY != 0 /* use multiple accesses to port 0x84 */ -# undef PCVT_PORTIO_DELAY /* to produce a delay of 7 us needed for*/ -# define PCVT_PORTIO_DELAY 1 /* accessing the keyboard controller, */ -#endif /* otherwise the system delay functions */ - /* are used. */ - -#if !defined PCVT_PCBURST /* ---------- DEFAULT: 256 ------------ */ -# define PCVT_PCBURST 256 /* NETBSD and FreeBSD >= 2.0 only: this */ -#endif /* is the number of output characters */ - /* handled together as a burst in */ - /* routine pcstart(), file pcvt_drv.c */ - #if !defined PCVT_SCANSET /* ---------- DEFAULT: 1 -------------- */ # define PCVT_SCANSET 1 /* define the keyboard scancode set you */ #endif /* want to use: */ @@ -295,37 +146,12 @@ /* 2 - code set 2 (supported) */ /* 3 - code set 3 (UNsupported) */ -#if !defined PCVT_KEYBDID /* ---------- DEFAULT: ON ------------- */ -# define PCVT_KEYBDID 1 /* check type of keyboard connected. at */ -#elif PCVT_KEYBDID != 0 /* least HP-keyboards send an id other */ -# undef PCVT_KEYBDID /* than the industry standard, so it */ -# define PCVT_KEYBDID 1 /* CAN lead to problems. if you have */ -#endif /* problems with this, TELL ME PLEASE ! */ - -#if !defined PCVT_SIGWINCH /* ---------- DEFAULT: ON ------------- */ -# define PCVT_SIGWINCH 1 /* this sends a SIGWINCH signal in case */ -#elif PCVT_SIGWINCH != 0 /* the window size is changed. to try, */ -# undef PCVT_SIGWINCH /* issue "scons -s<size>" while in elvis*/ -# define PCVT_SIGWINCH 1 /* and you'll see the effect. */ -#endif /* i'm not sure, whether this feature */ - /* has to be in the driver or has to */ - /* move as an ioctl call to scon .... */ - #if !defined PCVT_NULLCHARS /* ---------- DEFAULT: ON ------------- */ # define PCVT_NULLCHARS 1 /* allow the keyboard to send null */ #elif PCVT_NULLCHARS != 0 /* (0x00) characters to the calling */ # undef PCVT_NULLCHARS /* program. this has the side effect */ # define PCVT_NULLCHARS 1 /* that every undefined key also sends */ -#endif /* out nulls. take it as experimental */ - /* code, this behaviour will change in */ - /* a future release */ - -#if !defined PCVT_BACKUP_FONTS /* ---------- DEFAULT: ON ------------- */ -# define PCVT_BACKUP_FONTS 1 /* fonts are always kept memory-backed; */ -#elif PCVT_BACKUP_FONTS != 0 /* otherwise copies are only made if */ -# undef PCVT_BACKUP_FONTS /* they are needed. */ -# define PCVT_BACKUP_FONTS 1 -#endif +#endif /* out nulls. */ #ifndef PCVT_UPDATEFAST /* this is the rate at which the cursor */ # define PCVT_UPDATEFAST (hz/10) /* gets updated with its new position */ @@ -365,36 +191,6 @@ /* get in contact with Joerg Wunsch, who*/ /* submitted this code. Be careful !!! */ -#if !defined PCVT_PALFLICKER /* ---------- DEFAULT: OFF ------------ */ -# define PCVT_PALFLICKER 0 /* this option turns off the screen */ -#elif PCVT_PALFLICKER != 0 /* during accesses to the VGA DAC */ -# undef PCVT_PALFLICKER /* registers. why: on one fo the tested */ -# define PCVT_PALFLICKER 1 /* pc's (WD-chipset), accesses to the */ -#endif /* vga dac registers caused distortions */ - /* on the screen. Ferraro says, one has */ - /* to blank the screen. the method used */ - /* to accomplish this stopped the noise */ - /* but introduced another flicker, so */ - /* this is for you to experiment ..... */ - /* - see also PCVT_WAITRETRACE below -- */ - -#if !defined PCVT_WAITRETRACE /* ---------- DEFAULT: OFF ------------ */ -# define PCVT_WAITRETRACE 0 /* this option waits for being in a */ -#elif PCVT_WAITRETRACE != 0 /* retrace window prior to accessing */ -# undef PCVT_WAITRETRACE /* the VGA DAC registers. */ -# define PCVT_WAITRETRACE 1 /* this is the other method Ferraro */ -#endif /* mentioned in his book. this option */ - /* did eleminate the flicker noticably */ - /* but not completely. besides that, it */ - /* is implemented as a busy-wait loop */ - /* which is a no-no-no in environments */ - /* like this - VERY BAD PRACTICE !!!!! */ - /* the other method implementing it is */ - /* using the vertical retrace irq, but */ - /* we get short of irq-lines on pc's. */ - /* this is for you to experiment ..... */ - /* -- see also PCVT_PALFLICKER above -- */ - #if !defined PCVT_INHIBIT_NUMLOCK /* --------- DEFAULT: OFF ----------- */ # define PCVT_INHIBIT_NUMLOCK 0 /* A notebook hack: since i am getting */ #elif PCVT_INHIBIT_NUMLOCK != 0 /* tired of the numlock LED always */ @@ -414,23 +210,6 @@ /* and application mode keypad are */ /* silently ignored. */ -#if !defined PCVT_NOFASTSCROLL /* ---------- DEFAULT: OFF ------------ */ -# define PCVT_NOFASTSCROLL 0 /* If off, enables code for fast scroll.*/ -#elif PCVT_NOFASTSCROLL != 0 /* This is done by changing the CRTC */ -# undef PCVT_NOFASTSCROLL /* screen start address for scrolling */ -# define PCVT_NOFASTSCROLL 1 /* and using 2 times the screen size as */ -#endif /* buffer. The fastscroll code works */ - /* ONLY for VGA/EGA/CGA because it uses */ - /* the crtc for hardware scrolling and */ - /* therefore needs more than the one */ - /* page video memory MDA and most */ - /* Hercules boards support. */ - /* If you run pcvt ONLY on MDA/Hercules */ - /* you should disable fastscroll to save*/ - /* the time to decide which board you */ - /* are running pcvt on at runtime. */ - /* [see roll_up() and roll_down().] */ - #if !defined PCVT_SLOW_INTERRUPT/* ---------- DEFAULT: OFF ------------ */ # define PCVT_SLOW_INTERRUPT 0 /* If off, protecting critical regions */ #elif PCVT_SLOW_INTERRUPT != 0 /* in the keyboard fifo code is done by */ @@ -438,20 +217,6 @@ # define PCVT_SLOW_INTERRUPT 1 /* this is done by spl()/splx() calls. */ #endif -#ifdef XSERVER - -#if !defined PCVT_USL_VT_COMPAT /* ---------- DEFAULT: ON ------------- */ -# define PCVT_USL_VT_COMPAT 1 /* this option enables multiple virtual */ -#elif PCVT_USL_VT_COMPAT != 0 /* screen support for XFree86. If set */ -# undef PCVT_USL_VT_COMPAT /* to off, support for a "classic" */ -# define PCVT_USL_VT_COMPAT 1 /* single screen only X server is */ -#endif /* compiled in. If enabled, most of the */ - /* ioctl's from SYSV/USL are supported */ - /* to run multiple X servers and/or */ - /* character terminal sessions. */ - -#endif /* XSERVER */ - /*---------------------------------------------------------------------------* * Kernel messages attribute definitions * These define the foreground and background attributes used to diff --git a/sys/i386/isa/pcvt/pcvt_drv.c b/sys/i386/isa/pcvt/pcvt_drv.c index 5c50173..605002f 100644 --- a/sys/i386/isa/pcvt/pcvt_drv.c +++ b/sys/i386/isa/pcvt/pcvt_drv.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Hellmuth Michaelis + * Copyright (c) 1999, 2000 Hellmuth Michaelis * * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -11,7 +11,7 @@ * * Parts of this code regarding the NetBSD interface were written * by Charles Hannum. - * + * * This code is derived from software contributed to Berkeley by * William Jolitz and Don Ahn. * @@ -48,7 +48,7 @@ * pcvt_drv.c VT220 Driver Main Module / OS - Interface * --------------------------------------------------------- * - * Last Edit-Date: [Mon Dec 27 14:03:36 1999] + * Last Edit-Date: [Sun Mar 26 10:38:24 2000] * * $FreeBSD$ * @@ -57,33 +57,20 @@ #include "vt.h" #if NVT > 0 -#define EXTERN /* allocate mem */ - -#include <i386/isa/pcvt/pcvt_hdr.h> /* global include */ - -#if PCVT_FREEBSD >= 200 -#include <sys/bus.h> -#include <machine/stdarg.h> -#else -#include "machine/stdarg.h" -#endif +#define MAIN +#include <i386/isa/pcvt/pcvt_hdr.h> +#undef MAIN -extern int getchar __P((void)); +#include <sys/bus.h> /* XXX */ -#if PCVT_NETBSD - extern u_short *Crtat; -#endif /* PCVT_NETBSD */ - -static void vgapelinit(void); /* read initial VGA DAC palette */ - -#if defined XSERVER && !PCVT_USL_VT_COMPAT -static int pcvt_xmode_set(int on, struct proc *p); /* initialize for X mode */ -#endif /* XSERVER && !PCVT_USL_VT_COMPAT */ +static kbd_callback_func_t pcevent; +static int pcvt_kbd_wptr = 0; +static u_char pcvt_timeout_scheduled = 0; -#ifdef _DEV_KBD_KBDREG_H_ +static void vgapelinit(void); static void detect_kbd(void *arg); -static kbd_callback_func_t pcevent; -#endif +static void pcstart(register struct tty *tp); +static int pcparam(struct tty *tp, struct termios *t); static cn_probe_t pccnprobe; static cn_init_t pccninit; @@ -118,23 +105,23 @@ static struct cdevsw pc_cdevsw = { /* bmaj */ -1 }; -#if PCVT_NETBSD > 100 /* NetBSD-current Feb 20 1995 */ -int -pcprobe(struct device *parent, void *match, void *aux) -#else -#if PCVT_NETBSD > 9 -int -pcprobe(struct device *parent, struct device *self, void *aux) -#else -int +static int pcprobe ( struct isa_device *dev ); +static int pcattach ( struct isa_device *dev ); + +struct isa_driver vtdriver = { /* driver routines */ + pcprobe, pcattach, "vt", 1, +}; + +/*---------------------------------------------------------------------------* + * driver probe + *---------------------------------------------------------------------------*/ +static int pcprobe(struct isa_device *dev) -#endif /* PCVT_NETBSD > 9 */ -#endif /* PCVT_NETBSD > 100 */ { -#ifdef _DEV_KBD_KBDREG_H_ int i; - if (kbd == NULL) { + if (kbd == NULL) + { reset_keyboard = 0; kbd_configure(KB_CONF_PROBE_ONLY); i = kbd_allocate("*", -1, (void *)&kbd, pcevent, (void *)dev->id_unit); @@ -142,53 +129,26 @@ pcprobe(struct isa_device *dev) return (-1); } reset_keyboard = 1; /* it's now safe to do kbd reset */ -#endif /* _DEV_KBD_KBDREG_H_ */ kbd_code_init(); -#if PCVT_NETBSD > 9 - ((struct isa_attach_args *)aux)->ia_iosize = 16; - return 1; -#else -#ifdef _DEV_KBD_KBDREG_H_ return (-1); -#elif PCVT_NETBSD || PCVT_FREEBSD - return (16); -#else - return 1; -#endif /* PCVT_NETBSD || PCVT_FREEBSD */ -#endif /* PCVT_NETBSD > 9 */ - } -#if PCVT_NETBSD > 9 -void -pcattach(struct device *parent, struct device *self, void *aux) -{ - struct isa_attach_args *ia = aux; - static struct intrhand vthand; -#else -int +/*---------------------------------------------------------------------------* + * driver attach + *---------------------------------------------------------------------------*/ +static int pcattach(struct isa_device *dev) { -#endif /* PCVT_NETBSD > 9 */ - int i; vt_coldmalloc(); /* allocate memory for screens */ -#ifdef _DEV_KBD_KBDREG_H_ if (kbd == NULL) timeout(detect_kbd, (void *)dev->id_unit, hz*2); -#endif /* _DEV_KBD_KBDREG_H_ */ - -#if PCVT_NETBSD || PCVT_FREEBSD -#if PCVT_NETBSD > 9 - printf(": "); -#else printf("vt%d: ", dev->id_unit); -#endif /* PCVT_NETBSD > 9 */ switch(adaptor_type) { @@ -205,7 +165,7 @@ pcattach(struct isa_device *dev) break; case VGA_ADAPTOR: - printf("%s, ", (char *)vga_string(vga_type)); + printf("%s VGA, ", (char *)vga_string(vga_type)); if(can_do_132col) printf("80/132 col"); else @@ -240,180 +200,27 @@ pcattach(struct isa_device *dev) break; } - printf("kbd, [R%s]\n", PCVT_REL); - -#if PCVT_NETBSD || (PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200) + printf("kbd\n"); for(i = 0; i < totalscreens; i++) { - -#if PCVT_NETBSD - pc_tty[i] = ttymalloc(); - vs[i].vs_tty = pc_tty[i]; -#else /* !PCVT_NETBSD */ - pccons[i] = ttymalloc(pccons[i]); - vs[i].vs_tty = pccons[i]; -#endif /* PCVT_NETBSD */ - - } - -#if PCVT_EMU_MOUSE -#if PCVT_NETBSD - pc_tty[totalscreens] = ttymalloc(); /* the mouse emulator tty */ -#else /* !PCVT_NETBSD */ - /* the mouse emulator tty */ - pc_tty[totalscreens] = ttymalloc(pccons[totalscreens]); -#endif /* PCVT_NETBSD */ -#endif /* PCVT_EMU_MOUSE */ - -#if PCVT_NETBSD - pcconsp = pc_tty[0]; -#else /* !PCVT_NETBSD */ - pcconsp = pccons[0]; -#endif /* PCVT_NETBSD */ - -#endif /* #if PCVT_NETBSD || (PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200) */ - -#else /* !PCVT_NETBSD && !PCVT_FREEBSD*/ - - switch(adaptor_type) - { - case MDA_ADAPTOR: - printf(" <mda"); - break; - - case CGA_ADAPTOR: - printf(" <cga"); - break; - - case EGA_ADAPTOR: - printf(" <ega"); - break; - - case VGA_ADAPTOR: - printf(" <%s,", (char *)vga_string(vga_type)); - if(can_do_132col) - printf("80/132 col"); - else - printf("80 col"); - vgapelinit(); - break; - - default: - printf(" <unknown"); - break; - } - - if(color == 0) - printf(",mono"); - else - printf(",color"); - - printf(",%d scr,", totalscreens); - - switch(keyboard_type) - { - case KB_AT: - printf("at-"); - break; - - case KB_MFII: - printf("mf2-"); - break; - - default: - printf("unknown "); - break; - } - - printf("kbd,[R%s]>", PCVT_REL); - -#endif /* PCVT_NETBSD || PCVT_FREEBSD */ - -#if !PCVT_NETBSD && !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200) - for(i = 0; i < totalscreens; i++) - { ttyregister(&pccons[i]); vs[i].vs_tty = &pccons[i]; make_dev(&pc_cdevsw, i, UID_ROOT, GID_WHEEL, 0600, "ttyv%r", i); } -#endif /* !PCVT_NETBSD && !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200) */ async_update(UPDATE_START); /* start asynchronous updates */ -#if PCVT_NETBSD > 9 - - vthand.ih_fun = pcrint; - vthand.ih_arg = 0; - vthand.ih_level = IPL_TTY; - -#if (PCVT_NETBSD > 100) && defined(IST_EDGE) - intr_establish(ia->ia_irq, IST_EDGE, &vthand); -#else /* PCVT_NETBSD > 100 */ - intr_establish(ia->ia_irq, &vthand); -#endif /* PCVT_NETBSD > 100 */ - -#else /* PCVT_NETBSD > 9 */ - dev->id_ointr = pcrint; return 1; - -#endif /* PCVT_NETBSD > 9 */ - -} - -/* had a look at the friedl driver */ - -#if !PCVT_NETBSD - -struct tty * -get_pccons(Dev_t dev) -{ - register int i = minor(dev); - -#if PCVT_EMU_MOUSE - if(i == totalscreens) -#if !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200) - return(&pccons[i]); -#else - return(pccons[i]); -#endif /* !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200) */ -#endif /* PCVT_EMU_MOUSE */ - - if(i >= PCVT_NSCREENS) - return(NULL); -#if !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200) - return(&pccons[i]); -#else - return(pccons[i]); -#endif } -#else - -struct tty * -get_pccons(Dev_t dev) -{ - register int i = minor(dev); - -#if PCVT_EMU_MOUSE - if(i == totalscreens) - return(pc_tty[i]); -#endif /* PCVT_EMU_MOUSE */ - - if(i >= PCVT_NSCREENS) - return(NULL); - return(pc_tty[i]); -} - -#endif /* !PCVT_NETBSD */ - /*---------------------------------------------------------------------------* - * /dev/ttyc0, /dev/ttyc1, etc. + * driver open *---------------------------------------------------------------------------*/ -int -pcopen(Dev_t dev, int flag, int mode, struct proc *p) +static int +pcopen(dev_t dev, int flag, int mode, struct proc *p) { register struct tty *tp; register struct video_state *vsx; @@ -421,30 +228,14 @@ pcopen(Dev_t dev, int flag, int mode, struct proc *p) int winsz = 0; int i = minor(dev); -#if PCVT_EMU_MOUSE - if(i == totalscreens) - vsx = 0; - else -#endif /* PCVT_EMU_MOUSE */ - vsx = &vs[i]; - if((tp = get_pccons(dev)) == NULL) + if(i >= PCVT_NSCREENS) return ENXIO; - dev->si_tty = tp; + tp = &pccons[i]; -#if PCVT_EMU_MOUSE - if(i == totalscreens) - { - if(mouse.opened == 0) - mouse.buttons = mouse.extendedseen = - mouse.breakseen = mouse.lastmove.tv_sec = 0; - mouse.minor = i; - mouse.opened++; - } - else -#endif /* PCVT_EMU_MOUSE */ + dev->si_tty = tp; vsx->openf++; @@ -455,11 +246,6 @@ pcopen(Dev_t dev, int flag, int mode, struct proc *p) if ((tp->t_state & TS_ISOPEN) == 0) { - -#ifdef TS_WOPEN /* not (FreeBSD-1.1.5 or FreeBSD some time after 2.0.5) */ - tp->t_state |= TS_WOPEN; -#endif - ttychars(tp); tp->t_iflag = TTYDEF_IFLAG; tp->t_oflag = TTYDEF_OFLAG; @@ -471,17 +257,14 @@ pcopen(Dev_t dev, int flag, int mode, struct proc *p) winsz = 1; /* set winsize later */ } else if (tp->t_state & TS_XCLUDE && suser(p)) + { return (EBUSY); + } -#if PCVT_NETBSD || (PCVT_FREEBSD >= 200) retval = ((*linesw[tp->t_line].l_open)(dev, tp)); -#else - retval = ((*linesw[tp->t_line].l_open)(dev, tp, flag)); -#endif /* PCVT_NETBSD || (PCVT_FREEBSD >= 200) */ if(winsz == 1) { - /* * The line discipline has clobbered t_winsize if TS_ISOPEN * was clear. (NetBSD PR #400 from Bill Sommerfeld) @@ -498,62 +281,53 @@ pcopen(Dev_t dev, int flag, int mode, struct proc *p) splx(s); } - return(retval); } -int -pcclose(Dev_t dev, int flag, int mode, struct proc *p) +/*---------------------------------------------------------------------------* + * driver close + *---------------------------------------------------------------------------*/ +static int +pcclose(dev_t dev, int flag, int mode, struct proc *p) { register struct tty *tp; register struct video_state *vsx; int i = minor(dev); -#if PCVT_EMU_MOUSE - if(i == totalscreens) - vsx = 0; - else -#endif /* PCVT_EMU_MOUSE */ - vsx = &vs[i]; - if((tp = get_pccons(dev)) == NULL) + if(i >= PCVT_NSCREENS) return ENXIO; + tp = &pccons[i]; + (*linesw[tp->t_line].l_close)(tp, flag); - ttyclose(tp); -#if PCVT_EMU_MOUSE - if(i == totalscreens) - mouse.opened = 0; - else -#endif /* PCVT_EMU_MOUSE */ + ttyclose(tp); vsx->openf = 0; -#if PCVT_USL_VT_COMPAT -#if PCVT_EMU_MOUSE - - if(i == totalscreens) - return (0); - -#endif /* PCVT_EMU_MOUSE */ - +#ifdef XSERVER reset_usl_modes(vsx); - -#endif /* PCVT_USL_VT_COMPAT */ +#endif /* XSERVER */ return(0); } -int -pcioctl(Dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +/*---------------------------------------------------------------------------* + * driver ioctl + *---------------------------------------------------------------------------*/ +static int +pcioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) { register int error; register struct tty *tp; + int i = minor(dev); + + if(i >= PCVT_NSCREENS) + return ENXIO; - if((tp = get_pccons(dev)) == NULL) - return(ENXIO); + tp = &pccons[i]; /* note that some ioctl's are global, e.g. KBSTPMAT: There is * only one keyboard and different repeat rates for instance between @@ -561,21 +335,12 @@ pcioctl(Dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) * appropriate variables arrays */ -#if PCVT_EMU_MOUSE - if(minor(dev) == totalscreens) - { - if((error = mouse_ioctl(dev, cmd, data)) >= 0) - return error; - goto do_standard; - } -#endif /* PCVT_EMU_MOUSE */ - #ifdef XSERVER -#if PCVT_USL_VT_COMPAT if((error = usl_vt_ioctl(dev, cmd, data, flag, p)) >= 0) return error; +#if 0 /* * just for compatibility: * XFree86 < 2.0 and SuperProbe still might use it @@ -619,7 +384,6 @@ pcioctl(Dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) return 0; } - case CONSOLE_X_BELL: /* @@ -630,15 +394,8 @@ pcioctl(Dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) if (data) { - -#if PCVT_NETBSD - sysbeep(((int *)data)[0], - ((int *)data)[1] * hz / 1000); -#else /* PCVT_NETBSD */ sysbeep(PCVT_SYSBEEPF / ((int *)data)[0], ((int *)data)[1] * hz / 3000); -#endif /* PCVT_NETBSD */ - } else { @@ -648,47 +405,8 @@ pcioctl(Dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) default: /* fall through */ ; } +#endif /* 0 */ -#else /* PCVT_USL_VT_COMPAT */ - - switch(cmd) - { - case CONSOLE_X_MODE_ON: - return pcvt_xmode_set(1, p); - - case CONSOLE_X_MODE_OFF: - return pcvt_xmode_set(0, p); - - case CONSOLE_X_BELL: - - /* - * If `data' is non-null, the first int value denotes - * the pitch, the second a duration. Otherwise, behaves - * like BEL. - */ - - if (data) - { - -#if PCVT_NETBSD - sysbeep(((int *)data)[0], - ((int *)data)[1] * hz / 1000); -#else /* PCVT_NETBSD */ - sysbeep(PCVT_SYSBEEPF / ((int *)data)[0], - ((int *)data)[1] * hz / 3000); -#endif /* PCVT_NETBSD */ - - } - else - { - sysbeep(PCVT_SYSBEEPF / 1493, hz / 4); - } - return (0); - - default: /* fall through */ ; - } - -#endif /* PCVT_USL_VT_COMPAT */ #endif /* XSERVER */ if((error = kbdioctl(dev,cmd,data,flag)) >= 0) @@ -697,32 +415,21 @@ pcioctl(Dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) if((error = vgaioctl(dev,cmd,data,flag)) >= 0) return error; -#if PCVT_EMU_MOUSE -do_standard: -#endif - -#if PCVT_NETBSD > 9 || PCVT_FREEBSD >= 200 if((error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p)) != ENOIOCTL) return (error); -#else - if((error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag)) >= 0) - return(error); -#endif /* PCVT_NETBSD > 9 || PCVT_FREEBSD >= 200 */ -#if PCVT_NETBSD > 9 - if((error = ttioctl(tp, cmd, data, flag, p)) >= 0) - return (error); -#else if((error = ttioctl(tp, cmd, data, flag)) != ENOIOCTL) return (error); -#endif /* PCVT_NETBSD > 9 */ return (ENOTTY); } -int -pcmmap(Dev_t dev, vm_offset_t offset, int nprot) +/*---------------------------------------------------------------------------* + * driver mmap + *---------------------------------------------------------------------------*/ +static int +pcmmap(dev_t dev, vm_offset_t offset, int nprot) { if (offset > 0x20000 - PAGE_SIZE) return -1; @@ -730,23 +437,8 @@ pcmmap(Dev_t dev, vm_offset_t offset, int nprot) } /*---------------------------------------------------------------------------* - * - * handle a keyboard receive interrupt - * - * NOTE: the keyboard is multiplexed by means of "pcconsp" - * between virtual screens. pcconsp - switching is done in - * the vgapage() routine - * + * timeout handler *---------------------------------------------------------------------------*/ - -#if PCVT_KBD_FIFO - -u_char pcvt_kbd_fifo[PCVT_KBD_FIFO_SZ]; -static int pcvt_kbd_wptr = 0; -int pcvt_kbd_rptr = 0; -short pcvt_kbd_count= 0; -static u_char pcvt_timeout_scheduled = 0; - static void pcvt_timeout(void *arg) { @@ -791,9 +483,10 @@ pcvt_timeout(void *arg) return; } -#endif -#ifdef _DEV_KBD_KBDREG_H_ +/*---------------------------------------------------------------------------* + * check for keyboard + *---------------------------------------------------------------------------*/ static void detect_kbd(void *arg) { @@ -815,7 +508,10 @@ detect_kbd(void *arg) timeout(detect_kbd, (void *)unit, hz*2); } -int +/*---------------------------------------------------------------------------* + * keyboard event handler + *---------------------------------------------------------------------------*/ +static int pcevent(keyboard_t *thiskbd, int event, void *arg) { int unit = (int)arg; @@ -837,53 +533,35 @@ pcevent(keyboard_t *thiskbd, int event, void *arg) return EINVAL; } } -#endif /* _DEV_KBD_KBDREG_H_ */ +/*---------------------------------------------------------------------------* + * (keyboard) interrupt handler + *---------------------------------------------------------------------------*/ void pcrint(int unit) { - -#if PCVT_KBD_FIFO u_char dt; u_char ret = -1; - + int c; + # if PCVT_SLOW_INTERRUPT int s; # endif -# ifdef _DEV_KBD_KBDREG_H_ - int c; -# endif - -#else /* !PCVT_KBD_FIFO */ - u_char *cp; -#endif /* PCVT_KBD_FIFO */ - #if PCVT_SCREENSAVER pcvt_scrnsv_reset(); #endif /* PCVT_SCREENSAVER */ -#if PCVT_KBD_FIFO if (kbd_polling) { sgetc(1); return; } -# ifndef _DEV_KBD_KBDREG_H_ - while (inb(CONTROLLER_CTRL) & STATUS_OUTPBF) /* check 8042 buffer */ - { - ret = 1; /* got something */ - - PCVT_KBD_DELAY(); /* 7 us delay */ - - dt = inb(CONTROLLER_DATA); /* get it 8042 data */ -# else while ((c = (*kbdsw[kbd->kb_index]->read)(kbd, FALSE)) != -1) { ret = 1; /* got something */ dt = c; -# endif /* _DEV_KBD_KBDREG_H_ */ if (pcvt_kbd_count >= PCVT_KBD_FIFO_SZ) /* fifo overflow ? */ { @@ -912,37 +590,12 @@ pcrint(int unit) PCVT_ENABLE_INTR (); } } - -#else /* !PCVT_KBD_FIFO */ - - if((cp = sgetc(1)) == 0) - return; - - if (kbd_polling) - return; - - if(!(vs[current_video_screen].openf)) /* XXX was vs[minor(dev)] */ - return; - -#if PCVT_NULLCHARS - if(*cp == '\0') - { - /* pass a NULL character */ - (*linesw[pcconsp->t_line].l_rint)('\0', pcconsp); - return; - } -#endif /* PCVT_NULLCHARS */ - - while (*cp) - (*linesw[pcconsp->t_line].l_rint)(*cp++ & 0xff, pcconsp); - -#endif /* PCVT_KBD_FIFO */ } - -#if PCVT_NETBSD || PCVT_FREEBSD >= 200 - -void +/*---------------------------------------------------------------------------* + * start output + *---------------------------------------------------------------------------*/ +static void pcstart(register struct tty *tp) { register struct clist *rbp; @@ -972,7 +625,7 @@ pcstart(register struct tty *tp) while((len = q_to_b(rbp, buf, PCVT_PCBURST)) > 0) { if(vs[minor(tp->t_dev)].scrolling) - sgetc(31337); + sgetc(SCROLLBACK_COOKIE); /* * We need to do this outside spl since it could be fairly @@ -985,167 +638,47 @@ pcstart(register struct tty *tp) tp->t_state &= ~TS_BUSY; -#ifndef TS_ASLEEP /* FreeBSD some time after 2.0.5 */ ttwwakeup(tp); -#else - 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); - } -#endif -out: - splx(s); -} - -void -pcstop(struct tty *tp, int flag) -{ -} -#else /* PCVT_NETBSD || PCVT_FREEBSD >= 200 */ - -void -pcstart(struct tty *tp) -{ - int s; - unsigned char c; - - s = spltty(); - - if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) - { - goto out; - } - - for(;;) - { - -#if !(PCVT_FREEBSD > 114) - -#if !(PCVT_FREEBSD > 111) - if (RB_LEN(&tp->t_out) <= tp->t_lowat) -#else - if (RB_LEN(tp->t_out) <= tp->t_lowat) -#endif - { - if (tp->t_state&TS_ASLEEP) - { - tp->t_state &= ~TS_ASLEEP; -#if !(PCVT_FREEBSD > 111) - wakeup((caddr_t)&tp->t_out); -#else - wakeup((caddr_t)tp->t_out); -#endif - } - - if (tp->t_wsel) - { - selwakeup(tp->t_wsel, tp->t_state & TS_WCOLL); - tp->t_wsel = 0; - tp->t_state &= ~TS_WCOLL; - } - } - -#else /* PCVT_FREEBSD > 114 */ - if (tp->t_state & (TS_SO_OCOMPLETE | TS_SO_OLOWAT) - || tp->t_wsel) { - ttwwakeup(tp); - } -#endif /* !PCVT_FREEBSD > 114 */ - -#if !(PCVT_FREEBSD > 111) - if (RB_LEN(&tp->t_out) == 0) -#else - if (RB_LEN(tp->t_out) == 0) -#endif - { - goto out; - } - -#if !(PCVT_FREEBSD > 111) - c = getc(&tp->t_out); -#else - c = getc(tp->t_out); -#endif - - tp->t_state |= TS_BUSY; /* patch from Frank Maclachlan */ - splx(s); - sput(&c, 0, 1, minor(tp->t_dev)); - spltty(); - tp->t_state &= ~TS_BUSY; /* patch from Frank Maclachlan */ - } out: splx(s); } -#endif /* PCVT_NETBSD || PCVT_FREEBSD >= 200 */ - /*---------------------------------------------------------------------------* - * /dev/console + * console probe *---------------------------------------------------------------------------*/ - -#if !PCVT_NETBSD /* has moved to cons.c in netbsd-current */ -void -consinit() /* init for kernel messages during boot */ -{ -} -#endif /* PCVT_NETBSD */ - -#if PCVT_FREEBSD > 205 static void -#else -int -#endif pccnprobe(struct consdev *cp) { int unit = 0; int i; /* See if this driver is disabled in probe hint. */ - if (resource_int_value("vt", unit, "disabled", &i) == 0 && i) { + if (resource_int_value("vt", unit, "disabled", &i) == 0 && i) + { cp->cn_pri = CN_DEAD; return; } -#ifdef _DEV_KBD_KBDREG_H_ kbd_configure(KB_CONF_PROBE_ONLY); + if (kbd_find_keyboard("*", unit) < 0) { cp->cn_pri = CN_DEAD; return; } -#endif /* _DEV_KBD_KBDREG_H_ */ /* initialize required fields */ cp->cn_dev = makedev(CDEV_MAJOR, 0); cp->cn_pri = CN_INTERNAL; - -#if !PCVT_NETBSD - -#if !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200) cp->cn_tp = &pccons[0]; -#else - cp->cn_tp = pccons[0]; -#endif /* !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200) */ - -#endif /* !PCVT_NETBSD */ - -#if PCVT_FREEBSD <= 205 - return 1; -#endif } -#if PCVT_FREEBSD > 205 +/*---------------------------------------------------------------------------* + * console init + *---------------------------------------------------------------------------*/ static void -#else -int -#endif pccninit(struct consdev *cp) { int unit = 0; @@ -1153,7 +686,6 @@ pccninit(struct consdev *cp) pcvt_is_console = 1; -#ifdef _DEV_KBD_KBDREG_H_ /* * Don't reset the keyboard via `kbdio' just yet. * The system clock has not been calibrated... @@ -1165,7 +697,9 @@ pccninit(struct consdev *cp) kbd_release(kbd, (void *)&kbd); kbd = NULL; } + i = kbd_allocate("*", -1, (void *)&kbd, pcevent, (void *)unit); + if (i >= 0) kbd = kbd_get_keyboard(i); @@ -1181,180 +715,117 @@ pccninit(struct consdev *cp) KBD_TRANSLATION, 0); } #endif /* PCVT_SCANSET == 2 */ - -#endif /* _DEV_KBD_KBDREG_H_ */ - -#if PCVT_FREEBSD <= 205 - return 0; -#endif } +/*---------------------------------------------------------------------------* + * console finish + *---------------------------------------------------------------------------*/ static void pccnterm(struct consdev *cp) { -#ifdef _DEV_KBD_KBDREG_H_ if (kbd) { kbd_release(kbd, (void *)&kbd); kbd = NULL; } -#endif /* _DEV_KBD_KBDREG_H_ */ } -#if PCVT_FREEBSD > 205 +/*---------------------------------------------------------------------------* + * console put char + *---------------------------------------------------------------------------*/ static void -#else -int -#endif -pccnputc(Dev_t dev, U_char c) +pccnputc(dev_t dev, int c) { - -#if PCVT_SW0CNOUTP - - if(current_video_screen != 0) - { - -#if !PCVT_USL_VT_COMPAT - vgapage(0); -#else - switch_screen(0, 0); -#endif /* !PCVT_USL_VT_COMPAT */ - - } - -#endif /* PCVT_SW0CNOUTP */ - if (c == '\n') sput("\r", 1, 1, 0); sput((char *) &c, 1, 1, 0); async_update(UPDATE_KERN); - -#if PCVT_FREEBSD <= 205 - return 0; -#endif } +/*---------------------------------------------------------------------------* + * console get char + *---------------------------------------------------------------------------*/ static int -pccngetc(Dev_t dev) +pccngetc(dev_t dev) { register int s; static u_char *cp, cbuf[4]; /* Temp buf for multi-char key sequence. */ register u_char c; #ifdef XSERVER - -#if !PCVT_USL_VT_COMPAT - if (pcvt_xmode) - return 0; -#else /* !PCVT_USL_VT_COMPAT */ if (pcvt_kbd_raw) return 0; -#endif /* !PCVT_USL_VT_COMPAT */ - #endif /* XSERVER */ if (cp && *cp) + { /* * We still have a pending key sequence, e.g. * from an arrow key. Deliver this one first. */ return (*cp++); + } -#ifdef _DEV_KBD_KBDREG_H_ if (kbd == NULL) return 0; -#endif s = spltty(); /* block pcrint while we poll */ kbd_polling = 1; -#ifdef _DEV_KBD_KBDREG_H_ (*kbdsw[kbd->kb_index]->enable)(kbd); -#endif cp = sgetc(0); -#ifdef _DEV_KBD_KBDREG_H_ (*kbdsw[kbd->kb_index]->disable)(kbd); -#endif kbd_polling = 0; splx(s); + c = *cp++; - if (c && *cp) { + + if (c && *cp) + { /* Preserve the multi-char sequence for the next call. */ bcopy(cp, cbuf, 3); /* take care for a trailing '\0' */ cp = cbuf; - } else + } + else + { cp = 0; - -#if ! (PCVT_FREEBSD >= 201) - /* this belongs to cons.c */ - if (c == '\r') - c = '\n'; -#endif /* ! (PCVT_FREEBSD >= 201) */ - + } return c; } -#if PCVT_FREEBSD >= 200 +/*---------------------------------------------------------------------------* + * console check for char + *---------------------------------------------------------------------------*/ static int -pccncheckc(Dev_t dev) +pccncheckc(dev_t dev) { char *cp; int x; -#ifdef _DEV_KBD_KBDREG_H_ if (kbd == NULL) return 0; -#endif x = spltty(); kbd_polling = 1; -#ifdef _DEV_KBD_KBDREG_H_ (*kbdsw[kbd->kb_index]->enable)(kbd); -#endif cp = sgetc(1); -#ifdef _DEV_KBD_KBDREG_H_ (*kbdsw[kbd->kb_index]->disable)(kbd); -#endif kbd_polling = 0; splx(x); - return (cp == NULL ? -1 : *cp); -} -#endif /* PCVT_FREEBSD >= 200 */ -#if PCVT_NETBSD >= 100 -void -pccnpollc(Dev_t dev, int on) -{ - kbd_polling = on; - if (!on) { - register int s; - - /* - * If disabling polling, make sure there are no bytes left in - * the FIFO, holding up the interrupt line. Otherwise we - * won't get any further interrupts. - */ - s = spltty(); - pcrint(); - splx(s); - } + return (cp == NULL ? -1 : *cp); } -#endif /* PCVT_NETBSD >= 100 */ /*---------------------------------------------------------------------------* * Set line parameters *---------------------------------------------------------------------------*/ -int +static int pcparam(struct tty *tp, struct termios *t) { - register 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; + tp->t_cflag = t->c_cflag; return(0); } @@ -1363,7 +834,7 @@ pcparam(struct tty *tp, struct termios *t) * read initial VGA palette (as stored by VGA ROM BIOS) into * palette save area *----------------------------------------------------------------------*/ -void +static void vgapelinit(void) { register unsigned idx; @@ -1379,224 +850,6 @@ vgapelinit(void) NVGAPEL * sizeof(struct rgb)); } -#if defined XSERVER && !PCVT_USL_VT_COMPAT -/*----------------------------------------------------------------------* - * initialize for X mode - * i.e.: grant current process (the X server) all IO privileges, - * and mark in static variable so other hooks can test for it, - * save all loaded fonts and screen pages to pageable buffers; - * if parameter `on' is false, the same procedure is done reverse. - *----------------------------------------------------------------------*/ -static int -pcvt_xmode_set(int on, struct proc *p) -{ - static unsigned char *saved_fonts[NVGAFONTS]; - -#if PCVT_SCREENSAVER - static unsigned saved_scrnsv_tmo = 0; -#endif /* PCVT_SCREENSAVER */ - -#if (PCVT_NETBSD > 9) || (PCVT_FREEBSD > 102) - struct trapframe *fp; -#else - struct syscframe *fp; -#endif /* PCVT_NETBSD > 9 */ - - int error, i; - - /* X will only run on VGA and Hercules adaptors */ - - if(adaptor_type != VGA_ADAPTOR && adaptor_type != MDA_ADAPTOR) - return (EINVAL); - -#if PCVT_NETBSD > 9 - fp = (struct trapframe *)p->p_regs; -#else - fp = (struct syscframe *)p->p_regs; -#endif /* PCVT_NETBSD > 9 */ - - if(on) - { - /* - * Test whether the calling process has super-user privileges - * and we're in insecure mode. - * This prevents us from granting the potential security hole - * `IO priv' to insufficiently privileged processes. - */ - error = suser(p); - if (error != 0) - return (error); - if (securelevel > 0) - return (EPERM); - - if(pcvt_xmode) - return 0; - - pcvt_xmode = pcvt_kbd_raw = 1; - - for(i = 0; i < totalfonts; i++) - { - if(vgacs[i].loaded) - { - saved_fonts[i] = (unsigned char *) - malloc(32 * 256, M_DEVBUF, M_WAITOK); - if(saved_fonts[i] == 0) - { - printf( - "pcvt_xmode_set: no font buffer available\n"); - return (EAGAIN); - } - else - { - vga_move_charset(i, saved_fonts[i], 1); - } - } - else - { - saved_fonts[i] = 0; - } - } - -#if PCVT_SCREENSAVER - if(saved_scrnsv_tmo = scrnsv_timeout) - pcvt_set_scrnsv_tmo(0); /* turn it off */ -#endif /* PCVT_SCREENSAVER */ - - async_update(UPDATE_STOP); /* turn off */ - - /* disable text output and save screen contents */ - /* video board memory -> kernel memory */ - - bcopy(vsp->Crtat, vsp->Memory, - vsp->screen_rowsize * vsp->maxcol * CHR); - - vsp->Crtat = vsp->Memory; /* operate in memory now */ - -#ifndef _DEV_KBD_KBDREG_H_ - -#if PCVT_SCANSET == 2 - /* put keyboard to return ancient PC scan codes */ - kbc_8042cmd(CONTR_WRITE); -#if PCVT_USEKBDSEC /* security enabled */ - outb(CONTROLLER_DATA, - (COMMAND_SYSFLG|COMMAND_IRQEN|COMMAND_PCSCAN)); -#else /* security disabled */ - outb(CONTROLLER_DATA, - (COMMAND_INHOVR|COMMAND_SYSFLG|COMMAND_IRQEN|COMMAND_PCSCAN)); -#endif /* PCVT_USEKBDSEC */ -#endif /* PCVT_SCANSET == 2 */ - -#else /* _DEV_KBD_KBDREG_H_ */ - -#if PCVT_SCANSET == 2 - /* put keyboard to return ancient PC scan codes */ - set_controller_command_byte(*(KBDC *)kbd->kb_data, - KBD_TRANSLATION, KBD_TRANSLATION); -#endif /* PCVT_SCANSET == 2 */ - -#endif /* !_DEV_KBD_KBDREG_H_ */ - -#if PCVT_NETBSD > 9 - fp->tf_eflags |= PSL_IOPL; -#else - fp->sf_eflags |= PSL_IOPL; -#endif /* PCVT_NETBSD > 9 */ - - } - else - { - if(!pcvt_xmode) /* verify if in X */ - return 0; - - pcvt_xmode = pcvt_kbd_raw = 0; - - for(i = 0; i < totalfonts; i++) - { - if(saved_fonts[i]) - { - vga_move_charset(i, saved_fonts[i], 0); - free(saved_fonts[i], M_DEVBUF); - saved_fonts[i] = 0; - } - } - -#if PCVT_NETBSD > 9 - fp->tf_eflags &= ~PSL_IOPL; -#else - fp->sf_eflags &= ~PSL_IOPL; -#endif /* PCVT_NETBSD > 9 */ - -#if PCVT_SCREENSAVER - if(saved_scrnsv_tmo) - pcvt_set_scrnsv_tmo(saved_scrnsv_tmo); -#endif /* PCVT_SCREENSAVER */ - -#ifndef _DEV_KBD_KBDREG_H_ - -#if PCVT_SCANSET == 2 - kbc_8042cmd(CONTR_WRITE); -#if PCVT_USEKBDSEC /* security enabled */ - outb(CONTROLLER_DATA, - (COMMAND_SYSFLG|COMMAND_IRQEN)); -#else /* security disabled */ - outb(CONTROLLER_DATA, - (COMMAND_INHOVR|COMMAND_SYSFLG|COMMAND_IRQEN)); -#endif /* PCVT_USEKBDSEC */ -#endif /* PCVT_SCANSET == 2 */ - -#else /* _DEV_KBD_KBDREG_H_ */ - -#if PCVT_SCANSET == 2 - set_controller_command_byte(*(KBDC *)kbd->kb_data, - KBD_TRANSLATION, 0); -#endif /* PCVT_SCANSET == 2 */ - -#endif /* !_DEV_KBD_KBDREG_H_ */ - - if(adaptor_type == MDA_ADAPTOR) - { - /* - * Due to the fact that HGC registers are write-only, - * the Xserver can only make guesses about the state - * the HGC adaptor has been before turning on X mode. - * Thus, the display must be re-enabled now, and the - * cursor shape and location restored. - */ - outb(GN_DMCNTLM, 0x28); /* enable display, text mode */ - outb(addr_6845, CRTC_CURSORH); /* select high register */ - outb(addr_6845+1, - ((vsp->Crtat + vsp->cur_offset) - Crtat) >> 8); - outb(addr_6845, CRTC_CURSORL); /* select low register */ - outb(addr_6845+1, - ((vsp->Crtat + vsp->cur_offset) - Crtat)); - - outb(addr_6845, CRTC_CURSTART); /* select high register */ - outb(addr_6845+1, vsp->cursor_start); - outb(addr_6845, CRTC_CUREND); /* select low register */ - outb(addr_6845+1, vsp->cursor_end); - } - - /* restore screen and re-enable text output */ - /* kernel memory -> video board memory */ - - bcopy(vsp->Memory, Crtat, - vsp->screen_rowsize * vsp->maxcol * CHR); - - vsp->Crtat = Crtat; /* operate on-screen now */ - - /* set crtc screen memory start address */ - - outb(addr_6845, CRTC_STARTADRH); - outb(addr_6845+1, (vsp->Crtat - Crtat) >> 8); - outb(addr_6845, CRTC_STARTADRL); - outb(addr_6845+1, (vsp->Crtat - Crtat)); - - async_update(UPDATE_START); - } - return 0; -} -#endif /* XSERVER && !PCVT_USL_VT_COMPAT */ - #endif /* NVT > 0 */ /*-------------------------- E O F -------------------------------------*/ diff --git a/sys/i386/isa/pcvt/pcvt_ext.c b/sys/i386/isa/pcvt/pcvt_ext.c index 689304f..2251fb9 100644 --- a/sys/i386/isa/pcvt/pcvt_ext.c +++ b/sys/i386/isa/pcvt/pcvt_ext.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Hellmuth Michaelis + * Copyright (c) 1999, 2000 Hellmuth Michaelis * * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -42,7 +42,7 @@ * pcvt_ext.c VT220 Driver Extended Support Routines * ------------------------------------------------------ * - * Last Edit-Date: [Mon Dec 27 14:05:16 1999] + * Last Edit-Date: [Sun Mar 26 10:38:27 2000] * * $FreeBSD$ * @@ -1002,11 +1002,6 @@ et4000_col(int cols) int wd90c11_col(int cols) { - -#if !PCVT_BACKUP_FONTS - static unsigned char *sv_fontwd[NVGAFONTS]; -#endif /* !PCVT_BACKUP_FONTS */ - u_char *sp; u_char byte; int i; @@ -1039,30 +1034,6 @@ wd90c11_col(int cols) /* save current fonts */ -#if !PCVT_BACKUP_FONTS - for(i = 0; i < totalfonts; i++) - { - if(vgacs[i].loaded) - { - if((sv_fontwd[i] = - (u_char *)malloc(32 * 256, - M_DEVBUF, - M_WAITOK)) - == NULL) - printf("pcvt: no font buffer\n"); - else - vga_move_charset(i, - sv_fontwd[i], - 1); - } - else - { - sv_fontwd[i] = 0; - } - } - -#endif /* !PCVT_BACKUP_FONTS */ - sp = savearea.wd90c11; outb(addr_6845, 0x00); /* Horizontal Total */ @@ -1184,17 +1155,9 @@ wd90c11_col(int cols) /* restore fonts */ -#if !PCVT_BACKUP_FONTS - for(i = 0; i < totalfonts; i++) - { - if(sv_fontwd[i]) - vga_move_charset(i, sv_fontwd[i], 0); - } -#else for(i = 0; i < totalfonts; i++) if(saved_charsets[i]) vga_move_charset(i, 0, 0); -#endif /* !PCVT_BACKUP_FONTS */ select_vga_charset(vsp->vga_charset); @@ -2092,31 +2055,22 @@ cl_gd542x_col(int cols) return(1); } -#if PCVT_USL_VT_COMPAT +#ifdef XSERVER /*---------------------------------------------------------------------------* * switch screen from text mode to X-mode and vice versa *---------------------------------------------------------------------------*/ void switch_screen(int n, int oldgrafx, int newgrafx) { - #if PCVT_SCREENSAVER static unsigned saved_scrnsv_tmo = 0; #endif /* PCVT_SCREENSAVER */ -#if !PCVT_KBD_FIFO - int x; -#endif /* !PCVT_KBD_FIFO */ - int cols = vsp->maxcol; /* get current col val */ if(n < 0 || n >= totalscreens) return; -#if !PCVT_KBD_FIFO - x = spltty(); /* protect us */ -#endif /* !PCVT_KBD_FIFO */ - if(!oldgrafx && newgrafx) { /* switch from text to graphics */ @@ -2143,13 +2097,7 @@ switch_screen(int n, int oldgrafx, int newgrafx) /* update global screen pointers/variables */ current_video_screen = n; /* current screen no */ -#if !PCVT_NETBSD && !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200) pcconsp = &pccons[n]; /* current tty */ -#elif PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200 - pcconsp = pccons[n]; /* current tty */ -#else - pcconsp = pc_tty[n]; /* current tty */ -#endif vsp = &vs[n]; /* current video state ptr */ @@ -2213,10 +2161,6 @@ switch_screen(int n, int oldgrafx, int newgrafx) outb(addr_6845+1, 0); } -#if !PCVT_KBD_FIFO - splx(x); -#endif /* !PCVT_KBD_FIFO */ - select_vga_charset(vsp->vga_charset); if(vsp->maxcol != cols) @@ -2418,7 +2362,6 @@ vgapage(int new_screen) /* we are committed */ vt_switch_pending = 0; -#if PCVT_FREEBSD > 206 /* * XXX: If pcvt is acting as the systems console, * avoid panics going to the debugger while we are in @@ -2426,7 +2369,6 @@ vgapage(int new_screen) */ if(pcvt_is_console) cons_unavail = 0; -#endif } } return 0; @@ -2436,7 +2378,7 @@ vgapage(int new_screen) * ioctl handling for VT_USL mode *---------------------------------------------------------------------------*/ int -usl_vt_ioctl(Dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) +usl_vt_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) { int i, j, error, opri; struct vt_mode newmode; @@ -2504,7 +2446,6 @@ usl_vt_ioctl(Dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) vsp->proc = p; vsp->pid = p->p_pid; -#if PCVT_FREEBSD > 206 /* * XXX: If pcvt is acting as the systems console, * avoid panics going to the debugger while we are in @@ -2512,7 +2453,7 @@ usl_vt_ioctl(Dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) */ if(pcvt_is_console) cons_unavail = (newmode.mode == VT_PROCESS); -#endif + splx(opri); return 0; @@ -2582,11 +2523,10 @@ usl_vt_ioctl(Dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) { /* we are committed */ vt_switch_pending = 0; -#if PCVT_FREEBSD > 206 + /* XXX */ if(pcvt_is_console) cons_unavail = 0; -#endif } return 0; } @@ -2597,11 +2537,11 @@ usl_vt_ioctl(Dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) if(vsp->vt_status & VT_WAIT_ACK) { vt_switch_pending = 0; vsp->vt_status &= ~VT_WAIT_ACK; -#if PCVT_FREEBSD > 206 + /* XXX */ if(pcvt_is_console) cons_unavail = 1; -#endif + return 0; } break; @@ -2657,14 +2597,7 @@ usl_vt_ioctl(Dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) /* grant the process IO access; only allowed if euid == 0 */ /* and insecure */ { - -#if PCVT_NETBSD > 9 || PCVT_FREEBSD >= 200 struct trapframe *fp = p->p_md.md_regs; -#elif PCVT_NETBSD || (PCVT_FREEBSD && PCVT_FREEBSD > 102) - struct trapframe *fp = (struct trapframe *)p->p_regs; -#else - struct syscframe *fp = (struct syscframe *)p->p_regs; -#endif error = suser(p); if (error != 0) @@ -2672,11 +2605,7 @@ usl_vt_ioctl(Dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) if (securelevel > 0) return (EPERM); -#if PCVT_NETBSD || (PCVT_FREEBSD && PCVT_FREEBSD > 102) fp->tf_eflags |= PSL_IOPL; -#else - fp->sf_eflags |= PSL_IOPL; -#endif return 0; } @@ -2684,18 +2613,8 @@ usl_vt_ioctl(Dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) case KDDISABIO: /* abandon IO access permission */ { - -#if PCVT_NETBSD > 9 || PCVT_FREEBSD >= 200 struct trapframe *fp = p->p_md.md_regs; fp->tf_eflags &= ~PSL_IOPL; -#elif PCVT_NETBSD || (PCVT_FREEBSD && PCVT_FREEBSD > 102) - struct trapframe *fp = (struct trapframe *)p->p_regs; - fp->tf_eflags &= ~PSL_IOPL; -#else - struct syscframe *fp = (struct syscframe *)p->p_regs; - fp->sf_eflags &= ~PSL_IOPL; -#endif - return 0; } @@ -2769,16 +2688,7 @@ usl_vt_ioctl(Dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) int duration = *(int *)data >> 16; int pitch = *(int *)data & 0xffff; -#if PCVT_NETBSD - if(pitch != 0) - { - sysbeep(PCVT_SYSBEEPF / pitch, - duration * hz / 1000); - } -#else /* PCVT_NETBSD */ sysbeep(pitch, duration * hz / 3000); -#endif /* PCVT_NETBSD */ - } else { @@ -2813,7 +2723,7 @@ usl_vt_ioctl(Dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) return -1; /* inappropriate usl_vt_compat ioctl */ } -#endif /* PCVT_USL_VT_COMPAT */ +#endif /* XSERVER */ #endif /* NVT > 0 */ diff --git a/sys/i386/isa/pcvt/pcvt_hdr.h b/sys/i386/isa/pcvt/pcvt_hdr.h index cce271f..59208ef 100644 --- a/sys/i386/isa/pcvt/pcvt_hdr.h +++ b/sys/i386/isa/pcvt/pcvt_hdr.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Hellmuth Michaelis + * Copyright (c) 1999, 2000 Hellmuth Michaelis * * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -39,7 +39,7 @@ * pcvt_hdr.h VT220 Driver Global Include File * ------------------------------------------------ * - * Last Edit-Date: [Mon Dec 27 14:06:31 1999] + * Last Edit-Date: [Sun Mar 26 10:50:27 2000] * * $FreeBSD$ * @@ -49,11 +49,6 @@ /* see also: pcvt_ioctl.h */ #include "opt_pcvt.h" -#if defined(__FreeBSD__) && !defined(PCVT_FREEBSD) -# define PCVT_FREEBSD 210 -#endif - -#if PCVT_FREEBSD >= 200 #include <sys/param.h> #include <sys/systm.h> @@ -67,93 +62,37 @@ #include <sys/syslog.h> #include <sys/malloc.h> #include <sys/time.h> -#if PCVT_FREEBSD > 210 -#include <machine/random.h> -#endif /* PCVT_FREEBSD > 210 */ -#else /* ! PCVT_FREEBSD >= 200 */ - -#include "param.h" -#include "conf.h" -#include "ioctl.h" -#include "proc.h" -#include "signalvar.h" -#include "tty.h" -#include "uio.h" -#include "callout.h" -#include "systm.h" -#include "kernel.h" -#include "syslog.h" -#include "malloc.h" -#include "time.h" - -#endif /* PCVT_FREEBSD >= 200 */ - -#include <i386/isa/pcvt/pcvt_conf.h> +#include <sys/cons.h> +#include <machine/random.h> #include <machine/bus.h> +#include <machine/psl.h> +#include <machine/frame.h> +#include <machine/pcvt_ioctl.h> +#include <machine/pc/display.h> +#include <machine/clock.h> +#include <machine/md_var.h> +#include <machine/stdarg.h> #include <dev/kbd/kbdreg.h> #include <dev/kbd/atkbdcreg.h> -#if PCVT_NETBSD > 9 -#include "device.h" -#endif - -#if PCVT_NETBSD > 9 -#include "i386/isa/isavar.h" -#include "i386/cpufunc.h" -#elif PCVT_FREEBSD >= 200 +#include <i386/isa/pcvt/pcvt_conf.h> #include <i386/isa/isa_device.h> -#else -#include "i386/isa/isa_device.h" -#endif - -#if PCVT_FREEBSD >= 200 #include <i386/isa/icu.h> -#else -#include "i386/isa/icu.h" -#endif - -#if PCVT_NETBSD > 100 -#include "i386/isa/isareg.h" -#elif PCVT_FREEBSD >= 200 #include <i386/isa/isa.h> -#else -#include "i386/isa/isa.h" -#endif -#if PCVT_NETBSD > 9 -#include "dev/cons.h" -#elif PCVT_FREEBSD >= 200 -#include <sys/cons.h> -#else -#include "i386/i386/cons.h" -#endif +/*===========================================================================* + * definitions + *===========================================================================*/ -#if PCVT_NETBSD <= 9 -#if PCVT_FREEBSD >= 200 -#include <machine/psl.h> -#include <machine/frame.h> -#else /* ! PCVT_FREEBSD >= 200 */ -#include "machine/psl.h" -#include "machine/frame.h" -#endif /* PCVT_FREEBSD >= 200 */ -#endif /* PCVT_NETBSD <= 9 */ - -#if PCVT_NETBSD > 9 -#include <i386/isa/pcvt/pcvt_ioctl.h> -#elif PCVT_FREEBSD >= 200 -#include <machine/pcvt_ioctl.h> -#else -#include "machine/pcvt_ioctl.h" -#endif +#define PCVT_KBD_FIFO_SZ 256 /* keyboard fifo size */ +#define PCVT_PCBURST 256 /* # of burst out chars */ +#define SCROLLBACK_PAGES 8 /* scrollback buffer pages */ +#define SCROLLBACK_COOKIE 31337 /* scrollback buffer pages */ +#define PCVT_NONRESP_KEYB_TRY 25 /* no of times to try to detect */ + /* a nonresponding keyboard */ -#if PCVT_FREEBSD >= 200 -#include <machine/pc/display.h> -#if PCVT_FREEBSD > 200 -#include <machine/clock.h> -#include <machine/md_var.h> -#endif /* * The following values are defined in machine/console.h, but the header * file is not included here due to conflicts with pcvt_ioctl.h. @@ -162,13 +101,10 @@ #define KB_84 1 #define KB_101 2 #define KB_OTHER 3 -#else /* PCVT_FREEBSD >= 200 */ -#include "machine/pc/display.h" -#endif /* PCVT_FREEBSD >= 200 */ /* setup irq disable function to use */ -#if !(PCVT_SLOW_INTERRUPT) && (PCVT_NETBSD > 9) +#if !(PCVT_SLOW_INTERRUPT) # define PCVT_DISABLE_INTR() disable_intr() # define PCVT_ENABLE_INTR() enable_intr() # undef PCVT_SLOW_INTERRUPT @@ -179,134 +115,30 @@ # define PCVT_SLOW_INTERRUPT 1 #endif -/* perform option consistency checks */ - -#if defined PCVT_FREEBSD && PCVT_FREEBSD == 1 -# undef PCVT_FREEBSD -# define PCVT_FREEBSD 102 /* assume 1.0 release */ -#endif - -#if defined PCVT_NETBSD && PCVT_NETBSD == 1 -#undef PCVT_NETBSD -#define PCVT_NETBSD 9 /* assume 0.9 release for now */ -#endif - -#if PCVT_FREEBSD + PCVT_NETBSD == 0 -# error "pcvt_hdr.h: You MUST define one of PCVT_{NET,FREE}BSD \ -in the config file" -#elif (PCVT_FREEBSD && PCVT_NETBSD) -# error "pcvt_hdr.h: You CAN only define *one* of PCVT_{NET,FREE}BSD \ -in the config file" -#endif - #ifdef XSERVER /* PCVT_NULLCHARS is mandatory for X server */ -#if !PCVT_NULLCHARS + #undef PCVT_NULLCHARS #define PCVT_NULLCHARS 1 -#endif - -/* PCVT_BACKUP_FONTS is mandatory for PCVT_USL_VT_COMPAT */ -#if PCVT_USL_VT_COMPAT && !PCVT_BACKUP_FONTS -#undef PCVT_BACKUP_FONTS -#define PCVT_BACKUP_FONTS 1 -#endif - -#else /* XSERVER */ - -#if PCVT_USL_VT_COMPAT -#warning "Option PCVT_USL_VT_COMPAT meaningless without XSERVER" -#undef PCVT_USL_VT_COMPAT -#define PCVT_USL_VT_COMPAT 0 -#endif #endif /* XSERVER */ /* PCVT_SCREENSAVER is mandatory for PCVT_PRETTYSCRNS */ + #if PCVT_PRETTYSCRNS && !PCVT_SCREENSAVER #undef PCVT_SCREENSAVER #define PCVT_SCREENSAVER 1 #endif -/* get the inline inb/outb back again ... */ - -#if PCVT_NETBSD -#if PCVT_NETBSD == 9 -#include "machine/cpufunc.h" /* NetBSD 0.9 [...and earlier -currents] */ -#undef PCVT_USL_VT_COMPAT -#define PCVT_USL_VT_COMPAT 0 /* does not work, workaround ... */ -#else -#include "machine/pio.h" /* recent NetBSD -currents */ -#define NEW_AVERUNNABLE /* averunnable changes for younger currents */ -#endif /* PCVT_NETBSD == 9 */ -#endif /* PCVT_NETBSD */ - -#if PCVT_FREEBSD >= 200 -#define NEW_AVERUNNABLE /* new averunnable changes for FreeBSD 2.0 */ -#endif - #if PCVT_SCANSET !=1 && PCVT_SCANSET !=2 #error "Supported keyboard scancode sets are 1 and 2 only (for now)!!!" #endif -/* initial default scrollback buffer size (in pages) */ -#define SCROLLBACK_PAGES 8 - /*---------------------------------------------------------------------------* - * Keyboard and Keyboard Controller + * keyboard *---------------------------------------------------------------------------*/ -#ifndef _DEV_KBD_KBDREG_H_ - -#define CONTROLLER_CTRL 0x64 /* W - command, R - status */ -#define CONTROLLER_DATA 0x60 /* R/W - data */ - -/* commands to control the CONTROLLER (8042) on the mainboard */ - -#define CONTR_READ 0x20 /* read command byte from controller */ -#define CONTR_WRITE 0x60 /* write command to controller, see below */ -#define CONTR_SELFTEST 0xaa /* controller selftest, returns 0x55 when ok */ -#define CONTR_IFTEST 0xab /* interface selftest */ -#define CONTR_KBDISABL 0xad /* disable keyboard */ -#define CONTR_KBENABL 0xae /* enable keyboard */ - -/* command byte for writing to CONTROLLER (8042) via CONTR_WRITE */ - -#define COMMAND_RES7 0x80 /* bit 7, reserved, always write a ZERO ! */ -#define COMMAND_PCSCAN 0x40 /* bit 6, 1 = convert to pc scan codes */ -#define COMMAND_RES5 0x20 /* bit 5, perhaps (!) use 9bit frame - * instead of 11 */ -#define COMMAND_DISABL 0x10 /* bit 4, 1 = disable keyboard */ -#define COMMAND_INHOVR 0x08 /* bit 3, 1 = override security lock inhibit */ -#define COMMAND_SYSFLG 0x04 /* bit 2, value stored as "system flag" */ -#define COMMAND_RES2 0x02 /* bit 1, reserved, always write a ZERO ! */ -#define COMMAND_IRQEN 0x01 /* bit 0, 1 = enable output buffer full - * interrupt */ - -/* status from CONTROLLER (8042) on the mainboard */ - -#define STATUS_PARITY 0x80 /* bit 7, 1 = parity error on last byte */ -#define STATUS_RXTIMO 0x40 /* bit 6, 1 = receive timeout error occured */ -#define STATUS_TXTIMO 0x20 /* bit 5, 1 = transmit timeout error occured */ -#define STATUS_ENABLE 0x10 /* bit 4, 1 = keyboard unlocked */ -#define STATUS_WHAT 0x08 /* bit 3, 1 = wrote cmd to 0x64, 0 = wrote - * data to 0x60 */ -#define STATUS_SYSFLG 0x04 /* bit 2, value stored as "system flag" */ -#define STATUS_INPBF 0x02 /* bit 1, 1 = input buffer full (to 8042) */ -#define STATUS_OUTPBF 0x01 /* bit 0, 1 = output buffer full (from 8042) */ - -/* commands to the KEYBOARD (via the 8042 controller on mainboard..) */ - -#define KEYB_C_RESET 0xff /* reset keyboard to power-on status */ -#define KEYB_C_RESEND 0xfe /* resend last byte in case of error */ -#define KEYB_C_TYPEM 0xf3 /* set keyboard typematic rate/delay */ -#define KEYB_C_ID 0xf2 /* return keyboard id */ -#define KEYB_C_ECHO 0xee /* diagnostic, echo 0xee */ -#define KEYB_C_LEDS 0xed /* set/reset numlock,capslock & scroll lock */ - -#endif /* _DEV_KBD_KBDREG_H_ */ - /* responses from the KEYBOARD (via the 8042 controller on mainboard..) */ #define KEYB_R_OVERRUN0 0x00 /* keyboard buffer overflow */ @@ -679,21 +511,13 @@ in the config file" /* screen memory start, monochrome */ #ifndef MONO_BUF -# if PCVT_FREEBSD && (PCVT_FREEBSD > 102) -# define MONO_BUF (KERNBASE+0xB0000) -# else -# define MONO_BUF 0xfe0B0000 /* NetBSD-current: isa.h */ -# endif +#define MONO_BUF (KERNBASE+0xB0000) #endif /* screen memory start, color */ #ifndef CGA_BUF -# if PCVT_FREEBSD && (PCVT_FREEBSD > 102) -# define CGA_BUF (KERNBASE+0xB8000) -# else -# define CGA_BUF 0xfe0B8000 /* NetBSD-current: isa.h */ -# endif +#define CGA_BUF (KERNBASE+0xB8000) #endif #define CHR 2 /* bytes per word in screen mem */ @@ -729,41 +553,18 @@ in the config file" #define UPDATE_STOP ((void *)1) /* suspend cursor updates */ #define UPDATE_KERN ((void *)2) /* do cursor updates for kernel output */ -/* variables */ - -#ifdef EXTERN -#define WAS_EXTERN -#else -#define EXTERN extern -#endif - -EXTERN u_char *more_chars; /* response buffer via kbd */ -EXTERN u_char color; /* color or mono display */ - -EXTERN u_short kern_attr; /* kernel messages char attributes */ -EXTERN u_short user_attr; /* character attributes */ -#if !PCVT_EMU_MOUSE +/*===========================================================================* + * variables + *===========================================================================*/ -#if PCVT_NETBSD -EXTERN struct tty *pc_tty[PCVT_NSCREENS]; -#elif !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200) -EXTERN struct tty pccons[PCVT_NSCREENS]; -#else -EXTERN struct tty *pccons[PCVT_NSCREENS]; -#endif /* PCVT_NETBSD */ - -#else /* PCVT_EMU_MOUSE */ +u_char *more_chars; /* response buffer via kbd */ +u_char color; /* color or mono display */ -#if PCVT_NETBSD -EXTERN struct tty *pc_tty[PCVT_NSCREENS + 1]; -#elif !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200) -EXTERN struct tty pccons[PCVT_NSCREENS + 1]; -#else -EXTERN struct tty *pccons[PCVT_NSCREENS + 1]; -#endif +u_short kern_attr; /* kernel messages char attributes */ +u_short user_attr; /* character attributes */ -#endif /* PCVT_EMU_MOUSE */ +struct tty pccons[PCVT_NSCREENS]; struct sixels { u_char lower[MAXSIXEL]; /* lower half of char */ @@ -887,9 +688,7 @@ typedef struct video_state { u_short scr_offset; /* current scrollback offset (lines) */ short scrolling; /* current scrollback page */ u_short max_off; /* maximum scrollback offset */ - -#if PCVT_USL_VT_COMPAT /* SysV compatibility :-( */ - +#ifdef XSERVER struct vt_mode smode; struct proc *proc; pid_t pid; @@ -899,55 +698,25 @@ typedef struct video_state { #define VT_GRAFX 4 /* vt runs graphics mode */ #define VT_WAIT_ACT 8 /* a process is sleeping on this vt */ /* becoming active */ -#endif /* PCVT_USL_VT_COMPAT */ - +#endif /* XSERVER */ } video_state; -EXTERN video_state vs[PCVT_NSCREENS]; /* parameters for screens */ +video_state vs[PCVT_NSCREENS]; /* parameters for screens */ struct vga_char_state { - int loaded; /* Whether a font is loaded here */ - int secondloaded; /* an extension characterset was loaded, */ - /* the number is found here */ - u_char char_scanlines; /* Scanlines per character */ - u_char scr_scanlines; /* Low byte of scanlines per screen */ - int screen_size; /* Screen size in SIZ_YYROWS */ + int loaded; /* Whether a font is loaded here */ + int secondloaded; /* an extension characterset was loaded, */ + /* the number is found here */ + u_char char_scanlines; /* Scanlines per character */ + u_char scr_scanlines; /* Low byte of scanlines per screen */ + int screen_size; /* Screen size in SIZ_YYROWS */ }; -EXTERN struct vga_char_state vgacs[NVGAFONTS]; /* Character set states */ - -#if PCVT_EMU_MOUSE -struct mousestat { - struct timeval lastmove; /* last time the pointer moved */ - u_char opened; /* someone would like to use a mouse */ - u_char minor; /* minor device number */ - u_char buttons; /* current "buttons" pressed */ - u_char extendedseen; /* 0xe0 has been seen, do not use next key */ - u_char breakseen; /* key break has been seen for a sticky btn */ -}; -#endif /* PCVT_EMU_MOUSE */ +struct vga_char_state vgacs[NVGAFONTS]; /* Character set states */ -#ifdef WAS_EXTERN - -#if PCVT_NETBSD > 9 - -int pcprobe (); -void pcattach (); - -struct cfdriver vtcd = { - NULL, "vt", pcprobe, pcattach, DV_TTY, sizeof(struct device) -}; - -#else +u_short *Crtat; /* screen start address */ -int pcprobe ( struct isa_device *dev ); -int pcattach ( struct isa_device *dev ); - -struct isa_driver vtdriver = { /* driver routines */ - pcprobe, pcattach, "vt", 1, -}; - -#endif /* PCVT_NETBSD > 9 */ +#ifdef MAIN u_char fgansitopc[] = { /* foreground ANSI color -> pc */ FG_BLACK, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE, @@ -959,27 +728,12 @@ u_char bgansitopc[] = { /* background ANSI color -> pc */ BG_MAGENTA, BG_CYAN, BG_LIGHTGREY }; -#if !PCVT_NETBSD -u_short *Crtat; /* screen start address */ -#if !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200) -struct tty *pcconsp = &pccons[0]; /* ptr to current device */ -#else /* PCVT_FREEBSD > 110 */ -struct tty *pcconsp; -#endif /* !(PCVT_FREEBSD > 110) */ -#else -struct tty *pcconsp; /* ptr to current device, see pcattach() */ -#endif /* PCVT_NETBSD */ - -#if PCVT_EMU_MOUSE -struct mousestat mouse; -struct mousedefs mousedef = {0x3b, 0x3c, 0x3d, 0, 250000}; -#endif /* PCVT_EMU_MOUSE */ /* F1, F2, F3, false, 0.25 sec */ - -video_state *vsp = &vs[0]; /* ptr to current screen parms */ +struct tty *pcconsp = &pccons[0]; /* ptr to current device */ +video_state *vsp = &vs[0]; /* ptr to current screen parms */ -#if PCVT_USL_VT_COMPAT +#ifdef XSERVER int vt_switch_pending = 0; /* if > 0, a vt switch is */ -#endif /* PCVT_USL_VT_COMPAT */ /* pending; contains the # */ +#endif /* XSERVER */ /* pending; contains the # */ /* of the old vt + 1 */ u_int addr_6845 = MONO_BASE; /* crtc base addr */ @@ -1001,10 +755,8 @@ u_char chargen_access = 0; /* synchronize access */ u_char keyboard_type = KB_UNKNOWN; /* type of keyboard */ u_char keyboard_is_initialized = 0; /* for ddb sanity */ u_char kbd_polling = 0; /* keyboard is being polled */ -#ifdef _DEV_KBD_KBDREG_H_ u_char reset_keyboard = 0; /* OK to reset keyboard */ keyboard_t *kbd = NULL; -#endif /* _DEV_KBD_KBDREG_H_ */ #if PCVT_SHOWKEYS u_char keyboard_show = 0; /* normal display */ @@ -1022,15 +774,10 @@ u_char scrnsv_active = 0; /* active flag */ #ifdef XSERVER unsigned scrnsv_timeout = 0; /* initially off */ -#if !PCVT_USL_VT_COMPAT -u_char pcvt_xmode = 0; /* display is grafx */ -#endif /* PCVT_USL_VT_COMPAT */ u_char pcvt_kbd_raw = 0; /* keyboard sends scans */ #endif /* XSERVER */ -#if PCVT_BACKUP_FONTS u_char *saved_charsets[NVGAFONTS] = {0}; /* backup copy of fonts */ -#endif /* PCVT_BACKUP_FONTS */ /*--------------------------------------------------------------------------- @@ -1106,23 +853,25 @@ u_char sgr_tab_imono[16] = { /*15*/ (BG_LIGHTGREY | FG_BLACK | FG_BLINK | FG_INTENSE) /* bold+underl+blink+invers */ }; -#else /* WAS_EXTERN */ +u_char pcvt_kbd_fifo[PCVT_KBD_FIFO_SZ]; +int pcvt_kbd_rptr = 0; +int pcvt_kbd_count= 0; + +#else /* ! MAIN */ + +extern u_char pcvt_kbd_fifo[]; +extern int pcvt_kbd_rptr; +extern int pcvt_kbd_count; extern u_char vga_type; extern struct tty *pcconsp; extern video_state *vsp; -#if PCVT_EMU_MOUSE -extern struct mousestat mouse; -extern struct mousedefs mousedef; -#endif /* PCVT_EMU_MOUSE */ - -#if PCVT_USL_VT_COMPAT +#ifdef XSERVER extern int vt_switch_pending; -#endif /* PCVT_USL_VT_COMPAT */ +#endif /* XSERVER */ extern u_int addr_6845; -extern u_short *Crtat; extern u_char do_initialization; extern u_char pcvt_is_console; extern u_char bgansitopc[]; @@ -1142,23 +891,21 @@ extern u_char can_do_132col; extern u_char vga_family; extern u_char keyboard_is_initialized; extern u_char kbd_polling; -#ifdef _DEV_KBD_KBDREG_H_ extern u_char reset_keyboard; extern keyboard_t *kbd; -#endif /* _DEV_KBD_KBDREG_H_ */ #if PCVT_SHOWKEYS extern u_char keyboard_show; #endif /* PCVT_SHOWKEYS */ -extern u_char cursor_pos_valid; +extern u_char cursor_pos_valid; -extern u_char critical_scroll; -extern int switch_page; +extern u_char critical_scroll; +extern int switch_page; #if PCVT_SCREENSAVER -extern u_char reset_screen_saver; -extern u_char scrnsv_active; +extern u_char reset_screen_saver; +extern u_char scrnsv_active; #endif /* PCVT_SCREENSAVER */ extern u_char sgr_tab_color[]; @@ -1171,92 +918,13 @@ extern u_char pcvt_xmode; extern u_char pcvt_kbd_raw; #endif /* XSERVER */ -#if PCVT_BACKUP_FONTS extern u_char *saved_charsets[NVGAFONTS]; -#endif /* PCVT_BACKUP_FONTS */ -#endif /* WAS_EXTERN */ +#endif /* MAIN */ -/* - * FreeBSD > 1.0.2 cleaned up the kernel definitions (with the aim of - * getting ANSI-clean). Since there has been a mixed usage of types like - * "dev_t" (actually some short) in prototyped and non-prototyped fasion, - * each of those types is declared as "int" within function prototypes - * (which is what the compiler would actually promote it to). - * - * The macros below are used to clarify which type a parameter ought to - * be, regardless of its actual promotion to "int". - */ - -#define Dev_t int -#define U_short int -#define U_char int - -/* - * In FreeBSD >= 2.0, dev_t has type `unsigned long', so promoting it - * doesn't cause any problems in prototypes. - */ - -#if PCVT_FREEBSD >= 200 -#undef Dev_t -#define Dev_t dev_t -#endif - -#if !PCVT_FREEBSD || (PCVT_FREEBSD < 210) -extern void bcopyb(void *from, void *to, u_int length); -#endif - -#if !PCVT_FREEBSD || (PCVT_FREEBSD < 200) -extern void fillw(U_short value, void *addr, u_int length); -#endif - -int pcparam ( struct tty *tp, struct termios *t ); - -/* - * In FreeBSD > 2.0.6, driver console functions are declared in machine/cons.h - * and some return void, so don't declare them here. - */ -#if PCVT_FREEBSD <= 205 -int pccnprobe ( struct consdev *cp ); -int pccninit ( struct consdev *cp ); -int pccngetc ( Dev_t dev ); -int pccncheckc ( Dev_t dev ); -int pccnputc ( Dev_t dev, U_char c ); -#endif - -ointhand2_t pcrint; -void pcstart ( struct tty *tp ); -void pcstop ( struct tty *tp, int flag ); - -# if PCVT_FREEBSD < 200 -void consinit ( void ); -# endif - -#if PCVT_USL_VT_COMPAT -void switch_screen ( int n, int oldgrafx, int newgrafx ); -int usl_vt_ioctl (Dev_t dev, int cmd, caddr_t data, int flag, - struct proc *); -int vt_activate ( int newscreen ); -int vgapage ( int n ); -void get_usl_keymap( keymap_t *map ); -void reset_usl_modes (struct video_state *vsx); -#else -void vgapage ( int n ); -#endif /* PCVT_USL_VT_COMPAT */ - -#if PCVT_EMU_MOUSE -int mouse_ioctl ( Dev_t dev, int cmd, caddr_t data ); -#endif /* PCVT_EMU_MOUSE */ - -#if PCVT_SCREENSAVER -void pcvt_scrnsv_reset ( void ); -#endif /* PCVT_SCREENSAVER */ - -#if PCVT_SCREENSAVER && defined(XSERVER) -void pcvt_set_scrnsv_tmo ( int ); -#endif /* PCVT_SCREENSAVER && defined(XSERVER) */ - -void vga_move_charset ( unsigned n, unsigned char *b, int save_it); +/*===========================================================================* + * forward declarations + *===========================================================================*/ void async_update ( void *arg ); void clr_parms ( struct video_state *svsp ); @@ -1266,13 +934,14 @@ void dprintf ( unsigned flgs, const char *fmt, ... ); int egavga_test ( void ); void fkl_off ( struct video_state *svsp ); void fkl_on ( struct video_state *svsp ); -struct tty *get_pccons ( Dev_t dev ); + +#ifdef XSERVER +void get_usl_keymap( keymap_t *map ); +#endif + void init_sfkl ( struct video_state *svsp ); void init_ufkl ( struct video_state *svsp ); -#ifndef _DEV_KBD_KBDREG_H_ -int kbd_cmd ( int val ); -int kbd_response ( void ); -#endif /* _DEV_KBD_KBDREG_H_ */ +int kbdioctl ( dev_t dev, int cmd, caddr_t data, int flag ); void kbd_code_init ( void ); void kbd_code_init1 ( void ); @@ -1280,24 +949,42 @@ void kbd_code_init1 ( void ); void kbd_emulate_pc(int do_emulation); #endif -int kbdioctl ( Dev_t dev, int cmd, caddr_t data, int flag ); -void loadchar ( int fontset, int character, int char_scanlines, - u_char *char_table ); +void loadchar ( int fontset, int character, int char_scanlines, u_char *char_table ); void mda2egaorvga ( void ); +ointhand2_t pcrint; + +#if PCVT_SCREENSAVER +void pcvt_scrnsv_reset ( void ); +#ifdef XSERVER +void pcvt_set_scrnsv_tmo ( int ); +#endif +#endif + +void reallocate_scrollbuffer ( struct video_state *svsp, int pages ); + +#ifdef XSERVER +void reset_usl_modes (struct video_state *vsx); +#endif + void roll_up ( struct video_state *svsp, int n ); void select_vga_charset ( int vga_charset ); void set_2ndcharset ( void ); void set_charset ( struct video_state *svsp, int curvgacs ); void set_emulation_mode ( struct video_state *svsp, int mode ); void set_screen_size ( struct video_state *svsp, int size ); -void reallocate_scrollbuffer ( struct video_state *svsp, int pages ); -u_char *sgetc ( int noblock ); +u_char *sgetc ( int noblock ); void sixel_vga ( struct sixels *charsixel, u_char *charvga ); -void sput ( u_char *s, U_char attrib, int len, int page ); +void sput ( u_char *s, int attrib, int len, int page ); + +#ifdef XSERVER +void switch_screen ( int n, int oldgrafx, int newgrafx ); +#endif + +void swritefkl ( int num, u_char *string, struct video_state *svsp ); void sw_cursor ( int onoff ); void sw_sfkl ( struct video_state *svsp ); void sw_ufkl ( struct video_state *svsp ); -void swritefkl ( int num, u_char *string, struct video_state *svsp ); +void toggl_24l ( struct video_state *svsp ); void toggl_awm ( struct video_state *svsp ); void toggl_bell ( struct video_state *svsp ); void toggl_columns ( struct video_state *svsp ); @@ -1305,18 +992,36 @@ void toggl_dspf ( struct video_state *svsp ); void toggl_sevenbit ( struct video_state *svsp ); void update_hp ( struct video_state *svsp ); void update_led ( void ); + +#ifdef XSERVER +int usl_vt_ioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *); +#endif + void vga10_vga10 ( u_char *invga, u_char *outvga ); void vga10_vga14 ( u_char *invga, u_char *outvga ); void vga10_vga16 ( u_char *invga, u_char *outvga ); void vga10_vga8 ( u_char *invga, u_char *outvga ); +int vgaioctl ( dev_t dev, int cmd, caddr_t data, int flag ); + +#ifdef XSERVER +int vgapage ( int n ); +#else +void vgapage ( int n ); +#endif + +void vgapaletteio ( unsigned idx, struct rgb *val, int writeit ); +char *vga_string ( int number ); u_char vga_chipset ( void ); int vga_col ( struct video_state *svsp, int cols ); +void vga_move_charset ( unsigned n, unsigned char *b, int save_it); void vga_screen_off ( void ); void vga_screen_on ( void ); -char *vga_string ( int number ); int vga_test ( void ); -int vgaioctl ( Dev_t dev, int cmd, caddr_t data, int flag ); -void vgapaletteio ( unsigned idx, struct rgb *val, int writeit ); + +#ifdef XSERVER +int vt_activate ( int newscreen ); +#endif + void vt_aln ( struct video_state *svsp ); void vt_clearudk ( struct video_state *svsp ); void vt_clreol ( struct video_state *svsp ); @@ -1331,7 +1036,7 @@ void vt_curadr ( struct video_state *svsp ); void vt_cuu ( struct video_state *svsp ); void vt_da ( struct video_state *svsp ); void vt_dch ( struct video_state *svsp ); -void vt_dcsentry ( U_char ch, struct video_state *svsp ); +void vt_dcsentry ( int ch, struct video_state *svsp ); void vt_designate ( struct video_state *svsp); void vt_dl ( struct video_state *svsp ); void vt_dld ( struct video_state *svsp ); @@ -1364,18 +1069,18 @@ void vt_str ( struct video_state *svsp ); void vt_su ( struct video_state *svsp ); void vt_tst ( struct video_state *svsp ); void vt_udk ( struct video_state *svsp ); -void toggl_24l ( struct video_state *svsp ); -#ifdef PCVT_INCLUDE_VT_SELATTR +#ifdef PCVT_INCLUDE_VT_SELATTR +/*---------------------------------------------------------------------------* + * set selective attribute if appropriate + *---------------------------------------------------------------------------*/ #define INT_BITS (sizeof(unsigned int) * 8) #define INT_INDEX(n) ((n) / INT_BITS) #define BIT_INDEX(n) ((n) % INT_BITS) -/*---------------------------------------------------------------------------* - * set selective attribute if appropriate - *---------------------------------------------------------------------------*/ -static __inline void vt_selattr(struct video_state *svsp) +static __inline void +vt_selattr(struct video_state *svsp) { int i; @@ -1389,32 +1094,4 @@ static __inline void vt_selattr(struct video_state *svsp) #endif /* PCVT_INCLUDE_VT_SELATTR */ - -/*---------------------------------------------------------------------------* - * produce 7 us delay accessing the keyboard controller - *---------------------------------------------------------------------------*/ - -#if PCVT_PORTIO_DELAY - /* use multiple dummy accesses to port */ - /* 0x84 to produce keyboard controller */ - /* access delays */ -#define PCVT_KBD_DELAY() \ - { (void)inb(0x84); } \ - { (void)inb(0x84); } \ - { (void)inb(0x84); } \ - { (void)inb(0x84); } \ - { (void)inb(0x84); } \ - { (void)inb(0x84); } - -#else /* PCVT_PORTIO_DELAY */ - /* use system supplied delay function for */ - /* producing delays for accesssing the */ - /* keyboard controller */ -#if PCVT_NETBSD > 9 -#define PCVT_KBD_DELAY() delay(7) -#elif PCVT_FREEBSD || (PCVT_NETBSD <= 9) -#define PCVT_KBD_DELAY() DELAY(7) -#endif -#endif /* PCVT_PORTIO_DELAY */ - /*---------------------------------- E O F ----------------------------------*/ diff --git a/sys/i386/isa/pcvt/pcvt_kbd.c b/sys/i386/isa/pcvt/pcvt_kbd.c index 6155a11..c1441b4 100644 --- a/sys/i386/isa/pcvt/pcvt_kbd.c +++ b/sys/i386/isa/pcvt/pcvt_kbd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Hellmuth Michaelis + * Copyright (c) 1999, 2000 Hellmuth Michaelis * * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -45,7 +45,7 @@ * pcvt_kbd.c VT220 Driver Keyboard Interface Code * ---------------------------------------------------- * - * Last Edit-Date: [Mon Dec 27 14:01:50 1999] + * Last Edit-Date: [Sun Mar 26 10:54:07 2000] * * $FreeBSD$ * @@ -72,34 +72,51 @@ static void cfkey1(void), cfkey2(void), cfkey3(void), cfkey4(void); static void cfkey5(void), cfkey6(void), cfkey7(void), cfkey8(void); static void cfkey9(void), cfkey10(void), cfkey11(void), cfkey12(void); +#include <i386/isa/pcvt/pcvt_kbd.h> /* tables etc */ + static void doreset ( void ); static void ovlinit ( int force ); static void settpmrate ( int rate ); static void setlockkeys ( int snc ); -#ifndef _DEV_KBD_KBDREG_H_ -static int kbc_8042cmd ( int val ); -#endif /* !_DEV_KBD_KBDREG_H_ */ static int getokeydef ( unsigned key, struct kbd_ovlkey *thisdef ); static int getckeydef ( unsigned key, struct kbd_ovlkey *thisdef ); static int rmkeydef ( int key ); +static void scrollback_save_screen ( void ); +static void scrollback_restore_screen ( void ); static int setkeydef ( struct kbd_ovlkey *data ); -static u_char * xlatkey2ascii( U_short key ); +static u_char *xlatkey2ascii( int key ); static int ledstate = LEDSTATE_UPDATE_PENDING; /* keyboard led's */ static int tpmrate = KBD_TPD500|KBD_TPM100; static u_char altkpflag = 0; static u_short altkpval = 0; - -static u_short *scrollback_savedscreen = (u_short *)0; -static size_t scrnsv_size = (size_t)-1; -static void scrollback_save_screen ( void ); -static void scrollback_restore_screen ( void ); +static u_short *scrollback_savedscreen = (u_short *)0; +static size_t scrnsv_size = (size_t)-1; +static int lost_intr_timeout_queued = 0; +static struct callout_handle lost_intr_ch = + CALLOUT_HANDLE_INITIALIZER(&lost_intr_ch); #if PCVT_SHOWKEYS u_char rawkeybuf[80]; #endif -#include <i386/isa/pcvt/pcvt_kbd.h> /* tables etc */ +#if PCVT_USEKBDSEC /* security enabled */ + +# if PCVT_SCANSET == 2 +# define KBDINITCMD 0 +# else /* PCVT_SCANSET != 2 */ +# define KBDINITCMD KBD_TRANSLATION +# endif /* PCVT_SCANSET == 2 */ + +#else /* ! PCVT_USEKBDSEC */ /* security disabled */ + +# if PCVT_SCANSET == 2 +# define KBDINITCMD KBD_OVERRIDE_KBD_LOCK +# else /* PCVT_SCANSET != 2 */ +# define KBDINITCMD KBD_TRANSLATION | KBD_OVERRIDE_KBD_LOCK +# endif /* PCVT_SCANSET == 2 */ + +#endif /* PCVT_USEKBDSEC */ #if PCVT_SHOWKEYS /*---------------------------------------------------------------------------* @@ -146,64 +163,18 @@ do_vgapage(int page) vgapage(page); /* no, switch now */ } - -/* - * This code from Lon Willett enclosed in #if PCVT_UPDLED_LOSES_INTR is - * abled because it crashes FreeBSD 1.1.5.1 at boot time. - * The cause is obviously that the timeout queue is not yet initialized - * timeout is called from here the first time. - * Anyway it is a pointer in the right direction so it is included for - * reference here. - */ - -#define PCVT_UPDLED_LOSES_INTR 0 /* disabled for now */ - -#if PCVT_UPDLED_LOSES_INTR || defined(_DEV_KBD_KBDREG_H_) - /*---------------------------------------------------------------------------* * check for lost keyboard interrupts *---------------------------------------------------------------------------*/ - -/* - * The two commands to change the LEDs generate two KEYB_R_ACK responses - * from the keyboard, which aren't explicitly checked for (maybe they - * should be?). However, when a lot of other I/O is happening, one of - * the interrupts sometimes gets lost (I'm not sure of the details of - * how and why and what hardware this happens with). - * - * This may have had something to do with spltty() previously not being - * called before the kbd_cmd() calls in update_led(). - * - * This is a real problem, because normally the keyboard is only polled - * by pcrint(), and no more interrupts will be generated until the ACK - * has been read. So the keyboard is hung. This code polls a little - * while after changing the LEDs to make sure that this hasn't happened. - * - * XXX Quite possibly we should poll the kbd on a regular basis anyway, - * in the interest of robustness. It may be possible that interrupts - * get lost other times as well. - */ - -static int lost_intr_timeout_queued = 0; -static struct callout_handle lost_intr_ch = - CALLOUT_HANDLE_INITIALIZER(&lost_intr_ch); - static void -check_for_lost_intr (void *arg) +check_for_lost_intr(void *arg) { -#ifndef _DEV_KBD_KBDREG_H_ - lost_intr_timeout_queued = 0; - if (inb(CONTROLLER_CTRL) & STATUS_OUTPBF) - { - int opri = spltty (); - pcrint (); - splx (opri); - } -#else int opri; lost_intr_timeout_queued = 0; - if (kbd && (*kbdsw[kbd->kb_index]->lock)(kbd, TRUE)) { + + if (kbd && (*kbdsw[kbd->kb_index]->lock)(kbd, TRUE)) + { opri = spltty (); (*kbdsw[kbd->kb_index]->lock)(kbd, FALSE); if ((*kbdsw[kbd->kb_index]->check)(kbd)) @@ -213,11 +184,8 @@ check_for_lost_intr (void *arg) lost_intr_ch = timeout(check_for_lost_intr, (void *)NULL, hz); lost_intr_timeout_queued = 1; -#endif /* !_DEV_KBD_KBDREG_H_ */ } -#endif /* PCVT_UPDLED_LOSES_INTR || defined(_DEV_KBD_KBDREG_H_) */ - /*---------------------------------------------------------------------------* * update keyboard led's *---------------------------------------------------------------------------*/ @@ -231,95 +199,27 @@ update_led(void) int opri, new_ledstate; opri = spltty(); -#ifndef _DEV_KBD_KBDREG_H_ - new_ledstate = (vsp->scroll_lock) | - (vsp->num_lock * 2) | - (vsp->caps_lock * 4); -#else + new_ledstate = ((vsp->scroll_lock) ? LED_SCR : 0) | ((vsp->num_lock) ? LED_NUM : 0) | ((vsp->caps_lock) ? LED_CAP : 0); -#endif /* _DEV_KBD_KBDREG_H_ */ if (new_ledstate != ledstate) { -#ifndef _DEV_KBD_KBDREG_H_ - int response1, response2; - - ledstate = LEDSTATE_UPDATE_PENDING; - - if(kbd_cmd(KEYB_C_LEDS) != 0) + if (kbd == NULL) { - printf("Keyboard LED command timeout\n"); - splx(opri); - return; - } - - /* - * For some keyboards or keyboard controllers, it is an - * error to issue a command without waiting long enough - * for an ACK for the previous command. The keyboard - * gets confused, and responds with KEYB_R_RESEND, but - * we ignore that. Wait for the ACK here. The busy - * waiting doesn't matter much, since we lose anyway by - * busy waiting to send the command. - * - * XXX actually wait for any response, since we can't - * handle normal scancodes here. - * - * XXX all this should be interrupt driven. Issue only - * one command at a time wait for a ACK before proceeding. - * Retry after a timeout or on receipt of a KEYB_R_RESEND. - * KEYB_R_RESENDs seem to be guaranteed by working - * keyboard controllers with broken (or disconnected) - * keyboards. There is another code for keyboard - * reconnects. The keyboard hardware is very simple and - * well designed :-). - */ - response1 = kbd_response(); - - if(kbd_cmd(new_ledstate) != 0) { - printf("Keyboard LED data timeout\n"); + ledstate = new_ledstate; splx(opri); - return; } - response2 = kbd_response(); - - if (response1 == KEYB_R_ACK && response2 == KEYB_R_ACK) - ledstate = new_ledstate; else - printf( - "Keyboard LED command not ACKed (responses %#x %#x)\n", - response1, response2); -#else /* _DEV_KBD_KBDREG_H_ */ - - if (kbd == NULL) { - ledstate = new_ledstate; - splx(opri); - } else { + { ledstate = LEDSTATE_UPDATE_PENDING; splx(opri); if ((*kbdsw[kbd->kb_index]->ioctl)(kbd, KDSETLED, (caddr_t)&new_ledstate) == 0) ledstate = new_ledstate; } - -#endif /* !_DEV_KBD_KBDREG_H_ */ - -#if PCVT_UPDLED_LOSES_INTR - if (lost_intr_timeout_queued) - untimeout(check_for_lost_intr, NULL, lost_intr_ch); - - lost_intr_ch = timeout(check_for_lost_intr, NULL, hz); - lost_intr_timeout_queued = 1; -#endif /* PCVT_UPDLED_LOSES_INTR */ - } - -#ifndef _DEV_KBD_KBDREG_H_ - splx(opri); -#endif - #endif /* !PCVT_NO_LED_UPDATE */ } @@ -329,85 +229,13 @@ update_led(void) static void settpmrate(int rate) { -#ifndef _DEV_KBD_KBDREG_H_ - tpmrate = rate & 0x7f; - if(kbd_cmd(KEYB_C_TYPEM) != 0) - printf("Keyboard TYPEMATIC command timeout\n"); - else if(kbd_cmd(tpmrate) != 0) - printf("Keyboard TYPEMATIC data timeout\n"); -#else if (kbd == NULL) return; tpmrate = rate & 0x7f; if ((*kbdsw[kbd->kb_index]->ioctl)(kbd, KDSETRAD, (caddr_t)&tpmrate)) printf("pcvt: failed to set keyboard TYPEMATIC.\n"); -#endif /* !_DEV_KBD_KBDREG_H_ */ -} - -#ifndef _DEV_KBD_KBDREG_H_ -/*---------------------------------------------------------------------------* - * Pass command to keyboard controller (8042) - *---------------------------------------------------------------------------*/ -static int -kbc_8042cmd(int val) -{ - unsigned timeo; - - timeo = 100000; /* > 100 msec */ - while (inb(CONTROLLER_CTRL) & STATUS_INPBF) - if (--timeo == 0) - return (-1); - outb(CONTROLLER_CTRL, val); - return (0); -} - -/*---------------------------------------------------------------------------* - * Pass command to keyboard itself - *---------------------------------------------------------------------------*/ -int -kbd_cmd(int val) -{ - unsigned timeo; - - timeo = 100000; /* > 100 msec */ - while (inb(CONTROLLER_CTRL) & STATUS_INPBF) - if (--timeo == 0) - return (-1); - outb(CONTROLLER_DATA, val); - -#if PCVT_SHOWKEYS - showkey ('>', val); -#endif /* PCVT_SHOWKEYS */ - - return (0); } -/*---------------------------------------------------------------------------* - * Read response from keyboard - * NB: make sure to call spltty() before kbd_cmd(), kbd_response(). - *---------------------------------------------------------------------------*/ -int -kbd_response(void) -{ - u_char ch; - unsigned timeo; - - timeo = 500000; /* > 500 msec (KEYB_R_SELFOK requires 87) */ - while (!(inb(CONTROLLER_CTRL) & STATUS_OUTPBF)) - if (--timeo == 0) - return (-1); - - PCVT_KBD_DELAY(); /* 7 us delay */ - ch = inb(CONTROLLER_DATA); - -#if PCVT_SHOWKEYS - showkey ('<', ch); -#endif /* PCVT_SHOWKEYS */ - - return ch; -} -#endif /* _DEV_KBD_KBDREG_H_ */ - #if PCVT_SCANSET > 1 /*---------------------------------------------------------------------------* * switch PC scan code emulation mode @@ -415,265 +243,59 @@ kbd_response(void) void kbd_emulate_pc(int do_emulation) { -#ifndef _DEV_KBD_KBDREG_H_ - int cmd, timeo = 10000; - - cmd = COMMAND_SYSFLG|COMMAND_IRQEN; /* common base cmd */ - -#if !PCVT_USEKBDSEC - cmd |= COMMAND_INHOVR; -#endif - - if(do_emulation) - cmd |= COMMAND_PCSCAN; - - kbc_8042cmd(CONTR_WRITE); - while (inb(CONTROLLER_CTRL) & STATUS_INPBF) - if (--timeo == 0) - break; - outb(CONTROLLER_DATA, cmd); -#else set_controller_command_byte(*(KBDC *)kbd->kb_data, KBD_TRANSLATION, (do_emulation) ? KBD_TRANSLATION : 0); -#endif /* !_DEV_KBD_KBDREG_H_ */ } - #endif /* PCVT_SCANSET > 1 */ - -#ifndef PCVT_NONRESP_KEYB_TRY -#define PCVT_NONRESP_KEYB_TRY 25 /* no of times to try to detect */ -#endif /* a nonresponding keyboard */ - /*---------------------------------------------------------------------------* * try to force keyboard into a known state .. *---------------------------------------------------------------------------*/ static void doreset(void) { -#ifndef _DEV_KBD_KBDREG_H_ - int again = 0; - int once = 0; - int response, opri; - - /* Enable interrupts and keyboard, etc. */ - if (kbc_8042cmd(CONTR_WRITE) != 0) - printf("pcvt: doreset() - timeout controller write command\n"); - -#if PCVT_USEKBDSEC /* security enabled */ - -# if PCVT_SCANSET == 2 -# define KBDINITCMD COMMAND_SYSFLG|COMMAND_IRQEN -# else /* PCVT_SCANSET != 2 */ -# define KBDINITCMD COMMAND_PCSCAN|COMMAND_SYSFLG|COMMAND_IRQEN -# endif /* PCVT_SCANSET == 2 */ - -#else /* ! PCVT_USEKBDSEC */ /* security disabled */ - -# if PCVT_SCANSET == 2 -# define KBDINITCMD COMMAND_INHOVR|COMMAND_SYSFLG|COMMAND_IRQEN -# else /* PCVT_SCANSET != 2 */ -# define KBDINITCMD COMMAND_PCSCAN|COMMAND_INHOVR|COMMAND_SYSFLG\ - |COMMAND_IRQEN -# endif /* PCVT_SCANSET == 2 */ - -#endif /* PCVT_USEKBDSEC */ - - if (kbd_cmd(KBDINITCMD) != 0) - printf("pcvt: doreset() - timeout writing keyboard init command\n"); - - /* - * Discard any stale keyboard activity. The 0.1 boot code isn't - * very careful and sometimes leaves a KEYB_R_RESEND. Versions - * between 1992 and Oct 1996 didn't have the delay and sometimes - * left a KEYB_R_RESEND. - */ - while (1) { - if (inb(CONTROLLER_CTRL) & STATUS_OUTPBF) - kbd_response(); - else { - DELAY(10000); - if (!(inb(CONTROLLER_CTRL) & STATUS_OUTPBF)) - break; - } - } - - /* Start keyboard reset */ - - opri = spltty (); - - if (kbd_cmd(KEYB_C_RESET) != 0) - { - printf("pcvt: doreset() - timeout for keyboard reset command\n"); - outb(CONTROLLER_DATA, KEYB_C_RESET); /* force */ - } - - /* Wait for the first response to reset and handle retries */ - while ((response = kbd_response()) != KEYB_R_ACK) - { - if (response < 0) - { - if(!again) /* print message only once ! */ - printf("pcvt: doreset() - response != ack and response < 0 [one time only msg]\n"); - response = KEYB_R_RESEND; - } - else if (response == KEYB_R_RESEND) - { - if(!again) /* print message only once ! */ - printf("pcvt: doreset() - got KEYB_R_RESEND response ... [one time only msg]\n"); - } - if (response == KEYB_R_RESEND) - { - if(++again > PCVT_NONRESP_KEYB_TRY) - { - printf("pcvt: doreset() - Caution - no PC keyboard detected!\n"); - keyboard_type = KB_UNKNOWN; - splx(opri); - return; - } - - if((kbd_cmd(KEYB_C_RESET) != 0) && (once == 0)) - { - once++; /* print message only once ! */ - printf("pcvt: doreset() - timeout for loop keyboard reset command [one time only msg]\n"); - outb(CONTROLLER_DATA, KEYB_C_RESET); /* force */ - } - } - } - - /* Wait for the second response to reset */ - - while ((response = kbd_response()) != KEYB_R_SELFOK) - { - if (response < 0) - { - printf("pcvt: doreset() - response != OK and resonse < 0\n"); - /* - * If KEYB_R_SELFOK never arrives, the loop will - * finish here unless the keyboard babbles or - * STATUS_OUTPBF gets stuck. - */ - break; - } - } - - splx (opri); - -#if PCVT_KEYBDID - - opri = spltty (); - - if(kbd_cmd(KEYB_C_ID) != 0) - { - printf("pcvt: doreset() - timeout for keyboard ID command\n"); - keyboard_type = KB_UNKNOWN; - } - else - { - -r_entry: - - if((response = kbd_response()) == KEYB_R_MF2ID1) - { - if((response = kbd_response()) == KEYB_R_MF2ID2) - { - keyboard_type = KB_MFII; - } - else if(response == KEYB_R_MF2ID2HP) - { - keyboard_type = KB_MFII; - } - else - { - printf("\npcvt: doreset() - kbdid, response 2 = [%d]\n", - response); - keyboard_type = KB_UNKNOWN; - } - } - else if (response == KEYB_R_ACK) - { - goto r_entry; - } - else if (response == -1) - { - keyboard_type = KB_AT; - } - else - { - printf("\npcvt: doreset() - kbdid, response 1 = [%d]\n", response); - } - } - - splx (opri); - -#else /* PCVT_KEYBDID */ - - keyboard_type = KB_MFII; /* force it .. */ - -#endif /* PCVT_KEYBDID */ - -#else /* _DEV_KBD_KBDREG_H_ */ int type; if (!reset_keyboard) /* no, we are not ready to reset */ return; - if (lost_intr_timeout_queued) { + if (lost_intr_timeout_queued) + { untimeout(check_for_lost_intr, (void *)NULL, lost_intr_ch); lost_intr_timeout_queued = 0; } if (kbd == NULL) return; /* shouldn't happen */ + kbd_configure(0); ledstate = LEDSTATE_UPDATE_PENDING; -#if PCVT_USEKBDSEC /* security enabled */ - -# if PCVT_SCANSET == 2 -# define KBDINITCMD 0 -# else /* PCVT_SCANSET != 2 */ -# define KBDINITCMD KBD_TRANSLATION -# endif /* PCVT_SCANSET == 2 */ - -#else /* ! PCVT_USEKBDSEC */ /* security disabled */ - -# if PCVT_SCANSET == 2 -# define KBDINITCMD KBD_OVERRIDE_KBD_LOCK -# else /* PCVT_SCANSET != 2 */ -# define KBDINITCMD KBD_TRANSLATION | KBD_OVERRIDE_KBD_LOCK -# endif /* PCVT_SCANSET == 2 */ - -#endif /* PCVT_USEKBDSEC */ - set_controller_command_byte(*(KBDC *)kbd->kb_data, KBD_OVERRIDE_KBD_LOCK | KBD_TRANSLATION, KBDINITCMD); - keyboard_type = KB_MFII; /* force it .. */ -#if PCVT_KEYBDID type = KB_101; + (*kbdsw[kbd->kb_index]->ioctl)(kbd, KDGKBTYPE, (caddr_t)&type); + switch (type) { - case KB_84: - keyboard_type = KB_AT; - break; - case KB_101: - keyboard_type = KB_MFII; - break; - default: - keyboard_type = KB_UNKNOWN; - break; + case KB_84: + keyboard_type = KB_AT; + break; + case KB_101: + keyboard_type = KB_MFII; + break; + default: + keyboard_type = KB_UNKNOWN; + break; } -#endif /* PCVT_KEYBDID */ update_led(); lost_intr_ch = timeout(check_for_lost_intr, (void *)NULL, hz); lost_intr_timeout_queued = 1; - -#endif /* !_DEV_KBD_KBDREG_H_ */ } /*---------------------------------------------------------------------------* @@ -821,7 +443,7 @@ getckeydef(unsigned key, Ovl_tbl *thisdef) * if key is bound to a function, executes it, and ret empty ptr *---------------------------------------------------------------------------*/ static u_char * -xlatkey2ascii(U_short key) +xlatkey2ascii(int key) { static u_char capchar[2] = {0, 0}; #if PCVT_META_ESC @@ -1060,13 +682,6 @@ xlatkey2ascii(U_short key) * if noblock = 0, wait until a key is pressed. * else return NULL if no characters present. *---------------------------------------------------------------------------*/ - -#if PCVT_KBD_FIFO -extern u_char pcvt_kbd_fifo[]; -extern int pcvt_kbd_rptr; -extern short pcvt_kbd_count; -#endif - u_char * sgetc(int noblock) { @@ -1074,11 +689,16 @@ sgetc(int noblock) u_char dt = 0; u_char key = 0; u_short type; - -#if PCVT_KBD_FIFO && PCVT_SLOW_INTERRUPT + int c; + +#if PCVT_SLOW_INTERRUPT int s; #endif +#ifdef XSERVER + static char keybuf[2] = {0}; /* the second 0 is a delimiter! */ +#endif /* XSERVER */ + static u_char kbd_lastkey = 0; /* last keystroke */ static struct @@ -1091,17 +711,9 @@ sgetc(int noblock) u_char sysrq: 1; /* sysrq pressed */ } kbd_status = {0}; -#ifdef XSERVER - static char keybuf[2] = {0}; /* the second 0 is a delimiter! */ -#endif /* XSERVER */ - -#ifdef _DEV_KBD_KBDREG_H_ - int c; -#endif /* _DEV_KBD_KBDREG_H_ */ - loop: - if(noblock == 31337) + if(noblock == SCROLLBACK_COOKIE) { vsp->scrolling = 1; goto scroll_reset; @@ -1109,415 +721,68 @@ loop: #ifdef XSERVER -#ifndef _DEV_KBD_KBDREG_H_ - -#if PCVT_KBD_FIFO - - /* see if there is data from the keyboard available either from */ - /* the keyboard fifo or from the 8042 keyboard controller */ - - if (pcvt_kbd_count || (inb(CONTROLLER_CTRL) & STATUS_OUTPBF)) - { - if (!pcvt_kbd_count) /* source = 8042 */ - { - PCVT_KBD_DELAY(); /* 7 us delay */ - dt = inb(CONTROLLER_DATA); /* get from obuf */ - } - else /* source = keyboard fifo */ - { - dt = pcvt_kbd_fifo[pcvt_kbd_rptr++]; - PCVT_DISABLE_INTR(); - pcvt_kbd_count--; - PCVT_ENABLE_INTR(); - if (pcvt_kbd_rptr >= PCVT_KBD_FIFO_SZ) - pcvt_kbd_rptr = 0; - } - -#else /* !PCVT_KB_FIFO */ - - /* see if there is data from the keyboard available from the 8042 */ - - if (inb(CONTROLLER_CTRL) & STATUS_OUTPBF) + if (pcvt_kbd_count) { - PCVT_KBD_DELAY(); /* 7 us delay */ - dt = inb(CONTROLLER_DATA); /* yes, get data */ - -#endif /* !PCVT_KBD_FIFO */ - -#else /* _DEV_KBD_KBDREG_H_ */ - -#if PCVT_KBD_FIFO - if (pcvt_kbd_count) { dt = pcvt_kbd_fifo[pcvt_kbd_rptr++]; PCVT_DISABLE_INTR(); pcvt_kbd_count--; PCVT_ENABLE_INTR(); if (pcvt_kbd_rptr >= PCVT_KBD_FIFO_SZ) pcvt_kbd_rptr = 0; - } else -#endif /* PCVT_KBD_FIFO */ - if (!noblock) { + } + else if (!noblock) + { while ((c = (*kbdsw[kbd->kb_index]->read)(kbd, TRUE)) == -1) ; dt = c; - } else { + } + else + { if ((c = (*kbdsw[kbd->kb_index]->read)(kbd, FALSE)) == -1) return NULL; dt = c; } + /* + * If x mode is active, only care for locking keys, then + * return the scan code instead of any key translation. + * Additionally, this prevents us from any attempts to + * execute pcvt internal functions caused by keys (such + * as screen flipping). + */ + if (pcvt_kbd_raw) { + keybuf[0] = dt; -#endif /* !_DEV_KBD_KBDREG_H_ */ - - /* - * If x mode is active, only care for locking keys, then - * return the scan code instead of any key translation. - * Additionally, this prevents us from any attempts to - * execute pcvt internal functions caused by keys (such - * as screen flipping). - * XXX For now, only the default locking key definitions - * are recognized (i.e. if you have overloaded you "A" key - * as NUMLOCK, that wont effect X mode:-) - * Changing this would be nice, but would require modifi- - * cations to the X server. After having this, X will - * deal with the LEDs itself, so we are committed. - */ - /* - * Iff PCVT_USL_VT_COMPAT is defined, the behaviour has - * been fixed. We need not care about any keys here, since - * there are ioctls that deal with the lock key / LED stuff. - */ - if (pcvt_kbd_raw) - { - keybuf[0] = dt; - -#if PCVT_FREEBSD > 210 - add_keyboard_randomness(dt); -#endif /* PCVT_FREEBSD > 210 */ + add_keyboard_randomness(dt); -#if !PCVT_USL_VT_COMPAT - if ((dt & 0x80) == 0) - /* key make */ - switch(dt) - { - case 0x45: - /* XXX on which virt screen? */ vsp->num_lock ^= 1; - update_led(); - break; - - case 0x3a: - vsp->caps_lock ^= 1; - update_led(); - break; - - case 0x46: - vsp->scroll_lock ^= 1; - update_led(); - break; - } -#endif /* !PCVT_USL_VT_COMPAT */ - -#if PCVT_EMU_MOUSE - /* - * The (mouse systems) mouse emulator. The mouse - * device allocates the first device node that is - * not used by a virtual terminal. (E.g., you have - * eight vtys, /dev/ttyv0 thru /dev/ttyv7, so the - * mouse emulator were /dev/ttyv8.) - * Currently the emulator only works if the keyboard - * is in raw (PC scan code) mode. This is the typic- - * al case when running the X server. - * It is activated if the num locks LED is active - * for the current vty, and if the mouse device - * has been opened by at least one process. It - * grabs the numerical keypad events (but only - * the "non-extended", so the separate arrow keys - * continue to work), and three keys for the "mouse - * buttons", preferrably F1 thru F3. Any of the - * eight directions (N, NE, E, SE, S, SW, W, NW) - * is supported, and frequent key presses (less - * than e.g. half a second between key presses) - * cause the emulator to accelerate the pointer - * movement by 6, while single presses result in - * single moves, so each point can be reached. - */ - /* - * NB: the following code is spagghetti. - * Only eat it with lotta tomato ketchup and - * Parmesan cheese:-) - */ - /* - * look whether we will have to steal the keys - * and cook them into mouse events - */ - if(vsp->num_lock && mouse.opened) - { - int button, accel, i; - enum mouse_dir - { - MOUSE_NW, MOUSE_N, MOUSE_NE, - MOUSE_W, MOUSE_0, MOUSE_E, - MOUSE_SW, MOUSE_S, MOUSE_SE - } - move; - struct timeval now; - dev_t dummy = makedev(0, mouse.minor); - struct tty *mousetty = get_pccons(dummy); - /* - * strings to send for each mouse event, - * indexed by the movement direction and - * the "accelerator" value (TRUE for frequent - * key presses); note that the first byte - * of each string is actually overwritten - * by the current button value before sending - * the string - */ - static u_char mousestrings[2][MOUSE_SE+1][5] = - { - { - /* first, the non-accelerated strings*/ - {0x87, -1, 1, 0, 0}, /* NW */ - {0x87, 0, 1, 0, 0}, /* N */ - {0x87, 1, 1, 0, 0}, /* NE */ - {0x87, -1, 0, 0, 0}, /* W */ - {0x87, 0, 0, 0, 0}, /* 0 */ - {0x87, 1, 0, 0, 0}, /* E */ - {0x87, -1, -1, 0, 0}, /* SW */ - {0x87, 0, -1, 0, 0}, /* S */ - {0x87, 1, -1, 0, 0} /* SE */ - }, - { - /* now, 6 steps at once */ - {0x87, -4, 4, 0, 0}, /* NW */ - {0x87, 0, 6, 0, 0}, /* N */ - {0x87, 4, 4, 0, 0}, /* NE */ - {0x87, -6, 0, 0, 0}, /* W */ - {0x87, 0, 0, 0, 0}, /* 0 */ - {0x87, 6, 0, 0, 0}, /* E */ - {0x87, -4, -4, 0, 0}, /* SW */ - {0x87, 0, -6, 0, 0}, /* S */ - {0x87, 4, -4, 0, 0} /* SE */ - } - }; - - if(dt == 0xe0) - { - /* ignore extended scan codes */ - mouse.extendedseen = 1; - goto no_mouse_event; - } - if(mouse.extendedseen) - { - mouse.extendedseen = 0; - goto no_mouse_event; - } - mouse.extendedseen = 0; - - /* - * Note that we cannot use a switch here - * since we want to have the keycodes in - * a variable - */ - if((dt & 0x7f) == mousedef.leftbutton) { - button = 4; - goto do_button; - } - else if((dt & 0x7f) == mousedef.middlebutton) { - button = 2; - goto do_button; - } - else if((dt & 0x7f) == mousedef.rightbutton) { - button = 1; - do_button: - - /* - * i would really like to give - * some acustical support - * (pling/plong); i am not sure - * whether it is safe to call - * sysbeep from within an intr - * service, since it calls - * timeout in turn which mani- - * pulates the spl mask - jw - */ - -# define PLING sysbeep(PCVT_SYSBEEPF / 1500, 2) -# define PLONG sysbeep(PCVT_SYSBEEPF / 1200, 2) - - if(mousedef.stickybuttons) - { - if(dt & 0x80) { - mouse.breakseen = 1; - return (u_char *)0; - } - else if(mouse.buttons == button - && !mouse.breakseen) { - /* ignore repeats */ - return (u_char *)0; - } - else - mouse.breakseen = 0; - if(mouse.buttons == button) { - /* release it */ - mouse.buttons = 0; - PLONG; - } else { - /* - * eventually, release - * any other button, - * and stick this one - */ - mouse.buttons = button; - PLING; - } - } - else - { - if(dt & 0x80) { - mouse.buttons &= - ~button; - PLONG; - } - else if((mouse.buttons - & button) == 0) { - mouse.buttons |= - button; - PLING; - } - /*else: ignore same btn press*/ - } - move = MOUSE_0; - accel = 0; - } -# undef PLING -# undef PLONG - else switch(dt & 0x7f) - { - /* the arrow keys - KP 1 thru KP 9 */ - case 0x47: move = MOUSE_NW; goto do_move; - case 0x48: move = MOUSE_N; goto do_move; - case 0x49: move = MOUSE_NE; goto do_move; - case 0x4b: move = MOUSE_W; goto do_move; - case 0x4c: move = MOUSE_0; goto do_move; - case 0x4d: move = MOUSE_E; goto do_move; - case 0x4f: move = MOUSE_SW; goto do_move; - case 0x50: move = MOUSE_S; goto do_move; - case 0x51: move = MOUSE_SE; - do_move: - if(dt & 0x80) - /* - * arrow key break events are - * of no importance for us - */ - return (u_char *)0; - /* - * see whether the last move did - * happen "recently", i.e. before - * less than half a second - */ - getmicrotime(&now); - timevalsub(&now, &mouse.lastmove); - getmicrotime(&mouse.lastmove); - accel = (now.tv_sec == 0 - && now.tv_usec - < mousedef.acceltime); - break; - - default: /* not a mouse-emulating key */ - goto no_mouse_event; - } - mousestrings[accel][move][0] = - 0x80 + (~mouse.buttons & 7); - /* finally, send the string */ - for(i = 0; i < 5; i++) - (*linesw[mousetty->t_line].l_rint) - (mousestrings[accel][move][i], - mousetty); - return (u_char *)0; /* not a kbd event */ - } -no_mouse_event: - -#endif /* PCVT_EMU_MOUSE */ - - return ((u_char *)keybuf); - } + return ((u_char *)keybuf); } #else /* !XSERVER */ -#ifndef _DEV_KBD_KBDREG_H_ - -# if PCVT_KBD_FIFO - - /* see if there is data from the keyboard available either from */ - /* the keyboard fifo or from the 8042 keyboard controller */ - - if (pcvt_kbd_count || (inb(CONTROLLER_CTRL) & STATUS_OUTPBF)) - { - if (!noblock || kbd_polling) /* source = 8042 */ - { - PCVT_KBD_DELAY(); /* 7 us delay */ - dt = inb(CONTROLLER_DATA); - } - else /* source = keyboard fifo */ - { - dt = pcvt_kbd_fifo[pcvt_kbd_rptr++]; /* yes, get it ! */ - PCVT_DISABLE_INTR(); - pcvt_kbd_count--; - PCVT_ENABLE_INTR(); - if (pcvt_kbd_rptr >= PCVT_KBD_FIFO_SZ) - pcvt_kbd_rptr = 0; - } - } - -#else /* !PCVT_KBD_FIFO */ - - /* see if there is data from the keyboard available from the 8042 */ - - if(inb(CONTROLLER_CTRL) & STATUS_OUTPBF) + if (pcvt_kbd_count) { - PCVT_KBD_DELAY(); /* 7 us delay */ - dt = inb(CONTROLLER_DATA); /* yes, get data ! */ - } - -#endif /* !PCVT_KBD_FIFO */ - -#else /* _DEV_KBD_KBDREG_H_ */ - -#if PCVT_KBD_FIFO - if (pcvt_kbd_count) { dt = pcvt_kbd_fifo[pcvt_kbd_rptr++]; PCVT_DISABLE_INTR(); pcvt_kbd_count--; PCVT_ENABLE_INTR(); if (pcvt_kbd_rptr >= PCVT_KBD_FIFO_SZ) pcvt_kbd_rptr = 0; - } else -#endif /* PCVT_KBD_FIFO */ - if (!noblock) { + } + else if (!noblock) + { while ((c = (*kbdsw[kbd->kb_index]->read)(kbd, TRUE)) == -1) ; dt = c; - } else { - if ((c = (*kbdsw[kbd->kb_index]->read)(kbd, FALSE)) == -1) - return NULL; - dt = c; } - -#endif /* !_DEV_KBD_KBDREG_H_ */ - -#endif /* !XSERVER */ - -#ifndef _DEV_KBD_KBDREG_H_ else { - if(noblock) + if ((c = (*kbdsw[kbd->kb_index]->read)(kbd, FALSE)) == -1) return NULL; - else - goto loop; + dt = c; } -#endif /* !_DEV_KBD_KBDREG_H_ */ +#endif /* !XSERVER */ #if PCVT_SHOWKEYS showkey (' ', dt); @@ -1565,9 +830,7 @@ no_mouse_event: /* got a normal scan key */ regular: -#if PCVT_FREEBSD > 210 add_keyboard_randomness(dt); -#endif /* PCVT_FREEBSD > 210 */ #if PCVT_SCANSET == 1 kbd_status.breakseen = dt & 0x80 ? 1 : 0; @@ -1660,7 +923,7 @@ scroll_reset: } } - if (noblock == 31337) + if (noblock == SCROLLBACK_COOKIE) return NULL; if (key != 86) @@ -1685,11 +948,7 @@ scroll_reset: shutdown_nice(); #endif /* PCVT_CTRL_ALT_DEL */ -#if !(PCVT_NETBSD || PCVT_FREEBSD >= 200) -#include "ddb.h" -#endif /* !(PCVT_NETBSD || PCVT_FREEBSD >= 200) */ - -#if NDDB > 0 || defined(DDB) /* Check for cntl-alt-esc */ +#if defined(DDB) /* Check for cntl-alt-esc */ if((key == 110) && ctrl_down && (meta_down || altgr_down)) { @@ -1698,12 +957,10 @@ scroll_reset: if(!in_Debugger) { in_Debugger = 1; -#if PCVT_FREEBSD + /* the string is actually not used... */ Debugger("kbd"); -#else - Debugger(); -#endif + in_Debugger = 0; if(noblock) return NULL; @@ -1711,7 +968,7 @@ scroll_reset: goto loop; } } -#endif /* NDDB > 0 || defined(DDB) */ +#endif /* defined(DDB) */ /* look for keys with special handling */ if(key == 128) @@ -1945,7 +1202,7 @@ setkeydef(Ovl_tbl *data) * keyboard ioctl's entry *---------------------------------------------------------------------------*/ int -kbdioctl(Dev_t dev, int cmd, caddr_t data, int flag) +kbdioctl(dev_t dev, int cmd, caddr_t data, int flag) { int key; @@ -2019,33 +1276,7 @@ kbdioctl(Dev_t dev, int cmd, caddr_t data, int flag) return 0; } -#if PCVT_EMU_MOUSE -/*--------------------------------------------------------------------------* - * mouse emulator ioctl - *--------------------------------------------------------------------------*/ -int -mouse_ioctl(Dev_t dev, int cmd, caddr_t data) -{ - struct mousedefs *def = (struct mousedefs *)data; - - switch(cmd) - { - case KBDMOUSEGET: - *def = mousedef; - break; - - case KBDMOUSESET: - mousedef = *def; - break; - - default: - return -1; - } - return 0; -} -#endif /* PCVT_EMU_MOUSE */ - -#if PCVT_USL_VT_COMPAT +#ifdef XSERVER /*---------------------------------------------------------------------------* * convert ISO-8859 style keycode into IBM 437 *---------------------------------------------------------------------------*/ @@ -2139,8 +1370,7 @@ get_usl_keymap(keymap_t *map) } } } - -#endif /* PCVT_USL_VT_COMPAT */ +#endif /* XSERVER */ /*---------------------------------------------------------------------------* * switch keypad to numeric mode diff --git a/sys/i386/isa/pcvt/pcvt_kbd.h b/sys/i386/isa/pcvt/pcvt_kbd.h index 29a00df..932f85a 100644 --- a/sys/i386/isa/pcvt/pcvt_kbd.h +++ b/sys/i386/isa/pcvt/pcvt_kbd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Hellmuth Michaelis + * Copyright (c) 1999, 2000 Hellmuth Michaelis * * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -45,7 +45,7 @@ * pcvt_kbd.h VT220 Driver Keyboard Interface Header * ------------------------------------------------------ * - * Last Edit-Date: [Tue Dec 28 08:13:32 1999] + * Last Edit-Date: [Sun Mar 26 10:38:38 2000] * * $FreeBSD$ * @@ -58,9 +58,6 @@ typedef struct { u_char subtype; /* subtype, string or function */ -#ifdef PCVT_ALT_ENH - u_short str_leng; /* if string, stringlength */ -#endif union what { u_char *string; /* ptr to string, null terminated */ @@ -78,12 +75,6 @@ typedef struct entry unshift; /* normal default codes/funcs */ entry shift; /* shifted default codes/funcs */ entry ctrl; /* control default codes/funcs */ -#ifdef PCVT_ALT_ENH - entry alt; /* normal default codes/funcs */ - entry alt_shift; /* shifted default codes/funcs */ - entry alt_ctrl; /* control default codes/funcs */ - entry alt_ctrl_shift; /* normal default codes/funcs */ -#endif } Keycap_def; #define IDX0 0 /* default indexvalue into ovl table */ @@ -193,166 +184,6 @@ static u_char extscantokey[] = { static Keycap_def key2ascii[] = { - -#ifdef PCVT_ALT_ENH - -#define C (u_char *) -#define U (u_short) -#define V (void *) -#define S STR -#define F FNC -#define I IDX0 - -#define DFAULT {S, 0, C ""} - -/* DONT EVER OVERLOAD KEY 0, THIS IS A KEY THAT MUSTN'T EXIST */ - -/* type index unshift shift ctrl alt alt_shift alt_ctrl alt_ctrl_shift */ -/* -------------------------------------------------------------------------------------------------------------------------------------------------- */ -/* 0*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 1*/ KBD_ASCII, I, {S,1,C "`"}, {S,1,C "~"}, {S,1,C "`"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 2*/ KBD_ASCII, I, {S,1,C "1"}, {S,1,C "!"}, {S,1,C "1"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 3*/ KBD_ASCII, I, {S,1,C "2"}, {S,1,C "@"}, {S,1,C "\000"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 4*/ KBD_ASCII, I, {S,1,C "3"}, {S,1,C "#"}, {S,1,C "3"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 5*/ KBD_ASCII, I, {S,1,C "4"}, {S,1,C "$"}, {S,1,C "4"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 6*/ KBD_ASCII, I, {S,1,C "5"}, {S,1,C "%"}, {S,1,C "5"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 7*/ KBD_ASCII, I, {S,1,C "6"}, {S,1,C "^"}, {S,1,C "\036"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 8*/ KBD_ASCII, I, {S,1,C "7"}, {S,1,C "&"}, {S,1,C "7"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 9*/ KBD_ASCII, I, {S,1,C "8"}, {S,1,C "*"}, {S,1,C "9"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 10*/ KBD_ASCII, I, {S,1,C "9"}, {S,1,C "("}, {S,1,C "9"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 11*/ KBD_ASCII, I, {S,1,C "0"}, {S,1,C ")"}, {S,1,C "0"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 12*/ KBD_ASCII, I, {S,1,C "-"}, {S,1,C "_"}, {S,1,C "\037"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 13*/ KBD_ASCII, I, {S,1,C "="}, {S,1,C "+"}, {S,1,C "="}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 14*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 15*/ KBD_ASCII, I, {S,1,C "\177"}, {S,1,C "\010"}, {S,1,C "\177"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 16*/ KBD_ASCII, I, {S,1,C "\t"}, {S,1,C "\t"}, {S,1,C "\t"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 17*/ KBD_ASCII, I, {S,1,C "q"}, {S,1,C "Q"}, {S,1,C "\021"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 18*/ KBD_ASCII, I, {S,1,C "w"}, {S,1,C "W"}, {S,1,C "\027"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 19*/ KBD_ASCII, I, {S,1,C "e"}, {S,1,C "E"}, {S,1,C "\005"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 20*/ KBD_ASCII, I, {S,1,C "r"}, {S,1,C "R"}, {S,1,C "\022"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 21*/ KBD_ASCII, I, {S,1,C "t"}, {S,1,C "T"}, {S,1,C "\024"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 22*/ KBD_ASCII, I, {S,1,C "y"}, {S,1,C "Y"}, {S,1,C "\031"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 23*/ KBD_ASCII, I, {S,1,C "u"}, {S,1,C "U"}, {S,1,C "\025"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 24*/ KBD_ASCII, I, {S,1,C "i"}, {S,1,C "I"}, {S,1,C "\011"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 25*/ KBD_ASCII, I, {S,1,C "o"}, {S,1,C "O"}, {S,1,C "\017"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 26*/ KBD_ASCII, I, {S,1,C "p"}, {S,1,C "P"}, {S,1,C "\020"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 27*/ KBD_ASCII, I, {S,1,C "["}, {S,1,C "{"}, {S,1,C "\033"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 28*/ KBD_ASCII, I, {S,1,C "]"}, {S,1,C "}"}, {S,1,C "\035"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 29*/ KBD_ASCII, I, {S,1,C "\\"}, {S,1,C "|"}, {S,1,C "\034"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 30*/ KBD_CAPS, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 31*/ KBD_ASCII, I, {S,1,C "a"}, {S,1,C "A"}, {S,1,C "\001"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 32*/ KBD_ASCII, I, {S,1,C "s"}, {S,1,C "S"}, {S,1,C "\023"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 33*/ KBD_ASCII, I, {S,1,C "d"}, {S,1,C "D"}, {S,1,C "\004"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 34*/ KBD_ASCII, I, {S,1,C "f"}, {S,1,C "F"}, {S,1,C "\006"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 35*/ KBD_ASCII, I, {S,1,C "g"}, {S,1,C "G"}, {S,1,C "\007"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 36*/ KBD_ASCII, I, {S,1,C "h"}, {S,1,C "H"}, {S,1,C "\010"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 37*/ KBD_ASCII, I, {S,1,C "j"}, {S,1,C "J"}, {S,1,C "\n"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 38*/ KBD_ASCII, I, {S,1,C "k"}, {S,1,C "K"}, {S,1,C "\013"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 39*/ KBD_ASCII, I, {S,1,C "l"}, {S,1,C "L"}, {S,1,C "\014"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 40*/ KBD_ASCII, I, {S,1,C ";"}, {S,1,C ":"}, {S,1,C ";"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 41*/ KBD_ASCII, I, {S,1,C "'"}, {S,1,C "\""}, {S,1,C "'"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 42*/ KBD_ASCII, I, {S,1,C "\\"}, {S,1,C "|"}, {S,1,C "\034"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 43*/ KBD_RETURN,I, {S,1,C "\r"}, {S,1,C "\r"}, {S,1,C "\r"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 44*/ KBD_SHIFT, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 45*/ KBD_ASCII, I, {S,1,C "<"}, {S,1,C ">"}, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 46*/ KBD_ASCII, I, {S,1,C "z"}, {S,1,C "Z"}, {S,1,C "\032"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 47*/ KBD_ASCII, I, {S,1,C "x"}, {S,1,C "X"}, {S,1,C "\030"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 48*/ KBD_ASCII, I, {S,1,C "c"}, {S,1,C "C"}, {S,1,C "\003"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 49*/ KBD_ASCII, I, {S,1,C "v"}, {S,1,C "V"}, {S,1,C "\026"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 50*/ KBD_ASCII, I, {S,1,C "b"}, {S,1,C "B"}, {S,1,C "\002"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 51*/ KBD_ASCII, I, {S,1,C "n"}, {S,1,C "N"}, {S,1,C "\016"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 52*/ KBD_ASCII, I, {S,1,C "m"}, {S,1,C "M"}, {S,1,C "\r"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 53*/ KBD_ASCII, I, {S,1,C ","}, {S,1,C "<"}, {S,1,C ","}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 54*/ KBD_ASCII, I, {S,1,C "."}, {S,1,C ">"}, {S,1,C "."}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 55*/ KBD_ASCII, I, {S,1,C "/"}, {S,1,C "?"}, {S,1,C "/"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 56*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 57*/ KBD_SHIFT, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 58*/ KBD_CTL, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 59*/ KBD_ASCII, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 60*/ KBD_META, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -#if !PCVT_NULLCHARS -/* 61*/ KBD_ASCII, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -#else -/* 61*/ KBD_ASCII, I, DFAULT, DFAULT, {S,1,C "\000"}, DFAULT, DFAULT, DFAULT, DFAULT, -#endif /* PCVT_NULLCHARS */ -/* 62*/ KBD_META, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 63*/ KBD_ASCII, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 64*/ KBD_CTL, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 65*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 66*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 67*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 68*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 69*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 70*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 71*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 72*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 73*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 74*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 75*/ KBD_FUNC, I, {S,4,C "\033[2~"}, {S,4,C "\033[2~"}, {S,4,C "\033[2~"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 76*/ KBD_FUNC, I, {S,4,C "\033[3~"}, {S,4,C "\033[3~"}, {S,4,C "\033[3~"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 77*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 78*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 79*/ KBD_CURSOR,I, {S,4,C "\033[D"}, {S,4,C "\033OD"}, {S,4,C "\033[D"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 80*/ KBD_FUNC, I, {S,4,C "\033[1~"}, {S,4,C "\033[1~"}, {S,4,C "\033[1~"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 81*/ KBD_FUNC, I, {S,4,C "\033[4~"}, {S,4,C "\033[4~"}, {S,4,C "\033[4~"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 82*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 83*/ KBD_CURSOR,I, {S,4,C "\033[A"}, {S,4,C "\033OA"}, {S,4,C "\033[A"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 84*/ KBD_CURSOR,I, {S,4,C "\033[B"}, {S,4,C "\033OB"}, {S,4,C "\033[B"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 85*/ KBD_FUNC, I, {S,4,C "\033[5~"}, {S,4,C "\033[5~"}, {S,4,C "\033[5~"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 86*/ KBD_FUNC, I, {S,4,C "\033[6~"}, {S,4,C "\033[6~"}, {S,4,C "\033[6~"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 87*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 88*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 89*/ KBD_CURSOR,I, {S,3,C "\033[C"}, {S,3,C "\033OC"}, {S,3,C "\033[C"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 90*/ KBD_NUM, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 91*/ KBD_KP, I, {S,1,C "7"}, {S,2,C "\033Ow"}, {S,1,C "7"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 92*/ KBD_KP, I, {S,1,C "4"}, {S,2,C "\033Ot"}, {S,1,C "4"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 93*/ KBD_KP, I, {S,1,C "1"}, {S,2,C "\033Oq"}, {S,1,C "1"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 94*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/* 95*/ KBD_KP, I, {S,1,C "/"}, {S,1,C "/"}, {S,1,C "/"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 96*/ KBD_KP, I, {S,1,C "8"}, {S,2,C "\033Ox"}, {S,1,C "8"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 97*/ KBD_KP, I, {S,1,C "5"}, {S,2,C "\033Ou"}, {S,1,C "5"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 98*/ KBD_KP, I, {S,1,C "2"}, {S,2,C "\033Or"}, {S,1,C "2"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 99*/ KBD_KP, I, {S,1,C "0"}, {S,2,C "\033Op"}, {S,1,C "0"}, DFAULT, DFAULT, DFAULT, DFAULT, -/*100*/ KBD_KP, I, {S,1,C "*"}, {S,1,C "*"}, {S,1,C "*"}, DFAULT, DFAULT, DFAULT, DFAULT, -/*101*/ KBD_KP, I, {S,1,C "9"}, {S,2,C "\033Oy"}, {S,1,C "9"}, DFAULT, DFAULT, DFAULT, DFAULT, -/*102*/ KBD_KP, I, {S,1,C "6"}, {S,2,C "\033Ov"}, {S,1,C "6"}, DFAULT, DFAULT, DFAULT, DFAULT, -/*103*/ KBD_KP, I, {S,1,C "3"}, {S,2,C "\033Os"}, {S,1,C "3"}, DFAULT, DFAULT, DFAULT, DFAULT, -/*104*/ KBD_KP, I, {S,1,C "."}, {S,2,C "\033On"}, {S,1,C "."}, DFAULT, DFAULT, DFAULT, DFAULT, -/*105*/ KBD_KP, I, {S,1,C "-"}, {S,2,C "\033Om"}, {S,1,C "-"}, DFAULT, DFAULT, DFAULT, DFAULT, -/*106*/ KBD_KP, I, {S,1,C "+"}, {S,1,C "+"}, {S,1,C "+"}, DFAULT, DFAULT, DFAULT, DFAULT, -/*107*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/*108*/ KBD_RETURN,I, {S,1,C "\r"}, {S,2,C "\033OM"}, {S,1,C "\r"}, DFAULT, DFAULT, DFAULT, DFAULT, -/*109*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/*110*/ KBD_ASCII, I, {S,1,C "\033"}, {S,2,C "\033"}, {S,1,C "\033"}, DFAULT, DFAULT, DFAULT, DFAULT, -/*111*/ KBD_NONE, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/*112*/ KBD_FUNC, I, {F,0,V fkey1}, {F,0,V sfkey1}, {F,0,V cfkey1}, DFAULT, DFAULT, DFAULT, DFAULT, -/*113*/ KBD_FUNC, I, {F,0,V fkey2}, {F,0,V sfkey2}, {F,0,V cfkey2}, DFAULT, DFAULT, DFAULT, DFAULT, -/*114*/ KBD_FUNC, I, {F,0,V fkey3}, {F,0,V sfkey3}, {F,0,V cfkey3}, DFAULT, DFAULT, DFAULT, DFAULT, -/*115*/ KBD_FUNC, I, {F,0,V fkey4}, {F,0,V sfkey4}, {F,0,V cfkey4}, DFAULT, DFAULT, DFAULT, DFAULT, -/*116*/ KBD_FUNC, I, {F,0,V fkey5}, {F,0,V sfkey5}, {F,0,V cfkey5}, DFAULT, DFAULT, DFAULT, DFAULT, -/*117*/ KBD_FUNC, I, {F,0,V fkey6}, {F,0,V sfkey6}, {F,0,V cfkey6}, DFAULT, DFAULT, DFAULT, DFAULT, -/*118*/ KBD_FUNC, I, {F,0,V fkey7}, {F,0,V sfkey7}, {F,0,V cfkey7}, DFAULT, DFAULT, DFAULT, DFAULT, -/*119*/ KBD_FUNC, I, {F,0,V fkey8}, {F,0,V sfkey8}, {F,0,V cfkey8}, DFAULT, DFAULT, DFAULT, DFAULT, -/*120*/ KBD_FUNC, I, {F,0,V fkey9}, {F,0,V sfkey9}, {F,0,V cfkey9}, DFAULT, DFAULT, DFAULT, DFAULT, -/*121*/ KBD_FUNC, I, {F,0,V fkey10}, {F,0,V sfkey10}, {F,0,V cfkey10}, DFAULT, DFAULT, DFAULT, DFAULT, -/*122*/ KBD_FUNC, I, {F,0,V fkey11}, {F,0,V sfkey11}, {F,0,V cfkey11}, DFAULT, DFAULT, DFAULT, DFAULT, -/*123*/ KBD_FUNC, I, {F,0,V fkey12}, {F,0,V sfkey12}, {F,0,V cfkey12}, DFAULT, DFAULT, DFAULT, DFAULT, -/*124*/ KBD_KP, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/*125*/ KBD_SCROLL,I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/*126*/ KBD_BREAK, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, -/*127*/ KBD_FUNC, I, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, DFAULT, - -#undef C -#undef U -#undef V -#undef S -#undef F -#undef I -#undef DFLT -}; - -#else /* PCVT_ALT_ENH */ - /* define some shorthands to make the table (almost) fit into 80 columns */ #define C (u_char *) #define V (void *) @@ -504,13 +335,11 @@ static Keycap_def key2ascii[] = #undef I }; -#endif /* PCVT_ALT_ENH */ - static short keypad2num[] = { 7, 4, 1, -1, -1, 8, 5, 2, 0, -1, 9, 6, 3, -1, -1, -1, -1 }; -#if PCVT_USL_VT_COMPAT +#ifdef XSERVER #define N_KEYNUMS 128 @@ -563,5 +392,5 @@ static u_char iso2ibm437[] = 0x6f, 0x97, 0xa3, 0x96, 0x81, 0x98, 0, 0 }; -#endif /* PCVT_USL_VT_COMPAT */ +#endif /* XSERVER */ diff --git a/sys/i386/isa/pcvt/pcvt_out.c b/sys/i386/isa/pcvt/pcvt_out.c index 2c6d008..4090712 100644 --- a/sys/i386/isa/pcvt/pcvt_out.c +++ b/sys/i386/isa/pcvt/pcvt_out.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Hellmuth Michaelis + * Copyright (c) 1999, 2000 Hellmuth Michaelis * * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -42,7 +42,7 @@ * pcvt_out.c VT220 Terminal Emulator * --------------------------------------- * - * Last Edit-Date: [Mon Dec 27 14:07:39 1999] + * Last Edit-Date: [Sun Mar 26 10:43:40 2000] * * $FreeBSD$ * @@ -63,11 +63,10 @@ extern u_short csd_supplemental[]; static void write_char (struct video_state *svsp, int attrib, int ch); static void check_scroll ( struct video_state *svsp ); -static void hp_entry ( U_char ch, struct video_state *svsp ); +static void hp_entry ( int ch, struct video_state *svsp ); static void vt_coldinit ( void ); static void wrfkl ( int num, u_char *string, struct video_state *svsp ); static void writefkl ( int num, u_char *string, struct video_state *svsp ); - static int check_scrollback ( struct video_state *svsp ); /*---------------------------------------------------------------------------* @@ -133,7 +132,7 @@ u_short attrib, ch; /* XXX inefficient interface */ * emulator main entry *---------------------------------------------------------------------------*/ void -sput (u_char *s, U_char kernel, int len, int page) +sput (u_char *s, int kernel, int len, int page) { register struct video_state *svsp; u_short attrib; @@ -1196,13 +1195,13 @@ vt_coldinit(void) filllen); } -#if PCVT_USL_VT_COMPAT +#ifdef XSERVER svsp->smode.mode = VT_AUTO; svsp->smode.relsig = svsp->smode.acqsig = svsp->smode.frsig = 0; svsp->proc = 0; svsp->pid = svsp->vt_status = 0; -#endif /* PCVT_USL_VT_COMPAT */ +#endif /* XSERVER */ } @@ -1372,6 +1371,9 @@ check_scroll(struct video_state *svsp) } } +/*---------------------------------------------------------------------------* + * + *---------------------------------------------------------------------------*/ static int check_scrollback(struct video_state *svsp) { @@ -1583,11 +1585,8 @@ set_emulation_mode(struct video_state *svsp, int mode) svsp->scrr_end = svsp->scrr_len - 1; } -#if PCVT_SIGWINCH if (svsp->vs_tty && svsp->vs_tty->t_pgrp) pgsignal(svsp->vs_tty->t_pgrp, SIGWINCH, 1); -#endif /* PCVT_SIGWINCH */ - } /*---------------------------------------------------------------------------* @@ -1871,10 +1870,8 @@ vt_col(struct video_state *svsp, int cols) (cols == SCR_COL80)? 720: 1056; svsp->vs_tty->t_winsize.ws_ypixel = 400; -#if PCVT_SIGWINCH if(svsp->vs_tty->t_pgrp) pgsignal(svsp->vs_tty->t_pgrp, SIGWINCH, 1); -#endif /* PCVT_SIGWINCH */ } reallocate_scrollbuffer(svsp, svsp->scrollback_pages); @@ -1950,7 +1947,7 @@ clr_parms(struct video_state *svsp) *---------------------------------------------------------------------------*/ static void -hp_entry(U_char ch, struct video_state *svsp) +hp_entry(int ch, struct video_state *svsp) { switch(svsp->hp_state) { diff --git a/sys/i386/isa/pcvt/pcvt_sup.c b/sys/i386/isa/pcvt/pcvt_sup.c index 6917f7f..6dbd7b1 100644 --- a/sys/i386/isa/pcvt/pcvt_sup.c +++ b/sys/i386/isa/pcvt/pcvt_sup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Hellmuth Michaelis + * Copyright (c) 1999, 2000 Hellmuth Michaelis * * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -44,7 +44,7 @@ * pcvt_sup.c VT220 Driver Support Routines * --------------------------------------------- * - * Last Edit-Date: [Thu Dec 30 17:01:03 1999] + * Last Edit-Date: [Sun Mar 26 10:38:45 2000] * * $FreeBSD$ * @@ -61,13 +61,13 @@ static void vid_cursor ( struct cursorshape *data ); static void vgasetfontattr ( struct vgafontattr *data ); static void vgagetfontattr ( struct vgafontattr *data ); static void vgaloadchar ( struct vgaloadchar *data ); -static void vid_getscreen ( struct screeninfo *data, Dev_t dev ); -static void vid_setscreen ( struct screeninfo *data, Dev_t dev ); +static void vid_getscreen ( struct screeninfo *data, dev_t dev ); +static void vid_setscreen ( struct screeninfo *data, dev_t dev ); static void setchargen ( void ); static void setchargen3 ( void ); static void resetchargen ( void ); -static void vgareadpel ( struct vgapel *data, Dev_t dev ); -static void vgawritepel ( struct vgapel *data, Dev_t dev ); +static void vgareadpel ( struct vgapel *data, dev_t dev ); +static void vgawritepel ( struct vgapel *data, dev_t dev ); static void vgapcvtid ( struct pcvtid *data ); static void vgapcvtinfo ( struct pcvtinfo *data ); @@ -105,7 +105,7 @@ static u_short getrand ( void ); * execute vga ioctls *---------------------------------------------------------------------------*/ int -vgaioctl(Dev_t dev, int cmd, caddr_t data, int flag) +vgaioctl(dev_t dev, int cmd, caddr_t data, int flag) { if(minor(dev) >= PCVT_NSCREENS) return -1; @@ -117,15 +117,10 @@ vgaioctl(Dev_t dev, int cmd, caddr_t data, int flag) */ #ifdef XSERVER -#if PCVT_USL_VT_COMPAT #define is_dev_grafx vs[minor(dev)].vt_status & VT_GRAFX #define is_current_grafx vsp->vt_status & VT_GRAFX -#else /* old X interface */ -#define is_dev_grafx pcvt_xmode -#define is_current_grafx pcvt_xmode -#endif /* PCVT_USL_VT_COMPAT */ #else /* !XSERVER */ -#define is_dev_grafx 0 /* not applicable */ +#define is_dev_grafx 0 #define is_current_grafx 0 #endif /* XSERVER */ @@ -166,13 +161,6 @@ vgaioctl(Dev_t dev, int cmd, caddr_t data, int flag) break; case VGASETSCREEN: - -#if defined XSERVER && !PCVT_USL_VT_COMPAT - /* avoid screen switch if using old X mode */ - if(is_dev_grafx) - return EAGAIN; -#endif /* XSERVER && !PCVT_USL_VT_COMPAT */ - #if PCVT_SCREENSAVER pcvt_scrnsv_reset(); #endif /* PCVT_SCREENSAVER */ @@ -267,34 +255,16 @@ vgapcvtid(struct pcvtid *data) static void vgapcvtinfo(struct pcvtinfo *data) { -#if PCVT_NETBSD - data->opsys = CONF_NETBSD; - data->opsysrel = PCVT_NETBSD; -#elif PCVT_FREEBSD data->opsys = CONF_FREEBSD; - data->opsysrel = PCVT_FREEBSD; -#else - data->opsys = CONF_UNKNOWNOPSYS; - data->opsysrel = 0; -#endif + data->opsysrel = __FreeBSD__; data->nscreens = PCVT_NSCREENS; data->scanset = PCVT_SCANSET; data->updatefast= PCVT_UPDATEFAST; data->updateslow= PCVT_UPDATESLOW; data->sysbeepf = PCVT_SYSBEEPF; - -#if PCVT_NETBSD || PCVT_FREEBSD >= 200 data->pcburst = PCVT_PCBURST; -#else - data->pcburst = 1; -#endif - -#if PCVT_KBD_FIFO data->kbd_fifo_sz = PCVT_KBD_FIFO_SZ; -#else - data->kbd_fifo_sz = 0; -#endif data->compile_opts = (0 @@ -316,60 +286,27 @@ vgapcvtinfo(struct pcvtinfo *data) #if PCVT_24LINESDEF | CONF_24LINESDEF #endif -#if PCVT_EMU_MOUSE - | CONF_EMU_MOUSE -#endif #if PCVT_SHOWKEYS | CONF_SHOWKEYS #endif -#if PCVT_KEYBDID - | CONF_KEYBDID -#endif -#if PCVT_SIGWINCH - | CONF_SIGWINCH -#endif #if PCVT_NULLCHARS | CONF_NULLCHARS #endif -#if PCVT_BACKUP_FONTS - | CONF_BACKUP_FONTS -#endif -#if PCVT_SW0CNOUTP /* was FORCE8BIT */ - | CONF_SW0CNOUTP -#endif #if PCVT_SETCOLOR | CONF_SETCOLOR #endif #if PCVT_132GENERIC | CONF_132GENERIC #endif -#if PCVT_PALFLICKER - | CONF_PALFLICKER -#endif -#if PCVT_WAITRETRACE - | CONF_WAITRETRACE -#endif #ifdef XSERVER | CONF_XSERVER #endif -#if PCVT_USL_VT_COMPAT - | CONF_USL_VT_COMPAT -#endif -#if PCVT_PORTIO_DELAY - | CONF_PORTIO_DELAY -#endif #if PCVT_INHIBIT_NUMLOCK | CONF_INHIBIT_NUMLOCK #endif #if PCVT_META_ESC | CONF_META_ESC #endif -#if PCVT_KBD_FIFO - | CONF_KBD_FIFO -#endif -#if PCVT_NOFASTSCROLL - | CONF_NOFASTSCROLL -#endif #if PCVT_SLOW_INTERRUPT | CONF_SLOW_INTERRUPT #endif @@ -553,11 +490,11 @@ vgasetfontattr(struct vgafontattr *data) set_charset(&(vs[i]),vga_character_set); } -#if !PCVT_USL_VT_COMPAT - vgapage(current_video_screen); +#ifdef XSERVER + switch_screen(current_video_screen, 0, 0); #else - switch_screen(current_video_screen, 0, 0); -#endif /* !PCVT_USL_VT_COMPAT */ + vgapage(current_video_screen); +#endif /* XSERVER */ } @@ -618,7 +555,7 @@ vgaloadchar(struct vgaloadchar *data) * video ioctl - get screen information *---------------------------------------------------------------------------*/ static void -vid_getscreen(struct screeninfo *data, Dev_t dev) +vid_getscreen(struct screeninfo *data, dev_t dev) { int device = minor(dev); data->adaptor_type = adaptor_type; /* video adapter installed */ @@ -641,7 +578,7 @@ vid_getscreen(struct screeninfo *data, Dev_t dev) * video ioctl - set screen information *---------------------------------------------------------------------------*/ static void -vid_setscreen(struct screeninfo *data, Dev_t dev) +vid_setscreen(struct screeninfo *data, dev_t dev) { int screen; @@ -658,7 +595,7 @@ vid_setscreen(struct screeninfo *data, Dev_t dev) vgapage(screen); -#if defined XSERVER && PCVT_USL_VT_COMPAT +#ifdef XSERVER { int x = spltty(), waitfor = screen + 1; /* if the vt is yet to be released by a process, wait here */ @@ -670,7 +607,7 @@ vid_setscreen(struct screeninfo *data, Dev_t dev) /* make sure the switch really happened */ if(screen != current_video_screen) return; /* XXX should say "EAGAIN" here */ -#endif /* defined XSERVER && PCVT_USL_VT_COMPAT */ +#endif /* XSERVER */ if((data->screen_size != -1) || (data->force_24lines != -1)) { @@ -768,10 +705,8 @@ set_screen_size(struct video_state *svsp, int size) svsp->scrr_len = svsp->screen_rows; svsp->scrr_end = svsp->scrr_len - 1; -#if PCVT_SIGWINCH if (svsp->vs_tty && svsp->vs_tty->t_pgrp) pgsignal(svsp->vs_tty->t_pgrp, SIGWINCH, 1); -#endif /* PCVT_SIGWINCH */ reallocate_scrollbuffer(svsp, svsp->scrollback_pages); break; @@ -834,7 +769,7 @@ reallocate_scrollbuffer(struct video_state *svsp, int pages) * VGA ioctl - read DAC palette entry *---------------------------------------------------------------------------*/ static void -vgareadpel(struct vgapel *data, Dev_t dev) +vgareadpel(struct vgapel *data, dev_t dev) { register unsigned vpage = minor(dev); register unsigned idx = data->idx; @@ -852,7 +787,7 @@ vgareadpel(struct vgapel *data, Dev_t dev) * VGA ioctl - write DAC palette entry *---------------------------------------------------------------------------*/ static void -vgawritepel(struct vgapel *data, Dev_t dev) +vgawritepel(struct vgapel *data, dev_t dev) { register unsigned vpage = minor(dev); register unsigned idx = data->idx; @@ -876,60 +811,20 @@ vgawritepel(struct vgapel *data, Dev_t dev) void vgapaletteio(unsigned idx, struct rgb *val, int writeit) { - -#if PCVT_PALFLICKER - vga_screen_off(); -#endif /* PCVT_PALFLICKER */ - if(writeit) { outb(VGA_DAC + 2, idx); - -#if PCVT_WAITRETRACE - wait_retrace(); -#endif /* PCVT_WAITRETRACE */ - outb(VGA_DAC + 3, val->r & VGA_PMSK); - -#if PCVT_WAITRETRACE - wait_retrace(); -#endif /* PCVT_WAITRETRACE */ - outb(VGA_DAC + 3, val->g & VGA_PMSK); - -#if PCVT_WAITRETRACE - wait_retrace(); -#endif /* PCVT_WAITRETRACE */ - outb(VGA_DAC + 3, val->b & VGA_PMSK); } else /* read it */ { outb(VGA_DAC + 1, idx); - -#if PCVT_WAITRETRACE - wait_retrace(); -#endif /* PCVT_WAITRETRACE */ - val->r = inb(VGA_DAC + 3) & VGA_PMSK; - -#if PCVT_WAITRETRACE - wait_retrace(); -#endif /* PCVT_WAITRETRACE */ - val->g = inb(VGA_DAC + 3) & VGA_PMSK; - -#if PCVT_WAITRETRACE - wait_retrace(); -#endif /* PCVT_WAITRETRACE */ - val->b = inb(VGA_DAC + 3) & VGA_PMSK; } - -#if PCVT_PALFLICKER - vga_screen_on(); -#endif /* PCVT_PALFLICKER */ - } /*---------------------------------------------------------------------------* @@ -960,13 +855,7 @@ async_update(void *arg) /* first check if update is possible */ - if(chargen_access /* does no-one load characters? */ -#ifdef XSERVER /* is vt0 not in graphics mode? */ -#if !PCVT_USL_VT_COMPAT - || pcvt_xmode /* XXX necessary ????? */ -#endif /* PCVT_USL_VT_COMPAT */ -#endif /* XSERVER */ - ) + if(chargen_access) /* does no-one load characters? */ { goto async_update_exit; /* do not update anything */ } @@ -1033,13 +922,8 @@ async_update(void *arg) /* display load averages in last line (taken from tty.c) */ i = 18; -#ifdef NEW_AVERUNNABLE tmp = (averunnable.ldavg[0] * 100 + FSCALE / 2) >> FSHIFT; -#else - tmp = (averunnable[0] * 100 + FSCALE / 2) >> FSHIFT; -#endif - buffer[i++] = ((((tmp/100)/10) == 0) ? ' ' : @@ -1049,12 +933,8 @@ async_update(void *arg) buffer[i++] = ((tmp%100)/10) + '0'; buffer[i++] = ((tmp%100)%10) + '0'; i += 6; -#ifdef NEW_AVERUNNABLE tmp = (averunnable.ldavg[1] * 100 + FSCALE / 2) >> FSHIFT; -#else - tmp = (averunnable[1] * 100 + FSCALE / 2) >> FSHIFT; -#endif buffer[i++] = ((((tmp/100)/10) == 0) ? ' ' : ((tmp/100)/10) + '0'); @@ -1063,12 +943,8 @@ async_update(void *arg) buffer[i++] = ((tmp%100)/10) + '0'; buffer[i++] = ((tmp%100)%10) + '0'; i += 7; -#ifdef NEW_AVERUNNABLE tmp = (averunnable.ldavg[2] * 100 + FSCALE / 2) >> FSHIFT; -#else - tmp = (averunnable[2] * 100 + FSCALE / 2) >> FSHIFT; -#endif buffer[i++] = ((((tmp/100)/10) == 0) ? ' ' : ((tmp/100)/10) + '0'); @@ -1411,28 +1287,6 @@ resetchargen(void) chargen_access = 0; /* flag we are NOT accessing the chargen ram */ } -#if PCVT_WAITRETRACE -/*---------------------------------------------------------------------------* - * wait for being in a retrace time window - * NOTE: this is __VERY__ bad programming practice in this environment !! - *---------------------------------------------------------------------------*/ - -static void -wait_retrace(void) -{ - if(color) - { - while(!(inb(GN_INPSTAT1C) & 0x01)) - ; - } - else - { - while(!(inb(GN_INPSTAT1M) & 0x01)) - ; - } -} - -#endif /* PCVT_WAITRETRACE */ /*---------------------------------------------------------------------------* * switch screen off (VGA only) @@ -1524,11 +1378,7 @@ void loadchar(int fontset, int character, int char_scanlines, u_char *char_table) { unsigned char *d; - -#if PCVT_BACKUP_FONTS unsigned char *bak; -#endif /* PCVT_BACKUP_FONTS */ - int j, k; if((d = compute_charset_base(fontset)) == 0) @@ -1556,7 +1406,6 @@ loadchar(int fontset, int character, int char_scanlines, u_char *char_table) resetchargen(); /* access video ram */ -#if PCVT_BACKUP_FONTS if(saved_charsets[fontset] == 0) saved_charsets[fontset] = (u_char *)malloc(32 * 256, M_DEVBUF, M_WAITOK); @@ -1572,53 +1421,13 @@ loadchar(int fontset, int character, int char_scanlines, u_char *char_table) else panic("pcvt loadchar: no backup buffer"); #endif /* DIAGNOSTIC */ - -#endif /* PCVT_BACKUP_FONTS */ - } /*---------------------------------------------------------------------------* * save/restore character set n to addr b + * since there are always backed up copies, we do not save anything here + * parameter "b" is totally ignored *---------------------------------------------------------------------------*/ -#if !PCVT_BACKUP_FONTS - -void -vga_move_charset(unsigned n, unsigned char *b, int save_it) -{ - unsigned char *d = compute_charset_base(n); - -#ifdef DIAGNOSTIC - if(d == 0) - panic("vga_move_charset: wrong adaptor"); -#endif - - if(vsp->wd132col && (n == 1||n == 3||n == 5||n == 7)) - { - setchargen3(); - d -= 0x2000; - } - else - { - setchargen(); - } - - /* PLEASE, leave the following alone using bcopyb, as several */ - /* chipsets have problems if their memory is accessed with 32 */ - /* or 16 bits wide, don't change this to using bcopy for speed! */ - - if(save_it) - bcopyb(d, b, 256 /* chars */ * 32 /* bytes per char */); - else - bcopyb(b, d, 256 /* chars */ * 32 /* bytes per char */); - - resetchargen(); -} - -#else /* PCVT_BACKUP_FONTS */ - -/* since there are always backed up copies, we do not save anything here */ -/* parameter "b" is totally ignored */ - void vga_move_charset(unsigned n, unsigned char *b, int save_it) { @@ -1659,30 +1468,18 @@ vga_move_charset(unsigned n, unsigned char *b, int save_it) resetchargen(); } -#endif /* PCVT_BACKUP_FONTS */ - - -#if !PCVT_USL_VT_COMPAT +#ifndef XSERVER /*---------------------------------------------------------------------------* * switch to virtual screen n (0 ... PCVT_NSCREENS-1) *---------------------------------------------------------------------------*/ void vgapage(int n) { - -#if !PCVT_KBD_FIFO - int x; -#endif /* !PCVT_KBD_FIFO */ - int cols = vsp->maxcol; /* get current col val */ if(n < 0 || n >= totalscreens) return; -#if !PCVT_KBD_FIFO - x = spltty(); /* protect us */ -#endif /* !PCVT_KBD_FIFO */ - /* video board memory -> kernel memory */ bcopy(vsp->Crtat, vsp->Memory, vsp->screen_rows * vsp->maxcol * CHR); @@ -1693,13 +1490,7 @@ vgapage(int n) current_video_screen = n; /* current screen no */ -#if !PCVT_NETBSD && !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200) pcconsp = &pccons[n]; /* current tty */ -#elif PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200 - pcconsp = pccons[n]; /* current tty */ -#else - pcconsp = pc_tty[n]; /* current tty */ -#endif vsp = &vs[n]; /* current video state ptr */ @@ -1714,10 +1505,6 @@ vgapage(int n) outb(addr_6845, CRTC_STARTADRL); outb(addr_6845+1, 0); -#if !PCVT_KBD_FIFO - splx(x); -#endif /* !PCVT_KBD_FIFO */ - select_vga_charset(vsp->vga_charset); if(vsp->maxcol != cols) @@ -1754,12 +1541,11 @@ vgapage(int n) update_hp(vsp); /* update fkey labels, if present */ } -#endif /* !PCVT_USL_VT_COMPAT */ +#endif /* XSERVER */ /*---------------------------------------------------------------------------* * test if it is a vga *---------------------------------------------------------------------------*/ - int vga_test(void) { @@ -1918,27 +1704,6 @@ vga10_vga8(u_char *invga, u_char *outvga) } /*---------------------------------------------------------------------------* - * force a vga card to behave like an ega for debugging - *---------------------------------------------------------------------------*/ -#if FORCE_EGA -void -force_ega(void) -{ - unsigned char vgareg; - - if(adaptor_type == VGA_ADAPTOR) - { - adaptor_type = EGA_ADAPTOR; - totalfonts = 4; - vgareg = inb(GN_MISCOUTR); /* Miscellaneous Output Register */ - vgareg |= 128; /* Set 350 scanline mode */ - vgareg &= ~64; - outb(GN_MISCOUTW,vgareg); - } -} -#endif /* FORCE_EGA */ - -/*---------------------------------------------------------------------------* * disconnect attribute bit 3 from generating intensity * (and use it for a second character set !) *---------------------------------------------------------------------------*/ @@ -1965,9 +1730,6 @@ set_2ndcharset(void) static u_short getrand(void) { -#if !PCVT_FREEBSD - extern struct timeval time; /* time-of-day register */ -#endif static unsigned long seed = 1; register u_short res = (u_short)seed; seed = seed * 1103515245L + time_second; diff --git a/sys/i386/isa/pcvt/pcvt_tbl.h b/sys/i386/isa/pcvt/pcvt_tbl.h index 4efc841..54c9235 100644 --- a/sys/i386/isa/pcvt/pcvt_tbl.h +++ b/sys/i386/isa/pcvt/pcvt_tbl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1992, 1999 Hellmuth Michaelis. + * Copyright (c) 1992, 2000 Hellmuth Michaelis. * * All rights reserved. * @@ -29,7 +29,7 @@ * pcvt_tbl.h VT220 Driver Character Set Conversion Tables * ------------------------------------------------------------ * - * Last Edit-Date: [Mon Dec 27 14:12:37 1999] + * Last Edit-Date: [Sun Mar 26 10:38:49 2000] * * $FreeBSD$ * diff --git a/sys/i386/isa/pcvt/pcvt_vtf.c b/sys/i386/isa/pcvt/pcvt_vtf.c index 2923b14..c81736e 100644 --- a/sys/i386/isa/pcvt/pcvt_vtf.c +++ b/sys/i386/isa/pcvt/pcvt_vtf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Hellmuth Michaelis + * Copyright (c) 1999, 2000 Hellmuth Michaelis * * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -42,7 +42,7 @@ * pcvt_vtf.c VT220 Terminal Emulator Functions * ------------------------------------------------- * - * Last Edit-Date: [Mon Dec 27 14:13:33 1999] + * Last Edit-Date: [Sun Mar 26 10:38:52 2000] * * $FreeBSD$ * @@ -1428,7 +1428,7 @@ vt_mc(struct video_state *svsp) * *---------------------------------------------------------------------------*/ void -vt_dcsentry(U_char ch, struct video_state *svsp) +vt_dcsentry(int ch, struct video_state *svsp) { switch(svsp->dcs_state) { @@ -1928,9 +1928,6 @@ vt_sed(struct video_state *svsp) void roll_up(struct video_state *svsp, int n) { - -#if (PCVT_NOFASTSCROLL==0) - if(svsp->scrr_beg == 0 && /* if scroll region is whole screen */ svsp->scrr_len == svsp->screen_rows && (svsp != vsp || /* and either running in memory */ @@ -1938,13 +1935,11 @@ roll_up(struct video_state *svsp, int n) adaptor_type != MDA_ADAPTOR))) /* and not on MDA/Hercules */ { u_short *Memory = - -#if PCVT_USL_VT_COMPAT +#ifdef XSERVER (vsp != svsp || (vsp->vt_status & VT_GRAFX)) ? #else (vsp != svsp) ? #endif - svsp->Memory : Crtat; if(svsp->Crtat > (Memory + (svsp->screen_rows - n) * @@ -1959,13 +1954,11 @@ roll_up(struct video_state *svsp, int n) { svsp->Crtat += n * svsp->maxcol; } - -#if PCVT_USL_VT_COMPAT +#ifdef XSERVER if(vsp == svsp && !(vsp->vt_status & VT_GRAFX)) #else if(vsp == svsp) #endif - { outb(addr_6845, CRTC_STARTADRH); outb(addr_6845+1, (svsp->Crtat - Crtat) >> 8); @@ -1974,13 +1967,11 @@ roll_up(struct video_state *svsp, int n) } } else -#endif { bcopy( svsp->Crtat + ((svsp->scrr_beg + n) * svsp->maxcol), svsp->Crtat + (svsp->scrr_beg * svsp->maxcol), svsp->maxcol * (svsp->scrr_len - n) * CHR ); } - fillw( user_attr | ' ', svsp->Crtat + ((svsp->scrr_end - n + 1) * svsp->maxcol), n * svsp->maxcol); @@ -1995,9 +1986,6 @@ roll_up(struct video_state *svsp, int n) static void roll_down(struct video_state *svsp, int n) { - -#if (PCVT_NOFASTSCROLL==0) - if(svsp->scrr_beg == 0 && /* if scroll region is whole screen */ svsp->scrr_len == svsp->screen_rows && (svsp != vsp || /* and either running in memory */ @@ -2005,8 +1993,7 @@ roll_down(struct video_state *svsp, int n) adaptor_type != MDA_ADAPTOR))) /* and not on MDA/Hercules */ { u_short *Memory = - -#if PCVT_USL_VT_COMPAT +#ifdef XSERVER (vsp != svsp || (vsp->vt_status & VT_GRAFX)) ? #else (vsp != svsp) ? @@ -2025,13 +2012,11 @@ roll_down(struct video_state *svsp, int n) { svsp->Crtat -= n * svsp->maxcol; } - -#if PCVT_USL_VT_COMPAT +#ifdef XSERVER if(vsp == svsp && !(vsp->vt_status & VT_GRAFX)) #else if(vsp == svsp) #endif - { outb(addr_6845, CRTC_STARTADRH); outb(addr_6845+1, (svsp->Crtat - Crtat) >> 8); @@ -2040,13 +2025,11 @@ roll_down(struct video_state *svsp, int n) } } else -#endif { bcopy( svsp->Crtat + (svsp->scrr_beg * svsp->maxcol), svsp->Crtat + ((svsp->scrr_beg + n) * svsp->maxcol), svsp->maxcol * (svsp->scrr_len - n) * CHR ); } - fillw( user_attr | ' ', svsp->Crtat + (svsp->scrr_beg * svsp->maxcol), n * svsp->maxcol); |