Home | History | Annotate | Line # | Download | only in ee
gsfb.c revision 1.9
      1 /*	$NetBSD: gsfb.c,v 1.9 2003/11/02 13:12:14 shin Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2001 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by UCHIYAMA Yasushi.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #include <sys/cdefs.h>
     40 __KERNEL_RCSID(0, "$NetBSD: gsfb.c,v 1.9 2003/11/02 13:12:14 shin Exp $");
     41 
     42 #include "debug_playstation2.h"
     43 
     44 #include <sys/param.h>
     45 #include <sys/systm.h>
     46 
     47 #include <machine/autoconf.h>
     48 
     49 #include <dev/cons.h>
     50 
     51 #include <dev/wscons/wsconsio.h>
     52 #include <dev/wscons/wsdisplayvar.h>
     53 #include <dev/wscons/wscons_callbacks.h>
     54 
     55 #include <dev/wsfont/wsfont.h>
     56 
     57 #include <playstation2/ee/eevar.h>
     58 #include <playstation2/ee/gsvar.h>
     59 #include <playstation2/ee/gsreg.h>
     60 #include <playstation2/ee/dmacvar.h>
     61 #include <playstation2/ee/dmacreg.h>
     62 
     63 #ifdef DEBUG
     64 #define STATIC
     65 #else
     66 #define STATIC	static
     67 #endif
     68 
     69 STATIC struct gsfb {
     70 	int initialized;
     71 	int attached;
     72 	int is_console;
     73 	const struct wsscreen_descr *screen;
     74 	struct wsdisplay_font *font;
     75 } gsfb;
     76 
     77 STATIC void gsfb_dma_kick(paddr_t, size_t);
     78 STATIC void gsfb_font_expand_psmct32(const struct wsdisplay_font *, u_int,
     79     long, u_int32_t *);
     80 STATIC __inline__ void gsfb_set_cursor_pos(u_int32_t *, int, int, int, int);
     81 
     82 #define ATTR_FG_GET(a)	(((a )>> 24) & 0xf)
     83 #define ATTR_BG_GET(a)	(((a )>> 16) & 0xf)
     84 #define ATTR_FG_SET(x)	(((x) << 24) & 0x0f000000)
     85 #define ATTR_BG_SET(x)	(((x) << 16) & 0x000f0000)
     86 
     87 STATIC const u_int32_t gsfb_ansi_psmct32[] = {
     88 	0x80000000, /* black */
     89 	0x800000aa, /* red */
     90 	0x8000aa00, /* green */
     91 	0x8000aaaa, /* brown */
     92 	0x80aa0000, /* blue */
     93 	0x80aa00aa, /* magenta */
     94 	0x80aaaa00, /* cyan */
     95 	0x80aaaaaa, /* white */
     96 	0x80000000, /* black */
     97 	0x800000ff, /* red */
     98 	0x8000ff00, /* green */
     99 	0x8000ffff, /* brown */
    100 	0x80ff0000, /* blue */
    101 	0x80ff00ff, /* magenta */
    102 	0x80ffff00, /* cyan */
    103 	0x80ffffff, /* black */
    104 };
    105 
    106 #define TRXPOS_DXY(f, x, y)						\
    107 ({									\
    108 	f[9] = ((x) & 0x000007ff) | (((y) << 16) & 0x07ff0000);		\
    109 })
    110 
    111 #define TRXPOS_SY_DY(f, sy, dy)						\
    112 ({									\
    113 	f[8] = (((sy) << 16) & 0x07ff0000);				\
    114 	f[9] = (((dy) << 16) & 0x07ff0000);				\
    115 })
    116 
    117 #define TRXPOS_DXY_SXY(f, dx, dy, sx, sy)				\
    118 ({									\
    119 	f[8] = ((((sy) << 16) & 0x07ff0000) | ((sx) & 0x000007ff));	\
    120 	f[9] = ((((dy) << 16) & 0x07ff0000) | ((dx) & 0x000007ff));	\
    121 })
    122 
    123 STATIC u_int32_t gsfb_scroll_cmd_640x16[] __attribute__((__aligned__(16))) = {
    124         0x00008004, 0x10000000, 0x0000000e, 0x00000000,
    125         0x000a0000, 0x000a0000, 0x00000050, 0x00000000,
    126         0x07ff0000, 0x07ff0000, 0x00000051, 0x00000000,
    127         0x00000280, 0x00000010, 0x00000052, 0x00000000,
    128         0x00000002, 0x00000000, 0x00000053, 0x00000000,
    129 };
    130 
    131 STATIC u_int32_t gsfb_cursor_cmd[] __attribute__((__aligned__(16))) = {
    132 	0x00008007, 0x10000000, 0x0000000e, 0x00000000,
    133 	0x00000001, 0x00000000, 0x0000001a, 0x00000000,
    134         0x000000a4, 0x00000080, 0x00000042, 0x00000000,
    135 	0x00000046, 0x00000000, 0x00000000, 0x00000000,
    136 	0x80ffffff, 0x00000000, 0x00000001, 0x00000000,
    137 	0x00000000, 0x00000000, 0x0000000d, 0x00000000,
    138 	0x80ffffff, 0x00000000, 0x00000001, 0x00000000,
    139 	0x00000000, 0x00000000, 0x00000005, 0x00000000,
    140 };
    141 
    142 STATIC u_int32_t gsfb_copy_cmd_8x16[] __attribute__((__aligned__(16))) = {
    143         0x00008004, 0x10000000, 0x0000000e, 0x00000000,
    144         0x000a0000, 0x000a0000, 0x00000050, 0x00000000,
    145         0x07ff07ff, 0x07ff07ff, 0x00000051, 0x00000000,
    146         0x00000008, 0x00000010, 0x00000052, 0x00000000,
    147         0x00000002, 0x00000000, 0x00000053, 0x00000000,
    148 };
    149 
    150 STATIC u_int32_t gsfb_init_cmd_640x480[] __attribute__((__aligned__(16))) = {
    151 	0x00008008, 0x10000000, 0x0000000e, 0x00000000,
    152 	0x000a0000, 0x00000000, 0x0000004c, 0x00000000,
    153 	0x00000096, 0x00000000, 0x0000004e, 0x00000000,
    154 	0x02800000, 0x01e00000, 0x00000040, 0x00000000,
    155 	0x00000006, 0x00000000, 0x00000000, 0x00000000,
    156 	0x80000000, 0x00000000, 0x00000001, 0x00000000,
    157 	0x00000000, 0x00000000, 0x0000000d, 0x00000000,
    158 	0x80000000, 0x00000000, 0x00000001, 0x00000000,
    159 	0x1e002800, 0x00000000, 0x00000005, 0x00000000,
    160 };
    161 
    162 STATIC u_int32_t gsfb_load_cmd_8x16_psmct32[(6 + 32) * 4]
    163 	__attribute__((__aligned__(16))) = {
    164 	/* GIF tag + GS command */
    165         0x00000004, 0x10000000, 0x0000000e, 0x00000000,
    166         0x00000000, 0x000a0000, 0x00000050, 0x00000000,
    167         0x00000000, 0x00000000, 0x00000051, 0x00000000,
    168         0x00000008, 0x00000016, 0x00000052, 0x00000000,
    169         0x00000000, 0x00000000, 0x00000053, 0x00000000,
    170         0x00008020, 0x08000000, 0x00000000, 0x00000000,
    171 	/* Load area */
    172 #define FONT_SCRATCH_BASE	(6 * 4)
    173 };
    174 
    175 #ifdef GSFB_DEBUG_MONITOR
    176 #include <machine/stdarg.h>
    177 STATIC const struct _gsfb_debug_window {
    178 	int start, nrow, attr;
    179 } _gsfb_debug_window[3] = {
    180 	{ 24, 2 , ATTR_BG_SET(WSCOL_BROWN) | ATTR_FG_SET(WSCOL_BLUE) },
    181 	{ 26, 2 , ATTR_BG_SET(WSCOL_CYAN) | ATTR_FG_SET(WSCOL_BLUE) },
    182 	{ 28, 2 , ATTR_BG_SET(WSCOL_WHITE) | ATTR_FG_SET(WSCOL_BLUE) },
    183 };
    184 STATIC char _gsfb_debug_buf[80 * 2];
    185 #endif /* GSFB_DEBUG_MONITOR */
    186 
    187 STATIC int gsfb_match(struct device *, struct cfdata *, void *);
    188 STATIC void gsfb_attach(struct device *, struct device *, void *);
    189 
    190 CFATTACH_DECL(gsfb, sizeof(struct device),
    191     gsfb_match, gsfb_attach, NULL, NULL);
    192 
    193 STATIC void gsfb_hwinit(void);
    194 STATIC int gsfb_swinit(void);
    195 
    196 /* console */
    197 void gsfbcnprobe(struct consdev *);
    198 void gsfbcninit(struct consdev *);
    199 
    200 /* emul ops */
    201 STATIC void _gsfb_cursor(void *, int, int, int);
    202 STATIC int _gsfb_mapchar(void *, int, unsigned int *);
    203 STATIC void _gsfb_putchar(void *, int, int, u_int, long);
    204 STATIC void _gsfb_copycols(void *, int, int, int, int);
    205 STATIC void _gsfb_erasecols(void *, int, int, int, long);
    206 STATIC void _gsfb_copyrows(void *, int, int, int);
    207 STATIC void _gsfb_eraserows(void *, int, int, long);
    208 STATIC int _gsfb_allocattr(void *, int, int, int, long *);
    209 
    210 /* access ops */
    211 STATIC int _gsfb_ioctl(void *, u_long, caddr_t, int, struct proc *);
    212 STATIC paddr_t _gsfb_mmap(void *, off_t, int);
    213 STATIC int _gsfb_alloc_screen(void *, const struct wsscreen_descr *, void **,
    214     int *, int *, long *);
    215 STATIC void _gsfb_free_screen(void *, void *);
    216 STATIC int _gsfb_show_screen(void *, void *, int, void (*)(void *, int, int),
    217     void *);
    218 STATIC void _gsfb_pollc(void *, int);
    219 
    220 /*
    221  * wsdisplay attach args
    222  *   std: screen size 640 x 480, font size 8 x 16
    223  */
    224 #define GSFB_STD_SCREEN_WIDTH		640
    225 #define GSFB_STD_SCREEN_HEIGHT		480
    226 #define GSFB_STD_FONT_WIDTH		8
    227 #define GSFB_STD_FONT_HEIGHT		16
    228 const struct wsdisplay_emulops _gsfb_emulops = {
    229 	.cursor		= _gsfb_cursor,
    230 	.mapchar	= _gsfb_mapchar,
    231 	.putchar	= _gsfb_putchar,
    232 	.copycols	= _gsfb_copycols,
    233 	.erasecols	= _gsfb_erasecols,
    234 	.copyrows	= _gsfb_copyrows,
    235 	.eraserows	= _gsfb_eraserows,
    236 	.allocattr	= _gsfb_allocattr
    237 };
    238 
    239 const struct wsscreen_descr _gsfb_std_screen = {
    240 	.name		= "std",
    241 	.ncols		= 80,
    242 #ifdef GSFB_DEBUG_MONITOR
    243 	.nrows		= 24,
    244 #else
    245 	.nrows		= 30,
    246 #endif
    247 	.textops	= &_gsfb_emulops,
    248 	.fontwidth	= 8,
    249 	.fontheight	= 16,
    250 	.capabilities	= WSSCREEN_UNDERLINE | WSSCREEN_HILIT |
    251 	WSSCREEN_WSCOLORS
    252 };
    253 
    254 const struct wsscreen_descr *_gsfb_screen_table[] = {
    255 	&_gsfb_std_screen,
    256 };
    257 
    258 struct wsscreen_list _gsfb_screen_list = {
    259 	.nscreens	= sizeof(_gsfb_screen_table) /
    260 	sizeof(_gsfb_screen_table[0]),
    261 	.screens	= _gsfb_screen_table
    262 };
    263 
    264 struct wsdisplay_accessops _gsfb_accessops = {
    265 	.ioctl		= _gsfb_ioctl,
    266 	.mmap		= _gsfb_mmap,
    267 	.alloc_screen	= _gsfb_alloc_screen,
    268 	.free_screen	= _gsfb_free_screen,
    269 	.show_screen	= _gsfb_show_screen,
    270 	.load_font	= 0,
    271 	.pollc		= _gsfb_pollc
    272 };
    273 
    274 int
    275 gsfb_match(struct device *parent, struct cfdata *cf, void *aux)
    276 {
    277 	extern struct cfdriver gsfb_cd;
    278 	struct mainbus_attach_args *ma = aux;
    279 
    280 	if (strcmp(ma->ma_name, gsfb_cd.cd_name) != 0)
    281 		return (0);
    282 
    283 	return (!gsfb.attached);
    284 }
    285 
    286 void
    287 gsfb_attach(struct device *parent, struct device *self, void *aux)
    288 {
    289 	struct wsemuldisplaydev_attach_args wa;
    290 
    291 	gsfb.attached = 1;
    292 	if (!gsfb.is_console && gsfb_swinit() != 0)
    293 		return;
    294 
    295 	printf("\n");
    296 
    297 	wa.console	= gsfb.is_console;
    298 	wa.scrdata	= &_gsfb_screen_list;
    299 	wa.accessops	= &_gsfb_accessops;
    300 	wa.accesscookie	= &gsfb;
    301 
    302 	config_found(self, &wa, wsdisplaydevprint);
    303 }
    304 
    305 /*
    306  * console
    307  */
    308 void
    309 gsfbcnprobe(struct consdev *cndev)
    310 {
    311 
    312 	cndev->cn_pri = CN_INTERNAL;
    313 }
    314 
    315 void
    316 gsfbcninit(struct consdev *cndev)
    317 {
    318 	paddr_t paddr = MIPS_KSEG0_TO_PHYS(gsfb_init_cmd_640x480);
    319 	long defattr =  ATTR_BG_SET(WSCOL_BLACK) | ATTR_FG_SET(WSCOL_WHITE);
    320 
    321 	gsfb.is_console = 1;
    322 
    323 	gsfb_hwinit();
    324 	gsfb_swinit();
    325 
    326 	gsfb_dma_kick(paddr, sizeof gsfb_init_cmd_640x480);
    327 #ifdef GSFB_DEBUG_MONITOR
    328 	{
    329 		const struct _gsfb_debug_window *win;
    330 		int i;
    331 
    332 		for (i = 0; i < 3; i++) {
    333 			win = &_gsfb_debug_window[i];
    334 			_gsfb_eraserows(0, win->start, win->nrow, win->attr);
    335 		}
    336 	}
    337 #endif /* GSFB_DEBUG_MONITOR */
    338 
    339 	wsdisplay_cnattach(&_gsfb_std_screen, &gsfb, 0, 0, defattr);
    340 }
    341 
    342 void
    343 gsfb_hwinit()
    344 {
    345 	gs_init(VESA_1A);
    346 	dmac_init();
    347 
    348 	/* reset GIF channel DMA */
    349 	_reg_write_4(D2_QWC_REG, 0);
    350 	_reg_write_4(D2_MADR_REG, 0);
    351 	_reg_write_4(D2_TADR_REG, 0);
    352 	_reg_write_4(D2_CHCR_REG, 0);
    353 }
    354 
    355 int
    356 gsfb_swinit()
    357 {
    358 	int font;
    359 
    360 	wsfont_init();
    361 	font = wsfont_find(NULL, 8, 16, 0,  WSDISPLAY_FONTORDER_L2R,
    362 	    WSDISPLAY_FONTORDER_L2R);
    363 	if (font < 0)
    364 		return (1);
    365 
    366 	if (wsfont_lock(font, &gsfb.font))
    367 		return (1);
    368 
    369 	gsfb.screen = &_gsfb_std_screen;
    370 	gsfb.initialized = 1;
    371 
    372 	return (0);
    373 }
    374 
    375 /*
    376  * wsdisplay
    377  */
    378 void
    379 _gsfb_cursor(void *cookie, int on, int row, int col)
    380 {
    381 	paddr_t paddr = MIPS_KSEG0_TO_PHYS(gsfb_cursor_cmd);
    382 	u_int32_t *buf = (void *)MIPS_PHYS_TO_KSEG1(paddr);
    383 	struct wsdisplay_font *font = gsfb.font;
    384 
    385 	gsfb_set_cursor_pos(buf, col, row, font->fontwidth, font->fontheight);
    386 
    387 	gsfb_dma_kick(paddr, sizeof gsfb_cursor_cmd);
    388 }
    389 
    390 __inline__ void
    391 gsfb_set_cursor_pos(u_int32_t *p, int x, int y, int w, int h)
    392 {
    393 
    394 	x *= w;
    395 	y *= h;
    396 	p[20] = ((x << 4) & 0xffff) | ((y << 20) & 0xffff0000);
    397 	p[28] = (((x + w - 1) << 4) & 0xffff) |
    398 	    (((y + h - 1) << 20) & 0xffff0000);
    399 }
    400 
    401 int
    402 _gsfb_mapchar(void *cookie, int c, unsigned int *cp)
    403 {
    404 	struct wsdisplay_font *font = gsfb.font;
    405 
    406 	if (font->encoding != WSDISPLAY_FONTENC_ISO)
    407 		if ((c = wsfont_map_unichar(font, c)) < 0)
    408 			goto nomap;
    409 
    410 	if (c < font->firstchar || c >= font->firstchar + font->numchars)
    411 			goto nomap;
    412 
    413 	*cp = c;
    414 	return (5);
    415 
    416  nomap:
    417 	*cp = ' ';
    418 	return (0);
    419 }
    420 
    421 void
    422 _gsfb_putchar(void *cookie, int row, int col, u_int uc, long attr)
    423 {
    424 	paddr_t paddr = MIPS_KSEG0_TO_PHYS(gsfb_load_cmd_8x16_psmct32);
    425 	u_int32_t *buf = (void *)MIPS_PHYS_TO_KSEG1(paddr);
    426 	struct wsdisplay_font *font = gsfb.font;
    427 
    428 	/* copy font data to DMA region */
    429 	gsfb_font_expand_psmct32(font, uc, attr, &buf[FONT_SCRATCH_BASE]);
    430 
    431 	/* set destination position */
    432 	TRXPOS_DXY(buf, col * font->fontwidth, row * font->fontheight);
    433 
    434 	/* kick to GIF */
    435 	gsfb_dma_kick(paddr, sizeof gsfb_load_cmd_8x16_psmct32);
    436 }
    437 
    438 void
    439 _gsfb_copycols(void *cookie, int row, int srccol, int dstcol, int ncols)
    440 {
    441 	paddr_t paddr = MIPS_KSEG0_TO_PHYS(gsfb_copy_cmd_8x16);
    442 	u_int32_t *cmd = (void *)MIPS_PHYS_TO_KSEG1(paddr);
    443 	int y = gsfb.font->fontheight * row;
    444 	int w = gsfb.font->fontwidth;
    445 	int i;
    446 
    447 	if (dstcol > srccol) {
    448 		for (i = ncols - 1; i >= 0; i--) {
    449 			TRXPOS_DXY_SXY(cmd, (dstcol + i) * w, y, (srccol + i) * w, y);
    450 			gsfb_dma_kick(paddr, sizeof gsfb_copy_cmd_8x16);
    451 		}
    452 	} else {
    453 		for (i = 0; i < ncols; i++) {
    454 			TRXPOS_DXY_SXY(cmd, (dstcol + i) * w, y, (srccol + i) * w, y);
    455 			gsfb_dma_kick(paddr, sizeof gsfb_copy_cmd_8x16);
    456 		}
    457 	}
    458 }
    459 
    460 void
    461 _gsfb_erasecols(void *cookie, int row, int startcol, int ncols, long attr)
    462 {
    463 	int i;
    464 
    465 	for (i = 0; i < ncols; i++)
    466 		_gsfb_putchar(cookie, row, startcol + i, ' ', attr);
    467 }
    468 
    469 void
    470 _gsfb_copyrows(void *cookie, int src, int dst, int num)
    471 {
    472 	paddr_t paddr = MIPS_KSEG0_TO_PHYS(gsfb_scroll_cmd_640x16);
    473 	u_int32_t *cmd = (void *)MIPS_PHYS_TO_KSEG1(paddr);
    474 	int i;
    475 	int h = gsfb.font->fontheight;
    476 
    477 	if (dst > src) {
    478 		for (i = num - 1; i >= 0; i--) {
    479 			TRXPOS_SY_DY(cmd, (src + i) * h, (dst  + i) * h);
    480 			gsfb_dma_kick(paddr, sizeof gsfb_scroll_cmd_640x16);
    481 		}
    482 	} else {
    483 		for (i = 0; i < num; i++) {
    484 			TRXPOS_SY_DY(cmd, (src + i) * h, (dst  + i) * h);
    485 			gsfb_dma_kick(paddr, sizeof gsfb_scroll_cmd_640x16);
    486 		}
    487 	}
    488 }
    489 
    490 void
    491 _gsfb_eraserows(void *cookie, int row, int nrow, long attr)
    492 {
    493 	int i, j;
    494 
    495 	for (j = 0; j < nrow; j++)
    496 		for (i = 0; i < gsfb.screen->ncols; i++)
    497 			_gsfb_putchar(cookie, row + j, i, ' ', attr);
    498 }
    499 
    500 int
    501 _gsfb_allocattr(void *cookie, int fg, int bg, int flags, long *attr)
    502 {
    503 
    504 	if ((flags & WSATTR_BLINK) != 0)
    505 		return (EINVAL);
    506 
    507 	if ((flags & WSATTR_WSCOLORS) == 0) {
    508 		fg = WSCOL_WHITE;
    509 		bg = WSCOL_BLACK;
    510 	}
    511 
    512 	if ((flags & WSATTR_HILIT) != 0)
    513 		fg += 8;
    514 
    515 	flags = (flags & WSATTR_UNDERLINE) ? 1 : 0;
    516 
    517 
    518 	*attr = ATTR_BG_SET(bg) | ATTR_FG_SET(fg) | flags;
    519 
    520 	return (0);
    521 }
    522 
    523 int
    524 _gsfb_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
    525 {
    526 
    527 	return (EPASSTHROUGH); /* Inappropriate ioctl for device */
    528 }
    529 
    530 paddr_t
    531 _gsfb_mmap(void *v, off_t offset, int prot)
    532 {
    533 
    534 	return (-1); /* can't mmap */
    535 }
    536 
    537 int
    538 _gsfb_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
    539     int *curxp, int *curyp, long *attrp)
    540 {
    541 
    542 	*attrp = ATTR_BG_SET(WSCOL_BLACK) | ATTR_FG_SET(WSCOL_WHITE);
    543 
    544 	return (0);
    545 }
    546 
    547 void
    548 _gsfb_free_screen(void *v, void *cookie)
    549 {
    550 }
    551 
    552 int
    553 _gsfb_show_screen(void *v, void *cookie, int waitok,
    554     void (*cb)(void *, int, int), void *cbarg)
    555 {
    556 
    557 	return (0);
    558 }
    559 
    560 void
    561 _gsfb_pollc(void *v, int on)
    562 {
    563 
    564 }
    565 
    566 /*
    567  * font expansion
    568  *   PSMCT32 only
    569  */
    570 void
    571 gsfb_font_expand_psmct32(const struct wsdisplay_font *font, u_int c, long attr,
    572     u_int32_t *buf)
    573 {
    574 	u_int32_t fg, bg;
    575 	u_int8_t *bitmap;
    576 	int i, j;
    577 
    578 	KDASSERT(((u_int32_t)buf & 15) == 0);
    579 
    580 	fg = gsfb_ansi_psmct32[ATTR_FG_GET(attr)];
    581 	bg = gsfb_ansi_psmct32[ATTR_BG_GET(attr)];
    582 
    583 	bitmap = (u_int8_t *)font->data + (c - font->firstchar) *
    584 	    font->fontheight * font->stride;
    585 	for (i = 0; i < font->fontheight; i++, bitmap++) {
    586 		u_int32_t b = *bitmap;
    587 		for (j = 0; j < font->fontwidth; j++, b <<= 1)
    588 			*buf++ = (b & 0x80) ? fg : bg;
    589 	}
    590 }
    591 
    592 void
    593 gsfb_dma_kick(paddr_t addr, size_t size)
    594 {
    595 	/* Wait for previous DMA request complete */
    596 	while (_reg_read_4(D2_QWC_REG))
    597 		;
    598 
    599 	/* Wait until GS FIFO empty */
    600 	while ((_reg_read_8(GS_S_CSR_REG) & (3 << 14)) != (1 << 14))
    601 		;
    602 
    603 	/* wait for DMA complete */
    604 	dmac_bus_poll(D_CH2_GIF);
    605 
    606 	/* transfer addr */
    607 	_reg_write_4(D2_MADR_REG, addr);
    608 	/* transfer data size (unit qword) */
    609 	_reg_write_4(D2_QWC_REG, bytetoqwc(size));
    610 
    611 	/* kick DMA (normal-mode) */
    612 	dmac_chcr_write(D_CH2_GIF, D_CHCR_STR);
    613 }
    614 
    615 #ifdef GSFB_DEBUG_MONITOR
    616 void
    617 __gsfb_print(int window, const char *fmt, ...)
    618 {
    619 	const struct _gsfb_debug_window *win;
    620 	int i, s, x, y, n, a;
    621 	u_int c;
    622 	va_list ap;
    623 
    624 	if (!gsfb.initialized)
    625 		return;
    626 
    627 	s = _intr_suspend();
    628 	win = &_gsfb_debug_window[window];
    629 	x = 0;
    630 	y = win->start;
    631 	n = win->nrow * 80;
    632 	a = win->attr;
    633 
    634 	va_start(ap, fmt);
    635 	vsnprintf(_gsfb_debug_buf, n, fmt, ap);
    636 	va_end(ap);
    637 
    638 	_gsfb_eraserows(0, y, win->nrow, a);
    639 
    640 	for (i = 0; i < n &&
    641 	    (c = (u_int)_gsfb_debug_buf[i] & 0x7f) != 0; i++) {
    642 		if (c == '\n')
    643 			x = 0, y++;
    644 		else
    645 			_gsfb_putchar(0, y, x++, c, a);
    646 	}
    647 
    648 	_intr_resume(s);
    649 }
    650 
    651 void
    652 __gsfb_print_hex(int a0, int a1, int a2, int a3)
    653 {
    654 	__gsfb_print(2, "a0=%08x a1=%08x a2=%08x a3=%08x",
    655 	    a0, a1, a2, a3);
    656 }
    657 #endif /* GSFB_DEBUG_MONITOR */
    658