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 and Mark Davies of the Department of Computer 9 * Science, Victoria University of Wellington, New Zealand. 10 * 11 * %sccs.include.redist.c% 12 * 13 * from: Utah $Hdr: ite_hy.c 1.1 92/01/22$ 14 * 15 * @(#)ite_hy.c 8.1 (Berkeley) 06/10/93 16 */ 17 18 #include <hp300/stand/samachdep.h> 19 20 #ifdef ITECONSOLE 21 #include <sys/param.h> 22 23 #include <hp/dev/itevar.h> 24 #include <hp/dev/itereg.h> 25 #include <hp300/dev/grf_hyreg.h> 26 27 #define REGBASE ((struct hyboxfb *)(ip->regbase)) 28 #define WINDOWMOVER hyper_windowmove 29 30 #undef charX 31 #define charX(ip,c) \ 32 (((c) % (ip)->cpl) * ((((ip)->ftwidth + 7) / 8) * 8) + (ip)->fontx) 33 34 hyper_init(ip) 35 register struct ite_softc *ip; 36 { 37 int width; 38 39 ite_fontinfo(ip); 40 width = ((ip->ftwidth + 7) / 8) * 8; 41 ip->cpl = (ip->fbwidth - ip->dwidth) / width; 42 ip->cblanky = ip->fonty + ((128 / ip->cpl) +1) * ip->ftheight; 43 44 REGBASE->nblank = 0x05; 45 46 /* 47 * Clear the framebuffer on all planes. 48 */ 49 hyper_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 50 51 hyper_ite_fontinit(ip); 52 53 /* 54 * Stash the inverted cursor. 55 */ 56 hyper_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 57 ip->cblanky, ip->cblankx, ip->ftheight, 58 ip->ftwidth, RR_COPYINVERTED); 59 } 60 61 hyper_ite_fontinit(ip) 62 register struct ite_softc *ip; 63 { 64 register u_char *fbmem, *dp; 65 int c, l, b; 66 int stride, width; 67 68 dp = (u_char *)(getword(ip, getword(ip, FONTROM) + FONTADDR) + 69 ip->regbase) + FONTDATA; 70 stride = ip->fbwidth >> 3; 71 width = (ip->ftwidth + 7) / 8; 72 73 for (c = 0; c < 128; c++) { 74 fbmem = (u_char *) FBBASE + 75 (ip->fonty + (c / ip->cpl) * ip->ftheight) * 76 stride; 77 fbmem += (ip->fontx >> 3) + (c % ip->cpl) * width; 78 for (l = 0; l < ip->ftheight; l++) { 79 for (b = 0; b < width; b++) { 80 *fbmem++ = *dp; 81 dp += 2; 82 } 83 fbmem -= width; 84 fbmem += stride; 85 } 86 } 87 } 88 89 hyper_putc(ip, c, dy, dx, mode) 90 register struct ite_softc *ip; 91 register int dy, dx; 92 int c, mode; 93 { 94 hyper_windowmove(ip, charY(ip, c), charX(ip, c), 95 dy * ip->ftheight, dx * ip->ftwidth, 96 ip->ftheight, ip->ftwidth, RR_COPY); 97 } 98 99 hyper_cursor(ip, flag) 100 register struct ite_softc *ip; 101 int flag; 102 { 103 switch (flag) { 104 case MOVE_CURSOR: 105 erase_cursor(ip); 106 /* fall through ... */ 107 case DRAW_CURSOR: 108 draw_cursor(ip); 109 break; 110 default: 111 erase_cursor(ip); 112 break; 113 } 114 } 115 116 hyper_clear(ip, sy, sx, h, w) 117 struct ite_softc *ip; 118 register int sy, sx, h, w; 119 { 120 hyper_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 121 sy * ip->ftheight, sx * ip->ftwidth, 122 h * ip->ftheight, w * ip->ftwidth, 123 RR_CLEAR); 124 } 125 126 hyper_scroll(ip, sy, sx, count, dir) 127 register struct ite_softc *ip; 128 register int sy, count; 129 int dir, sx; 130 { 131 register int dy = sy - count; 132 register int height = ip->rows - sy; 133 134 hyper_cursor(ip, ERASE_CURSOR); 135 136 hyper_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 137 dy * ip->ftheight, sx * ip->ftwidth, 138 height * ip->ftheight, 139 ip->cols * ip->ftwidth, RR_COPY); 140 } 141 142 #include <hp300/dev/maskbits.h> 143 144 /* NOTE: 145 * the first element in starttab could be 0xffffffff. making it 0 146 * lets us deal with a full first word in the middle loop, rather 147 * than having to do the multiple reads and masks that we'd 148 * have to do if we thought it was partial. 149 */ 150 int starttab[32] = 151 { 152 0x00000000, 153 0x7FFFFFFF, 154 0x3FFFFFFF, 155 0x1FFFFFFF, 156 0x0FFFFFFF, 157 0x07FFFFFF, 158 0x03FFFFFF, 159 0x01FFFFFF, 160 0x00FFFFFF, 161 0x007FFFFF, 162 0x003FFFFF, 163 0x001FFFFF, 164 0x000FFFFF, 165 0x0007FFFF, 166 0x0003FFFF, 167 0x0001FFFF, 168 0x0000FFFF, 169 0x00007FFF, 170 0x00003FFF, 171 0x00001FFF, 172 0x00000FFF, 173 0x000007FF, 174 0x000003FF, 175 0x000001FF, 176 0x000000FF, 177 0x0000007F, 178 0x0000003F, 179 0x0000001F, 180 0x0000000F, 181 0x00000007, 182 0x00000003, 183 0x00000001 184 }; 185 186 int endtab[32] = 187 { 188 0x00000000, 189 0x80000000, 190 0xC0000000, 191 0xE0000000, 192 0xF0000000, 193 0xF8000000, 194 0xFC000000, 195 0xFE000000, 196 0xFF000000, 197 0xFF800000, 198 0xFFC00000, 199 0xFFE00000, 200 0xFFF00000, 201 0xFFF80000, 202 0xFFFC0000, 203 0xFFFE0000, 204 0xFFFF0000, 205 0xFFFF8000, 206 0xFFFFC000, 207 0xFFFFE000, 208 0xFFFFF000, 209 0xFFFFF800, 210 0xFFFFFC00, 211 0xFFFFFE00, 212 0xFFFFFF00, 213 0xFFFFFF80, 214 0xFFFFFFC0, 215 0xFFFFFFE0, 216 0xFFFFFFF0, 217 0xFFFFFFF8, 218 0xFFFFFFFC, 219 0xFFFFFFFE 220 }; 221 222 hyper_windowmove(ip, sy, sx, dy, dx, h, w, func) 223 struct ite_softc *ip; 224 int sy, sx, dy, dx, h, w, func; 225 { 226 unsigned int *psrcBase, *pdstBase; 227 /* start of src and dst bitmaps */ 228 int width; /* add to get to same position in next line */ 229 230 unsigned int *psrcLine, *pdstLine; 231 /* pointers to line with current src and dst */ 232 register unsigned int *psrc; /* pointer to current src longword */ 233 register unsigned int *pdst; /* pointer to current dst longword */ 234 235 /* following used for looping through a line */ 236 unsigned int startmask, endmask; /* masks for writing ends of dst */ 237 int nlMiddle; /* whole longwords in dst */ 238 register int nl; /* temp copy of nlMiddle */ 239 register unsigned int tmpSrc; 240 /* place to store full source word */ 241 register int xoffSrc; /* offset (>= 0, < 32) from which to 242 fetch whole longwords fetched 243 in src */ 244 int nstart; /* number of ragged bits at start of dst */ 245 int nend; /* number of ragged bits at end of dst */ 246 int srcStartOver; /* pulling nstart bits from src 247 overflows into the next word? */ 248 249 if (h == 0 || w == 0) 250 return; 251 252 width = ip->fbwidth >> 5; 253 psrcLine = ((unsigned int *) ip->fbbase) + (sy * width); 254 pdstLine = ((unsigned int *) ip->fbbase) + (dy * width); 255 256 /* x direction doesn't matter for < 1 longword */ 257 if (w <= 32) 258 { 259 int srcBit, dstBit; /* bit offset of src and dst */ 260 261 pdstLine += (dx >> 5); 262 psrcLine += (sx >> 5); 263 psrc = psrcLine; 264 pdst = pdstLine; 265 266 srcBit = sx & 0x1f; 267 dstBit = dx & 0x1f; 268 269 while(h--) 270 { 271 getandputrop(psrc, srcBit, dstBit, w, pdst, func) 272 pdst += width; 273 psrc += width; 274 } 275 } 276 else 277 { 278 maskbits(dx, w, startmask, endmask, nlMiddle) 279 if (startmask) 280 nstart = 32 - (dx & 0x1f); 281 else 282 nstart = 0; 283 if (endmask) 284 nend = (dx + w) & 0x1f; 285 else 286 nend = 0; 287 288 xoffSrc = ((sx & 0x1f) + nstart) & 0x1f; 289 srcStartOver = ((sx & 0x1f) + nstart) > 31; 290 291 pdstLine += (dx >> 5); 292 psrcLine += (sx >> 5); 293 294 while (h--) 295 { 296 psrc = psrcLine; 297 pdst = pdstLine; 298 299 if (startmask) 300 { 301 getandputrop(psrc, (sx & 0x1f), 302 (dx & 0x1f), nstart, pdst, func) 303 pdst++; 304 if (srcStartOver) 305 psrc++; 306 } 307 308 /* special case for aligned operations */ 309 if (xoffSrc == 0) 310 { 311 nl = nlMiddle; 312 while (nl--) 313 { 314 DoRop (*pdst, func, *psrc++, *pdst); 315 pdst++; 316 } 317 } 318 else 319 { 320 nl = nlMiddle + 1; 321 while (--nl) 322 { 323 getunalignedword (psrc, xoffSrc, tmpSrc) 324 DoRop (*pdst, func, tmpSrc, *pdst); 325 pdst++; 326 psrc++; 327 } 328 } 329 330 if (endmask) 331 { 332 getandputrop0(psrc, xoffSrc, nend, pdst, func); 333 } 334 335 pdstLine += width; 336 psrcLine += width; 337 } 338 } 339 } 340 #endif 341