Home | History | Annotate | Line # | Download | only in vsa
smg.c revision 1.27.8.7
      1 /*	$NetBSD: smg.c,v 1.27.8.7 2003/01/03 16:57:16 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 CFATTACH_DECL(smg, sizeof(struct smg_softc),
    120     smg_match, smg_attach, NULL, NULL);
    121 
    122 static void	smg_cursor(void *, int, int, int);
    123 static int	smg_mapchar(void *, int, unsigned int *);
    124 static void	smg_putchar(void *, int, int, u_int, long);
    125 static void	smg_copycols(void *, int, int, int,int);
    126 static void	smg_erasecols(void *, int, int, int, long);
    127 static void	smg_copyrows(void *, int, int, int);
    128 static void	smg_eraserows(void *, int, int, long);
    129 static int	smg_allocattr(void *, int, int, int, long *);
    130 
    131 const struct wsdisplay_emulops smg_emulops = {
    132 	smg_cursor,
    133 	smg_mapchar,
    134 	smg_putchar,
    135 	smg_copycols,
    136 	smg_erasecols,
    137 	smg_copyrows,
    138 	smg_eraserows,
    139 	smg_allocattr
    140 };
    141 
    142 const struct wsscreen_descr smg_stdscreen = {
    143 	"128x57", SM_COLS, SM_ROWS,
    144 	&smg_emulops,
    145 	8, SM_CHEIGHT,
    146 	WSSCREEN_UNDERLINE|WSSCREEN_REVERSE,
    147 };
    148 
    149 const struct wsscreen_descr *_smg_scrlist[] = {
    150 	&smg_stdscreen,
    151 };
    152 
    153 const struct wsscreen_list smg_screenlist = {
    154 	sizeof(_smg_scrlist) / sizeof(struct wsscreen_descr *),
    155 	_smg_scrlist,
    156 };
    157 
    158 static	caddr_t	sm_addr;
    159 
    160 extern struct wsdisplay_font qvss8x15;
    161 static  u_char *qf;
    162 
    163 #define QCHAR(c) (c < 32 ? 32 : (c > 127 ? c - 66 : c - 32))
    164 #define QFONT(c,line)	qf[QCHAR(c) * 15 + line]
    165 #define	SM_ADDR(row, col, line) \
    166 	sm_addr[col + (row * SM_CHEIGHT * SM_COLS) + line * SM_COLS]
    167 
    168 
    169 static int	smg_ioctl(void *, u_long, caddr_t, int, struct proc *);
    170 static paddr_t	smg_mmap(void *, off_t, int);
    171 static int	smg_alloc_screen(void *, const struct wsscreen_descr *,
    172 				      void **, int *, int *, long *);
    173 static void	smg_free_screen(void *, void *);
    174 static int	smg_show_screen(void *, void *, int,
    175 				     void (*) (void *, int, int), void *);
    176 static void	smg_crsr_blink(void *);
    177 
    178 const struct wsdisplay_accessops smg_accessops = {
    179 	smg_ioctl,
    180 	smg_mmap,
    181 	smg_alloc_screen,
    182 	smg_free_screen,
    183 	smg_show_screen,
    184 	0 /* load_font */
    185 };
    186 
    187 struct	smg_screen {
    188 	int	ss_curx;
    189 	int	ss_cury;
    190 	u_char	ss_image[SM_ROWS][SM_COLS];	/* Image of current screen */
    191 	u_char	ss_attr[SM_ROWS][SM_COLS];	/* Reversed etc... */
    192 };
    193 
    194 static	struct smg_screen smg_conscreen;
    195 static	struct smg_screen *curscr;
    196 
    197 static	struct callout smg_cursor_ch = CALLOUT_INITIALIZER;
    198 
    199 int
    200 smg_match(struct device *parent, struct cfdata *match, void *aux)
    201 {
    202 	struct vsbus_attach_args *va = aux;
    203 	volatile short *curcmd;
    204 	volatile short *cfgtst;
    205 	short tmp, tmp2;
    206 
    207 	if (vax_boardtype == VAX_BTYP_49 || vax_boardtype == VAX_BTYP_53)
    208 		return 0;
    209 
    210 	curcmd = (short *)va->va_addr;
    211 	cfgtst = (short *)vax_map_physmem(VS_CFGTST, 1);
    212 	/*
    213 	 * Try to find the cursor chip by testing the flip-flop.
    214 	 * If nonexistent, no glass tty.
    215 	 */
    216 	curcmd[0] = CUR_CMD_HSHI|CUR_CMD_FOPB;
    217 	DELAY(300000);
    218 	tmp = cfgtst[0];
    219 	curcmd[0] = CUR_CMD_TEST|CUR_CMD_HSHI;
    220 	DELAY(300000);
    221 	tmp2 = cfgtst[0];
    222 	vax_unmap_physmem((vaddr_t)cfgtst, 1);
    223 
    224 	if (tmp2 != tmp)
    225 		return 20; /* Using periodic interrupt */
    226 	else
    227 		return 0;
    228 }
    229 
    230 void
    231 smg_attach(struct device *parent, struct device *self, void *aux)
    232 {
    233 	struct wsemuldisplaydev_attach_args aa;
    234 
    235 	printf("\n");
    236 	sm_addr = (caddr_t)vax_map_physmem(SMADDR, (SMSIZE/VAX_NBPG));
    237 	curaddr = (caddr_t)vax_map_physmem(KA420_CUR_BASE, 1);
    238 	if (sm_addr == 0) {
    239 		printf("%s: Couldn't alloc graphics memory.\n", self->dv_xname);
    240 		return;
    241 	}
    242 	curscr = &smg_conscreen;
    243 	aa.console = (vax_confdata & (KA420_CFG_L3CON|KA420_CFG_MULTU)) == 0;
    244 
    245 	aa.scrdata = &smg_screenlist;
    246 	aa.accessops = &smg_accessops;
    247 	callout_reset(&smg_cursor_ch, hz / 2, smg_crsr_blink, NULL);
    248 	curcmd = CUR_CMD_HSHI;
    249 	WRITECUR(CUR_CMD, curcmd);
    250 	qf = qvss8x15.data;
    251 
    252 	config_found(self, &aa, wsemuldisplaydevprint);
    253 }
    254 
    255 static	u_char *cursor;
    256 static	int cur_on;
    257 
    258 static void
    259 smg_crsr_blink(void *arg)
    260 {
    261 	if (cur_on)
    262 		*cursor ^= 255;
    263 	callout_reset(&smg_cursor_ch, hz / 2, smg_crsr_blink, NULL);
    264 }
    265 
    266 void
    267 smg_cursor(void *id, int on, int row, int col)
    268 {
    269 	struct smg_screen *ss = id;
    270 
    271 	if (ss == curscr) {
    272 		SM_ADDR(ss->ss_cury, ss->ss_curx, 14) =
    273 		    QFONT(ss->ss_image[ss->ss_cury][ss->ss_curx], 14);
    274 		cursor = &SM_ADDR(row, col, 14);
    275 		if ((cur_on = on))
    276 			*cursor ^= 255;
    277 	}
    278 	ss->ss_curx = col;
    279 	ss->ss_cury = row;
    280 }
    281 
    282 int
    283 smg_mapchar(void *id, int uni, unsigned int *index)
    284 {
    285 	if (uni < 256) {
    286 		*index = uni;
    287 		return (5);
    288 	}
    289 	*index = ' ';
    290 	return (0);
    291 }
    292 
    293 static void
    294 smg_putchar(void *id, int row, int col, u_int c, long attr)
    295 {
    296 	struct smg_screen *ss = id;
    297 	int i;
    298 
    299 	c &= 0xff;
    300 
    301 	ss->ss_image[row][col] = c;
    302 	ss->ss_attr[row][col] = attr;
    303 	if (ss != curscr)
    304 		return;
    305 	for (i = 0; i < 15; i++) {
    306 		unsigned char ch = QFONT(c, i);
    307 
    308 		SM_ADDR(row, col, i) = (attr & WSATTR_REVERSE ? ~ch : ch);
    309 
    310 	}
    311 	if (attr & WSATTR_UNDERLINE)
    312 		SM_ADDR(row, col, 14) ^= SM_ADDR(row, col, 14);
    313 }
    314 
    315 /*
    316  * copies columns inside a row.
    317  */
    318 static void
    319 smg_copycols(void *id, int row, int srccol, int dstcol, int ncols)
    320 {
    321 	struct smg_screen *ss = id;
    322 	int i;
    323 
    324 	bcopy(&ss->ss_image[row][srccol], &ss->ss_image[row][dstcol], ncols);
    325 	bcopy(&ss->ss_attr[row][srccol], &ss->ss_attr[row][dstcol], ncols);
    326 	if (ss != curscr)
    327 		return;
    328 	for (i = 0; i < SM_CHEIGHT; i++)
    329 		bcopy(&SM_ADDR(row,srccol, i), &SM_ADDR(row, dstcol, i),ncols);
    330 }
    331 
    332 /*
    333  * Erases a bunch of chars inside one row.
    334  */
    335 static void
    336 smg_erasecols(void *id, int row, int startcol, int ncols, long fillattr)
    337 {
    338 	struct smg_screen *ss = id;
    339 	int i;
    340 
    341 	bzero(&ss->ss_image[row][startcol], ncols);
    342 	bzero(&ss->ss_attr[row][startcol], ncols);
    343 	if (ss != curscr)
    344 		return;
    345 	for (i = 0; i < SM_CHEIGHT; i++)
    346 		bzero(&SM_ADDR(row, startcol, i), ncols);
    347 }
    348 
    349 static void
    350 smg_copyrows(void *id, int srcrow, int dstrow, int nrows)
    351 {
    352 	struct smg_screen *ss = id;
    353 	int frows;
    354 
    355 	bcopy(&ss->ss_image[srcrow][0], &ss->ss_image[dstrow][0],
    356 	    nrows * SM_COLS);
    357 	bcopy(&ss->ss_attr[srcrow][0], &ss->ss_attr[dstrow][0],
    358 	    nrows * SM_COLS);
    359 	if (ss != curscr)
    360 		return;
    361 	if (nrows > 25) {
    362 		frows = nrows >> 1;
    363 		if (srcrow > dstrow) {
    364 			bcopy(&sm_addr[(srcrow * SM_NEXTROW)],
    365 			    &sm_addr[(dstrow * SM_NEXTROW)],
    366 			    frows * SM_NEXTROW);
    367 			bcopy(&sm_addr[((srcrow + frows) * SM_NEXTROW)],
    368 			    &sm_addr[((dstrow + frows) * SM_NEXTROW)],
    369 			    (nrows - frows) * SM_NEXTROW);
    370 		} else {
    371 			bcopy(&sm_addr[((srcrow + frows) * SM_NEXTROW)],
    372 			    &sm_addr[((dstrow + frows) * SM_NEXTROW)],
    373 			    (nrows - frows) * SM_NEXTROW);
    374 			bcopy(&sm_addr[(srcrow * SM_NEXTROW)],
    375 			    &sm_addr[(dstrow * SM_NEXTROW)],
    376 			    frows * SM_NEXTROW);
    377 		}
    378 	} else
    379 		bcopy(&sm_addr[(srcrow * SM_NEXTROW)],
    380 		    &sm_addr[(dstrow * SM_NEXTROW)], nrows * SM_NEXTROW);
    381 }
    382 
    383 static void
    384 smg_eraserows(void *id, int startrow, int nrows, long fillattr)
    385 {
    386 	struct smg_screen *ss = id;
    387 	int frows;
    388 
    389 	bzero(&ss->ss_image[startrow][0], nrows * SM_COLS);
    390 	bzero(&ss->ss_attr[startrow][0], nrows * SM_COLS);
    391 	if (ss != curscr)
    392 		return;
    393 	if (nrows > 25) {
    394 		frows = nrows >> 1;
    395 		bzero(&sm_addr[(startrow * SM_NEXTROW)], frows * SM_NEXTROW);
    396 		bzero(&sm_addr[((startrow + frows) * SM_NEXTROW)],
    397 		    (nrows - frows) * SM_NEXTROW);
    398 	} else
    399 		bzero(&sm_addr[(startrow * SM_NEXTROW)], nrows * SM_NEXTROW);
    400 }
    401 
    402 static int
    403 smg_allocattr(void *id, int fg, int bg, int flags, long *attrp)
    404 {
    405 	*attrp = flags;
    406 	return 0;
    407 }
    408 
    409 static void
    410 setcursor(struct wsdisplay_cursor *v)
    411 {
    412 	u_short red, green, blue;
    413 	u_int32_t 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)/sizeof(curfg[0]); i++) {
    446 			WRITECUR(CUR_LOAD, ((u_int16_t)curfg[i] & fgmask) |
    447 			    (((u_int16_t)curmask[i] & (u_int16_t)~curfg[i])
    448 			    & bgmask));
    449 		}
    450 		for (i = 0; i < sizeof(curmask)/sizeof(curmask[0]); i++) {
    451 			WRITECUR(CUR_LOAD, (u_int16_t)curmask[i]);
    452 		}
    453 		WRITECUR(CUR_CMD, curcmd);
    454 	}
    455 }
    456 
    457 int
    458 smg_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
    459 {
    460 	struct wsdisplay_fbinfo *fb = (void *)data;
    461 	static short curc;
    462 
    463 	switch (cmd) {
    464 	case WSDISPLAYIO_GTYPE:
    465 		*(u_int *)data = WSDISPLAY_TYPE_VAX_MONO;
    466 		break;
    467 
    468 	case WSDISPLAYIO_GINFO:
    469 		fb->height = SM_YWIDTH;
    470 		fb->width = SM_XWIDTH;
    471 		fb->depth = 1;
    472 		fb->cmsize = 2;
    473 		break;
    474 
    475 	case WSDISPLAYIO_SVIDEO:
    476 		if (*(u_int *)data == WSDISPLAYIO_VIDEO_ON) {
    477 			curcmd = curc;
    478 		} else {
    479 			curc = curcmd;
    480 			curcmd &= ~(CUR_CMD_FOPA|CUR_CMD_ENPA);
    481 			curcmd |= CUR_CMD_FOPB;
    482 		}
    483 		WRITECUR(CUR_CMD, curcmd);
    484 		break;
    485 
    486 	case WSDISPLAYIO_GVIDEO:
    487 		*(u_int *)data = (curcmd & CUR_CMD_FOPB ?
    488 		    WSDISPLAYIO_VIDEO_OFF : WSDISPLAYIO_VIDEO_ON);
    489 		break;
    490 
    491 	case WSDISPLAYIO_SCURSOR:
    492 		setcursor((struct wsdisplay_cursor *)data);
    493 		break;
    494 
    495 	case WSDISPLAYIO_SCURPOS:
    496 		curx = ((struct wsdisplay_curpos *)data)->x;
    497 		cury = ((struct wsdisplay_curpos *)data)->y;
    498 		WRITECUR(CUR_XPOS, curx + CUR_XBIAS);
    499 		WRITECUR(CUR_YPOS, cury + CUR_YBIAS);
    500 		break;
    501 
    502 	case WSDISPLAYIO_GCURPOS:
    503 		((struct wsdisplay_curpos *)data)->x = curx;
    504 		((struct wsdisplay_curpos *)data)->y = cury;
    505 		break;
    506 
    507 	case WSDISPLAYIO_GCURMAX:
    508 		((struct wsdisplay_curpos *)data)->x = 16;
    509 		((struct wsdisplay_curpos *)data)->y = 16;
    510 		break;
    511 
    512 	default:
    513 		return EPASSTHROUGH;
    514 	}
    515 	return 0;
    516 }
    517 
    518 static paddr_t
    519 smg_mmap(void *v, off_t offset, int prot)
    520 {
    521 	if (offset >= SMSIZE || offset < 0)
    522 		return -1;
    523 	return (SMADDR + offset) >> PGSHIFT;
    524 }
    525 
    526 int
    527 smg_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
    528     int *curxp, int *curyp, long *defattrp)
    529 {
    530 	*cookiep = malloc(sizeof(struct smg_screen), M_DEVBUF, M_WAITOK);
    531 	bzero(*cookiep, sizeof(struct smg_screen));
    532 	*curxp = *curyp = *defattrp = 0;
    533 	return 0;
    534 }
    535 
    536 void
    537 smg_free_screen(void *v, void *cookie)
    538 {
    539 }
    540 
    541 int
    542 smg_show_screen(void *v, void *cookie, int waitok,
    543     void (*cb)(void *, int, int), void *cbarg)
    544 {
    545 	struct smg_screen *ss = cookie;
    546 	int row, col, line;
    547 
    548 	if (ss == curscr)
    549 		return (0);
    550 
    551 	for (row = 0; row < SM_ROWS; row++)
    552 		for (line = 0; line < SM_CHEIGHT; line++) {
    553 			for (col = 0; col < SM_COLS; col++) {
    554 				u_char s, c = ss->ss_image[row][col];
    555 
    556 				if (c < 32)
    557 					c = 32;
    558 				s = QFONT(c, line);
    559 				if (ss->ss_attr[row][col] & WSATTR_REVERSE)
    560 					s ^= 255;
    561 				SM_ADDR(row, col, line) = s;
    562 			}
    563 			if (ss->ss_attr[row][col] & WSATTR_UNDERLINE)
    564 				SM_ADDR(row, col, line) = 255;
    565 		}
    566 	cursor = &sm_addr[(ss->ss_cury * SM_CHEIGHT * SM_COLS) + ss->ss_curx +
    567 	    ((SM_CHEIGHT - 1) * SM_COLS)];
    568 	curscr = ss;
    569 	return (0);
    570 }
    571 
    572 cons_decl(smg);
    573 
    574 void
    575 smgcninit(cndev)
    576 	struct	consdev *cndev;
    577 {
    578 	extern void lkccninit(struct consdev *);
    579 	extern int lkccngetc(dev_t);
    580 	extern int dz_vsbus_lk201_cnattach __P((int));
    581 	/* Clear screen */
    582 	memset(sm_addr, 0, 128*864);
    583 
    584 	curscr = &smg_conscreen;
    585 	wsdisplay_cnattach(&smg_stdscreen, &smg_conscreen, 0, 0, 0);
    586 	cn_tab->cn_pri = CN_INTERNAL;
    587 	qf = qvss8x15.data;
    588 
    589 #if NDZKBD > 0
    590 	dzkbd_cnattach(0); /* Connect keyboard and screen together */
    591 #endif
    592 }
    593 
    594 /*
    595  * Called very early to setup the glass tty as console.
    596  * Because it's called before the VM system is inited, virtual memory
    597  * for the framebuffer can be stolen directly without disturbing anything.
    598  */
    599 void
    600 smgcnprobe(cndev)
    601 	struct  consdev *cndev;
    602 {
    603 	extern vaddr_t virtual_avail;
    604 	extern const struct cdevsw wsdisplay_cdevsw;
    605 
    606 	switch (vax_boardtype) {
    607 	case VAX_BTYP_410:
    608 	case VAX_BTYP_420:
    609 	case VAX_BTYP_43:
    610 		if ((vax_confdata & KA420_CFG_L3CON) ||
    611 		    (vax_confdata & KA420_CFG_MULTU))
    612 			break; /* doesn't use graphics console */
    613 		sm_addr = (caddr_t)virtual_avail;
    614 		virtual_avail += SMSIZE;
    615 		ioaccess((vaddr_t)sm_addr, SMADDR, (SMSIZE/VAX_NBPG));
    616 		cndev->cn_pri = CN_INTERNAL;
    617 		cndev->cn_dev = makedev(cdevsw_lookup_major(&wsdisplay_cdevsw),
    618 					0);
    619 		break;
    620 
    621 	default:
    622 		break;
    623 	}
    624 }
    625