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