xref: /netbsd/sys/arch/atari/dev/ite_et.c (revision bf9ec67e)
1 /*	$NetBSD: ite_et.c,v 1.12 2002/03/17 19:40:35 atatat 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 
117 	if (card_probed <= 0) {
118 		if (card_probed == 0) /* Probed but failed */
119 			return 0;
120 		card_probed = 0;
121 
122 		/*
123 		 * Check if the layers we depend on exist
124 		 */
125 		if(!(machineid & ATARI_HADES))
126 			return 0;
127 		if (!et_probe_card())
128 			return 0;
129 		if (grfabs_probe(&et_probe_video) == 0)
130 			return 0;
131 		viewprobe();
132 		card_probed = 1; /* Probed and found */
133 	}
134 
135 	if (atari_realconfig == 0) {
136 		/*
137 		 * Early console init. Only match first unit.
138 		 */
139 		if (did_consinit)
140 			return 0;
141 		if (viewopen(cfp->cf_unit, 0, 0, NULL))
142 			return 0;
143 		cfdata_grf = cfp;
144 		did_consinit = 1;
145 		return 1;
146 	}
147 
148 	/*
149 	 * Normal config. When we are called directly from the grfbus,
150 	 * we only match the first unit. The attach function will call us for
151 	 * the other configured units.
152 	 */
153 	if (grf_auxp->from_bus_match
154 	    && ((did_consinit > 1) || !et_probe_card()))
155 		return 0;
156 
157 	if (!grf_auxp->from_bus_match && (grf_auxp->unit != cfp->cf_unit))
158 		return 0;
159 
160 	/*
161 	 * Final constraint: each grf needs a view....
162 	 */
163 	if((cfdata_grf == NULL) || (did_consinit > 1)) {
164 	    if(viewopen(cfp->cf_unit, 0, 0, NULL))
165 		return 0;
166 	}
167 	did_consinit = 2;
168 	return 1;
169 }
170 
171 /*
172  * attach: initialize the grf-structure and try to attach an ite to us.
173  * note  : dp is NULL during early console init.
174  */
175 void
176 grfetattach(pdp, dp, auxp)
177 struct device	*pdp, *dp;
178 void		*auxp;
179 {
180 	static struct grf_softc		congrf;
181 	static int			first_attach = 1;
182 	       grf_auxp_t		*grf_bus_auxp = auxp;
183 	       grf_auxp_t		grf_auxp;
184 	       struct grf_softc		*gp;
185 	       int			maj;
186 
187 	/*
188 	 * find our major device number
189 	 */
190 	for(maj = 0; maj < nchrdev; maj++)
191 		if (cdevsw[maj].d_open == grfopen)
192 			break;
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 
361 	vs.x      = winsz->x;
362 	vs.y      = winsz->y;
363 	vs.width  = winsz->width;
364 	vs.height = winsz->height;
365 	vs.depth  = winsz->depth;
366 
367 	error = viewioctl(ip->grf->g_viewdev, VIOCSSIZE, (caddr_t)&vs, 0,
368 								NOPROC);
369 	view  = viewview(ip->grf->g_viewdev);
370 
371 	/*
372 	 * Reinitialize our structs
373 	 */
374 	ip->cols = view->display.width  / ip->font.width;
375 	ip->rows = view->display.height / ip->font.height;
376 
377 	/*
378 	 * save new values so that future opens use them
379 	 * this may not be correct when we implement Virtual Consoles
380 	 */
381 	ite_default_height = view->display.height;
382 	ite_default_width  = view->display.width;
383 	ite_default_x      = view->display.x;
384 	ite_default_y      = view->display.y;
385 	ite_default_depth  = view->bitmap->depth;
386 
387 	et_save = (save_area_t *)view->save_area;
388 	if (et_save == NULL)
389 	    et_inittextmode(ip, NULL, view->flags & VF_DISPLAY);
390 	else {
391 	    et_inittextmode(ip, &et_save->sv_regs, view->flags & VF_DISPLAY);
392 	    et_save->fb_size = ip->cols * ip->rows;
393 	}
394 	et_clear(ip, 0, 0, ip->rows, ip->cols);
395 
396 	return(error);
397 }
398 
399 int
400 iteet_ioctl(ip, cmd, addr, flag, p)
401 struct ite_softc	*ip;
402 u_long			cmd;
403 caddr_t			addr;
404 int			flag;
405 struct proc		*p;
406 {
407 	struct winsize		ws;
408 	struct itewinsize	*is;
409 	int			error = 0;
410 	view_t			*view = viewview(ip->grf->g_viewdev);
411 
412 	switch (cmd) {
413 	case ITEIOCSWINSZ:
414 		is = (struct itewinsize *)addr;
415 
416 		if(ite_newsize(ip, is))
417 			error = ENOMEM;
418 		else {
419 			view         = viewview(ip->grf->g_viewdev);
420 			ws.ws_row    = ip->rows;
421 			ws.ws_col    = ip->cols;
422 			ws.ws_xpixel = view->display.width;
423 			ws.ws_ypixel = view->display.height;
424 			ite_reset(ip);
425 			/*
426 			 * XXX tell tty about the change
427 			 * XXX this is messy, but works
428 			 */
429 			iteioctl(ip->grf->g_itedev,TIOCSWINSZ,(caddr_t)&ws,0,p);
430 		}
431 		break;
432 	case VIOCSCMAP:
433 	case VIOCGCMAP:
434 		/*
435 		 * XXX watchout for that NOPROC. its not really the kernel
436 		 * XXX talking these two commands don't use the proc pointer
437 		 * XXX though.
438 		 */
439 		error = viewioctl(ip->grf->g_viewdev, cmd, addr, flag, NOPROC);
440 		break;
441 	default:
442 		error = EPASSTHROUGH;
443 		break;
444 	}
445 	return (error);
446 }
447 
448 void
449 et_cursor(ip, flag)
450 	struct ite_softc *ip;
451 	int flag;
452 {
453 	volatile u_char	*ba;
454 		 view_t	*v;
455 		 u_long cpos;
456 
457 	ba = ((ipriv_t*)ip->priv)->regkva;
458 	v  = viewview(ip->grf->g_viewdev);
459 
460 	/*
461 	 * Don't update the cursor when not on display
462 	 */
463 	if (!(v->flags & VF_DISPLAY))
464 		return;
465 
466 	switch (flag) {
467  	    case DRAW_CURSOR:
468 		/*WCrt(ba, CRT_ID_CURSOR_START, & ~0x20); */
469 	    case MOVE_CURSOR:
470 		cpos  =  RCrt(ba, CRT_ID_START_ADDR_LOW) & 0xff;
471 		cpos |= (RCrt(ba, CRT_ID_START_ADDR_HIGH) & 0xff) << 8;
472 		cpos += ip->curx + ip->cury * ip->cols;
473 		WCrt(ba, CRT_ID_CURSOR_LOC_LOW, cpos & 0xff);
474 		WCrt(ba, CRT_ID_CURSOR_LOC_HIGH, (cpos >> 8) & 0xff);
475 		WCrt(ba, CTR_ID_EXT_START, (cpos >> (16-2)) & 0x0c);
476 
477 		ip->cursorx = ip->curx;
478 		ip->cursory = ip->cury;
479 		break;
480 	    case ERASE_CURSOR:
481 		/*WCrt(ba, CRT_ID_CURSOR_START, | 0x20); */
482 	    case START_CURSOROPT:
483 	    case END_CURSOROPT:
484 	    default:
485 		break;
486     	}
487 }
488 
489 void
490 et_putc(ip, c, dy, dx, mode)
491 	struct ite_softc *ip;
492 	int c;
493 	int dy;
494 	int dx;
495 	int mode;
496 {
497 	view_t	*v   = viewview(ip->grf->g_viewdev);
498 	u_char	attr;
499 	u_short	*cp;
500 
501 	attr = (unsigned char) ((mode & ATTR_INV) ? (0x70) : (0x07));
502 	if (mode & ATTR_UL)     attr |= 0x01;
503 	if (mode & ATTR_BOLD)   attr |= 0x08;
504 	if (mode & ATTR_BLINK)  attr |= 0x80;
505 
506 	cp  = (u_short*)v->bitmap->plane;
507 	cp[(dy * ip->cols) + dx] = (c << 8) | attr;
508 }
509 
510 void
511 et_clear(ip, sy, sx, h, w)
512 	struct ite_softc *ip;
513 	int sy;
514 	int sx;
515 	int h;
516 	int w;
517 {
518 	/* et_clear and et_scroll both rely on ite passing arguments
519 	 * which describe continuous regions.  For a VT200 terminal,
520 	 * this is safe behavior.
521 	 */
522 	view_t		*v   = viewview(ip->grf->g_viewdev);
523 	u_short		*dest;
524 	int		len;
525 
526 	dest = (u_short *)v->bitmap->plane + (sy * ip->cols) + sx;
527 	for(len = w * h; len-- ;)
528 		*dest++ = 0x2007;
529 }
530 
531 void
532 et_scroll(ip, sy, sx, count, dir)
533 	struct ite_softc *ip;
534 	int	sy;
535 	int	sx;
536 	int	count;
537 	int	dir;
538 {
539 	view_t	*v   = viewview(ip->grf->g_viewdev);
540 	u_short	*fb;
541 	u_short	*src, *dst;
542 	int	len;
543 
544 	fb = (u_short*)v->bitmap->plane + sy * ip->cols;
545 	switch (dir) {
546 	    case SCROLL_UP:
547 			src = fb;
548 			dst = fb - count * ip->cols;
549 			len = (ip->bottom_margin + 1 - sy) * ip->cols;
550 			break;
551 	    case SCROLL_DOWN:
552 			src = fb;
553 			dst = fb + count * ip->cols;
554 			len = (ip->bottom_margin + 1 - (sy + count)) * ip->cols;
555 			break;
556 	    case SCROLL_RIGHT:
557 			src = fb + sx;
558 			dst = fb + sx + count;
559 			len = ip->cols - sx + count;
560 			break;
561 	    case SCROLL_LEFT:
562 			src = fb + sx;
563 			dst = fb + sx - count;
564 			len = ip->cols - sx;
565 			break;
566 	    default:
567 			return;
568 	}
569 	if (src > dst) {
570 		while (len--)
571 			*dst++ = *src++;
572 	}
573 	else {
574 		src = &src[len];
575 		dst = &dst[len];
576 		while (len--)
577 			*--dst = *--src;
578 	}
579 }
580 
581 static void
582 et_inittextmode(ip, etregs, loadfont)
583 	struct ite_softc *ip;
584 	et_sv_reg_t	 *etregs;
585 	int		 loadfont;
586 {
587 	volatile u_char *ba;
588 	font_info	*fd;
589 	u_char		*fb;
590 	u_char		*c, *f, tmp;
591 	u_short		z, y;
592 	int		s;
593 	view_t		*v   = viewview(ip->grf->g_viewdev);
594 	et_sv_reg_t	loc_regs;
595 
596 	if (etregs == NULL) {
597 		etregs = &loc_regs;
598 		et_hwsave(etregs);
599 	}
600 
601 	ba = ((ipriv_t*)ip->priv)->regkva;
602 	fb = v->bitmap->plane;
603 
604 #if defined(KFONT_8X8)
605 	fd = &font_info_8x8;
606 #else
607 	fd = &font_info_8x16;
608 #endif
609 
610 	if (loadfont) { /* XXX: We should set the colormap */
611 		/*
612 		 * set colors (B&W)
613 		 */
614 		vgaw(ba, VDAC_ADDRESS_W, 0);
615 		for (z = 0; z < 256; z++) {
616 			y = (z & 1) ? ((z > 7) ? 2 : 1) : 0;
617 
618 			vgaw(ba, VDAC_DATA, etconscolors[y][0]);
619 			vgaw(ba, VDAC_DATA, etconscolors[y][1]);
620 			vgaw(ba, VDAC_DATA, etconscolors[y][2]);
621 		}
622 
623 		/*
624 		 * Enter a suitable mode to download the font. This
625 		 * basically means sequential addressing mode
626 		 */
627 		s = splhigh();
628 
629 		WAttr(ba, 0x20 | ACT_ID_ATTR_MODE_CNTL, 0x0a);
630 		WSeq(ba, SEQ_ID_MAP_MASK,	 0x04);
631 		WSeq(ba, SEQ_ID_MEMORY_MODE,	 0x06);
632 		WGfx(ba, GCT_ID_READ_MAP_SELECT, 0x02);
633 		WGfx(ba, GCT_ID_GRAPHICS_MODE,	 0x00);
634 		WGfx(ba, GCT_ID_MISC,		 0x04);
635 		splx(s);
636 
637 		/*
638 		 * load text font into beginning of display memory. Each
639 		 * character cell is 32 bytes long (enough for 4 planes)
640 		 */
641 		for (z = 0, c = fb; z < 256 * 32; z++)
642 			*c++ = 0;
643 
644 		c = (unsigned char *) (fb) + (32 * fd->font_lo);
645 		f = fd->font_p;
646 		z = fd->font_lo;
647 		for (; z <= fd->font_hi; z++, c += (32 - fd->height))
648 			for (y = 0; y < fd->height; y++) {
649 				*c++ = *f++;
650 			}
651 	}
652 
653 	/*
654 	 * Odd/Even addressing
655 	 */
656 	etregs->seq[SEQ_ID_MAP_MASK]        = 0x03;
657 	etregs->seq[SEQ_ID_MEMORY_MODE]     = 0x03;
658 	etregs->grf[GCT_ID_READ_MAP_SELECT] = 0x00;
659 	etregs->grf[GCT_ID_GRAPHICS_MODE]   = 0x10;
660 	etregs->grf[GCT_ID_MISC]            = 0x06;
661 
662 	/*
663 	 * Font height + underline location
664 	 */
665 	tmp = etregs->crt[CRT_ID_MAX_ROW_ADDRESS] & 0xe0;
666 	etregs->crt[CRT_ID_MAX_ROW_ADDRESS] = tmp | (fd->height - 1);
667 	tmp = etregs->crt[CRT_ID_UNDERLINE_LOC] & 0xe0;
668 	etregs->crt[CRT_ID_UNDERLINE_LOC] = tmp | (fd->height - 1);
669 
670 	/*
671 	 * Cursor setup
672 	 */
673 	etregs->crt[CRT_ID_CURSOR_START]    = 0x00;
674 	etregs->crt[CRT_ID_CURSOR_END]      = fd->height - 1;
675 	etregs->crt[CRT_ID_CURSOR_LOC_HIGH] = 0x00;
676 	etregs->crt[CRT_ID_CURSOR_LOC_LOW]  = 0x00;
677 
678 	/*
679 	 * Enter text mode
680 	 */
681 	etregs->crt[CRT_ID_MODE_CONTROL]    = 0xa3;
682 	etregs->attr[ACT_ID_ATTR_MODE_CNTL] = 0x0a;
683 
684 #if 1
685 	if (loadfont || (etregs == &loc_regs))
686 #else
687 	if (etregs == &loc_regs)
688 #endif
689 		et_hwrest(etregs);
690 }
691