Port-sparc archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Panic at boot on 4/330 with cgfour and cgsix
tokenalt@ wrote:
> So bad news. After getting the video to work I have found the keyboard
> doesn't work. At least not for the console, it does work for the
> kernel debugger however each character is echoed twice. You can
> actually see that in the video I linked in my first email. I tested
> the 10.0 kernel which only has the bwtwo driver and the keyboard
> doesn't work on it either. I will try older kernels later but in the
> meantime here is a dmesg with a working cgfour and not working
> keyboard.
The problem is currently there is no MI wsdisplay(9) support
for cgfour(4), as commented in sparc/conf/GENERIC.
IIRC the Sun PROM uses the overlay bwtwo plane for putchar on console
even if cgfour is selected as a console (at least seen on my sun3x).
On NetBSD, currently bwtwo(4) has wsdisplay support but cgfour(4)
doesn't, so console settings are not handled properly, as seen
in your dmesg that only "wsdisplay1 at bwtwo" is attached.
AFAIK cgfour(4) is a simple 8 bpp dumb framebuffer, so it should
be trivial to add wsdisplay(9) support with MI rasops(9).
How about the following changes, mostly just taken from cgthree(4)?
https://github.com/tsutsui/netbsd-src/compare/trunk...tsutsui:netbsd-src:sparc-cgfour-wscons
---
diff --git a/sys/arch/sparc/conf/GENERIC b/sys/arch/sparc/conf/GENERIC
index 2b888bf14f70..b2cd04038bc5 100644
--- a/sys/arch/sparc/conf/GENERIC
+++ b/sys/arch/sparc/conf/GENERIC
@@ -632,9 +632,8 @@ cgthree* at sbus? slot ? offset ?
## Sun "cgfour" color framebuffer with overlay plane. See above comment
## regarding overlay plane.
-# XXX no wsdisplay support
-#cgfour0 at obio0 addr 0xfb300000 level 4 # sun4/300 P4
-#cgfour0 at obio0 addr 0x0b300000 level 4 # sun4/100 P4
+cgfour0 at obio0 addr 0xfb300000 level 4 # sun4/300 P4
+cgfour0 at obio0 addr 0x0b300000 level 4 # sun4/100 P4
## Sun "cgsix" accelerated color framebuffer.
cgsix0 at sbus? slot ? offset ?
diff --git a/sys/arch/sparc/conf/files.sparc b/sys/arch/sparc/conf/files.sparc
index 8d2f1442505b..6f1dd802d60f 100644
--- a/sys/arch/sparc/conf/files.sparc
+++ b/sys/arch/sparc/conf/files.sparc
@@ -245,7 +245,7 @@ device cgtwo: fb, rasops8
attach cgtwo at vme
file arch/sparc/dev/cgtwo.c cgtwo needs-flag
-device cgfour: bt_dac, fb, rasops8, pfour
+device cgfour: bt_dac, fb, pfour, rasops8, wsemuldisplaydev, vcons
attach cgfour at obio
file arch/sparc/dev/cgfour.c cgfour needs-flag
diff --git a/sys/arch/sparc/dev/cgfour.c b/sys/arch/sparc/dev/cgfour.c
index 857df460372b..28a0207619c0 100644
--- a/sys/arch/sparc/dev/cgfour.c
+++ b/sys/arch/sparc/dev/cgfour.c
@@ -101,6 +101,8 @@
* XXX should defer colormap updates to vertical retrace interrupts
*/
+#include "wsdisplay.h"
+
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cgfour.c,v 1.51 2023/12/20 05:33:18 thorpej Exp $");
@@ -122,6 +124,15 @@ __KERNEL_RCSID(0, "$NetBSD: cgfour.c,v 1.51 2023/12/20 05:33:18 thorpej Exp $");
#include <dev/sun/btvar.h>
#include <dev/sun/pfourreg.h>
+#if NWSDISPLAY > 0
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsdisplay_vconsvar.h>
+#include <dev/wsfont/wsfont.h>
+#include <dev/rasops/rasops.h>
+
+#include "opt_wsemul.h"
+#endif
+
/* per-display variables */
struct cgfour_softc {
struct fbdevice sc_fb; /* frame buffer device */
@@ -129,6 +140,13 @@ struct cgfour_softc {
bus_addr_t sc_paddr; /* phys address for device mmap() */
volatile struct fbcontrol *sc_fbc; /* Brooktree registers */
+#if NWSDISPLAY > 0
+ uint32_t sc_width;
+ uint32_t sc_height; /* display width / height */
+ uint32_t sc_stride;
+ int sc_mode;
+ struct vcons_data sc_vd;
+#endif
union bt_cmap sc_cmap; /* Brooktree color map */
};
@@ -178,6 +196,44 @@ static int cgfour_get_video(struct cgfour_softc *);
static void cgfour_set_video(struct cgfour_softc *, int);
#endif
+#if NWSDISPLAY > 0
+static void cgfour_setup_palette(struct cgfour_softc *);
+
+static struct wsscreen_descr cgfour_defaultscreen = {
+ .name = "std",
+ /* all other members will be filled by rasops */
+};
+
+static int cgfour_ioctl(void *, void *, u_long, void *, int, struct lwp *);
+static paddr_t cgfour_mmap(void *, void *, off_t, int);
+static void cgfour_init_screen(void *, struct vcons_screen *, int, long *);
+
+static int cgfour_putcmap(struct cgfour_softc *, struct wsdisplay_cmap *);
+static int cgfour_getcmap(struct cgfour_softc *, struct wsdisplay_cmap *);
+
+static struct wsdisplay_accessops cgfour_accessops = {
+ .ioctl = cgfour_ioctl,
+ .mmap = cgfour_mmap,
+ .alloc_screen = NULL,
+ .free_screen = NULL,
+ .show_screen = NULL,
+ .load_font = NULL,
+ .pollc = NULL,
+ .scroll = NULL
+};
+
+static const struct wsscreen_descr *_cgfour_scrlist[] = {
+ &cgfour_defaultscreen
+};
+
+static struct wsscreen_list cgfour_screenlist = {
+ .nscreens = sizeof(_cgfour_scrlist) / sizeof(struct wsscreen_descr *),
+ .screens = _cgfour_scrlist
+};
+
+static struct vcons_screen cgfour_console_screen;
+#endif
+
/*
* Match a cgfour.
*/
@@ -219,6 +275,12 @@ cgfourattach(device_t parent, device_t self, void *aux)
volatile struct bt_regs *bt;
struct fbdevice *fb = &sc->sc_fb;
int ramsize, i, isconsole;
+ paddr_t cmap_pa;
+#if NWSDISPLAY > 0
+ struct wsemuldisplaydev_attach_args wsemul_aa;
+ struct rasops_info *ri = &cgfour_console_screen.scr_ri;
+ unsigned long defattr;
+#endif
sc->sc_bustag = oba->oba_bustag;
sc->sc_paddr = (bus_addr_t)oba->oba_paddr;
@@ -287,8 +349,10 @@ cgfourattach(device_t parent, device_t self, void *aux)
#endif
/* Map the Brooktree. */
+ /* XXX: PFOUR_COLOR_OFF_CMAP assumes 32 bit wraparound */
+ cmap_pa = (paddr_t)oba->oba_paddr + (paddr_t)PFOUR_COLOR_OFF_CMAP;
if (bus_space_map(oba->oba_bustag,
- oba->oba_paddr + PFOUR_COLOR_OFF_CMAP,
+ cmap_pa,
sizeof(struct fbcontrol),
BUS_SPACE_MAP_LINEAR,
&bh) != 0) {
@@ -321,6 +385,50 @@ cgfourattach(device_t parent, device_t self, void *aux)
* to notice if we're the console framebuffer.
*/
fb_attach(fb, isconsole);
+
+#if NWSDISPLAY > 0
+ sc->sc_width = fb->fb_type.fb_width;
+ sc->sc_stride = fb->fb_type.fb_width;
+ sc->sc_height = fb->fb_type.fb_height;
+
+ /* setup rasops and so on for wsdisplay */
+ sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
+
+ vcons_init(&sc->sc_vd, sc, &cgfour_defaultscreen, &cgfour_accessops);
+ sc->sc_vd.init_screen = cgfour_init_screen;
+
+ if (isconsole) {
+ /* we mess with cgfour_console_screen only once */
+ vcons_init_screen(&sc->sc_vd, &cgfour_console_screen, 1,
+ &defattr);
+ memset(sc->sc_fb.fb_pixels, (defattr >> 16) & 0xff,
+ sc->sc_stride * sc->sc_height);
+ cgfour_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
+
+ cgfour_defaultscreen.textops = &ri->ri_ops;
+ cgfour_defaultscreen.capabilities = ri->ri_caps;
+ cgfour_defaultscreen.nrows = ri->ri_rows;
+ cgfour_defaultscreen.ncols = ri->ri_cols;
+ sc->sc_vd.active = &cgfour_console_screen;
+ wsdisplay_cnattach(&cgfour_defaultscreen, ri, 0, 0, defattr);
+ vcons_replay_msgbuf(&cgfour_console_screen);
+ } else {
+ /*
+ * we're not the console so we just clear the screen and don't
+ * set up any sort of text display
+ */
+ }
+
+ /* Initialize the default color map. */
+ cgfour_setup_palette(sc);
+
+ wsemul_aa.scrdata = &cgfour_screenlist;
+ wsemul_aa.console = isconsole;
+ wsemul_aa.accessops = &cgfour_accessops;
+ wsemul_aa.accesscookie = &sc->sc_vd;
+ config_found(self, &wsemul_aa, wsemuldisplaydevprint,
+ CFARGS_NONE);
+#endif /* NWSDISPLAY > 0 */
#endif /* SUN4 */
}
@@ -503,4 +611,181 @@ cgfourloadcmap(struct cgfour_softc *sc, int start, int ncolors)
bt->bt_cmap = i << 24;
}
}
+
+#if NWSDISPLAY > 0
+static void
+cgfour_setup_palette(struct cgfour_softc *sc)
+{
+ int i, j;
+
+ j = 0;
+ for (i = 0; i < 256; i++) {
+ sc->sc_cmap.cm_map[i][0] = rasops_cmap[j];
+ j++;
+ sc->sc_cmap.cm_map[i][1] = rasops_cmap[j];
+ j++;
+ sc->sc_cmap.cm_map[i][2] = rasops_cmap[j];
+ j++;
+ }
+ cgfourloadcmap(sc, 0, 256);
+}
+
+static int
+cgfour_ioctl(void *v, void *vs, u_long cmd, void *data, int flag,
+ struct lwp *l)
+{
+ /* we'll probably need to add more stuff here */
+ struct vcons_data *vd = v;
+ struct cgfour_softc *sc = vd->cookie;
+ struct wsdisplay_fbinfo *wdf;
+ struct vcons_screen *ms = sc->sc_vd.active;
+ struct rasops_info *ri = &ms->scr_ri;
+ switch (cmd) {
+ case WSDISPLAYIO_GTYPE:
+ *(u_int *)data = WSDISPLAY_TYPE_SUNTCX; /* XXX */
+ return 0;
+ case WSDISPLAYIO_GINFO:
+ wdf = (void *)data;
+ wdf->height = ri->ri_height;
+ wdf->width = ri->ri_width;
+ wdf->depth = 8;
+ wdf->cmsize = 256;
+ return 0;
+
+ case WSDISPLAYIO_GETCMAP:
+ return cgfour_getcmap(sc,
+ (struct wsdisplay_cmap *)data);
+ case WSDISPLAYIO_PUTCMAP:
+ return cgfour_putcmap(sc,
+ (struct wsdisplay_cmap *)data);
+
+ case WSDISPLAYIO_SMODE:
+ {
+ int new_mode = *(int *)data;
+
+ if (new_mode != sc->sc_mode) {
+ sc->sc_mode = new_mode;
+ if (new_mode == WSDISPLAYIO_MODE_EMUL) {
+ cgfour_setup_palette(sc);
+ vcons_redraw_screen(ms);
+ }
+ }
+ }
+ return 0;
+ case WSDISPLAYIO_GET_FBINFO:
+ {
+ struct wsdisplayio_fbinfo *fbi = data;
+
+ return wsdisplayio_get_fbinfo(&ms->scr_ri, fbi);
+ }
+ }
+ return EPASSTHROUGH;
+}
+
+static paddr_t
+cgfour_mmap(void *v, void *vs, off_t offset, int prot)
+{
+ struct vcons_data *vd = v;
+ struct cgfour_softc *sc = vd->cookie;
+ paddr_t cookie = -1;
+
+ switch (sc->sc_mode) {
+ case WSDISPLAYIO_MODE_DUMBFB:
+ if (offset >= 0 && offset >= sc->sc_fb.fb_type.fb_size) {
+ cookie = bus_space_mmap(sc->sc_bustag,
+ sc->sc_paddr, PFOUR_COLOR_OFF_COLOR + offset,
+ prot, BUS_SPACE_MAP_LINEAR);
+ }
+ break;
+ default:
+ break;
+ }
+
+ return cookie;
+}
+
+static int
+cgfour_putcmap(struct cgfour_softc *sc, struct wsdisplay_cmap *cm)
+{
+ u_int index = cm->index;
+ u_int count = cm->count;
+ int error,i;
+ if (index >= 256 || count > 256 || index + count > 256)
+ return EINVAL;
+
+ for (i = 0; i < count; i++)
+ {
+ error = copyin(&cm->red[i],
+ &sc->sc_cmap.cm_map[index + i][0], 1);
+ if (error)
+ return error;
+ error = copyin(&cm->green[i],
+ &sc->sc_cmap.cm_map[index + i][1],
+ 1);
+ if (error)
+ return error;
+ error = copyin(&cm->blue[i],
+ &sc->sc_cmap.cm_map[index + i][2], 1);
+ if (error)
+ return error;
+ }
+ cgfourloadcmap(sc, index, count);
+
+ return 0;
+}
+
+static int
+cgfour_getcmap(struct cgfour_softc *sc, struct wsdisplay_cmap *cm)
+{
+ u_int index = cm->index;
+ u_int count = cm->count;
+ int error,i;
+
+ if (index >= 256 || count > 256 || index + count > 256)
+ return EINVAL;
+
+ for (i = 0; i < count; i++)
+ {
+ error = copyout(&sc->sc_cmap.cm_map[index + i][0],
+ &cm->red[i], 1);
+ if (error)
+ return error;
+ error = copyout(&sc->sc_cmap.cm_map[index + i][1],
+ &cm->green[i], 1);
+ if (error)
+ return error;
+ error = copyout(&sc->sc_cmap.cm_map[index + i][2],
+ &cm->blue[i], 1);
+ if (error)
+ return error;
+ }
+
+ return 0;
+}
+
+static void
+cgfour_init_screen(void *cookie, struct vcons_screen *scr,
+ int existing, long *defattr)
+{
+ struct cgfour_softc *sc = cookie;
+ struct rasops_info *ri = &scr->scr_ri;
+
+ scr->scr_flags |= VCONS_DONT_READ;
+
+ ri->ri_depth = 8;
+ ri->ri_width = sc->sc_width;
+ ri->ri_height = sc->sc_height;
+ ri->ri_stride = sc->sc_stride;
+ ri->ri_flg = RI_CENTER;
+
+ ri->ri_bits = sc->sc_fb.fb_pixels;
+
+ rasops_init(ri, 0, 0);
+ ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_REVERSE;
+ rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight,
+ sc->sc_width / ri->ri_font->fontwidth);
+
+ ri->ri_hw = scr;
+}
+#endif /* NWSDISPLAY > 0 */
#endif /* SUN4 */
diff --git a/sys/dev/sun/fb.c b/sys/dev/sun/fb.c
index 76942d37e68c..1c86dc42b910 100644
--- a/sys/dev/sun/fb.c
+++ b/sys/dev/sun/fb.c
@@ -180,9 +180,9 @@ fb_attach(struct fbdevice *fb, int isconsole)
fbl->fb_next = NULL;
aprint_normal_dev(fbl->fb_dev->fb_device,
"moved to /dev/fb%d\n", nfb);
- aprint_normal_dev(fbl->fb_dev->fb_device,
- "attached to /dev/fb0\n");
fblist.fb_dev = fb;
+ aprint_normal_dev(fblist.fb_dev->fb_device,
+ "attached to /dev/fb0\n");
if (fb->fb_flags & FB_FORCE)
seen_force = 1;
/* Add to end of fb list. */
---
Izumi Tsutsui
Home |
Main Index |
Thread Index |
Old Index