diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-12-03 16:38:14 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-12-03 16:38:14 +0000 |
commit | e80be550edadedd59814b011a900b1b84a8688b0 (patch) | |
tree | 9ad0302eade7154e1b1c465ce93dd0617924845f /sys/arch/sparc | |
parent | d9b4d3e5f6d68ef92222ca3f4b1771d00ac04799 (diff) |
Clean frame buffer attachment code:
- There is no need to check for buses config(8) will not let us attach to
- Better P4 bus logic, which does not need to abuse device flags
- Do not bother trying to print a meaningful device description when it is
not connected to sbus.
Diffstat (limited to 'sys/arch/sparc')
-rw-r--r-- | sys/arch/sparc/conf/files.sparc | 4 | ||||
-rw-r--r-- | sys/arch/sparc/dev/bwtwo.c | 74 | ||||
-rw-r--r-- | sys/arch/sparc/dev/cgeight.c | 16 | ||||
-rw-r--r-- | sys/arch/sparc/dev/cgfour.c | 24 | ||||
-rw-r--r-- | sys/arch/sparc/dev/cgsix.c | 85 | ||||
-rw-r--r-- | sys/arch/sparc/dev/cgthree.c | 51 | ||||
-rw-r--r-- | sys/arch/sparc/dev/cgtwo.c | 18 | ||||
-rw-r--r-- | sys/arch/sparc/include/fbvar.h | 10 |
8 files changed, 102 insertions, 180 deletions
diff --git a/sys/arch/sparc/conf/files.sparc b/sys/arch/sparc/conf/files.sparc index b17e10d7c99..f9e5d418050 100644 --- a/sys/arch/sparc/conf/files.sparc +++ b/sys/arch/sparc/conf/files.sparc @@ -1,4 +1,4 @@ -# $OpenBSD: files.sparc,v 1.72 2006/12/02 11:00:35 miod Exp $ +# $OpenBSD: files.sparc,v 1.73 2006/12/03 16:38:10 miod Exp $ # $NetBSD: files.sparc,v 1.44 1997/08/31 21:29:16 pk Exp $ # @(#)files.sparc 8.1 (Berkeley) 7/19/93 @@ -191,7 +191,7 @@ attach cgtwelve at sbus file arch/sparc/dev/cgtwelve.c cgtwelve device cgtwo: wsemuldisplaydev, rasops8, wsemul_sun -attach cgtwo at sbus, obio, vmes +attach cgtwo at vmes file arch/sparc/dev/cgtwo.c cgtwo device mgx: wsemuldisplaydev, rasops8, wsemul_sun diff --git a/sys/arch/sparc/dev/bwtwo.c b/sys/arch/sparc/dev/bwtwo.c index 06c687f8dc5..b9cb9ddafb2 100644 --- a/sys/arch/sparc/dev/bwtwo.c +++ b/sys/arch/sparc/dev/bwtwo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bwtwo.c,v 1.33 2006/06/02 20:00:54 miod Exp $ */ +/* $OpenBSD: bwtwo.c,v 1.34 2006/12/03 16:38:12 miod Exp $ */ /* $NetBSD: bwtwo.c,v 1.33 1997/05/24 20:16:02 pk Exp $ */ /* @@ -128,19 +128,16 @@ bwtwomatch(struct device *parent, void *vcf, void *aux) struct confargs *ca = aux; struct romaux *ra = &ca->ca_ra; - /* - * Mask out invalid flags from the user. - */ - cf->cf_flags &= FB_USERMASK; - if (strcmp(cf->cf_driver->cd_name, ra->ra_name)) return (0); +#if 0 if (CPU_ISSUN4 && cf->cf_unit != 0) return (0); +#endif if (ca->ca_bustype == BUS_SBUS) - return(1); + return (1); /* * Make sure there's hardware there. @@ -148,29 +145,32 @@ bwtwomatch(struct device *parent, void *vcf, void *aux) if (probeget(ra->ra_vaddr, 4) == -1) return (0); + switch (ca->ca_bustype) { + case BUS_VME16: + case BUS_VME32: + return (1); + case BUS_OBIO: #if defined(SUN4) - if (CPU_ISSUN4 && (ca->ca_bustype == BUS_OBIO)) { - /* - * Check for a pfour framebuffer, but do not match the - * overlay planes for color pfour framebuffers. - */ - switch (fb_pfour_id(ra->ra_vaddr)) { - case PFOUR_ID_BW: - cf->cf_flags |= FB_PFOUR; - /* FALLTHROUGH */ - - case PFOUR_NOTPFOUR: - return (1); - - case PFOUR_ID_COLOR8P1: /* bwtwo in ... */ - case PFOUR_ID_COLOR24: /* ...overlay plane */ - default: - return (0); + if (CPU_ISSUN4) { + /* + * Check for a pfour framebuffer, but do not match the + * overlay planes for color pfour framebuffers. + */ + switch (fb_pfour_id(ra->ra_vaddr)) { + case PFOUR_ID_BW: + case PFOUR_NOTPFOUR: + return (1); + case PFOUR_ID_COLOR8P1: /* bwtwo in ... */ + case PFOUR_ID_COLOR24: /* ...overlay plane */ + default: + return (0); + } } - } #endif - - return (0); + return (1); + default: + return (0); + } } void @@ -181,26 +181,25 @@ bwtwoattach(struct device *parent, struct device *self, void *args) int node = ca->ca_ra.ra_node; int isconsole = 0; int sbus = 1; - char *nam = NULL; + char *nam; - sc->sc_sunfb.sf_flags = self->dv_cfdata->cf_flags; + printf(": "); /* * Map the control register. */ #if defined(SUN4) if (CPU_ISSUN4 && ca->ca_bustype == BUS_OBIO && - ISSET(sc->sc_sunfb.sf_flags, FB_PFOUR)) { + fb_pfour_id(ca->ca_ra.ra_vaddr) != PFOUR_NOTPFOUR) { + SET(sc->sc_sunfb.sf_flags, FB_PFOUR); sc->sc_sunfb.sf_pfour = (volatile u_int32_t *) mapiodev(ca->ca_ra.ra_reg, 0, sizeof(u_int32_t)); - sc->sc_reg = NULL; } else #endif { sc->sc_reg = (volatile struct fbcontrol *) mapiodev(ca->ca_ra.ra_reg, BWREG_REG, sizeof(struct fbcontrol)); - sc->sc_sunfb.sf_pfour = NULL; } /* Set up default pixel offset. May be changed below. */ @@ -214,17 +213,17 @@ bwtwoattach(struct device *parent, struct device *self, void *args) sbus = node = 0; #if defined(SUN4) if (ISSET(sc->sc_sunfb.sf_flags, FB_PFOUR)) { - nam = "bwtwo/p4"; + nam = "p4"; sc->sc_pixeloffset = PFOUR_BW_OFF; } else #endif - nam = "bwtwo"; + nam = NULL; break; case BUS_VME32: case BUS_VME16: sbus = node = 0; - nam = "bwtwo"; + nam = NULL; break; case BUS_SBUS: @@ -235,7 +234,8 @@ obp_name: break; } - printf(": %s", nam); + if (nam != NULL && *nam != '\0') + printf("%s, ", nam); #if defined(SUN4) if (CPU_ISSUN4) { @@ -270,7 +270,7 @@ obp_name: bwtwo_burner(sc, 1, 0); fb_setsize(&sc->sc_sunfb, 1, 1152, 900, node, ca->ca_bustype); - printf(", %dx%d\n", sc->sc_sunfb.sf_width, sc->sc_sunfb.sf_height); + printf("%dx%d\n", sc->sc_sunfb.sf_width, sc->sc_sunfb.sf_height); sc->sc_sunfb.sf_ro.ri_bits = mapiodev(ca->ca_ra.ra_reg, sc->sc_pixeloffset, round_page(sc->sc_sunfb.sf_fbsize)); diff --git a/sys/arch/sparc/dev/cgeight.c b/sys/arch/sparc/dev/cgeight.c index 6420c2a6b06..f1796cb8edd 100644 --- a/sys/arch/sparc/dev/cgeight.c +++ b/sys/arch/sparc/dev/cgeight.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cgeight.c,v 1.26 2006/07/25 21:23:30 miod Exp $ */ +/* $OpenBSD: cgeight.c,v 1.27 2006/12/03 16:38:12 miod Exp $ */ /* $NetBSD: cgeight.c,v 1.13 1997/05/24 20:16:04 pk Exp $ */ /* @@ -121,11 +121,6 @@ cgeightmatch(struct device *parent, void *vcf, void *aux) struct confargs *ca = aux; struct romaux *ra = &ca->ca_ra; - /* - * Mask out invalid flags from the user. - */ - cf->cf_flags &= FB_USERMASK; - if (strcmp(cf->cf_driver->cd_name, ra->ra_name)) return (0); @@ -141,10 +136,8 @@ cgeightmatch(struct device *parent, void *vcf, void *aux) /* * Check the pfour register. */ - if (fb_pfour_id(ra->ra_vaddr) == PFOUR_ID_COLOR24) { - cf->cf_flags |= FB_PFOUR; + if (fb_pfour_id(ra->ra_vaddr) == PFOUR_ID_COLOR24) return (1); - } return (0); } @@ -158,9 +151,8 @@ cgeightattach(struct device *parent, struct device *self, void *args) volatile struct bt_regs *bt; int isconsole = 0; - sc->sc_sunfb.sf_flags = self->dv_cfdata->cf_flags; - /* Map the pfour register. */ + SET(sc->sc_sunfb.sf_flags, FB_PFOUR); sc->sc_sunfb.sf_pfour = (volatile u_int32_t *) mapiodev(ca->ca_ra.ra_reg, 0, sizeof(u_int32_t)); @@ -193,7 +185,7 @@ cgeightattach(struct device *parent, struct device *self, void *args) PFOUR_COLOR_OFF_OVERLAY, round_page(sc->sc_sunfb.sf_fbsize)); fbwscons_init(&sc->sc_sunfb, isconsole ? 0 : RI_CLEAR); - printf(": cgeight/p4, %dx%d", sc->sc_sunfb.sf_width, + printf(": p4, %dx%d", sc->sc_sunfb.sf_width, sc->sc_sunfb.sf_height); if (isconsole) { diff --git a/sys/arch/sparc/dev/cgfour.c b/sys/arch/sparc/dev/cgfour.c index e1701d2d5fc..46a8d6f4f28 100644 --- a/sys/arch/sparc/dev/cgfour.c +++ b/sys/arch/sparc/dev/cgfour.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cgfour.c,v 1.26 2006/07/25 21:23:30 miod Exp $ */ +/* $OpenBSD: cgfour.c,v 1.27 2006/12/03 16:38:12 miod Exp $ */ /* $NetBSD: cgfour.c,v 1.13 1997/05/24 20:16:06 pk Exp $ */ /* @@ -121,11 +121,6 @@ cgfourmatch(struct device *parent, void *vcf, void *aux) struct confargs *ca = aux; struct romaux *ra = &ca->ca_ra; - /* - * Mask out invalid flags from the user. - */ - cf->cf_flags &= FB_USERMASK; - if (strcmp(cf->cf_driver->cd_name, ra->ra_name)) return (0); @@ -138,10 +133,8 @@ cgfourmatch(struct device *parent, void *vcf, void *aux) /* * Check the pfour register. */ - if (fb_pfour_id(ra->ra_vaddr) == PFOUR_ID_COLOR8P1) { - cf->cf_flags |= FB_PFOUR; + if (fb_pfour_id(ra->ra_vaddr) == PFOUR_ID_COLOR8P1) return (1); - } return (0); } @@ -155,11 +148,14 @@ cgfourattach(struct device *parent, struct device *self, void *args) volatile struct bt_regs *bt; int isconsole = 0; - sc->sc_sunfb.sf_flags = self->dv_cfdata->cf_flags; + printf(": p4"); - printf(": cgfour/p4"); + /* Map the pfour register. */ + SET(sc->sc_sunfb.sf_flags, FB_PFOUR); + sc->sc_sunfb.sf_pfour = (volatile u_int32_t *) + mapiodev(ca->ca_ra.ra_reg, 0, sizeof(u_int32_t)); - if (CPU_ISSUN4) { + if (cputyp == CPU_SUN4) { struct eeprom *eep = (struct eeprom *)eeprom_va; /* @@ -170,10 +166,6 @@ cgfourattach(struct device *parent, struct device *self, void *args) isconsole = 1; } - /* Map the pfour register. */ - sc->sc_sunfb.sf_pfour = (volatile u_int32_t *) - mapiodev(ca->ca_ra.ra_reg, 0, sizeof(u_int32_t)); - /* * When the ROM has mapped in a cgfour display, the address * maps only the video RAM, so in any case we have to map the diff --git a/sys/arch/sparc/dev/cgsix.c b/sys/arch/sparc/dev/cgsix.c index ed52176a230..24f146b1f6b 100644 --- a/sys/arch/sparc/dev/cgsix.c +++ b/sys/arch/sparc/dev/cgsix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cgsix.c,v 1.36 2006/12/02 11:21:35 miod Exp $ */ +/* $OpenBSD: cgsix.c,v 1.37 2006/12/03 16:38:13 miod Exp $ */ /* $NetBSD: cgsix.c,v 1.33 1997/08/07 19:12:30 pk Exp $ */ /* @@ -168,40 +168,37 @@ cgsixmatch(struct device *parent, void *vcf, void *aux) struct confargs *ca = aux; struct romaux *ra = &ca->ca_ra; - /* - * Mask out invalid flags from the user. - */ - cf->cf_flags &= FB_USERMASK; - if (strcmp(ra->ra_name, cf->cf_driver->cd_name) && strcmp(ra->ra_name, "SUNW,cgsix")) return (0); - if (ca->ca_bustype == BUS_SBUS) + switch (ca->ca_bustype) { + case BUS_SBUS: return (1); - + case BUS_OBIO: #if defined(SUN4) - if (CPU_ISSUN4 && (ca->ca_bustype == BUS_OBIO)) { - void *tmp; - - /* - * Check for a pfour framebuffer. This is done somewhat - * differently on the cgsix than other pfour framebuffers. - */ - bus_untmp(); - tmp = (caddr_t)mapdev(ra->ra_reg, TMPMAP_VA, CGSIX_FHC_OFFSET, - NBPG); - if (probeget(tmp, 4) == -1) - return (0); - - if (fb_pfour_id(tmp) == PFOUR_ID_FASTCOLOR) { - cf->cf_flags |= FB_PFOUR; - return (1); + if (CPU_ISSUN4) { + void *tmp; + + /* + * Check for a pfour framebuffer. This is done + * somewhat differently on the cgsix than other + * pfour framebuffers. + */ + bus_untmp(); + tmp = (caddr_t)mapdev(ra->ra_reg, TMPMAP_VA, + CGSIX_FHC_OFFSET, NBPG); + if (probeget(tmp, 4) == -1) + return (0); + + if (fb_pfour_id(tmp) == PFOUR_ID_FASTCOLOR) + return (1); } - } #endif - - return (0); + /* FALLTHROUGH */ + default: + return (0); + } } void @@ -211,10 +208,10 @@ cgsixattach(struct device *parent, struct device *self, void *args) struct confargs *ca = args; int node = 0; int isconsole = 0, sbus = 1; - char *nam = NULL; + char *nam; u_int fhcrev; - sc->sc_sunfb.sf_flags = self->dv_cfdata->cf_flags; + printf(": "); /* * Map just BT, FHC, FBC, THC, and video RAM. @@ -234,37 +231,17 @@ cgsixattach(struct device *parent, struct device *self, void *args) switch (ca->ca_bustype) { case BUS_OBIO: sbus = node = 0; - if (ISSET(sc->sc_sunfb.sf_flags, FB_PFOUR)) - nam = "cgsix/p4"; - else - nam = "cgsix"; - -#if defined(SUN4M) - if (CPU_ISSUN4M) { /* 4m has framebuffer on obio */ - node = ca->ca_ra.ra_node; - nam = getpropstring(node, "model"); - break; - } -#endif - break; - - case BUS_VME32: - case BUS_VME16: - sbus = node = 0; - nam = "cgsix"; + SET(sc->sc_sunfb.sf_flags, FB_PFOUR); + nam = "p4"; break; - case BUS_SBUS: node = ca->ca_ra.ra_node; nam = getpropstring(node, "model"); break; - - case BUS_MAIN: - printf("cgsix on mainbus?\n"); - return; } - printf(": %s", nam); + if (*nam != '\0') + printf("%s, ", nam); #if defined(SUN4) if (CPU_ISSUN4) { @@ -332,7 +309,7 @@ cgsixattach(struct device *parent, struct device *self, void *args) cgsix_ras_init(sc); } - printf(", %dx%d, rev %d\n", sc->sc_sunfb.sf_width, + printf("%dx%d, rev %d\n", sc->sc_sunfb.sf_width, sc->sc_sunfb.sf_height, fhcrev); if (isconsole) { diff --git a/sys/arch/sparc/dev/cgthree.c b/sys/arch/sparc/dev/cgthree.c index 2bf62f66ce0..8baf7c85f95 100644 --- a/sys/arch/sparc/dev/cgthree.c +++ b/sys/arch/sparc/dev/cgthree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cgthree.c,v 1.31 2006/07/25 21:23:30 miod Exp $ */ +/* $OpenBSD: cgthree.c,v 1.32 2006/12/03 16:38:13 miod Exp $ */ /* $NetBSD: cgthree.c,v 1.33 1997/05/24 20:16:11 pk Exp $ */ /* @@ -178,11 +178,10 @@ cgthreematch(struct device *parent, void *vcf, void *aux) strcmp("cgRDI", ra->ra_name)) return (0); - if (ca->ca_bustype == BUS_SBUS) - return (1); + if (ca->ca_bustype != BUS_SBUS) + return (0); - ra->ra_len = NBPG; - return (probeget(ra->ra_vaddr, 4) != -1); + return (1); } void @@ -190,41 +189,23 @@ cgthreeattach(struct device *parent, struct device *self, void *args) { struct cgthree_softc *sc = (struct cgthree_softc *)self; struct confargs *ca = args; - int node = 0, isrdi = 0, i; + int node, isrdi = 0, i; volatile struct bt_regs *bt; - int isconsole = 0, sbus = 1; - char *nam = NULL; - - switch (ca->ca_bustype) { - case BUS_OBIO: - if (CPU_ISSUN4M) { /* 4m has framebuffer on obio */ - sbus = 0; - node = ca->ca_ra.ra_node; - nam = getpropstring(node, "model"); - if (*nam == '\0') - nam = "cgthree"; - break; - } - case BUS_VME32: - case BUS_VME16: - sbus = node = 0; - nam = "cgthree"; - break; + int isconsole = 0; + char *nam; - case BUS_SBUS: - node = ca->ca_ra.ra_node; - nam = getpropstring(node, "model"); - if (*nam == '\0') - nam = "cgthree"; - break; - } + printf(": "); + + node = ca->ca_ra.ra_node; - if (!strcmp(ca->ca_ra.ra_name, "cgRDI")) { + if (strcmp(ca->ca_ra.ra_name, "cgRDI") == 0) { isrdi = 1; nam = "cgRDI"; - } + } else + nam = getpropstring(node, "model"); - printf(": %s", nam); + if (nam != NULL && *nam != '\0') + printf("%s, ", nam); isconsole = node == fbnode; @@ -269,7 +250,7 @@ cgthreeattach(struct device *parent, struct device *self, void *args) round_page(sc->sc_sunfb.sf_fbsize)); sc->sc_sunfb.sf_ro.ri_hw = sc; - printf(", %dx%d\n", sc->sc_sunfb.sf_width, sc->sc_sunfb.sf_height); + printf("%dx%d\n", sc->sc_sunfb.sf_width, sc->sc_sunfb.sf_height); /* * If the framebuffer width is under 1024x768, which is the case for diff --git a/sys/arch/sparc/dev/cgtwo.c b/sys/arch/sparc/dev/cgtwo.c index d57db8ab2e1..635cbbfec16 100644 --- a/sys/arch/sparc/dev/cgtwo.c +++ b/sys/arch/sparc/dev/cgtwo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cgtwo.c,v 1.34 2006/06/29 17:52:21 miod Exp $ */ +/* $OpenBSD: cgtwo.c,v 1.35 2006/12/03 16:38:13 miod Exp $ */ /* $NetBSD: cgtwo.c,v 1.22 1997/05/24 20:16:12 pk Exp $ */ /* @@ -172,20 +172,6 @@ cgtwoattach(struct device *parent, struct device *self, void *args) struct confargs *ca = args; int node = 0; int isconsole = 0; - char *nam = NULL; - - switch (ca->ca_bustype) { - case BUS_VME16: - node = 0; - nam = "cgtwo"; - break; - - default: - panic("cgtwoattach: impossible bustype"); - /* NOTREACHED */ - } - - printf(": %s", nam); if (CPU_ISSUN4) { struct eeprom *eep = (struct eeprom *)eeprom_va; @@ -226,7 +212,7 @@ cgtwoattach(struct device *parent, struct device *self, void *args) fbwscons_init(&sc->sc_sunfb, isconsole ? 0 : RI_CLEAR); fbwscons_setcolormap(&sc->sc_sunfb, cgtwo_setcolor); - printf(", %dx%d\n", sc->sc_sunfb.sf_width, sc->sc_sunfb.sf_height); + printf(": %dx%d\n", sc->sc_sunfb.sf_width, sc->sc_sunfb.sf_height); if (isconsole) { fbwscons_console_init(&sc->sc_sunfb, -1); diff --git a/sys/arch/sparc/include/fbvar.h b/sys/arch/sparc/include/fbvar.h index da9c82235c1..f3ae5a7fb07 100644 --- a/sys/arch/sparc/include/fbvar.h +++ b/sys/arch/sparc/include/fbvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fbvar.h,v 1.16 2006/03/12 22:53:01 miod Exp $ */ +/* $OpenBSD: fbvar.h,v 1.17 2006/12/03 16:38:13 miod Exp $ */ /* $NetBSD: fbvar.h,v 1.9 1997/07/07 23:31:30 pk Exp $ */ /* @@ -42,13 +42,6 @@ */ /* - * Frame buffer device flags. - */ - -#define FB_PFOUR 0x00010000 /* indicates fb is a pfour fb */ -#define FB_USERMASK (0) /* flags that the user can set */ - -/* * Common frame buffer variables. * All framebuffer softc structures must start with such a structure. */ @@ -65,6 +58,7 @@ struct sunfb { int *sf_crowp, *sf_ccolp; /* PROM cursor position */ int sf_flags; +#define FB_PFOUR 0x00000001 /* indicates a P4 fb */ volatile u_int32_t* sf_pfour; /* P4 register when applicable */ struct rasops_info sf_ro; |