File:  [DragonFly] / src / sys / dev / video / pcvt / i386 / Attic / pcvt_hdr.h
Revision 1.4: download - view: text, annotated - select for diffs
Fri Feb 13 01:45:15 2004 UTC (10 years, 9 months ago) by joerg
Branches: MAIN
CVS tags: HEAD
Add __DragonFly__

    1: /*
    2:  * Copyright (c) 1999 Hellmuth Michaelis
    3:  *
    4:  * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch.
    5:  *
    6:  * Copyright (c) 1992, 1993 Brian Dunford-Shore.
    7:  *
    8:  * All rights reserved.
    9:  *
   10:  * Redistribution and use in source and binary forms, with or without
   11:  * modification, are permitted provided that the following conditions
   12:  * are met:
   13:  * 1. Redistributions of source code must retain the above copyright
   14:  *    notice, this list of conditions and the following disclaimer.
   15:  * 2. Redistributions in binary form must reproduce the above copyright
   16:  *    notice, this list of conditions and the following disclaimer in the
   17:  *    documentation and/or other materials provided with the distribution.
   18:  * 3. All advertising materials mentioning features or use of this software
   19:  *    must display the following acknowledgement:
   20:  *	This product includes software developed by
   21:  *	Hellmuth Michaelis, Brian Dunford-Shore and Joerg Wunsch.
   22:  * 4. The name authors may not be used to endorse or promote products
   23:  *    derived from this software without specific prior written permission.
   24:  *
   25:  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
   26:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   27:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   28:  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   29:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   30:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   31:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   32:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   33:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   34:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   35:  */
   36: 
   37: /*---------------------------------------------------------------------------
   38:  *
   39:  *	pcvt_hdr.h	VT220 Driver Global Include File
   40:  *	------------------------------------------------
   41:  *
   42:  *	Last Edit-Date: [Mon Dec 27 14:06:31 1999]
   43:  *
   44:  * $FreeBSD: src/sys/i386/isa/pcvt/pcvt_hdr.h,v 1.36.2.3 2001/08/06 15:30:21 joerg Exp $
   45:  * $DragonFly: src/sys/dev/video/pcvt/i386/pcvt_hdr.h,v 1.4 2004/02/13 01:45:15 joerg Exp $
   46:  *
   47:  *---------------------------------------------------------------------------*/
   48: 
   49: #define	PCVT_REL "3.20-b24"	/* driver attach announcement	*/
   50: 				/* see also: pcvt_ioctl.h	*/
   51: 
   52: #include "opt_pcvt.h"
   53: #if (defined(__DragonFly__) || defined(__FreeBSD__)) && !defined(PCVT_FREEBSD)
   54: #  define PCVT_FREEBSD 210
   55: #endif
   56: 
   57: #if PCVT_FREEBSD >= 200
   58: 
   59: #include <sys/param.h>
   60: #include <sys/systm.h>
   61: #include <sys/conf.h>
   62: #include <sys/proc.h>
   63: #include <sys/signalvar.h>
   64: #include <sys/tty.h>
   65: #include <sys/uio.h>
   66: #include <sys/callout.h>
   67: #include <sys/kernel.h>
   68: #include <sys/syslog.h>
   69: #include <sys/malloc.h>
   70: #include <sys/time.h>
   71: /*
   72:  * XXX sys/kbio.h declares a lot of junk, but we need it for NUM_KEYS which
   73:  * is used in dev/kbd/kbdreg.h.
   74:  */
   75: #include <sys/kbio.h>
   76: #undef KB_OTHER
   77: #undef S
   78: #undef F
   79: 
   80: #if PCVT_FREEBSD > 210
   81: #include <sys/random.h>
   82: #endif	/* PCVT_FREEBSD > 210 */
   83: #else /* ! PCVT_FREEBSD >= 200 */
   84: 
   85: #include "param.h"
   86: #include "conf.h"
   87: #include "ioctl.h"
   88: #include "proc.h"
   89: #include "signalvar.h"
   90: #include "tty.h"
   91: #include "uio.h"
   92: #include "callout.h"
   93: #include "systm.h"
   94: #include "kernel.h"
   95: #include "syslog.h"
   96: #include "malloc.h"
   97: #include "time.h"
   98: 
   99: #endif /* PCVT_FREEBSD >= 200 */
  100: 
  101: #include "pcvt_conf.h"
  102: 
  103: #include <machine/bus.h>
  104: 
  105: #include <dev/misc/kbd/kbdreg.h>
  106: #include <dev/misc/kbd/atkbdcreg.h>
  107: 
  108: #if PCVT_NETBSD > 9
  109: #include "device.h"
  110: #endif
  111: 
  112: #if PCVT_NETBSD > 9
  113: #include "i386/isa/isavar.h"
  114: #include "i386/cpufunc.h"
  115: #elif PCVT_FREEBSD >= 200
  116: #include <bus/isa/i386/isa_device.h>
  117: #else
  118: #include "i386/isa/isa_device.h"
  119: #endif
  120: 
  121: #if PCVT_FREEBSD >= 200
  122: #include <i386/isa/icu.h>
  123: #else
  124: #include "i386/isa/icu.h"
  125: #endif
  126: 
  127: #if PCVT_NETBSD > 100
  128: #include "i386/isa/isareg.h"
  129: #elif PCVT_FREEBSD >= 200
  130: #include <bus/isa/i386/isa.h>
  131: #else
  132: #include "i386/isa/isa.h"
  133: #endif
  134: 
  135: #if PCVT_NETBSD > 9
  136: #include "dev/cons.h"
  137: #elif PCVT_FREEBSD >= 200
  138: #include <sys/cons.h>
  139: #else
  140: #include "i386/i386/cons.h"
  141: #endif
  142: 
  143: #if PCVT_NETBSD <= 9
  144: #if PCVT_FREEBSD >= 200
  145: #include <machine/psl.h>
  146: #include <machine/frame.h>
  147: #else /* ! PCVT_FREEBSD >= 200 */
  148: #include "machine/psl.h"
  149: #include "machine/frame.h"
  150: #endif /* PCVT_FREEBSD >= 200 */
  151: #endif /* PCVT_NETBSD <= 9 */
  152: 
  153: #if PCVT_NETBSD > 9
  154: #include <i386/isa/pcvt/pcvt_ioctl.h>
  155: #elif PCVT_FREEBSD >= 200
  156: #include <machine/pcvt_ioctl.h>
  157: #else
  158: #include "machine/pcvt_ioctl.h"
  159: #endif
  160: 
  161: #if PCVT_FREEBSD >= 200
  162: #include <machine/pc/display.h>
  163: #if PCVT_FREEBSD > 200
  164: #include <machine/clock.h>
  165: #include <machine/md_var.h>
  166: #endif
  167: /*
  168:  * The following values are defined in machine/console.h, but the header
  169:  * file is not included here due to conflicts with pcvt_ioctl.h.
  170:  */
  171: #define KDGKBTYPE	_IOR('K', 64, int)
  172: #define KB_84		1
  173: #define KB_101		2
  174: #define KB_OTHER	3
  175: #else /* PCVT_FREEBSD >= 200 */
  176: #include "machine/pc/display.h"
  177: #endif /* PCVT_FREEBSD >= 200 */
  178: 
  179: /* setup irq disable function to use */
  180: 
  181: #if !(PCVT_SLOW_INTERRUPT) && (PCVT_NETBSD > 9)
  182: # define PCVT_DISABLE_INTR()	disable_intr()
  183: # define PCVT_ENABLE_INTR()	enable_intr()
  184: # undef PCVT_SLOW_INTERRUPT
  185: #else
  186: # define PCVT_DISABLE_INTR()	s = spltty()
  187: # define PCVT_ENABLE_INTR()	splx(s)
  188: # undef PCVT_SLOW_INTERRUPT
  189: # define PCVT_SLOW_INTERRUPT 1
  190: #endif
  191: 
  192: /* perform option consistency checks */
  193: 
  194: #if defined PCVT_FREEBSD && PCVT_FREEBSD == 1
  195: # undef PCVT_FREEBSD
  196: # define PCVT_FREEBSD 102	/* assume 1.0 release */
  197: #endif
  198: 
  199: #if defined PCVT_NETBSD && PCVT_NETBSD == 1
  200: #undef PCVT_NETBSD
  201: #define PCVT_NETBSD 9		/* assume 0.9 release for now */
  202: #endif
  203: 
  204: #if PCVT_FREEBSD + PCVT_NETBSD == 0
  205: # error "pcvt_hdr.h: You MUST define one of PCVT_{NET,FREE}BSD \
  206: in the config file"
  207: #elif (PCVT_FREEBSD && PCVT_NETBSD)
  208: # error "pcvt_hdr.h: You CAN only define *one* of PCVT_{NET,FREE}BSD \
  209: in the config file"
  210: #endif
  211: 
  212: #ifdef XSERVER
  213: 
  214: /* PCVT_NULLCHARS is mandatory for X server */
  215: #if !PCVT_NULLCHARS
  216: #undef PCVT_NULLCHARS
  217: #define PCVT_NULLCHARS 1
  218: #endif
  219: 
  220: /* PCVT_BACKUP_FONTS is mandatory for PCVT_USL_VT_COMPAT */
  221: #if PCVT_USL_VT_COMPAT && !PCVT_BACKUP_FONTS
  222: #undef PCVT_BACKUP_FONTS
  223: #define PCVT_BACKUP_FONTS 1
  224: #endif
  225: 
  226: #else /* XSERVER */
  227: 
  228: #if PCVT_USL_VT_COMPAT
  229: #warning "Option PCVT_USL_VT_COMPAT meaningless without XSERVER"
  230: #undef PCVT_USL_VT_COMPAT
  231: #define PCVT_USL_VT_COMPAT 0
  232: #endif
  233: 
  234: #endif /* XSERVER */
  235: 
  236: /* PCVT_SCREENSAVER is mandatory for PCVT_PRETTYSCRNS */
  237: #if PCVT_PRETTYSCRNS && !PCVT_SCREENSAVER
  238: #undef PCVT_SCREENSAVER
  239: #define PCVT_SCREENSAVER 1
  240: #endif
  241: 
  242: /* get the inline inb/outb back again ... */
  243: 
  244: #if PCVT_NETBSD
  245: #if PCVT_NETBSD == 9
  246: #include "machine/cpufunc.h"	/* NetBSD 0.9 [...and earlier -currents] */
  247: #undef PCVT_USL_VT_COMPAT
  248: #define PCVT_USL_VT_COMPAT 0	/* does not work, workaround ... */
  249: #else
  250: #include "machine/pio.h"	/* recent NetBSD -currents */
  251: #define NEW_AVERUNNABLE		/* averunnable changes for younger currents */
  252: #endif /* PCVT_NETBSD == 9 */
  253: #endif /* PCVT_NETBSD */
  254: 
  255: #if PCVT_FREEBSD >= 200
  256: #define NEW_AVERUNNABLE		/* new averunnable changes for FreeBSD 2.0 */
  257: #endif
  258: 
  259: #if PCVT_SCANSET !=1 && PCVT_SCANSET !=2
  260: #error "Supported keyboard scancode sets are 1 and 2 only (for now)!!!"
  261: #endif
  262: 
  263: /* initial default scrollback buffer size (in pages) */
  264: #define SCROLLBACK_PAGES       8
  265: 
  266: /*---------------------------------------------------------------------------*
  267:  *	Keyboard and Keyboard Controller
  268:  *---------------------------------------------------------------------------*/
  269: 
  270: #ifndef _DEV_KBD_KBDREG_H_
  271: 
  272: #define CONTROLLER_CTRL	0x64	/* W - command, R - status	*/
  273: #define CONTROLLER_DATA	0x60	/* R/W - data			*/
  274: 
  275: /* commands to control the CONTROLLER (8042) on the mainboard */
  276: 
  277: #define CONTR_READ	0x20	/* read command byte from controller */
  278: #define CONTR_WRITE	0x60	/* write command to controller, see below */
  279: #define CONTR_SELFTEST	0xaa	/* controller selftest, returns 0x55 when ok */
  280: #define CONTR_IFTEST	0xab	/* interface selftest */
  281: #define CONTR_KBDISABL	0xad	/* disable keyboard */
  282: #define CONTR_KBENABL	0xae	/* enable keyboard */
  283: 
  284: /* command byte for writing to CONTROLLER (8042) via CONTR_WRITE */
  285: 
  286: #define	 COMMAND_RES7	0x80	/* bit 7, reserved, always write a ZERO ! */
  287: #define	 COMMAND_PCSCAN	0x40	/* bit 6, 1 = convert to pc scan codes */
  288: #define	 COMMAND_RES5	0x20	/* bit 5, perhaps (!) use 9bit frame
  289: 				 * instead of 11 */
  290: #define	 COMMAND_DISABL	0x10	/* bit 4, 1 = disable keyboard */
  291: #define	 COMMAND_INHOVR	0x08	/* bit 3, 1 = override security lock inhibit */
  292: #define	 COMMAND_SYSFLG	0x04	/* bit 2, value stored as "system flag" */
  293: #define	 COMMAND_RES2	0x02	/* bit 1, reserved, always write a ZERO ! */
  294: #define	 COMMAND_IRQEN	0x01	/* bit 0, 1 = enable output buffer full
  295: 				 * interrupt */
  296: 
  297: /* status from CONTROLLER (8042) on the mainboard */
  298: 
  299: #define	STATUS_PARITY	0x80	/* bit 7, 1 = parity error on last byte */
  300: #define STATUS_RXTIMO	0x40	/* bit 6, 1 = receive timeout error occured */
  301: #define STATUS_TXTIMO	0x20	/* bit 5, 1 = transmit timeout error occured */
  302: #define STATUS_ENABLE	0x10	/* bit 4, 1 = keyboard unlocked */
  303: #define STATUS_WHAT	0x08	/* bit 3, 1 = wrote cmd to 0x64, 0 = wrote
  304: 				 * data to 0x60 */
  305: #define STATUS_SYSFLG	0x04	/* bit 2, value stored as "system flag" */
  306: #define STATUS_INPBF	0x02	/* bit 1, 1 = input buffer full (to 8042) */
  307: #define STATUS_OUTPBF	0x01	/* bit 0, 1 = output buffer full (from 8042) */
  308: 
  309: /* commands to the KEYBOARD (via the 8042 controller on mainboard..) */
  310: 
  311: #define KEYB_C_RESET	0xff	/* reset keyboard to power-on status */
  312: #define	KEYB_C_RESEND	0xfe	/* resend last byte in case of error */
  313: #define KEYB_C_TYPEM	0xf3	/* set keyboard typematic rate/delay */
  314: #define KEYB_C_ID	0xf2	/* return keyboard id */
  315: #define KEYB_C_ECHO	0xee	/* diagnostic, echo 0xee */
  316: #define KEYB_C_LEDS	0xed	/* set/reset numlock,capslock & scroll lock */
  317: 
  318: #endif /* _DEV_KBD_KBDREG_H_ */
  319: 
  320: /* responses from the KEYBOARD (via the 8042 controller on mainboard..) */
  321: 
  322: #define	KEYB_R_OVERRUN0	0x00	/* keyboard buffer overflow */
  323: #define KEYB_R_SELFOK	0xaa	/* keyboard selftest ok after KEYB_C_RESET */
  324: #define KEYB_R_EXT0	0xe0	/* keyboard extended scancode prefix 1 */
  325: #define KEYB_R_EXT1	0xe1	/* keyboard extended scancode prefix 2 */
  326: #define KEYB_R_ECHO	0xee	/* keyboard response to KEYB_C_ECHO */
  327: #define KEYB_R_BREAKPFX	0xf0	/* break code prefix for set 2 and 3 */
  328: #define KEYB_R_ACK	0xfa	/* acknowledge after a command has rx'd */
  329: #define KEYB_R_SELFBAD	0xfc	/*keyboard selftest FAILED after KEYB_C_RESET*/
  330: #define KEYB_R_DIAGBAD	0xfd	/* keyboard self diagnostic failure */
  331: #define KEYB_R_RESEND	0xfe	/* keyboard wants command resent or illegal
  332: 				 * command rx'd */
  333: #define	KEYB_R_OVERRUN1	0xff	/* keyboard buffer overflow */
  334: 
  335: #define KEYB_R_MF2ID1	0xab	/* MF II Keyboard id-byte #1 */
  336: #define KEYB_R_MF2ID2	0x41	/* MF II Keyboard id-byte #2 */
  337: #define KEYB_R_MF2ID2HP	0x83	/* MF II Keyboard id-byte #2 from HP keybd's */
  338: 
  339: /* internal Keyboard Type */
  340: 
  341: #define KB_UNKNOWN	0	/* unknown keyboard type */
  342: #define KB_AT		1	/* AT (84 keys) Keyboard */
  343: #define KB_MFII		2	/* MF II (101/102 keys) Keyboard */
  344: 
  345: /*---------------------------------------------------------------------------*
  346:  *	CMOS ram access to get the "Equipment Byte"
  347:  *---------------------------------------------------------------------------*/
  348: 
  349: #define RTC_EQUIPMENT	0x14	/* equipment byte in cmos ram	*/
  350: #define EQ_EGAVGA	0	/* reserved (= ega/vga)		*/
  351: #define EQ_40COLOR	1	/* display = 40 col color	*/
  352: #define EQ_80COLOR	2	/* display = 80 col color	*/
  353: #define EQ_80MONO	3	/* display = 80 col mono	*/
  354: 
  355: /*---------------------------------------------------------------------------*
  356:  *	VT220 -> internal color conversion table fields
  357:  *---------------------------------------------------------------------------*/
  358: 
  359: #define VT_NORMAL	0x00		/* no attributes at all */
  360: #define VT_BOLD		0x01		/* bold attribute */
  361: #define VT_UNDER	0x02		/* underline attribute */
  362: #define VT_BLINK	0x04		/* blink attribute */
  363: #define VT_INVERSE	0x08		/* inverse attribute */
  364: 
  365: /*---------------------------------------------------------------------------*
  366:  *	VGA GENERAL/EXTERNAL Registers          (3BA or 3DA and 3CA, 3C2, 3CC)
  367:  *---------------------------------------------------------------------------*/
  368: 
  369: #define GN_MISCOUTR	0x3CC		/* misc output register read */
  370: #define GN_MISCOUTW	0x3C2		/* misc output register write */
  371: #define GN_INPSTAT0	0x3C2		/* input status 0, r/o */
  372: #define GN_INPSTAT1M	0x3BA		/* input status 1, r/o, mono */
  373: #define GN_INPSTAT1C	0x3DA		/* input status 1, r/o, color */
  374: #define GN_FEATR	0x3CA		/* feature control, read */
  375: #define GN_FEATWM	0x3BA		/* feature control, write, mono */
  376: #define GN_FEATWC	0x3DA		/* feature control, write, color */
  377: #define GN_VSUBSYS	0x3C3		/* video subsystem register r/w */
  378: #define GN_DMCNTLM	0x3B8		/* display mode control, r/w, mono */
  379: #define GN_DMCNTLC	0x3D8		/* display mode control, r/w, color */
  380: #define GN_COLORSEL	0x3D9		/* color select register, w/o */
  381: #define GN_HERCOMPAT	0x3BF		/* Hercules compatibility reg, w/o */
  382: 
  383: /*---------------------------------------------------------------------------*
  384:  *	VGA CRTC Registers			  (3B4 and 3B5 or 3D4 and 3D5)
  385:  *---------------------------------------------------------------------------*/
  386: 
  387: #define MONO_BASE	0x3B4		/* crtc index register address mono */
  388: #define CGA_BASE	0x3D4		/* crtc index register address color */
  389: 
  390: #define	CRTC_ADDR	0x00		/* index register */
  391: 
  392: #define CRTC_HTOTAL	0x00		/* horizontal total */
  393: #define CRTC_HDISPLE	0x01		/* horizontal display end */
  394: #define CRTC_HBLANKS	0x02		/* horizontal blank start */
  395: #define CRTC_HBLANKE	0x03		/* horizontal blank end */
  396: #define CRTC_HSYNCS	0x04		/* horizontal sync start */
  397: #define CRTC_HSYNCE	0x05		/* horizontal sync end */
  398: #define CRTC_VTOTAL	0x06		/* vertical total */
  399: #define CRTC_OVERFLL	0x07		/* overflow low */
  400: #define CRTC_IROWADDR	0x08		/* inital row address */
  401: #define CRTC_MAXROW	0x09		/* maximum row address */
  402: #define CRTC_CURSTART	0x0A		/* cursor start row address */
  403: #define 	CURSOR_ON_BIT 0x20	/* cursor on/off on mda/cga/vga */
  404: #define CRTC_CUREND	0x0B		/* cursor end row address */
  405: #define CRTC_STARTADRH	0x0C		/* linear start address mid */
  406: #define CRTC_STARTADRL	0x0D		/* linear start address low */
  407: #define CRTC_CURSORH	0x0E		/* cursor address mid */
  408: #define CRTC_CURSORL	0x0F		/* cursor address low */
  409: #define CRTC_VSYNCS	0x10		/* vertical sync start */
  410: #define CRTC_VSYNCE	0x11		/* vertical sync end */
  411: #define CRTC_VDE	0x12		/* vertical display end */
  412: #define CRTC_OFFSET	0x13		/* row offset */
  413: #define CRTC_ULOC	0x14		/* underline row address */
  414: #define CRTC_VBSTART	0x15		/* vertical blank start */
  415: #define CRTC_VBEND	0x16		/* vertical blank end */
  416: #define CRTC_MODE	0x17		/* CRTC mode register */
  417: #define CRTC_SPLITL	0x18		/* split screen start low */
  418: 
  419: /* start of ET4000 extensions */
  420: 
  421: #define CRTC_RASCAS	0x32		/* ras/cas configuration */
  422: #define CRTC_EXTSTART	0x33		/* extended start address */
  423: #define CRTC_COMPAT6845	0x34		/* 6845 comatibility control */
  424: #define CRTC_OVFLHIGH	0x35		/* overflow high */
  425: #define CRTC_SYSCONF1	0x36		/* video system configuration 1 */
  426: #define CRTC_SYSCONF2	0x36		/* video system configuration 2 */
  427: 
  428: /* start of WD/Paradise extensions */
  429: 
  430: #define	CRTC_PR10	0x29		/* r/w unlocking */
  431: #define	CRTC_PR11	0x2A		/* ega switches */
  432: #define	CRTC_PR12	0x2B		/* scratch pad */
  433: #define	CRTC_PR13	0x2C		/* interlace h/2 start */
  434: #define	CRTC_PR14	0x2D		/* interlace h/2 end */
  435: #define	CRTC_PR15	0x2E		/* misc control #1 */
  436: #define	CRTC_PR16	0x2F		/* misc control #2 */
  437: #define	CRTC_PR17	0x30		/* misc control #3 */
  438: 					/* 0x31 .. 0x3f reserved */
  439: /* Video 7 */
  440: 
  441: #define CRTC_V7ID	0x1f		/* identification register */
  442: 
  443: /* Trident */
  444: 
  445: #define CRTC_MTEST	0x1e		/* module test register */
  446: #define CRTC_SOFTPROG	0x1f		/* software programming */
  447: #define CRTC_LATCHRDB	0x22		/* latch read back register */
  448: #define CRTC_ATTRSRDB	0x24		/* attribute state read back register*/
  449: #define CRTC_ATTRIRDB	0x26		/* attribute index read back register*/
  450: #define CRTC_HOSTAR	0x27		/* high order start address register */
  451: 
  452: /*---------------------------------------------------------------------------*
  453:  *	VGA TIMING & SEQUENCER Registers			 (3C4 and 3C5)
  454:  *---------------------------------------------------------------------------*/
  455: 
  456: #define TS_INDEX	0x3C4		/* index register */
  457: #define TS_DATA		0x3C5		/* data register */
  458: 
  459: #define TS_SYNCRESET	0x00		/* synchronous reset */
  460: #define TS_MODE		0x01		/* ts mode register */
  461: #define TS_WRPLMASK	0x02		/* write plane mask */
  462: #define TS_FONTSEL	0x03		/* font select register */
  463: #define TS_MEMMODE	0x04		/* memory mode register */
  464: 
  465: /* ET4000 only */
  466: 
  467: #define TS_RESERVED	0x05		/* undef, reserved */
  468: #define TS_STATECNTL	0x06		/* state control register */
  469: #define TS_AUXMODE	0x07		/* auxiliary mode control */
  470: 
  471: /* WD/Paradise only */
  472: 
  473: #define TS_UNLOCKSEQ	0x06		/* PR20 - unlock sequencer register */
  474: #define TS_DISCFSTAT	0x07		/* PR21 - display config status */
  475: #define TS_MEMFIFOCTL	0x10		/* PR30 - memory i/f & fifo control */
  476: #define TS_SYSIFCNTL	0x11		/* PR31 - system interface control */
  477: #define TS_MISC4	0x12		/* PR32 - misc control #4 */
  478: 
  479: /* Video 7 */
  480: 
  481: #define TS_EXTCNTL	0x06		/* extensions control */
  482: #define TS_CLRVDISP	0x30		/* clear vertical display 0x30-0x3f */
  483: #define TS_V7CHIPREV	0x8e		/* chipset revision 0x8e-0x8f */
  484: #define TS_SWBANK	0xe8		/* single/write bank register, rev 5+*/
  485: #define TS_RDBANK	0xe8		/* read bank register, rev 4+ */
  486: #define TS_MISCCNTL	0xe8		/* misc control register, rev 4+ */
  487: #define TS_SWSTROBE	0xea		/* switch strobe */
  488: #define TS_MWRCNTL	0xf3		/* masked write control */
  489: #define TS_MWRMVRAM	0xf4		/* masked write mask VRAM only */
  490: #define TS_BANKSEL	0xf6		/* bank select */
  491: #define TS_SWREADB	0xf7		/* switch readback */
  492: #define TS_PAGESEL	0xf9		/* page select */
  493: #define TS_COMPAT	0xfc		/* compatibility control */
  494: #define TS_16BITCTL	0xff		/* 16 bit interface control */
  495: 
  496: /* Trident */
  497: 
  498: #define TS_HWVERS	0x0b		/* hardware version, switch old/new! */
  499: #define TS_CONFPORT1	0x0c		/* config port 1 and 2    - caution! */
  500: #define TS_MODEC2	0x0d		/* old/new mode control 2 - caution! */
  501: #define TS_MODEC1	0x0e		/* old/new mode control 1 - caution! */
  502: #define	TS_PUPM2	0x0f		/* power up mode 2 */
  503: 
  504: /*---------------------------------------------------------------------------*
  505:  *	VGA GRAPHICS DATA CONTROLLER Registers		    (3CE, 3CF and 3CD)
  506:  *---------------------------------------------------------------------------*/
  507: 
  508: #define GDC_SEGSEL	0x3CD		/* segment select register */
  509: #define GDC_INDEX	0x3CE		/* index register */
  510: #define GDC_DATA	0x3CF		/* data register */
  511: 
  512: #define GDC_SETRES	0x00		/* set / reset bits */
  513: #define GDC_ENSETRES	0x01		/* enable set / reset */
  514: #define GDC_COLORCOMP	0x02		/* color compare register */
  515: #define GDC_ROTFUNC	0x03		/* data rotate / function select */
  516: #define GDC_RDPLANESEL	0x04		/* read plane select */
  517: #define GDC_MODE	0x05		/* gdc mode register */
  518: #define GDC_MISC	0x06		/* gdc misc register */
  519: #define GDC_COLORCARE	0x07		/* color care register */
  520: #define GDC_BITMASK	0x08		/* bit mask register */
  521: 
  522: /* WD/Paradise only */
  523: 
  524: #define GDC_BANKSWA	0x09		/* PR0A - bank switch a */
  525: #define GDC_BANKSWB	0x0a		/* PR0B - bank switch b */
  526: #define GDC_MEMSIZE	0x0b		/* PR1 memory size */
  527: #define GDC_VIDEOSEL	0x0c		/* PR2 video configuration */
  528: #define GDC_CRTCNTL	0x0d		/* PR3 crt address control */
  529: #define GDC_VIDEOCNTL	0x0e		/* PR4 video control */
  530: #define GDC_PR5GPLOCK	0x0f		/* PR5 gp status and lock */
  531: 
  532: /* Video 7 */
  533: 
  534: #define GDC_DATALATCH	0x22		/* gdc data latch */
  535: 
  536: /*---------------------------------------------------------------------------*
  537:  *	VGA ATTRIBUTE CONTROLLER Registers			 (3C0 and 3C1)
  538:  *---------------------------------------------------------------------------*/
  539: 
  540: #define ATC_INDEX	0x3C0		/* index register  AND	*/
  541: #define ATC_DATAW	0x3C0		/* data write	   !!!	*/
  542: #define ATC_DATAR	0x3C1		/* data read */
  543: 
  544: #define ATC_ACCESS	0x20		/* access bit in ATC index register */
  545: 
  546: #define ATC_PALETTE0	0x00		/* color palette register 0 */
  547: #define ATC_PALETTE1	0x01		/* color palette register 1 */
  548: #define ATC_PALETTE2	0x02		/* color palette register 2 */
  549: #define ATC_PALETTE3	0x03		/* color palette register 3 */
  550: #define ATC_PALETTE4	0x04		/* color palette register 4 */
  551: #define ATC_PALETTE5	0x05		/* color palette register 5 */
  552: #define ATC_PALETTE6	0x06		/* color palette register 6 */
  553: #define ATC_PALETTE7	0x07		/* color palette register 7 */
  554: #define ATC_PALETTE8	0x08		/* color palette register 8 */
  555: #define ATC_PALETTE9	0x09		/* color palette register 9 */
  556: #define ATC_PALETTEA	0x0A		/* color palette register 10 */
  557: #define ATC_PALETTEB	0x0B		/* color palette register 11 */
  558: #define ATC_PALETTEC	0x0C		/* color palette register 12 */
  559: #define ATC_PALETTED	0x0D		/* color palette register 13 */
  560: #define ATC_PALETTEE	0x0E		/* color palette register 14 */
  561: #define ATC_PALETTEF	0x0F		/* color palette register 15 */
  562: #define ATC_MODE	0x10		/* atc mode register */
  563: #define ATC_OVERSCAN	0x11		/* overscan register */
  564: #define ATC_COLPLEN	0x12		/* color plane enable register */
  565: #define ATC_HORPIXPAN	0x13		/* horizontal pixel panning */
  566: #define ATC_COLRESET	0x14		/* color reset */
  567: #define ATC_MISC	0x16		/* misc register (ET3000/ET4000) */
  568: 
  569: /*---------------------------------------------------------------------------*
  570:  *	VGA palette handling (output DAC palette)
  571:  *---------------------------------------------------------------------------*/
  572: 
  573: #define VGA_DAC		0x3C6		/* vga dac address */
  574: #define VGA_PMSK	0x3F		/* palette mask, 64 distinct values */
  575: #define NVGAPEL 	256		/* number of palette entries */
  576: 
  577: /*---------------------------------------------------------------------------*
  578:  *	function key labels
  579:  *---------------------------------------------------------------------------*/
  580: 
  581: #define LABEL_LEN	9		/* length of one label */
  582: #define LABEL_MID	8		/* mid-part (row/col)	*/
  583: 
  584: #define LABEL_ROWH	((4*LABEL_LEN)+1)
  585: #define LABEL_ROWL	((4*LABEL_LEN)+2)
  586: #define LABEL_COLU	((4*LABEL_LEN)+4)
  587: #define LABEL_COLH	((4*LABEL_LEN)+5)
  588: #define LABEL_COLL	((4*LABEL_LEN)+6)
  589: 
  590: /* tab setting */
  591: 
  592: #define MAXTAB 132		/* no of possible tab stops */
  593: 
  594: /* escape detection state machine */
  595: 
  596: #define STATE_INIT	0	/* normal	*/
  597: #define	STATE_ESC	1	/* got ESC	*/
  598: #define STATE_BLANK	2	/* got ESC space*/
  599: #define STATE_HASH	3	/* got ESC #	*/
  600: #define STATE_BROPN	4	/* got ESC (	*/
  601: #define STATE_BRCLO	5	/* got ESC )	*/
  602: #define STATE_CSI	6	/* got ESC [	*/
  603: #define STATE_CSIQM	7	/* got ESC [ ?	*/
  604: #define STATE_AMPSND	8	/* got ESC &	*/
  605: #define STATE_STAR	9	/* got ESC *	*/
  606: #define STATE_PLUS	10	/* got ESC +	*/
  607: #define STATE_DCS	11	/* got ESC P	*/
  608: #define STATE_SCA	12	/* got ESC <Ps> " */
  609: #define STATE_STR	13	/* got ESC !	*/
  610: #define STATE_MINUS	14	/* got ESC -	*/
  611: #define STATE_DOT	15	/* got ESC .	*/
  612: #define STATE_SLASH	16	/* got ESC /	*/
  613: 
  614: /* for storing escape sequence parameters */
  615: 
  616: #define MAXPARMS 	10	/* maximum no of parms */
  617: 
  618: /* terminal responses */
  619: 
  620: #define DA_VT220	"\033[?62;1;2;6;7;8;9c"
  621: 
  622: /* sub-states for Device Control String processing */
  623: 
  624: #define DCS_INIT	0	/* got ESC P ... */
  625: #define DCS_AND_UDK	1	/* got ESC P ... | */
  626: #define DCS_UDK_DEF	2	/* got ESC P ... | fnckey / */
  627: #define DCS_UDK_ESC	3	/* got ESC P ... | fnckey / ... ESC */
  628: #define DCS_DLD_DSCS	4	/* got ESC P ... { */
  629: #define DCS_DLD_DEF	5	/* got ESC P ... { dscs */
  630: #define DCS_DLD_ESC	6	/* got ESC P ... { dscs ... / ... ESC */
  631: 
  632: /* vt220 user defined keys and vt220 downloadable charset */
  633: 
  634: #define MAXUDKDEF	300	/* max 256 char + 1 '\0' + space.. */
  635: #define	MAXUDKEYS	18	/* plus holes .. */
  636: #define DSCS_LENGTH	3	/* descriptor length */
  637: #define MAXSIXEL	8	/* sixels forever ! */
  638: 
  639: /* sub-states for HP-terminal emulator */
  640: 
  641: #define SHP_INIT	0
  642: 
  643: /* esc & f family */
  644: 
  645: #define SHP_AND_F	1
  646: #define SHP_AND_Fa	2
  647: #define SHP_AND_Fak	3
  648: #define SHP_AND_Fak1	4
  649: #define SHP_AND_Fakd	5
  650: #define SHP_AND_FakdL	6
  651: #define SHP_AND_FakdLl	7
  652: #define SHP_AND_FakdLls	8
  653: 
  654: /* esc & j family */
  655: 
  656: #define SHP_AND_J	9
  657: #define SHP_AND_JL	10
  658: 
  659: /* esc & every-thing-else */
  660: 
  661: #define SHP_AND_ETE	11
  662: 
  663: /* additionals for function key labels */
  664: 
  665: #define MAX_LABEL	16
  666: #define MAX_STRING	80
  667: #define MAX_STATUS	160
  668: 
  669: /* MAX values for screen sizes for possible video adaptors */
  670: 
  671: #define MAXROW_MDACGA	25		/* MDA/CGA can do 25 x 80 max */
  672: #define MAXCOL_MDACGA	80
  673: 
  674: #define MAXROW_EGA	43		/* EGA can do 43 x 80 max */
  675: #define MAXCOL_EGA	80
  676: 
  677: #define MAXROW_VGA	50		/* VGA can do 50 x 80 max */
  678: #define MAXCOL_VGA	80
  679: #define MAXCOL_SVGA	132		/* Super VGA can do 50 x 132 max */
  680: 
  681: /* switch 80/132 columns */
  682: 
  683: #define SCR_COL80	80		/* in 80 col mode */
  684: #define SCR_COL132	132		/* in 132 col mode */
  685: 
  686: #define MAXDECSCA	(((MAXCOL_SVGA * MAXROW_VGA) \
  687: 			/ (8 * sizeof(unsigned int)) ) + 1 )
  688: 
  689: /* screen memory start, monochrome */
  690: 
  691: #ifndef	MONO_BUF
  692: # if PCVT_FREEBSD && (PCVT_FREEBSD > 102)
  693: #  define MONO_BUF	(KERNBASE+0xB0000)
  694: # else
  695: #  define MONO_BUF	0xfe0B0000		 /* NetBSD-current: isa.h */
  696: # endif
  697: #endif
  698: 
  699: /* screen memory start, color */
  700: 
  701: #ifndef	CGA_BUF
  702: # if PCVT_FREEBSD && (PCVT_FREEBSD > 102)
  703: #  define CGA_BUF	(KERNBASE+0xB8000)
  704: # else
  705: #  define CGA_BUF	0xfe0B8000		 /* NetBSD-current: isa.h */
  706: # endif
  707: #endif
  708: 
  709: #define	CHR		2		/* bytes per word in screen mem */
  710: 
  711: #define NVGAFONTS	8		/* number of vga fonts loadable */
  712: 
  713: #define MAXKEYNUM	127		/* max no of keys in table */
  714: 
  715: /* charset tables */
  716: 
  717: #define	CSL	0x0000		/* ega/vga charset, lower half of 512 */
  718: #define	CSH	0x0800		/* ega/vga charset, upper half of 512 */
  719: #define CSSIZE	96		/* (physical) size of a character set */
  720: 
  721: /* charset designations */
  722: 
  723: #define D_G0		0	/* designated as G0 */
  724: #define D_G1		1	/* designated as G1 */
  725: #define D_G2		2	/* designated as G2 */
  726: #define D_G3		3	/* designated as G3 */
  727: #define D_G1_96		4	/* designated as G1 for 96-char charsets */
  728: #define D_G2_96		5	/* designated as G2 for 96-char charsets */
  729: #define D_G3_96		6	/* designated as G3 for 96-char charsets */
  730: 
  731: /* which fkey-labels */
  732: 
  733: #define SYS_FKL		0	/* in hp mode, sys-fkls are active */
  734: #define USR_FKL		1	/* in hp mode, user-fkls are active */
  735: 
  736: /* arguments to async_update() */
  737: 
  738: #define UPDATE_START	((void *)0)	/* do cursor update and requeue */
  739: #define UPDATE_STOP	((void *)1)	/* suspend cursor updates */
  740: #define UPDATE_KERN	((void *)2)	/* do cursor updates for kernel output */
  741: 
  742: /* variables */
  743: 
  744: #ifdef EXTERN
  745: #define WAS_EXTERN
  746: #else
  747: #define EXTERN extern
  748: #endif
  749: 
  750: EXTERN	u_char	*more_chars;		/* response buffer via kbd */
  751: EXTERN	u_char	color;			/* color or mono display */
  752: 
  753: EXTERN	u_short	kern_attr;		/* kernel messages char attributes */
  754: EXTERN	u_short	user_attr;		/* character attributes */
  755: 
  756: #if !PCVT_EMU_MOUSE
  757: 
  758: #if PCVT_NETBSD
  759: EXTERN struct tty *pc_tty[PCVT_NSCREENS];
  760: #elif !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200)
  761: EXTERN struct tty pccons[PCVT_NSCREENS];
  762: #else
  763: EXTERN struct tty *pccons[PCVT_NSCREENS];
  764: #endif /* PCVT_NETBSD */
  765: 
  766: #else /* PCVT_EMU_MOUSE */
  767: 
  768: #if PCVT_NETBSD
  769: EXTERN struct tty *pc_tty[PCVT_NSCREENS + 1];
  770: #elif !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200)
  771: EXTERN struct tty pccons[PCVT_NSCREENS + 1];
  772: #else
  773: EXTERN struct tty *pccons[PCVT_NSCREENS + 1];
  774: #endif
  775: 
  776: #endif /* PCVT_EMU_MOUSE */
  777: 
  778: struct sixels {
  779: 	u_char lower[MAXSIXEL];		/* lower half of char */
  780: 	u_char upper[MAXSIXEL];		/* upper half of char */
  781: };
  782: 
  783: struct udkentry {
  784: 	u_char	first[MAXUDKEYS];	/* index to first char */
  785: 	u_char	length[MAXUDKEYS];	/* length of this entry */
  786: };
  787: 
  788: /* VGA palette handling */
  789: struct rgb {
  790: 	u_char	r, g, b;		/* red/green/blue, valid 0..VGA_PMSK */
  791: };
  792: 
  793: typedef struct video_state {
  794: 	u_short	*Crtat;			/* video page start addr */
  795: 	u_short *Memory;		/* malloc'ed memory start address */
  796: 	struct tty *vs_tty;		/* pointer to this screen's tty */
  797: 	u_char	maxcol;			/* 80 or 132 cols on screen */
  798: 	u_char 	row, col;		/* current cursor position */
  799: 	u_short	c_attr;			/* current character attributes */
  800: 	u_char	vtsgr;			/* current sgr configuration */
  801: 	u_short	cur_offset;		/* current cursor position offset */
  802: 	u_char	bell_on;		/* flag, bell enabled */
  803: 	u_char	sevenbit;		/* flag, data path 7 bits wide */
  804: 	u_char	dis_fnc;		/* flag, display functions enable */
  805: 	u_char	transparent;		/* flag, mk path tmp trnsprnt for ctls*/
  806: 	u_char	scrr_beg;		/* scrolling region, begin */
  807: 	u_char	scrr_len;		/* scrolling region, length */
  808: 	u_char	scrr_end;		/* scrolling region, end */
  809: 	u_char	screen_rows;		/* screen size, length - status lines */
  810: 	u_char	screen_rowsize; 	/* screen size, length */
  811: 	u_char	vga_charset;		/* VGA character set value */
  812: 	u_char	lastchar;		/* flag, vt100 behaviour of last char */
  813: 	u_char	lastrow;		/* save row, --------- " -----------  */
  814: 	u_char	*report_chars;		/* ptr, status reports from terminal */
  815: 	u_char	report_count;		/* count, ----------- " ------------ */
  816: 	u_char	state;			/* escape sequence state machine */
  817: 	u_char	m_awm;			/* flag, vt100 mode, auto wrap */
  818: 	u_char	m_om;			/* flag, vt100 mode, origin mode */
  819: 	u_char	sc_flag;		/* flag, vt100 mode,saved parms valid */
  820: 	u_char	sc_row;			/* saved row */
  821: 	u_char	sc_col;			/* saved col */
  822: 	u_short sc_cur_offset;		/* saved cursor addr offset */
  823: 	u_short	sc_attr;		/* saved attributes */
  824: 	u_char	sc_vtsgr;		/* saved sgr configuration */
  825: 	u_char	sc_awm;			/* saved auto wrap mode */
  826: 	u_char	sc_om;			/* saved origin mode */
  827: 	u_short	*sc_G0;			/* save G0 ptr */
  828: 	u_short	*sc_G1;			/* save G1 ptr */
  829: 	u_short	*sc_G2;			/* save G2 ptr */
  830: 	u_short	*sc_G3;			/* save G3 ptr */
  831: 	u_short	**sc_GL;		/* save GL ptr */
  832: 	u_short	**sc_GR;		/* save GR ptr */
  833: 	u_char	sc_sel;			/* selective erase state */
  834: 	u_char	ufkl[8][17];		/* user fkey-labels */
  835: 	u_char	sfkl[8][17];		/* system fkey-labels */
  836: 	u_char	labels_on;		/* display fkey labels etc. on/off */
  837: 	u_char	which_fkl;		/* which fkey labels are active */
  838: 	char	tab_stops[MAXTAB]; 	/* table of active tab stops */
  839: 	u_char	parmi;			/* parameter index */
  840: 	u_char	parms[MAXPARMS];	/* parameter array */
  841: 	u_char	hp_state;		/* hp escape sequence state machine */
  842: 	u_char	attribute;		/* attribute normal, tx only, local */
  843: 	u_char	key;			/* fkey label no */
  844: 	u_char	l_len;			/* buffer length's */
  845: 	u_char	s_len;
  846: 	u_char	m_len;
  847: 	u_char	i;			/* help (got short of names ...) */
  848: 	u_char	l_buf[MAX_LABEL+1]; 	/* buffers */
  849: 	u_char	s_buf[MAX_STRING+1];
  850: 	u_char	m_buf[MAX_STATUS+1];
  851: 	u_char	openf;			/* we are opened ! */
  852: 	u_char	vt_pure_mode;		/* no fkey labels, row/col, status */
  853: 	u_char	cursor_start;		/* Start of cursor */
  854: 	u_char	cursor_end;		/* End of cursor */
  855: 	u_char	cursor_on;		/* cursor switched on */
  856: 	u_char	ckm;			/* true = cursor key normal mode */
  857: 	u_char	irm;			/* true = insert mode */
  858: 	u_char	lnm;			/* Line Feed/New Line Mode */
  859: 	u_char	dcs_state;		/* dcs escape sequence state machine */
  860: 	u_char	udk_def[MAXUDKDEF]; 	/* new definitions for vt220 FKeys */
  861: 	u_char	udk_defi;		/* index for FKey definitions */
  862: 	u_char	udk_deflow;		/* low or high nibble in sequence */
  863: 	u_char	udk_fnckey;		/* function key to assign to */
  864: 	u_char	dld_dscs[DSCS_LENGTH];	/* designate soft character set id */
  865: 	u_char	dld_dscsi;		/* index for dscs */
  866: 	u_char	dld_sixel_lower;	/* upper/lower sixels of character */
  867: 	u_char	dld_sixelli;		/* index for lower sixels */
  868: 	u_char	dld_sixelui;		/* index for upper sixels */
  869: 	struct sixels sixel;		/* structure for storing char sixels */
  870: 	u_char	selchar;		/* true = selective attribute on */
  871: 	u_int	decsca[MAXDECSCA];	/* Select Character Attrib bit array */
  872: 	u_short **GL;			/* ptr to current GL conversion table*/
  873: 	u_short **GR;			/* ptr to current GR conversion table*/
  874: 	u_short *G0;			/* ptr to current G0 conversion table*/
  875: 	u_short *G1;			/* ptr to current G1 conversion table*/
  876: 	u_char force24;			/* force 24 lines in DEC 25 and HP 28*/
  877: 	u_short *G2;			/* ptr to current G2 conversion table*/
  878: 	u_short *G3;			/* ptr to current G3 conversion table*/
  879: 	u_char	dld_id[DSCS_LENGTH+1];	/* soft character set id */
  880: 	u_char	which[DSCS_LENGTH+1];	/* which set to designate */
  881: 	u_char	whichi;			/* index into which ..	*/
  882: 	u_char  ss;			/* flag, single shift G2 / G3 -> GL */
  883: 	u_short **Gs;			/* ptr to cur. G2/G3 conversion table*/
  884: 	u_char	udkbuf[MAXUDKDEF];	/* buffer for user defined keys */
  885: 	struct udkentry ukt;		/* index & length for each udk */
  886: 	u_char	udkff;			/* index into buffer first free entry*/
  887: 	struct rgb palette[NVGAPEL];	/* saved VGA DAC palette */
  888: 	u_char	wd132col;		/* we are on a wd vga and in 132 col */
  889: 	u_char	scroll_lock; 		/* scroll lock active */
  890: 	u_char	caps_lock;		/* caps lock active */
  891: 	u_char	shift_lock;		/* shiftlock flag (virtual ..) */
  892: 	u_char	num_lock;		/* num lock, true = keypad num mode */
  893: 	u_char	abs_write;		/* write outside of scroll region */
  894: 
  895: 	u_short *Scrollback;            /* scrollback buffer */
  896: 	u_short scrollback_pages;	/* size of scrollback buffer */
  897: 	u_short scr_offset;             /* current scrollback offset (lines) */
  898: 	short scrolling;                /* current scrollback page */
  899: 	u_short max_off;                /* maximum scrollback offset */
  900: 	
  901: #if PCVT_USL_VT_COMPAT			/* SysV compatibility :-( */
  902: 
  903: 	struct vt_mode smode;
  904: 	struct proc *proc;
  905: 	pid_t pid;
  906: 	unsigned vt_status;
  907: #define	VT_WAIT_REL 1			/* wait till process released vt */
  908: #define VT_WAIT_ACK 2			/* wait till process ack vt acquire */
  909: #define VT_GRAFX    4			/* vt runs graphics mode */
  910: #define VT_WAIT_ACT 8			/* a process is sleeping on this vt */
  911: 					/*  becoming active */
  912: #endif /* PCVT_USL_VT_COMPAT */
  913: 
  914: } video_state;
  915: 
  916: EXTERN video_state vs[PCVT_NSCREENS];	/* parameters for screens */
  917: 
  918: struct vga_char_state {
  919: 	int	loaded;		/* Whether a font is loaded here */
  920: 	int	secondloaded;	/* an extension characterset was loaded, */
  921: 				/*	the number is found here	 */
  922: 	u_char	char_scanlines;	/* Scanlines per character */
  923: 	u_char	scr_scanlines;	/* Low byte of scanlines per screen */
  924: 	int	screen_size;	/* Screen size in SIZ_YYROWS */
  925: };
  926: 
  927: EXTERN struct vga_char_state vgacs[NVGAFONTS];	/* Character set states */
  928: 
  929: #if PCVT_EMU_MOUSE
  930: struct mousestat {
  931: 	struct timeval lastmove; /* last time the pointer moved */
  932: 	u_char opened;		 /* someone would like to use a mouse */
  933: 	u_char minor;		 /* minor device number */
  934: 	u_char buttons;		 /* current "buttons" pressed */
  935: 	u_char extendedseen;	 /* 0xe0 has been seen, do not use next key */
  936: 	u_char breakseen;	 /* key break has been seen for a sticky btn */
  937: };
  938: #endif /* PCVT_EMU_MOUSE */
  939: 
  940: #ifdef WAS_EXTERN
  941: 
  942: #if PCVT_NETBSD > 9
  943: 
  944: int pcprobe ();
  945: void pcattach ();
  946: 
  947: struct cfdriver vtcd = {
  948: 	NULL, "vt", pcprobe, pcattach, DV_TTY, sizeof(struct device)
  949: };
  950: 
  951: #else
  952: 
  953: int pcprobe ( struct isa_device *dev );
  954: int pcattach ( struct isa_device *dev );
  955: 
  956: struct	isa_driver vtdriver = {		/* driver routines */
  957: 	pcprobe, pcattach, "vt", 1,
  958: };
  959: 
  960: #endif /* PCVT_NETBSD > 9 */
  961: 
  962: u_char fgansitopc[] = {			/* foreground ANSI color -> pc */
  963: 	FG_BLACK, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE,
  964: 	FG_MAGENTA, FG_CYAN, FG_LIGHTGREY
  965: };
  966: 
  967: u_char bgansitopc[] = {			/* background ANSI color -> pc */
  968: 	BG_BLACK, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE,
  969: 	BG_MAGENTA, BG_CYAN, BG_LIGHTGREY
  970: };
  971: 
  972: #if !PCVT_NETBSD
  973: u_short *Crtat;			/* screen start address */
  974: #if !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200)
  975: struct tty *pcconsp =	&pccons[0];		/* ptr to current device */
  976: #else /* PCVT_FREEBSD > 110 */
  977: struct tty *pcconsp;
  978: #endif /* !(PCVT_FREEBSD > 110) */
  979: #else
  980: struct tty *pcconsp;		/* ptr to current device, see pcattach() */
  981: #endif /* PCVT_NETBSD */
  982: 
  983: #if PCVT_EMU_MOUSE
  984: struct mousestat	mouse;
  985: struct mousedefs	mousedef = {0x3b, 0x3c, 0x3d, 0,     250000};
  986: #endif /* PCVT_EMU_MOUSE */	/*  F1,   F2,   F3,   false, 0.25 sec */
  987: 
  988: video_state *vsp 		= &vs[0]; /* ptr to current screen parms */
  989: 
  990: #if PCVT_USL_VT_COMPAT
  991: int	vt_switch_pending	= 0; 		/* if > 0, a vt switch is */
  992: #endif /* PCVT_USL_VT_COMPAT */			/* pending; contains the # */
  993: 						/* of the old vt + 1 */
  994: 
  995: u_int	addr_6845		= MONO_BASE;	/* crtc base addr */
  996: u_char	do_initialization	= 1;		/* we have to init ourselves */
  997: u_char	pcvt_is_console		= 0;		/* until we know it */
  998: u_char 	shift_down 		= 0;		/* shift key down flag */
  999: u_char	ctrl_down		= 0; 		/* ctrl key down flag */
 1000: u_char	meta_down		= 0; 		/* alt key down flag */
 1001: u_char	altgr_down		= 0; 		/* altgr key down flag */
 1002: u_char	kbrepflag		= 1;		/* key repeat flag */
 1003: u_char	totalscreens		= 1;		/* screens available */
 1004: u_char	current_video_screen	= 0;		/* displayed screen no */
 1005: u_char	adaptor_type 		= UNKNOWN_ADAPTOR;/* adaptor type */
 1006: u_char 	vga_type 		= VGA_UNKNOWN;	/* vga chipset */
 1007: u_char	can_do_132col		= 0;		/* vga chipset can 132 cols */
 1008: u_char	vga_family		= 0;		/* vga manufacturer */
 1009: u_char	totalfonts		= 0;		/* fonts available */
 1010: u_char	chargen_access		= 0;		/* synchronize access */
 1011: u_char	keyboard_type		= KB_UNKNOWN;	/* type of keyboard */
 1012: u_char	keyboard_is_initialized = 0;		/* for ddb sanity */
 1013: u_char	kbd_polling		= 0;		/* keyboard is being polled */
 1014: #ifdef _DEV_KBD_KBDREG_H_
 1015: u_char	reset_keyboard		= 0;		/* OK to reset keyboard */
 1016: keyboard_t *kbd			= NULL;
 1017: #endif /* _DEV_KBD_KBDREG_H_ */
 1018: 
 1019: #if PCVT_SHOWKEYS
 1020: u_char	keyboard_show		= 0;		/* normal display */
 1021: #endif /* PCVT_SHOWKEYS */
 1022: 
 1023: u_char	cursor_pos_valid	= 0;		/* sput left a valid position*/
 1024: 
 1025: u_char	critical_scroll		= 0;		/* inside scrolling up */
 1026: int	switch_page		= -1;		/* which page to switch to */
 1027: 
 1028: #if PCVT_SCREENSAVER
 1029: u_char	reset_screen_saver	= 1;		/* reset the saver next time */
 1030: u_char	scrnsv_active		= 0;		/* active flag */
 1031: #endif /* PCVT_SCREENSAVER */
 1032: 
 1033: #ifdef XSERVER
 1034: unsigned scrnsv_timeout		= 0;		/* initially off */
 1035: #if !PCVT_USL_VT_COMPAT
 1036: u_char pcvt_xmode		= 0;		/* display is grafx */
 1037: #endif /* PCVT_USL_VT_COMPAT */
 1038: u_char pcvt_kbd_raw		= 0;		/* keyboard sends scans */
 1039: #endif /* XSERVER */
 1040: 
 1041: #if PCVT_BACKUP_FONTS
 1042: u_char *saved_charsets[NVGAFONTS] = {0};	/* backup copy of fonts */
 1043: #endif /* PCVT_BACKUP_FONTS */
 1044: 
 1045: /*---------------------------------------------------------------------------
 1046: 
 1047: 	VT220 attributes -> internal emulator attributes conversion tables
 1048: 
 1049: 	be careful when designing color combinations, because on
 1050: 	EGA and VGA displays, bit 3 of the attribute byte is used
 1051: 	for characterset switching, and is no longer available for
 1052: 	foreground intensity (bold)!
 1053: 
 1054: ---------------------------------------------------------------------------*/
 1055: 
 1056: /* color displays */
 1057: 
 1058: u_char sgr_tab_color[16] = {
 1059: /*00*/  (BG_BLACK     | FG_LIGHTGREY),             /* normal               */
 1060: /*01*/  (BG_BLUE      | FG_LIGHTGREY),             /* bold                 */
 1061: /*02*/  (BG_BROWN     | FG_LIGHTGREY),             /* underline            */
 1062: /*03*/  (BG_MAGENTA   | FG_LIGHTGREY),             /* bold+underline       */
 1063: /*04*/  (BG_BLACK     | FG_LIGHTGREY | FG_BLINK),  /* blink                */
 1064: /*05*/  (BG_BLUE      | FG_LIGHTGREY | FG_BLINK),  /* bold+blink           */
 1065: /*06*/  (BG_BROWN     | FG_LIGHTGREY | FG_BLINK),  /* underline+blink      */
 1066: /*07*/  (BG_MAGENTA   | FG_LIGHTGREY | FG_BLINK),  /* bold+underline+blink */
 1067: /*08*/  (BG_LIGHTGREY | FG_BLACK),                 /* invers               */
 1068: /*09*/  (BG_LIGHTGREY | FG_BLUE),                  /* bold+invers          */
 1069: /*10*/  (BG_LIGHTGREY | FG_BROWN),                 /* underline+invers     */
 1070: /*11*/  (BG_LIGHTGREY | FG_MAGENTA),               /* bold+underline+invers*/
 1071: /*12*/  (BG_LIGHTGREY | FG_BLACK      | FG_BLINK), /* blink+invers         */
 1072: /*13*/  (BG_LIGHTGREY | FG_BLUE       | FG_BLINK), /* bold+blink+invers    */
 1073: /*14*/  (BG_LIGHTGREY | FG_BROWN      | FG_BLINK), /* underline+blink+invers*/
 1074: /*15*/  (BG_LIGHTGREY | FG_MAGENTA    | FG_BLINK)  /*bold+underl+blink+invers*/
 1075: };
 1076: 
 1077: /* monochrome displays (VGA version, no intensity) */
 1078: 
 1079: u_char sgr_tab_mono[16] = {
 1080: /*00*/  (BG_BLACK     | FG_LIGHTGREY),            /* normal               */
 1081: /*01*/  (BG_BLACK     | FG_UNDERLINE),            /* bold                 */
 1082: /*02*/  (BG_BLACK     | FG_UNDERLINE),            /* underline            */
 1083: /*03*/  (BG_BLACK     | FG_UNDERLINE),            /* bold+underline       */
 1084: /*04*/  (BG_BLACK     | FG_LIGHTGREY | FG_BLINK), /* blink                */
 1085: /*05*/  (BG_BLACK     | FG_UNDERLINE | FG_BLINK), /* bold+blink           */
 1086: /*06*/  (BG_BLACK     | FG_UNDERLINE | FG_BLINK), /* underline+blink      */
 1087: /*07*/  (BG_BLACK     | FG_UNDERLINE | FG_BLINK), /* bold+underline+blink */
 1088: /*08*/  (BG_LIGHTGREY | FG_BLACK),                /* invers               */
 1089: /*09*/  (BG_LIGHTGREY | FG_BLACK),                /* bold+invers          */
 1090: /*10*/  (BG_LIGHTGREY | FG_BLACK),                /* underline+invers     */
 1091: /*11*/  (BG_LIGHTGREY | FG_BLACK),                /* bold+underline+invers*/
 1092: /*12*/  (BG_LIGHTGREY | FG_BLACK | FG_BLINK),     /* blink+invers         */
 1093: /*13*/  (BG_LIGHTGREY | FG_BLACK | FG_BLINK),     /* bold+blink+invers    */
 1094: /*14*/  (BG_LIGHTGREY | FG_BLACK | FG_BLINK),     /* underline+blink+invers*/
 1095: /*15*/  (BG_LIGHTGREY | FG_BLACK | FG_BLINK)      /*bold+underl+blink+invers*/
 1096: };
 1097: 
 1098: /* monochrome displays (MDA version, with intensity) */
 1099: 
 1100: u_char sgr_tab_imono[16] = {
 1101: /*00*/  (BG_BLACK     | FG_LIGHTGREY),                /* normal               */
 1102: /*01*/  (BG_BLACK     | FG_LIGHTGREY | FG_INTENSE),   /* bold                 */
 1103: /*02*/  (BG_BLACK     | FG_UNDERLINE),                /* underline            */
 1104: /*03*/  (BG_BLACK     | FG_UNDERLINE | FG_INTENSE),   /* bold+underline       */
 1105: /*04*/  (BG_BLACK     | FG_LIGHTGREY | FG_BLINK),     /* blink                */
 1106: /*05*/  (BG_BLACK     | FG_LIGHTGREY | FG_INTENSE | FG_BLINK), /* bold+blink  */
 1107: /*06*/  (BG_BLACK     | FG_UNDERLINE | FG_BLINK),     /* underline+blink      */
 1108: /*07*/  (BG_BLACK     | FG_UNDERLINE | FG_BLINK | FG_INTENSE), /* bold+underline+blink */
 1109: /*08*/  (BG_LIGHTGREY | FG_BLACK),                    /* invers               */
 1110: /*09*/  (BG_LIGHTGREY | FG_BLACK | FG_INTENSE),       /* bold+invers          */
 1111: /*10*/  (BG_LIGHTGREY | FG_BLACK),                    /* underline+invers     */
 1112: /*11*/  (BG_LIGHTGREY | FG_BLACK | FG_INTENSE),       /* bold+underline+invers*/
 1113: /*12*/  (BG_LIGHTGREY | FG_BLACK | FG_BLINK),         /* blink+invers         */
 1114: /*13*/  (BG_LIGHTGREY | FG_BLACK | FG_BLINK | FG_INTENSE),/* bold+blink+invers*/
 1115: /*14*/  (BG_LIGHTGREY | FG_BLACK | FG_BLINK),         /* underline+blink+invers*/
 1116: /*15*/  (BG_LIGHTGREY | FG_BLACK | FG_BLINK | FG_INTENSE) /* bold+underl+blink+invers */
 1117: };
 1118: 
 1119: #else /* WAS_EXTERN */
 1120: 
 1121: extern u_char		vga_type;
 1122: extern struct tty	*pcconsp;
 1123: extern video_state	*vsp;
 1124: 
 1125: #if PCVT_EMU_MOUSE
 1126: extern struct mousestat mouse;
 1127: extern struct mousedefs mousedef;
 1128: #endif /* PCVT_EMU_MOUSE */
 1129: 
 1130: #if PCVT_USL_VT_COMPAT
 1131: extern int		vt_switch_pending;
 1132: #endif /* PCVT_USL_VT_COMPAT */
 1133: 
 1134: extern u_int		addr_6845;
 1135: extern u_short		*Crtat;
 1136: extern u_char		do_initialization;
 1137: extern u_char		pcvt_is_console;
 1138: extern u_char		bgansitopc[];
 1139: extern u_char		fgansitopc[];
 1140: extern u_char 		shift_down;
 1141: extern u_char		ctrl_down;
 1142: extern u_char		meta_down;
 1143: extern u_char		altgr_down;
 1144: extern u_char		kbrepflag;
 1145: extern u_char		adaptor_type;
 1146: extern u_char		current_video_screen;
 1147: extern u_char		totalfonts;
 1148: extern u_char		totalscreens;
 1149: extern u_char		chargen_access;
 1150: extern u_char		keyboard_type;
 1151: extern u_char		can_do_132col;
 1152: extern u_char		vga_family;
 1153: extern u_char		keyboard_is_initialized;
 1154: extern u_char		kbd_polling;
 1155: #ifdef _DEV_KBD_KBDREG_H_
 1156: extern u_char		reset_keyboard;
 1157: extern keyboard_t	*kbd;
 1158: #endif /* _DEV_KBD_KBDREG_H_ */
 1159: 
 1160: #if PCVT_SHOWKEYS
 1161: extern u_char		keyboard_show;
 1162: #endif /* PCVT_SHOWKEYS */
 1163: 
 1164: extern	u_char	cursor_pos_valid;
 1165: 
 1166: extern	u_char	critical_scroll;
 1167: extern	int	switch_page;
 1168: 
 1169: #if PCVT_SCREENSAVER
 1170: extern	u_char	reset_screen_saver;
 1171: extern	u_char	scrnsv_active;
 1172: #endif /* PCVT_SCREENSAVER */
 1173: 
 1174: extern u_char		sgr_tab_color[];
 1175: extern u_char		sgr_tab_mono[];
 1176: extern u_char		sgr_tab_imono[];
 1177: 
 1178: #ifdef XSERVER
 1179: extern unsigned		scrnsv_timeout;
 1180: extern u_char		pcvt_xmode;
 1181: extern u_char		pcvt_kbd_raw;
 1182: #endif /* XSERVER */
 1183: 
 1184: #if PCVT_BACKUP_FONTS
 1185: extern u_char		*saved_charsets[NVGAFONTS];
 1186: #endif /* PCVT_BACKUP_FONTS */
 1187: 
 1188: #endif	/* WAS_EXTERN */
 1189: 
 1190: /*
 1191:  * FreeBSD > 1.0.2 cleaned up the kernel definitions (with the aim of
 1192:  * getting ANSI-clean). Since there has been a mixed usage of types like
 1193:  * "dev_t" (actually some short) in prototyped and non-prototyped fasion,
 1194:  * each of those types is declared as "int" within function prototypes
 1195:  * (which is what the compiler would actually promote it to).
 1196:  *
 1197:  * The macros below are used to clarify which type a parameter ought to
 1198:  * be, regardless of its actual promotion to "int".
 1199:  */
 1200: 
 1201: #define Dev_t	int
 1202: #define U_short	int
 1203: #define U_char	int
 1204: 
 1205: /*
 1206:  * In FreeBSD >= 2.0, dev_t has type `unsigned long', so promoting it
 1207:  * doesn't cause any problems in prototypes.
 1208:  */
 1209: 
 1210: #if PCVT_FREEBSD >= 200
 1211: #undef Dev_t
 1212: #define Dev_t	dev_t
 1213: #endif
 1214: 
 1215: #if !PCVT_FREEBSD || (PCVT_FREEBSD < 210)
 1216: extern void bcopyb(void *from, void *to, u_int length);
 1217: #endif
 1218: 
 1219: #if !PCVT_FREEBSD || (PCVT_FREEBSD < 200)
 1220: extern void fillw(U_short value, void *addr, u_int length);
 1221: #endif
 1222: 
 1223: int	pcparam ( struct tty *tp, struct termios *t );
 1224: 
 1225: /*
 1226:  * In FreeBSD > 2.0.6, driver console functions are declared in machine/cons.h
 1227:  * and some return void, so don't declare them here.
 1228:  */
 1229: #if PCVT_FREEBSD <= 205
 1230: int	pccnprobe ( struct consdev *cp );
 1231: int	pccninit ( struct consdev *cp );
 1232: int	pccngetc ( Dev_t dev );
 1233: int	pccncheckc ( Dev_t dev );
 1234: int	pccnputc ( Dev_t dev, U_char c );
 1235: #endif
 1236: 
 1237: ointhand2_t	pcrint;
 1238: void	pcstart ( struct tty *tp );
 1239: void	pcstop ( struct tty *tp, int flag );
 1240: 
 1241: # if PCVT_FREEBSD < 200
 1242: void	consinit ( void );
 1243: # endif
 1244: 
 1245: #if PCVT_USL_VT_COMPAT
 1246: void	switch_screen ( int n, int oldgrafx, int newgrafx );
 1247: int	usl_vt_ioctl (Dev_t dev, int cmd, caddr_t data, int flag,
 1248: 		      struct proc *);
 1249: int	vt_activate ( int newscreen );
 1250: int	vgapage ( int n );
 1251: void	get_usl_keymap( keymap_t *map );
 1252: void	reset_usl_modes (struct video_state *vsx);
 1253: #else
 1254: void	vgapage ( int n );
 1255: #endif /* PCVT_USL_VT_COMPAT */
 1256: 
 1257: #if PCVT_EMU_MOUSE
 1258: int	mouse_ioctl ( Dev_t dev, int cmd, caddr_t data );
 1259: #endif /*  PCVT_EMU_MOUSE */
 1260: 
 1261: #if PCVT_SCREENSAVER
 1262: void 	pcvt_scrnsv_reset ( void );
 1263: #endif /* PCVT_SCREENSAVER */
 1264: 
 1265: #if PCVT_SCREENSAVER && defined(XSERVER)
 1266: void 	pcvt_set_scrnsv_tmo ( int );
 1267: #endif /* PCVT_SCREENSAVER && defined(XSERVER) */
 1268: 
 1269: void	vga_move_charset ( unsigned n, unsigned char *b, int save_it);
 1270: 
 1271: void	async_update ( void *arg );
 1272: void	clr_parms ( struct video_state *svsp );
 1273: void	cons_highlight ( void );
 1274: void	cons_normal ( void );
 1275: void	dprintf ( unsigned flgs, const char *fmt, ... );
 1276: int	egavga_test ( void );
 1277: void	fkl_off ( struct video_state *svsp );
 1278: void	fkl_on ( struct video_state *svsp );
 1279: struct tty *get_pccons ( Dev_t dev );
 1280: void	init_sfkl ( struct video_state *svsp );
 1281: void	init_ufkl ( struct video_state *svsp );
 1282: #ifndef _DEV_KBD_KBDREG_H_
 1283: int	kbd_cmd ( int val );
 1284: int	kbd_response ( void );
 1285: #endif /* _DEV_KBD_KBDREG_H_ */
 1286: void	kbd_code_init ( void );
 1287: void	kbd_code_init1 ( void );
 1288: 
 1289: #if PCVT_SCANSET > 1
 1290: void	kbd_emulate_pc(int do_emulation);
 1291: #endif
 1292: 
 1293: int	kbdioctl ( Dev_t dev, int cmd, caddr_t data, int flag );
 1294: void	loadchar ( int fontset, int character, int char_scanlines,
 1295: 		   u_char *char_table );
 1296: void	mda2egaorvga ( void );
 1297: void	roll_up ( struct video_state *svsp, int n );
 1298: void	select_vga_charset ( int vga_charset );
 1299: void	set_2ndcharset ( void );
 1300: void	set_charset ( struct video_state *svsp, int curvgacs );
 1301: void	set_emulation_mode ( struct video_state *svsp, int mode );
 1302: void	set_screen_size ( struct video_state *svsp, int size );
 1303: void	reallocate_scrollbuffer ( struct video_state *svsp, int pages );
 1304: u_char *sgetc ( int noblock );
 1305: void	sixel_vga ( struct sixels *charsixel, u_char *charvga );
 1306: void	sput ( u_char *s, U_char attrib, int len, int page );
 1307: void	sw_cursor ( int onoff );
 1308: void	sw_sfkl ( struct video_state *svsp );
 1309: void	sw_ufkl ( struct video_state *svsp );
 1310: void	swritefkl ( int num, u_char *string, struct video_state *svsp );
 1311: void	toggl_awm ( struct video_state *svsp );
 1312: void	toggl_bell ( struct video_state *svsp );
 1313: void	toggl_columns ( struct video_state *svsp );
 1314: void	toggl_dspf ( struct video_state *svsp );
 1315: void	toggl_sevenbit ( struct video_state *svsp );
 1316: void 	update_hp ( struct video_state *svsp );
 1317: void	update_led ( void );
 1318: void	vga10_vga10 ( u_char *invga, u_char *outvga );
 1319: void	vga10_vga14 ( u_char *invga, u_char *outvga );
 1320: void	vga10_vga16 ( u_char *invga, u_char *outvga );
 1321: void	vga10_vga8 ( u_char *invga, u_char *outvga );
 1322: u_char	vga_chipset ( void );
 1323: int	vga_col ( struct video_state *svsp, int cols );
 1324: void	vga_screen_off ( void );
 1325: void	vga_screen_on ( void );
 1326: char   *vga_string ( int number );
 1327: int	vga_test ( void );
 1328: int	vgaioctl ( Dev_t dev, int cmd, caddr_t data, int flag );
 1329: void	vgapaletteio ( unsigned idx, struct rgb *val, int writeit );
 1330: void	vt_aln ( struct video_state *svsp );
 1331: void	vt_clearudk ( struct video_state *svsp );
 1332: void	vt_clreol ( struct video_state *svsp );
 1333: void	vt_clreos ( struct video_state *svsp );
 1334: void	vt_clrtab ( struct video_state *svsp );
 1335: int	vt_col ( struct video_state *svsp, int cols );
 1336: void	vt_coldmalloc ( void );
 1337: void	vt_cub ( struct video_state *svsp );
 1338: void	vt_cud ( struct video_state *svsp );
 1339: void	vt_cuf ( struct video_state *svsp );
 1340: void	vt_curadr ( struct video_state *svsp );
 1341: void	vt_cuu ( struct video_state *svsp );
 1342: void	vt_da ( struct video_state *svsp );
 1343: void	vt_dch ( struct video_state *svsp );
 1344: void	vt_dcsentry ( U_char ch, struct video_state *svsp );
 1345: void	vt_designate ( struct video_state *svsp);
 1346: void	vt_dl ( struct video_state *svsp );
 1347: void	vt_dld ( struct video_state *svsp );
 1348: void	vt_dsr ( struct video_state *svsp );
 1349: void	vt_ech ( struct video_state *svsp );
 1350: void	vt_ic ( struct video_state *svsp );
 1351: void	vt_il ( struct video_state *svsp );
 1352: void	vt_ind ( struct video_state *svsp );
 1353: void	vt_initsel ( struct video_state *svsp );
 1354: void	vt_keyappl ( struct video_state *svsp );
 1355: void	vt_keynum ( struct video_state *svsp );
 1356: void	vt_mc ( struct video_state *svsp );
 1357: void	vt_nel ( struct video_state *svsp );
 1358: void	vt_rc ( struct video_state *svsp );
 1359: void	vt_reqtparm ( struct video_state *svsp );
 1360: void	vt_reset_ansi ( struct video_state *svsp );
 1361: void	vt_reset_dec_priv_qm ( struct video_state *svsp );
 1362: void	vt_ri ( struct video_state *svsp );
 1363: void	vt_ris ( struct video_state *svsp );
 1364: void	vt_sc ( struct video_state *svsp );
 1365: void	vt_sca ( struct video_state *svsp );
 1366: void	vt_sd ( struct video_state *svsp );
 1367: void	vt_sed ( struct video_state *svsp );
 1368: void	vt_sel ( struct video_state *svsp );
 1369: void	vt_set_ansi ( struct video_state *svsp );
 1370: void	vt_set_dec_priv_qm ( struct video_state *svsp );
 1371: void	vt_sgr ( struct video_state *svsp );
 1372: void	vt_stbm ( struct video_state *svsp );
 1373: void	vt_str ( struct video_state *svsp );
 1374: void	vt_su ( struct video_state *svsp );
 1375: void	vt_tst ( struct video_state *svsp );
 1376: void	vt_udk ( struct video_state *svsp );
 1377: void	toggl_24l ( struct video_state *svsp );
 1378: 
 1379: #ifdef PCVT_INCLUDE_VT_SELATTR
 1380: 
 1381: #define INT_BITS	(sizeof(unsigned int) * 8)
 1382: #define INT_INDEX(n)	((n) / INT_BITS)
 1383: #define BIT_INDEX(n)	((n) % INT_BITS)
 1384: 
 1385: /*---------------------------------------------------------------------------*
 1386:  *	set selective attribute if appropriate
 1387:  *---------------------------------------------------------------------------*/
 1388: static __inline void vt_selattr(struct video_state *svsp)
 1389: {
 1390: 	int i;
 1391: 
 1392: 	i = (svsp->Crtat + svsp->cur_offset) - svsp->Crtat;
 1393: 
 1394: 	if(svsp->selchar)
 1395: 		svsp->decsca[INT_INDEX(i)] |=  (1 << BIT_INDEX(i));
 1396: 	else
 1397: 		svsp->decsca[INT_INDEX(i)] &= ~(1 << BIT_INDEX(i));
 1398: }
 1399: 
 1400: #endif /* PCVT_INCLUDE_VT_SELATTR */
 1401: 
 1402: 
 1403: /*---------------------------------------------------------------------------*
 1404:  *	produce 7 us delay accessing the keyboard controller
 1405:  *---------------------------------------------------------------------------*/
 1406: 
 1407: #if PCVT_PORTIO_DELAY
 1408: 				/* use multiple dummy accesses to port    */
 1409: 				/* 0x84 to produce keyboard controller    */
 1410: 				/* access delays                          */
 1411: #define PCVT_KBD_DELAY()          \
 1412: 	{ (void)inb(0x84); } \
 1413: 	{ (void)inb(0x84); } \
 1414: 	{ (void)inb(0x84); } \
 1415: 	{ (void)inb(0x84); } \
 1416: 	{ (void)inb(0x84); } \
 1417: 	{ (void)inb(0x84); }
 1418: 
 1419: #else /* PCVT_PORTIO_DELAY */
 1420: 				/* use system supplied delay function for */
 1421: 				/* producing delays for accesssing the    */
 1422: 				/* keyboard controller                    */
 1423: #if PCVT_NETBSD > 9
 1424: #define PCVT_KBD_DELAY()	delay(7)
 1425: #elif PCVT_FREEBSD || (PCVT_NETBSD <= 9)
 1426: #define PCVT_KBD_DELAY()	DELAY(7)
 1427: #endif
 1428: #endif /* PCVT_PORTIO_DELAY */
 1429: 
 1430: /*---------------------------------- E O F ----------------------------------*/