Oh GACK! src-clean doesn't quite work that easily since cleandist rebuilds the
[unix-history] / sys / i386 / isa / codrv / co_hdr.h
CommitLineData
15637ed4
RG
1/*
2 * General declarations for CO driver
3 *
4 * Copyright 1992 by Holger Veit
5 * May be freely used with Bill Jolitz's port of
6 * 386bsd and may be included in a 386bsd collection
7 * as long as binary and source are available and reproduce the above
8 * copyright.
9 *
10 * You may freely modify this code and contribute improvements based
11 * on this code as long as you don't claim to be the original author.
12 * Commercial use of this source requires permittance of the copyright
13 * holder. A general license for 386bsd will override this restriction.
14 *
15 * Use at your own risk. The copyright holder or any person who makes
16 * this code available for the public (administrators of public archives
17 * for instance) are not responsible for any harm to hardware or software
18 * that might happen due to wrong application or program faults.
19 *
20 * @(#) $RCSfile: co_hdr.h,v $ $Revision: 1.11 $ (Contributed to 386bsd) $Date: 93/01/23 23:14:39 $
21 *
22 * History: see CO_HISTORY
23 */
24
25#ifndef _CO_HDR_H_
26#define _CO_HDR_H_
27#ifndef GLOBAL
28#define GLOBAL extern
29#endif
30
31#include "param.h"
32#include "malloc.h"
33#include "conf.h"
34#include "ioctl.h"
35#include "proc.h"
36#include "user.h"
37#include "tty.h"
38#include "uio.h"
39#include "fcntl.h"
40#include "i386/isa/isa_device.h"
41#include "callout.h"
42#include "systm.h"
43#include "kernel.h"
44#include "vnode.h"
45#include "syslog.h"
46#include "i386/isa/icu.h"
47#include "i386/i386/cons.h"
48#include "i386/isa/isa.h"
49#include "i386/isa/ic/i8042.h"
50#include "i386/isa/kbd.h"
51#include "machine/pc/display.h"
52#include "machine/psl.h"
53#include "machine/frame.h"
54#include "ioctl_pc.h"
55
56/*
57 * user adjustable constants
58 */
59
60/*#define NETBSD*/ /* define this if you have NetBSD */
61
62#define SCRSAVER 2 /* 1=standard moving block */
63 /* 2=moving snake (thanks: Christoph Robitschko) */
64
65#define BLANKTIMEOUT 10*60 /* Default Screen blanking after 10*60 seconds */
66#define KBDTIMEOUT 0x15000l /* timeout parameter for a keyboard response
67 * adjust for slow keyboard at a fast computer
68 * (e.g. 486DX laptop)
69 */
70#define KBDRETRIES 5 /* max. no. of tries to reset the keyboard in
71 * probing loop, avoids hanging forever if
72 * keyboard does not reply like expected
73 */
74
75#define FAT_CURSOR /* full size cursor, undef if to leave unchanged */
76
77
78/* default screen attributes */
79#define DEF_STD_BGAT BG_BLACK /* standard background */
80#define DEF_STD_M_FGAT FG_LIGHTGREY /* standard mono foreground */
81#define DEF_STD_C_FGAT FG_LIGHTGREY /* standard color foreground */
82#define DEF_KERN_BGAT BG_BLACK /* kernelmode background */
83#define DEF_KERN_M_FGAT FG_UNDERLINE /* kernelmode mono foreground */
84#define DEF_KERN_C_FGAT FG_LIGHTBLUE /* XXX (to distinguish) kernelmode color foreground */
85#define DEF_SO_M_AT FG_INTENSE|BG_LIGHTGREY /* standout mono mode */
86#define DEF_SO_C_AT FG_YELLOW|BG_BLACK /* standout color mode */
87
88/*****************NO USER DEFINABLE DATA BELOW THIS LINE*******************/
89
90/* this is an anachronism in the moment: there is no ioctl other than CODRV1
91 * public available. If you want to write a different ioctl set
92 * based on the core system, read co_codrv1.c as a template.
93 */
94#define CODRV1 1
95
96/* I dunno why this had to be changed! */
97#ifndef NETBSD
98#include "ddb.h"
99#else /* is NetBSD */
100#undef NDDB
101#ifdef DDB
102#define NDDB 1
103#else
104#define NDDB 0
105#endif
106#endif /* NetBSD */
107
108#define DEFAULTCOL 80
109#define DEFAULTROW 25
110#define CHR 2
111 /* Don't think these locations are true virtual addrs! */
112#define MONO_BUF 0xfe0b0000
113#define CGA_BUF 0xfe0b8000
114#define EGA_BIOS 0xfe0c0000
115#define ALTEGA_BIOS 0xfe0e0000 /* alternate video BIOS location */
116#define IOPHYSMEM 0xa0000
117
118#define MONO_BASE 0x3b4
119#define CGA_BASE 0x3d4
120
121/* 6845 register definitions */
122#define M6845_ADDR 0
123#define M6845_HTOTAL 0
124#define M6845_HDISPL 1
125#define M6845_HSYNC 2
126#define M6845_SYNCWIDTH 3
127#define M6845_VTOTAL 4
128#define M6845_VTOTADJ 5
129#define M6845_VDISPL 6
130#define M6845_VSYNC 7
131#define M6845_IMODE 8
132#define M6845_MAXSCAN 9
133#define M6845_CURSTART 0x0A
134#define M6845_CUREND 0x0B
135#define M6845_STARTADRH 0x0C
136#define M6845_STARTADRL 0x0D
137#define M6845_CURSORH 0x0E
138#define M6845_CURSORL 0x0F
139#define M6845_LPENH 0x10
140#define M6845_LPENL 0x11
141
142/* for screentimeout */
143#define BLANKSTART 0 /* for reset and change */
144#define BLANKSTOP 1 /* temporarily suspend */
145
146#define MAXESCPARAM 10 /* max # of ESC parameters */
147
148/* for fonts */
149#define XLAT2PC8 0xFFFE
150#define NOFONT 0xFFFD
151#define ISOLATIN1 0
152
153/* abbreviation for LED control */
154#define leds(vp) ((vp->altgrled ? \
155 vp->altgrlock : vp->shiftled ? \
156 vp->shiftlock : vp->caps) << 2 | \
157 vp->num<<1 | vp->scroll)
158
159/*
160 * local types
161 */
162
163
164#define KBDMAXOVLKEYSIZE 15 /* excl. zero byte */
165#define KBDDEFOVLKEYSIZE 4 /* excl. zero byte */
166
167/* This defines the actually used table for key assignments, and is
168 * dynamically assigned.
169 */
170typedef struct kbd_ovlkey Ovl_tbl;
171
172/* This defines the default table for key assignments. This table does
173 * not have entries for META, ALTGR, SHIFTALTGR like the overloaded key
174 * table
175 */
176typedef struct {
177 u_short type; /* type of key */
178 Ovl_tbl *ovlptr; /* -vak pointer into overload table */
179 XCHAR unshift[KBDDEFOVLKEYSIZE+1]; /* default codes */
180 XCHAR shift[KBDDEFOVLKEYSIZE+1];
181 XCHAR ctrl[KBDDEFOVLKEYSIZE+1];
182} Keycap_def;
183
184#define XC0 { 0,1,1,1 }
185#define XC1(a) { a,0,1,1 }
186#define XC2(a,b) { a,b,0,1 }
187#define XC3(a,b,c) { a,b,c,0 }
188#define XC4(a,b,c,d) { a,b,c,d }
189#define XE3(a,b) { '\033',a,b,0 }
190#if XCHAR == u_char
191#define xc_bcopy(src,dst,sz) bcopyb(src,dst,sz)
192#define xc_char2xc(X) (X)
193#else
194ERROR! CHANGE xc_bcopy!!!!!!
195#endif
196
197/* This is the special functions lookup table (local version of
198 * struct kbd_special
199 */
200
201#define MAXNROFSPEC 30 /* so many keys may have special functions */
202typedef struct {
203 u_short key;
204 u_short modifier;
205 u_short scan;
206 u_short function;
207} Spec_tbl;
208
209/* noise, noise, noise (local structure) */
210struct kbd_sound {
211 int pitch; /* Frequency in Hz */
212 int duration; /* Time in msec */
213};
214
215/*
216 * global variables
217 */
218GLOBAL struct consinfo cons_capabilities;
219GLOBAL volatile char vtswsema;
220extern u_short *Crtat; /* only absolute address in video area */
221extern Keycap_def kbd_keytab[];
222
223GLOBAL struct consoftc {
224 int cs_mymajor;
225 int cs_flags;
226#define CO_INITRB 0x001
227#define CO_INITTTY 0x002
228#define CO_OPEN 0x004 /* cs_opencnt != 0 */
229#define CO_OPENRAW 0x008
230#define CO_POLLING 0x010 /* polling for input */
231#define CO_ACTIVE 0x020 /* timeout active (unused) */
232#define CO_ASYNC 0x040 /* Async I/O mode */
233#define CO_RDWAIT 0x080 /* blocked on read */
234
235 int cs_timo; /* timeouts since interrupt (unused) */
236 u_long cs_wedgecnt; /* times restarted (unused)*/
237 u_long cs_ovfl; /* buffer overflows */
238#ifdef OLDPATCHKIT
239 struct proc *cs_selp; /* Process waiting for select call */
240#else
241 pid_t cs_rsel; /* Process waiting for select call */
242#endif
243 int cs_pgid; /* Process group for ASYNC I/O */
244/*XXX*/ struct tty *cs_constty; /* used to restore constty if */
245 /* anyone dares to steal CONSOLE during raw open */
246 struct vty *cs_actvty; /* active vty which owns the /dev/kbd */
247 int cs_opencnt; /* counter for opens from vtys */
248} consoftc;
249
250GLOBAL struct kbdstate {
251
252 int pitch; /* default pitch of beep */
253 int duration; /* default duration of beep */
254
255/* XXX could be bitfields. But why? */
256 u_char m0flag; /* clear META-map flag */
257 u_char c0flag; /* clear CRTL-map flag */
258 u_char a0flag; /* clear ALT-map flag */
259 u_char ledstate; /* current state of kbd LEDS */
260
261 u_char shift_down; /* shift pressed */
262 u_char ctrl_down; /* ctrl pressed */
263 u_char meta_down; /* meta pressed */
264 u_char altgr_down; /* altgr pressed */
265 u_char repeat; /* allow key repetition */
266 u_char id; /* keyboard id */
267 int tpmrate; /* repetition rate/delay */
268} kbs; /* kbd state */
269
270GLOBAL struct videostate {
271 char blanking;
272 char color;
273 char f89bit; /* 8/9 bit flag */
274 short cardtype; /* set by device probe */
275 short cardsubtype; /* chipset version */
276 short ram; /* set by whoami */
277 int iobase;
278 int scrtimeout; /* Timeout for screenblanker */
279 u_short encoding[2]; /* font encoding */
280 short _atiext; /* ATI VGA special regs */
281} vds;
282
283/* poor man's C++. The usage of these attributes is NOT FOR NONSENSE */
284#define PRIVATE
285#define PUBLIC
286
287/* VT central data structure */
288struct vty {
289PRIVATE u_short *Crtat; /* ptr to virtual video page */
290PRIVATE u_short *crtat; /* ptr to virtual cursor position */
291PRIVATE u_short *vbuf; /* video buffer */
292
293PUBLIC char so; /* in standout mode? */
294PUBLIC char vtynum; /* to get vt# from vtyptr */
295PUBLIC u_short ttycnt; /* open reference counter */
296PUBLIC struct tty *ttyp; /* pointer to virtual tty information */
297
298PUBLIC u_short so_at; /* standout attribute */
299
300PUBLIC struct outmode {
301 u_short fg_at,bg_at; /* kernel attributes */
302 u_short def_at; /* default attribute */
303 char f2; /* select second font */
304 char escstate; /* escape state */
305 char parcnt; /* param count */
306 int param[MAXESCPARAM]; /* ESC parameters */
307 } om[2]; /* 0 = std, 1 = kernel */
308PUBLIC struct outmode *op; /* pointer to actual set */
309
310PUBLIC short row, col; /* current cursor position */
311PUBLIC short nrow, ncol; /* current screen geometry */
312PUBLIC short size; /* size of video space */
313PUBLIC u_char visible; /* =1 is visible */
314PUBLIC u_char scroll; /* =1, scrolllock active */
315PUBLIC u_char caps; /* caps lock active */
316PUBLIC u_char num; /* num lock active */
317PUBLIC u_char shiftlock; /* shift lock active */
318PUBLIC u_char altgrlock; /* altgr lock active */
319PUBLIC u_char altgrled; /* -vak- CAPS led is ALTGR-LOCK */
320PUBLIC u_char shiftled; /* -vak- CAPS led is CAPS-LOCK */
321
322PUBLIC int pitch; /* vty dependent sound */
323PUBLIC int duration;
324};
325
326/* TTY structure for virtual terminals */
327extern struct vty vtys[]; /* vty data */
328extern struct tty pccons[]; /* vty-tty buffers */
329extern int nvty; /* # of available vtys */
330extern struct tty *constty; /* console tty */
331GLOBAL struct vty *actvty; /* pointer to actual vty */
332
333/* Ring buffer of the raw co device */
334GLOBAL struct ringb co_buf;
335
336/*
337 * prototypes
338 */
339
340/* in co_cons.c */
341extern struct tty *dev2tty(dev_t dev);
342extern int pcopen(dev_t dev, int flag, int mode, struct proc*);
343extern int pcclose(dev_t dev, int flag, int mode, struct proc*);
344extern int pcread(dev_t dev, struct uio *uio, int flag);
345extern int pcwrite(dev_t dev, struct uio *uio, int flag);
346extern int pcioctl(dev_t dev, int cmd, caddr_t data, int flag);
347extern int pcstart(struct tty *tp);
348extern void pccnprobe(struct consdev *cp);
349extern void pccninit(struct consdev *cp);
350extern void pccnputc(dev_t dev, int c);
351extern int pccngetc(dev_t dev);
352extern int pcparam(struct tty*,struct termios*);
353extern int pcpoll(int onoff);
354extern int pg(char *p,int q,int r,int s,int t,int u,int v,int w,int x,int y,int z);
355extern int getchar();
356
357/* in co_kbd.c */
358extern void reset_kbd_flags();
359extern int coopen(dev_t dev, int flag, int mode, struct proc *p);
360extern int coclose(dev_t dev, int flag, int mode, struct proc *p);
361extern int coread(dev_t dev, struct uio *uio, int flag);
362extern void cointr(dev_t dev, int irq, int cpl);
363extern void cowakeup();
364extern int coselect(dev_t dev, int rw, struct proc *p);
365extern int coioctl(dev_t dev, int cmd, caddr_t data, int flag);
366extern int comap(dev_t dev, int offset, int nprot);
367extern int coprobe(struct isa_device *dev);
368extern void kbd_setleds(int ledval);
369extern void kbd_ovlinit();
370extern int kbd_getokeydef(u_int key,Ovl_tbl *thisdef);
371extern int kbd_getckeydef(u_int key,Ovl_tbl *thisdef);
372extern int kbd_getspecial(struct kbd_hotkey *data);
373extern int kbd_setspecial(struct kbd_hotkey *data);
374extern int sgetc(int noblock); /* compatibility */
375extern XCHAR *kbd_sgetc(int noblock);
376extern void kbd_settpmrate(int rate);
377extern int kbd_rmkeydef(u_int key);
378extern int kbd_setkeydef(Ovl_tbl *data);
379extern int kbd_cvtsound(int ipitch, int *opitch, int idur, int *odur);
380
381/* in co_vga.c */
382extern void cons_highlight();
383extern void cons_normal();
384extern int coattach(struct isa_device *dev);
385extern void vga_setcursorpos(int pos);
386extern void vga_cursor(int a);
387extern void vga_doblanking(int fct);
388extern void sput(int vtynum, XCHAR c, int ka);
389extern void consinit();
390extern void vga_whoami();
391extern int vga_setcshape(struct cursorshape *data);
392extern int vga_getcshape(struct cursorshape *data);
393extern int vga_getvideoinfo(struct videoinfo *data);
394extern void vga_enablecg();
395extern void vga_disablecg();
396extern int vga_xlatiso646(struct vty *vp,u_short *at,u_short *sat,int c);
397/* emulator support */
398extern void vga_cursorup(struct vty *vp, int n);
399extern void vga_cursordown(struct vty *vp, int n);
400extern void vga_cursorleft(struct vty *vp, int n);
401extern void vga_cursorright(struct vty *vp, int n, int wrap);
402extern void vga_scrollup(struct vty *vp,int n, int cm);
403extern void vga_scrolldown(struct vty *vp, int n);
404extern void vga_cursormove(struct vty *vp, int x, int y);
405extern void vga_cursorrelative(struct vty *vp, int dx, int dy);
406extern void vga_clearcursor(struct vty *vp, int mode);
407extern void vga_clearline(struct vty *vp, int mode);
408extern void vga_deleteline(struct vty *vp, int n);
409extern void vga_insertline(struct vty *vp, int n);
410extern void vga_deletechars(struct vty *vp, int n);
411extern void vga_insertchars(struct vty *vp, int n);
412extern void vga_setattributes(struct vty *vp, int mode, int attr);
413extern void vga_selectfont(struct vty *vp,int fontnr);
414extern void vga_wrtchar(struct vty *vp, u_int c, u_int at);
415extern int vga_checkcursor(struct vty *vp);
416extern void vga_sendchar(struct vty *vp, XCHAR c);
417extern void vga_initvideo();
418
419/* in co_pc3.c */
420extern void vtemul_init(); /* initialize terminal emulator */
421extern void vtemul_exec(struct vty*,XCHAR); /* process data */
422
423/* in co_vty.c */
424extern struct vty *dev2vty(dev_t dev);
425extern void vty_init(int first);
426extern void vty_setactive(int vtyno,int sw);
427extern void vty_next();
428extern void vty_previous();
429extern void vty_broadcast(const char *fmt,...);
430
431/* in co_codrv1.c/co_codrv2.c, etc. */
432extern void coioctl_init();
433extern int consioctl(dev_t dev, int cmd, caddr_t data, int flag);
434extern int kbdioctl(dev_t dev, int cmd, caddr_t data, int flag);
435extern int vgaioctl(dev_t dev, int cmd, caddr_t data, int flag);
436
437/*******************************************************************
438 * The video console multiplexer (not yet)
439 ******************************************************************/
440
441/* in future this will be a struct of pointers to functions, and
442 * will be filled by a "module_init call
443 */
444
445#ifdef GFX_CONSOLE
446#define emul_cursorup gfx_cursorup
447#define emul_cursordown gfx_cursordown
448#define emul_cursorleft gfx_cursorleft
449#define emul_cursorright gfx_cursorright
450#define emul_scrollup gfx_scrollup
451#define emul_scrolldown gfx_scrolldown
452#define emul_cursormove gfx_cursormove
453#define emul_cursorrelative gfx_cursorrelative
454#define emul_clearcursor gfx_clearcursor
455#define emul_clearline gfx_clearline
456#define emul_deleteline gfx_deleteline
457#define emul_insertline gfx_insertline
458#define emul_deletechars gfx_deletechars
459#define emul_insertchars gfx_insertchars
460#define emul_setattributes gfx_setattributes
461#define emul_selectfont gfx_selectfont
462#define emul_wrtchar gfx_wrtchar
463#define emul_checkcursor gfx_checkcursor
464#define emul_sendchar gfx_sendchar
465#define emul_initvideo gfx_initvideo
466#else
467#define emul_cursorup vga_cursorup
468#define emul_cursordown vga_cursordown
469#define emul_cursorleft vga_cursorleft
470#define emul_cursorright vga_cursorright
471#define emul_scrollup vga_scrollup
472#define emul_scrolldown vga_scrolldown
473#define emul_cursormove vga_cursormove
474#define emul_cursorrelative vga_cursorrelative
475#define emul_clearcursor vga_clearcursor
476#define emul_clearline vga_clearline
477#define emul_deleteline vga_deleteline
478#define emul_insertline vga_insertline
479#define emul_deletechars vga_deletechars
480#define emul_insertchars vga_insertchars
481#define emul_setattributes vga_setattributes
482#define emul_selectfont vga_selectfont
483#define emul_wrtchar vga_wrtchar
484#define emul_checkcursor vga_checkcursor
485#define emul_sendchar vga_sendchar
486#define emul_initvideo vga_initvideo
487#endif
488
489#endif /* _CO_HDR_H_
490