diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2013-06-04 21:05:55 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2013-06-04 21:05:55 +0000 |
commit | 1bae6cab2a9afb4e46b924ba5eb62e2499ffe888 (patch) | |
tree | 2b478f7ef65280bf593a50a9e20ca0a0da5aaa1c | |
parent | 51ce17d9e2e603adcfc9f5f2e1d3129f3280e8ca (diff) |
Support for the SS10/SS20 NVSIMM as block devices; tested by nick@
-rw-r--r-- | share/man/man4/man4.sparc/presto.4 | 13 | ||||
-rw-r--r-- | sys/arch/sparc/conf/GENERIC | 5 | ||||
-rw-r--r-- | sys/arch/sparc/conf/files.sparc | 4 | ||||
-rw-r--r-- | sys/arch/sparc/dev/presto.c | 73 |
4 files changed, 64 insertions, 31 deletions
diff --git a/share/man/man4/man4.sparc/presto.4 b/share/man/man4/man4.sparc/presto.4 index c296b57fedb..647699ef53f 100644 --- a/share/man/man4/man4.sparc/presto.4 +++ b/share/man/man4/man4.sparc/presto.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: presto.4,v 1.5 2010/07/11 07:37:30 jmc Exp $ +.\" $OpenBSD: presto.4,v 1.6 2013/06/04 21:05:53 miod Exp $ .\" Copyright (c) 2003, Miodrag Vallat .\" All rights reserved. .\" @@ -23,7 +23,7 @@ .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: July 11 2010 $ +.Dd $Mdocdate: June 4 2013 $ .Dt PRESTO 4 sparc .Os .Sh NAME @@ -31,13 +31,13 @@ .Nd Prestoserve battery-backed memory .Sh SYNOPSIS .Cd "presto* at sbus?" +.Cd "presto* at mainbus?" Pq "SS10/SS20 NVSIMM" .Sh DESCRIPTION The .Tn Legato -Prestoserve NVRAM cards -used to be part of the +Prestoserve NVRAM SBus cards and NVSIMM used to be part of the .Dq NFS accelerator -product, which used the cards memory as an NFS-dedicated cache, increasing +product, which used the device's memory as an NFS-dedicated cache, increasing performance of NFS servers exporting filesystem as NFS protocol, version 2. .Pp The @@ -64,6 +64,3 @@ partition .Xr disklabel 5 , .Xr disklabel 8 , .Xr MAKEDEV 8 -.Sh BUGS -The NVSIMM flavour, designed for SPARCstation models 10 and 20, is not -supported yet. diff --git a/sys/arch/sparc/conf/GENERIC b/sys/arch/sparc/conf/GENERIC index c97f4ee5da1..6fc6547201d 100644 --- a/sys/arch/sparc/conf/GENERIC +++ b/sys/arch/sparc/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.103 2011/11/08 12:53:58 deraadt Exp $ +# $OpenBSD: GENERIC,v 1.104 2013/06/04 21:05:54 miod Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -359,7 +359,8 @@ fd* at fdc0 # the drive itself #daadio* at fvme? addr 0x0 level 1 vect 0x1f # Matrix MD-DAADIO board # Prestoserve NVRAM -#presto* at sbus? +#presto* at sbus? # SBus board +#presto* at mainbus? # SS10/SS20 NVSIMM pseudo-device hotplug 1 # devices hot plugging pseudo-device wsmux 2 # mouse & keyboard multiplexor diff --git a/sys/arch/sparc/conf/files.sparc b/sys/arch/sparc/conf/files.sparc index 6e0a5886ac5..57bb7172310 100644 --- a/sys/arch/sparc/conf/files.sparc +++ b/sys/arch/sparc/conf/files.sparc @@ -1,4 +1,4 @@ -# $OpenBSD: files.sparc,v 1.92 2013/04/21 14:44:16 sebastia Exp $ +# $OpenBSD: files.sparc,v 1.93 2013/06/04 21:05:54 miod Exp $ # $NetBSD: files.sparc,v 1.44 1997/08/31 21:29:16 pk Exp $ # @(#)files.sparc 8.1 (Berkeley) 7/19/93 @@ -361,7 +361,7 @@ file arch/sparc/dev/tctrl.c tctrl needs-flag # Prestoserve NVRAM device presto: disk -attach presto at sbus +attach presto at mainbus, sbus file arch/sparc/dev/presto.c presto needs-flag # PCMCIA devices diff --git a/sys/arch/sparc/dev/presto.c b/sys/arch/sparc/dev/presto.c index 8c3efc605f1..1e37bb550fb 100644 --- a/sys/arch/sparc/dev/presto.c +++ b/sys/arch/sparc/dev/presto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: presto.c,v 1.23 2011/07/06 19:14:54 matthew Exp $ */ +/* $OpenBSD: presto.c,v 1.24 2013/06/04 21:05:53 miod Exp $ */ /* * Copyright (c) 2003, Miodrag Vallat. * All rights reserved. @@ -47,13 +47,17 @@ struct presto_softc { struct device sc_dev; struct disk sc_dk; + vsize_t sc_offset; /* reserved memory offset */ vsize_t sc_memsize; /* total NVRAM size */ caddr_t sc_mem; /* NVRAM kva */ + caddr_t sc_status; /* status register kva (MBus) */ char sc_model[16]; /* Prestoserve model */ }; /* - * The beginning of the NVRAM contains a few control and status values + * The beginning of the NVRAM contains a few control and status values. + * On SBus boards, there are two distinct four-bit status values; + * On MBus boards, these are provided in the second register mapping. */ #define PSERVE_BATTERYSTATUS 0x07 @@ -65,7 +69,10 @@ struct presto_softc { #define PSDATA_EMPTY 0x00 #define PSDATA_SAVED 0x01 -/* reserved area size - needs to be rounded to a sector size for i/o */ +/* + * Reserved area size on SBus flavours, needs to be rounded to a sector + * size for i/o. + */ #define PSERVE_RESERVED 0x0010 #define PSERVE_OFFSET roundup(PSERVE_RESERVED, DEV_BSIZE) @@ -90,13 +97,18 @@ presto_match(struct device *parent, void *vcf, void *aux) struct confargs *ca = aux; struct romaux *ra = &ca->ca_ra; - if (strcmp(ra->ra_name, "MMI,prestoserve") != 0) - return (0); + if (strcmp(ra->ra_name, "MMI,prestoserve") != 0 && + strcmp(ra->ra_name, "SUNW,nvone") != 0) + return 0; + + if (ra->ra_nreg < 1) + return 0; - if (ra->ra_len < PSERVE_OFFSET) /* no usable memory ? */ - return (0); + /* no usable memory ? */ + if (ra->ra_nreg == 1 && ra->ra_len < PSERVE_OFFSET) + return 0; - return (1); + return 1; } void @@ -126,24 +138,39 @@ presto_attach(struct device *parent, struct device *self, void *args) /* Map memory */ sc->sc_mem = (void *)mapiodev(ca->ca_ra.ra_reg, 0, sc->sc_memsize); + if (ca->ca_ra.ra_nreg == 1) { + sc->sc_status = NULL; + } else { + sc->sc_status = (void *)mapiodev(&ca->ca_ra.ra_reg[1], 0, + ca->ca_ra.ra_reg[1].rr_len); + } /* * Clear the ``disconnect battery'' bit. */ - *(u_int8_t *)(sc->sc_mem + PSERVE_BATTERYSTATUS) = 0x00; + if (sc->sc_status == NULL) + *(u_int8_t *)(sc->sc_mem + PSERVE_BATTERYSTATUS) = 0x00; + else + *(u_int8_t *)sc->sc_status &= 0x0f; /* * Clear the ``unflushed data'' status. This way, if the card is * reused under SunOS, the system will not try to flush whatever * data the user put in the nvram... */ - *(u_int8_t *)(sc->sc_mem + PSERVE_DATASTATUS) = 0x00; + if (sc->sc_status == NULL) + *(u_int8_t *)(sc->sc_mem + PSERVE_DATASTATUS) = 0x00; + else + *(u_int8_t *)sc->sc_status &= 0xf0; /* * Decode battery status */ - status = *(u_int8_t *)(sc->sc_mem + PSERVE_BATTERYSTATUS); - printf("battery status %x ", status); + if (sc->sc_status == NULL) + status = *(u_int8_t *)(sc->sc_mem + PSERVE_BATTERYSTATUS); + else + status = *(u_int8_t *)sc->sc_status; + printf("battery status %02x ", status); if (ISSET(status, PSBAT_FAULT)) { printf("(non-working)"); } else if (ISSET(status, PSBAT_CONNECTED)) { @@ -156,13 +183,21 @@ presto_attach(struct device *parent, struct device *self, void *args) printf("\n"); #ifdef DEBUG - printf("%s: status codes %02.2x, %02.2x, %02.2x, %02.2x\n", - sc->sc_dev.dv_xname, - *(u_int8_t *)(sc->sc_mem + 0x03), *(u_int8_t *)(sc->sc_mem + 0x07), - *(u_int8_t *)(sc->sc_mem + 0x0b), *(u_int8_t *)(sc->sc_mem + 0x0f)); + if (sc->sc_status == NULL) { + printf("%s: status codes %02.2x, %02.2x, %02.2x, %02.2x\n", + sc->sc_dev.dv_xname, + *(u_int8_t *)(sc->sc_mem + 0x03), + *(u_int8_t *)(sc->sc_mem + 0x07), + *(u_int8_t *)(sc->sc_mem + 0x0b), + *(u_int8_t *)(sc->sc_mem + 0x0f)); + } #endif sc->sc_dk.dk_name = sc->sc_dev.dv_xname; + if (sc->sc_status == NULL) + sc->sc_offset = PSERVE_OFFSET; + else + sc->sc_offset = 0; disk_attach(&sc->sc_dev, &sc->sc_dk); } @@ -269,7 +304,7 @@ prestostrategy(struct buf *bp) goto done; /* Bound the request size, then move data between buf and nvram */ - offset = (bp->b_blkno << DEV_BSHIFT) + PSERVE_OFFSET; + offset = (bp->b_blkno << DEV_BSHIFT) + sc->sc_offset; count = bp->b_bcount; if (count > (sc->sc_memsize - offset)) count = (sc->sc_memsize - offset); @@ -338,14 +373,14 @@ prestoioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *proc) */ void presto_getdisklabel(dev_t dev, struct presto_softc *sc, struct disklabel *lp, - int spoofonly); + int spoofonly) { bzero(sc->sc_dk.dk_label, sizeof(struct disklabel)); lp->d_secsize = DEV_BSIZE; lp->d_ntracks = 1; lp->d_nsectors = 32; - DL_SETDSIZE(lp, (sc->sc_memsize - PSERVE_OFFSET) >> DEV_BSHIFT); + DL_SETDSIZE(lp, (sc->sc_memsize - sc->sc_offset) >> DEV_BSHIFT); lp->d_ncylinders = DL_GETDSIZE(lp) / lp->d_nsectors; lp->d_secpercyl = lp->d_nsectors; |