Module Name:    src
Committed By:   rin
Date:           Fri Jul 26 10:48:45 UTC 2019

Modified Files:
        src/share/man/man4: genfb.4
        src/sys/arch/mac68k/conf: files.mac68k
        src/sys/arch/mac68k/dev: grf_subr.c grfvar.h maccons.c
        src/sys/arch/mac68k/mac68k: conf.c machdep.c
        src/sys/arch/mac68k/obio: grf_obio.c
        src/sys/dev/rasops: rasops.c
        src/sys/dev/wsfb: files.wsfb
Added Files:
        src/sys/arch/mac68k/conf: WSFB WSFB.common WSFBSBC
        src/sys/arch/mac68k/dev: genfb_grfbus.c
        src/sys/arch/mac68k/obio: grf_obioreg.h

Log Message:
Add genfb(4) driver for mac68k grfbus.
1, 2, 4, 8, 15, and 32 color-depths are supported.

ANSI colors on console are functional for depth >= 4.

Graphic applications based on wsfb API should work, provided
they can correctly handle fbi_fboffset and your color depth.

wsfb driver of Xorg 1.20 and mlterm-fb (framebuffer version of
x11/mlterm) work fine for depth == 1 || depth >= 8.

For depth == 8 (256 colors), graphic applications require
colormap callback, which is currently supported for some
internal graphic adapters, and only Civic (found on Quadra
AV series) was tested. Register definition and its usage are
taken from Linux. You can easily support other adapters if
Linux supports that.

Have fun, and any problem reports are welcomed!


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/share/man/man4/genfb.4
cvs rdiff -u -r0 -r1.1 src/sys/arch/mac68k/conf/WSFB \
    src/sys/arch/mac68k/conf/WSFB.common src/sys/arch/mac68k/conf/WSFBSBC
cvs rdiff -u -r1.128 -r1.129 src/sys/arch/mac68k/conf/files.mac68k
cvs rdiff -u -r0 -r1.1 src/sys/arch/mac68k/dev/genfb_grfbus.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/mac68k/dev/grf_subr.c
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/mac68k/dev/grfvar.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/mac68k/dev/maccons.c
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/mac68k/mac68k/conf.c
cvs rdiff -u -r1.352 -r1.353 src/sys/arch/mac68k/mac68k/machdep.c
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/mac68k/obio/grf_obio.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/mac68k/obio/grf_obioreg.h
cvs rdiff -u -r1.90 -r1.91 src/sys/dev/rasops/rasops.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/wsfb/files.wsfb

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man4/genfb.4
diff -u src/share/man/man4/genfb.4:1.3 src/share/man/man4/genfb.4:1.4
--- src/share/man/man4/genfb.4:1.3	Mon Aug 24 02:25:18 2009
+++ src/share/man/man4/genfb.4	Fri Jul 26 10:48:44 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: genfb.4,v 1.3 2009/08/24 02:25:18 jmcneill Exp $
+.\"	$NetBSD: genfb.4,v 1.4 2019/07/26 10:48:44 rin Exp $
 .\"
 .\" Copyright (c) 2007 Michael Lorenz
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd August 23, 2009
+.Dd July 26, 2019
 .Dt GENFB 4
 .Os
 .Sh NAME
@@ -35,6 +35,8 @@
 .Sh SYNOPSIS
 .Cd "genfb* at pci?"
 .Cd "genfb* at sbus?"
+.Cd "genfb* at intvid?" Pq mac68k
+.Cd "genfb* at macvid?" Pq mac68k
 .Cd "wsdisplay* at genfb?"
 .Sh DESCRIPTION
 The
@@ -65,9 +67,13 @@ Bus address of the framebuffer.
 When attaching to
 .Xr sbus 4
 all those parameters are retrieved from the firmware.
+.Ss mac68k
+All those parameters are configured with Mac OS,
+and retrieved from the boot loader.
 .Sh SEE ALSO
 .Xr pci 4 ,
 .Xr sbus 4 ,
+.Xr mac68k/intro 4 ,
 .Xr wscons 4 ,
 .Xr wsdisplay 4
 .Sh BUGS

Index: src/sys/arch/mac68k/conf/files.mac68k
diff -u src/sys/arch/mac68k/conf/files.mac68k:1.128 src/sys/arch/mac68k/conf/files.mac68k:1.129
--- src/sys/arch/mac68k/conf/files.mac68k:1.128	Mon Feb 18 01:12:23 2019
+++ src/sys/arch/mac68k/conf/files.mac68k	Fri Jul 26 10:48:44 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.mac68k,v 1.128 2019/02/18 01:12:23 thorpej Exp $
+#	$NetBSD: files.mac68k,v 1.129 2019/07/26 10:48:44 rin Exp $
 
 # mac68k-specific configuration info
 
@@ -64,7 +64,10 @@ device	macfb: wsemuldisplaydev, wsraster
 attach	macfb at grfbus
 file	arch/mac68k/dev/macfb.c		macfb needs-flag
 
-file	arch/mac68k/dev/maccons.c	akbd & macfb
+attach	genfb at grfbus with genfb_grfbus
+file	arch/mac68k/dev/genfb_grfbus.c	genfb_grfbus
+
+file	arch/mac68k/dev/maccons.c	akbd & (macfb | genfb_grfbus)
 
 #device	ite: wsemuldisplaydev
 #attach	ite at wsdisplay

