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