- Don't use our own private endian conversion cruft (from OpenBSD).

- SmartRAID V is not and will never be an EATA board (from OpenBSD).
- Use dpt_outl() when issuing EATA command packet address to HBA.
- Fix a style nit.
- Fix a typo.
This commit is contained in:
ad 1999-11-29 15:04:23 +00:00
parent 0daccde651
commit 4763c00196
2 changed files with 23 additions and 49 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dpt.c,v 1.12 1999/10/23 16:26:33 ad Exp $ */
/* $NetBSD: dpt.c,v 1.13 1999/11/29 15:04:23 ad Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dpt.c,v 1.12 1999/10/23 16:26:33 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: dpt.c,v 1.13 1999/11/29 15:04:23 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -78,8 +78,8 @@ __KERNEL_RCSID(0, "$NetBSD: dpt.c,v 1.12 1999/10/23 16:26:33 ad Exp $");
#include <sys/queue.h>
#include <sys/proc.h>
#include <sys/buf.h>
#include <sys/endian.h>
#include <machine/endian.h>
#include <machine/bswap.h>
#include <machine/bus.h>
@ -99,13 +99,6 @@ static struct scsipi_device dpt_dev = {
};
static char *dpt_cname[] = {
#ifdef notdef
"PM3755", "SmartRAID V",
"PM3754", "SmartRAID V",
"PM2654", "SmartRAID V",
"PM2554", "SmartRAID V",
"PM1554", "SmartRAID V",
#endif
"PM3334", "SmartRAID IV",
"PM3332", "SmartRAID IV",
"PM2144", "SmartCache IV",
@ -246,7 +239,7 @@ dpt_init(sc, intrstr)
ec = &sc->sc_ec;
/* Allocate the CCB/status packet/scratch DMA map and load */
sc->sc_nccbs = min(SWAP16(*(int16_t *)ec->ec_queuedepth), DPT_MAX_CCBS);
sc->sc_nccbs = min(be16toh(*(int16_t *)ec->ec_queuedepth), DPT_MAX_CCBS);
sc->sc_spoff = sc->sc_nccbs * sizeof(struct dpt_ccb);
sc->sc_scroff = sc->sc_spoff + sizeof(struct eata_sp);
sc->sc_scrlen = 256; /* XXX */
@ -411,10 +404,7 @@ dpt_cmd(sc, cp, addr, eatacmd, icmd)
if (cp == NULL)
addr = 0;
dpt_outb(sc, HA_DMA_BASE + 0, (u_int32_t)addr);
dpt_outb(sc, HA_DMA_BASE + 1, (u_int32_t)addr >> 8);
dpt_outb(sc, HA_DMA_BASE + 2, (u_int32_t)addr >> 16);
dpt_outb(sc, HA_DMA_BASE + 3, (u_int32_t)addr >> 24);
dpt_outl(sc, HA_DMA_BASE, (u_int32_t)addr);
if (eatacmd == CP_IMMEDIATE) {
if (cp == NULL) {
@ -907,7 +897,7 @@ dpt_scsi_cmd(xs)
cp->cp_lun = sc_link->scsipi_scsi.lun;
cp->cp_channel = sc_link->scsipi_scsi.channel;
cp->cp_senselen = sizeof(ccb->ccb_sense);
cp->cp_stataddr = SWAP32(sc->sc_sppa);
cp->cp_stataddr = htobe32(sc->sc_sppa);
cp->cp_dispri = 1;
cp->cp_identify = 1;
cp->cp_autosense = 1;
@ -922,10 +912,10 @@ dpt_scsi_cmd(xs)
else
cp->cp_nocache = 0;
cp->cp_senseaddr = SWAP32(sc->sc_dmamap_ccb->dm_segs[0].ds_addr +
cp->cp_senseaddr = htobe32(sc->sc_dmamap_ccb->dm_segs[0].ds_addr +
CCB_OFF(sc, ccb) + offsetof(struct dpt_ccb, ccb_sense));
if (xs->datalen) {
if (xs->datalen != 0) {
xfer = ccb->ccb_dmamap_xfer;
#ifdef TFS
if ((flags & XS_CTL_DATA_UIO) != 0) {
@ -958,8 +948,8 @@ dpt_scsi_cmd(xs)
/* Don't bother using scatter/gather for just 1 segment */
if (xfer->dm_nsegs == 1) {
cp->cp_dataaddr = SWAP32(xfer->dm_segs[0].ds_addr);
cp->cp_datalen = SWAP32(xfer->dm_segs[0].ds_len);
cp->cp_dataaddr = htobe32(xfer->dm_segs[0].ds_addr);
cp->cp_datalen = htobe32(xfer->dm_segs[0].ds_len);
cp->cp_scatter = 0;
} else {
/*
@ -968,13 +958,13 @@ dpt_scsi_cmd(xs)
*/
sg = ccb->ccb_sg;
for (i = 0; i < xfer->dm_nsegs; i++, sg++) {
sg->sg_addr = SWAP32(xfer->dm_segs[i].ds_addr);
sg->sg_len = SWAP32(xfer->dm_segs[i].ds_len);
sg->sg_addr = htobe32(xfer->dm_segs[i].ds_addr);
sg->sg_len = htobe32(xfer->dm_segs[i].ds_len);
}
cp->cp_dataaddr = SWAP32(CCB_OFF(sc, ccb) +
cp->cp_dataaddr = htobe32(CCB_OFF(sc, ccb) +
sc->sc_dmamap_ccb->dm_segs[0].ds_addr +
offsetof(struct dpt_ccb, ccb_sg));
cp->cp_datalen = SWAP32(i * sizeof(struct eata_sg));
cp->cp_datalen = htobe32(i * sizeof(struct eata_sg));
cp->cp_scatter = 1;
}
} else {
@ -1118,7 +1108,7 @@ dpt_hba_inquire(sc, ei)
cp->cp_lun = 0;
cp->cp_channel = 0;
cp->cp_senselen = sizeof(ccb->ccb_sense);
cp->cp_stataddr = SWAP32(sc->sc_sppa);
cp->cp_stataddr = htobe32(sc->sc_sppa);
cp->cp_dispri = 1;
cp->cp_identify = 1;
cp->cp_autosense = 0;
@ -1127,8 +1117,8 @@ dpt_hba_inquire(sc, ei)
cp->cp_datain = 1;
cp->cp_dataout = 0;
cp->cp_senseaddr = 0;
cp->cp_dataaddr = SWAP32(sc->sc_scrpa);
cp->cp_datalen = SWAP32(sizeof(struct eata_inquiry_data));
cp->cp_dataaddr = htobe32(sc->sc_scrpa);
cp->cp_datalen = htobe32(sizeof(struct eata_inquiry_data));
cp->cp_scatter = 0;
/* Put together the SCSI inquiry command */

View File

@ -1,4 +1,4 @@
/* $NetBSD: dptreg.h,v 1.4 1999/10/19 20:16:48 ad Exp $ */
/* $NetBSD: dptreg.h,v 1.5 1999/11/29 15:04:23 ad Exp $ */
/*
* Copyright (c) 1999 Andy Doran <ad@NetBSD.org>
@ -44,35 +44,19 @@
#ifdef _KERNEL
#if BYTE_ORDER == LITTLE_ENDIAN
#define SWAP32(x) bswap32((x))
#define SWAP16(x) bswap16((x))
#define RSWAP32(x) (x)
#define RSWAP16(x) (x)
#else
#define SWAP32(x) (x)
#define SWAP16(x) (x)
#define RSWAP32(x) bswap32((x))
#define RSWAP16(x) bswap16((x))
#endif
#define dpt_inb(x, o) \
bus_space_read_1((x)->sc_iot, (x)->sc_ioh, (o))
#define dpt_inw(x, o) \
RSWAP16(bus_space_read_2((x)->sc_iot, (x)->sc_ioh, (o)))
le16toh(bus_space_read_2((x)->sc_iot, (x)->sc_ioh, (o)))
#define dpt_inl(x, o) \
RSWAP32(bus_space_read_4((x)->sc_iot, (x)->sc_ioh, (o)))
le32toh(bus_space_read_4((x)->sc_iot, (x)->sc_ioh, (o)))
#define dpt_outb(x, o, d) \
bus_space_write_1((x)->sc_iot, (x)->sc_ioh, (o), (d))
#define dpt_outw(x, o, d) \
bus_space_write_2((x)->sc_iot, (x)->sc_ioh, (o), RSWAP16(d))
bus_space_write_2((x)->sc_iot, (x)->sc_ioh, (o), htole16(d))
#define dpt_outl(x, o, d) \
bus_space_write_4((x)->sc_iot, (x)->sc_ioh, (o), RSWAP32(d))
bus_space_write_4((x)->sc_iot, (x)->sc_ioh, (o), htole32(d))
#endif /* _KERNEL */
@ -87,7 +71,7 @@
#define HA_ICMD_CODE1 (HA_BASE + 5)
#define HA_ICMD (HA_BASE + 6)
/* EATA commands. There are many more the we don't define or use. */
/* EATA commands. There are many more that we don't define or use. */
#define HA_COMMAND (HA_BASE + 7)
#define CP_PIO_GETCFG 0xf0 /* Read configuration data, PIO */
#define CP_PIO_CMD 0xf2 /* Execute command, PIO */