ite_cc.c revision 1.16.6.2 1 /* $NetBSD: ite_cc.c,v 1.16.6.2 2002/04/01 07:39:32 nathanw Exp $ */
2
3 /*
4 * Copyright (c) 1996 Leo Weppelman
5 * Copyright (c) 1994 Christian E. Hopps
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Christian E. Hopps.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #include <sys/param.h>
35 #include <sys/conf.h>
36 #include <sys/proc.h>
37 #include <sys/ioctl.h>
38 #include <sys/tty.h>
39 #include <sys/systm.h>
40 #include <sys/queue.h>
41 #include <sys/termios.h>
42 #include <sys/malloc.h>
43 #include <sys/device.h>
44 #include <dev/cons.h>
45 #include <machine/cpu.h>
46 #include <atari/atari/device.h>
47 #include <atari/dev/itevar.h>
48 #include <atari/dev/iteioctl.h>
49 #include <atari/dev/grfioctl.h>
50 #include <atari/dev/grfabs_reg.h>
51 #include <atari/dev/grfvar.h>
52 #include <atari/dev/font.h>
53 #include <atari/dev/viewioctl.h>
54 #include <atari/dev/viewvar.h>
55
56 #include "grfcc.h"
57
58 /*
59 * This is what ip->priv points to;
60 * it contains local variables for custom-chip ites.
61 */
62 struct ite_priv {
63 u_char **row_ptr; /* array of pointers into the bitmap */
64 u_long row_bytes;
65 u_long cursor_opt;
66 u_short *column_offset; /* array of offsets for columns */
67 u_int row_offset; /* the row offset */
68 u_short width; /* the bitmap width */
69 u_short underline; /* where the underline goes */
70 u_short ft_x; /* the font width */
71 u_short ft_y; /* the font height */
72 u_char *font_cell[256];/* the font pointer */
73 };
74 typedef struct ite_priv ipriv_t;
75
76 /*
77 * We need the following space to get an ite-console setup before
78 * the VM-system is brought up. We setup for a 1280x960 monitor with
79 * an 8x8 font.
80 */
81 #define CONS_MAXROW 120 /* Max. number of rows on console */
82 #define CONS_MAXCOL 160 /* Max. number of columns on console */
83 static u_short con_columns[CONS_MAXCOL];
84 static u_char *con_rows[CONS_MAXROW];
85 static ipriv_t con_ipriv;
86
87 extern font_info font_info_8x8;
88 extern font_info font_info_8x16;
89
90 static void view_init __P((struct ite_softc *));
91 static void view_deinit __P((struct ite_softc *));
92 static int itecc_ioctl __P((struct ite_softc *, u_long, caddr_t, int,
93 struct proc *));
94 static int ite_newsize __P((struct ite_softc *, struct itewinsize *));
95 static void cursor32 __P((struct ite_softc *, int));
96 static void putc8 __P((struct ite_softc *, int, int, int, int));
97 static void clear8 __P((struct ite_softc *, int, int, int, int));
98 static void scroll8 __P((struct ite_softc *, int, int, int, int));
99 static void scrollbmap __P((bmap_t *, u_short, u_short, u_short, u_short,
100 short, short));
101
102 /*
103 * grfcc config stuff
104 */
105 void grfccattach __P((struct device *, struct device *, void *));
106 int grfccmatch __P((struct device *, struct cfdata *, void *));
107 int grfccprint __P((void *, const char *));
108
109 struct cfattach grfcc_ca = {
110 sizeof(struct grf_softc), grfccmatch, grfccattach
111 };
112
113 /*
114 * only used in console init.
115 */
116 static struct cfdata *cfdata_grf = NULL;
117
118 /*
119 * Probe functions we can use:
120 */
121 #ifdef TT_VIDEO
122 void tt_probe_video __P((MODES *));
123 #endif /* TT_VIDEO */
124 #ifdef FALCON_VIDEO
125 void falcon_probe_video __P((MODES *));
126 #endif /* FALCON_VIDEO */
127
128 int
129 grfccmatch(pdp, cfp, auxp)
130 struct device *pdp;
131 struct cfdata *cfp;
132 void *auxp;
133 {
134 static int did_consinit = 0;
135 static int must_probe = 1;
136 grf_auxp_t *grf_auxp = auxp;
137
138 if (must_probe) {
139 /*
140 * Check if the layers we depend on exist
141 */
142 if (!(machineid & (ATARI_TT|ATARI_FALCON)))
143 return (0);
144 #ifdef TT_VIDEO
145 if ((machineid & ATARI_TT) && !grfabs_probe(&tt_probe_video))
146 return (0);
147 #endif /* TT_VIDEO */
148 #ifdef FALCON_VIDEO
149 if ((machineid & ATARI_FALCON)
150 && !grfabs_probe(&falcon_probe_video))
151 return (0);
152 #endif /* FALCON_VIDEO */
153
154 viewprobe();
155 must_probe = 0;
156 }
157
158 if (atari_realconfig == 0) {
159 /*
160 * Early console init. Only match first unit.
161 */
162 if (did_consinit)
163 return(0);
164 if (viewopen(cfp->cf_unit, 0, 0, NULL))
165 return(0);
166 cfdata_grf = cfp;
167 did_consinit = 1;
168 return (1);
169 }
170
171 /*
172 * Normal config. When we are called directly from the grfbus,
173 * we only match the first unit. The attach function will call us for
174 * the other configured units.
175 */
176 if (grf_auxp->from_bus_match && (did_consinit > 1))
177 return (0);
178
179 if (!grf_auxp->from_bus_match && (grf_auxp->unit != cfp->cf_unit))
180 return (0);
181
182 /*
183 * Final constraint: each grf needs a view....
184 */
185 if((cfdata_grf == NULL) || (did_consinit > 1)) {
186 if(viewopen(cfp->cf_unit, 0, 0, NULL))
187 return(0);
188 }
189 did_consinit = 2;
190 return(1);
191 }
192
193 /*
194 * attach: initialize the grf-structure and try to attach an ite to us.
195 * note : dp is NULL during early console init.
196 */
197 void
198 grfccattach(pdp, dp, auxp)
199 struct device *pdp, *dp;
200 void *auxp;
201 {
202 static struct grf_softc congrf;
203 static int first_attach = 1;
204 grf_auxp_t *grf_bus_auxp = auxp;
205 grf_auxp_t grf_auxp;
206 struct grf_softc *gp;
207 int maj;
208
209 /*
210 * find our major device number
211 */
212 for(maj = 0; maj < nchrdev; maj++)
213 if (cdevsw[maj].d_open == grfopen)
214 break;
215
216 /*
217 * Handle exeption case: early console init
218 */
219 if(dp == NULL) {
220 congrf.g_unit = cfdata_grf->cf_unit;
221 congrf.g_grfdev = makedev(maj, congrf.g_unit);
222 congrf.g_itedev = (dev_t)-1;
223 congrf.g_flags = GF_ALIVE;
224 congrf.g_mode = grf_mode;
225 congrf.g_conpri = grfcc_cnprobe();
226 congrf.g_viewdev = congrf.g_unit;
227 grfcc_iteinit(&congrf);
228 grf_viewsync(&congrf);
229
230 /* Attach console ite */
231 atari_config_found(cfdata_grf, NULL, &congrf, grfccprint);
232 return;
233 }
234
235 gp = (struct grf_softc *)dp;
236 gp->g_unit = gp->g_device.dv_unit;
237 grfsp[gp->g_unit] = gp;
238
239 if((cfdata_grf != NULL) && (gp->g_unit == congrf.g_unit)) {
240 /*
241 * We inited earlier just copy the info, take care
242 * not to copy the device struct though.
243 */
244 bcopy(&congrf.g_display, &gp->g_display,
245 (char *)&gp[1] - (char *)&gp->g_display);
246 }
247 else {
248 gp->g_grfdev = makedev(maj, gp->g_unit);
249 gp->g_itedev = (dev_t)-1;
250 gp->g_flags = GF_ALIVE;
251 gp->g_mode = grf_mode;
252 gp->g_conpri = 0;
253 gp->g_viewdev = gp->g_unit;
254 grfcc_iteinit(gp);
255 grf_viewsync(gp);
256 }
257
258 printf(": width %d height %d", gp->g_display.gd_dwidth,
259 gp->g_display.gd_dheight);
260 if(gp->g_display.gd_colors == 2)
261 printf(" monochrome\n");
262 else printf(" colors %d\n", gp->g_display.gd_colors);
263
264 /*
265 * try and attach an ite
266 */
267 config_found(dp, gp, grfccprint);
268
269 /*
270 * If attaching the first unit, go ahead and 'find' the rest of us
271 */
272 if (first_attach) {
273 first_attach = 0;
274 grf_auxp.from_bus_match = 0;
275 for (grf_auxp.unit=1; grf_auxp.unit < NGRFCC; grf_auxp.unit++) {
276 config_found(pdp, (void*)&grf_auxp, grf_bus_auxp->busprint);
277 }
278 }
279 }
280
281 int
282 grfccprint(auxp, pnp)
283 void *auxp;
284 const char *pnp;
285 {
286 if(pnp)
287 printf("ite at %s", pnp);
288 return(UNCONF);
289 }
290
291 /*
292 * called from grf_cc to return console priority
293 */
294 int
295 grfcc_cnprobe()
296 {
297 return(CN_INTERNAL);
298 }
299 /*
300 * called from grf_cc to init ite portion of
301 * grf_softc struct
302 */
303 void
304 grfcc_iteinit(gp)
305 struct grf_softc *gp;
306 {
307
308 gp->g_itecursor = cursor32;
309 gp->g_iteputc = putc8;
310 gp->g_iteclear = clear8;
311 gp->g_itescroll = scroll8;
312 gp->g_iteinit = view_init;
313 gp->g_itedeinit = view_deinit;
314 }
315
316 static void
317 view_deinit(ip)
318 struct ite_softc *ip;
319 {
320 ip->flags &= ~ITE_INITED;
321 }
322
323 static void
324 view_init(ip)
325 register struct ite_softc *ip;
326 {
327 struct itewinsize wsz;
328 ipriv_t *cci;
329
330 if((cci = ip->priv) != NULL)
331 return;
332
333 ip->itexx_ioctl = itecc_ioctl;
334
335 #if defined(KFONT_8X8)
336 ip->font = font_info_8x8;
337 #else
338 ip->font = font_info_8x16;
339 #endif
340
341 /* Find the correct set of rendering routines for this font. */
342 if(ip->font.width != 8)
343 panic("kernel font size not supported");
344
345 if(!atari_realconfig)
346 ip->priv = cci = &con_ipriv;
347 else ip->priv = cci = (ipriv_t*)malloc(sizeof(*cci), M_DEVBUF,M_WAITOK);
348 if(cci == NULL)
349 panic("No memory for ite-view");
350 bzero(cci, sizeof(*cci));
351
352 cci->cursor_opt = 0;
353 cci->row_ptr = NULL;
354 cci->column_offset = NULL;
355
356 wsz.x = ite_default_x;
357 wsz.y = ite_default_y;
358 wsz.width = ite_default_width;
359 wsz.height = ite_default_height;
360 wsz.depth = ite_default_depth;
361
362 ite_newsize (ip, &wsz);
363
364 /*
365 * Only console will be turned on by default..
366 */
367 if(ip->flags & ITE_ISCONS)
368 ip->grf->g_mode(ip->grf, GM_GRFON, NULL, 0, 0);
369 }
370
371 static int
372 ite_newsize(ip, winsz)
373 struct ite_softc *ip;
374 struct itewinsize *winsz;
375 {
376 struct view_size vs;
377 ipriv_t *cci = ip->priv;
378 u_long i, j;
379 int error = 0;
380 view_t *view;
381
382 vs.x = winsz->x;
383 vs.y = winsz->y;
384 vs.width = winsz->width;
385 vs.height = winsz->height;
386 vs.depth = winsz->depth;
387
388 error = viewioctl(ip->grf->g_viewdev, VIOCSSIZE, (caddr_t)&vs, 0,
389 NOPROC);
390 view = viewview(ip->grf->g_viewdev);
391
392 /*
393 * Reinitialize our structs
394 */
395 ip->cols = view->display.width / ip->font.width;
396 ip->rows = view->display.height / ip->font.height;
397
398 /*
399 * save new values so that future opens use them
400 * this may not be correct when we implement Virtual Consoles
401 */
402 ite_default_height = view->display.height;
403 ite_default_width = view->display.width;
404 ite_default_x = view->display.x;
405 ite_default_y = view->display.y;
406 ite_default_depth = view->bitmap->depth;
407
408 if(cci->row_ptr && (cci->row_ptr != con_rows)) {
409 free(cci->row_ptr, M_DEVBUF);
410 cci->row_ptr = NULL;
411 }
412 if(cci->column_offset && (cci->column_offset != con_columns)) {
413 free(cci->column_offset, M_DEVBUF);
414 cci->column_offset = NULL;
415 }
416
417 if(!atari_realconfig) {
418 cci->row_ptr = con_rows;
419 cci->column_offset = con_columns;
420 }
421 else {
422 cci->row_ptr = malloc(sizeof(u_char *) * ip->rows,M_DEVBUF,M_NOWAIT);
423 cci->column_offset = malloc(sizeof(u_int)*ip->cols,M_DEVBUF,M_NOWAIT);
424 }
425
426 if(!cci->row_ptr || !cci->column_offset)
427 panic("No memory for ite-view");
428
429 cci->width = view->bitmap->bytes_per_row << 3;
430 cci->underline = ip->font.baseline + 1;
431 cci->row_offset = view->bitmap->bytes_per_row;
432 cci->ft_x = ip->font.width;
433 cci->ft_y = ip->font.height;
434 cci->row_bytes = cci->row_offset * cci->ft_y;
435 cci->row_ptr[0] = view->bitmap->plane;
436 for(i = 1; i < ip->rows; i++)
437 cci->row_ptr[i] = cci->row_ptr[i-1] + cci->row_bytes;
438
439 /*
440 * Initialize the column offsets to point at the correct location
441 * in the first plane. This definitely assumes a font width of 8!
442 */
443 j = view->bitmap->depth * 2;
444 cci->column_offset[0] = 0;
445 for(i = 1; i < ip->cols; i++)
446 cci->column_offset[i] = ((i >> 1) * j) + (i & 1);
447
448 /* initialize the font cell pointers */
449 cci->font_cell[ip->font.font_lo] = ip->font.font_p;
450 for(i = ip->font.font_lo+1; i <= ip->font.font_hi; i++)
451 cci->font_cell[i] = cci->font_cell[i-1] + ip->font.height;
452
453 return(error);
454 }
455
456 int
457 itecc_ioctl(ip, cmd, addr, flag, p)
458 struct ite_softc *ip;
459 u_long cmd;
460 caddr_t addr;
461 int flag;
462 struct proc *p;
463 {
464 struct winsize ws;
465 struct itewinsize *is;
466 int error = 0;
467 view_t *view = viewview(ip->grf->g_viewdev);
468
469 switch (cmd) {
470 case ITEIOCSWINSZ:
471 is = (struct itewinsize *)addr;
472
473 if(ite_newsize(ip, is))
474 error = ENOMEM;
475 else {
476 view = viewview(ip->grf->g_viewdev);
477 ws.ws_row = ip->rows;
478 ws.ws_col = ip->cols;
479 ws.ws_xpixel = view->display.width;
480 ws.ws_ypixel = view->display.height;
481 ite_reset(ip);
482 /*
483 * XXX tell tty about the change
484 * XXX this is messy, but works
485 */
486 iteioctl(ip->grf->g_itedev,TIOCSWINSZ,(caddr_t)&ws,0,p);
487 }
488 break;
489 case VIOCSCMAP:
490 case VIOCGCMAP:
491 /*
492 * XXX watchout for that NOPROC. its not really the kernel
493 * XXX talking these two commands don't use the proc pointer
494 * XXX though.
495 */
496 error = viewioctl(ip->grf->g_viewdev, cmd, addr, flag, NOPROC);
497 break;
498 default:
499 error = EPASSTHROUGH;
500 break;
501 }
502 return (error);
503 }
504
505 static void
506 cursor32(struct ite_softc *ip, int flag)
507 {
508 int cend;
509 u_char *pl;
510 ipriv_t *cci;
511
512 cci = ip->priv;
513
514 if(flag == END_CURSOROPT)
515 cci->cursor_opt--;
516 else if(flag == START_CURSOROPT) {
517 if(!cci->cursor_opt)
518 cursor32(ip, ERASE_CURSOR);
519 cci->cursor_opt++;
520 return; /* if we are already opted. */
521 }
522
523 if(cci->cursor_opt)
524 return; /* if we are still nested. */
525 /* else we draw the cursor. */
526
527 if(flag != DRAW_CURSOR && flag != END_CURSOROPT) {
528 /*
529 * erase the cursor
530 */
531 cend = ip->font.height-1;
532 pl = cci->column_offset[ip->cursorx]
533 + cci->row_ptr[ip->cursory];
534 __asm__ __volatile__
535 ("1: notb %0@ ; addaw %4,%0\n\t"
536 "dbra %1,1b"
537 : "=a" (pl), "=d" (cend)
538 : "0" (pl), "1" (cend),
539 "d" (cci->row_offset)
540 );
541 }
542
543 if(flag != DRAW_CURSOR && flag != MOVE_CURSOR && flag != END_CURSOROPT)
544 return;
545
546 /*
547 * draw the cursor
548 */
549 cend = min(ip->curx, ip->cols-1);
550 if (flag == DRAW_CURSOR
551 && ip->cursorx == cend && ip->cursory == ip->cury)
552 return;
553 ip->cursorx = cend;
554 ip->cursory = ip->cury;
555 cend = ip->font.height-1;
556 pl = cci->column_offset[ip->cursorx]
557 + cci->row_ptr[ip->cursory];
558
559 __asm__ __volatile__
560 ("1: notb %0@ ; addaw %4,%0\n\t"
561 "dbra %1,1b"
562 : "=a" (pl), "=d" (cend)
563 : "0" (pl), "1" (cend),
564 "d" (cci->row_offset)
565 );
566 }
567
568 static void
569 putc8(struct ite_softc *ip, int c, int dy, int dx, int mode)
570 {
571 register ipriv_t *cci = (ipriv_t *)ip->priv;
572 register u_char *pl = cci->column_offset[dx] + cci->row_ptr[dy];
573 register u_int fh = cci->ft_y;
574 register u_int ro = cci->row_offset;
575 register u_char eor_mask;
576 register u_char bl, tmp, ul;
577 register u_char *ft;
578
579 if(c < ip->font.font_lo || c > ip->font.font_hi)
580 return;
581
582 ft = cci->font_cell[c];
583
584 if(!mode) {
585 while(fh--) {
586 *pl = *ft++; pl += ro;
587 }
588 return;
589 }
590
591 eor_mask = (mode & ATTR_INV) ? 0xff : 0x00;
592 bl = (mode & ATTR_BOLD) ? 1 : 0;
593 ul = (mode & ATTR_UL) ? fh - cci->underline : fh;
594 for(; fh--; pl += ro) {
595 if(fh != ul) {
596 tmp = *ft++;
597 if(bl)
598 tmp |= (tmp >> 1);
599 *pl = tmp ^ eor_mask;
600 }
601 else {
602 *pl = 0xff ^ eor_mask;
603 ft++;
604 }
605 }
606 }
607
608 static void
609 clear8(struct ite_softc *ip, int sy, int sx, int h, int w)
610 {
611 ipriv_t *cci = (ipriv_t *) ip->priv;
612 view_t *v = viewview(ip->grf->g_viewdev);
613 bmap_t *bm = v->bitmap;
614
615 if((sx == 0) && (w == ip->cols)) {
616 /* common case: clearing whole lines */
617 while (h--) {
618 int i;
619 u_char *ptr = cci->row_ptr[sy];
620 for(i = 0; i < ip->font.height; i++) {
621 bzero(ptr, bm->bytes_per_row);
622 ptr += bm->bytes_per_row;
623 }
624 sy++;
625 }
626 }
627 else {
628 /*
629 * clearing only part of a line
630 * XXX could be optimized MUCH better, but is it worth the
631 * trouble?
632 */
633
634 int i;
635 u_char *pls, *ple;
636
637 pls = cci->row_ptr[sy];
638 ple = pls + cci->column_offset[sx + w-1];
639 pls = pls + cci->column_offset[sx];
640
641 for(i = ((ip->font.height) * h)-1; i >= 0; i--) {
642 u_char *p = pls;
643 while(p <= ple)
644 *p++ = 0;
645 pls += bm->bytes_per_row;
646 ple += bm->bytes_per_row;
647 }
648 }
649 }
650
651 /* Note: sx is only relevant for SCROLL_LEFT or SCROLL_RIGHT. */
652 static void
653 scroll8(ip, sy, sx, count, dir)
654 register struct ite_softc *ip;
655 register int sy;
656 int dir, sx, count;
657 {
658 bmap_t *bm = viewview(ip->grf->g_viewdev)->bitmap;
659 u_char *pl = ((ipriv_t *)ip->priv)->row_ptr[sy];
660
661 if(dir == SCROLL_UP) {
662 int dy = sy - count;
663
664 cursor32(ip, ERASE_CURSOR);
665 scrollbmap(bm, 0, dy*ip->font.height, bm->bytes_per_row >> 3,
666 (ip->bottom_margin-dy+1)*ip->font.height,
667 0, -(count*ip->font.height));
668 }
669 else if(dir == SCROLL_DOWN) {
670 cursor32(ip, ERASE_CURSOR);
671 scrollbmap(bm, 0, sy*ip->font.height, bm->bytes_per_row >> 3,
672 (ip->bottom_margin-sy+1)*ip->font.height,
673 0, count*ip->font.height);
674 }
675 else if(dir == SCROLL_RIGHT) {
676 int sofs = (ip->cols - count) * ip->font.width;
677 int dofs = (ip->cols) * ip->font.width;
678 int i, j;
679
680 cursor32(ip, ERASE_CURSOR);
681 for(j = ip->font.height-1; j >= 0; j--) {
682 int sofs2 = sofs, dofs2 = dofs;
683 for (i = (ip->cols - (sx + count))-1; i >= 0; i--) {
684 int t;
685 sofs2 -= ip->font.width;
686 dofs2 -= ip->font.width;
687 asm("bfextu %1@{%2:%3},%0" : "=d" (t)
688 : "a" (pl), "d" (sofs2), "d" (ip->font.width));
689 asm("bfins %3,%0@{%1:%2}" :
690 : "a" (pl), "d" (dofs2), "d" (ip->font.width),
691 "d" (t));
692 }
693 pl += bm->bytes_per_row;
694 }
695 }
696 else { /* SCROLL_LEFT */
697 int sofs = (sx) * ip->font.width;
698 int dofs = (sx - count) * ip->font.width;
699 int i, j;
700
701 cursor32(ip, ERASE_CURSOR);
702 for(j = ip->font.height-1; j >= 0; j--) {
703 int sofs2 = sofs, dofs2 = dofs;
704 for(i = (ip->cols - sx)-1; i >= 0; i--) {
705 int t;
706
707 asm("bfextu %1@{%2:%3},%0" : "=d" (t)
708 : "a" (pl), "d" (sofs2), "d" (ip->font.width));
709 asm("bfins %3,%0@{%1:%2}"
710 : : "a" (pl), "d" (dofs2),"d" (ip->font.width),
711 "d" (t));
712 sofs2 += ip->font.width;
713 dofs2 += ip->font.width;
714 }
715 pl += bm->bytes_per_row;
716 }
717 }
718 }
719
720 static void
721 scrollbmap (bmap_t *bm, u_short x, u_short y, u_short width, u_short height, short dx, short dy)
722 {
723 u_short lwpr = bm->bytes_per_row >> 2;
724
725 if(dx) {
726 /* FIX: */ panic ("delta x not supported in scroll bitmap yet.");
727 }
728
729 if(dy == 0) {
730 return;
731 }
732 if(dy > 0) {
733 u_long *pl = (u_long *)bm->plane;
734 u_long *src_y = pl + (lwpr*y);
735 u_long *dest_y = pl + (lwpr*(y+dy));
736 u_long count = lwpr*(height-dy);
737 u_long *clr_y = src_y;
738 u_long clr_count = dest_y - src_y;
739 u_long bc, cbc;
740
741 src_y += count - 1;
742 dest_y += count - 1;
743
744 bc = count >> 4;
745 count &= 0xf;
746
747 while (bc--) {
748 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
749 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
750 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
751 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
752 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
753 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
754 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
755 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
756 }
757 while (count--)
758 *dest_y-- = *src_y--;
759
760 cbc = clr_count >> 4;
761 clr_count &= 0xf;
762
763 while (cbc--) {
764 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
765 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
766 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
767 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
768 }
769 while(clr_count--)
770 *clr_y++ = 0;
771 }
772 else {
773 u_long *pl = (u_long *)bm->plane;
774 u_long *src_y = pl + (lwpr*(y-dy));
775 u_long *dest_y = pl + (lwpr*y);
776 long count = lwpr*(height + dy);
777 u_long *clr_y = dest_y + count;
778 u_long clr_count = src_y - dest_y;
779 u_long bc, cbc;
780
781 bc = count >> 4;
782 count &= 0xf;
783
784 while(bc--) {
785 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
786 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
787 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
788 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
789 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
790 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
791 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
792 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
793 }
794 while(count--)
795 *dest_y++ = *src_y++;
796
797 cbc = clr_count >> 4;
798 clr_count &= 0xf;
799
800 while (cbc--) {
801 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
802 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
803 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
804 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
805 }
806 while (clr_count--)
807 *clr_y++ = 0;
808 }
809 }
810