xref: /netbsd-src/sys/arch/atari/dev/ite_et.c (revision 76dfffe33547c37f8bdd446e3e4ab0f3c16cea4b)
1 /*	$NetBSD: ite_et.c,v 1.4 1996/10/13 04:11:02 christos 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 /* XXX: move to ite.c */
92 extern int ite_default_x;
93 extern int ite_default_y;
94 extern int ite_default_width;
95 extern int ite_default_depth;
96 extern int ite_default_height;
97 
98 /*
99  * grfet config stuff
100  */
101 void grfetattach __P((struct device *, struct device *, void *));
102 int  grfetmatch __P((struct device *, void *, void *));
103 int  grfetprint __P((void *, const char *));
104 
105 struct cfattach grfet_ca = {
106 	sizeof(struct grf_softc), grfetmatch, grfetattach
107 };
108 
109 struct cfdriver grfet_cd = {
110 	NULL, "grfet", DV_DULL
111 };
112 
113 /*
114  * only used in console init.
115  */
116 static struct cfdata *cfdata_grf   = NULL;
117 
118 int
119 grfetmatch(pdp, match, auxp)
120 struct device	*pdp;
121 void	*match, *auxp;
122 {
123 	static int	must_probe = 1;
124 	grf_auxp_t	*grf_auxp = auxp;
125 	struct cfdata	*cfp = match;
126 
127 	if (must_probe) {
128 		if(!(machineid & ATARI_HADES))
129 			return 0;
130 		/*
131 		 * Check if the layers we depend on exist
132 		 */
133 		if (grfabs_probe(&et_probe_video) == 0)
134 			return 0;
135 		viewprobe();
136 		must_probe = 0;
137 	}
138 
139 	if (atari_realconfig == 0) {
140 		/*
141 		 * Early console init. Only match unit 0.
142 		 */
143 		if (cfp->cf_unit != 0)
144 			return 0;
145 		if (!et_probe_card())
146 			return 0;
147 		if (viewopen(0, 0, 0, NULL))
148 			return 0;
149 		cfdata_grf = cfp;
150 		return 1;
151 	}
152 
153 	/*
154 	 * Normal config. When we are called directly from the grfbus,
155 	 * we only match unit 0. The attach function will call us for
156 	 * the other configured units.
157 	 */
158 	if (grf_auxp->from_bus_match
159 	    && ((cfp->cf_unit != 0) || !et_probe_card()))
160 		return 0;
161 
162 	if (!grf_auxp->from_bus_match && (grf_auxp->unit != cfp->cf_unit))
163 		return 0;
164 
165 	/*
166 	 * Final constraint: each grf needs a view....
167 	 */
168 	if((cfdata_grf == NULL) || (cfp->cf_unit != 0)) {
169 	    if(viewopen(cfp->cf_unit, 0, 0, NULL))
170 		return 0;
171 	}
172 	return 1;
173 }
174 
175 /*
176  * attach: initialize the grf-structure and try to attach an ite to us.
177  * note  : dp is NULL during early console init.
178  */
179 void
180 grfetattach(pdp, dp, auxp)
181 struct device	*pdp, *dp;
182 void		*auxp;
183 {
184 	static struct grf_softc		congrf;
185 	       grf_auxp_t		*grf_bus_auxp = auxp;
186 	       grf_auxp_t		grf_auxp;
187 	       struct grf_softc		*gp;
188 	       int			maj;
189 
190 	/*
191 	 * find our major device number
192 	 */
193 	for(maj = 0; maj < nchrdev; maj++)
194 		if (cdevsw[maj].d_open == grfopen)
195 			break;
196 
197 	/*
198 	 * Handle exeption case: early console init
199 	 */
200 	if(dp == NULL) {
201 		congrf.g_unit    = 0;
202 		congrf.g_grfdev  = makedev(maj, 0);
203 		congrf.g_itedev  = (dev_t)-1;
204 		congrf.g_flags   = GF_ALIVE;
205 		congrf.g_mode    = grf_mode;
206 		congrf.g_conpri  = CN_INTERNAL;
207 		congrf.g_viewdev = congrf.g_unit;
208 		grfet_iteinit(&congrf);
209 		grf_viewsync(&congrf);
210 
211 		/* Attach console ite */
212 		atari_config_found(cfdata_grf, NULL, &congrf, grfetprint);
213 		return;
214 	}
215 
216 	gp = (struct grf_softc *)dp;
217 	gp->g_unit = gp->g_device.dv_unit;
218 	grfsp[gp->g_unit] = gp;
219 
220 	if((cfdata_grf != NULL) && (gp->g_unit == 0)) {
221 		/*
222 		 * We inited earlier just copy the info, take care
223 		 * not to copy the device struct though.
224 		 */
225 		bcopy(&congrf.g_display, &gp->g_display,
226 			(char *)&gp[1] - (char *)&gp->g_display);
227 	}
228 	else {
229 		gp->g_grfdev  = makedev(maj, gp->g_unit);
230 		gp->g_itedev  = (dev_t)-1;
231 		gp->g_flags   = GF_ALIVE;
232 		gp->g_mode    = grf_mode;
233 		gp->g_conpri  = 0;
234 		gp->g_viewdev = gp->g_unit;
235 		grfet_iteinit(gp);
236 		grf_viewsync(gp);
237 	}
238 
239 	printf(": %dx%d", gp->g_display.gd_dwidth, gp->g_display.gd_dheight);
240 	if(gp->g_display.gd_colors == 2)
241 		printf(" monochrome\n");
242 	else printf(" colors %d\n", gp->g_display.gd_colors);
243 
244 	/*
245 	 * try and attach an ite
246 	 */
247 	config_found(dp, gp, grfetprint);
248 
249 	/*
250 	 * If attaching unit 0, go ahead and 'find' the rest of us
251 	 */
252 	if (gp->g_unit == 0) {
253 		grf_auxp.from_bus_match = 0;
254 		for (grf_auxp.unit=0; grf_auxp.unit < NGRFET; grf_auxp.unit++) {
255 		    config_found(pdp, (void*)&grf_auxp, grf_bus_auxp->busprint);
256 		}
257 	}
258 }
259 
260 int
261 grfetprint(auxp, pnp)
262 void *auxp;
263 const char *pnp;
264 {
265 	if(pnp) /* XXX */
266 		printf("ite at %s", pnp);
267 	return(UNCONF);
268 }
269 
270 /*
271  * Init ite portion of grf_softc struct
272  */
273 static void
274 grfet_iteinit(gp)
275 struct grf_softc *gp;
276 {
277 
278 	gp->g_itecursor = et_cursor;
279 	gp->g_iteputc   = et_putc;
280 	gp->g_iteclear  = et_clear;
281 	gp->g_itescroll = et_scroll;
282 	gp->g_iteinit   = view_init;
283 	gp->g_itedeinit = view_deinit;
284 }
285 
286 static void
287 view_deinit(ip)
288 struct ite_softc	*ip;
289 {
290 	ip->flags &= ~ITE_INITED;
291 }
292 
293 static void
294 view_init(ip)
295 register struct ite_softc *ip;
296 {
297 	struct itewinsize	wsz;
298 	ipriv_t			*cci;
299 	view_t			*view;
300 	save_area_t		*et_save;
301 
302 	if((cci = ip->priv) != NULL)
303 		return;
304 
305 	ip->itexx_ioctl = iteet_ioctl;
306 
307 #if defined(KFONT_8X8)
308 	ip->font = font_info_8x8;
309 #else
310 	ip->font = font_info_8x16;
311 #endif
312 
313 	/* Find the correct set of rendering routines for this font.  */
314 	if(ip->font.width != 8)
315 		panic("kernel font size not supported");
316 
317 	if(!atari_realconfig)
318 		ip->priv = cci = &con_ipriv;
319 	else ip->priv = cci = (ipriv_t*)malloc(sizeof(*cci), M_DEVBUF,M_WAITOK);
320 	if(cci == NULL)
321 		panic("No memory for ite-view");
322 	bzero(cci, sizeof(*cci));
323 
324 	wsz.x      = ite_default_x;
325 	wsz.y      = ite_default_y;
326 	wsz.width  = ite_default_width;
327 	wsz.height = ite_default_height;
328 	wsz.depth  = ite_default_depth;
329 
330 	ite_newsize (ip, &wsz);
331 
332 	view  = viewview(ip->grf->g_viewdev);
333 	cci->regkva = view->bitmap->regs;
334 
335 	/*
336 	 * Only console will be turned on by default..
337 	 */
338 	if(ip->flags & ITE_ISCONS)
339 		ip->grf->g_mode(ip->grf, GM_GRFON, NULL, 0, 0);
340 
341 	/*
342 	 * Activate text-mode settings
343 	 */
344 	et_save = (save_area_t *)view->save_area;
345 	if (et_save == NULL)
346 		et_inittextmode(ip, NULL, view->flags & VF_DISPLAY);
347 	else {
348 		et_inittextmode(ip, &et_save->sv_regs, view->flags&VF_DISPLAY);
349 		et_save->fb_size = ip->cols * ip->rows;
350 	}
351 }
352 
353 static int
354 ite_newsize(ip, winsz)
355 struct ite_softc	*ip;
356 struct itewinsize	*winsz;
357 {
358 	struct view_size	vs;
359 	int			error = 0;
360 	save_area_t		*et_save;
361 	view_t			*view;
362 
363 	vs.x      = winsz->x;
364 	vs.y      = winsz->y;
365 	vs.width  = winsz->width;
366 	vs.height = winsz->height;
367 	vs.depth  = winsz->depth;
368 
369 	error = viewioctl(ip->grf->g_viewdev, VIOCSSIZE, (caddr_t)&vs, 0,
370 								NOPROC);
371 	view  = viewview(ip->grf->g_viewdev);
372 
373 	/*
374 	 * Reinitialize our structs
375 	 */
376 	ip->cols = view->display.width  / ip->font.width;
377 	ip->rows = view->display.height / ip->font.height;
378 
379 	/*
380 	 * save new values so that future opens use them
381 	 * this may not be correct when we implement Virtual Consoles
382 	 */
383 	ite_default_height = view->display.height;
384 	ite_default_width  = view->display.width;
385 	ite_default_x      = view->display.x;
386 	ite_default_y      = view->display.y;
387 	ite_default_depth  = view->bitmap->depth;
388 
389 	et_save = (save_area_t *)view->save_area;
390 	if (et_save == NULL)
391 	    et_inittextmode(ip, NULL, view->flags & VF_DISPLAY);
392 	else {
393 	    et_inittextmode(ip, &et_save->sv_regs, view->flags & VF_DISPLAY);
394 	    et_save->fb_size = ip->cols * ip->rows;
395 	}
396 	et_clear(ip, 0, 0, ip->rows, ip->cols);
397 
398 	return(error);
399 }
400 
401 int
402 iteet_ioctl(ip, cmd, addr, flag, p)
403 struct ite_softc	*ip;
404 u_long			cmd;
405 caddr_t			addr;
406 int			flag;
407 struct proc		*p;
408 {
409 	struct winsize		ws;
410 	struct itewinsize	*is;
411 	int			error = 0;
412 	view_t			*view = viewview(ip->grf->g_viewdev);
413 #if 0 /* LWP: notyet */
414 	struct itebell		*ib;
415 #endif
416 
417 	switch (cmd) {
418 	case ITEIOCSWINSZ:
419 		is = (struct itewinsize *)addr;
420 
421 		if(ite_newsize(ip, is))
422 			error = ENOMEM;
423 		else {
424 			view         = viewview(ip->grf->g_viewdev);
425 			ws.ws_row    = ip->rows;
426 			ws.ws_col    = ip->cols;
427 			ws.ws_xpixel = view->display.width;
428 			ws.ws_ypixel = view->display.height;
429 			ite_reset(ip);
430 			/*
431 			 * XXX tell tty about the change
432 			 * XXX this is messy, but works
433 			 */
434 			iteioctl(ip->grf->g_itedev,TIOCSWINSZ,(caddr_t)&ws,0,p);
435 		}
436 		break;
437 	case ITEIOCGBELL:
438 #if 0 /* LWP */
439 		/* XXX This won't work now			*/
440 		/* XXX Should the bell be device dependent?	*/
441 		ib         = (struct itebell *)addr;
442 		ib->volume = bvolume;
443 		ib->pitch  = bpitch;
444 		ib->msec   = bmsec;
445 #endif
446 		break;
447 	case ITEIOCSBELL:
448 #if 0 /* LWP */
449 		/* XXX See above				*/
450 		ib = (struct itebell *)addr;
451 		/* bounds check */
452 		if(ib->pitch > MAXBPITCH || ib->pitch < MINBPITCH ||
453 		    ib->volume > MAXBVOLUME || ib->msec > MAXBTIME)
454 			error = EINVAL;
455 		else {
456 			bvolume = ib->volume;
457 			bpitch  = ib->pitch;
458 			bmsec   = ib->msec;
459 		}
460 #endif
461 		break;
462 	case VIOCSCMAP:
463 	case VIOCGCMAP:
464 		/*
465 		 * XXX watchout for that NOPROC. its not really the kernel
466 		 * XXX talking these two commands don't use the proc pointer
467 		 * XXX though.
468 		 */
469 		error = viewioctl(ip->grf->g_viewdev, cmd, addr, flag, NOPROC);
470 		break;
471 	default:
472 		error = -1;
473 		break;
474 	}
475 	return (error);
476 }
477 
478 void
479 et_cursor(ip, flag)
480 	struct ite_softc *ip;
481 	int flag;
482 {
483 	volatile u_char	*ba;
484 		 view_t	*v;
485 		 u_long cpos;
486 
487 	ba = ((ipriv_t*)ip->priv)->regkva;
488 	v  = viewview(ip->grf->g_viewdev);
489 
490 	/*
491 	 * Don't update the cursor when not on display
492 	 */
493 	if (!(v->flags & VF_DISPLAY))
494 		return;
495 
496 	switch (flag) {
497  	    case DRAW_CURSOR:
498 		/*WCrt(ba, CRT_ID_CURSOR_START, & ~0x20); */
499 	    case MOVE_CURSOR:
500 		cpos  =  RCrt(ba, CRT_ID_START_ADDR_LOW) & 0xff;
501 		cpos |= (RCrt(ba, CRT_ID_START_ADDR_HIGH) & 0xff) << 8;
502 		cpos += ip->curx + ip->cury * ip->cols;
503 		WCrt(ba, CRT_ID_CURSOR_LOC_LOW, cpos & 0xff);
504 		WCrt(ba, CRT_ID_CURSOR_LOC_HIGH, (cpos >> 8) & 0xff);
505 		WCrt(ba, CTR_ID_EXT_START, (cpos >> (16-2)) & 0x0c);
506 
507 		ip->cursorx = ip->curx;
508 		ip->cursory = ip->cury;
509 		break;
510 	    case ERASE_CURSOR:
511 		/*WCrt(ba, CRT_ID_CURSOR_START, | 0x20); */
512 	    case START_CURSOROPT:
513 	    case END_CURSOROPT:
514 	    default:
515 		break;
516     	}
517 }
518 
519 void
520 et_putc(ip, c, dy, dx, mode)
521 	struct ite_softc *ip;
522 	int c;
523 	int dy;
524 	int dx;
525 	int mode;
526 {
527 	view_t	*v   = viewview(ip->grf->g_viewdev);
528 	u_char	attr;
529 	u_short	*cp;
530 
531 	attr = (unsigned char) ((mode & ATTR_INV) ? (0x70) : (0x07));
532 	if (mode & ATTR_UL)     attr |= 0x01;
533 	if (mode & ATTR_BOLD)   attr |= 0x08;
534 	if (mode & ATTR_BLINK)  attr |= 0x80;
535 
536 	cp  = (u_short*)v->bitmap->plane;
537 	cp[(dy * ip->cols) + dx] = (c << 8) | attr;
538 }
539 
540 void
541 et_clear(ip, sy, sx, h, w)
542 	struct ite_softc *ip;
543 	int sy;
544 	int sx;
545 	int h;
546 	int w;
547 {
548 	/* cl_clear and cl_scroll both rely on ite passing arguments
549 	 * which describe continuous regions.  For a VT200 terminal,
550 	 * this is safe behavior.
551 	 */
552 	view_t		*v   = viewview(ip->grf->g_viewdev);
553 	u_short		*dest;
554 	int		len;
555 
556 	dest = (u_short *)v->bitmap->plane + (sy * ip->cols) + sx;
557 	for(len = w * h; len-- ;)
558 		*dest++ = 0x2007;
559 }
560 
561 void
562 et_scroll(ip, sy, sx, count, dir)
563 	struct ite_softc *ip;
564 	int	sy;
565 	int	sx;
566 	int	count;
567 	int	dir;
568 {
569 	view_t	*v   = viewview(ip->grf->g_viewdev);
570 	u_short	*fb;
571 	u_short	*src, *dst;
572 	int	len;
573 
574 	fb = (u_short*)v->bitmap->plane + sy * ip->cols;
575 	switch (dir) {
576 	    case SCROLL_UP:
577 			src = fb;
578 			dst = fb - count * ip->cols;
579 			len = (ip->bottom_margin + 1 - sy) * ip->cols;
580 			break;
581 	    case SCROLL_DOWN:
582 			src = fb;
583 			dst = fb + count * ip->cols;
584 			len = (ip->bottom_margin + 1 - (sy + count)) * ip->cols;
585 			break;
586 	    case SCROLL_RIGHT:
587 			src = fb + sx;
588 			dst = fb + sx + count;
589 			len = ip->cols - sx + count;
590 			break;
591 	    case SCROLL_LEFT:
592 			src = fb + sx;
593 			dst = fb + sx - count;
594 			len = ip->cols - sx;
595 			break;
596 	    default:
597 			return;
598 	}
599 	if (src > dst) {
600 		while (len--)
601 			*dst++ = *src++;
602 	}
603 	else {
604 		src = &src[len];
605 		dst = &dst[len];
606 		while (len--)
607 			*--dst = *--src;
608 	}
609 }
610 
611 static void
612 et_inittextmode(ip, etregs, loadfont)
613 	struct ite_softc *ip;
614 	et_sv_reg_t	 *etregs;
615 	int		 loadfont;
616 {
617 	volatile u_char *ba;
618 	font_info	*fd;
619 	u_char		*fb;
620 	u_char		*c, *f, tmp;
621 	u_short		z, y;
622 	int		s;
623 	view_t		*v   = viewview(ip->grf->g_viewdev);
624 	et_sv_reg_t	loc_regs;
625 
626 	if (etregs == NULL) {
627 		etregs = &loc_regs;
628 		et_hwsave(etregs);
629 	}
630 
631 	ba = ((ipriv_t*)ip->priv)->regkva;
632 	fb = v->bitmap->plane;
633 
634 #if defined(KFONT_8X8)
635 	fd = &font_info_8x8;
636 #else
637 	fd = &font_info_8x16;
638 #endif
639 
640 	if (loadfont) { /* XXX: We should set the colormap */
641 		/*
642 		 * set colors (B&W)
643 		 */
644 		vgaw(ba, VDAC_ADDRESS_W, 0);
645 		for (z = 0; z < 256; z++) {
646 			y = (z & 1) ? ((z > 7) ? 2 : 1) : 0;
647 
648 			vgaw(ba, VDAC_DATA, etconscolors[y][0]);
649 			vgaw(ba, VDAC_DATA, etconscolors[y][1]);
650 			vgaw(ba, VDAC_DATA, etconscolors[y][2]);
651 		}
652 
653 		/*
654 		 * Enter a suitable mode to download the font. This
655 		 * basically means sequential addressing mode
656 		 */
657 		s = splhigh();
658 
659 		WAttr(ba, 0x20 | ACT_ID_ATTR_MODE_CNTL, 0x0a);
660 		WSeq(ba, SEQ_ID_MAP_MASK,	 0x04);
661 		WSeq(ba, SEQ_ID_MEMORY_MODE,	 0x06);
662 		WGfx(ba, GCT_ID_READ_MAP_SELECT, 0x02);
663 		WGfx(ba, GCT_ID_GRAPHICS_MODE,	 0x00);
664 		WGfx(ba, GCT_ID_MISC,		 0x04);
665 		splx(s);
666 
667 		/*
668 		 * load text font into beginning of display memory. Each
669 		 * character cell is 32 bytes long (enough for 4 planes)
670 		 */
671 		for (z = 0, c = fb; z < 256 * 32; z++)
672 			*c++ = 0;
673 
674 		c = (unsigned char *) (fb) + (32 * fd->font_lo);
675 		f = fd->font_p;
676 		z = fd->font_lo;
677 		for (; z <= fd->font_hi; z++, c += (32 - fd->height))
678 			for (y = 0; y < fd->height; y++) {
679 				*c++ = *f++;
680 			}
681 	}
682 
683 	/*
684 	 * Odd/Even addressing
685 	 */
686 	etregs->seq[SEQ_ID_MAP_MASK]        = 0x03;
687 	etregs->seq[SEQ_ID_MEMORY_MODE]     = 0x03;
688 	etregs->grf[GCT_ID_READ_MAP_SELECT] = 0x00;
689 	etregs->grf[GCT_ID_GRAPHICS_MODE]   = 0x10;
690 	etregs->grf[GCT_ID_MISC]            = 0x06;
691 
692 	/*
693 	 * Font height + underline location
694 	 */
695 	tmp = etregs->crt[CRT_ID_MAX_ROW_ADDRESS] & 0xe0;
696 	etregs->crt[CRT_ID_MAX_ROW_ADDRESS] = tmp | (fd->height - 1);
697 	tmp = etregs->crt[CRT_ID_UNDERLINE_LOC] & 0xe0;
698 	etregs->crt[CRT_ID_UNDERLINE_LOC] = tmp | (fd->height - 1);
699 
700 	/*
701 	 * Cursor setup
702 	 */
703 	etregs->crt[CRT_ID_CURSOR_START]    = 0x00;
704 	etregs->crt[CRT_ID_CURSOR_END]      = fd->height - 1;
705 	etregs->crt[CRT_ID_CURSOR_LOC_HIGH] = 0x00;
706 	etregs->crt[CRT_ID_CURSOR_LOC_LOW]  = 0x00;
707 
708 	/*
709 	 * Enter text mode
710 	 */
711 	etregs->crt[CRT_ID_MODE_CONTROL]    = 0xa3;
712 	etregs->attr[ACT_ID_ATTR_MODE_CNTL] = 0x0a;
713 
714 #if 1
715 	if (loadfont || (etregs == &loc_regs))
716 #else
717 	if (etregs == &loc_regs)
718 #endif
719 		et_hwrest(etregs);
720 }
721