From 2693ffa811b543a36df2743b848bb70d0890b45e Mon Sep 17 00:00:00 2001 From: miod Date: Wed, 20 Aug 2008 18:59:59 +0000 Subject: [PATCH] Minimal driver for the VAXstation 35x0/38x0 LEGSS option, currently limited to 8 bit mode operation, and no color or accelerated features until I can find documentation about it. Speed is decent by VAX standards, except for scrolling, which is so abysmally slow one could see ZZ Top's beards growing while waiting for the screen to scroll... --- distrib/notes/vax/hardware | 10 +- share/man/man4/man4.vax/Makefile | 4 +- share/man/man4/man4.vax/intro.4 | 6 +- share/man/man4/man4.vax/legss.4 | 50 ++++ share/man/man4/man4.vax/mbus.4 | 8 +- sys/arch/vax/conf/GENERIC | 6 +- sys/arch/vax/conf/RAMDISK | 6 +- sys/arch/vax/dec/dzcons.c | 16 +- sys/arch/vax/mbus/files.mbus | 12 +- sys/arch/vax/mbus/legss.c | 428 ++++++++++++++++++++++++++++++ sys/arch/vax/vax/findcpu.c | 10 +- sys/arch/vax/vax/wscons_machdep.c | 8 +- 12 files changed, 534 insertions(+), 30 deletions(-) create mode 100644 share/man/man4/man4.vax/legss.4 create mode 100644 sys/arch/vax/mbus/legss.c diff --git a/distrib/notes/vax/hardware b/distrib/notes/vax/hardware index 7b6332a3576..f3f4ba5997a 100644 --- a/distrib/notes/vax/hardware +++ b/distrib/notes/vax/hardware @@ -1,11 +1,11 @@ -dnl $OpenBSD: hardware,v 1.25 2008/08/18 23:19:15 miod Exp $ +dnl $OpenBSD: hardware,v 1.26 2008/08/20 18:59:59 miod Exp $ OpenBSD/MACHINE OSREV runs on a wide variety of VAX hardware. The following systems have been tested: - VAXstation 2000 - VAXstation 3100/{30,40} - VAXstation 3100/{38,48} - VAXstation 3100/76 - - VAXstation 3520,3540 + - VAXstation 3520,3540 (3820 and 3840 should also run) - VAXstation 4000/VLC - VAXstation 4000/60 - VAXstation 4000/90 @@ -55,11 +55,13 @@ Supported devices {:-include-:}: - VAXstation 3100/{30,38,40,48} color frame buffer option (gpx) - VAXstation 3100/76 SPX frame buffer, also available as on option for VAXstation 3100/{30,38,40,48} (lcspx) + - VAXstation 35x0/38x0 frame buffer (legss), without the 16 planes + option - VAXstation 4000/60 and 4000/VLC frame buffer (lcg) - VAXstation 4000/90 color frame buffer (lcspx) - VXT2000 color frame buffer (lcspx) - The VXT2000 monochrome frame buffer and the spxg/spxgt option for - VAXstation 4000s are not supported yet. + The VXT2000 monochrome frame buffer, the LEGSS 16 plane option and + the spxg/spxgt option for VAXstation 4000s are not supported yet. * Input devices: - LK201 and LK401 keyboards (lkkbd) diff --git a/share/man/man4/man4.vax/Makefile b/share/man/man4/man4.vax/Makefile index 180e929eed3..6d94688df8e 100644 --- a/share/man/man4/man4.vax/Makefile +++ b/share/man/man4/man4.vax/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.23 2008/08/18 23:19:18 miod Exp $ +# $OpenBSD: Makefile,v 1.24 2008/08/20 19:00:01 miod Exp $ # $NetBSD: Makefile,v 1.6 1996/03/03 17:13:09 thorpej Exp $ # from: @(#)Makefile 5.4 (Berkeley) 5/11/90 @@ -7,7 +7,7 @@ # ec.4 en.4 ex.4 fl.4 hdh.4 hk.4 ht.4 hy.4 ik.4 il.4 ix.4 kg.4 lp.4 np.4 # pcl.4 ps.4 tm.4 tmscp.4 tu.4 up.4 ut.4 uu.4 va.4 vp.4 vv.4 MAN= asc.4 autoconf.4 cons.4 de.4 dhu.4 dz.4 fwio.4 gpx.4 hp.4 \ - ibus.4 intro.4 lcg.4 lcspx.4 le.4 led.4 lkkbd.4 lkms.4 \ + ibus.4 intro.4 lcg.4 lcspx.4 le.4 led.4 legss.4 lkkbd.4 lkms.4 \ mbus.4 mem.4 mscpbus.4 mt.4 mtc.4 ncr.4 qe.4 qsc.4 ra.4 rx.4 \ sii.4 smg.4 ts.4 uba.4 uda.4 vsbus.4 vxtbus.4 ze.4 MLINKS= mem.4 kmem.4 diff --git a/share/man/man4/man4.vax/intro.4 b/share/man/man4/man4.vax/intro.4 index 01e0862aafb..c22761391e1 100644 --- a/share/man/man4/man4.vax/intro.4 +++ b/share/man/man4/man4.vax/intro.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: intro.4,v 1.31 2008/08/18 23:19:18 miod Exp $ +.\" $OpenBSD: intro.4,v 1.32 2008/08/20 19:00:01 miod Exp $ .\" $NetBSD: intro.4,v 1.3 1996/03/03 17:13:44 thorpej Exp $ .\" .\" Copyright (c) 1980, 1991 Regents of the University of California. @@ -30,7 +30,7 @@ .\" .\" from: @(#)intro.4 6.6 (Berkeley) 3/27/91 .\" -.Dd $Mdocdate: August 18 2008 $ +.Dd $Mdocdate: August 20 2008 $ .Dt INTRO 4 vax .Os .Sh NAME @@ -126,6 +126,8 @@ Low-Cost SPX color frame buffer AMD LANCE Ethernet device .It Xr led 4 VAX LED driver +.It Xr legss 4 +Low-End Graphics Subsystem .It Xr lkkbd 4 LK200/LK400 keyboard driver .It Xr lkms 4 diff --git a/share/man/man4/man4.vax/legss.4 b/share/man/man4/man4.vax/legss.4 new file mode 100644 index 00000000000..5059e5597e1 --- /dev/null +++ b/share/man/man4/man4.vax/legss.4 @@ -0,0 +1,50 @@ +.\" $OpenBSD: legss.4,v 1.1 2008/08/20 19:00:01 miod Exp $ +.\" +.\" Copyright (c) 2008 Miodrag Vallat. +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: August 20 2008 $ +.Dt LEGSS 4 vax +.Os +.Sh NAME +.Nm legss +.Nd Low-End Graphics Subsystem +.Sh SYNOPSIS +.Cd "legss* at mbus0 mid 7" +.Cd "wsdisplay* at legss?" +.Sh DESCRIPTION +The +.Nm +is a 8 bit color frame buffer found in VAXstation 35x0 and 38x0 series. +An optional VCB03 16 plane option expands it to a 24 bit color frame buffer. +.Pp +The +.Nm +driver interfaces the frame buffer with the +.Xr wscons 4 +console framework. +It does not provide direct device driver entry points +but makes its functions available via the internal +.Xr wsdisplay 4 +interface. +.Sh SEE ALSO +.Xr intro 4 , +.Xr mbus 4 , +.Xr wscons 4 , +.Xr wsdisplay 4 +.Sh BUGS +The 16 plane option is currently not supported, and needs to be removed +for the +.Nm +driver to operate properly. diff --git a/share/man/man4/man4.vax/mbus.4 b/share/man/man4/man4.vax/mbus.4 index eb7c09d466a..efb3dce7828 100644 --- a/share/man/man4/man4.vax/mbus.4 +++ b/share/man/man4/man4.vax/mbus.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mbus.4,v 1.1 2008/08/18 23:19:18 miod Exp $ +.\" $OpenBSD: mbus.4,v 1.2 2008/08/20 19:00:01 miod Exp $ .\" .\" Copyright (c) 2008 Miodrag Vallat. .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: August 18 2008 $ +.Dd $Mdocdate: August 20 2008 $ .Dt MBUS 4 vax .Os .Sh NAME @@ -34,8 +34,8 @@ The following M-bus devices are supported: .Bl -tag -width 8n -compact -offset indent .It Xr fwio 4 Firefox Workstation I/O module -.\" .It Xr legss 4 -.\" Low-End Graphics Subsystem +.It Xr legss 4 +Low-End Graphics Subsystem .It Xr uba 4 UNIBUS/Q-bus controller .El diff --git a/sys/arch/vax/conf/GENERIC b/sys/arch/vax/conf/GENERIC index aed634833eb..c33bc61ecd4 100644 --- a/sys/arch/vax/conf/GENERIC +++ b/sys/arch/vax/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.49 2008/08/18 23:19:21 miod Exp $ +# $OpenBSD: GENERIC,v 1.50 2008/08/20 19:00:01 miod Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -84,7 +84,8 @@ le0 at ibus0 # LANCE ethernet (MV3400) # M-bus found on VS 3[58][24]0 fwio* at mbus0 mid ? # I/O module -uba0 at mbus0 mid 0 +legss0 at mbus0 mid 7 # Graphics module +uba0 at mbus0 mid 0 # Q-bus adaptor module dz0 at fwio? # DZ-11 like serial ports dz* at fwio? # DZ-11 (on additional fwio) @@ -160,6 +161,7 @@ uk* at scsibus? wsdisplay* at gpx? wsdisplay* at lcg? wsdisplay* at lcspx? +wsdisplay* at legss? wsdisplay* at smg? #wsdisplay* at qd0 diff --git a/sys/arch/vax/conf/RAMDISK b/sys/arch/vax/conf/RAMDISK index ec7e7f96b5d..f5f08986929 100644 --- a/sys/arch/vax/conf/RAMDISK +++ b/sys/arch/vax/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.30 2008/08/18 23:19:21 miod Exp $ +# $OpenBSD: RAMDISK,v 1.31 2008/08/20 19:00:01 miod Exp $ machine vax # machine type @@ -91,7 +91,8 @@ le0 at ibus0 # LANCE ethernet # M-bus found on VS 3[58][24]0 fwio* at mbus0 mid ? # I/O module -uba0 at mbus0 mid 0 +legss0 at mbus0 mid 7 # Graphics module +uba0 at mbus0 mid 0 # Q-bus adaptor module dz0 at fwio? # DZ-11 like serial ports dz* at fwio? # DZ-11 (on additional fwio) @@ -167,6 +168,7 @@ cd* at scsibus? wsdisplay* at gpx? wsdisplay* at lcg? wsdisplay* at lcspx? +wsdisplay* at legss? wsdisplay* at smg? #wsdisplay* at qd0 diff --git a/sys/arch/vax/dec/dzcons.c b/sys/arch/vax/dec/dzcons.c index 3e40c7c70f8..79bac467ce9 100644 --- a/sys/arch/vax/dec/dzcons.c +++ b/sys/arch/vax/dec/dzcons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dzcons.c,v 1.3 2008/08/20 18:55:24 miod Exp $ */ +/* $OpenBSD: dzcons.c,v 1.4 2008/08/20 19:00:01 miod Exp $ */ /* $NetBSD: dz_ibus.c,v 1.15 1999/08/27 17:50:42 ragge Exp $ */ /* * Copyright (c) 1998 Ludd, University of Lule}, Sweden. @@ -50,6 +50,7 @@ #ifdef VAX60 #include #include +#include #endif #include @@ -164,12 +165,14 @@ dzcnprobe(cndev) struct consdev *cndev; { extern vaddr_t iospace; - int diagcons, major; + int diagcons, major, pri; paddr_t ioaddr = 0x200a0000; if ((major = getmajor(dzopen)) < 0) return; + pri = CN_DEAD; + switch (vax_boardtype) { case VAX_BTYP_410: case VAX_BTYP_420: @@ -194,8 +197,9 @@ dzcnprobe(cndev) #ifdef VAX60 case VAX_BTYP_60: - ioaddr = MBUS_SLOT_BASE(mbus_ioslot) + 0x600000; - diagcons = 3; /* XXX force serial for now */ + ioaddr = MBUS_SLOT_BASE(mbus_ioslot) + FWIO_DZ_REG_OFFSET; + diagcons = 3; + pri = CN_LOWPRI; /* graphics console always wins */ break; #endif @@ -203,7 +207,9 @@ dzcnprobe(cndev) return; } - cndev->cn_pri = diagcons != 0 ? CN_HIGHPRI : CN_LOWPRI; + if (pri == CN_DEAD) + pri = diagcons != 0 ? CN_HIGHPRI : CN_LOWPRI; + cndev->cn_pri = pri; cndev->cn_dev = makedev(major, dz_can_have_kbd() ? 3 : diagcons); dz_console_regs = iospace; ioaccess(iospace, ioaddr, 1); diff --git a/sys/arch/vax/mbus/files.mbus b/sys/arch/vax/mbus/files.mbus index 8b692910545..88d0de15eea 100644 --- a/sys/arch/vax/mbus/files.mbus +++ b/sys/arch/vax/mbus/files.mbus @@ -1,4 +1,4 @@ -# $OpenBSD: files.mbus,v 1.1 2008/08/18 23:19:25 miod Exp $ +# $OpenBSD: files.mbus,v 1.2 2008/08/20 19:00:01 miod Exp $ # VAXstation 3[58][24]0 internal bus device mbus { [mid = -1] } @@ -19,11 +19,15 @@ file arch/vax/mbus/if_le_fwio.c le_fwio attach sii at fwio with sii_fwio file arch/vax/mbus/sii_fwio.c sii_fwio -# L2008 CQBIC +# L2004 LEGSS video +# (with L2005 8-plane output module and optional L2006 16-plane module) +device legss: wsemuldisplaydev, rasops32 +attach legss at mbus +file arch/vax/mbus/legss.c legss needs-flag + +# L2008 FQAM (CQBIC) attach uba at mbus with uba_mbus file arch/vax/mbus/uba_mbus.c uba_mbus # L2001 or L2010 CPU -# L2004 LEGSS video -# (with L2005 8-plane output module and optional L2006 16-plane module) # L2007 memory diff --git a/sys/arch/vax/mbus/legss.c b/sys/arch/vax/mbus/legss.c new file mode 100644 index 00000000000..3b73ce80f33 --- /dev/null +++ b/sys/arch/vax/mbus/legss.c @@ -0,0 +1,428 @@ +/* $OpenBSD: legss.c,v 1.1 2008/08/20 19:00:01 miod Exp $ */ + +/* + * Copyright (c) 2008 Miodrag Vallat. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * LEGSS frame buffer + * + * This beast is different enough from a QDSS or a GPX to need a specific + * driver. Unfortunately, it is not yet known how this hardware works. + * + * The frame buffer memory is accessible linearly in 32 bit words (one + * per pixel, although apparently only 20 bits are writable). + * + * We currently drive the frame buffer as a monochrome, unaccelerated + * display. + * + * Note that the hardware probe is made easier since graphics can only + * exist in the last M-Bus slot, and the terminal information in the SSC + * will tell us whether it is properly populated or not. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +#include + +#include +#include +#include +#include + +/* Graphics can only exist at mid 7 */ +#define MID_GRAPHICS 7 +#define LEGSS_BASE MBUS_SLOT_BASE(MID_GRAPHICS) + +#define LEGSS_VRAM_OFFSET 0x00800000 + +#define LEGSS_VISWIDTH 1280 +#define LEGSS_WIDTH 2048 +#define LEGSS_VISHEIGHT 1024 +#define LEGSS_HEIGHT 2048 + +int legss_match(struct device *, void *, void *); +void legss_attach(struct device *, struct device *, void *); + +struct legss_screen { + struct rasops_info ss_ri; + int ss_console; + u_int ss_depth; + vaddr_t ss_vram; +}; + +/* for console */ +struct legss_screen legss_consscr; + +struct legss_softc { + struct device sc_dev; + struct legss_screen *sc_scr; + int sc_nscreens; +}; + +struct cfattach legss_ca = { + sizeof(struct legss_softc), legss_match, legss_attach, +}; + +struct cfdriver legss_cd = { + NULL, "legss", DV_DULL +}; + +struct wsscreen_descr legss_stdscreen = { + "std", +}; + +const struct wsscreen_descr *_legss_scrlist[] = { + &legss_stdscreen, +}; + +const struct wsscreen_list legss_screenlist = { + sizeof(_legss_scrlist) / sizeof(struct wsscreen_descr *), + _legss_scrlist, +}; + +int legss_ioctl(void *, u_long, caddr_t, int, struct proc *); +paddr_t legss_mmap(void *, off_t, int); +int legss_alloc_screen(void *, const struct wsscreen_descr *, + void **, int *, int *, long *); +void legss_free_screen(void *, void *); +int legss_show_screen(void *, void *, int, + void (*) (void *, int, int), void *); + +const struct wsdisplay_accessops legss_accessops = { + legss_ioctl, + legss_mmap, + legss_alloc_screen, + legss_free_screen, + legss_show_screen, + NULL, /* load_font */ + NULL, /* scrollback */ + NULL, /* getchar */ + NULL /* burner */ +}; + +int legss_setup_screen(struct legss_screen *); +u_int legss_probe_depth(vaddr_t); + +/* + * Autoconf glue + */ + +int +legss_match(struct device *parent, void *vcf, void *aux) +{ + struct mbus_attach_args *maa = (struct mbus_attach_args *)aux; + + if (maa->maa_class == CLASS_GRAPHICS && + maa->maa_interface == INTERFACE_FBIC && + maa->maa_mid == MID_GRAPHICS) + return 1; + + return 0; +} + +void +legss_attach(struct device *parent, struct device *self, void *aux) +{ + struct legss_softc *sc = (struct legss_softc *)self; + struct legss_screen *scr; + struct wsemuldisplaydev_attach_args aa; + int console; + vaddr_t tmp; + extern struct consdev wsdisplay_cons; + + console = (vax_confdata & 0x60) != 0 && cn_tab == &wsdisplay_cons; + if (console) { + scr = &legss_consscr; + sc->sc_nscreens = 1; + } else { + scr = malloc(sizeof(struct legss_screen), M_DEVBUF, M_NOWAIT); + if (scr == NULL) { + printf(": can not allocate memory\n"); + return; + } + + tmp = vax_map_physmem(LEGSS_BASE + LEGSS_VRAM_OFFSET, 1); + if (tmp == 0L) { + printf(": can not probe depth\n"); + goto bad1; + } + scr->ss_depth = legss_probe_depth(tmp); + vax_unmap_physmem(tmp, 1); + + if (scr->ss_depth == 0) { + printf(": unrecognized depth\n"); + goto bad1; + } + + scr->ss_vram = vax_map_physmem(LEGSS_BASE + LEGSS_VRAM_OFFSET, + (LEGSS_VISHEIGHT * LEGSS_WIDTH * 32 / NBBY) / VAX_NBPG); + if (scr->ss_vram == 0L) { + printf(": can not map frame buffer\n"); + goto bad1; + } + + if (legss_setup_screen(scr) != 0) { + printf(": initialization failed\n"); + goto bad2; + } + } + sc->sc_scr = scr; + + printf(": %dx%d %d plane color framebuffer\n", + LEGSS_VISWIDTH, LEGSS_VISHEIGHT, scr->ss_depth); + + aa.console = console; + aa.scrdata = &legss_screenlist; + aa.accessops = &legss_accessops; + aa.accesscookie = sc; + aa.defaultscreens = 0; + + config_found(self, &aa, wsemuldisplaydevprint); + + return; + +bad2: + vax_unmap_physmem(scr->ss_vram, + (LEGSS_VISHEIGHT * LEGSS_WIDTH * 32 / NBBY) / VAX_NBPG); +bad1: + free(scr, M_DEVBUF); +} + +/* + * wsdisplay accessops + */ + +int +legss_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p) +{ + struct legss_softc *sc = v; + struct legss_screen *ss = sc->sc_scr; + struct wsdisplay_fbinfo *wdf; + + switch (cmd) { + case WSDISPLAYIO_GTYPE: + *(u_int *)data = 0; /* XXX WSDISPLAY_TYPE_LEGSS; */ + break; + + case WSDISPLAYIO_GINFO: + wdf = (struct wsdisplay_fbinfo *)data; + wdf->height = ss->ss_ri.ri_height; + wdf->width = ss->ss_ri.ri_width; + wdf->depth = ss->ss_depth; + wdf->cmsize = 0; + break; + + case WSDISPLAYIO_LINEBYTES: + *(u_int *)data = LEGSS_WIDTH * 32 / NBBY; + + case WSDISPLAYIO_GETCMAP: + case WSDISPLAYIO_PUTCMAP: + break; + + case WSDISPLAYIO_GVIDEO: + case WSDISPLAYIO_SVIDEO: + break; + + default: + return -1; + } + + return 0; +} + +paddr_t +legss_mmap(void *v, off_t offset, int prot) +{ + /* Do not allow mmap yet because of the read-only upper 12 bits */ + return -1; +} + +int +legss_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep, + int *curxp, int *curyp, long *defattrp) +{ + struct legss_softc *sc = v; + struct legss_screen *ss = sc->sc_scr; + struct rasops_info *ri = &ss->ss_ri; + + if (sc->sc_nscreens > 0) + return ENOMEM; + + *cookiep = ri; + *curxp = *curyp = 0; + ri->ri_ops.alloc_attr(ri, 0, 0, 0, defattrp); + sc->sc_nscreens++; + + return 0; +} + +void +legss_free_screen(void *v, void *cookie) +{ + struct legss_softc *sc = v; + + sc->sc_nscreens--; +} + +int +legss_show_screen(void *v, void *cookie, int waitok, + void (*cb)(void *, int, int), void *cbarg) +{ + return 0; +} + +int +legss_setup_screen(struct legss_screen *ss) +{ + struct rasops_info *ri = &ss->ss_ri; + + bzero(ri, sizeof(*ri)); + ri->ri_depth = 32; /* masquerade as a 32 bit device for rasops */ + ri->ri_width = LEGSS_VISWIDTH; + ri->ri_height = LEGSS_VISHEIGHT; + ri->ri_stride = LEGSS_WIDTH * 32 / NBBY; + ri->ri_flg = RI_FORCEMONO | RI_CENTER | RI_CLEAR; + ri->ri_hw = ss; + ri->ri_bits = (u_char *)ss->ss_vram; + + /* + * Ask for an unholy big display, rasops will trim this to more + * reasonable values. + */ + if (rasops_init(ri, 160, 160) != 0) + return -1; + + legss_stdscreen.ncols = ri->ri_cols; + legss_stdscreen.nrows = ri->ri_rows; + legss_stdscreen.textops = &ri->ri_ops; + legss_stdscreen.fontwidth = ri->ri_font->fontwidth; + legss_stdscreen.fontheight = ri->ri_font->fontheight; + legss_stdscreen.capabilities = ri->ri_caps; + + return 0; +} + +u_int +legss_probe_depth(vaddr_t vram) +{ + uint32_t probe; + + *(volatile uint32_t *)vram = 0; + *(volatile uint32_t *)vram = 0xffffffff; + probe = *(volatile uint32_t *)vram; + + /* + * Need to mask the upper 12 bits, they don't seem to be connected + * to anything and latch random bus data. + */ + switch (probe & 0x000fffff) { + case 0x00ff: + return 8; + default: + return 0; + } +} + +/* + * Console support code + */ + +int legsscnprobe(void); +int legsscninit(void); + +int +legsscnprobe() +{ + extern vaddr_t virtual_avail; + int depth; + + if (vax_boardtype != VAX_BTYP_60) + return 0; /* move along, nothing there */ + + /* no working graphics hardware, or forced serial console? */ + if ((vax_confdata & 0x60) == 0) + return 0; + + /* + * Check for a recognized color depth. + */ + + ioaccess(virtual_avail, LEGSS_BASE + LEGSS_VRAM_OFFSET, 1); + depth = legss_probe_depth(virtual_avail); + iounaccess(virtual_avail, 1); + + if (depth == 0) + return 0; /* unsupported, default to serial */ + + return 1; +} + +/* + * Called very early to setup the glass tty as console. + * Because it's called before the VM system is initialized, virtual memory + * for the framebuffer can be stolen directly without disturbing anything. + */ +int +legsscninit() +{ + struct legss_screen *ss = &legss_consscr; + extern vaddr_t virtual_avail; + vaddr_t ova; + long defattr; + struct rasops_info *ri; + + ova = virtual_avail; + + ioaccess(virtual_avail, LEGSS_BASE + LEGSS_VRAM_OFFSET, 1); + ss->ss_depth = legss_probe_depth(virtual_avail); + iounaccess(virtual_avail, 1); + if (ss->ss_depth == 0) + return 1; + + ioaccess(virtual_avail, LEGSS_BASE + LEGSS_VRAM_OFFSET, + (LEGSS_VISHEIGHT * LEGSS_WIDTH * 32 / NBBY) / VAX_NBPG); + ss->ss_vram = virtual_avail; + virtual_avail += (LEGSS_VISHEIGHT * LEGSS_WIDTH * 32 / NBBY); + virtual_avail = round_page(virtual_avail); + + /* this had better not fail */ + if (legss_setup_screen(ss) != 0) { + iounaccess(ss->ss_vram, + (LEGSS_VISHEIGHT * LEGSS_WIDTH * 32 / NBBY) / VAX_NBPG); + virtual_avail = ova; + return 1; + } + + ri = &ss->ss_ri; + ri->ri_ops.alloc_attr(ri, 0, 0, 0, &defattr); + wsdisplay_cnattach(&legss_stdscreen, ri, 0, 0, defattr); + + return 0; +} diff --git a/sys/arch/vax/vax/findcpu.c b/sys/arch/vax/vax/findcpu.c index 8b6a76f6d4d..4c5d1dab0bd 100644 --- a/sys/arch/vax/vax/findcpu.c +++ b/sys/arch/vax/vax/findcpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: findcpu.c,v 1.13 2008/08/18 23:19:29 miod Exp $ */ +/* $OpenBSD: findcpu.c,v 1.14 2008/08/20 19:00:01 miod Exp $ */ /* $NetBSD: findcpu.c,v 1.5 1999/08/23 19:10:43 ragge Exp $ */ /* * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden. @@ -38,6 +38,7 @@ #include #include #include +#include /* * We set up some information about the machine we're @@ -46,8 +47,8 @@ * outside of this routine, they should be read only! */ int vax_cputype; /* highest byte of SID register */ -int vax_bustype; /* holds/defines all busses on this machine */ -int vax_boardtype; /* machine dependend, combination of SID and SIE */ +int vax_bustype; /* holds/defines the main bus type on this machine */ +int vax_boardtype; /* machine dependent, combination of SID and SIE */ int vax_cpudata = 0; /* contents of the SID register */ int vax_siedata = 0; /* contents of the SIE register */ @@ -112,6 +113,8 @@ findcpu(void) break; case VAX_BTYP_60: + vax_confdata = + ((struct cvax_ssc *)CVAX_SSC)->ssc_terminfo; vax_bustype = VAX_MBUS; break; @@ -124,7 +127,6 @@ findcpu(void) case VAX_BTYP_1305: vax_bustype = VAX_IBUS; break; - } break; diff --git a/sys/arch/vax/vax/wscons_machdep.c b/sys/arch/vax/vax/wscons_machdep.c index ab24b9c71a3..77308d6a892 100644 --- a/sys/arch/vax/vax/wscons_machdep.c +++ b/sys/arch/vax/vax/wscons_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wscons_machdep.c,v 1.5 2008/08/18 23:04:28 miod Exp $ */ +/* $OpenBSD: wscons_machdep.c,v 1.6 2008/08/20 19:00:01 miod Exp $ */ /* * Copyright (c) 2006 Miodrag Vallat. * @@ -49,6 +49,7 @@ #include "gpx.h" #include "lcg.h" #include "lcspx.h" +#include "legss.h" #include "smg.h" int (*wsfbcninit)(void) = NULL; @@ -68,6 +69,7 @@ do { \ FRAMEBUFFER_PROTOS(gpx); FRAMEBUFFER_PROTOS(lcg); FRAMEBUFFER_PROTOS(lcspx); +FRAMEBUFFER_PROTOS(legss); FRAMEBUFFER_PROTOS(smg); #include @@ -103,6 +105,9 @@ wscnprobe(struct consdev *cp) #if NLCSPX > 0 FRAMEBUFFER_PROBE(lcspx); #endif +#if NLEGSS > 0 + FRAMEBUFFER_PROBE(legss); +#endif #if NSMG > 0 FRAMEBUFFER_PROBE(smg); #endif @@ -127,6 +132,7 @@ wscninit(struct consdev *cp) } switch (vax_bustype) { + case VAX_MBUS: case VAX_VSBUS: #if NDZKBD > 0 dzkbd_cnattach(); -- 2.20.1