]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - 6/sys/i386/isa/pcvt/pcvt_hdr.h
merge fix for boot-time hang on centos' xen
[FreeBSD/FreeBSD.git] / 6 / sys / i386 / isa / pcvt / pcvt_hdr.h
1 /*-
2  * Copyright (c) 1999, 2000 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: [Wed Apr  5 18:21:32 2000]
43  *
44  * $FreeBSD$
45  *
46  *---------------------------------------------------------------------------*/
47
48 #define PCVT_REL "3.60"         /* driver attach announcement   */
49                                 /* see also: pcvt_ioctl.h       */
50
51 #include "opt_pcvt.h"
52
53 #include <sys/param.h>
54 #include <sys/systm.h>
55 #include <sys/callout.h>
56 #include <sys/conf.h>
57 #include <sys/cons.h>
58 #include <sys/kdb.h>
59 #include <sys/kernel.h>
60 #include <sys/module.h>
61 #include <sys/lock.h>
62 #include <sys/malloc.h>
63 #include <sys/mutex.h>
64 #include <sys/proc.h>
65 #include <sys/random.h>
66 #include <sys/signalvar.h>
67 #include <sys/syslog.h>
68 #include <sys/time.h>
69 #include <sys/tty.h>
70 #include <sys/uio.h>
71
72 #include <machine/bus.h>
73 #include <machine/psl.h>
74 #include <machine/frame.h>
75 #include <machine/pcvt_ioctl.h>
76 #include <machine/pc/display.h>
77 #include <machine/clock.h>
78 #include <machine/md_var.h>
79 #include <machine/stdarg.h>
80
81 #include <dev/kbd/kbdreg.h>
82 #include <dev/atkbdc/atkbdcreg.h>
83
84 #include <i386/isa/pcvt/pcvt_conf.h>
85
86 /*===========================================================================*
87  *      definitions
88  *===========================================================================*/
89
90 #define PCVT_KBD_FIFO_SZ        256     /* keyboard fifo size */
91 #define PCVT_PCBURST            256     /* # of burst out chars */
92 #define SCROLLBACK_PAGES        8       /* scrollback buffer pages */
93 #define SCROLLBACK_COOKIE       31337   /* scrollback buffer pages */
94 #define PCVT_NONRESP_KEYB_TRY   25      /* no of times to try to detect */
95                                         /* a nonresponding keyboard     */
96
97 /*
98  * The following values are defined in sys/kbio.h, but the header
99  * file is not included here due to conflicts with pcvt_ioctl.h.
100  * XXX: Still relevant ?
101  */
102 #define KDGKBTYPE       _IOR('K', 64, int)
103 #define KB_84           1
104 #define KB_101          2
105 #define KB_OTHER        3
106
107 /* setup irq disable function to use */
108
109 #if !(PCVT_SLOW_INTERRUPT)
110 # define PCVT_DISABLE_INTR()    disable_intr()
111 # define PCVT_ENABLE_INTR()     enable_intr()
112 # undef PCVT_SLOW_INTERRUPT
113 #else
114 # define PCVT_DISABLE_INTR()    s = spltty()
115 # define PCVT_ENABLE_INTR()     splx(s)
116 # undef PCVT_SLOW_INTERRUPT
117 # define PCVT_SLOW_INTERRUPT 1
118 #endif
119
120 #ifdef XSERVER
121
122 /* PCVT_NULLCHARS is mandatory for X server */
123
124 #undef PCVT_NULLCHARS
125 #define PCVT_NULLCHARS 1
126
127 #endif /* XSERVER */
128
129 /* PCVT_SCREENSAVER is mandatory for PCVT_PRETTYSCRNS */
130
131 #if PCVT_PRETTYSCRNS && !PCVT_SCREENSAVER
132 #undef PCVT_SCREENSAVER
133 #define PCVT_SCREENSAVER 1
134 #endif
135
136 #if PCVT_SCANSET !=1 && PCVT_SCANSET !=2
137 #error "Supported keyboard scancode sets are 1 and 2 only (for now)!!!"
138 #endif
139
140 /*---------------------------------------------------------------------------*
141  *      keyboard
142  *---------------------------------------------------------------------------*/
143
144 /* responses from the KEYBOARD (via the 8042 controller on mainboard..) */
145
146 #define KEYB_R_OVERRUN0 0x00    /* keyboard buffer overflow */
147 #define KEYB_R_SELFOK   0xaa    /* keyboard selftest ok after KEYB_C_RESET */
148 #define KEYB_R_EXT0     0xe0    /* keyboard extended scancode prefix 1 */
149 #define KEYB_R_EXT1     0xe1    /* keyboard extended scancode prefix 2 */
150 #define KEYB_R_ECHO     0xee    /* keyboard response to KEYB_C_ECHO */
151 #define KEYB_R_BREAKPFX 0xf0    /* break code prefix for set 2 and 3 */
152 #define KEYB_R_ACK      0xfa    /* acknowledge after a command has rx'd */
153 #define KEYB_R_SELFBAD  0xfc    /*keyboard selftest FAILED after KEYB_C_RESET*/
154 #define KEYB_R_DIAGBAD  0xfd    /* keyboard self diagnostic failure */
155 #define KEYB_R_RESEND   0xfe    /* keyboard wants command resent or illegal
156                                  * command rx'd */
157 #define KEYB_R_OVERRUN1 0xff    /* keyboard buffer overflow */
158
159 #define KEYB_R_MF2ID1   0xab    /* MF II Keyboard id-byte #1 */
160 #define KEYB_R_MF2ID2   0x41    /* MF II Keyboard id-byte #2 */
161 #define KEYB_R_MF2ID2HP 0x83    /* MF II Keyboard id-byte #2 from HP keybd's */
162
163 /* internal Keyboard Type */
164
165 #define KB_UNKNOWN      0       /* unknown keyboard type */
166 #define KB_AT           1       /* AT (84 keys) Keyboard */
167 #define KB_MFII         2       /* MF II (101/102 keys) Keyboard */
168
169 /*---------------------------------------------------------------------------*
170  *      CMOS ram access to get the "Equipment Byte"
171  *---------------------------------------------------------------------------*/
172
173 #define RTC_EQUIPMENT   0x14    /* equipment byte in cmos ram   */
174 #define EQ_EGAVGA       0       /* reserved (= ega/vga)         */
175 #define EQ_40COLOR      1       /* display = 40 col color       */
176 #define EQ_80COLOR      2       /* display = 80 col color       */
177 #define EQ_80MONO       3       /* display = 80 col mono        */
178
179 /*---------------------------------------------------------------------------*
180  *      VT220 -> internal color conversion table fields
181  *---------------------------------------------------------------------------*/
182
183 #define VT_NORMAL       0x00            /* no attributes at all */
184 #define VT_BOLD         0x01            /* bold attribute */
185 #define VT_UNDER        0x02            /* underline attribute */
186 #define VT_BLINK        0x04            /* blink attribute */
187 #define VT_INVERSE      0x08            /* inverse attribute */
188
189 /*---------------------------------------------------------------------------*
190  *      VGA GENERAL/EXTERNAL Registers          (3BA or 3DA and 3CA, 3C2, 3CC)
191  *---------------------------------------------------------------------------*/
192
193 #define GN_MISCOUTR     0x3CC           /* misc output register read */
194 #define GN_MISCOUTW     0x3C2           /* misc output register write */
195 #define GN_INPSTAT0     0x3C2           /* input status 0, r/o */
196 #define GN_INPSTAT1M    0x3BA           /* input status 1, r/o, mono */
197 #define GN_INPSTAT1C    0x3DA           /* input status 1, r/o, color */
198 #define GN_FEATR        0x3CA           /* feature control, read */
199 #define GN_FEATWM       0x3BA           /* feature control, write, mono */
200 #define GN_FEATWC       0x3DA           /* feature control, write, color */
201 #define GN_VSUBSYS      0x3C3           /* video subsystem register r/w */
202 #define GN_DMCNTLM      0x3B8           /* display mode control, r/w, mono */
203 #define GN_DMCNTLC      0x3D8           /* display mode control, r/w, color */
204 #define GN_COLORSEL     0x3D9           /* color select register, w/o */
205 #define GN_HERCOMPAT    0x3BF           /* Hercules compatibility reg, w/o */
206
207 /*---------------------------------------------------------------------------*
208  *      VGA CRTC Registers                        (3B4 and 3B5 or 3D4 and 3D5)
209  *---------------------------------------------------------------------------*/
210
211 #define MONO_BASE       0x3B4           /* crtc index register address mono */
212 #define CGA_BASE        0x3D4           /* crtc index register address color */
213
214 #define CRTC_ADDR       0x00            /* index register */
215
216 #define CRTC_HTOTAL     0x00            /* horizontal total */
217 #define CRTC_HDISPLE    0x01            /* horizontal display end */
218 #define CRTC_HBLANKS    0x02            /* horizontal blank start */
219 #define CRTC_HBLANKE    0x03            /* horizontal blank end */
220 #define CRTC_HSYNCS     0x04            /* horizontal sync start */
221 #define CRTC_HSYNCE     0x05            /* horizontal sync end */
222 #define CRTC_VTOTAL     0x06            /* vertical total */
223 #define CRTC_OVERFLL    0x07            /* overflow low */
224 #define CRTC_IROWADDR   0x08            /* inital row address */
225 #define CRTC_MAXROW     0x09            /* maximum row address */
226 #define CRTC_CURSTART   0x0A            /* cursor start row address */
227 #define         CURSOR_ON_BIT 0x20      /* cursor on/off on mda/cga/vga */
228 #define CRTC_CUREND     0x0B            /* cursor end row address */
229 #define CRTC_STARTADRH  0x0C            /* linear start address mid */
230 #define CRTC_STARTADRL  0x0D            /* linear start address low */
231 #define CRTC_CURSORH    0x0E            /* cursor address mid */
232 #define CRTC_CURSORL    0x0F            /* cursor address low */
233 #define CRTC_VSYNCS     0x10            /* vertical sync start */
234 #define CRTC_VSYNCE     0x11            /* vertical sync end */
235 #define CRTC_VDE        0x12            /* vertical display end */
236 #define CRTC_OFFSET     0x13            /* row offset */
237 #define CRTC_ULOC       0x14            /* underline row address */
238 #define CRTC_VBSTART    0x15            /* vertical blank start */
239 #define CRTC_VBEND      0x16            /* vertical blank end */
240 #define CRTC_MODE       0x17            /* CRTC mode register */
241 #define CRTC_SPLITL     0x18            /* split screen start low */
242
243 /* start of ET4000 extensions */
244
245 #define CRTC_RASCAS     0x32            /* ras/cas configuration */
246 #define CRTC_EXTSTART   0x33            /* extended start address */
247 #define CRTC_COMPAT6845 0x34            /* 6845 comatibility control */
248 #define CRTC_OVFLHIGH   0x35            /* overflow high */
249 #define CRTC_SYSCONF1   0x36            /* video system configuration 1 */
250 #define CRTC_SYSCONF2   0x36            /* video system configuration 2 */
251
252 /* start of WD/Paradise extensions */
253
254 #define CRTC_PR10       0x29            /* r/w unlocking */
255 #define CRTC_PR11       0x2A            /* ega switches */
256 #define CRTC_PR12       0x2B            /* scratch pad */
257 #define CRTC_PR13       0x2C            /* interlace h/2 start */
258 #define CRTC_PR14       0x2D            /* interlace h/2 end */
259 #define CRTC_PR15       0x2E            /* misc control #1 */
260 #define CRTC_PR16       0x2F            /* misc control #2 */
261 #define CRTC_PR17       0x30            /* misc control #3 */
262                                         /* 0x31 .. 0x3f reserved */
263 /* Video 7 */
264
265 #define CRTC_V7ID       0x1f            /* identification register */
266
267 /* Trident */
268
269 #define CRTC_MTEST      0x1e            /* module test register */
270 #define CRTC_SOFTPROG   0x1f            /* software programming */
271 #define CRTC_LATCHRDB   0x22            /* latch read back register */
272 #define CRTC_ATTRSRDB   0x24            /* attribute state read back register*/
273 #define CRTC_ATTRIRDB   0x26            /* attribute index read back register*/
274 #define CRTC_HOSTAR     0x27            /* high order start address register */
275
276 /*---------------------------------------------------------------------------*
277  *      VGA TIMING & SEQUENCER Registers                         (3C4 and 3C5)
278  *---------------------------------------------------------------------------*/
279
280 #define TS_INDEX        0x3C4           /* index register */
281 #define TS_DATA         0x3C5           /* data register */
282
283 #define TS_SYNCRESET    0x00            /* synchronous reset */
284 #define TS_MODE         0x01            /* ts mode register */
285 #define TS_WRPLMASK     0x02            /* write plane mask */
286 #define TS_FONTSEL      0x03            /* font select register */
287 #define TS_MEMMODE      0x04            /* memory mode register */
288
289 /* ET4000 only */
290
291 #define TS_RESERVED     0x05            /* undef, reserved */
292 #define TS_STATECNTL    0x06            /* state control register */
293 #define TS_AUXMODE      0x07            /* auxiliary mode control */
294
295 /* WD/Paradise only */
296
297 #define TS_UNLOCKSEQ    0x06            /* PR20 - unlock sequencer register */
298 #define TS_DISCFSTAT    0x07            /* PR21 - display config status */
299 #define TS_MEMFIFOCTL   0x10            /* PR30 - memory i/f & fifo control */
300 #define TS_SYSIFCNTL    0x11            /* PR31 - system interface control */
301 #define TS_MISC4        0x12            /* PR32 - misc control #4 */
302
303 /* Video 7 */
304
305 #define TS_EXTCNTL      0x06            /* extensions control */
306 #define TS_CLRVDISP     0x30            /* clear vertical display 0x30-0x3f */
307 #define TS_V7CHIPREV    0x8e            /* chipset revision 0x8e-0x8f */
308 #define TS_SWBANK       0xe8            /* single/write bank register, rev 5+*/
309 #define TS_RDBANK       0xe8            /* read bank register, rev 4+ */
310 #define TS_MISCCNTL     0xe8            /* misc control register, rev 4+ */
311 #define TS_SWSTROBE     0xea            /* switch strobe */
312 #define TS_MWRCNTL      0xf3            /* masked write control */
313 #define TS_MWRMVRAM     0xf4            /* masked write mask VRAM only */
314 #define TS_BANKSEL      0xf6            /* bank select */
315 #define TS_SWREADB      0xf7            /* switch readback */
316 #define TS_PAGESEL      0xf9            /* page select */
317 #define TS_COMPAT       0xfc            /* compatibility control */
318 #define TS_16BITCTL     0xff            /* 16 bit interface control */
319
320 /* Trident */
321
322 #define TS_HWVERS       0x0b            /* hardware version, switch old/new! */
323 #define TS_CONFPORT1    0x0c            /* config port 1 and 2    - caution! */
324 #define TS_MODEC2       0x0d            /* old/new mode control 2 - caution! */
325 #define TS_MODEC1       0x0e            /* old/new mode control 1 - caution! */
326 #define TS_PUPM2        0x0f            /* power up mode 2 */
327
328 /*---------------------------------------------------------------------------*
329  *      VGA GRAPHICS DATA CONTROLLER Registers              (3CE, 3CF and 3CD)
330  *---------------------------------------------------------------------------*/
331
332 #define GDC_SEGSEL      0x3CD           /* segment select register */
333 #define GDC_INDEX       0x3CE           /* index register */
334 #define GDC_DATA        0x3CF           /* data register */
335
336 #define GDC_SETRES      0x00            /* set / reset bits */
337 #define GDC_ENSETRES    0x01            /* enable set / reset */
338 #define GDC_COLORCOMP   0x02            /* color compare register */
339 #define GDC_ROTFUNC     0x03            /* data rotate / function select */
340 #define GDC_RDPLANESEL  0x04            /* read plane select */
341 #define GDC_MODE        0x05            /* gdc mode register */
342 #define GDC_MISC        0x06            /* gdc misc register */
343 #define GDC_COLORCARE   0x07            /* color care register */
344 #define GDC_BITMASK     0x08            /* bit mask register */
345
346 /* WD/Paradise only */
347
348 #define GDC_BANKSWA     0x09            /* PR0A - bank switch a */
349 #define GDC_BANKSWB     0x0a            /* PR0B - bank switch b */
350 #define GDC_MEMSIZE     0x0b            /* PR1 memory size */
351 #define GDC_VIDEOSEL    0x0c            /* PR2 video configuration */
352 #define GDC_CRTCNTL     0x0d            /* PR3 crt address control */
353 #define GDC_VIDEOCNTL   0x0e            /* PR4 video control */
354 #define GDC_PR5GPLOCK   0x0f            /* PR5 gp status and lock */
355
356 /* Video 7 */
357
358 #define GDC_DATALATCH   0x22            /* gdc data latch */
359
360 /*---------------------------------------------------------------------------*
361  *      VGA ATTRIBUTE CONTROLLER Registers                       (3C0 and 3C1)
362  *---------------------------------------------------------------------------*/
363
364 #define ATC_INDEX       0x3C0           /* index register  AND  */
365 #define ATC_DATAW       0x3C0           /* data write      !!!  */
366 #define ATC_DATAR       0x3C1           /* data read */
367
368 #define ATC_ACCESS      0x20            /* access bit in ATC index register */
369
370 #define ATC_PALETTE0    0x00            /* color palette register 0 */
371 #define ATC_PALETTE1    0x01            /* color palette register 1 */
372 #define ATC_PALETTE2    0x02            /* color palette register 2 */
373 #define ATC_PALETTE3    0x03            /* color palette register 3 */
374 #define ATC_PALETTE4    0x04            /* color palette register 4 */
375 #define ATC_PALETTE5    0x05            /* color palette register 5 */
376 #define ATC_PALETTE6    0x06            /* color palette register 6 */
377 #define ATC_PALETTE7    0x07            /* color palette register 7 */
378 #define ATC_PALETTE8    0x08            /* color palette register 8 */
379 #define ATC_PALETTE9    0x09            /* color palette register 9 */
380 #define ATC_PALETTEA    0x0A            /* color palette register 10 */
381 #define ATC_PALETTEB    0x0B            /* color palette register 11 */
382 #define ATC_PALETTEC    0x0C            /* color palette register 12 */
383 #define ATC_PALETTED    0x0D            /* color palette register 13 */
384 #define ATC_PALETTEE    0x0E            /* color palette register 14 */
385 #define ATC_PALETTEF    0x0F            /* color palette register 15 */
386 #define ATC_MODE        0x10            /* atc mode register */
387 #define ATC_OVERSCAN    0x11            /* overscan register */
388 #define ATC_COLPLEN     0x12            /* color plane enable register */
389 #define ATC_HORPIXPAN   0x13            /* horizontal pixel panning */
390 #define ATC_COLRESET    0x14            /* color reset */
391 #define ATC_MISC        0x16            /* misc register (ET3000/ET4000) */
392
393 /*---------------------------------------------------------------------------*
394  *      VGA palette handling (output DAC palette)
395  *---------------------------------------------------------------------------*/
396
397 #define VGA_DAC         0x3C6           /* vga dac address */
398 #define VGA_PMSK        0x3F            /* palette mask, 64 distinct values */
399 #define NVGAPEL         256             /* number of palette entries */
400
401 /*---------------------------------------------------------------------------*
402  *      function key labels
403  *---------------------------------------------------------------------------*/
404
405 #define LABEL_LEN       9               /* length of one label */
406 #define LABEL_MID       8               /* mid-part (row/col)   */
407
408 #define LABEL_ROWH      ((4*LABEL_LEN)+1)
409 #define LABEL_ROWL      ((4*LABEL_LEN)+2)
410 #define LABEL_COLU      ((4*LABEL_LEN)+4)
411 #define LABEL_COLH      ((4*LABEL_LEN)+5)
412 #define LABEL_COLL      ((4*LABEL_LEN)+6)
413
414 /* tab setting */
415
416 #define MAXTAB 132              /* no of possible tab stops */
417
418 /* escape detection state machine */
419
420 #define STATE_INIT      0       /* normal       */
421 #define STATE_ESC       1       /* got ESC      */
422 #define STATE_BLANK     2       /* got ESC space*/
423 #define STATE_HASH      3       /* got ESC #    */
424 #define STATE_BROPN     4       /* got ESC (    */
425 #define STATE_BRCLO     5       /* got ESC )    */
426 #define STATE_CSI       6       /* got ESC [    */
427 #define STATE_CSIQM     7       /* got ESC [ ?  */
428 #define STATE_AMPSND    8       /* got ESC &    */
429 #define STATE_STAR      9       /* got ESC *    */
430 #define STATE_PLUS      10      /* got ESC +    */
431 #define STATE_DCS       11      /* got ESC P    */
432 #define STATE_SCA       12      /* got ESC <Ps> " */
433 #define STATE_STR       13      /* got ESC !    */
434 #define STATE_MINUS     14      /* got ESC -    */
435 #define STATE_DOT       15      /* got ESC .    */
436 #define STATE_SLASH     16      /* got ESC /    */
437
438 /* for storing escape sequence parameters */
439
440 #define MAXPARMS        10      /* maximum no of parms */
441
442 /* terminal responses */
443
444 #define DA_VT220        "\033[?62;1;2;6;7;8;9c"
445
446 /* sub-states for Device Control String processing */
447
448 #define DCS_INIT        0       /* got ESC P ... */
449 #define DCS_AND_UDK     1       /* got ESC P ... | */
450 #define DCS_UDK_DEF     2       /* got ESC P ... | fnckey / */
451 #define DCS_UDK_ESC     3       /* got ESC P ... | fnckey / ... ESC */
452 #define DCS_DLD_DSCS    4       /* got ESC P ... { */
453 #define DCS_DLD_DEF     5       /* got ESC P ... { dscs */
454 #define DCS_DLD_ESC     6       /* got ESC P ... { dscs ... / ... ESC */
455
456 /* vt220 user defined keys and vt220 downloadable charset */
457
458 #define MAXUDKDEF       300     /* max 256 char + 1 '\0' + space.. */
459 #define MAXUDKEYS       18      /* plus holes .. */
460 #define DSCS_LENGTH     3       /* descriptor length */
461 #define MAXSIXEL        8       /* sixels forever ! */
462
463 /* sub-states for HP-terminal emulator */
464
465 #define SHP_INIT        0
466
467 /* esc & f family */
468
469 #define SHP_AND_F       1
470 #define SHP_AND_Fa      2
471 #define SHP_AND_Fak     3
472 #define SHP_AND_Fak1    4
473 #define SHP_AND_Fakd    5
474 #define SHP_AND_FakdL   6
475 #define SHP_AND_FakdLl  7
476 #define SHP_AND_FakdLls 8
477
478 /* esc & j family */
479
480 #define SHP_AND_J       9
481 #define SHP_AND_JL      10
482
483 /* esc & every-thing-else */
484
485 #define SHP_AND_ETE     11
486
487 /* additionals for function key labels */
488
489 #define MAX_LABEL       16
490 #define MAX_STRING      80
491 #define MAX_STATUS      160
492
493 /* MAX values for screen sizes for possible video adaptors */
494
495 #define MAXROW_MDACGA   25              /* MDA/CGA can do 25 x 80 max */
496 #define MAXCOL_MDACGA   80
497
498 #define MAXROW_EGA      43              /* EGA can do 43 x 80 max */
499 #define MAXCOL_EGA      80
500
501 #define MAXROW_VGA      50              /* VGA can do 50 x 80 max */
502 #define MAXCOL_VGA      80
503 #define MAXCOL_SVGA     132             /* Super VGA can do 50 x 132 max */
504
505 /* switch 80/132 columns */
506
507 #define SCR_COL80       80              /* in 80 col mode */
508 #define SCR_COL132      132             /* in 132 col mode */
509
510 #define MAXDECSCA       (((MAXCOL_SVGA * MAXROW_VGA) \
511                         / (8 * sizeof(unsigned int)) ) + 1 )
512
513 /* screen memory start, monochrome */
514
515 #ifndef MONO_BUF
516 #define MONO_BUF        (KERNBASE+0xB0000)
517 #endif
518
519 /* screen memory start, color */
520
521 #ifndef CGA_BUF
522 #define CGA_BUF         (KERNBASE+0xB8000)
523 #endif
524
525 #define CHR             2               /* bytes per word in screen mem */
526
527 #define NVGAFONTS       8               /* number of vga fonts loadable */
528
529 #define MAXKEYNUM       127             /* max no of keys in table */
530
531 /* charset tables */
532
533 #define CSL     0x0000          /* ega/vga charset, lower half of 512 */
534 #define CSH     0x0800          /* ega/vga charset, upper half of 512 */
535 #define CSSIZE  96              /* (physical) size of a character set */
536
537 /* charset designations */
538
539 #define D_G0            0       /* designated as G0 */
540 #define D_G1            1       /* designated as G1 */
541 #define D_G2            2       /* designated as G2 */
542 #define D_G3            3       /* designated as G3 */
543 #define D_G1_96         4       /* designated as G1 for 96-char charsets */
544 #define D_G2_96         5       /* designated as G2 for 96-char charsets */
545 #define D_G3_96         6       /* designated as G3 for 96-char charsets */
546
547 /* which fkey-labels */
548
549 #define SYS_FKL         0       /* in hp mode, sys-fkls are active */
550 #define USR_FKL         1       /* in hp mode, user-fkls are active */
551
552 /* arguments to async_update() */
553
554 #define UPDATE_START    ((void *)0)     /* do cursor update and requeue */
555 #define UPDATE_STOP     ((void *)1)     /* suspend cursor updates */
556 #define UPDATE_KERN     ((void *)2)     /* do cursor updates for kernel output */
557
558
559 /*===========================================================================*
560  *      variables
561  *===========================================================================*/
562
563 #ifdef MAIN
564 # define EXTERN /* actually define variables when included from pcvt_drv.c */
565 #else
566 # define EXTERN extern                  /* declare them only */
567 #endif
568
569 EXTERN u_char   *more_chars;            /* response buffer via kbd */
570 EXTERN u_char   color;                  /* color or mono display */
571
572 EXTERN u_short  kern_attr;              /* kernel messages char attributes */
573 EXTERN u_short  user_attr;              /* character attributes */
574
575 EXTERN struct tty *pcvt_tty[PCVT_NSCREENS];
576
577 struct sixels {
578         u_char lower[MAXSIXEL];         /* lower half of char */
579         u_char upper[MAXSIXEL];         /* upper half of char */
580 };
581
582 struct udkentry {
583         u_short first[MAXUDKEYS];       /* index to first char */
584         u_char  length[MAXUDKEYS];      /* length of this entry */
585 };
586
587 /* VGA palette handling */
588 struct rgb {
589         u_char  r, g, b;                /* red/green/blue, valid 0..VGA_PMSK */
590 };
591
592 typedef struct video_state {
593         u_short *Crtat;                 /* video page start addr */
594         u_short *Memory;                /* malloc'ed memory start address */
595         struct tty *vs_tty;             /* pointer to this screen's tty */
596         u_char  maxcol;                 /* 80 or 132 cols on screen */
597         u_char  row, col;               /* current cursor position */
598         u_short c_attr;                 /* current character attributes */
599         u_char  vtsgr;                  /* current sgr configuration */
600         u_short cur_offset;             /* current cursor position offset */
601         u_char  bell_on;                /* flag, bell enabled */
602         u_char  sevenbit;               /* flag, data path 7 bits wide */
603         u_char  dis_fnc;                /* flag, display functions enable */
604         u_char  transparent;            /* flag, mk path tmp trnsprnt for ctls*/
605         u_char  scrr_beg;               /* scrolling region, begin */
606         u_char  scrr_len;               /* scrolling region, length */
607         u_char  scrr_end;               /* scrolling region, end */
608         u_char  screen_rows;            /* screen size, length - status lines */
609         u_char  screen_rowsize;         /* screen size, length */
610         u_char  vga_charset;            /* VGA character set value */
611         u_char  lastchar;               /* flag, vt100 behaviour of last char */
612         u_char  lastrow;                /* save row, --------- " -----------  */
613         u_char  *report_chars;          /* ptr, status reports from terminal */
614         u_char  report_count;           /* count, ----------- " ------------ */
615         u_char  state;                  /* escape sequence state machine */
616         u_char  m_awm;                  /* flag, vt100 mode, auto wrap */
617         u_char  m_om;                   /* flag, vt100 mode, origin mode */
618         u_char  sc_flag;                /* flag, vt100 mode,saved parms valid */
619         u_char  sc_row;                 /* saved row */
620         u_char  sc_col;                 /* saved col */
621         u_short sc_cur_offset;          /* saved cursor addr offset */
622         u_short sc_attr;                /* saved attributes */
623         u_char  sc_vtsgr;               /* saved sgr configuration */
624         u_char  sc_awm;                 /* saved auto wrap mode */
625         u_char  sc_om;                  /* saved origin mode */
626         u_short *sc_G0;                 /* save G0 ptr */
627         u_short *sc_G1;                 /* save G1 ptr */
628         u_short *sc_G2;                 /* save G2 ptr */
629         u_short *sc_G3;                 /* save G3 ptr */
630         u_short **sc_GL;                /* save GL ptr */
631         u_short **sc_GR;                /* save GR ptr */
632         u_char  sc_sel;                 /* selective erase state */
633         u_char  ufkl[8][17];            /* user fkey-labels */
634         u_char  sfkl[8][17];            /* system fkey-labels */
635         u_char  labels_on;              /* display fkey labels etc. on/off */
636         u_char  which_fkl;              /* which fkey labels are active */
637         char    tab_stops[MAXTAB];      /* table of active tab stops */
638         u_char  parmi;                  /* parameter index */
639         u_char  parms[MAXPARMS];        /* parameter array */
640         u_char  hp_state;               /* hp escape sequence state machine */
641         u_char  attribute;              /* attribute normal, tx only, local */
642         u_char  key;                    /* fkey label no */
643         u_char  l_len;                  /* buffer length's */
644         u_char  s_len;
645         u_char  m_len;
646         u_char  i;                      /* help (got short of names ...) */
647         u_char  l_buf[MAX_LABEL+1];     /* buffers */
648         u_char  s_buf[MAX_STRING+1];
649         u_char  m_buf[MAX_STATUS+1];
650         u_char  openf;                  /* we are opened ! */
651         u_char  vt_pure_mode;           /* no fkey labels, row/col, status */
652         u_char  cursor_start;           /* Start of cursor */
653         u_char  cursor_end;             /* End of cursor */
654         u_char  cursor_on;              /* cursor switched on */
655         u_char  ckm;                    /* true = cursor key normal mode */
656         u_char  irm;                    /* true = insert mode */
657         u_char  lnm;                    /* Line Feed/New Line Mode */
658         u_char  dcs_state;              /* dcs escape sequence state machine */
659         u_char  udk_def[MAXUDKDEF];     /* new definitions for vt220 FKeys */
660         u_short udk_defi;               /* index for FKey definitions */
661         u_char  udk_deflow;             /* low or high nibble in sequence */
662         u_char  udk_fnckey;             /* function key to assign to */
663         u_char  dld_dscs[DSCS_LENGTH];  /* designate soft character set id */
664         u_char  dld_dscsi;              /* index for dscs */
665         u_char  dld_sixel_lower;        /* upper/lower sixels of character */
666         u_char  dld_sixelli;            /* index for lower sixels */
667         u_char  dld_sixelui;            /* index for upper sixels */
668         struct sixels sixel;            /* structure for storing char sixels */
669         u_char  selchar;                /* true = selective attribute on */
670         u_int   decsca[MAXDECSCA];      /* Select Character Attrib bit array */
671         u_short **GL;                   /* ptr to current GL conversion table*/
672         u_short **GR;                   /* ptr to current GR conversion table*/
673         u_short *G0;                    /* ptr to current G0 conversion table*/
674         u_short *G1;                    /* ptr to current G1 conversion table*/
675         u_char force24;                 /* force 24 lines in DEC 25 and HP 28*/
676         u_short *G2;                    /* ptr to current G2 conversion table*/
677         u_short *G3;                    /* ptr to current G3 conversion table*/
678         u_char  dld_id[DSCS_LENGTH+1];  /* soft character set id */
679         u_char  which[DSCS_LENGTH+1];   /* which set to designate */
680         u_char  whichi;                 /* index into which ..  */
681         u_char  ss;                     /* flag, single shift G2 / G3 -> GL */
682         u_short **Gs;                   /* ptr to cur. G2/G3 conversion table*/
683         u_char  udkbuf[MAXUDKDEF];      /* buffer for user defined keys */
684         struct udkentry ukt;            /* index & length for each udk */
685         u_short udkff;                  /* index into buffer first free entry*/
686         struct rgb palette[NVGAPEL];    /* saved VGA DAC palette */
687         u_char  wd132col;               /* we are on a wd vga and in 132 col */
688         u_char  scroll_lock;            /* scroll lock active */
689         u_char  caps_lock;              /* caps lock active */
690         u_char  shift_lock;             /* shiftlock flag (virtual ..) */
691         u_char  num_lock;               /* num lock, true = keypad num mode */
692         u_char  abs_write;              /* write outside of scroll region */
693
694         u_short *Scrollback;            /* scrollback buffer */
695         u_short scrollback_pages;       /* size of scrollback buffer */
696         u_short scr_offset;             /* current scrollback offset (lines) */
697         short scrolling;                /* current scrollback page */
698         u_short max_off;                /* maximum scrollback offset */
699 #ifdef XSERVER
700         struct vt_mode smode;
701         struct proc *proc;
702         pid_t pid;
703         unsigned vt_status;
704 #define VT_WAIT_REL 1                   /* wait till process released vt */
705 #define VT_WAIT_ACK 2                   /* wait till process ack vt acquire */
706 #define VT_GRAFX    4                   /* vt runs graphics mode */
707 #define VT_WAIT_ACT 8                   /* a process is sleeping on this vt */
708                                         /*  becoming active */
709 #endif /* XSERVER */
710 } video_state;
711
712 EXTERN video_state vs[PCVT_NSCREENS];   /* parameters for screens */
713
714 struct vga_char_state {
715         int     loaded;                 /* Whether a font is loaded here */
716         int     secondloaded;           /* an extension characterset was loaded, */
717                                         /*      the number is found here         */
718         u_char  char_scanlines;         /* Scanlines per character */
719         u_char  scr_scanlines;          /* Low byte of scanlines per screen */
720         int     screen_size;            /* Screen size in SIZ_YYROWS */
721 };
722
723 EXTERN struct vga_char_state vgacs[NVGAFONTS];  /* Character set states */
724
725 EXTERN u_short *Crtat;                  /* screen start address */
726
727 #ifdef MAIN
728
729 u_char fgansitopc[] = {                 /* foreground ANSI color -> pc */
730         FG_BLACK, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE,
731         FG_MAGENTA, FG_CYAN, FG_LIGHTGREY
732 };
733
734 u_char bgansitopc[] = {                 /* background ANSI color -> pc */
735         BG_BLACK, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE,
736         BG_MAGENTA, BG_CYAN, BG_LIGHTGREY
737 };
738
739 video_state *vsp = &vs[0];              /* ptr to current screen parms */
740
741 #ifdef XSERVER
742 int     vt_switch_pending       = 0;            /* if > 0, a vt switch is */
743 #endif /* XSERVER */                            /* pending; contains the # */
744                                                 /* of the old vt + 1 */
745
746 u_int   addr_6845               = MONO_BASE;    /* crtc base addr */
747 u_char  do_initialization       = 1;            /* we have to init ourselves */
748 u_char  pcvt_is_console         = 0;            /* until we know it */
749 u_char  shift_down              = 0;            /* shift key down flag */
750 u_char  ctrl_down               = 0;            /* ctrl key down flag */
751 u_char  meta_down               = 0;            /* alt key down flag */
752 u_char  altgr_down              = 0;            /* altgr key down flag */
753 u_char  kbrepflag               = 1;            /* key repeat flag */
754 u_char  totalscreens            = 1;            /* screens available */
755 u_char  current_video_screen    = 0;            /* displayed screen no */
756 u_char  adaptor_type            = UNKNOWN_ADAPTOR;/* adaptor type */
757 u_char  vga_type                = VGA_UNKNOWN;  /* vga chipset */
758 u_char  can_do_132col           = 0;            /* vga chipset can 132 cols */
759 u_char  vga_family              = 0;            /* vga manufacturer */
760 u_char  totalfonts              = 0;            /* fonts available */
761 u_char  chargen_access          = 0;            /* synchronize access */
762 u_char  keyboard_type           = KB_UNKNOWN;   /* type of keyboard */
763 u_char  keyboard_is_initialized = 0;            /* for ddb sanity */
764 u_char  kbd_polling             = 0;            /* keyboard is being polled */
765 u_char  reset_keyboard          = 0;            /* OK to reset keyboard */
766 keyboard_t *kbd                 = NULL;
767 struct consdev *pcvt_consptr    = NULL;
768
769 #if PCVT_SHOWKEYS
770 u_char  keyboard_show           = 0;            /* normal display */
771 #endif /* PCVT_SHOWKEYS */
772
773 u_char  cursor_pos_valid        = 0;            /* sput left a valid position*/
774
775 u_char  critical_scroll         = 0;            /* inside scrolling up */
776 int     switch_page             = -1;           /* which page to switch to */
777
778 #if PCVT_SCREENSAVER
779 u_char  reset_screen_saver      = 1;            /* reset the saver next time */
780 u_char  scrnsv_active           = 0;            /* active flag */
781 #endif /* PCVT_SCREENSAVER */
782
783 #ifdef XSERVER
784 unsigned scrnsv_timeout         = 0;            /* initially off */
785 u_char pcvt_kbd_raw             = 0;            /* keyboard sends scans */
786 #endif /* XSERVER */
787
788 u_char *saved_charsets[NVGAFONTS] = {0};        /* backup copy of fonts */
789
790 /*---------------------------------------------------------------------------
791
792         VT220 attributes -> internal emulator attributes conversion tables
793
794         be careful when designing color combinations, because on
795         EGA and VGA displays, bit 3 of the attribute byte is used
796         for characterset switching, and is no longer available for
797         foreground intensity (bold)!
798
799 ---------------------------------------------------------------------------*/
800
801 /* color displays */
802
803 u_char sgr_tab_color[16] = {
804 /*00*/  (BG_BLACK     | FG_LIGHTGREY),             /* normal               */
805 /*01*/  (BG_BLUE      | FG_LIGHTGREY),             /* bold                 */
806 /*02*/  (BG_BROWN     | FG_LIGHTGREY),             /* underline            */
807 /*03*/  (BG_MAGENTA   | FG_LIGHTGREY),             /* bold+underline       */
808 /*04*/  (BG_BLACK     | FG_LIGHTGREY | FG_BLINK),  /* blink                */
809 /*05*/  (BG_BLUE      | FG_LIGHTGREY | FG_BLINK),  /* bold+blink           */
810 /*06*/  (BG_BROWN     | FG_LIGHTGREY | FG_BLINK),  /* underline+blink      */
811 /*07*/  (BG_MAGENTA   | FG_LIGHTGREY | FG_BLINK),  /* bold+underline+blink */
812 /*08*/  (BG_LIGHTGREY | FG_BLACK),                 /* invers               */
813 /*09*/  (BG_LIGHTGREY | FG_BLUE),                  /* bold+invers          */
814 /*10*/  (BG_LIGHTGREY | FG_BROWN),                 /* underline+invers     */
815 /*11*/  (BG_LIGHTGREY | FG_MAGENTA),               /* bold+underline+invers*/
816 /*12*/  (BG_LIGHTGREY | FG_BLACK      | FG_BLINK), /* blink+invers         */
817 /*13*/  (BG_LIGHTGREY | FG_BLUE       | FG_BLINK), /* bold+blink+invers    */
818 /*14*/  (BG_LIGHTGREY | FG_BROWN      | FG_BLINK), /* underline+blink+invers*/
819 /*15*/  (BG_LIGHTGREY | FG_MAGENTA    | FG_BLINK)  /*bold+underl+blink+invers*/
820 };
821
822 /* monochrome displays (VGA version, no intensity) */
823
824 u_char sgr_tab_mono[16] = {
825 /*00*/  (BG_BLACK     | FG_LIGHTGREY),            /* normal               */
826 /*01*/  (BG_BLACK     | FG_UNDERLINE),            /* bold                 */
827 /*02*/  (BG_BLACK     | FG_UNDERLINE),            /* underline            */
828 /*03*/  (BG_BLACK     | FG_UNDERLINE),            /* bold+underline       */
829 /*04*/  (BG_BLACK     | FG_LIGHTGREY | FG_BLINK), /* blink                */
830 /*05*/  (BG_BLACK     | FG_UNDERLINE | FG_BLINK), /* bold+blink           */
831 /*06*/  (BG_BLACK     | FG_UNDERLINE | FG_BLINK), /* underline+blink      */
832 /*07*/  (BG_BLACK     | FG_UNDERLINE | FG_BLINK), /* bold+underline+blink */
833 /*08*/  (BG_LIGHTGREY | FG_BLACK),                /* invers               */
834 /*09*/  (BG_LIGHTGREY | FG_BLACK),                /* bold+invers          */
835 /*10*/  (BG_LIGHTGREY | FG_BLACK),                /* underline+invers     */
836 /*11*/  (BG_LIGHTGREY | FG_BLACK),                /* bold+underline+invers*/
837 /*12*/  (BG_LIGHTGREY | FG_BLACK | FG_BLINK),     /* blink+invers         */
838 /*13*/  (BG_LIGHTGREY | FG_BLACK | FG_BLINK),     /* bold+blink+invers    */
839 /*14*/  (BG_LIGHTGREY | FG_BLACK | FG_BLINK),     /* underline+blink+invers*/
840 /*15*/  (BG_LIGHTGREY | FG_BLACK | FG_BLINK)      /*bold+underl+blink+invers*/
841 };
842
843 /* monochrome displays (MDA version, with intensity) */
844
845 u_char sgr_tab_imono[16] = {
846 /*00*/  (BG_BLACK     | FG_LIGHTGREY),                /* normal               */
847 /*01*/  (BG_BLACK     | FG_LIGHTGREY | FG_INTENSE),   /* bold                 */
848 /*02*/  (BG_BLACK     | FG_UNDERLINE),                /* underline            */
849 /*03*/  (BG_BLACK     | FG_UNDERLINE | FG_INTENSE),   /* bold+underline       */
850 /*04*/  (BG_BLACK     | FG_LIGHTGREY | FG_BLINK),     /* blink                */
851 /*05*/  (BG_BLACK     | FG_LIGHTGREY | FG_INTENSE | FG_BLINK), /* bold+blink  */
852 /*06*/  (BG_BLACK     | FG_UNDERLINE | FG_BLINK),     /* underline+blink      */
853 /*07*/  (BG_BLACK     | FG_UNDERLINE | FG_BLINK | FG_INTENSE), /* bold+underline+blink */
854 /*08*/  (BG_LIGHTGREY | FG_BLACK),                    /* invers               */
855 /*09*/  (BG_LIGHTGREY | FG_BLACK | FG_INTENSE),       /* bold+invers          */
856 /*10*/  (BG_LIGHTGREY | FG_BLACK),                    /* underline+invers     */
857 /*11*/  (BG_LIGHTGREY | FG_BLACK | FG_INTENSE),       /* bold+underline+invers*/
858 /*12*/  (BG_LIGHTGREY | FG_BLACK | FG_BLINK),         /* blink+invers         */
859 /*13*/  (BG_LIGHTGREY | FG_BLACK | FG_BLINK | FG_INTENSE),/* bold+blink+invers*/
860 /*14*/  (BG_LIGHTGREY | FG_BLACK | FG_BLINK),         /* underline+blink+invers*/
861 /*15*/  (BG_LIGHTGREY | FG_BLACK | FG_BLINK | FG_INTENSE) /* bold+underl+blink+invers */
862 };
863
864 u_char  pcvt_kbd_fifo[PCVT_KBD_FIFO_SZ];
865 int     pcvt_kbd_rptr = 0;
866 int     pcvt_kbd_count= 0;
867
868 #else   /* ! MAIN */
869
870 extern u_char           pcvt_kbd_fifo[];
871 extern int              pcvt_kbd_rptr;
872 extern int              pcvt_kbd_count;
873
874 extern u_char           vga_type;
875 extern video_state      *vsp;
876
877 #ifdef XSERVER
878 extern int              vt_switch_pending;
879 #endif /* XSERVER */
880
881 extern u_int            addr_6845;
882 extern u_char           do_initialization;
883 extern u_char           pcvt_is_console;
884 extern u_char           bgansitopc[];
885 extern u_char           fgansitopc[];
886 extern u_char           shift_down;
887 extern u_char           ctrl_down;
888 extern u_char           meta_down;
889 extern u_char           altgr_down;
890 extern u_char           kbrepflag;
891 extern u_char           adaptor_type;
892 extern u_char           current_video_screen;
893 extern u_char           totalfonts;
894 extern u_char           totalscreens;
895 extern u_char           chargen_access;
896 extern u_char           keyboard_type;
897 extern u_char           can_do_132col;
898 extern u_char           vga_family;
899 extern u_char           keyboard_is_initialized;
900 extern u_char           kbd_polling;
901 extern u_char           reset_keyboard;
902 extern keyboard_t       *kbd;
903 extern struct consdev   *pcvt_consptr;
904
905 #if PCVT_SHOWKEYS
906 extern u_char           keyboard_show;
907 #endif /* PCVT_SHOWKEYS */
908
909 extern  u_char          cursor_pos_valid;
910
911 extern  u_char          critical_scroll;
912 extern  int             switch_page;
913
914 #if PCVT_SCREENSAVER
915 extern  u_char          reset_screen_saver;
916 extern  u_char          scrnsv_active;
917 #endif /* PCVT_SCREENSAVER */
918
919 extern u_char           sgr_tab_color[];
920 extern u_char           sgr_tab_mono[];
921 extern u_char           sgr_tab_imono[];
922
923 #ifdef XSERVER
924 extern unsigned         scrnsv_timeout;
925 extern u_char           pcvt_xmode;
926 extern u_char           pcvt_kbd_raw;
927 #endif /* XSERVER */
928
929 extern u_char           *saved_charsets[NVGAFONTS];
930
931 #endif /* MAIN */
932
933 /*===========================================================================*
934  *      forward declarations
935  *===========================================================================*/
936
937 void    async_update ( void *arg );
938 void    clr_parms ( struct video_state *svsp );
939 void    cons_highlight ( void );
940 void    cons_normal ( void );
941 void    dprintf ( unsigned flgs, const char *fmt, ... );
942 int     egavga_test ( void );
943 void    fkl_off ( struct video_state *svsp );
944 void    fkl_on ( struct video_state *svsp );
945
946 #ifdef XSERVER
947 void    get_usl_keymap( keymap_t *map );
948 #endif
949
950 void    init_sfkl ( struct video_state *svsp );
951 void    init_ufkl ( struct video_state *svsp );
952 int     kbdioctl ( struct cdev *dev, int cmd, caddr_t data, int flag );
953 void    kbd_code_init ( void );
954 void    kbd_code_init1 ( void );
955
956 #if PCVT_SCANSET > 1
957 void    kbd_emulate_pc(int do_emulation);
958 #endif
959
960 void    loadchar ( int fontset, int character, int char_scanlines, u_char *char_table );
961 void    mda2egaorvga ( void );
962 void    pcvt_rint(int unit);
963
964 #if PCVT_SCREENSAVER
965 void    pcvt_scrnsv_reset ( void );
966 #ifdef XSERVER
967 void    pcvt_set_scrnsv_tmo ( int );
968 #endif
969 #endif
970
971 void    reallocate_scrollbuffer ( struct video_state *svsp, int pages );
972
973 #ifdef XSERVER
974 void    reset_usl_modes (struct video_state *vsx);
975 #endif
976
977 void    roll_up ( struct video_state *svsp, int n );
978 void    select_vga_charset ( int vga_charset );
979 void    set_2ndcharset ( void );
980 void    set_charset ( struct video_state *svsp, int curvgacs );
981 void    set_emulation_mode ( struct video_state *svsp, int mode );
982 void    set_screen_size ( struct video_state *svsp, int size );
983 u_char  *sgetc ( int noblock );
984 void    sixel_vga ( struct sixels *charsixel, u_char *charvga );
985 void    sput ( u_char *s, int attrib, int len, int page );
986
987 #ifdef XSERVER
988 void    switch_screen ( int n, int oldgrafx, int newgrafx );
989 #endif
990
991 void    swritefkl ( int num, u_char *string, struct video_state *svsp );
992 void    sw_cursor ( int onoff );
993 void    sw_sfkl ( struct video_state *svsp );
994 void    sw_ufkl ( struct video_state *svsp );
995 void    toggl_24l ( struct video_state *svsp );
996 void    toggl_awm ( struct video_state *svsp );
997 void    toggl_bell ( struct video_state *svsp );
998 void    toggl_columns ( struct video_state *svsp );
999 void    toggl_dspf ( struct video_state *svsp );
1000 void    toggl_sevenbit ( struct video_state *svsp );
1001 void    update_hp ( struct video_state *svsp );
1002 void    update_led ( void );
1003
1004 #ifdef XSERVER
1005 int     usl_vt_ioctl (struct cdev *dev, int cmd, caddr_t data, int flag, struct thread *);
1006 #endif
1007
1008 void    vga10_vga10 ( u_char *invga, u_char *outvga );
1009 void    vga10_vga14 ( u_char *invga, u_char *outvga );
1010 void    vga10_vga16 ( u_char *invga, u_char *outvga );
1011 void    vga10_vga8 ( u_char *invga, u_char *outvga );
1012 int     vgaioctl ( struct cdev *dev, int cmd, caddr_t data, int flag );
1013
1014 #ifdef XSERVER
1015 int     vgapage ( int n );
1016 #else
1017 void    vgapage ( int n );
1018 #endif
1019
1020 void    vgapaletteio ( unsigned idx, struct rgb *val, int writeit );
1021 char    *vga_string ( int number );
1022 u_char  vga_chipset ( void );
1023 int     vga_col ( struct video_state *svsp, int cols );
1024 void    vga_move_charset ( unsigned n, unsigned char *b, int save_it);
1025 void    vga_screen_off ( void );
1026 void    vga_screen_on ( void );
1027 int     vga_test ( void );
1028
1029 #ifdef XSERVER
1030 int     vt_activate ( int newscreen );
1031 #endif
1032
1033 void    vt_aln ( struct video_state *svsp );
1034 void    vt_clearudk ( struct video_state *svsp );
1035 void    vt_clreol ( struct video_state *svsp );
1036 void    vt_clreos ( struct video_state *svsp );
1037 void    vt_clrtab ( struct video_state *svsp );
1038 int     vt_col ( struct video_state *svsp, int cols );
1039 void    vt_coldmalloc ( void );
1040 void    vt_cub ( struct video_state *svsp );
1041 void    vt_cud ( struct video_state *svsp );
1042 void    vt_cuf ( struct video_state *svsp );
1043 void    vt_curadr ( struct video_state *svsp );
1044 void    vt_cuu ( struct video_state *svsp );
1045 void    vt_da ( struct video_state *svsp );
1046 void    vt_dch ( struct video_state *svsp );
1047 void    vt_dcsentry ( int ch, struct video_state *svsp );
1048 void    vt_designate ( struct video_state *svsp);
1049 void    vt_dl ( struct video_state *svsp );
1050 void    vt_dld ( struct video_state *svsp );
1051 void    vt_dsr ( struct video_state *svsp );
1052 void    vt_ech ( struct video_state *svsp );
1053 void    vt_ic ( struct video_state *svsp );
1054 void    vt_il ( struct video_state *svsp );
1055 void    vt_ind ( struct video_state *svsp );
1056 void    vt_initsel ( struct video_state *svsp );
1057 void    vt_keyappl ( struct video_state *svsp );
1058 void    vt_keynum ( struct video_state *svsp );
1059 void    vt_mc ( struct video_state *svsp );
1060 void    vt_nel ( struct video_state *svsp );
1061 void    vt_rc ( struct video_state *svsp );
1062 void    vt_reqtparm ( struct video_state *svsp );
1063 void    vt_reset_ansi ( struct video_state *svsp );
1064 void    vt_reset_dec_priv_qm ( struct video_state *svsp );
1065 void    vt_ri ( struct video_state *svsp );
1066 void    vt_ris ( struct video_state *svsp );
1067 void    vt_sc ( struct video_state *svsp );
1068 void    vt_sca ( struct video_state *svsp );
1069 void    vt_sd ( struct video_state *svsp );
1070 void    vt_sed ( struct video_state *svsp );
1071 void    vt_sel ( struct video_state *svsp );
1072 void    vt_set_ansi ( struct video_state *svsp );
1073 void    vt_set_dec_priv_qm ( struct video_state *svsp );
1074 void    vt_sgr ( struct video_state *svsp );
1075 void    vt_stbm ( struct video_state *svsp );
1076 void    vt_str ( struct video_state *svsp );
1077 void    vt_su ( struct video_state *svsp );
1078 void    vt_tst ( struct video_state *svsp );
1079 void    vt_udk ( struct video_state *svsp );
1080
1081
1082 #ifdef PCVT_INCLUDE_VT_SELATTR
1083 /*---------------------------------------------------------------------------*
1084  *      set selective attribute if appropriate
1085  *---------------------------------------------------------------------------*/
1086 #define INT_BITS        (sizeof(unsigned int) * 8)
1087 #define INT_INDEX(n)    ((n) / INT_BITS)
1088 #define BIT_INDEX(n)    ((n) % INT_BITS)
1089
1090 static __inline void
1091 vt_selattr(struct video_state *svsp)
1092 {
1093         int i;
1094
1095         i = (svsp->Crtat + svsp->cur_offset) - svsp->Crtat;
1096
1097         if(svsp->selchar)
1098                 svsp->decsca[INT_INDEX(i)] |=  (1 << BIT_INDEX(i));
1099         else
1100                 svsp->decsca[INT_INDEX(i)] &= ~(1 << BIT_INDEX(i));
1101 }
1102
1103 #endif /* PCVT_INCLUDE_VT_SELATTR */
1104
1105 /*---------------------------------- E O F ----------------------------------*/