summaryrefslogtreecommitdiff
path: root/sys/arch/mac68k/dev/grf_mv.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/mac68k/dev/grf_mv.c')
-rw-r--r--sys/arch/mac68k/dev/grf_mv.c237
1 files changed, 110 insertions, 127 deletions
diff --git a/sys/arch/mac68k/dev/grf_mv.c b/sys/arch/mac68k/dev/grf_mv.c
index 60538127af1..b5b6e2d425c 100644
--- a/sys/arch/mac68k/dev/grf_mv.c
+++ b/sys/arch/mac68k/dev/grf_mv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grf_mv.c,v 1.28 2006/01/08 20:35:21 miod Exp $ */
+/* $OpenBSD: grf_mv.c,v 1.29 2006/01/09 20:51:48 miod Exp $ */
/* $NetBSD: grf_nubus.c,v 1.62 2001/01/22 20:27:02 briggs Exp $ */
/*
@@ -36,7 +36,6 @@
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/malloc.h>
-#include <sys/mman.h>
#include <sys/proc.h>
#include <sys/systm.h>
@@ -45,43 +44,45 @@
#include <machine/viareg.h>
#include <mac68k/dev/nubus.h>
-#include <mac68k/dev/grfvar.h>
-
-static void load_image_data(caddr_t data, struct image_data *image);
-
-static int grfmv_intr_generic_write1(void *vsc);
-static int grfmv_intr_generic_write4(void *vsc);
-static int grfmv_intr_generic_or4(void *vsc);
-
-static int grfmv_intr_cb264(void *vsc);
-static int grfmv_intr_cb364(void *vsc);
-static int grfmv_intr_cmax(void *vsc);
-static int grfmv_intr_cti(void *vsc);
-static int grfmv_intr_radius(void *vsc);
-static int grfmv_intr_radius24(void *vsc);
-static int grfmv_intr_supermacgfx(void *vsc);
-static int grfmv_intr_lapis(void *vsc);
-static int grfmv_intr_formac(void *vsc);
-static int grfmv_intr_vimage(void *vsc);
-static int grfmv_intr_gvimage(void *vsc);
-static int grfmv_intr_radius_gsc(void *vsc);
-static int grfmv_intr_radius_gx(void *vsc);
-
-static int grfmv_match(struct device *, void *, void *);
-static void grfmv_attach(struct device *, struct device *, void *);
-
-struct cfdriver macvid_cd = {
- NULL, "macvid", DV_DULL
-};
-struct cfattach macvid_ca = {
- sizeof(struct grfbus_softc), grfmv_match, grfmv_attach
+/*
+#include <dev/wscons/wsconsio.h>
+*/
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/rasops/rasops.h>
+#include <mac68k/dev/macfbvar.h>
+
+int macfb_nubus_match(struct device *, void *, void *);
+void macfb_nubus_attach(struct device *, struct device *, void *);
+
+struct cfattach macfb_nubus_ca = {
+ sizeof(struct macfb_softc), macfb_nubus_match, macfb_nubus_attach
};
-static void
-load_image_data(data, image)
- caddr_t data;
- struct image_data *image;
+void load_image_data(caddr_t data, struct image_data *image);
+
+int grfmv_intr_generic_write1(void *vsc);
+int grfmv_intr_generic_write4(void *vsc);
+int grfmv_intr_generic_or4(void *vsc);
+
+int grfmv_intr_cb264(void *vsc);
+int grfmv_intr_cb364(void *vsc);
+int grfmv_intr_cmax(void *vsc);
+int grfmv_intr_cti(void *vsc);
+int grfmv_intr_radius(void *vsc);
+int grfmv_intr_radius24(void *vsc);
+int grfmv_intr_supermacgfx(void *vsc);
+int grfmv_intr_lapis(void *vsc);
+int grfmv_intr_formac(void *vsc);
+int grfmv_intr_vimage(void *vsc);
+int grfmv_intr_gvimage(void *vsc);
+int grfmv_intr_radius_gsc(void *vsc);
+int grfmv_intr_radius_gx(void *vsc);
+
+#define CARD_NAME_LEN 64
+
+void
+load_image_data(caddr_t data, struct image_data *image)
{
bcopy(data , &image->size, 4);
bcopy(data + 4, &image->offset, 4);
@@ -102,22 +103,19 @@ load_image_data(data, image)
bcopy(data + 42, &image->planeBytes, 4);
}
-static int
-grfmv_match(parent, vcf, aux)
- struct device *parent;
- void *vcf;
- void *aux;
+int
+macfb_nubus_match(struct device *parent, void *vcf, void *aux)
{
struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
if (na->category != NUBUS_CATEGORY_DISPLAY)
- return 0;
+ return (0);
if (na->type != NUBUS_TYPE_VIDEO)
- return 0;
+ return (0);
if (na->drsw != NUBUS_DRSW_APPLE)
- return 0;
+ return (0);
/*
* If we've gotten this far, then we're dealing with a real-live
@@ -125,23 +123,20 @@ grfmv_match(parent, vcf, aux)
* determine that this is an active resource??? Dunno. But we'll
* proceed like it is.
*/
-
- return 1;
+ return (1);
}
-static void
-grfmv_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
+void
+macfb_nubus_attach(struct device *parent, struct device *self, void *aux)
{
- struct grfbus_softc *sc = (struct grfbus_softc *)self;
struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
+ struct macfb_softc *sc = (struct macfb_softc *)self;
struct image_data image_store, image;
- struct grfmode gm;
char cardname[CARD_NAME_LEN];
nubus_dirent dirent;
nubus_dir dir, mode_dir, board_dir;
int mode;
+ struct grfmode gm;
bcopy(na->fmt, &sc->sc_slot, sizeof(nubus_slot));
@@ -152,7 +147,7 @@ grfmv_attach(parent, self, aux)
if (bus_space_map(sc->sc_tag, sc->sc_basepa, NBMEMSIZE,
0, &sc->sc_regh)) {
- printf(": grfmv_attach: failed to map slot %d\n", na->slot);
+ printf(": failed to map slot %d\n", na->slot);
return;
}
@@ -160,9 +155,8 @@ grfmv_attach(parent, self, aux)
if (nubus_find_rsrc(sc->sc_tag, sc->sc_regh,
&sc->sc_slot, &dir, na->rsrcid, &dirent) <= 0) {
-bad:
- bus_space_unmap(sc->sc_tag, sc->sc_regh, NBMEMSIZE);
- return;
+ printf(": failed to get board rsrc.\n");
+ goto bad;
}
nubus_get_dir_from_rsrc(&sc->sc_slot, &dirent, &board_dir);
@@ -171,8 +165,10 @@ bad:
&sc->sc_slot, &board_dir, NUBUS_RSRC_TYPE, &dirent) <= 0)
if ((na->rsrcid != 128) ||
(nubus_find_rsrc(sc->sc_tag, sc->sc_regh,
- &sc->sc_slot, &dir, 129, &dirent) <= 0))
+ &sc->sc_slot, &dir, 129, &dirent) <= 0)) {
+ printf(": failed to get board rsrc.\n");
goto bad;
+ }
mode = NUBUS_RSRC_FIRSTMODE;
if (nubus_find_rsrc(sc->sc_tag, sc->sc_regh,
@@ -207,9 +203,8 @@ bad:
gm.fbbase = (caddr_t)(sc->sc_handle.base); /* XXX evil hack */
gm.fboff = image.offset;
- strncpy(cardname, nubus_get_card_name(sc->sc_tag, sc->sc_regh,
- &sc->sc_slot), CARD_NAME_LEN);
- cardname[CARD_NAME_LEN-1] = '\0';
+ strlcpy(cardname, nubus_get_card_name(sc->sc_tag, sc->sc_regh,
+ &sc->sc_slot), sizeof cardname);
printf(": %s\n", cardname);
if (sc->card_id == NUBUS_DRHW_TFB) {
@@ -221,9 +216,11 @@ bad:
*/
if (strncmp(cardname, "Samsung 768", 11) == 0)
sc->card_id = NUBUS_DRHW_SAM768;
+#ifdef DEBUG
else if (strncmp(cardname, "Toby frame", 10) != 0)
printf("%s: This display card pretends to be a TFB!\n",
sc->sc_dev.dv_xname);
+#endif
}
switch (sc->card_id) {
@@ -368,7 +365,11 @@ bad:
}
/* Perform common video attachment. */
- grf_establish(sc, &gm);
+ macfb_attach_common(sc, &gm);
+ return;
+
+bad:
+ bus_space_unmap(sc->sc_tag, sc->sc_regh, NBMEMSIZE);
}
/* Interrupt handlers... */
@@ -378,11 +379,10 @@ bad:
* varies between cards.
*/
/*ARGSUSED*/
-static int
-grfmv_intr_generic_write1(vsc)
- void *vsc;
+int
+grfmv_intr_generic_write1(void *vsc)
{
- struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
+ struct macfb_softc *sc = (struct macfb_softc *)vsc;
bus_space_write_1(sc->sc_tag, sc->sc_regh,
sc->cli_offset, (u_int8_t)sc->cli_value);
@@ -395,11 +395,10 @@ grfmv_intr_generic_write1(vsc)
* varies between cards.
*/
/*ARGSUSED*/
-static int
-grfmv_intr_generic_write4(vsc)
- void *vsc;
+int
+grfmv_intr_generic_write4(void *vsc)
{
- struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
+ struct macfb_softc *sc = (struct macfb_softc *)vsc;
bus_space_write_4(sc->sc_tag, sc->sc_regh,
sc->cli_offset, sc->cli_value);
@@ -412,11 +411,10 @@ grfmv_intr_generic_write4(vsc)
* varies between cards.
*/
/*ARGSUSED*/
-static int
-grfmv_intr_generic_or4(vsc)
- void *vsc;
+int
+grfmv_intr_generic_or4(void *vsc)
{
- struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
+ struct macfb_softc *sc = (struct macfb_softc *)vsc;
unsigned long scratch;
scratch = bus_space_read_4(sc->sc_tag, sc->sc_regh, sc->cli_offset);
@@ -429,11 +427,10 @@ grfmv_intr_generic_or4(vsc)
* Routine to clear interrupts for the Radius PrecisionColor 8xj card.
*/
/*ARGSUSED*/
-static int
-grfmv_intr_radius(vsc)
- void *vsc;
+int
+grfmv_intr_radius(void *vsc)
{
- struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
+ struct macfb_softc *sc = (struct macfb_softc *)vsc;
u_int8_t c;
c = sc->cli_value;
@@ -450,11 +447,10 @@ grfmv_intr_radius(vsc)
* Is this what the 8xj routine is doing, too?
*/
/*ARGSUSED*/
-static int
-grfmv_intr_radius24(vsc)
- void *vsc;
+int
+grfmv_intr_radius24(void *vsc)
{
- struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
+ struct macfb_softc *sc = (struct macfb_softc *)vsc;
u_int8_t c;
c = 0x80 | bus_space_read_1(sc->sc_tag, sc->sc_regh, 0xfffd8);
@@ -474,11 +470,10 @@ grfmv_intr_radius24(vsc)
* Information for this provided by Brad Salai <bsalai@servtech.com>
*/
/*ARGSUSED*/
-static int
-grfmv_intr_cti(vsc)
- void *vsc;
+int
+grfmv_intr_cti(void *vsc)
{
- struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
+ struct macfb_softc *sc = (struct macfb_softc *)vsc;
u_int8_t c;
c = bus_space_read_1(sc->sc_tag, sc->sc_regh, 0x80000);
@@ -490,14 +485,12 @@ grfmv_intr_cti(vsc)
}
/*ARGSUSED*/
-static int
-grfmv_intr_cb264(vsc)
- void *vsc;
+int
+grfmv_intr_cb264(void *vsc)
{
- struct grfbus_softc *sc;
+ struct macfb_softc *sc = (struct macfb_softc *)vsc;
volatile char *slotbase;
- sc = (struct grfbus_softc *)vsc;
slotbase = (volatile char *)(sc->sc_handle.base); /* XXX evil hack */
asm volatile(" movl %0,a0
movl a0@(0xff6028),d0
@@ -545,14 +538,12 @@ grfmv_intr_cb264(vsc)
* significantly simplified. Contributions welcome... :-)
*/
/*ARGSUSED*/
-static int
-grfmv_intr_cb364(vsc)
- void *vsc;
+int
+grfmv_intr_cb364(void *vsc)
{
- struct grfbus_softc *sc;
+ struct macfb_softc *sc = (struct macfb_softc *)vsc;
volatile char *slotbase;
- sc = (struct grfbus_softc *)vsc;
slotbase = (volatile char *)(sc->sc_handle.base); /* XXX evil hack */
asm volatile(" movl %0,a0
movl a0@(0xfe6028),d0
@@ -634,11 +625,10 @@ grfmv_intr_cb364(vsc)
* Interrupt clearing routine for SuperMac GFX card.
*/
/*ARGSUSED*/
-static int
-grfmv_intr_supermacgfx(vsc)
- void *vsc;
+int
+grfmv_intr_supermacgfx(void *vsc)
{
- struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
+ struct macfb_softc *sc = (struct macfb_softc *)vsc;
u_int8_t dummy;
dummy = bus_space_read_1(sc->sc_tag, sc->sc_regh, 0xE70D3);
@@ -649,11 +639,10 @@ grfmv_intr_supermacgfx(vsc)
* Routine to clear interrupts for the Sigma Designs ColorMax card.
*/
/*ARGSUSED*/
-static int
-grfmv_intr_cmax(vsc)
- void *vsc;
+int
+grfmv_intr_cmax(void *vsc)
{
- struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
+ struct macfb_softc *sc = (struct macfb_softc *)vsc;
u_int32_t dummy;
dummy = bus_space_read_4(sc->sc_tag, sc->sc_regh, 0xf501c);
@@ -666,11 +655,10 @@ grfmv_intr_cmax(vsc)
* (for the SE/30).
*/
/*ARGSUSED*/
-static int
-grfmv_intr_lapis(vsc)
- void *vsc;
+int
+grfmv_intr_lapis(void *vsc)
{
- struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
+ struct macfb_softc *sc = (struct macfb_softc *)vsc;
bus_space_write_1(sc->sc_tag, sc->sc_regh, 0xff7000, 0x08);
bus_space_write_1(sc->sc_tag, sc->sc_regh, 0xff7000, 0x0C);
@@ -681,11 +669,10 @@ grfmv_intr_lapis(vsc)
* Routine to clear interrupts for the Formac Color Card II
*/
/*ARGSUSED*/
-static int
-grfmv_intr_formac(vsc)
- void *vsc;
+int
+grfmv_intr_formac(void *vsc)
{
- struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
+ struct macfb_softc *sc = (struct macfb_softc *)vsc;
u_int8_t dummy;
dummy = bus_space_read_1(sc->sc_tag, sc->sc_regh, 0xde80db);
@@ -697,11 +684,10 @@ grfmv_intr_formac(vsc)
* Routine to clear interrupts for the Vimage by Interware Co., Ltd.
*/
/*ARGSUSED*/
-static int
-grfmv_intr_vimage(vsc)
- void *vsc;
+int
+grfmv_intr_vimage(void *vsc)
{
- struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
+ struct macfb_softc *sc = (struct macfb_softc *)vsc;
bus_space_write_1(sc->sc_tag, sc->sc_regh, 0x800000, 0x67);
bus_space_write_1(sc->sc_tag, sc->sc_regh, 0x800000, 0xE7);
@@ -712,11 +698,10 @@ grfmv_intr_vimage(vsc)
* Routine to clear interrupts for the Grand Vimage by Interware Co., Ltd.
*/
/*ARGSUSED*/
-static int
-grfmv_intr_gvimage(vsc)
- void *vsc;
+int
+grfmv_intr_gvimage(void *vsc)
{
- struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
+ struct macfb_softc *sc = (struct macfb_softc *)vsc;
u_int8_t dummy;
dummy = bus_space_read_1(sc->sc_tag, sc->sc_regh, 0xf00000);
@@ -727,11 +712,10 @@ grfmv_intr_gvimage(vsc)
* Routine to clear interrupts for the Radius GS/C
*/
/*ARGSUSED*/
-static int
-grfmv_intr_radius_gsc(vsc)
- void *vsc;
+int
+grfmv_intr_radius_gsc(void *vsc)
{
- struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
+ struct macfb_softc *sc = (struct macfb_softc *)vsc;
u_int8_t dummy;
dummy = bus_space_read_1(sc->sc_tag, sc->sc_regh, 0xfb802);
@@ -743,11 +727,10 @@ grfmv_intr_radius_gsc(vsc)
* Routine to clear interrupts for the Radius GS/C
*/
/*ARGSUSED*/
-static int
-grfmv_intr_radius_gx(vsc)
- void *vsc;
+int
+grfmv_intr_radius_gx(void *vsc)
{
- struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
+ struct macfb_softc *sc = (struct macfb_softc *)vsc;
bus_space_write_1(sc->sc_tag, sc->sc_regh, 0x600000, 0x00);
bus_space_write_1(sc->sc_tag, sc->sc_regh, 0x600000, 0x20);