Index: src/sys/arch/mac68k/dev/grf_subr.c
diff -u src/sys/arch/mac68k/dev/grf_subr.c:1.21 src/sys/arch/mac68k/dev/grf_subr.c:1.22
--- src/sys/arch/mac68k/dev/grf_subr.c:1.21	Sat Oct 27 17:17:59 2012
+++ src/sys/arch/mac68k/dev/grf_subr.c	Fri Jul 26 10:48:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: grf_subr.c,v 1.21 2012/10/27 17:17:59 chs Exp $	*/
+/*	$NetBSD: grf_subr.c,v 1.22 2019/07/26 10:48:44 rin Exp $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: grf_subr.c,v 1.21 2012/10/27 17:17:59 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: grf_subr.c,v 1.22 2019/07/26 10:48:44 rin Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -64,6 +64,8 @@ grf_establish(struct grfbus_softc *sc, n
 	ga.ga_handle = sc->sc_handle;
 	ga.ga_phys = sc->sc_basepa;
 	ga.ga_mode = g_mode;
+	ga.ga_set_mapreg = sc->sc_set_mapreg;
+	ga.ga_parent = sc;
 	(void)config_found(sc->sc_dev, &ga, grfbusprint);
 }
 

Index: src/sys/arch/mac68k/dev/grfvar.h
diff -u src/sys/arch/mac68k/dev/grfvar.h:1.31 src/sys/arch/mac68k/dev/grfvar.h:1.32
--- src/sys/arch/mac68k/dev/grfvar.h:1.31	Sat Oct 27 17:17:59 2012
+++ src/sys/arch/mac68k/dev/grfvar.h	Fri Jul 26 10:48:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: grfvar.h,v 1.31 2012/10/27 17:17:59 chs Exp $	*/
+/*	$NetBSD: grfvar.h,v 1.32 2019/07/26 10:48:44 rin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -41,6 +41,15 @@
 #define CARD_NAME_LEN	64
 
 /*
+ * Color map, required for DAFB to support genfb(4).
+ */
+struct grfbus_cmap {
+	uint8_t		*red;
+	uint8_t		*green;
+	uint8_t		*blue;
+};
+
+/*
  * State info, per hardware instance.
  */
 struct grfbus_softc {
@@ -60,6 +69,10 @@ struct grfbus_softc {
 					/* for cards where that's suff.	*/
 	u_int32_t	cli_value;	/* Value to write at cli_offset */
 	nubus_dir	board_dir;	/* Nubus dir for curr board	*/
+
+	bus_space_handle_t	sc_cmh;
+	void			(*sc_set_mapreg)(void *, int, int, int, int);
+	struct grfbus_cmap	sc_cmap;
 };
 
 /*
@@ -82,6 +95,8 @@ struct grfbus_attach_args {
 	bus_addr_t	ga_phys;
 	bus_addr_t	ga_fboff;
 	int		(*ga_mode)(struct grf_softc *, int, void *);
+	void		(*ga_set_mapreg)(void *, int, int, int, int);
+	struct grfbus_softc *ga_parent;
 };
 
 typedef	void *(*grf_phys_t)(struct grf_softc *, vaddr_t);

Index: src/sys/arch/mac68k/dev/maccons.c
diff -u src/sys/arch/mac68k/dev/maccons.c:1.9 src/sys/arch/mac68k/dev/maccons.c:1.10
--- src/sys/arch/mac68k/dev/maccons.c:1.9	Wed Oct 17 19:55:13 2007
+++ src/sys/arch/mac68k/dev/maccons.c	Fri Jul 26 10:48:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: maccons.c,v 1.9 2007/10/17 19:55:13 garbled Exp $	*/
+/*	$NetBSD: maccons.c,v 1.10 2019/07/26 10:48:44 rin Exp $	*/
 
 /*
  * Copyright (C) 1999 Scott Reynolds.  All rights reserved.
@@ -27,25 +27,37 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: maccons.c,v 1.9 2007/10/17 19:55:13 garbled Exp $");
+__KERNEL_RCSID(0, "$NetBSD: maccons.c,v 1.10 2019/07/26 10:48:44 rin Exp $");
 
+#include "genfb.h"
+#include "macfb.h"
 #include "wsdisplay.h"
 #include "wskbd.h"
 #include "zsc.h"
 
+#if (NGENFB + NMACFB) > 1
+#error "genfb(4) and macfb(4) cannot be enabled at the same time"
+#endif
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/conf.h>
 
 #include <machine/autoconf.h>
 #include <machine/cpu.h>
-
 #include <machine/video.h>
+
 #include <dev/cons.h>
-#include <dev/wscons/wskbdvar.h>
 #include <dev/wscons/wsdisplayvar.h>
-#include <mac68k/dev/macfbvar.h>
+#include <dev/wscons/wskbdvar.h>
+#if NGENFB > 0
+#include <dev/wsfb/genfbvar.h>
+#endif
+
 #include <mac68k/dev/akbdvar.h>
+#if NMACFB > 0
+#include <mac68k/dev/macfbvar.h>
+#endif
 
 void maccnprobe(struct consdev *);
 void maccninit(struct consdev *);
@@ -84,7 +96,11 @@ maccninit(struct consdev *cp)
 	 * note:  maccons_initted is initialized to (-1).
 	 */
 	if (++maccons_initted > 0) {
+#if NMACFB > 0
 		macfb_cnattach(mac68k_video.mv_phys);
+#elif NGENFB > 0
+		genfb_cnattach();
+#endif
 		akbd_cnattach();
 	}
 }

