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