xref: /original-bsd/sys/hp/dev/itevar.h (revision 3705696b)
1 /*
2  * Copyright (c) 1988 University of Utah.
3  * Copyright (c) 1990, 1993
4  *	The Regents of the University of California.  All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * the Systems Programming Group of the University of Utah Computer
8  * Science Department.
9  *
10  * %sccs.include.redist.c%
11  *
12  * from: Utah $Hdr: itevar.h 1.15 92/12/20$
13  *
14  *	@(#)itevar.h	8.1 (Berkeley) 06/10/93
15  */
16 
17 #define UNIT(dev)       minor(dev)
18 
19 struct itesw {
20 	int	ite_hwid;		/* Hardware id */
21 	int	(*ite_init)();
22 	int	(*ite_deinit)();
23 	int	(*ite_clear)();
24 	int	(*ite_putc)();
25 	int	(*ite_cursor)();
26 	int	(*ite_scroll)();
27 	u_char	(*ite_readbyte)();
28 	int	(*ite_writeglyph)();
29 };
30 
31 #define getbyte(ip, offset) \
32 	((*(ip)->isw->ite_readbyte)(ip, offset))
33 
34 #define getword(ip, offset) \
35 	((getbyte(ip, offset) << 8) | getbyte(ip, (offset) + 2))
36 
37 #define writeglyph(ip, offset, fontbuf) \
38 	((*(ip)->isw->ite_writeglyph)((ip), (offset), (fontbuf)))
39 
40 struct ite_softc {
41 	int	flags;
42 	struct  itesw *isw;
43 	struct  grf_softc *grf;
44 	caddr_t regbase, fbbase;
45 	short	curx, cury;
46 	short   cursorx, cursory;
47 	short   cblankx, cblanky;
48 	short	rows, cols;
49 	short   cpl;
50 	short	dheight, dwidth;
51 	short	fbheight, fbwidth;
52 	short	ftheight, ftwidth;
53 	short	fontx, fonty;
54 	short   attribute;
55 	u_char	*attrbuf;
56 	short	planemask;
57 	short	pos;
58 	char	imode, escape, fpd, hold;
59 	caddr_t	devdata;			/* display dependent data */
60 };
61 
62 /* Flags */
63 #define ITE_ALIVE	0x01	/* hardware exists */
64 #define ITE_INITED	0x02	/* device has been initialized */
65 #define ITE_CONSOLE	0x04	/* device can be console */
66 #define ITE_ISCONS	0x08	/* device is console */
67 #define ITE_ACTIVE	0x10	/* device is being used as ITE */
68 #define ITE_INGRF	0x20	/* device in use as non-ITE */
69 #define ITE_CURSORON	0x40	/* cursor being tracked */
70 
71 #define attrloc(ip, y, x) \
72 	(ip->attrbuf + ((y) * ip->cols) + (x))
73 
74 #define attrclr(ip, sy, sx, h, w) \
75 	bzero(ip->attrbuf + ((sy) * ip->cols) + (sx), (h) * (w))
76 
77 #define attrmov(ip, sy, sx, dy, dx, h, w) \
78 	bcopy(ip->attrbuf + ((sy) * ip->cols) + (sx), \
79 	      ip->attrbuf + ((dy) * ip->cols) + (dx), \
80 	      (h) * (w))
81 
82 #define attrtest(ip, attr) \
83 	((* (u_char *) attrloc(ip, ip->cury, ip->curx)) & attr)
84 
85 #define attrset(ip, attr) \
86 	((* (u_char *) attrloc(ip, ip->cury, ip->curx)) = attr)
87 
88 /*
89  * X and Y location of character 'c' in the framebuffer, in pixels.
90  */
91 #define	charX(ip,c)	\
92 	(((c) % (ip)->cpl) * (ip)->ftwidth + (ip)->fontx)
93 
94 #define	charY(ip,c)	\
95 	(((c) / (ip)->cpl) * (ip)->ftheight + (ip)->fonty)
96 
97 /*
98  * The cursor is just an inverted space.
99  */
100 #define draw_cursor(ip) { \
101 	WINDOWMOVER(ip, ip->cblanky, ip->cblankx, \
102 		    ip->cury * ip->ftheight, \
103 		    ip->curx * ip->ftwidth, \
104 		    ip->ftheight, ip->ftwidth, RR_XOR); \
105         ip->cursorx = ip->curx; \
106 	ip->cursory = ip->cury; }
107 
108 #define erase_cursor(ip) \
109   	WINDOWMOVER(ip, ip->cblanky, ip->cblankx, \
110 		    ip->cursory * ip->ftheight, \
111 		    ip->cursorx * ip->ftwidth, \
112 		    ip->ftheight, ip->ftwidth, RR_XOR);
113 
114 /* Character attributes */
115 #define ATTR_NOR        0x0             /* normal */
116 #define	ATTR_INV	0x1		/* inverse */
117 #define	ATTR_UL		0x2		/* underline */
118 #define ATTR_ALL	(ATTR_INV | ATTR_UL)
119 
120 /* Keyboard attributes */
121 #define ATTR_KPAD	0x4		/* keypad transmit */
122 
123 /* Replacement Rules */
124 #define RR_CLEAR		0x0
125 #define RR_COPY			0x3
126 #define RR_XOR			0x6
127 #define RR_COPYINVERTED  	0xc
128 
129 #define SCROLL_UP	0x01
130 #define SCROLL_DOWN	0x02
131 #define SCROLL_LEFT	0x03
132 #define SCROLL_RIGHT	0x04
133 #define DRAW_CURSOR	0x05
134 #define ERASE_CURSOR    0x06
135 #define MOVE_CURSOR	0x07
136 
137 #define KBD_SSHIFT	4		/* bits to shift status */
138 #define	KBD_CHARMASK	0x7F
139 
140 /* keyboard status */
141 #define	KBD_SMASK	0xF		/* service request status mask */
142 #define	KBD_CTRLSHIFT	0x8		/* key + CTRL + SHIFT */
143 #define	KBD_CTRL	0x9		/* key + CTRL */
144 #define	KBD_SHIFT	0xA		/* key + SHIFT */
145 #define	KBD_KEY		0xB		/* key only */
146 
147 #define KBD_CAPSLOCK    0x18
148 
149 #define KBD_EXT_LEFT_DOWN     0x12
150 #define KBD_EXT_LEFT_UP       0x92
151 #define KBD_EXT_RIGHT_DOWN    0x13
152 #define KBD_EXT_RIGHT_UP      0x93
153 
154 #define	TABSIZE		8
155 #define	TABEND(u)	(ite_tty[u].t_winsize.ws_col - TABSIZE)
156 
157 #ifdef KERNEL
158 extern	struct ite_softc ite_softc[];
159 extern	struct itesw itesw[];
160 extern	int nitesw;
161 #endif
162