summaryrefslogtreecommitdiff
path: root/sys/arch/mvme68k/dev
diff options
context:
space:
mode:
authorchuck <chuck@cvs.openbsd.org>1996-02-03 18:31:13 +0000
committerchuck <chuck@cvs.openbsd.org>1996-02-03 18:31:13 +0000
commit18fd0c22032a9c4f541172058eb56113e70ca735 (patch)
treef06b7aeedbb87ced139f36e4268119c6b75af273 /sys/arch/mvme68k/dev
parentf34705a30c83ef27acf58b47c75c736e6858247a (diff)
Ensure siop_acb alignment via malloc rather than let alignment depend
on the size of MI data structures that come before it in the softc. Chip will not function properly if alignment is wrong. Detected and fixed by: Chuck Cranor <chuck@ccrc.wustl.edu> and Michael L Hitch <osymh@gemini.oscs.montana.edu>
Diffstat (limited to 'sys/arch/mvme68k/dev')
-rw-r--r--sys/arch/mvme68k/dev/siop.c20
-rw-r--r--sys/arch/mvme68k/dev/siopvar.h5
2 files changed, 18 insertions, 7 deletions
diff --git a/sys/arch/mvme68k/dev/siop.c b/sys/arch/mvme68k/dev/siop.c
index 56fc1503d09..a4994eb792b 100644
--- a/sys/arch/mvme68k/dev/siop.c
+++ b/sys/arch/mvme68k/dev/siop.c
@@ -1,4 +1,4 @@
-/* $Id: siop.c,v 1.3 1995/11/30 09:51:26 deraadt Exp $ */
+/* $Id: siop.c,v 1.4 1996/02/03 18:31:10 chuck Exp $ */
/*
* Copyright (c) 1994 Michael L. Hitch
@@ -49,6 +49,7 @@
#include <sys/disklabel.h>
#include <sys/dkstat.h>
#include <sys/buf.h>
+#include <sys/malloc.h>
#include <scsi/scsi_all.h>
#include <scsi/scsiconf.h>
#include <machine/autoconf.h>
@@ -483,11 +484,20 @@ siopinitialize(sc)
{
/*
* Need to check that scripts is on a long word boundary
- * and that DS is on a long word boundary.
* Also should verify that dev doesn't span non-contiguous
* physical pages.
*/
sc->sc_scriptspa = kvtop(scripts);
+
+ /*
+ * malloc sc_acb to ensure that DS is on a long word boundary.
+ */
+
+ MALLOC(sc->sc_acb, struct siop_acb *,
+ sizeof(struct siop_acb) * SIOP_NACB, M_DEVBUF, M_NOWAIT);
+ if (sc->sc_acb == NULL)
+ panic("siopinitialize: ACB malloc failed!");
+
sc->sc_tcp[1] = 1000 / sc->sc_clock_freq;
sc->sc_tcp[2] = 1500 / sc->sc_clock_freq;
sc->sc_tcp[3] = 2000 / sc->sc_clock_freq;
@@ -574,8 +584,8 @@ siopreset(sc)
TAILQ_INIT(&sc->free_list);
sc->sc_nexus = NULL;
acb = sc->sc_acb;
- bzero(acb, sizeof(sc->sc_acb));
- for (i = 0; i < sizeof(sc->sc_acb) / sizeof(*acb); i++) {
+ bzero(acb, sizeof(struct siop_acb) * SIOP_NACB);
+ for (i = 0; i < SIOP_NACB; i++) {
TAILQ_INSERT_TAIL(&sc->free_list, acb, chain);
acb++;
}
@@ -737,7 +747,7 @@ siop_start (sc, target, lun, cbuf, clen, buf, len)
#endif
/* push data cache for all data the 53c710 needs to access */
- dma_cachectl (sc, sizeof (struct siop_softc));
+ dma_cachectl (acb, sizeof (struct siop_acb));
dma_cachectl (cbuf, clen);
if (buf != NULL && len != 0)
dma_cachectl (buf, len);
diff --git a/sys/arch/mvme68k/dev/siopvar.h b/sys/arch/mvme68k/dev/siopvar.h
index f028eb65e74..8121be8ff93 100644
--- a/sys/arch/mvme68k/dev/siopvar.h
+++ b/sys/arch/mvme68k/dev/siopvar.h
@@ -1,4 +1,4 @@
-/* $Id: siopvar.h,v 1.2 1995/11/07 08:49:34 deraadt Exp $ */
+/* $Id: siopvar.h,v 1.3 1996/02/03 18:31:12 chuck Exp $ */
/*
* Copyright (c) 1995 Theo de Raadt
@@ -143,7 +143,8 @@ struct siop_softc {
nexus_list;
struct siop_acb *sc_nexus; /* current command */
- struct siop_acb sc_acb[8]; /* the real command blocks */
+#define SIOP_NACB 8
+ struct siop_acb *sc_acb; /* the real command blocks */
struct siop_tinfo sc_tinfo[8];
u_short sc_clock_freq;