1 /* 2 * Copyright (c) 1988 University of Utah. 3 * Copyright (c) 1990 The Regents of the University of California. 4 * 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.14 92/01/21$ 13 * 14 * @(#)itevar.h 7.3 (Berkeley) 06/05/92 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 70 #define attrloc(ip, y, x) \ 71 (ip->attrbuf + ((y) * ip->cols) + (x)) 72 73 #define attrclr(ip, sy, sx, h, w) \ 74 bzero(ip->attrbuf + ((sy) * ip->cols) + (sx), (h) * (w)) 75 76 #define attrmov(ip, sy, sx, dy, dx, h, w) \ 77 bcopy(ip->attrbuf + ((sy) * ip->cols) + (sx), \ 78 ip->attrbuf + ((dy) * ip->cols) + (dx), \ 79 (h) * (w)) 80 81 #define attrtest(ip, attr) \ 82 ((* (u_char *) attrloc(ip, ip->cury, ip->curx)) & attr) 83 84 #define attrset(ip, attr) \ 85 ((* (u_char *) attrloc(ip, ip->cury, ip->curx)) = attr) 86 87 /* 88 * X and Y location of character 'c' in the framebuffer, in pixels. 89 */ 90 #define charX(ip,c) \ 91 (((c) % (ip)->cpl) * (ip)->ftwidth + (ip)->fontx) 92 93 #define charY(ip,c) \ 94 (((c) / (ip)->cpl) * (ip)->ftheight + (ip)->fonty) 95 96 /* 97 * The cursor is just an inverted space. 98 */ 99 #define draw_cursor(ip) { \ 100 WINDOWMOVER(ip, ip->cblanky, ip->cblankx, \ 101 ip->cury * ip->ftheight, \ 102 ip->curx * ip->ftwidth, \ 103 ip->ftheight, ip->ftwidth, RR_XOR); \ 104 ip->cursorx = ip->curx; \ 105 ip->cursory = ip->cury; } 106 107 #define erase_cursor(ip) \ 108 WINDOWMOVER(ip, ip->cblanky, ip->cblankx, \ 109 ip->cursory * ip->ftheight, \ 110 ip->cursorx * ip->ftwidth, \ 111 ip->ftheight, ip->ftwidth, RR_XOR); 112 113 /* Character attributes */ 114 #define ATTR_NOR 0x0 /* normal */ 115 #define ATTR_INV 0x1 /* inverse */ 116 #define ATTR_UL 0x2 /* underline */ 117 #define ATTR_ALL (ATTR_INV | ATTR_UL) 118 119 /* Keyboard attributes */ 120 #define ATTR_KPAD 0x4 /* keypad transmit */ 121 122 /* Replacement Rules */ 123 #define RR_CLEAR 0x0 124 #define RR_COPY 0x3 125 #define RR_XOR 0x6 126 #define RR_COPYINVERTED 0xc 127 128 #define SCROLL_UP 0x01 129 #define SCROLL_DOWN 0x02 130 #define SCROLL_LEFT 0x03 131 #define SCROLL_RIGHT 0x04 132 #define DRAW_CURSOR 0x05 133 #define ERASE_CURSOR 0x06 134 #define MOVE_CURSOR 0x07 135 136 #define KBD_SSHIFT 4 /* bits to shift status */ 137 #define KBD_CHARMASK 0x7F 138 139 /* keyboard status */ 140 #define KBD_SMASK 0xF /* service request status mask */ 141 #define KBD_CTRLSHIFT 0x8 /* key + CTRL + SHIFT */ 142 #define KBD_CTRL 0x9 /* key + CTRL */ 143 #define KBD_SHIFT 0xA /* key + SHIFT */ 144 #define KBD_KEY 0xB /* key only */ 145 146 #define KBD_CAPSLOCK 0x18 147 148 #define KBD_EXT_LEFT_DOWN 0x12 149 #define KBD_EXT_LEFT_UP 0x92 150 #define KBD_EXT_RIGHT_DOWN 0x13 151 #define KBD_EXT_RIGHT_UP 0x93 152 153 #define TABSIZE 8 154 #define TABEND(u) (ite_tty[u].t_winsize.ws_col - TABSIZE) 155 156 #ifdef KERNEL 157 extern struct ite_softc ite_softc[]; 158 extern struct itesw itesw[]; 159 extern int nitesw; 160 #endif 161