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