summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-01-10 21:19:16 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-01-10 21:19:16 +0000
commit90931ba68dcd9cb5fdc814f38c4fc3c97f89e1ac (patch)
tree416e36983c1b3b5a8bbb30e995c0cd17f57d9bcd
parentbbadd263082a662a1159f75df866108784ec5c75 (diff)
Simplify external macfb interfaces, kill an intermediate attachment structure.
-rw-r--r--sys/arch/mac68k/dev/grf_iv.c26
-rw-r--r--sys/arch/mac68k/dev/grf_mv.c29
-rw-r--r--sys/arch/mac68k/dev/macfb.c44
-rw-r--r--sys/arch/mac68k/dev/macfbvar.h16
-rw-r--r--sys/arch/mac68k/mac68k/wscons_machdep.c7
5 files changed, 52 insertions, 70 deletions
diff --git a/sys/arch/mac68k/dev/grf_iv.c b/sys/arch/mac68k/dev/grf_iv.c
index 8aceafea8b2..9cd06066807 100644
--- a/sys/arch/mac68k/dev/grf_iv.c
+++ b/sys/arch/mac68k/dev/grf_iv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grf_iv.c,v 1.34 2006/01/09 20:51:48 miod Exp $ */
+/* $OpenBSD: grf_iv.c,v 1.35 2006/01/10 21:19:14 miod Exp $ */
/* $NetBSD: grf_iv.c,v 1.17 1997/02/20 00:23:27 scottr Exp $ */
/*
@@ -64,6 +64,7 @@
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
+#include <sys/malloc.h>
#include <machine/autoconf.h>
#include <machine/bus.h>
@@ -202,7 +203,7 @@ macfb_obio_attach(struct device *parent, struct device *self, void *aux)
struct macfb_softc *sc = (struct macfb_softc *)self;
u_long base, length;
u_int32_t vbase1, vbase2;
- struct grfmode gm;
+ struct macfb_devconfig *dc;
sc->card_id = 0;
@@ -336,14 +337,19 @@ macfb_obio_attach(struct device *parent, struct device *self, void *aux)
mac68k_vidphys < (sc->sc_basepa + length))
videoaddr = sc->sc_handle.base + sc->sc_fbofs; /* XXX big ol' hack */
- gm.psize = videobitdepth;
- gm.width = videosize & 0xffff;
- gm.height = (videosize >> 16) & 0xffff;
- gm.rowbytes = videorowbytes;
- gm.fbsize = gm.height * gm.rowbytes;
- gm.fbbase = (caddr_t)sc->sc_handle.base; /* XXX yet another hack */
- gm.fboff = sc->sc_fbofs;
+ dc = malloc(sizeof(*dc), M_DEVBUF, M_WAITOK);
+ bzero(dc, sizeof(*dc));
+
+ dc->dc_vaddr = (vaddr_t)sc->sc_handle.base; /* XXX yet another hack */
+ dc->dc_paddr = sc->sc_basepa;
+ dc->dc_offset = sc->sc_fbofs;
+ dc->dc_wid = videosize & 0xffff;
+ dc->dc_ht = (videosize >> 16) & 0xffff;
+ dc->dc_depth = videobitdepth;
+ dc->dc_rowbytes = videorowbytes;
+ dc->dc_size = dc->dc_ht * dc->dc_rowbytes;
+ dc->nscreens = 0;
/* Perform common video attachment. */
- macfb_attach_common(sc, &gm);
+ macfb_attach_common(sc, dc);
}
diff --git a/sys/arch/mac68k/dev/grf_mv.c b/sys/arch/mac68k/dev/grf_mv.c
index b5b6e2d425c..b6473bb7d4d 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.29 2006/01/09 20:51:48 miod Exp $ */
+/* $OpenBSD: grf_mv.c,v 1.30 2006/01/10 21:19:14 miod Exp $ */
/* $NetBSD: grf_nubus.c,v 1.62 2001/01/22 20:27:02 briggs Exp $ */
/*
@@ -45,9 +45,6 @@
#include <mac68k/dev/nubus.h>
-/*
-#include <dev/wscons/wsconsio.h>
-*/
#include <dev/wscons/wsdisplayvar.h>
#include <dev/rasops/rasops.h>
#include <mac68k/dev/macfbvar.h>
@@ -136,7 +133,7 @@ macfb_nubus_attach(struct device *parent, struct device *self, void *aux)
nubus_dirent dirent;
nubus_dir dir, mode_dir, board_dir;
int mode;
- struct grfmode gm;
+ struct macfb_devconfig *dc;
bcopy(na->fmt, &sc->sc_slot, sizeof(nubus_slot));
@@ -195,13 +192,19 @@ macfb_nubus_attach(struct device *parent, struct device *self, void *aux)
load_image_data((caddr_t)&image_store, &image);
- gm.psize = image.pixelSize;
- gm.width = image.right - image.left;
- gm.height = image.bottom - image.top;
- gm.rowbytes = image.rowbytes;
- gm.fbsize = gm.height * gm.rowbytes;
- gm.fbbase = (caddr_t)(sc->sc_handle.base); /* XXX evil hack */
- gm.fboff = image.offset;
+ dc = malloc(sizeof(*dc), M_DEVBUF, M_WAITOK);
+ bzero(dc, sizeof(*dc));
+
+ dc->dc_vaddr = (vaddr_t)sc->sc_handle.base; /* XXX evil hack */
+ dc->dc_paddr = sc->sc_basepa;
+ dc->dc_offset = image.offset;
+ dc->dc_wid = image.right - image.left;
+ dc->dc_ht = image.bottom - image.top;
+ dc->dc_depth = image.pixelSize;
+ dc->dc_rowbytes = image.rowbytes;
+ dc->dc_size = dc->dc_ht * dc->dc_rowbytes;
+
+ /* Perform common video attachment. */
strlcpy(cardname, nubus_get_card_name(sc->sc_tag, sc->sc_regh,
&sc->sc_slot), sizeof cardname);
@@ -365,7 +368,7 @@ macfb_nubus_attach(struct device *parent, struct device *self, void *aux)
}
/* Perform common video attachment. */
- macfb_attach_common(sc, &gm);
+ macfb_attach_common(sc, dc);
return;
bad:
diff --git a/sys/arch/mac68k/dev/macfb.c b/sys/arch/mac68k/dev/macfb.c
index ecd49508841..53bae5db404 100644
--- a/sys/arch/mac68k/dev/macfb.c
+++ b/sys/arch/mac68k/dev/macfb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: macfb.c,v 1.7 2006/01/09 21:52:12 miod Exp $ */
+/* $OpenBSD: macfb.c,v 1.8 2006/01/10 21:19:14 miod Exp $ */
/* $NetBSD: macfb.c,v 1.11 2005/01/15 16:00:59 chs Exp $ */
/*
* Copyright (c) 1998 Matt DeBergalis
@@ -202,7 +202,7 @@ macfb_alloc_attr(void *cookie, int fg, int bg, int flg, long *attr)
}
void
-macfb_attach_common(struct macfb_softc *sc, struct grfmode *gm)
+macfb_attach_common(struct macfb_softc *sc, struct macfb_devconfig *dc)
{
struct wsemuldisplaydev_attach_args waa;
struct wsscreen_descr *scrlist[1];
@@ -210,38 +210,26 @@ macfb_attach_common(struct macfb_softc *sc, struct grfmode *gm)
int isconsole;
/* Print hardware characteristics. */
- printf("%s: %dx%d ", sc->sc_dev.dv_xname, gm->width, gm->height);
- if (gm->psize == 1)
+ printf("%s: %dx%d ", sc->sc_dev.dv_xname, dc->dc_wid, dc->dc_ht);
+ if (dc->dc_depth == 1)
printf("monochrome");
else
- printf("%d color", 1 << gm->psize);
+ printf("%d color", 1 << dc->dc_depth);
printf(" display\n");
- isconsole = macfb_is_console(sc->sc_basepa + gm->fboff);
+ isconsole = macfb_is_console(sc->sc_basepa + dc->dc_offset);
if (isconsole) {
- sc->sc_dc = &macfb_console_dc;
- sc->sc_dc->nscreens = 1;
+ free(dc, M_DEVBUF);
+ dc = sc->sc_dc = &macfb_console_dc;
+ dc->nscreens = 1;
} else {
- sc->sc_dc = malloc(sizeof(struct macfb_devconfig),
- M_DEVBUF, M_WAITOK);
- sc->sc_dc->dc_vaddr = (vaddr_t)gm->fbbase;
- sc->sc_dc->dc_paddr = sc->sc_basepa;
- sc->sc_dc->dc_size = gm->fbsize;
-
- sc->sc_dc->dc_wid = gm->width;
- sc->sc_dc->dc_ht = gm->height;
- sc->sc_dc->dc_depth = gm->psize;
- sc->sc_dc->dc_rowbytes = gm->rowbytes;
-
- sc->sc_dc->dc_offset = gm->fboff;
- sc->sc_dc->nscreens = 0;
-
- if (macfb_init(sc->sc_dc) != 0)
+ sc->sc_dc = dc;
+ if (macfb_init(dc) != 0)
return;
}
- scrlist[0] = &sc->sc_dc->wsd;
+ scrlist[0] = &dc->wsd;
screenlist.nscreens = 1;
screenlist.screens = (const struct wsscreen_descr **)scrlist;
@@ -343,7 +331,7 @@ macfb_show_screen(void *v, void *cookie, int waitok,
}
int
-macfb_cnattach(paddr_t addr)
+macfb_cnattach()
{
struct macfb_devconfig *dc = &macfb_console_dc;
long defattr;
@@ -351,15 +339,13 @@ macfb_cnattach(paddr_t addr)
dc->dc_vaddr = trunc_page(videoaddr);
dc->dc_paddr = trunc_page(mac68k_vidphys);
-
+ dc->dc_offset = m68k_page_offset(mac68k_vidphys);
dc->dc_wid = videosize & 0xffff;
dc->dc_ht = (videosize >> 16) & 0xffff;
dc->dc_depth = videobitdepth;
dc->dc_rowbytes = videorowbytes;
-
dc->dc_size = (mac68k_vidlen > 0) ?
mac68k_vidlen : dc->dc_ht * dc->dc_rowbytes;
- dc->dc_offset = m68k_page_offset(mac68k_vidphys);
/* set up the display */
if (macfb_init(dc) != 0)
@@ -376,6 +362,6 @@ macfb_cnattach(paddr_t addr)
wsdisplay_cnattach(&dc->wsd, ri, 0, 0, defattr);
- macfb_consaddr = addr;
+ macfb_consaddr = mac68k_vidphys;
return (0);
}
diff --git a/sys/arch/mac68k/dev/macfbvar.h b/sys/arch/mac68k/dev/macfbvar.h
index 6589a7bce5c..6a83cb31f87 100644
--- a/sys/arch/mac68k/dev/macfbvar.h
+++ b/sys/arch/mac68k/dev/macfbvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: macfbvar.h,v 1.3 2006/01/09 20:51:48 miod Exp $ */
+/* $OpenBSD: macfbvar.h,v 1.4 2006/01/10 21:19:14 miod Exp $ */
/* $NetBSD: macfbvar.h,v 1.3 2005/01/15 16:00:59 chs Exp $ */
/* $NetBSD: grfvar.h,v 1.11 1996/08/04 06:03:58 scottr Exp $ */
/* $NetBSD: grfioctl.h,v 1.5 1995/07/02 05:26:45 briggs Exp $ */
@@ -99,16 +99,6 @@ struct image_data {
#define VID_PAGE_CNT 3
#define VID_DEV_TYPE 4
-struct grfmode {
- caddr_t fbbase; /* Base of page of frame buffer */
- u_int32_t fbsize; /* Size of frame buffer */
- u_int16_t fboff; /* Offset of frame buffer from base */
- u_int16_t rowbytes; /* Screen rowbytes */
- u_int16_t width; /* Screen width */
- u_int16_t height; /* Screen height */
- u_int16_t psize; /* Screen depth */
-};
-
struct macfb_devconfig {
vaddr_t dc_vaddr; /* memory space virtual base address */
paddr_t dc_paddr; /* memory space physical base address */
@@ -149,5 +139,5 @@ struct macfb_softc {
struct macfb_devconfig *sc_dc;
};
-void macfb_attach_common(struct macfb_softc *, struct grfmode *);
-int macfb_cnattach(paddr_t);
+void macfb_attach_common(struct macfb_softc *, struct macfb_devconfig *);
+int macfb_cnattach(void);
diff --git a/sys/arch/mac68k/mac68k/wscons_machdep.c b/sys/arch/mac68k/mac68k/wscons_machdep.c
index 4d7788a7812..263c1bb1ff6 100644
--- a/sys/arch/mac68k/mac68k/wscons_machdep.c
+++ b/sys/arch/mac68k/mac68k/wscons_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wscons_machdep.c,v 1.3 2006/01/09 20:51:49 miod Exp $ */
+/* $OpenBSD: wscons_machdep.c,v 1.4 2006/01/10 21:19:15 miod Exp $ */
/* $NetBSD: maccons.c,v 1.5 2005/01/15 16:00:59 chs Exp $ */
/*
@@ -54,9 +54,6 @@ cons_decl(ws);
int maccons_initted = (-1);
-/* From Booter via locore */
-extern u_int32_t mac68k_vidphys;
-
void
wscnprobe(struct consdev *cp)
{
@@ -88,7 +85,7 @@ wscninit(struct consdev *cp)
* note: maccons_initted is initialized to (-1).
*/
if (++maccons_initted > 0) {
- macfb_cnattach(mac68k_vidphys);
+ macfb_cnattach();
akbd_cnattach();
}
}