Home | History | Annotate | Line # | Download | only in vsa
smg.c revision 1.12
      1  1.12     ragge /*	$NetBSD: smg.c,v 1.12 1999/02/02 18:37:21 ragge Exp $ */
      2   1.1     ragge /*
      3   1.1     ragge  * Copyright (c) 1998 Ludd, University of Lule}, Sweden.
      4   1.1     ragge  * All rights reserved.
      5   1.1     ragge  *
      6   1.1     ragge  * Redistribution and use in source and binary forms, with or without
      7   1.1     ragge  * modification, are permitted provided that the following conditions
      8   1.1     ragge  * are met:
      9   1.1     ragge  * 1. Redistributions of source code must retain the above copyright
     10   1.1     ragge  *    notice, this list of conditions and the following disclaimer.
     11   1.1     ragge  * 2. Redistributions in binary form must reproduce the above copyright
     12   1.1     ragge  *    notice, this list of conditions and the following disclaimer in the
     13   1.1     ragge  *    documentation and/or other materials provided with the distribution.
     14   1.1     ragge  * 3. All advertising materials mentioning features or use of this software
     15   1.1     ragge  *    must display the following acknowledgement:
     16   1.6     ragge  *	This product includes software developed at Ludd, University of
     17   1.6     ragge  *	Lule}, Sweden and its contributors.
     18   1.1     ragge  * 4. The name of the author may not be used to endorse or promote products
     19   1.1     ragge  *    derived from this software without specific prior written permission
     20   1.1     ragge  *
     21   1.1     ragge  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22   1.1     ragge  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23   1.1     ragge  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24   1.1     ragge  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25   1.1     ragge  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26   1.1     ragge  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27   1.1     ragge  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28   1.1     ragge  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29   1.1     ragge  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30   1.1     ragge  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31   1.1     ragge  */
     32   1.1     ragge 
     33   1.1     ragge #include <sys/param.h>
     34   1.1     ragge #include <sys/device.h>
     35   1.1     ragge #include <sys/systm.h>
     36   1.1     ragge #include <sys/time.h>
     37   1.1     ragge #include <sys/malloc.h>
     38   1.1     ragge #include <sys/conf.h>
     39   1.6     ragge #include <sys/kernel.h>
     40   1.1     ragge 
     41   1.1     ragge #include <dev/cons.h>
     42   1.1     ragge 
     43   1.1     ragge #include <dev/wscons/wsdisplayvar.h>
     44   1.1     ragge #include <dev/wscons/wsconsio.h>
     45   1.1     ragge #include <dev/wscons/wscons_callbacks.h>
     46   1.1     ragge 
     47   1.1     ragge #include <machine/vsbus.h>
     48   1.1     ragge #include <machine/sid.h>
     49  1.12     ragge #include <machine/cpu.h>
     50   1.1     ragge 
     51   1.1     ragge #include "lkc.h"
     52   1.1     ragge 
     53   1.6     ragge #define SM_COLS		128	/* char width of screen */
     54   1.6     ragge #define SM_ROWS		57	/* rows of char on screen */
     55   1.6     ragge #define SM_CHEIGHT	15	/* lines a char consists of */
     56   1.6     ragge #define SM_NEXTROW	(SM_COLS * SM_CHEIGHT)
     57   1.1     ragge 
     58   1.1     ragge static	int smg_match __P((struct device *, struct cfdata *, void *));
     59   1.1     ragge static	void smg_attach __P((struct device *, struct device *, void *));
     60   1.1     ragge 
     61   1.1     ragge struct	smg_softc {
     62   1.1     ragge 	struct	device ss_dev;
     63   1.1     ragge };
     64   1.1     ragge 
     65   1.1     ragge struct cfattach smg_ca = {
     66   1.1     ragge 	sizeof(struct smg_softc), smg_match, smg_attach,
     67   1.1     ragge };
     68   1.1     ragge 
     69   1.1     ragge static void	smg_cursor __P((void *, int, int, int));
     70   1.5  drochner unsigned int	smg_mapchar __P((void *, int));
     71   1.4  drochner static void	smg_putchar __P((void *, int, int, u_int, long));
     72   1.1     ragge static void	smg_copycols __P((void *, int, int, int,int));
     73   1.1     ragge static void	smg_erasecols __P((void *, int, int, int, long));
     74   1.1     ragge static void	smg_copyrows __P((void *, int, int, int));
     75   1.1     ragge static void	smg_eraserows __P((void *, int, int, long));
     76   1.1     ragge static int	smg_alloc_attr __P((void *, int, int, int, long *));
     77   1.1     ragge 
     78   1.1     ragge const struct wsdisplay_emulops smg_emulops = {
     79   1.1     ragge 	smg_cursor,
     80   1.5  drochner 	smg_mapchar,
     81   1.4  drochner 	smg_putchar,
     82   1.1     ragge 	smg_copycols,
     83   1.1     ragge 	smg_erasecols,
     84   1.1     ragge 	smg_copyrows,
     85   1.1     ragge 	smg_eraserows,
     86   1.1     ragge 	smg_alloc_attr
     87   1.1     ragge };
     88   1.1     ragge 
     89   1.1     ragge const struct wsscreen_descr smg_stdscreen = {
     90   1.6     ragge 	"128x57", SM_COLS, SM_ROWS,
     91   1.6     ragge 	&smg_emulops,
     92   1.6     ragge 	8, SM_CHEIGHT,
     93   1.6     ragge 	WSSCREEN_UNDERLINE|WSSCREEN_REVERSE,
     94   1.1     ragge };
     95   1.1     ragge 
     96   1.1     ragge const struct wsscreen_descr *_smg_scrlist[] = {
     97   1.1     ragge 	&smg_stdscreen,
     98   1.1     ragge };
     99   1.1     ragge 
    100   1.1     ragge const struct wsscreen_list smg_screenlist = {
    101   1.1     ragge 	sizeof(_smg_scrlist) / sizeof(struct wsscreen_descr *),
    102   1.1     ragge 	_smg_scrlist,
    103   1.1     ragge };
    104   1.1     ragge 
    105  1.12     ragge static	caddr_t	sm_addr;
    106  1.12     ragge 
    107   1.6     ragge extern char q_font[];
    108   1.6     ragge #define QCHAR(c) (c < 32 ? 32 : (c > 127 ? c - 66 : c - 32))
    109   1.6     ragge #define QFONT(c,line)	q_font[QCHAR(c) * 15 + line]
    110   1.6     ragge #define	SM_ADDR(row, col, line) \
    111   1.6     ragge 	sm_addr[col + (row * SM_CHEIGHT * SM_COLS) + line * SM_COLS]
    112   1.6     ragge 
    113   1.6     ragge 
    114   1.1     ragge static int	smg_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
    115   1.1     ragge static int	smg_mmap __P((void *, off_t, int));
    116   1.1     ragge static int	smg_alloc_screen __P((void *, const struct wsscreen_descr *,
    117   1.6     ragge 				      void **, int *, int *, long *));
    118   1.1     ragge static void	smg_free_screen __P((void *, void *));
    119   1.1     ragge static void	smg_show_screen __P((void *, void *));
    120   1.6     ragge static void	smg_crsr_blink __P((void *));
    121   1.1     ragge 
    122   1.1     ragge const struct wsdisplay_accessops smg_accessops = {
    123   1.1     ragge 	smg_ioctl,
    124   1.1     ragge 	smg_mmap,
    125   1.1     ragge 	smg_alloc_screen,
    126   1.1     ragge 	smg_free_screen,
    127   1.1     ragge 	smg_show_screen,
    128  1.11  drochner 	0 /* load_font */
    129   1.1     ragge };
    130   1.1     ragge 
    131   1.1     ragge struct	smg_screen {
    132   1.1     ragge 	int	ss_curx;
    133   1.1     ragge 	int	ss_cury;
    134   1.2     ragge 	u_char	ss_image[SM_ROWS][SM_COLS];	/* Image of current screen */
    135   1.6     ragge 	u_char	ss_attr[SM_ROWS][SM_COLS];	/* Reversed etc... */
    136   1.1     ragge };
    137   1.1     ragge 
    138   1.2     ragge static	struct smg_screen smg_conscreen;
    139   1.2     ragge static	struct smg_screen *curscr;
    140   1.1     ragge 
    141   1.1     ragge int
    142   1.1     ragge smg_match(parent, match, aux)
    143   1.1     ragge 	struct device *parent;
    144   1.1     ragge 	struct cfdata *match;
    145   1.1     ragge 	void *aux;
    146   1.1     ragge {
    147   1.6     ragge 	struct	vsbus_attach_args *va = aux;
    148   1.1     ragge 
    149   1.8     ragge 	if (va->va_type != inr_vf)
    150   1.1     ragge 		return 0;
    151  1.12     ragge 
    152  1.12     ragge 	if (sm_addr == 0)
    153  1.12     ragge 		sm_addr = (caddr_t)vax_map_physmem(SMADDR, (SMSIZE/VAX_NBPG));
    154   1.1     ragge 	if (sm_addr == 0)
    155  1.12     ragge 		return 0;
    156   1.1     ragge 	return 1;
    157   1.1     ragge }
    158   1.1     ragge 
    159   1.1     ragge void
    160   1.1     ragge smg_attach(parent, self, aux)
    161   1.1     ragge 	struct device *parent, *self;
    162   1.1     ragge 	void *aux;
    163   1.1     ragge {
    164   1.1     ragge 	struct wsemuldisplaydev_attach_args aa;
    165   1.1     ragge 
    166   1.1     ragge 	printf("\n");
    167   1.2     ragge 	curscr = &smg_conscreen;
    168   1.1     ragge 	aa.console = !(vax_confdata & 0x20);
    169   1.1     ragge 	aa.scrdata = &smg_screenlist;
    170   1.1     ragge 	aa.accessops = &smg_accessops;
    171   1.6     ragge 	timeout(smg_crsr_blink, 0, hz/2);
    172   1.1     ragge 
    173   1.1     ragge 	config_found(self, &aa, wsemuldisplaydevprint);
    174   1.1     ragge }
    175   1.1     ragge 
    176   1.6     ragge static	u_char *cursor;
    177   1.6     ragge static	int cur_on;
    178   1.6     ragge 
    179   1.6     ragge static void
    180   1.6     ragge smg_crsr_blink(arg)
    181   1.6     ragge 	void *arg;
    182   1.6     ragge {
    183   1.6     ragge 	if (cur_on)
    184   1.6     ragge 		*cursor ^= 255;
    185   1.6     ragge 	timeout(smg_crsr_blink, 0, hz/2);
    186   1.6     ragge }
    187   1.6     ragge 
    188   1.1     ragge void
    189   1.1     ragge smg_cursor(id, on, row, col)
    190   1.1     ragge 	void *id;
    191   1.1     ragge 	int on, row, col;
    192   1.1     ragge {
    193   1.2     ragge 	struct smg_screen *ss = id;
    194   1.2     ragge 
    195   1.6     ragge 	if (ss == curscr) {
    196   1.6     ragge 		SM_ADDR(ss->ss_cury, ss->ss_curx, 14) =
    197   1.6     ragge 		    QFONT(ss->ss_image[ss->ss_cury][ss->ss_curx], 14);
    198   1.6     ragge 		cursor = &SM_ADDR(row, col, 14);
    199   1.6     ragge 		if ((cur_on = on))
    200   1.6     ragge 			*cursor ^= 255;
    201   1.6     ragge 	}
    202   1.2     ragge 	ss->ss_curx = col;
    203   1.2     ragge 	ss->ss_cury = row;
    204   1.5  drochner }
    205   1.5  drochner 
    206   1.5  drochner unsigned int
    207   1.5  drochner smg_mapchar(id, uni)
    208   1.5  drochner 	void *id;
    209   1.5  drochner 	int uni;
    210   1.5  drochner {
    211   1.5  drochner 	if (uni < 256)
    212   1.5  drochner 		return (uni);
    213   1.5  drochner 	return (0);
    214   1.1     ragge }
    215   1.1     ragge 
    216   1.1     ragge static void
    217   1.4  drochner smg_putchar(id, row, col, c, attr)
    218   1.1     ragge 	void *id;
    219   1.1     ragge 	int row, col;
    220   1.4  drochner 	u_int c;
    221   1.1     ragge 	long attr;
    222   1.1     ragge {
    223   1.2     ragge 	struct smg_screen *ss = id;
    224   1.4  drochner 	int i;
    225   1.1     ragge 
    226   1.4  drochner 	c &= 0xff;
    227   1.4  drochner 
    228   1.4  drochner 	ss->ss_image[row][col] = c;
    229   1.6     ragge 	ss->ss_attr[row][col] = attr;
    230   1.2     ragge 	if (ss != curscr)
    231   1.2     ragge 		return;
    232   1.6     ragge 	for (i = 0; i < 15; i++) {
    233   1.6     ragge 		unsigned char ch = QFONT(c, i);
    234   1.6     ragge 
    235   1.6     ragge 		SM_ADDR(row, col, i) = (attr & WSATTR_REVERSE ? ~ch : ch);
    236   1.6     ragge 
    237   1.6     ragge 	}
    238   1.6     ragge 	if (attr & WSATTR_UNDERLINE)
    239   1.6     ragge 		SM_ADDR(row, col, 14) ^= SM_ADDR(row, col, 14);
    240   1.1     ragge }
    241   1.1     ragge 
    242   1.1     ragge /*
    243   1.1     ragge  * copies columns inside a row.
    244   1.1     ragge  */
    245   1.1     ragge static void
    246   1.1     ragge smg_copycols(id, row, srccol, dstcol, ncols)
    247   1.1     ragge 	void *id;
    248   1.1     ragge 	int row, srccol, dstcol, ncols;
    249   1.1     ragge {
    250   1.2     ragge 	struct smg_screen *ss = id;
    251   1.1     ragge 	int i;
    252   1.1     ragge 
    253   1.2     ragge 	bcopy(&ss->ss_image[row][srccol], &ss->ss_image[row][dstcol], ncols);
    254   1.6     ragge 	bcopy(&ss->ss_attr[row][srccol], &ss->ss_attr[row][dstcol], ncols);
    255   1.2     ragge 	if (ss != curscr)
    256   1.2     ragge 		return;
    257   1.1     ragge 	for (i = 0; i < SM_CHEIGHT; i++)
    258   1.6     ragge 		bcopy(&SM_ADDR(row,srccol, i), &SM_ADDR(row, dstcol, i),ncols);
    259   1.1     ragge }
    260   1.1     ragge 
    261   1.1     ragge /*
    262   1.1     ragge  * Erases a bunch of chars inside one row.
    263   1.1     ragge  */
    264   1.1     ragge static void
    265   1.1     ragge smg_erasecols(id, row, startcol, ncols, fillattr)
    266   1.1     ragge 	void *id;
    267   1.1     ragge 	int row, startcol, ncols;
    268   1.1     ragge 	long fillattr;
    269   1.1     ragge {
    270   1.2     ragge 	struct smg_screen *ss = id;
    271   1.1     ragge 	int i;
    272   1.1     ragge 
    273   1.2     ragge 	bzero(&ss->ss_image[row][startcol], ncols);
    274   1.6     ragge 	bzero(&ss->ss_attr[row][startcol], ncols);
    275   1.2     ragge 	if (ss != curscr)
    276   1.2     ragge 		return;
    277   1.1     ragge 	for (i = 0; i < SM_CHEIGHT; i++)
    278   1.6     ragge 		bzero(&SM_ADDR(row, startcol, i), ncols);
    279   1.1     ragge }
    280   1.1     ragge 
    281   1.1     ragge static void
    282   1.1     ragge smg_copyrows(id, srcrow, dstrow, nrows)
    283   1.1     ragge 	void *id;
    284   1.1     ragge 	int srcrow, dstrow, nrows;
    285   1.1     ragge {
    286   1.2     ragge 	struct smg_screen *ss = id;
    287   1.1     ragge 	int frows;
    288   1.1     ragge 
    289   1.6     ragge 	bcopy(&ss->ss_image[srcrow][0], &ss->ss_image[dstrow][0],
    290   1.6     ragge 	    nrows * SM_COLS);
    291   1.6     ragge 	bcopy(&ss->ss_attr[srcrow][0], &ss->ss_attr[dstrow][0],
    292   1.6     ragge 	    nrows * SM_COLS);
    293   1.2     ragge 	if (ss != curscr)
    294   1.2     ragge 		return;
    295   1.1     ragge 	if (nrows > 25) {
    296   1.1     ragge 		frows = nrows >> 1;
    297   1.1     ragge 		if (srcrow > dstrow) {
    298   1.1     ragge 			bcopy(&sm_addr[(srcrow * SM_NEXTROW)],
    299   1.1     ragge 			    &sm_addr[(dstrow * SM_NEXTROW)],
    300   1.1     ragge 			    frows * SM_NEXTROW);
    301   1.1     ragge 			bcopy(&sm_addr[((srcrow + frows) * SM_NEXTROW)],
    302   1.1     ragge 			    &sm_addr[((dstrow + frows) * SM_NEXTROW)],
    303   1.1     ragge 			    (nrows - frows) * SM_NEXTROW);
    304   1.1     ragge 		} else {
    305   1.1     ragge 			bcopy(&sm_addr[((srcrow + frows) * SM_NEXTROW)],
    306   1.1     ragge 			    &sm_addr[((dstrow + frows) * SM_NEXTROW)],
    307   1.1     ragge 			    (nrows - frows) * SM_NEXTROW);
    308   1.1     ragge 			bcopy(&sm_addr[(srcrow * SM_NEXTROW)],
    309   1.1     ragge 			    &sm_addr[(dstrow * SM_NEXTROW)],
    310   1.1     ragge 			    frows * SM_NEXTROW);
    311   1.1     ragge 		}
    312   1.1     ragge 	} else
    313   1.1     ragge 		bcopy(&sm_addr[(srcrow * SM_NEXTROW)],
    314   1.1     ragge 		    &sm_addr[(dstrow * SM_NEXTROW)], nrows * SM_NEXTROW);
    315   1.1     ragge }
    316   1.1     ragge 
    317   1.1     ragge static void
    318   1.1     ragge smg_eraserows(id, startrow, nrows, fillattr)
    319   1.1     ragge 	void *id;
    320   1.1     ragge 	int startrow, nrows;
    321   1.1     ragge 	long fillattr;
    322   1.1     ragge {
    323   1.2     ragge 	struct smg_screen *ss = id;
    324   1.1     ragge 	int frows;
    325   1.1     ragge 
    326   1.6     ragge 	bzero(&ss->ss_image[startrow][0], nrows * SM_COLS);
    327   1.6     ragge 	bzero(&ss->ss_attr[startrow][0], nrows * SM_COLS);
    328   1.2     ragge 	if (ss != curscr)
    329   1.2     ragge 		return;
    330   1.1     ragge 	if (nrows > 25) {
    331   1.1     ragge 		frows = nrows >> 1;
    332   1.1     ragge 		bzero(&sm_addr[(startrow * SM_NEXTROW)], frows * SM_NEXTROW);
    333   1.1     ragge 		bzero(&sm_addr[((startrow + frows) * SM_NEXTROW)],
    334   1.1     ragge 		    (nrows - frows) * SM_NEXTROW);
    335   1.1     ragge 	} else
    336   1.1     ragge 		bzero(&sm_addr[(startrow * SM_NEXTROW)], nrows * SM_NEXTROW);
    337   1.1     ragge }
    338   1.1     ragge 
    339   1.1     ragge static int
    340   1.1     ragge smg_alloc_attr(id, fg, bg, flags, attrp)
    341   1.1     ragge 	void *id;
    342   1.1     ragge 	int fg, bg;
    343   1.1     ragge 	int flags;
    344   1.1     ragge 	long *attrp;
    345   1.1     ragge {
    346   1.6     ragge 	*attrp = flags;
    347   1.1     ragge 	return 0;
    348   1.1     ragge }
    349   1.1     ragge 
    350   1.1     ragge int
    351   1.1     ragge smg_ioctl(v, cmd, data, flag, p)
    352   1.1     ragge 	void *v;
    353   1.1     ragge 	u_long cmd;
    354   1.1     ragge 	caddr_t data;
    355   1.1     ragge 	int flag;
    356   1.1     ragge 	struct proc *p;
    357   1.1     ragge {
    358   1.8     ragge 	struct wsdisplay_fbinfo fb;
    359   1.8     ragge 
    360   1.8     ragge 	switch (cmd) {
    361   1.8     ragge 	case WSDISPLAYIO_GTYPE:
    362   1.8     ragge 		*(u_int *)data = WSDISPLAY_TYPE_PM_MONO;
    363   1.8     ragge 		break;
    364   1.8     ragge 
    365   1.8     ragge 	case WSDISPLAYIO_GINFO:
    366   1.8     ragge 		fb.height = 864;
    367   1.8     ragge 		fb.width = 1024;
    368   1.8     ragge 		return copyout(&fb, data, sizeof(struct wsdisplay_fbinfo));
    369   1.8     ragge 
    370   1.8     ragge 
    371   1.8     ragge 	default:
    372   1.8     ragge 		return -1;
    373   1.8     ragge 	}
    374   1.8     ragge 	return 0;
    375   1.1     ragge }
    376   1.1     ragge 
    377   1.1     ragge static int
    378   1.1     ragge smg_mmap(v, offset, prot)
    379   1.1     ragge 	void *v;
    380   1.1     ragge 	off_t offset;
    381   1.1     ragge 	int prot;
    382   1.1     ragge {
    383   1.9       mrg 	if (offset >= SMSIZE || offset < 0)
    384   1.8     ragge 		return -1;
    385   1.8     ragge 	return (SMADDR + offset) >> CLSHIFT;
    386   1.1     ragge }
    387   1.1     ragge 
    388   1.1     ragge int
    389   1.1     ragge smg_alloc_screen(v, type, cookiep, curxp, curyp, defattrp)
    390   1.1     ragge 	void *v;
    391   1.1     ragge 	const struct wsscreen_descr *type;
    392   1.1     ragge 	void **cookiep;
    393   1.1     ragge 	int *curxp, *curyp;
    394   1.1     ragge 	long *defattrp;
    395   1.1     ragge {
    396   1.2     ragge 	*cookiep = malloc(sizeof(struct smg_screen), M_DEVBUF, M_WAITOK);
    397   1.3     ragge 	bzero(*cookiep, sizeof(struct smg_screen));
    398   1.3     ragge 	*curxp = *curyp = *defattrp = 0;
    399   1.1     ragge 	return 0;
    400   1.1     ragge }
    401   1.1     ragge 
    402   1.1     ragge void
    403   1.1     ragge smg_free_screen(v, cookie)
    404   1.1     ragge 	void *v;
    405   1.1     ragge 	void *cookie;
    406   1.1     ragge {
    407   1.1     ragge }
    408   1.1     ragge 
    409   1.1     ragge void
    410   1.1     ragge smg_show_screen(v, cookie)
    411   1.1     ragge 	void *v;
    412   1.1     ragge 	void *cookie;
    413   1.1     ragge {
    414   1.2     ragge 	struct smg_screen *ss = cookie;
    415   1.2     ragge 	int row, col, line;
    416   1.2     ragge 
    417   1.2     ragge 	if (ss == curscr)
    418   1.2     ragge 		return;
    419   1.2     ragge 
    420   1.6     ragge 	for (row = 0; row < SM_ROWS; row++)
    421   1.8     ragge 		for (line = 0; line < SM_CHEIGHT; line++) {
    422   1.6     ragge 			for (col = 0; col < SM_COLS; col++) {
    423   1.6     ragge 				u_char s, c = ss->ss_image[row][col];
    424   1.6     ragge 
    425   1.6     ragge 				if (c < 32)
    426   1.6     ragge 					c = 32;
    427   1.6     ragge 				s = QFONT(c, line);
    428   1.6     ragge 				if (ss->ss_attr[row][col] & WSATTR_REVERSE)
    429   1.6     ragge 					s ^= 255;
    430   1.6     ragge 				SM_ADDR(row, col, line) = s;
    431   1.2     ragge 			}
    432   1.8     ragge 			if (ss->ss_attr[row][col] & WSATTR_UNDERLINE)
    433   1.8     ragge 				SM_ADDR(row, col, line) = 255;
    434   1.8     ragge 		}
    435   1.6     ragge 	cursor = &sm_addr[(ss->ss_cury * SM_CHEIGHT * SM_COLS) + ss->ss_curx +
    436   1.6     ragge 	    ((SM_CHEIGHT - 1) * SM_COLS)];
    437   1.2     ragge 	curscr = ss;
    438   1.1     ragge }
    439   1.1     ragge 
    440   1.1     ragge cons_decl(smg);
    441   1.1     ragge 
    442   1.6     ragge #define WSCONSOLEMAJOR 68
    443   1.1     ragge 
    444   1.1     ragge void
    445   1.1     ragge smgcninit(cndev)
    446   1.6     ragge 	struct	consdev *cndev;
    447   1.1     ragge {
    448   1.1     ragge 	extern void lkccninit __P((struct consdev *));
    449   1.1     ragge 	extern int lkccngetc __P((dev_t));
    450   1.1     ragge 	/* Clear screen */
    451  1.10     ragge 	memset(sm_addr, 0, 128*864);
    452   1.1     ragge 
    453   1.2     ragge 	curscr = &smg_conscreen;
    454   1.2     ragge 	wsdisplay_cnattach(&smg_stdscreen, &smg_conscreen, 0, 0, 0);
    455   1.1     ragge 	cn_tab->cn_dev = makedev(WSCONSOLEMAJOR, 0);
    456   1.1     ragge #if NLKC
    457   1.1     ragge 	lkccninit(cndev);
    458   1.1     ragge 	wsdisplay_set_cons_kbd(lkccngetc, nullcnpollc);
    459   1.1     ragge #endif
    460   1.1     ragge }
    461   1.1     ragge 
    462   1.1     ragge int smgprobe(void);
    463   1.1     ragge int
    464   1.1     ragge smgprobe()
    465   1.1     ragge {
    466   1.1     ragge 	switch (vax_boardtype) {
    467   1.1     ragge 	case VAX_BTYP_410:
    468   1.1     ragge 	case VAX_BTYP_420:
    469   1.1     ragge 	case VAX_BTYP_43:
    470   1.1     ragge 		if (vax_confdata & 0x20) /* doesn't use graphics console */
    471   1.1     ragge 			break;
    472  1.12     ragge 		sm_addr = (caddr_t)vax_map_physmem(SMADDR, (SMSIZE/VAX_NBPG));
    473  1.12     ragge 		if (sm_addr == 0)
    474  1.12     ragge 			return 0;
    475   1.1     ragge 
    476   1.1     ragge 		return 1;
    477   1.1     ragge 
    478   1.1     ragge 	default:
    479   1.1     ragge 		break;
    480   1.1     ragge 	}
    481   1.1     ragge 	return 0;
    482   1.1     ragge }
    483