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: ite_gb.c 1.1 90/07/09$ 13 * 14 * @(#)ite_gb.c 7.3 (Berkeley) 12/16/90 15 */ 16 17 #include "ite.h" 18 #if NITE > 0 19 20 #include "sys/param.h" 21 #include "sys/conf.h" 22 #include "sys/user.h" 23 #include "sys/proc.h" 24 #include "sys/ioctl.h" 25 #include "sys/tty.h" 26 #include "sys/systm.h" 27 #include "sys/uio.h" 28 29 #include "itevar.h" 30 #include "itereg.h" 31 #include "grf_gbreg.h" 32 33 #include "../include/cpu.h" 34 35 /* XXX */ 36 #include "grfioctl.h" 37 #include "grfvar.h" 38 39 #define REGBASE ((struct gboxfb *)(ip->regbase)) 40 #define WINDOWMOVER gatorbox_windowmove 41 42 gatorbox_init(ip) 43 register struct ite_softc *ip; 44 { 45 /* XXX */ 46 if (ip->regbase == 0) { 47 struct grfinfo *gi = &grf_softc[ip - ite_softc].g_display; 48 ip->regbase = IOV(gi->gd_regaddr); 49 ip->fbbase = IOV(gi->gd_fbaddr); 50 } 51 52 REGBASE->write_protect = 0x0; 53 REGBASE->interrupt = 0x4; 54 REGBASE->rep_rule = RR_COPY; 55 REGBASE->blink1 = 0xff; 56 REGBASE->blink2 = 0xff; 57 gb_microcode(REGADDR); 58 REGBASE->sec_interrupt = 0x01; 59 60 /* 61 * Set up the color map entries. We use three entries in the 62 * color map. The first, is for black, the second is for 63 * white, and the very last entry is for the inverted cursor. 64 */ 65 REGBASE->creg_select = 0x00; 66 REGBASE->cmap_red = 0x00; 67 REGBASE->cmap_grn = 0x00; 68 REGBASE->cmap_blu = 0x00; 69 REGBASE->cmap_write = 0x00; 70 gbcm_waitbusy(REGADDR); 71 72 REGBASE->creg_select = 0x01; 73 REGBASE->cmap_red = 0xFF; 74 REGBASE->cmap_grn = 0xFF; 75 REGBASE->cmap_blu = 0xFF; 76 REGBASE->cmap_write = 0x01; 77 gbcm_waitbusy(REGADDR); 78 79 REGBASE->creg_select = 0xFF; 80 REGBASE->cmap_red = 0xFF; 81 REGBASE->cmap_grn = 0xFF; 82 REGBASE->cmap_blu = 0xFF; 83 REGBASE->cmap_write = 0x01; 84 gbcm_waitbusy(REGADDR); 85 86 ite_devinfo(ip); 87 ite_fontinit(ip); 88 89 /* 90 * Clear the display. This used to be before the font unpacking 91 * but it crashes. Figure it out later. 92 */ 93 gatorbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR); 94 tile_mover_waitbusy(REGADDR); 95 96 /* 97 * Stash the inverted cursor. 98 */ 99 gatorbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 100 ip->cblanky, ip->cblankx, ip->ftheight, 101 ip->ftwidth, RR_COPYINVERTED); 102 } 103 104 gatorbox_deinit(ip) 105 struct ite_softc *ip; 106 { 107 gatorbox_windowmove(ip, 0, 0, 0, 0, 108 ip->dheight, ip->dwidth, RR_CLEAR); 109 tile_mover_waitbusy(REGADDR); 110 111 ip->flags &= ~ITE_INITED; 112 } 113 114 gatorbox_putc(ip, c, dy, dx, mode) 115 register struct ite_softc *ip; 116 register int dy, dx; 117 int c, mode; 118 { 119 register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); 120 121 gatorbox_windowmove(ip, charY(ip, c), charX(ip, c), 122 dy * ip->ftheight, dx * ip->ftwidth, 123 ip->ftheight, ip->ftwidth, wrr); 124 } 125 126 gatorbox_cursor(ip, flag) 127 register struct ite_softc *ip; 128 register int flag; 129 { 130 if (flag == DRAW_CURSOR) 131 draw_cursor(ip) 132 else if (flag == MOVE_CURSOR) { 133 erase_cursor(ip) 134 draw_cursor(ip) 135 } 136 else 137 erase_cursor(ip) 138 } 139 140 gatorbox_clear(ip, sy, sx, h, w) 141 struct ite_softc *ip; 142 register int sy, sx, h, w; 143 { 144 gatorbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 145 sy * ip->ftheight, sx * ip->ftwidth, 146 h * ip->ftheight, w * ip->ftwidth, 147 RR_CLEAR); 148 } 149 #define gatorbox_blockmove(ip, sy, sx, dy, dx, h, w) \ 150 gatorbox_windowmove((ip), \ 151 (sy) * ip->ftheight, \ 152 (sx) * ip->ftwidth, \ 153 (dy) * ip->ftheight, \ 154 (dx) * ip->ftwidth, \ 155 (h) * ip->ftheight, \ 156 (w) * ip->ftwidth, \ 157 RR_COPY) 158 159 gatorbox_scroll(ip, sy, sx, count, dir) 160 register struct ite_softc *ip; 161 register int sy; 162 int dir, sx, count; 163 { 164 register int height, dy, i; 165 166 tile_mover_waitbusy(REGADDR); 167 REGBASE->write_protect = 0x0; 168 169 gatorbox_cursor(ip, ERASE_CURSOR); 170 171 if (dir == SCROLL_UP) { 172 dy = sy - count; 173 height = ip->rows - sy; 174 for (i = 0; i < height; i++) 175 gatorbox_blockmove(ip, sy + i, sx, dy + i, 0, 176 1, ip->cols); 177 } 178 else if (dir == SCROLL_DOWN) { 179 dy = sy + count; 180 height = ip->rows - dy; 181 for (i = (height - 1); i >= 0; i--) 182 gatorbox_blockmove(ip, sy + i, sx, dy + i, 0, 183 1, ip->cols); 184 } 185 else if (dir == SCROLL_RIGHT) { 186 gatorbox_blockmove(ip, sy, sx, sy, sx + count, 187 1, ip->cols - (sx + count)); 188 } 189 else { 190 gatorbox_blockmove(ip, sy, sx, sy, sx - count, 191 1, ip->cols - sx); 192 } 193 } 194 195 gatorbox_windowmove(ip, sy, sx, dy, dx, h, w, mask) 196 register struct ite_softc *ip; 197 int sy, sx, dy, dx, mask; 198 register int h, w; 199 { 200 register int src, dest; 201 202 src = (sy * 1024) + sx; /* upper left corner in pixels */ 203 dest = (dy * 1024) + dx; 204 205 tile_mover_waitbusy(REGADDR); 206 REGBASE->width = -(w / 4); 207 REGBASE->height = -(h / 4); 208 if (src < dest) 209 REGBASE->rep_rule = MOVE_DOWN_RIGHT|mask; 210 else { 211 REGBASE->rep_rule = MOVE_UP_LEFT|mask; 212 /* 213 * Adjust to top of lower right tile of the block. 214 */ 215 src = src + ((h - 4) * 1024) + (w - 4); 216 dest= dest + ((h - 4) * 1024) + (w - 4); 217 } 218 FBBASE[dest] = FBBASE[src]; 219 } 220 #endif 221