Index: src/sys/arch/mac68k/mac68k/conf.c
diff -u src/sys/arch/mac68k/mac68k/conf.c:1.63 src/sys/arch/mac68k/mac68k/conf.c:1.64
--- src/sys/arch/mac68k/mac68k/conf.c:1.63	Sun Dec 11 12:18:03 2005
+++ src/sys/arch/mac68k/mac68k/conf.c	Fri Jul 26 10:48:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: conf.c,v 1.63 2005/12/11 12:18:03 christos Exp $	*/
+/*	$NetBSD: conf.c,v 1.64 2019/07/26 10:48:44 rin Exp $	*/
 
 /*
  * Copyright (c) 1990 The Regents of the University of California.
@@ -34,15 +34,17 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: conf.c,v 1.63 2005/12/11 12:18:03 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: conf.c,v 1.64 2019/07/26 10:48:44 rin Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
 #include <dev/cons.h>
 
-#include "zstty.h"
 #include "akbd.h"
+#include "genfb.h"
 #include "macfb.h"
+#include "zstty.h"
+
 #define maccnpollc	nullcnpollc
 cons_decl(mac);
 #define zscnpollc	nullcnpollc
@@ -52,7 +54,7 @@ struct	consdev constab[] = {
 #if NZSTTY > 0
 	cons_init(zs),
 #endif
-#if NAKBD > 0 && NMACFB > 0
+#if NAKBD > 0 && (NMACFB + NGENFB) > 0
 	cons_init(mac),
 #endif
 	{ 0 },

Index: src/sys/arch/mac68k/mac68k/machdep.c
diff -u src/sys/arch/mac68k/mac68k/machdep.c:1.352 src/sys/arch/mac68k/mac68k/machdep.c:1.353
--- src/sys/arch/mac68k/mac68k/machdep.c:1.352	Tue Nov  7 14:56:03 2017
+++ src/sys/arch/mac68k/mac68k/machdep.c	Fri Jul 26 10:48:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.352 2017/11/07 14:56:03 christos Exp $	*/
+/*	$NetBSD: machdep.c,v 1.353 2019/07/26 10:48:44 rin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -74,7 +74,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.352 2017/11/07 14:56:03 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.353 2019/07/26 10:48:44 rin Exp $");
 
 #include "opt_adb.h"
 #include "opt_copy_symtab.h"
@@ -84,6 +84,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include "opt_modular.h"
 #include "opt_compat_netbsd.h"
 #include "akbd.h"
+#include "genfb.h"
 #include "macfb.h"
 #include "zsc.h"
 
@@ -315,7 +316,7 @@ consinit(void)
 		cninit();
 		init = 1;
 	} else {
-#if NAKBD > 0 && NMACFB > 0
+#if NAKBD > 0 && (NMACFB + NGENFB) > 0
 		/*
 		 * XXX  This is an evil hack on top of an evil hack!
 		 *

Index: src/sys/arch/mac68k/obio/grf_obio.c
diff -u src/sys/arch/mac68k/obio/grf_obio.c:1.58 src/sys/arch/mac68k/obio/grf_obio.c:1.59
--- src/sys/arch/mac68k/obio/grf_obio.c:1.58	Sat Oct 27 17:18:00 2012
+++ src/sys/arch/mac68k/obio/grf_obio.c	Fri Jul 26 10:48:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: grf_obio.c,v 1.58 2012/10/27 17:18:00 chs Exp $	*/
+/*	$NetBSD: grf_obio.c,v 1.59 2019/07/26 10:48:44 rin Exp $	*/
 
 /*
  * Copyright (C) 1998 Scott Reynolds
@@ -60,13 +60,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: grf_obio.c,v 1.58 2012/10/27 17:18:00 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: grf_obio.c,v 1.59 2019/07/26 10:48:44 rin Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
 #include <sys/ioctl.h>
+#include <sys/kmem.h>
 #include <sys/file.h>
-#include <sys/malloc.h>
 #include <sys/mman.h>
 #include <sys/proc.h>
 #include <sys/systm.h>
@@ -79,6 +79,7 @@ __KERNEL_RCSID(0, "$NetBSD: grf_obio.c,v
 #include <machine/video.h>
 
 #include <mac68k/nubus/nubus.h>
+#include <mac68k/obio/grf_obioreg.h>
 #include <mac68k/obio/obiovar.h>
 #include <mac68k/dev/grfvar.h>
 
@@ -86,16 +87,14 @@ static int	grfiv_mode(struct grf_softc *
 static int	grfiv_match(device_t, cfdata_t, void *);
 static void	grfiv_attach(device_t, device_t, void *);
 
+static void	dafb_set_mapreg(void *, int, int, int, int);
+static void	civic_set_mapreg(void *, int, int, int, int);
+static void	valkyrie_set_mapreg(void *, int, int, int, int);
+static void	rbv_set_mapreg(void *, int, int, int, int);
+
 CFATTACH_DECL_NEW(intvid, sizeof(struct grfbus_softc),
     grfiv_match, grfiv_attach, NULL, NULL);
 
-#define	DAFB_BASE		0xf9000000
-#define DAFB_CONTROL_BASE	0xf9800000
-#define	CIVIC_BASE		0x50100000
-#define CIVIC_CONTROL_BASE	0x50036000
-#define	VALKYRIE_BASE		0xf9000000
-#define VALKYRIE_CONTROL_BASE	0x50f2a000
-
 static int
 grfiv_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -208,7 +207,7 @@ grfiv_attach(device_t parent, device_t s
 	switch (current_mac_model->class) {
 	case MACH_CLASSQ2:
 		if (current_mac_model->machineid != MACH_MACLC575) {
-			sc->sc_basepa = VALKYRIE_BASE;
+			sc->sc_basepa = VALKYRIE_FB_BASE;
 			length = 0x00100000;		/* 1MB */
 
 			if (sc->sc_basepa <= mac68k_video.mv_phys &&
@@ -223,6 +222,10 @@ grfiv_attach(device_t parent, device_t s
 				length = mac68k_video.mv_len + sc->sc_fbofs;
 			}
 
+			if (bus_space_map(sc->sc_tag, VALKYRIE_CMAP_BASE,
+			    VALKYRIE_CMAP_LEN, 0, &sc->sc_cmh) == 0)
+				sc->sc_set_mapreg = valkyrie_set_mapreg;
+
 			printf(" @ %lx: Valkyrie video subsystem\n",
 			    sc->sc_basepa + sc->sc_fbofs);
 			break;
@@ -237,7 +240,7 @@ grfiv_attach(device_t parent, device_t s
 			return;
 		}
 
-		sc->sc_basepa = DAFB_BASE;
+		sc->sc_basepa = DAFB_FB_BASE;
 		length = 0x00100000;		/* 1MB */
 
 		/* Compute the current frame buffer offset */
@@ -264,6 +267,15 @@ grfiv_attach(device_t parent, device_t s
 		vbase2 = bus_space_read_4(sc->sc_tag, sc->sc_regh, 0x4) & 0xf;
 		sc->sc_fbofs = (vbase1 << 9) | (vbase2 << 5);
 
+		if (bus_space_map(sc->sc_tag, DAFB_CMAP_BASE, DAFB_CMAP_LEN,
+		    0, &sc->sc_cmh) == 0) {
+			uint8_t *buf = kmem_zalloc(256 * 3, KM_SLEEP);
+			sc->sc_cmap.red = buf;
+			sc->sc_cmap.green = buf + 256;
+			sc->sc_cmap.blue = buf + 256 * 2;
+			sc->sc_set_mapreg = dafb_set_mapreg;
+		}
+
 		printf(" @ %lx: DAFB video subsystem, monitor sense %x\n",
 		    sc->sc_basepa + sc->sc_fbofs,
 		    (bus_space_read_4(sc->sc_tag, sc->sc_regh, 0x1c) & 0x7));
@@ -271,7 +283,7 @@ grfiv_attach(device_t parent, device_t s
 		bus_space_unmap(sc->sc_tag, sc->sc_regh, 0x20);
 		break;
 	case MACH_CLASSAV:
-		sc->sc_basepa = CIVIC_BASE;
+		sc->sc_basepa = CIVIC_FB_BASE;
 		length = 0x00200000;		/* 2MB */
 		if (mac68k_video.mv_phys >= sc->sc_basepa &&
 		    mac68k_video.mv_phys < (sc->sc_basepa + length)) {
@@ -282,6 +294,10 @@ grfiv_attach(device_t parent, device_t s
 			length = mac68k_video.mv_len + sc->sc_fbofs;
 		}
 
+		if (bus_space_map(sc->sc_tag, CIVIC_CMAP_BASE, CIVIC_CMAP_LEN,
+		    0, &sc->sc_cmh) == 0)
+			sc->sc_set_mapreg = civic_set_mapreg;
+
 		printf(" @ %lx: CIVIC video subsystem\n",
 		    sc->sc_basepa + sc->sc_fbofs);
 		break;
@@ -291,6 +307,10 @@ grfiv_attach(device_t parent, device_t s
 		sc->sc_fbofs = m68k_page_offset(mac68k_video.mv_phys);
 		length = mac68k_video.mv_len + sc->sc_fbofs;
 
+		if (bus_space_map(sc->sc_tag, RBV_CMAP_BASE, RBV_CMAP_LEN,
+		    0, &sc->sc_cmh) == 0)
+			sc->sc_set_mapreg = rbv_set_mapreg;
+
 		printf(" @ %lx: RBV video subsystem, ",
 		    sc->sc_basepa + sc->sc_fbofs);
 		switch (via2_reg(rMonitor) & RBVMonitorMask) {
@@ -318,6 +338,8 @@ grfiv_attach(device_t parent, device_t s
 		sc->sc_fbofs = m68k_page_offset(mac68k_video.mv_phys);
 		length = mac68k_video.mv_len + sc->sc_fbofs;
 
+		/* XXX setpalette? */
+
 		printf(" @ %lx: On-board video\n",
 		    sc->sc_basepa + sc->sc_fbofs);
 		break;
@@ -368,3 +390,121 @@ grfiv_mode(struct grf_softc *sc, int cmd
 	}
 	return EINVAL;
 }
+
+#define	CHECK_INDEX(index)						\
+	do {								\
+		size_t depth = mac68k_video.mv_depth;			\
+		if (depth == 1 || depth > 8 || (index) >= (1 << depth))	\
+			return;						\
+	} while (0 /* CONSTCOND */)
+
+static void
+dafb_set_mapreg(void *cookie, int index, int r, int g, int b)
+{
+	struct grfbus_softc *sc = (struct grfbus_softc *)cookie;
+	static int last = -2;
+
+	CHECK_INDEX(index);
+
+#define	dafb_write_lut(val)	\
+    bus_space_write_1(sc->sc_tag, sc->sc_cmh, DAFB_CMAP_LUT, val)
+
+	if (index != last + 1) {
+		bus_space_write_4(sc->sc_tag, sc->sc_cmh, DAFB_CMAP_RESET, 0);
+		for (int i = 0; i < index; i++) {
+			dafb_write_lut(sc->sc_cmap.red[i]);
+			dafb_write_lut(sc->sc_cmap.green[i]);
+			dafb_write_lut(sc->sc_cmap.blue[i]);
+		}
+	}
+
+	dafb_write_lut(r);
+	dafb_write_lut(g);
+	dafb_write_lut(b);
+
+	last = index;
+	sc->sc_cmap.red[index] = r;
+	sc->sc_cmap.green[index] = g;
+	sc->sc_cmap.blue[index] = b;
+
+#undef	dafb_write_lut
+
+}
+
+static void
+civic_set_mapreg(void *cookie, int index, int r, int g, int b)
+{
+	struct grfbus_softc *sc = (struct grfbus_softc *)cookie;
+	uint8_t status, junk = 0;
+
+	CHECK_INDEX(index);
+
+#define	civic_read_lut		\
+    bus_space_read_1(sc->sc_tag, sc->sc_cmh, CIVIC_CMAP_LUT)
+#define	civic_write_lut(val)	\
+    bus_space_write_1(sc->sc_tag, sc->sc_cmh, CIVIC_CMAP_LUT, val)
+
+	bus_space_write_1(sc->sc_tag, sc->sc_cmh, CIVIC_CMAP_ADDR, index);
+	status = bus_space_read_1(sc->sc_tag, sc->sc_cmh, CIVIC_CMAP_STATUS2);
+	if (status & 0x08) {
+		junk = civic_read_lut;
+		junk = civic_read_lut;
+		junk = civic_read_lut;
+		junk = civic_read_lut;
+		if (status & 0x0d) {
+			civic_write_lut(0);
+			civic_write_lut(0);
+		}
+	}
+	civic_write_lut(r);
+	civic_write_lut(g);
+	civic_write_lut(b);
+	civic_write_lut(junk);
+
+#undef	civic_read_lut
+#undef	civic_write_lut
+
+}
+
+static void
+valkyrie_set_mapreg(void *cookie, int index, int r, int g, int b)
+{
+	struct grfbus_softc *sc = (struct grfbus_softc *)cookie;
+
+	CHECK_INDEX(index);
+
+#define	valkyrie_write_lut(val)	\
+    bus_space_write_1(sc->sc_tag, sc->sc_cmh, VALKYRIE_CMAP_LUT, val)
+
+	bus_space_write_1(sc->sc_tag, sc->sc_cmh, VALKYRIE_CMAP_ADDR, index);
+	delay(1);
+	valkyrie_write_lut(r);
+	valkyrie_write_lut(g);
+	valkyrie_write_lut(b);
+
+#undef	valkyrie_write_lut
+
+}
+
+static void
+rbv_set_mapreg(void *cookie, int index, int r, int g, int b)
+{
+	struct grfbus_softc *sc = (struct grfbus_softc *)cookie;
+
+	CHECK_INDEX(index);
+
+#define	rbv_write_lut(val)	\
+    bus_space_write_1(sc->sc_tag, sc->sc_cmh, RBV_CMAP_LUT, val)
+
+	index += 256 - (1 << mac68k_video.mv_depth);
+	bus_space_write_1(sc->sc_tag, sc->sc_cmh, RBV_CMAP_CNTL, 0xff);
+	bus_space_write_1(sc->sc_tag, sc->sc_cmh, RBV_CMAP_ADDR, index);
+	rbv_write_lut(r);
+	rbv_write_lut(g);
+	rbv_write_lut(b);
+
+#undef	rbv_write_lut
+
+}
+
+#undef	CHECK_INDEX

Index: src/sys/dev/rasops/rasops.c
diff -u src/sys/dev/rasops/rasops.c:1.90 src/sys/dev/rasops/rasops.c:1.91
--- src/sys/dev/rasops/rasops.c:1.90	Fri Jul 26 05:24:04 2019
+++ src/sys/dev/rasops/rasops.c	Fri Jul 26 10:48:45 2019
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.90 2019/07/26 05:24:04 rin Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.91 2019/07/26 10:48:45 rin Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.90 2019/07/26 05:24:04 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.91 2019/07/26 10:48:45 rin Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -134,6 +134,51 @@ const uint8_t rasops_isgray[16] = {
 	0, 0, 0, 1,
 };
 
+#ifdef RASOPS_APPLE_PALETTE
+/*
+ * Approximate ANSI colormap for legacy Apple color palettes
+ */
+static const uint8_t apple8_devcmap[16] = {
+	0xff,	/* black	0x00, 0x00, 0x00 */
+	0x6b,	/* red		0x99, 0x00, 0x00 */
+	0xc5,	/* green	0x00, 0x99, 0x00 */
+	0x59,	/* yellow	0x99, 0x99, 0x00 */
+	0xd4,	/* blue		0x00, 0x00, 0x99 */
+	0x68,	/* magenta	0x99, 0x00, 0x99 */
+	0xc2,	/* cyan		0x00, 0x99, 0x99 */
+	0x2b,	/* white	0xcc, 0xcc, 0xcc */
+
+	0x56,	/* black	0x99, 0x99, 0x99 */
+	0x23,	/* red		0xff, 0x00, 0x00 */
+	0xb9,	/* green	0x00, 0xff, 0x00 */
+	0x05,	/* yellow	0xff, 0xff, 0x00 */
+	0xd2,	/* blue		0x00, 0x00, 0xff */
+	0x1e,	/* magenta	0xff, 0x00, 0xff */
+	0xb4,	/* cyan		0x00, 0xff, 0xff */
+	0x00,	/* white	0xff, 0xff, 0xff */
+};
+
+static const uint8_t apple4_devcmap[16] = {
+	15,	/* black	*/
+	 3,	/* red		*/
+	 8,	/* green	*/
+	 1,	/* yellow	*/
+	 6,	/* blue		*/
+	 4,	/* magenta	*/
+	 7,	/* cyan		*/
+	12,	/* light grey	*/
+
+	13,	/* medium grey	*/
+	 3,	/* red		*/
+	 8,	/* green	*/
+	 1,	/* yellow	*/
+	 6,	/* blue		*/
+	 4,	/* magenta	*/
+	 7,	/* cyan		*/
+	 0,	/* white	*/
+};
+#endif
+
 /* Generic functions */
 static void	rasops_copyrows(void *, int, int, int);
 static int	rasops_mapchar(void *, int, u_int *);
@@ -429,7 +474,14 @@ rasops_reconfig(struct rasops_info *ri, 
 
 	ri->ri_caps &= ~(WSSCREEN_UNDERLINE | WSSCREEN_HILIT |
 		    WSSCREEN_WSCOLORS | WSSCREEN_REVERSE);
-	if (ri->ri_depth < 8 || (ri->ri_flg & RI_FORCEMONO) != 0) {
+
+	if ((ri->ri_flg & RI_FORCEMONO) != 0 ||
+#ifdef RASOPS_APPLE_PALETTE
+	    ri->ri_depth == 1
+#else
+	    ri->ri_depth < 8
+#endif
+	) {
 		ri->ri_ops.allocattr = rasops_allocattr_mono;
 		ri->ri_caps |= WSSCREEN_UNDERLINE | WSSCREEN_REVERSE;
 	} else {
@@ -792,10 +844,27 @@ rasops_init_devcmap(struct rasops_info *
 		ri->ri_devcmap[15] = -1;
 		return;
 
+#ifdef RASOPS_APPLE_PALETTE
+	case 4:
+		for (i = 0; i < 16; i++) {
+			c = apple4_devcmap[i];
+			ri->ri_devcmap[i] =
+			    (c <<  0) | (c <<  4) | (c <<  8) | (c << 12) |
+			    (c << 16) | (c << 20) | (c << 24) | (c << 28);
+		}
+		return;
+#else
+	/* XXXRO What should we do here? */
+#endif
+
 	case 8:
 		if ((ri->ri_flg & RI_8BIT_IS_RGB) == 0) {
 			for (i = 0; i < 16; i++) {
+#ifdef RASOPS_APPLE_PALETTE
+				c = apple8_devcmap[i];
+#else
 				c = i;
+#endif
 				ri->ri_devcmap[i] =
 				    c | (c << 8) | (c << 16) | (c << 24);
 			}

Index: src/sys/dev/wsfb/files.wsfb
diff -u src/sys/dev/wsfb/files.wsfb:1.10 src/sys/dev/wsfb/files.wsfb:1.11
--- src/sys/dev/wsfb/files.wsfb:1.10	Fri May 31 01:35:56 2019
+++ src/sys/dev/wsfb/files.wsfb	Fri Jul 26 10:48:45 2019
@@ -1,4 +1,4 @@
-# $NetBSD: files.wsfb,v 1.10 2019/05/31 01:35:56 jmcneill Exp $
+# $NetBSD: files.wsfb,v 1.11 2019/07/26 10:48:45 rin Exp $
 
 #
 # wsdisplay framebuffer drivers
@@ -9,7 +9,7 @@ defflag opt_wsfb.h WSFB_FAKE_VGA_FB	# al
 defflag opt_wsfb.h WSFB_ALLOW_OTHERS	# allow to mmap() foreign ranges
 
 # a generic framebuffer console
-define genfb: rasops1, rasops2, rasops8, rasops15, rasops16, rasops24, rasops32, vcons, edid
+define genfb: rasops1, rasops2, rasops4, rasops8, rasops15, rasops16, rasops24, rasops32, vcons, edid
 device genfb: genfb, wsemuldisplaydev, drm, splash
 file	dev/wsfb/genfb.c	genfb	needs-flag
 defflag opt_genfb.h GENFB_DEBUG GENFB_SHADOWFB

Added files:

Index: src/sys/arch/mac68k/conf/WSFB
diff -u /dev/null src/sys/arch/mac68k/conf/WSFB:1.1
--- /dev/null	Fri Jul 26 10:48:45 2019
+++ src/sys/arch/mac68k/conf/WSFB	Fri Jul 26 10:48:44 2019
@@ -0,0 +1,6 @@
+# $NetBSD: WSFB,v 1.1 2019/07/26 10:48:44 rin Exp $
+#
+# GENERIC with wsfb raster console driver enabled
+
+include "arch/mac68k/conf/GENERIC"
+include "arch/mac68k/conf/WSFB.common"
Index: src/sys/arch/mac68k/conf/WSFB.common
diff -u /dev/null src/sys/arch/mac68k/conf/WSFB.common:1.1
--- /dev/null	Fri Jul 26 10:48:45 2019
+++ src/sys/arch/mac68k/conf/WSFB.common	Fri Jul 26 10:48:44 2019
@@ -0,0 +1,27 @@
+# $NetBSD: WSFB.common,v 1.1 2019/07/26 10:48:44 rin Exp $
+
+genfb* at intvid?
+genfb* at macvid?
+wsdisplay* at wsemuldisplaydev?
+
+options RASOPS_APPLE_PALETTE
+
+options WSDISPLAY_DEFAULTSCREENS=1
+options WS_KERNEL_FG=WSCOL_GREEN
+#options WS_KERNEL_BG=WSCOL_BLACK
+
+pseudo-device wsfont
+pseudo-device wsmux
+
+no options WSDISPLAY_COMPAT_ITEFONT
+no options RCONS_2BPP
+no options RCONS_4BPP
+no options RCONS_16BPP
+no options GRF_COMPAT
+
+no macfb* at intvid?
+no macfb* at macvid?
+no wsdisplay* at macfb?
+
+no pseudo-device grf
+no pseudo-device ite
Index: src/sys/arch/mac68k/conf/WSFBSBC
diff -u /dev/null src/sys/arch/mac68k/conf/WSFBSBC:1.1
--- /dev/null	Fri Jul 26 10:48:45 2019
+++ src/sys/arch/mac68k/conf/WSFBSBC	Fri Jul 26 10:48:44 2019
@@ -0,0 +1,6 @@
+# $NetBSD: WSFBSBC,v 1.1 2019/07/26 10:48:44 rin Exp $
+#
+# GENERICSBC with wsfb raster console driver enabled
+
+include "arch/mac68k/conf/GENERICSBC"
+include "arch/mac68k/conf/WSFB.common"

Index: src/sys/arch/mac68k/dev/genfb_grfbus.c
diff -u /dev/null src/sys/arch/mac68k/dev/genfb_grfbus.c:1.1
--- /dev/null	Fri Jul 26 10:48:45 2019
+++ src/sys/arch/mac68k/dev/genfb_grfbus.c	Fri Jul 26 10:48:44 2019
@@ -0,0 +1,257 @@
+/* $NetBSD: genfb_grfbus.c,v 1.1 2019/07/26 10:48:44 rin Exp $ */
+
+/* NetBSD: simplefb.c,v 1.7 2019/01/30 00:55:04 jmcneill Exp */
+/*-
+ * Copyright (c) 2017 Jared McNeill <jmcne...@invisible.ca>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* NetBSD: macfb.c,v 1.20 2012/10/27 17:17:59 chs Exp */
+/*
+ * Copyright (c) 1998 Matt DeBergalis
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Matt DeBergalis
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "opt_wsdisplay_compat.h"
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: genfb_grfbus.c,v 1.1 2019/07/26 10:48:44 rin Exp $");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/systm.h>
+
+#include <machine/cpu.h>
+#include <machine/bus.h>
+
+#include <machine/video.h>
+#include <machine/grfioctl.h>
+#include <mac68k/nubus/nubus.h>
+#include <mac68k/dev/grfvar.h>
+
+#include <dev/wsfb/genfbvar.h>
+
+struct genfb_grfbus_softc {
+	struct genfb_softc sc_gen;
+
+	uint32_t sc_width;
+	uint32_t sc_height;
+	uint8_t  sc_depth;
+	uint16_t sc_stride;
+
+	paddr_t sc_paddr;
+	vaddr_t sc_vaddr;
+
+	void (*sc_set_mapreg)(void *, int, int, int, int);
+	struct grfbus_softc *sc_parent;
+};
+
+static int genfb_grfbus_ioctl(void *, void *, u_long, void *, int, lwp_t *);
+static paddr_t genfb_grfbus_mmap(void *, void *, off_t, int);
+
+static struct genfb_ops gfb_ops = {
+	.genfb_ioctl = genfb_grfbus_ioctl,
+	.genfb_mmap = genfb_grfbus_mmap,
+};
+
+static struct genfb_colormap_callback gfb_cmcb;
+
+static int __unused
+genfb_grfbus_is_console(paddr_t addr)
+{
+
+	if (addr != mac68k_video.mv_phys &&
+	    (addr >= 0xf9000000 && addr <= 0xfeffffff)) {
+		/*
+		 * This is in the NuBus standard slot space range, so we
+		 * may well have to look at 0xFssxxxxx, too.  Mask off the
+		 * slot number and duplicate it in bits 20-23, per IM:V
+		 * pp 459, 463, and IM:VI ch 30 p 17.
+		 * Note:  this is an ugly hack and I wish I knew what
+		 * to do about it.  -- sr
+		 */
+		addr = (paddr_t)(((u_long)addr & 0xff0fffff) |
+		    (((u_long)addr & 0x0f000000) >> 4));
+	}
+	return ((mac68k_machine.serial_console & 0x03) == 0
+	    && (addr == mac68k_video.mv_phys));
+}
+
+static int
+genfb_grfbus_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, lwp_t *l)
+{
+	struct genfb_grfbus_softc * const sc = v;
+#if 0
+	struct wsdisplayio_bus_id *busid;
+#endif
+	struct wsdisplayio_fbinfo *fbi;
+	struct rasops_info *ri;
+	int error;
+
+	switch (cmd) {
+	case WSDISPLAYIO_GTYPE:
+		*(u_int *)data = WSDISPLAY_TYPE_GENFB;
+		return 0;
+#if 0
+	case WSDISPLAYIO_GET_BUSID:
+		busid = data;
+		busid->bus_type = WSDISPLAYIO_BUS_GRFBUS;
+		return 0;
+#endif
+	case WSDISPLAYIO_GET_FBINFO:
+		fbi = data;
+		ri = &sc->sc_gen.vd.active->scr_ri;
+		error = wsdisplayio_get_fbinfo(ri, fbi);
+		if (error == 0) {
+	                /*
+	                 * XXX
+	                 * if the fb isn't page aligned, tell wsfb to skip the
+			 * unaligned part
+			 */
+			fbi->fbi_fboffset = m68k_page_offset(sc->sc_paddr);
+			fbi->fbi_flags |= WSFB_VRAM_IS_RAM;
+		}
+		return error;
+	default:
+		return EPASSTHROUGH;
+	}
+}
+
+static paddr_t
+genfb_grfbus_mmap(void *v, void *vs, off_t off, int prot)
+{
+	struct genfb_grfbus_softc * const sc = v;
+
+	if (off < 0 || off >= m68k_page_offset(sc->sc_paddr) +
+	    sc->sc_gen.sc_fbsize)
+		return -1;
+
+	return m68k_btop(m68k_trunc_page(sc->sc_paddr) + off);
+}
+
+static int
+genfb_grfbus_attach_genfb(struct genfb_grfbus_softc *sc)
+{
+	device_t dev = sc->sc_gen.sc_dev;
+	prop_dictionary_t dict = device_properties(dev);
+	bool is_console;
+
+	prop_dictionary_set_uint32(dict, "width", sc->sc_width);
+	prop_dictionary_set_uint32(dict, "height", sc->sc_height);
+	prop_dictionary_set_uint8(dict, "depth", sc->sc_depth);
+	prop_dictionary_set_uint16(dict, "linebytes", sc->sc_stride);
+
+	prop_dictionary_set_uint32(dict, "address", sc->sc_paddr);
+	prop_dictionary_set_uint64(dict, "virtual_address", sc->sc_vaddr);
+
+	if (sc->sc_set_mapreg != NULL) {
+		gfb_cmcb.gcc_cookie = sc->sc_parent;
+		gfb_cmcb.gcc_set_mapreg = sc->sc_set_mapreg;
+		prop_dictionary_set_uint64(dict, "cmap_callback",
+		    (uint64_t)(uintptr_t)&gfb_cmcb);
+	}
+
+	genfb_init(&sc->sc_gen);
+
+	if (sc->sc_gen.sc_width == 0 || sc->sc_gen.sc_fbsize == 0) {
+		aprint_normal(": disabled\n");
+		return ENXIO;
+	}
+
+	aprint_naive("\n");
+	aprint_normal(": colormap callback %sprovided\n",
+	    sc->sc_set_mapreg != NULL ? "" : "not ");
+
+	is_console = genfb_grfbus_is_console(sc->sc_paddr);
+	if (is_console)
+		aprint_normal_dev(sc->sc_gen.sc_dev,
+		    "switching to framebuffer console\n");
+	prop_dictionary_set_bool(dict, "is_console", is_console);
+
+	genfb_attach(&sc->sc_gen, &gfb_ops);
+
+	return 0;
+}
+
+static int
+genfb_grfbus_match(device_t parent, cfdata_t cf, void *aux)
+{
+
+	return 1;
+}
+
+static void
+genfb_grfbus_attach(device_t parent, device_t self, void *aux)
+{
+	struct genfb_grfbus_softc * const sc = device_private(self);
+	struct grfbus_attach_args *ga = aux;
+	struct grfmode *gm = ga->ga_grfmode;
+
+	sc->sc_gen.sc_dev = self;
+
+	sc->sc_width = gm->width;
+	sc->sc_height = gm->height;
+
+	/*
+	 * XXX: tested on Quadra 840AV
+	 */
+	sc->sc_depth = gm->psize == 16 ? 15 : gm->psize;
+
+	sc->sc_stride = gm->rowbytes;
+	sc->sc_paddr = ga->ga_phys + gm->fboff;
+	sc->sc_vaddr = (vaddr_t)gm->fbbase + gm->fboff;
+	sc->sc_set_mapreg = ga->ga_set_mapreg;
+	sc->sc_parent = ga->ga_parent;
+
+	genfb_grfbus_attach_genfb(sc);
+}
+
+CFATTACH_DECL_NEW(genfb_grfbus, sizeof(struct genfb_grfbus_softc),
+	genfb_grfbus_match, genfb_grfbus_attach, NULL, NULL);

Index: src/sys/arch/mac68k/obio/grf_obioreg.h
diff -u /dev/null src/sys/arch/mac68k/obio/grf_obioreg.h:1.1
--- /dev/null	Fri Jul 26 10:48:45 2019
+++ src/sys/arch/mac68k/obio/grf_obioreg.h	Fri Jul 26 10:48:44 2019
@@ -0,0 +1,106 @@
+/* $NetBSD: grf_obioreg.h,v 1.1 2019/07/26 10:48:44 rin Exp $ */
+
+/* NetBSD: grf_obio.c,v 1.58 2012/10/27 17:18:00 chs Exp */
+/*
+ * Copyright (C) 1998 Scott Reynolds
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * Copyright (c) 1995 Allen Briggs.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by Allen Briggs.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * DAFB framebuffer and register definitions
+ */
+#define	DAFB_FB_BASE		0xf9000000
+
+#define	DAFB_CONTROL_BASE	0xf9800000
+
+#define	DAFB_CMAP_BASE		0xf9800200	/* Taken from Linux */
+#define	DAFB_CMAP_LEN		0x14
+#define	DAFB_CMAP_RESET		0x00
+#define	DAFB_CMAP_LUT		0x13
+
+/*
+ * Civic framebuffer and register definitions
+ */
+#define	CIVIC_FB_BASE		0x50100000
+
+#define	CIVIC_CONTROL_BASE	0x50036000
+
+#define	CIVIC_CMAP_BASE		0x50f30800	/* Taken from Linux */
+#define	CIVIC_CMAP_LEN		0x30
+#define	CIVIC_CMAP_ADDR		0x00
+#define	CIVIC_CMAP_LUT		0x10
+#define	CIVIC_CMAP_STATUS	0x20
+#define	CIVIC_CMAP_VBLADDR	0x28
+#define	CIVIC_CMAP_STATUS2	0x2c
+
+/*
+ * Valkyrie framebuffer and register definitions
+ */
+#define	VALKYRIE_FB_BASE	0xf9000000
+
+#define	VALKYRIE_CONTROL_BASE	0x50f2a000
+
+#define	VALKYRIE_CMAP_BASE	0x50f24000	/* Taken from Linux */
+#define	VALKYRIE_CMAP_LEN	0x8
+#define	VALKYRIE_CMAP_ADDR	0x0
+#define	VALKYRIE_CMAP_LUT	0x4
+
+/*
+ * RBV register definitions
+ */
+#define	DAC_CMAP_BASE		0x50f24000	/* Taken from Linux */
+#define	RBV_CMAP_BASE		DAC_CMAP_BASE
+#define	RBV_CMAP_LEN		0xc
+#define	RBV_CMAP_ADDR		0x0
+#define	RBV_CMAP_LUT		0x4
+#define	RBV_CMAP_CNTL		0x8

Reply via email to