Home | History | Annotate | Line # | Download | only in dev
ite_et.c revision 1.12.4.1
      1 /*	$NetBSD: ite_et.c,v 1.12.4.1 2002/05/19 07:56:39 gehenna Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1996 Leo Weppelman.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *      This product includes software developed by Leo Weppelman.
     18  * 4. The name of the author may not be used to endorse or promote products
     19  *    derived from this software without specific prior written permission
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 #include <sys/param.h>
     33 #include <sys/systm.h>
     34 #include <sys/conf.h>
     35 #include <sys/ioctl.h>
     36 #include <sys/malloc.h>
     37 #include <sys/device.h>
     38 #include <dev/cons.h>
     39 
     40 #include <machine/cpu.h>
     41 
     42 #include <atari/atari/device.h>
     43 
     44 #include <atari/dev/itevar.h>
     45 #include <atari/dev/iteioctl.h>
     46 #include <atari/dev/grfioctl.h>
     47 #include <atari/dev/grf_etreg.h>
     48 #include <atari/dev/grfabs_reg.h>
     49 #include <atari/dev/grfabs_et.h>
     50 #include <atari/dev/grfvar.h>
     51 #include <atari/dev/font.h>
     52 #include <atari/dev/viewioctl.h>
     53 #include <atari/dev/viewvar.h>
     54 
     55 #include "grfet.h"
     56 
     57 /*
     58  * This is what ip->priv points to;
     59  * it contains local variables for custom-chip ites.
     60  */
     61 struct ite_priv {
     62 	volatile u_char	*regkva;
     63 };
     64 
     65 typedef struct ite_priv ipriv_t;
     66 
     67 static ipriv_t	con_ipriv;
     68 
     69 /* Console colors */
     70 static u_char etconscolors[3][3] = {	/* background, foreground, hilite */
     71 	{0x0, 0x0, 0x0}, {0x30, 0x30, 0x30}, { 0x3f,  0x3f,  0x3f}
     72 };
     73 
     74 /* XXX: Shouldn't these be in font.h???? */
     75 extern font_info	font_info_8x8;
     76 extern font_info	font_info_8x16;
     77 
     78 static void grfet_iteinit __P((struct grf_softc *));
     79 static void view_init __P((struct ite_softc *));
     80 static void view_deinit __P((struct ite_softc *));
     81 static int  iteet_ioctl __P((struct ite_softc *, u_long, caddr_t, int,
     82 							struct proc *));
     83 static int  ite_newsize __P((struct ite_softc *, struct itewinsize *));
     84 static void et_inittextmode __P((struct ite_softc *, et_sv_reg_t *, int));
     85 void et_cursor __P((struct ite_softc *ip, int flag));
     86 void et_clear __P((struct ite_softc *ip, int sy, int sx, int h, int w));
     87 void et_putc __P((struct ite_softc *ip, int c, int dy, int dx, int mode));
     88 void et_scroll __P((struct ite_softc *ip, int sy, int sx, int count,
     89     int dir));
     90 
     91 /*
     92  * grfet config stuff
     93  */
     94 void grfetattach __P((struct device *, struct device *, void *));
     95 int  grfetmatch __P((struct device *, struct cfdata *, void *));
     96 int  grfetprint __P((void *, const char *));
     97 
     98 struct cfattach grfet_ca = {
     99 	sizeof(struct grf_softc), grfetmatch, grfetattach
    100 };
    101 
    102 /*
    103  * only used in console init.
    104  */
    105 static struct cfdata *cfdata_grf   = NULL;
    106 
    107 int
    108 grfetmatch(pdp, cfp, auxp)
    109 struct device	*pdp;
    110 struct cfdata	*cfp;
    111 void		*auxp;
    112 {
    113 	static int	card_probed  = -1;
    114 	static int	did_consinit = 0;
    115 	grf_auxp_t	*grf_auxp = auxp;
    116 	extern const struct cdevsw view_cdevsw;
    117 
    118 	if (card_probed <= 0) {
    119 		if (card_probed == 0) /* Probed but failed */
    120 			return 0;
    121 		card_probed = 0;
    122 
    123 		/*
    124 		 * Check if the layers we depend on exist
    125 		 */
    126 		if(!(machineid & ATARI_HADES))
    127 			return 0;
    128 		if (!et_probe_card())
    129 			return 0;
    130 		if (grfabs_probe(&et_probe_video) == 0)
    131 			return 0;
    132 		viewprobe();
    133 		card_probed = 1; /* Probed and found */
    134 	}
    135 
    136 	if (atari_realconfig == 0) {
    137 		/*
    138 		 * Early console init. Only match first unit.
    139 		 */
    140 		if (did_consinit)
    141 			return 0;
    142 		if ((*view_cdevsw.d_open)(cfp->cf_unit, 0, 0, NULL))
    143 			return 0;
    144 		cfdata_grf = cfp;
    145 		did_consinit = 1;
    146 		return 1;
    147 	}
    148 
    149 	/*
    150 	 * Normal config. When we are called directly from the grfbus,
    151 	 * we only match the first unit. The attach function will call us for
    152 	 * the other configured units.
    153 	 */
    154 	if (grf_auxp->from_bus_match
    155 	    && ((did_consinit > 1) || !et_probe_card()))
    156 		return 0;
    157 
    158 	if (!grf_auxp->from_bus_match && (grf_auxp->unit != cfp->cf_unit))
    159 		return 0;
    160 
    161 	/*
    162 	 * Final constraint: each grf needs a view....
    163 	 */
    164 	if((cfdata_grf == NULL) || (did_consinit > 1)) {
    165 	    if((*view_cdevsw.d_open)(cfp->cf_unit, 0, 0, NULL))
    166 		return 0;
    167 	}
    168 	did_consinit = 2;
    169 	return 1;
    170 }
    171 
    172 /*
    173  * attach: initialize the grf-structure and try to attach an ite to us.
    174  * note  : dp is NULL during early console init.
    175  */
    176 void
    177 grfetattach(pdp, dp, auxp)
    178 struct device	*pdp, *dp;
    179 void		*auxp;
    180 {
    181 	static struct grf_softc		congrf;
    182 	static int			first_attach = 1;
    183 	       grf_auxp_t		*grf_bus_auxp = auxp;
    184 	       grf_auxp_t		grf_auxp;
    185 	       struct grf_softc		*gp;
    186 	       int			maj;
    187 	extern const struct cdevsw grf_cdevsw;
    188 
    189 	/*
    190 	 * find our major device number
    191 	 */
    192 	maj = cdevsw_lookup_major(&grf_cdevsw);
    193 
    194 	/*
    195 	 * Handle exeption case: early console init
    196 	 */
    197 	if(dp == NULL) {
    198 		congrf.g_unit    = cfdata_grf->cf_unit;
    199 		congrf.g_grfdev  = makedev(maj, congrf.g_unit);
    200 		congrf.g_itedev  = (dev_t)-1;
    201 		congrf.g_flags   = GF_ALIVE;
    202 		congrf.g_mode    = grf_mode;
    203 		congrf.g_conpri  = CN_INTERNAL;
    204 		congrf.g_viewdev = congrf.g_unit;
    205 		grfet_iteinit(&congrf);
    206 		grf_viewsync(&congrf);
    207 
    208 		/* Attach console ite */
    209 		atari_config_found(cfdata_grf, NULL, &congrf, grfetprint);
    210 		return;
    211 	}
    212 
    213 	gp = (struct grf_softc *)dp;
    214 	gp->g_unit = gp->g_device.dv_unit;
    215 	grfsp[gp->g_unit] = gp;
    216 
    217 	if((cfdata_grf != NULL) && (gp->g_unit == congrf.g_unit)) {
    218 		/*
    219 		 * We inited earlier just copy the info, take care
    220 		 * not to copy the device struct though.
    221 		 */
    222 		bcopy(&congrf.g_display, &gp->g_display,
    223 			(char *)&gp[1] - (char *)&gp->g_display);
    224 	}
    225 	else {
    226 		gp->g_grfdev  = makedev(maj, gp->g_unit);
    227 		gp->g_itedev  = (dev_t)-1;
    228 		gp->g_flags   = GF_ALIVE;
    229 		gp->g_mode    = grf_mode;
    230 		gp->g_conpri  = 0;
    231 		gp->g_viewdev = gp->g_unit;
    232 		grfet_iteinit(gp);
    233 		grf_viewsync(gp);
    234 	}
    235 
    236 	printf(": %dx%d", gp->g_display.gd_dwidth, gp->g_display.gd_dheight);
    237 	if(gp->g_display.gd_colors == 2)
    238 		printf(" monochrome\n");
    239 	else printf(" colors %d\n", gp->g_display.gd_colors);
    240 
    241 	/*
    242 	 * try and attach an ite
    243 	 */
    244 	config_found(dp, gp, grfetprint);
    245 
    246 	/*
    247 	 * If attaching the first unit, go ahead and 'find' the rest of us
    248 	 */
    249 	if (first_attach) {
    250 		first_attach = 0;
    251 		grf_auxp.from_bus_match = 0;
    252 		for (grf_auxp.unit=0; grf_auxp.unit < NGRFET; grf_auxp.unit++) {
    253 		    config_found(pdp, (void*)&grf_auxp, grf_bus_auxp->busprint);
    254 		}
    255 	}
    256 }
    257 
    258 int
    259 grfetprint(auxp, pnp)
    260 void *auxp;
    261 const char *pnp;
    262 {
    263 	if(pnp) /* XXX */
    264 		printf("ite at %s", pnp);
    265 	return(UNCONF);
    266 }
    267 
    268 /*
    269  * Init ite portion of grf_softc struct
    270  */
    271 static void
    272 grfet_iteinit(gp)
    273 struct grf_softc *gp;
    274 {
    275 
    276 	gp->g_itecursor = et_cursor;
    277 	gp->g_iteputc   = et_putc;
    278 	gp->g_iteclear  = et_clear;
    279 	gp->g_itescroll = et_scroll;
    280 	gp->g_iteinit   = view_init;
    281 	gp->g_itedeinit = view_deinit;
    282 }
    283 
    284 static void
    285 view_deinit(ip)
    286 struct ite_softc	*ip;
    287 {
    288 	ip->flags &= ~ITE_INITED;
    289 }
    290 
    291 static void
    292 view_init(ip)
    293 register struct ite_softc *ip;
    294 {
    295 	struct itewinsize	wsz;
    296 	ipriv_t			*cci;
    297 	view_t			*view;
    298 	save_area_t		*et_save;
    299 
    300 	if((cci = ip->priv) != NULL)
    301 		return;
    302 
    303 	ip->itexx_ioctl = iteet_ioctl;
    304 
    305 #if defined(KFONT_8X8)
    306 	ip->font = font_info_8x8;
    307 #else
    308 	ip->font = font_info_8x16;
    309 #endif
    310 
    311 	/* Find the correct set of rendering routines for this font.  */
    312 	if(ip->font.width != 8)
    313 		panic("kernel font size not supported");
    314 
    315 	if(!atari_realconfig)
    316 		ip->priv = cci = &con_ipriv;
    317 	else ip->priv = cci = (ipriv_t*)malloc(sizeof(*cci), M_DEVBUF,M_WAITOK);
    318 	if(cci == NULL)
    319 		panic("No memory for ite-view");
    320 	bzero(cci, sizeof(*cci));
    321 
    322 	wsz.x      = ite_default_x;
    323 	wsz.y      = ite_default_y;
    324 	wsz.width  = ite_default_width;
    325 	wsz.height = ite_default_height;
    326 	wsz.depth  = ite_default_depth;
    327 
    328 	ite_newsize (ip, &wsz);
    329 
    330 	view  = viewview(ip->grf->g_viewdev);
    331 	cci->regkva = view->bitmap->regs;
    332 
    333 	/*
    334 	 * Only console will be turned on by default..
    335 	 */
    336 	if(ip->flags & ITE_ISCONS)
    337 		ip->grf->g_mode(ip->grf, GM_GRFON, NULL, 0, 0);
    338 
    339 	/*
    340 	 * Activate text-mode settings
    341 	 */
    342 	et_save = (save_area_t *)view->save_area;
    343 	if (et_save == NULL)
    344 		et_inittextmode(ip, NULL, view->flags & VF_DISPLAY);
    345 	else {
    346 		et_inittextmode(ip, &et_save->sv_regs, view->flags&VF_DISPLAY);
    347 		et_save->fb_size = ip->cols * ip->rows;
    348 	}
    349 }
    350 
    351 static int
    352 ite_newsize(ip, winsz)
    353 struct ite_softc	*ip;
    354 struct itewinsize	*winsz;
    355 {
    356 	struct view_size	vs;
    357 	int			error = 0;
    358 	save_area_t		*et_save;
    359 	view_t			*view;
    360 	extern const struct cdevsw view_cdevsw;
    361 
    362 	vs.x      = winsz->x;
    363 	vs.y      = winsz->y;
    364 	vs.width  = winsz->width;
    365 	vs.height = winsz->height;
    366 	vs.depth  = winsz->depth;
    367 
    368 	error = (*view_cdevsw.d_ioctl)(ip->grf->g_viewdev, VIOCSSIZE,
    369 				       (caddr_t)&vs, 0, NOPROC);
    370 	view  = viewview(ip->grf->g_viewdev);
    371 
    372 	/*
    373 	 * Reinitialize our structs
    374 	 */
    375 	ip->cols = view->display.width  / ip->font.width;
    376 	ip->rows = view->display.height / ip->font.height;
    377 
    378 	/*
    379 	 * save new values so that future opens use them
    380 	 * this may not be correct when we implement Virtual Consoles
    381 	 */
    382 	ite_default_height = view->display.height;
    383 	ite_default_width  = view->display.width;
    384 	ite_default_x      = view->display.x;
    385 	ite_default_y      = view->display.y;
    386 	ite_default_depth  = view->bitmap->depth;
    387 
    388 	et_save = (save_area_t *)view->save_area;
    389 	if (et_save == NULL)
    390 	    et_inittextmode(ip, NULL, view->flags & VF_DISPLAY);
    391 	else {
    392 	    et_inittextmode(ip, &et_save->sv_regs, view->flags & VF_DISPLAY);
    393 	    et_save->fb_size = ip->cols * ip->rows;
    394 	}
    395 	et_clear(ip, 0, 0, ip->rows, ip->cols);
    396 
    397 	return(error);
    398 }
    399 
    400 int
    401 iteet_ioctl(ip, cmd, addr, flag, p)
    402 struct ite_softc	*ip;
    403 u_long			cmd;
    404 caddr_t			addr;
    405 int			flag;
    406 struct proc		*p;
    407 {
    408 	struct winsize		ws;
    409 	struct itewinsize	*is;
    410 	int			error = 0;
    411 	view_t			*view = viewview(ip->grf->g_viewdev);
    412 	extern const struct cdevsw ite_cdevsw;
    413 	extern const struct cdevsw view_cdevsw;
    414 
    415 	switch (cmd) {
    416 	case ITEIOCSWINSZ:
    417 		is = (struct itewinsize *)addr;
    418 
    419 		if(ite_newsize(ip, is))
    420 			error = ENOMEM;
    421 		else {
    422 			view         = viewview(ip->grf->g_viewdev);
    423 			ws.ws_row    = ip->rows;
    424 			ws.ws_col    = ip->cols;
    425 			ws.ws_xpixel = view->display.width;
    426 			ws.ws_ypixel = view->display.height;
    427 			ite_reset(ip);
    428 			/*
    429 			 * XXX tell tty about the change
    430 			 * XXX this is messy, but works
    431 			 */
    432 			(*ite_cdevsw.d_ioctl)(ip->grf->g_itedev, TIOCSWINSZ,
    433 					      (caddr_t)&ws, 0, p);
    434 		}
    435 		break;
    436 	case VIOCSCMAP:
    437 	case VIOCGCMAP:
    438 		/*
    439 		 * XXX watchout for that NOPROC. its not really the kernel
    440 		 * XXX talking these two commands don't use the proc pointer
    441 		 * XXX though.
    442 		 */
    443 		error = (*view_cdevsw.d_ioctl)(ip->grf->g_viewdev, cmd, addr,
    444 					       flag, NOPROC);
    445 		break;
    446 	default:
    447 		error = EPASSTHROUGH;
    448 		break;
    449 	}
    450 	return (error);
    451 }
    452 
    453 void
    454 et_cursor(ip, flag)
    455 	struct ite_softc *ip;
    456 	int flag;
    457 {
    458 	volatile u_char	*ba;
    459 		 view_t	*v;
    460 		 u_long cpos;
    461 
    462 	ba = ((ipriv_t*)ip->priv)->regkva;
    463 	v  = viewview(ip->grf->g_viewdev);
    464 
    465 	/*
    466 	 * Don't update the cursor when not on display
    467 	 */
    468 	if (!(v->flags & VF_DISPLAY))
    469 		return;
    470 
    471 	switch (flag) {
    472  	    case DRAW_CURSOR:
    473 		/*WCrt(ba, CRT_ID_CURSOR_START, & ~0x20); */
    474 	    case MOVE_CURSOR:
    475 		cpos  =  RCrt(ba, CRT_ID_START_ADDR_LOW) & 0xff;
    476 		cpos |= (RCrt(ba, CRT_ID_START_ADDR_HIGH) & 0xff) << 8;
    477 		cpos += ip->curx + ip->cury * ip->cols;
    478 		WCrt(ba, CRT_ID_CURSOR_LOC_LOW, cpos & 0xff);
    479 		WCrt(ba, CRT_ID_CURSOR_LOC_HIGH, (cpos >> 8) & 0xff);
    480 		WCrt(ba, CTR_ID_EXT_START, (cpos >> (16-2)) & 0x0c);
    481 
    482 		ip->cursorx = ip->curx;
    483 		ip->cursory = ip->cury;
    484 		break;
    485 	    case ERASE_CURSOR:
    486 		/*WCrt(ba, CRT_ID_CURSOR_START, | 0x20); */
    487 	    case START_CURSOROPT:
    488 	    case END_CURSOROPT:
    489 	    default:
    490 		break;
    491     	}
    492 }
    493 
    494 void
    495 et_putc(ip, c, dy, dx, mode)
    496 	struct ite_softc *ip;
    497 	int c;
    498 	int dy;
    499 	int dx;
    500 	int mode;
    501 {
    502 	view_t	*v   = viewview(ip->grf->g_viewdev);
    503 	u_char	attr;
    504 	u_short	*cp;
    505 
    506 	attr = (unsigned char) ((mode & ATTR_INV) ? (0x70) : (0x07));
    507 	if (mode & ATTR_UL)     attr |= 0x01;
    508 	if (mode & ATTR_BOLD)   attr |= 0x08;
    509 	if (mode & ATTR_BLINK)  attr |= 0x80;
    510 
    511 	cp  = (u_short*)v->bitmap->plane;
    512 	cp[(dy * ip->cols) + dx] = (c << 8) | attr;
    513 }
    514 
    515 void
    516 et_clear(ip, sy, sx, h, w)
    517 	struct ite_softc *ip;
    518 	int sy;
    519 	int sx;
    520 	int h;
    521 	int w;
    522 {
    523 	/* et_clear and et_scroll both rely on ite passing arguments
    524 	 * which describe continuous regions.  For a VT200 terminal,
    525 	 * this is safe behavior.
    526 	 */
    527 	view_t		*v   = viewview(ip->grf->g_viewdev);
    528 	u_short		*dest;
    529 	int		len;
    530 
    531 	dest = (u_short *)v->bitmap->plane + (sy * ip->cols) + sx;
    532 	for(len = w * h; len-- ;)
    533 		*dest++ = 0x2007;
    534 }
    535 
    536 void
    537 et_scroll(ip, sy, sx, count, dir)
    538 	struct ite_softc *ip;
    539 	int	sy;
    540 	int	sx;
    541 	int	count;
    542 	int	dir;
    543 {
    544 	view_t	*v   = viewview(ip->grf->g_viewdev);
    545 	u_short	*fb;
    546 	u_short	*src, *dst;
    547 	int	len;
    548 
    549 	fb = (u_short*)v->bitmap->plane + sy * ip->cols;
    550 	switch (dir) {
    551 	    case SCROLL_UP:
    552 			src = fb;
    553 			dst = fb - count * ip->cols;
    554 			len = (ip->bottom_margin + 1 - sy) * ip->cols;
    555 			break;
    556 	    case SCROLL_DOWN:
    557 			src = fb;
    558 			dst = fb + count * ip->cols;
    559 			len = (ip->bottom_margin + 1 - (sy + count)) * ip->cols;
    560 			break;
    561 	    case SCROLL_RIGHT:
    562 			src = fb + sx;
    563 			dst = fb + sx + count;
    564 			len = ip->cols - sx + count;
    565 			break;
    566 	    case SCROLL_LEFT:
    567 			src = fb + sx;
    568 			dst = fb + sx - count;
    569 			len = ip->cols - sx;
    570 			break;
    571 	    default:
    572 			return;
    573 	}
    574 	if (src > dst) {
    575 		while (len--)
    576 			*dst++ = *src++;
    577 	}
    578 	else {
    579 		src = &src[len];
    580 		dst = &dst[len];
    581 		while (len--)
    582 			*--dst = *--src;
    583 	}
    584 }
    585 
    586 static void
    587 et_inittextmode(ip, etregs, loadfont)
    588 	struct ite_softc *ip;
    589 	et_sv_reg_t	 *etregs;
    590 	int		 loadfont;
    591 {
    592 	volatile u_char *ba;
    593 	font_info	*fd;
    594 	u_char		*fb;
    595 	u_char		*c, *f, tmp;
    596 	u_short		z, y;
    597 	int		s;
    598 	view_t		*v   = viewview(ip->grf->g_viewdev);
    599 	et_sv_reg_t	loc_regs;
    600 
    601 	if (etregs == NULL) {
    602 		etregs = &loc_regs;
    603 		et_hwsave(etregs);
    604 	}
    605 
    606 	ba = ((ipriv_t*)ip->priv)->regkva;
    607 	fb = v->bitmap->plane;
    608 
    609 #if defined(KFONT_8X8)
    610 	fd = &font_info_8x8;
    611 #else
    612 	fd = &font_info_8x16;
    613 #endif
    614 
    615 	if (loadfont) { /* XXX: We should set the colormap */
    616 		/*
    617 		 * set colors (B&W)
    618 		 */
    619 		vgaw(ba, VDAC_ADDRESS_W, 0);
    620 		for (z = 0; z < 256; z++) {
    621 			y = (z & 1) ? ((z > 7) ? 2 : 1) : 0;
    622 
    623 			vgaw(ba, VDAC_DATA, etconscolors[y][0]);
    624 			vgaw(ba, VDAC_DATA, etconscolors[y][1]);
    625 			vgaw(ba, VDAC_DATA, etconscolors[y][2]);
    626 		}
    627 
    628 		/*
    629 		 * Enter a suitable mode to download the font. This
    630 		 * basically means sequential addressing mode
    631 		 */
    632 		s = splhigh();
    633 
    634 		WAttr(ba, 0x20 | ACT_ID_ATTR_MODE_CNTL, 0x0a);
    635 		WSeq(ba, SEQ_ID_MAP_MASK,	 0x04);
    636 		WSeq(ba, SEQ_ID_MEMORY_MODE,	 0x06);
    637 		WGfx(ba, GCT_ID_READ_MAP_SELECT, 0x02);
    638 		WGfx(ba, GCT_ID_GRAPHICS_MODE,	 0x00);
    639 		WGfx(ba, GCT_ID_MISC,		 0x04);
    640 		splx(s);
    641 
    642 		/*
    643 		 * load text font into beginning of display memory. Each
    644 		 * character cell is 32 bytes long (enough for 4 planes)
    645 		 */
    646 		for (z = 0, c = fb; z < 256 * 32; z++)
    647 			*c++ = 0;
    648 
    649 		c = (unsigned char *) (fb) + (32 * fd->font_lo);
    650 		f = fd->font_p;
    651 		z = fd->font_lo;
    652 		for (; z <= fd->font_hi; z++, c += (32 - fd->height))
    653 			for (y = 0; y < fd->height; y++) {
    654 				*c++ = *f++;
    655 			}
    656 	}
    657 
    658 	/*
    659 	 * Odd/Even addressing
    660 	 */
    661 	etregs->seq[SEQ_ID_MAP_MASK]        = 0x03;
    662 	etregs->seq[SEQ_ID_MEMORY_MODE]     = 0x03;
    663 	etregs->grf[GCT_ID_READ_MAP_SELECT] = 0x00;
    664 	etregs->grf[GCT_ID_GRAPHICS_MODE]   = 0x10;
    665 	etregs->grf[GCT_ID_MISC]            = 0x06;
    666 
    667 	/*
    668 	 * Font height + underline location
    669 	 */
    670 	tmp = etregs->crt[CRT_ID_MAX_ROW_ADDRESS] & 0xe0;
    671 	etregs->crt[CRT_ID_MAX_ROW_ADDRESS] = tmp | (fd->height - 1);
    672 	tmp = etregs->crt[CRT_ID_UNDERLINE_LOC] & 0xe0;
    673 	etregs->crt[CRT_ID_UNDERLINE_LOC] = tmp | (fd->height - 1);
    674 
    675 	/*
    676 	 * Cursor setup
    677 	 */
    678 	etregs->crt[CRT_ID_CURSOR_START]    = 0x00;
    679 	etregs->crt[CRT_ID_CURSOR_END]      = fd->height - 1;
    680 	etregs->crt[CRT_ID_CURSOR_LOC_HIGH] = 0x00;
    681 	etregs->crt[CRT_ID_CURSOR_LOC_LOW]  = 0x00;
    682 
    683 	/*
    684 	 * Enter text mode
    685 	 */
    686 	etregs->crt[CRT_ID_MODE_CONTROL]    = 0xa3;
    687 	etregs->attr[ACT_ID_ATTR_MODE_CNTL] = 0x0a;
    688 
    689 #if 1
    690 	if (loadfont || (etregs == &loc_regs))
    691 #else
    692 	if (etregs == &loc_regs)
    693 #endif
    694 		et_hwrest(etregs);
    695 }
    696