From: chuck Date: Sat, 3 Feb 1996 18:32:57 +0000 (+0000) Subject: Ensure siop_acb alignment via malloc rather than let alignment depend X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2c5e50477e09f8a6c721f97b3dfb56b4ba5ca2bf;p=openbsd 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 and Michael L Hitch --- diff --git a/sys/arch/amiga/dev/siop.c b/sys/arch/amiga/dev/siop.c index ebbd360fbe8..a572aef9390 100644 --- a/sys/arch/amiga/dev/siop.c +++ b/sys/arch/amiga/dev/siop.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -531,11 +532,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; @@ -640,8 +650,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++; } @@ -803,7 +813,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/amiga/dev/siopvar.h b/sys/arch/amiga/dev/siopvar.h index ae86c41b0c1..b4c55e4e84a 100644 --- a/sys/arch/amiga/dev/siopvar.h +++ b/sys/arch/amiga/dev/siopvar.h @@ -141,7 +141,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;