Home | History | Annotate | Line # | Download | only in vsa
smg.c revision 1.33
      1 /*	$NetBSD: smg.c,v 1.33 2002/09/27 20:37:04 thorpej Exp $ */
      2 /*
      3  * Copyright (c) 1998 Ludd, University of Lule}, Sweden.
      4  * All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. All advertising materials mentioning features or use of this software
     15  *    must display the following acknowledgement:
     16  *	This product includes software developed at Ludd, University of
     17  *	Lule}, Sweden and its contributors.
     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 
     33 #include <sys/param.h>
     34 #include <sys/device.h>
     35 #include <sys/systm.h>
     36 #include <sys/callout.h>
     37 #include <sys/time.h>
     38 #include <sys/malloc.h>
     39 #include <sys/conf.h>
     40 #include <sys/kernel.h>
     41 
     42 #include <machine/vsbus.h>
     43 #include <machine/sid.h>
     44 #include <machine/cpu.h>
     45 #include <machine/ka420.h>
     46 
     47 #include <dev/cons.h>
     48 
     49 #include <dev/dec/dzreg.h>
     50 #include <dev/dec/dzvar.h>
     51 #include <dev/dec/dzkbdvar.h>
     52 
     53 #include <dev/wscons/wsdisplayvar.h>
     54 #include <dev/wscons/wsconsio.h>
     55 #include <dev/wscons/wscons_callbacks.h>
     56 
     57 #include "dzkbd.h"
     58 #include "opt_wsfont.h"
     59 
     60 /* Safety guard */
     61 #ifndef FONT_QVSS8x15
     62 #include <dev/wsfont/qvss8x15.h>
     63 #endif
     64 
     65 /* Screen hardware defs */
     66 #define SM_COLS		128	/* char width of screen */
     67 #define SM_ROWS		57	/* rows of char on screen */
     68 #define SM_CHEIGHT	15	/* lines a char consists of */
     69 #define SM_NEXTROW	(SM_COLS * SM_CHEIGHT)
     70 #define	SM_YWIDTH	864
     71 #define SM_XWIDTH	1024
     72 
     73 /* Cursor register definitions */
     74 #define	CUR_CMD		0
     75 #define	CUR_XPOS	4
     76 #define CUR_YPOS	8
     77 #define CUR_XMIN_1	12
     78 #define CUR_XMAX_1	16
     79 #define CUR_YMIN_1	20
     80 #define CUR_YMAX_1	24
     81 #define CUR_XMIN_2	28
     82 #define CUR_XMAX_2	32
     83 #define CUR_YMIN_2	36
     84 #define CUR_YMAX_2	40
     85 #define CUR_LOAD	44
     86 
     87 #define CUR_CMD_TEST	0x8000
     88 #define CUR_CMD_HSHI	0x4000
     89 #define CUR_CMD_VBHI	0x2000
     90 #define CUR_CMD_LODSA	0x1000
     91 #define CUR_CMD_FORG2	0x0800
     92 #define CUR_CMD_ENRG2	0x0400
     93 #define CUR_CMD_FORG1	0x0200
     94 #define CUR_CMD_ENRG1	0x0100
     95 #define CUR_CMD_XHWID	0x0080
     96 #define CUR_CMD_XHCL1	0x0040
     97 #define CUR_CMD_XHCLP	0x0020
     98 #define CUR_CMD_XHAIR	0x0010
     99 #define CUR_CMD_FOPB	0x0008
    100 #define CUR_CMD_ENPB	0x0004
    101 #define CUR_CMD_FOPA	0x0002
    102 #define CUR_CMD_ENPA	0x0001
    103 
    104 #define CUR_XBIAS	216	/* Add to cursor position */
    105 #define	CUR_YBIAS	33
    106 
    107 #define	WRITECUR(addr, val)	*(volatile short *)(curaddr + (addr)) = (val)
    108 static	caddr_t	curaddr;
    109 static	short curcmd, curx, cury, hotX, hotY;
    110 static	int bgmask, fgmask;
    111 
    112 static	int smg_match(struct device *, struct cfdata *, void *);
    113 static	void smg_attach(struct device *, struct device *, void *);
    114 
    115 struct	smg_softc {
    116 	struct	device ss_dev;
    117 };
    118 
    119 const struct cfattach smg_ca = {
    120 	sizeof(struct smg_softc), smg_match, smg_attach,
    121 };
    122 
    123 static void	smg_cursor(void *, int, int, int);
    124 static int	smg_mapchar(void *, int, unsigned int *);
    125 static void	smg_putchar(void *, int, int, u_int, long);
    126 static void	smg_copycols(void *, int, int, int,int);
    127 static void	smg_erasecols(void *, int, int, int, long);
    128 static void	smg_copyrows(void *, int, int, int);
    129 static void	smg_eraserows(void *, int, int, long);
    130 static int	smg_allocattr(void *, int, int, int, long *);
    131 
    132 const struct wsdisplay_emulops smg_emulops = {
    133 	smg_cursor,
    134 	smg_mapchar,
    135 	smg_putchar,
    136 	smg_copycols,
    137 	smg_erasecols,
    138 	smg_copyrows,
    139 	smg_eraserows,
    140 	smg_allocattr
    141 };
    142 
    143 const struct wsscreen_descr smg_stdscreen = {
    144 	"128x57", SM_COLS, SM_ROWS,
    145 	&smg_emulops,
    146 	8, SM_CHEIGHT,
    147 	WSSCREEN_UNDERLINE|WSSCREEN_REVERSE,
    148 };
    149 
    150 const struct wsscreen_descr *_smg_scrlist[] = {
    151 	&smg_stdscreen,
    152 };
    153 
    154 const struct wsscreen_list smg_screenlist = {
    155 	sizeof(_smg_scrlist) / sizeof(struct wsscreen_descr *),
    156 	_smg_scrlist,
    157 };
    158 
    159 static	caddr_t	sm_addr;
    160 
    161 extern struct wsdisplay_font qvss8x15;
    162 static  u_char *qf;
    163 
    164 #define QCHAR(c) (c < 32 ? 32 : (c > 127 ? c - 66 : c - 32))
    165 #define QFONT(c,line)	qf[QCHAR(c) * 15 + line]
    166 #define	SM_ADDR(row, col, line) \
    167 	sm_addr[col + (row * SM_CHEIGHT * SM_COLS) + line * SM_COLS]
    168 
    169 
    170 static int	smg_ioctl(void *, u_long, caddr_t, int, struct proc *);
    171 static paddr_t	smg_mmap(void *, off_t, int);
    172 static int	smg_alloc_screen(void *, const struct wsscreen_descr *,
    173 				      void **, int *, int *, long *);
    174 static void	smg_free_screen(void *, void *);
    175 static int	smg_show_screen(void *, void *, int,
    176 				     void (*) (void *, int, int), void *);
    177 static void	smg_crsr_blink(void *);
    178 
    179 const struct wsdisplay_accessops smg_accessops = {
    180 	smg_ioctl,
    181 	smg_mmap,
    182 	smg_alloc_screen,
    183 	smg_free_screen,
    184 	smg_show_screen,
    185 	0 /* load_font */
    186 };
    187 
    188 struct	smg_screen {
    189 	int	ss_curx;
    190 	int	ss_cury;
    191 	u_char	ss_image[SM_ROWS][SM_COLS];	/* Image of current screen */
    192 	u_char	ss_attr[SM_ROWS][SM_COLS];	/* Reversed etc... */
    193 };
    194 
    195 static	struct smg_screen smg_conscreen;
    196 static	struct smg_screen *curscr;
    197 
    198 static	struct callout smg_cursor_ch = CALLOUT_INITIALIZER;
    199 
    200 int
    201 smg_match(struct device *parent, struct cfdata *match, void *aux)
    202 {
    203 	struct vsbus_attach_args *va = aux;
    204 	volatile short *curcmd;
    205 	volatile short *cfgtst;
    206 	short tmp, tmp2;
    207 
    208 	if (vax_boardtype == VAX_BTYP_49 || vax_boardtype == VAX_BTYP_53)
    209 		return 0;
    210 
    211 	curcmd = (short *)va->va_addr;
    212 	cfgtst = (short *)vax_map_physmem(VS_CFGTST, 1);
    213 	/*
    214 	 * Try to find the cursor chip by testing the flip-flop.
    215 	 * If nonexistent, no glass tty.
    216 	 */
    217 	curcmd[0] = CUR_CMD_HSHI|CUR_CMD_FOPB;
    218 	DELAY(300000);
    219 	tmp = cfgtst[0];
    220 	curcmd[0] = CUR_CMD_TEST|CUR_CMD_HSHI;
    221 	DELAY(300000);
    222 	tmp2 = cfgtst[0];
    223 	vax_unmap_physmem((vaddr_t)cfgtst, 1);
    224 
    225 	if (tmp2 != tmp)
    226 		return 20; /* Using periodic interrupt */
    227 	else
    228 		return 0;
    229 }
    230 
    231 void
    232 smg_attach(struct device *parent, struct device *self, void *aux)
    233 {
    234 	struct wsemuldisplaydev_attach_args aa;
    235 
    236 	printf("\n");
    237 	sm_addr = (caddr_t)vax_map_physmem(SMADDR, (SMSIZE/VAX_NBPG));
    238 	curaddr = (caddr_t)vax_map_physmem(KA420_CUR_BASE, 1);
    239 	if (sm_addr == 0) {
    240 		printf("%s: Couldn't alloc graphics memory.\n", self->dv_xname);
    241 		return;
    242 	}
    243 	curscr = &smg_conscreen;
    244 	aa.console = (vax_confdata & (KA420_CFG_L3CON|KA420_CFG_MULTU)) == 0;
    245 
    246 	aa.scrdata = &smg_screenlist;
    247 	aa.accessops = &smg_accessops;
    248 	callout_reset(&smg_cursor_ch, hz / 2, smg_crsr_blink, NULL);
    249 	curcmd = CUR_CMD_HSHI;
    250 	WRITECUR(CUR_CMD, curcmd);
    251 	qf = qvss8x15.data;
    252 
    253 	config_found(self, &aa, wsemuldisplaydevprint);
    254 }
    255 
    256 static	u_char *cursor;
    257 static	int cur_on;
    258 
    259 static void
    260 smg_crsr_blink(void *arg)
    261 {
    262 	if (cur_on)
    263 		*cursor ^= 255;
    264 	callout_reset(&smg_cursor_ch, hz / 2, smg_crsr_blink, NULL);
    265 }
    266 
    267 void
    268 smg_cursor(void *id, int on, int row, int col)
    269 {
    270 	struct smg_screen *ss = id;
    271 
    272 	if (ss == curscr) {
    273 		SM_ADDR(ss->ss_cury, ss->ss_curx, 14) =
    274 		    QFONT(ss->ss_image[ss->ss_cury][ss->ss_curx], 14);
    275 		cursor = &SM_ADDR(row, col, 14);
    276 		if ((cur_on = on))
    277 			*cursor ^= 255;
    278 	}
    279 	ss->ss_curx = col;
    280 	ss->ss_cury = row;
    281 }
    282 
    283 int
    284 smg_mapchar(void *id, int uni, unsigned int *index)
    285 {
    286 	if (uni < 256) {
    287 		*index = uni;
    288 		return (5);
    289 	}
    290 	*index = ' ';
    291 	return (0);
    292 }
    293 
    294 static void
    295 smg_putchar(void *id, int row, int col, u_int c, long attr)
    296 {
    297 	struct smg_screen *ss = id;
    298 	int i;
    299 
    300 	c &= 0xff;
    301 
    302 	ss->ss_image[row][col] = c;
    303 	ss->ss_attr[row][col] = attr;
    304 	if (ss != curscr)
    305 		return;
    306 	for (i = 0; i < 15; i++) {
    307 		unsigned char ch = QFONT(c, i);
    308 
    309 		SM_ADDR(row, col, i) = (attr & WSATTR_REVERSE ? ~ch : ch);
    310 
    311 	}
    312 	if (attr & WSATTR_UNDERLINE)
    313 		SM_ADDR(row, col, 14) ^= SM_ADDR(row, col, 14);
    314 }
    315 
    316 /*
    317  * copies columns inside a row.
    318  */
    319 static void
    320 smg_copycols(void *id, int row, int srccol, int dstcol, int ncols)
    321 {
    322 	struct smg_screen *ss = id;
    323 	int i;
    324 
    325 	bcopy(&ss->ss_image[row][srccol], &ss->ss_image[row][dstcol], ncols);
    326 	bcopy(&ss->ss_attr[row][srccol], &ss->ss_attr[row][dstcol], ncols);
    327 	if (ss != curscr)
    328 		return;
    329 	for (i = 0; i < SM_CHEIGHT; i++)
    330 		bcopy(&SM_ADDR(row,srccol, i), &SM_ADDR(row, dstcol, i),ncols);
    331 }
    332 
    333 /*
    334  * Erases a bunch of chars inside one row.
    335  */
    336 static void
    337 smg_erasecols(void *id, int row, int startcol, int ncols, long fillattr)
    338 {
    339 	struct smg_screen *ss = id;
    340 	int i;
    341 
    342 	bzero(&ss->ss_image[row][startcol], ncols);
    343 	bzero(&ss->ss_attr[row][startcol], ncols);
    344 	if (ss != curscr)
    345 		return;
    346 	for (i = 0; i < SM_CHEIGHT; i++)
    347 		bzero(&SM_ADDR(row, startcol, i), ncols);
    348 }
    349 
    350 static void
    351 smg_copyrows(void *id, int srcrow, int dstrow, int nrows)
    352 {
    353 	struct smg_screen *ss = id;
    354 	int frows;
    355 
    356 	bcopy(&ss->ss_image[srcrow][0], &ss->ss_image[dstrow][0],
    357 	    nrows * SM_COLS);
    358 	bcopy(&ss->ss_attr[srcrow][0], &ss->ss_attr[dstrow][0],
    359 	    nrows * SM_COLS);
    360 	if (ss != curscr)
    361 		return;
    362 	if (nrows > 25) {
    363 		frows = nrows >> 1;
    364 		if (srcrow > dstrow) {
    365 			bcopy(&sm_addr[(srcrow * SM_NEXTROW)],
    366 			    &sm_addr[(dstrow * SM_NEXTROW)],
    367 			    frows * SM_NEXTROW);
    368 			bcopy(&sm_addr[((srcrow + frows) * SM_NEXTROW)],
    369 			    &sm_addr[((dstrow + frows) * SM_NEXTROW)],
    370 			    (nrows - frows) * SM_NEXTROW);
    371 		} else {
    372 			bcopy(&sm_addr[((srcrow + frows) * SM_NEXTROW)],
    373 			    &sm_addr[((dstrow + frows) * SM_NEXTROW)],
    374 			    (nrows - frows) * SM_NEXTROW);
    375 			bcopy(&sm_addr[(srcrow * SM_NEXTROW)],
    376 			    &sm_addr[(dstrow * SM_NEXTROW)],
    377 			    frows * SM_NEXTROW);
    378 		}
    379 	} else
    380 		bcopy(&sm_addr[(srcrow * SM_NEXTROW)],
    381 		    &sm_addr[(dstrow * SM_NEXTROW)], nrows * SM_NEXTROW);
    382 }
    383 
    384 static void
    385 smg_eraserows(void *id, int startrow, int nrows, long fillattr)
    386 {
    387 	struct smg_screen *ss = id;
    388 	int frows;
    389 
    390 	bzero(&ss->ss_image[startrow][0], nrows * SM_COLS);
    391 	bzero(&ss->ss_attr[startrow][0], nrows * SM_COLS);
    392 	if (ss != curscr)
    393 		return;
    394 	if (nrows > 25) {
    395 		frows = nrows >> 1;
    396 		bzero(&sm_addr[(startrow * SM_NEXTROW)], frows * SM_NEXTROW);
    397 		bzero(&sm_addr[((startrow + frows) * SM_NEXTROW)],
    398 		    (nrows - frows) * SM_NEXTROW);
    399 	} else
    400 		bzero(&sm_addr[(startrow * SM_NEXTROW)], nrows * SM_NEXTROW);
    401 }
    402 
    403 static int
    404 smg_allocattr(void *id, int fg, int bg, int flags, long *attrp)
    405 {
    406 	*attrp = flags;
    407 	return 0;
    408 }
    409 
    410 static void
    411 setcursor(struct wsdisplay_cursor *v)
    412 {
    413 	u_short red, green, blue, curfg[16], curmask[16];
    414 	int i;
    415 
    416 	/* Enable cursor */
    417 	if (v->which & WSDISPLAY_CURSOR_DOCUR) {
    418 		if (v->enable)
    419 			curcmd |= CUR_CMD_ENPB|CUR_CMD_ENPA;
    420 		else
    421 			curcmd &= ~(CUR_CMD_ENPB|CUR_CMD_ENPA);
    422 		WRITECUR(CUR_CMD, curcmd);
    423 	}
    424 	if (v->which & WSDISPLAY_CURSOR_DOHOT) {
    425 		hotX = v->hot.x;
    426 		hotY = v->hot.y;
    427 	}
    428 	if (v->which & WSDISPLAY_CURSOR_DOCMAP) {
    429 		/* First background */
    430 		red = fusword(v->cmap.red);
    431 		green = fusword(v->cmap.green);
    432 		blue = fusword(v->cmap.blue);
    433 		bgmask = (((30L * red + 59L * green + 11L * blue) >> 8) >=
    434 		    (((1<<8)-1)*50)) ? ~0 : 0;
    435 		red = fusword(v->cmap.red+2);
    436 		green = fusword(v->cmap.green+2);
    437 		blue = fusword(v->cmap.blue+2);
    438 		fgmask = (((30L * red + 59L * green + 11L * blue) >> 8) >=
    439 		    (((1<<8)-1)*50)) ? ~0 : 0;
    440 	}
    441 	if (v->which & WSDISPLAY_CURSOR_DOSHAPE) {
    442 		WRITECUR(CUR_CMD, curcmd | CUR_CMD_LODSA);
    443 		copyin(v->image, curfg, sizeof(curfg));
    444 		copyin(v->mask, curmask, sizeof(curmask));
    445 		for (i = 0; i < sizeof(curfg)/2; i++) {
    446 			WRITECUR(CUR_LOAD, (curfg[i] & fgmask) |
    447 			    ((curmask[i] & ~curfg[i]) & bgmask));
    448 		}
    449 		for (i = 0; i < sizeof(curmask)/2; i++) {
    450 			WRITECUR(CUR_LOAD, curmask[i]);
    451 		}
    452 		WRITECUR(CUR_CMD, curcmd);
    453 	}
    454 }
    455 
    456 int
    457 smg_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
    458 {
    459 	struct wsdisplay_fbinfo *fb = (void *)data;
    460 	static short curc;
    461 
    462 	switch (cmd) {
    463 	case WSDISPLAYIO_GTYPE:
    464 		*(u_int *)data = WSDISPLAY_TYPE_VAX_MONO;
    465 		break;
    466 
    467 	case WSDISPLAYIO_GINFO:
    468 		fb->height = SM_YWIDTH;
    469 		fb->width = SM_XWIDTH;
    470 		fb->depth = 1;
    471 		fb->cmsize = 2;
    472 		break;
    473 
    474 	case WSDISPLAYIO_SVIDEO:
    475 		if (*(u_int *)data == WSDISPLAYIO_VIDEO_ON) {
    476 			curcmd = curc;
    477 		} else {
    478 			curc = curcmd;
    479 			curcmd &= ~(CUR_CMD_FOPA|CUR_CMD_ENPA);
    480 			curcmd |= CUR_CMD_FOPB;
    481 		}
    482 		WRITECUR(CUR_CMD, curcmd);
    483 		break;
    484 
    485 	case WSDISPLAYIO_GVIDEO:
    486 		*(u_int *)data = (curcmd & CUR_CMD_FOPB ?
    487 		    WSDISPLAYIO_VIDEO_OFF : WSDISPLAYIO_VIDEO_ON);
    488 		break;
    489 
    490 	case WSDISPLAYIO_SCURSOR:
    491 		setcursor((struct wsdisplay_cursor *)data);
    492 		break;
    493 
    494 	case WSDISPLAYIO_SCURPOS:
    495 		curx = ((struct wsdisplay_curpos *)data)->x;
    496 		cury = ((struct wsdisplay_curpos *)data)->y;
    497 		WRITECUR(CUR_XPOS, curx + CUR_XBIAS);
    498 		WRITECUR(CUR_YPOS, cury + CUR_YBIAS);
    499 		break;
    500 
    501 	case WSDISPLAYIO_GCURPOS:
    502 		((struct wsdisplay_curpos *)data)->x = curx;
    503 		((struct wsdisplay_curpos *)data)->y = cury;
    504 		break;
    505 
    506 	default:
    507 		return EPASSTHROUGH;
    508 	}
    509 	return 0;
    510 }
    511 
    512 static paddr_t
    513 smg_mmap(void *v, off_t offset, int prot)
    514 {
    515 	if (offset >= SMSIZE || offset < 0)
    516 		return -1;
    517 	return (SMADDR + offset) >> PGSHIFT;
    518 }
    519 
    520 int
    521 smg_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
    522     int *curxp, int *curyp, long *defattrp)
    523 {
    524 	*cookiep = malloc(sizeof(struct smg_screen), M_DEVBUF, M_WAITOK);
    525 	bzero(*cookiep, sizeof(struct smg_screen));
    526 	*curxp = *curyp = *defattrp = 0;
    527 	return 0;
    528 }
    529 
    530 void
    531 smg_free_screen(void *v, void *cookie)
    532 {
    533 }
    534 
    535 int
    536 smg_show_screen(void *v, void *cookie, int waitok,
    537     void (*cb)(void *, int, int), void *cbarg)
    538 {
    539 	struct smg_screen *ss = cookie;
    540 	int row, col, line;
    541 
    542 	if (ss == curscr)
    543 		return (0);
    544 
    545 	for (row = 0; row < SM_ROWS; row++)
    546 		for (line = 0; line < SM_CHEIGHT; line++) {
    547 			for (col = 0; col < SM_COLS; col++) {
    548 				u_char s, c = ss->ss_image[row][col];
    549 
    550 				if (c < 32)
    551 					c = 32;
    552 				s = QFONT(c, line);
    553 				if (ss->ss_attr[row][col] & WSATTR_REVERSE)
    554 					s ^= 255;
    555 				SM_ADDR(row, col, line) = s;
    556 			}
    557 			if (ss->ss_attr[row][col] & WSATTR_UNDERLINE)
    558 				SM_ADDR(row, col, line) = 255;
    559 		}
    560 	cursor = &sm_addr[(ss->ss_cury * SM_CHEIGHT * SM_COLS) + ss->ss_curx +
    561 	    ((SM_CHEIGHT - 1) * SM_COLS)];
    562 	curscr = ss;
    563 	return (0);
    564 }
    565 
    566 cons_decl(smg);
    567 
    568 void
    569 smgcninit(cndev)
    570 	struct	consdev *cndev;
    571 {
    572 	extern void lkccninit(struct consdev *);
    573 	extern int lkccngetc(dev_t);
    574 	extern int dz_vsbus_lk201_cnattach __P((int));
    575 	/* Clear screen */
    576 	memset(sm_addr, 0, 128*864);
    577 
    578 	curscr = &smg_conscreen;
    579 	wsdisplay_cnattach(&smg_stdscreen, &smg_conscreen, 0, 0, 0);
    580 	cn_tab->cn_pri = CN_INTERNAL;
    581 	qf = qvss8x15.data;
    582 
    583 #if NDZKBD > 0
    584 	dzkbd_cnattach(0); /* Connect keyboard and screen together */
    585 #endif
    586 }
    587 
    588 /*
    589  * Called very early to setup the glass tty as console.
    590  * Because it's called before the VM system is inited, virtual memory
    591  * for the framebuffer can be stolen directly without disturbing anything.
    592  */
    593 void
    594 smgcnprobe(cndev)
    595 	struct  consdev *cndev;
    596 {
    597 	extern vaddr_t virtual_avail;
    598 	extern const struct cdevsw wsdisplay_cdevsw;
    599 
    600 	switch (vax_boardtype) {
    601 	case VAX_BTYP_410:
    602 	case VAX_BTYP_420:
    603 	case VAX_BTYP_43:
    604 		if ((vax_confdata & KA420_CFG_L3CON) ||
    605 		    (vax_confdata & KA420_CFG_MULTU))
    606 			break; /* doesn't use graphics console */
    607 		sm_addr = (caddr_t)virtual_avail;
    608 		virtual_avail += SMSIZE;
    609 		ioaccess((vaddr_t)sm_addr, SMADDR, (SMSIZE/VAX_NBPG));
    610 		cndev->cn_pri = CN_INTERNAL;
    611 		cndev->cn_dev = makedev(cdevsw_lookup_major(&wsdisplay_cdevsw),
    612 					0);
    613 		break;
    614 
    615 	default:
    616 		break;
    617 	}
    618 }
    619