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