summaryrefslogtreecommitdiff
path: root/sys/arch/hp300/dev/sd.c
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1997-04-16 11:56:40 +0000
committerJason Downs <downsj@cvs.openbsd.org>1997-04-16 11:56:40 +0000
commitab08be91e5dc66cfc42b85763d4caf94e2fd3d09 (patch)
tree89caace66e8787764cc54b781a8cbfd881b69458 /sys/arch/hp300/dev/sd.c
parent75113d46e0ad67778c0741a5bfc96d9d686f7eec (diff)
Merge portions of NetBSD up to 970415.
This includes: * All of the prototyping and KNF changes. * The new interrupt system. * Portions of the Domain Keyboard support from Mike Smith. This does not include: * m68k changes, namely generic dumps. Various sundry changes and fixes by me.
Diffstat (limited to 'sys/arch/hp300/dev/sd.c')
-rw-r--r--sys/arch/hp300/dev/sd.c143
1 files changed, 75 insertions, 68 deletions
diff --git a/sys/arch/hp300/dev/sd.c b/sys/arch/hp300/dev/sd.c
index 1ce13bda0d5..ec0a5846610 100644
--- a/sys/arch/hp300/dev/sd.c
+++ b/sys/arch/hp300/dev/sd.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: sd.c,v 1.9 1997/02/10 06:43:34 downsj Exp $ */
-/* $NetBSD: sd.c,v 1.29 1997/01/30 09:14:20 thorpej Exp $ */
+/* $OpenBSD: sd.c,v 1.10 1997/04/16 11:56:15 downsj Exp $ */
+/* $NetBSD: sd.c,v 1.31 1997/04/02 22:37:36 scottr Exp $ */
/*
* Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
@@ -47,20 +47,18 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/buf.h>
-#include <sys/stat.h>
-#include <sys/disklabel.h>
+#include <sys/device.h>
#include <sys/disk.h>
+#include <sys/disklabel.h>
+#include <sys/fcntl.h>
+#include <sys/ioctl.h>
#include <sys/malloc.h>
#include <sys/proc.h>
-#include <sys/ioctl.h>
-#include <sys/fcntl.h>
-#include <sys/device.h>
+#include <sys/stat.h>
#include <hp300/dev/scsireg.h>
#include <hp300/dev/scsivar.h>
-
#include <hp300/dev/sdvar.h>
-
#ifdef USELEDS
#include <hp300/hp300/led.h>
#endif
@@ -70,10 +68,12 @@
#include <vm/vm_prot.h>
#include <vm/pmap.h>
+/*
extern void disksort();
extern void biodone();
extern int physio();
extern void TBIS();
+*/
int sdmatch __P((struct device *, void *, void *));
void sdattach __P((struct device *, struct device *, void *));
@@ -86,17 +86,6 @@ struct cfdriver sd_cd = {
NULL, "sd", DV_DISK
};
-void sdstrategy __P((struct buf *));
-void sdustart __P((int));
-
-void sdstart __P((void *));
-void sdgo __P((void *));
-void sdintr __P((void *, int));
-
-int sdgetcapacity __P((struct sd_softc *, dev_t));
-
-static void sdgetgeom __P((struct sd_softc *));
-
#ifdef DEBUG
int sddebug = 1;
#define SDB_ERROR 0x01
@@ -104,8 +93,8 @@ int sddebug = 1;
#define SDB_CAPACITY 0x04
#endif
-static struct scsi_fmt_cdb sd_read_cmd = { 10, CMD_READ_EXT };
-static struct scsi_fmt_cdb sd_write_cmd = { 10, CMD_WRITE_EXT };
+static struct scsi_fmt_cdb sd_read_cmd = { 10, { CMD_READ_EXT } };
+static struct scsi_fmt_cdb sd_write_cmd = { 10, { CMD_WRITE_EXT } };
/*
* Table of scsi commands users are allowed to access via "format"
@@ -132,6 +121,26 @@ static char legal_cmds[256] = {
/*f0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
+/* bdev_decl(sd); */
+/* cdev_decl(sd); */
+/* XXX we should use macros to do these... */
+int sdopen __P((dev_t, int, int, struct proc *));
+int sdclose __P((dev_t, int, int, struct proc *));
+
+int sdioctl __P((dev_t, u_long, caddr_t, int, struct proc *));
+int sdread __P((dev_t, struct uio *, int));
+void sdreset __P((struct sd_softc *));
+int sdwrite __P((dev_t, struct uio *, int));
+
+void sdstrategy __P((struct buf *));
+int sddump __P((dev_t, daddr_t, caddr_t, size_t));
+int sdsize __P((dev_t));
+
+static void sdgetgeom __P((struct sd_softc *));
+static void sdlblkstrat __P((struct buf *, int));
+static int sderror __P((struct sd_softc *, int));
+static void sdfinish __P((struct sd_softc *, struct buf *));
+
/*
* Perform a mode-sense on page 0x04 (rigid geometry).
*/
@@ -145,7 +154,7 @@ sdgetgeom(sc)
} sensebuf;
struct scsi_fmt_cdb modesense_geom = {
6,
- CMD_MODE_SENSE, 0, 0x04, 0, sizeof(sensebuf), 0
+ { CMD_MODE_SENSE, 0, 0x04, 0, sizeof(sensebuf), 0 }
};
int ctlr, slave, unit;
@@ -260,7 +269,7 @@ sdattach(parent, self, aux)
void
sdreset(sc)
- register struct sd_softc *sc;
+ struct sd_softc *sc;
{
sc->sc_stats.sdresets++;
}
@@ -277,7 +286,7 @@ sdgetcapacity(sc, dev)
{
static struct scsi_fmt_cdb cap = {
10,
- CMD_READ_CAPACITY, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ { CMD_READ_CAPACITY, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
u_char *capbuf;
int i, capbufsize;
@@ -377,9 +386,9 @@ sdgetinfo(dev)
{
int unit = sdunit(dev);
struct sd_softc *sc = sd_cd.cd_devs[unit];
- register struct disklabel *lp = sc->sc_dkdev.dk_label;
- register struct partition *pi;
- char *msg, *readdisklabel();
+ struct disklabel *lp = sc->sc_dkdev.dk_label;
+ struct partition *pi;
+ char *msg;
bzero((caddr_t)lp, sizeof *lp);
msg = NULL;
@@ -450,7 +459,7 @@ sdopen(dev, flags, mode, p)
int flags, mode;
struct proc *p;
{
- register int unit = sdunit(dev);
+ int unit = sdunit(dev);
struct sd_softc *sc;
int error, mask, part;
@@ -511,7 +520,7 @@ sdclose(dev, flag, mode, p)
{
int unit = sdunit(dev);
struct sd_softc *sc = sd_cd.cd_devs[unit];
- register struct disk *dk = &sc->sc_dkdev;
+ struct disk *dk = &sc->sc_dkdev;
int mask, s;
mask = 1 << sdpart(dev);
@@ -553,15 +562,15 @@ sdclose(dev, flag, mode, p)
*/
static void
sdlblkstrat(bp, bsize)
- register struct buf *bp;
- register int bsize;
+ struct buf *bp;
+ int bsize;
{
struct sd_softc *sc = sd_cd.cd_devs[sdunit(bp->b_dev)];
- register struct buf *cbp = (struct buf *)malloc(sizeof(struct buf),
+ struct buf *cbp = (struct buf *)malloc(sizeof(struct buf),
M_DEVBUF, M_WAITOK);
caddr_t cbuf = (caddr_t)malloc(bsize, M_DEVBUF, M_WAITOK);
- register int bn, resid;
- register caddr_t addr;
+ int bn, resid;
+ caddr_t addr;
bzero((caddr_t)cbp, sizeof(*cbp));
cbp->b_proc = curproc; /* XXX */
@@ -571,13 +580,13 @@ sdlblkstrat(bp, bsize)
addr = bp->b_un.b_addr;
#ifdef DEBUG
if (sddebug & SDB_PARTIAL)
- printf("sdlblkstrat: bp %x flags %x bn %x resid %x addr %x\n",
+ printf("sdlblkstrat: bp %p flags %lx bn %x resid %x addr %p\n",
bp, bp->b_flags, bn, resid, addr);
#endif
while (resid > 0) {
- register int boff = dbtob(bn) & (bsize - 1);
- register int count;
+ int boff = dbtob(bn) & (bsize - 1);
+ int count;
if (boff || resid < bsize) {
sc->sc_stats.sdpartials++;
@@ -588,7 +597,7 @@ sdlblkstrat(bp, bsize)
cbp->b_bcount = bsize;
#ifdef DEBUG
if (sddebug & SDB_PARTIAL)
- printf(" readahead: bn %x cnt %x off %x addr %x\n",
+ printf(" readahead: bn %x cnt %x off %x addr %p\n",
cbp->b_blkno, count, boff, addr);
#endif
sdstrategy(cbp);
@@ -605,7 +614,7 @@ sdlblkstrat(bp, bsize)
bcopy(addr, &cbuf[boff], count);
#ifdef DEBUG
if (sddebug & SDB_PARTIAL)
- printf(" writeback: bn %x cnt %x off %x addr %x\n",
+ printf(" writeback: bn %x cnt %x off %x addr %p\n",
cbp->b_blkno, count, boff, addr);
#endif
} else {
@@ -615,7 +624,7 @@ sdlblkstrat(bp, bsize)
cbp->b_bcount = count;
#ifdef DEBUG
if (sddebug & SDB_PARTIAL)
- printf(" fulltrans: bn %x cnt %x addr %x\n",
+ printf(" fulltrans: bn %x cnt %x addr %p\n",
cbp->b_blkno, count, addr);
#endif
}
@@ -633,7 +642,7 @@ done:
addr += count;
#ifdef DEBUG
if (sddebug & SDB_PARTIAL)
- printf(" done: bn %x resid %x addr %x\n",
+ printf(" done: bn %x resid %x addr %p\n",
bn, resid, addr);
#endif
}
@@ -643,14 +652,14 @@ done:
void
sdstrategy(bp)
- register struct buf *bp;
+ struct buf *bp;
{
int unit = sdunit(bp->b_dev);
struct sd_softc *sc = sd_cd.cd_devs[unit];
- register struct buf *dp = &sc->sc_tab;
- register struct partition *pinfo;
- register daddr_t bn;
- register int sz, s;
+ struct buf *dp = &sc->sc_tab;
+ struct partition *pinfo;
+ daddr_t bn;
+ int sz, s;
int offset;
if (sc->sc_format_pid >= 0) {
@@ -728,7 +737,7 @@ done:
void
sdustart(unit)
- register int unit;
+ int unit;
{
struct sd_softc *sc = sd_cd.cd_devs[unit];
@@ -801,7 +810,7 @@ sdfinish(sc, bp)
struct sd_softc *sc;
struct buf *bp;
{
- register struct buf *dp = &sc->sc_tab;
+ struct buf *dp = &sc->sc_tab;
dp->b_errcnt = 0;
dp->b_actf = bp->b_actf;
@@ -830,8 +839,8 @@ sdstart(arg)
* so check now.
*/
if (sc->sc_format_pid >= 0 && legal_cmds[sc->sc_cmdstore.cdb[0]] > 0) {
- register struct buf *bp = sc->sc_tab.b_actf;
- register int sts;
+ struct buf *bp = sc->sc_tab.b_actf;
+ int sts;
sc->sc_tab.b_errcnt = 0;
while (1) {
@@ -860,9 +869,9 @@ sdgo(arg)
void *arg;
{
struct sd_softc *sc = arg;
- register struct buf *bp = sc->sc_tab.b_actf;
- register int pad;
- register struct scsi_fmt_cdb *cmd;
+ struct buf *bp = sc->sc_tab.b_actf;
+ int pad;
+ struct scsi_fmt_cdb *cmd;
if (sc->sc_format_pid >= 0) {
cmd = &sc->sc_cmdstore;
@@ -884,7 +893,7 @@ sdgo(arg)
pad = (bp->b_bcount & (sc->sc_blksize - 1)) != 0;
#ifdef DEBUG
if (pad)
- printf("%s: partial block xfer -- %x bytes\n",
+ printf("%s: partial block xfer -- %lx bytes\n",
sc->sc_dev.dv_xname, bp->b_bcount);
#endif
sc->sc_stats.sdtransfers++;
@@ -902,7 +911,7 @@ sdgo(arg)
}
#ifdef DEBUG
if (sddebug & SDB_ERROR)
- printf("%s: sdstart: %s adr %d blk %d len %d ecnt %d\n",
+ printf("%s: sdstart: %s adr %p blk %ld len %ld ecnt %ld\n",
sc->sc_dev.dv_xname,
bp->b_flags & B_READ? "read" : "write",
bp->b_un.b_addr, bp->b_cylin, bp->b_bcount,
@@ -918,9 +927,8 @@ sdintr(arg, stat)
void *arg;
int stat;
{
- register struct sd_softc *sc = arg;
- int unit = sc->sc_dev.dv_unit;
- register struct buf *bp = sc->sc_tab.b_actf;
+ struct sd_softc *sc = arg;
+ struct buf *bp = sc->sc_tab.b_actf;
int cond;
if (bp == NULL) {
@@ -941,7 +949,7 @@ sdintr(arg, stat)
if (cond < 0 && sc->sc_tab.b_errcnt++ < SDRETRY) {
#ifdef DEBUG
if (sddebug & SDB_ERROR)
- printf("%s: retry #%d\n",
+ printf("%s: retry #%ld\n",
sc->sc_dev.dv_xname,
sc->sc_tab.b_errcnt);
#endif
@@ -961,9 +969,9 @@ sdread(dev, uio, flags)
struct uio *uio;
int flags;
{
- register int unit = sdunit(dev);
+ int unit = sdunit(dev);
struct sd_softc *sc = sd_cd.cd_devs[unit];
- register int pid;
+ int pid;
if ((pid = sc->sc_format_pid) >= 0 &&
pid != uio->uio_procp->p_pid)
@@ -978,9 +986,9 @@ sdwrite(dev, uio, flags)
struct uio *uio;
int flags;
{
- register int unit = sdunit(dev);
+ int unit = sdunit(dev);
struct sd_softc *sc = sd_cd.cd_devs[unit];
- register int pid;
+ int pid;
if ((pid = sc->sc_format_pid) >= 0 &&
pid != uio->uio_procp->p_pid)
@@ -992,14 +1000,14 @@ sdwrite(dev, uio, flags)
int
sdioctl(dev, cmd, data, flag, p)
dev_t dev;
- int cmd;
+ u_long cmd;
caddr_t data;
int flag;
struct proc *p;
{
int unit = sdunit(dev);
struct sd_softc *sc = sd_cd.cd_devs[unit];
- register struct disklabel *lp = sc->sc_dkdev.dk_label;
+ struct disklabel *lp = sc->sc_dkdev.dk_label;
int error, flags;
switch (cmd) {
@@ -1096,7 +1104,7 @@ int
sdsize(dev)
dev_t dev;
{
- register int unit = sdunit(dev);
+ int unit = sdunit(dev);
struct sd_softc *sc = sd_cd.cd_devs[unit];
int psize, didopen = 0;
@@ -1141,7 +1149,6 @@ sddump(dev, blkno, va, size)
int unit, part;
struct sd_softc *sc;
struct disklabel *lp;
- daddr_t baddr;
char stat;
/* Check for recursive dump; if so, punt. */