summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authortsutsui <tsutsui@NetBSD.org>1999-12-26 10:41:22 +0000
committertsutsui <tsutsui@NetBSD.org>1999-12-26 10:41:22 +0000
commitf1a6ac445d569d84c0655cee9a2b01ff543e9af4 (patch)
treeddab3feebff20218cc1f938ddf072fa5e9d8ff36 /sys/dev
parentd56fffdd70cf9d9065f5f93cd9c9bc44ba3e1a06 (diff)
Use htole32() and le32toh() instead of SCR_BO().
XXX Should we still keep non-NetBSD part?
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/ncr.c146
-rw-r--r--sys/dev/pci/ncrreg.h8
2 files changed, 74 insertions, 80 deletions
diff --git a/sys/dev/pci/ncr.c b/sys/dev/pci/ncr.c
index 9b4d0c10205..cd8da1ad833 100644
--- a/sys/dev/pci/ncr.c
+++ b/sys/dev/pci/ncr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ncr.c,v 1.92 1999/12/20 03:37:06 tsutsui Exp $ */
+/* $NetBSD: ncr.c,v 1.93 1999/12/26 10:41:22 tsutsui Exp $ */
/**************************************************************************
**
@@ -342,16 +342,16 @@
bus_space_write_4 (np->sc_st, np->sc_sh, (o), (val))
#define READSCRIPT_OFF(base, off) \
- SCR_BO(base ? *((INT32 *)((char *)base + (off))) : \
+ le32toh(base ? *((INT32 *)((char *)base + (off))) : \
bus_space_read_stream_4(np->ram_tag, np->ram_handle, off))
#define WRITESCRIPT_OFF(base, off, val) \
do { \
if (base) \
- *((INT32 *)((char *)base + (off))) = (SCR_BO(val)); \
+ *((INT32 *)((char *)base + (off))) = (htole32(val)); \
else \
bus_space_write_stream_4(np->ram_tag, np->ram_handle, \
- off, SCR_BO(val)); \
+ off, htole32(val)); \
} while (0)
#define READSCRIPT(r) \
@@ -1524,7 +1524,7 @@ static int read_tekram_eeprom
#if 0
static char ident[] =
- "\n$NetBSD: ncr.c,v 1.92 1999/12/20 03:37:06 tsutsui Exp $\n";
+ "\n$NetBSD: ncr.c,v 1.93 1999/12/26 10:41:22 tsutsui Exp $\n";
#endif
static const u_long ncr_version = NCR_VERSION * 11
@@ -4280,8 +4280,8 @@ static void ncr_attach (pcici_t config_id, int unit)
** init data structure
*/
- np->ncb_dma->jump_tcb.l_cmd = SCR_BO(SCR_JUMP);
- np->ncb_dma->jump_tcb.l_paddr = SCR_BO(NCB_SCRIPTH_PHYS (np, abort));
+ np->ncb_dma->jump_tcb.l_cmd = htole32(SCR_JUMP);
+ np->ncb_dma->jump_tcb.l_paddr = htole32(NCB_SCRIPTH_PHYS (np, abort));
/*
** Get SCSI addr of host adapter (set by bios?).
@@ -4845,14 +4845,14 @@ static INT32 ncr_start (struct scsipi_xfer * xp)
if (flags & XS_CTL_DATA_IN) {
bus_addr_t sp = NCB_SCRIPT_PHYS (np, data_in);
- cp->phys.header.savep = SCR_BO(sp);
- cp->phys.header.goalp = SCR_BO(sp + 20 + segments * 16);
+ cp->phys.header.savep = htole32(sp);
+ cp->phys.header.goalp = htole32(sp + 20 + segments * 16);
} else if (flags & XS_CTL_DATA_OUT) {
bus_addr_t sp = NCB_SCRIPT_PHYS (np, data_out);
- cp->phys.header.savep = SCR_BO(sp);
- cp->phys.header.goalp = SCR_BO(sp + 20 + segments * 16);
+ cp->phys.header.savep = htole32(sp);
+ cp->phys.header.goalp = htole32(sp + 20 + segments * 16);
} else {
- cp->phys.header.savep = SCR_BO(NCB_SCRIPT_PHYS (np, no_data));
+ cp->phys.header.savep = htole32(NCB_SCRIPT_PHYS (np, no_data));
cp->phys.header.goalp = cp->phys.header.savep;
};
cp->phys.header.lastp = cp->phys.header.savep;
@@ -4881,8 +4881,8 @@ static INT32 ncr_start (struct scsipi_xfer * xp)
/*
** Startqueue
*/
- cp->phys.header.launch.l_paddr = SCR_BO(NCB_SCRIPT_PHYS (np, select));
- cp->phys.header.launch.l_cmd = SCR_BO(SCR_JUMP);
+ cp->phys.header.launch.l_paddr = htole32(NCB_SCRIPT_PHYS (np, select));
+ cp->phys.header.launch.l_cmd = htole32(SCR_JUMP);
/*
** select
*/
@@ -4892,21 +4892,21 @@ static INT32 ncr_start (struct scsipi_xfer * xp)
/*
** message
*/
- cp->phys.smsg.addr = SCR_BO(CCB_PHYS (cp, scsi_smsg));
- cp->phys.smsg.size = SCR_BO(msglen);
+ cp->phys.smsg.addr = htole32(CCB_PHYS (cp, scsi_smsg));
+ cp->phys.smsg.size = htole32(msglen);
- cp->phys.smsg2.addr = SCR_BO(CCB_PHYS (cp, scsi_smsg2));
- cp->phys.smsg2.size = SCR_BO(msglen2);
+ cp->phys.smsg2.addr = htole32(CCB_PHYS (cp, scsi_smsg2));
+ cp->phys.smsg2.size = htole32(msglen2);
/*
** command
*/
- cp->phys.cmd.addr = SCR_BO(CCB_PHYS (cp, scsi_cmd));
- cp->phys.cmd.size = SCR_BO(xp->cmdlen);
+ cp->phys.cmd.addr = htole32(CCB_PHYS (cp, scsi_cmd));
+ cp->phys.cmd.size = htole32(xp->cmdlen);
/*
** sense command
*/
- cp->phys.scmd.addr = SCR_BO(CCB_PHYS (cp, sensecmd));
- cp->phys.scmd.size = SCR_BO(6);
+ cp->phys.scmd.addr = htole32(CCB_PHYS (cp, sensecmd));
+ cp->phys.scmd.size = htole32(6);
/*
** patch requested size into sense command
*/
@@ -4918,8 +4918,8 @@ static INT32 ncr_start (struct scsipi_xfer * xp)
/*
** sense data
*/
- cp->phys.sense.addr = SCR_BO(CCB_PHYS (cp, sense_data));
- cp->phys.sense.size = SCR_BO(sizeof(struct scsipi_sense_data));
+ cp->phys.sense.addr = htole32(CCB_PHYS (cp, sense_data));
+ cp->phys.sense.size = htole32(sizeof(struct scsipi_sense_data));
/*
** status
*/
@@ -4944,7 +4944,7 @@ static INT32 ncr_start (struct scsipi_xfer * xp)
** reselect pattern and activate this job.
*/
- cp->jump_ccb.l_cmd = SCR_BO((SCR_JUMP ^ IFFALSE (DATA (cp->tag))));
+ cp->jump_ccb.l_cmd = htole32(SCR_JUMP ^ IFFALSE (DATA (cp->tag)));
#ifdef __NetBSD__
cp->tlimit = mono_time.tv_sec + xp->timeout / 1000 + 2;
#else
@@ -4958,8 +4958,8 @@ static INT32 ncr_start (struct scsipi_xfer * xp)
qidx = np->squeueput + 1;
if (qidx >= MAX_START) qidx=0;
- np->ncb_dma->squeue [qidx ] = SCR_BO(NCB_SCRIPT_PHYS (np, idle));
- np->ncb_dma->squeue [np->squeueput] = SCR_BO(CCB_PHYS (cp, phys));
+ np->ncb_dma->squeue [qidx ] = htole32(NCB_SCRIPT_PHYS (np, idle));
+ np->ncb_dma->squeue [np->squeueput] = htole32(CCB_PHYS (cp, phys));
np->squeueput = qidx;
if(DEBUG_FLAGS & DEBUG_QUEUE)
@@ -5070,12 +5070,12 @@ void ncr_complete (ncb_p np, ccb_p cp)
/*
** No Reselect anymore.
*/
- cp->jump_ccb.l_cmd = SCR_BO((SCR_JUMP));
+ cp->jump_ccb.l_cmd = htole32(SCR_JUMP);
/*
** No starting.
*/
- cp->phys.header.launch.l_paddr= SCR_BO(NCB_SCRIPT_PHYS (np, idle));
+ cp->phys.header.launch.l_paddr= htole32(NCB_SCRIPT_PHYS (np, idle));
/*
** timestamp
@@ -5397,7 +5397,7 @@ void ncr_init (ncb_p np, char * msg, u_long code)
*/
for (i=0;i<MAX_START;i++)
- np -> ncb_dma -> squeue [i] = SCR_BO(NCB_SCRIPT_PHYS (np, idle));
+ np -> ncb_dma -> squeue [i] = htole32(NCB_SCRIPT_PHYS (np, idle));
/*
** Start at first entry.
@@ -6000,13 +6000,13 @@ static void ncr_timeout (void *arg)
** Disable reselect.
** Remove it from startqueue.
*/
- cp->jump_ccb.l_cmd = SCR_BO((SCR_JUMP));
+ cp->jump_ccb.l_cmd = htole32(SCR_JUMP);
if (cp->phys.header.launch.l_paddr ==
- SCR_BO(NCB_SCRIPT_PHYS (np, select))) {
+ htole32(NCB_SCRIPT_PHYS (np, select))) {
printf ("%s: timeout ccb=%p (skip)\n",
ncr_name (np), cp);
cp->phys.header.launch.l_paddr
- = SCR_BO(NCB_SCRIPT_PHYS (np, skip));
+ = htole32(NCB_SCRIPT_PHYS (np, skip));
};
switch (cp->host_status) {
@@ -6017,7 +6017,7 @@ static void ncr_timeout (void *arg)
** still in start queue ?
*/
if (cp->phys.header.launch.l_paddr ==
- SCR_BO(NCB_SCRIPT_PHYS (np, skip)))
+ htole32(NCB_SCRIPT_PHYS (np, skip)))
continue;
/* fall through */
@@ -6611,8 +6611,8 @@ static void ncr_int_ma (ncb_p np, u_char dstat)
if (cmd & 0x10) { /* Table indirect */
tblp = (u_int32_t *) ((char*) &cp->phys + oadr);
- olen = SCR_BO(tblp[0]);
- oadr = SCR_BO(tblp[1]);
+ olen = le32toh(tblp[0]);
+ oadr = le32toh(tblp[1]);
} else {
tblp = (u_int32_t *) 0;
olen = READSCRIPT_OFF(vdsp_base, vdsp_off) & 0xffffff;
@@ -6654,25 +6654,25 @@ static void ncr_int_ma (ncb_p np, u_char dstat)
*/
newcmd = cp->patch;
- if (cp->phys.header.savep == SCR_BO(vtophys (newcmd))) newcmd+=4;
+ if (cp->phys.header.savep == htole32(vtophys (newcmd))) newcmd+=4;
/*
** fillin the commands
*/
- newcmd[0] = SCR_BO(((cmd & 0x0f) << 24) | rest);
- newcmd[1] = SCR_BO(oadr + olen - rest);
- newcmd[2] = SCR_BO(SCR_JUMP);
- newcmd[3] = SCR_BO(nxtdsp);
+ newcmd[0] = htole32(((cmd & 0x0f) << 24) | rest);
+ newcmd[1] = htole32(oadr + olen - rest);
+ newcmd[2] = htole32(SCR_JUMP);
+ newcmd[3] = htole32(nxtdsp);
if (DEBUG_FLAGS & DEBUG_PHASE) {
PRINT_ADDR(cp->xfer);
printf ("newcmd[%ld] %x %x %x %x.\n",
(long)(newcmd - cp->patch),
- (unsigned)SCR_BO(newcmd[0]),
- (unsigned)SCR_BO(newcmd[1]),
- (unsigned)SCR_BO(newcmd[2]),
- (unsigned)SCR_BO(newcmd[3]));
+ (unsigned)le32toh(newcmd[0]),
+ (unsigned)le32toh(newcmd[1]),
+ (unsigned)le32toh(newcmd[2]),
+ (unsigned)le32toh(newcmd[3]));
}
/*
** fake the return address (to the patch).
@@ -7211,8 +7211,8 @@ void ncr_int_sir (ncb_p np)
printf ("M_DISCONNECT received, but datapointer not saved:\n"
"\tdata=%x save=%x goal=%x.\n",
(unsigned) INL (nc_temp),
- SCR_BO((unsigned) np->ncb_dma->header.savep),
- SCR_BO((unsigned) np->ncb_dma->header.goalp));
+ le32toh((unsigned) np->ncb_dma->header.savep),
+ le32toh((unsigned) np->ncb_dma->header.goalp));
break;
/*--------------------------------------------------------------------
@@ -7436,28 +7436,28 @@ static void ncr_alloc_ccb (ncb_p np, u_long target, u_long lun)
/*
** initialize it.
*/
- tp->jump_tcb.l_cmd = SCR_BO((SCR_JUMP^IFFALSE (DATA (0x80 + target))));
+ tp->jump_tcb.l_cmd = htole32(SCR_JUMP^IFFALSE (DATA (0x80 + target)));
tp->jump_tcb.l_paddr = np->ncb_dma->jump_tcb.l_paddr;
tp->getscr[0] =
- (np->features & FE_PFEN)? SCR_BO(SCR_COPY(1)) : SCR_BO(SCR_COPY_F(1));
- tp->getscr[1] = SCR_BO(vtophys (&tp->sval));
- tp->getscr[2] = SCR_BO(np->paddr + offsetof (struct ncr_reg, nc_sxfer));
+ (np->features & FE_PFEN)? htole32(SCR_COPY(1)) : htole32(SCR_COPY_F(1));
+ tp->getscr[1] = htole32(vtophys (&tp->sval));
+ tp->getscr[2] = htole32(np->paddr + offsetof (struct ncr_reg, nc_sxfer));
tp->getscr[3] = tp->getscr[0];
- tp->getscr[4] = SCR_BO(vtophys (&tp->wval));
- tp->getscr[5] = SCR_BO(np->paddr + offsetof (struct ncr_reg, nc_scntl3));
+ tp->getscr[4] = htole32(vtophys (&tp->wval));
+ tp->getscr[5] = htole32(np->paddr + offsetof (struct ncr_reg, nc_scntl3));
assert (( (offsetof(struct ncr_reg, nc_sxfer) ^
offsetof(struct tcb , sval )) &3) == 0);
assert (( (offsetof(struct ncr_reg, nc_scntl3) ^
offsetof(struct tcb , wval )) &3) == 0);
- tp->call_lun.l_cmd = SCR_BO((SCR_CALL));
- tp->call_lun.l_paddr = SCR_BO(NCB_SCRIPT_PHYS (np, resel_lun));
+ tp->call_lun.l_cmd = htole32(SCR_CALL);
+ tp->call_lun.l_paddr = htole32(NCB_SCRIPT_PHYS (np, resel_lun));
- tp->jump_lcb.l_cmd = SCR_BO((SCR_JUMP));
- tp->jump_lcb.l_paddr = SCR_BO(NCB_SCRIPTH_PHYS (np, abort));
- np->ncb_dma->jump_tcb.l_paddr = SCR_BO(vtophys (&tp->jump_tcb));
+ tp->jump_lcb.l_cmd = htole32(SCR_JUMP);
+ tp->jump_lcb.l_paddr = htole32(NCB_SCRIPTH_PHYS (np, abort));
+ np->ncb_dma->jump_tcb.l_paddr = htole32(vtophys (&tp->jump_tcb));
tp->usrtags = SCSI_NCR_DFLT_TAGS;
ncr_setmaxtags (tp, tp->usrtags);
@@ -7478,21 +7478,21 @@ static void ncr_alloc_ccb (ncb_p np, u_long target, u_long lun)
** Initialize it
*/
bzero (lp, sizeof (*lp));
- lp->jump_lcb.l_cmd = SCR_BO((SCR_JUMP ^ IFFALSE (DATA (lun))));
+ lp->jump_lcb.l_cmd = htole32(SCR_JUMP ^ IFFALSE (DATA (lun)));
lp->jump_lcb.l_paddr = tp->jump_lcb.l_paddr;
- lp->call_tag.l_cmd = SCR_BO((SCR_CALL));
- lp->call_tag.l_paddr = SCR_BO(NCB_SCRIPT_PHYS (np, resel_tag));
+ lp->call_tag.l_cmd = htole32(SCR_CALL);
+ lp->call_tag.l_paddr = htole32(NCB_SCRIPT_PHYS (np, resel_tag));
- lp->jump_ccb.l_cmd = SCR_BO((SCR_JUMP));
- lp->jump_ccb.l_paddr = SCR_BO(NCB_SCRIPTH_PHYS (np, aborttag));
+ lp->jump_ccb.l_cmd = htole32(SCR_JUMP);
+ lp->jump_ccb.l_paddr = htole32(NCB_SCRIPTH_PHYS (np, aborttag));
lp->actlink = 1;
/*
** Chain into LUN list
*/
- tp->jump_lcb.l_paddr = SCR_BO(vtophys (&lp->jump_lcb));
+ tp->jump_lcb.l_paddr = htole32(vtophys (&lp->jump_lcb));
tp->lp[lun] = lp;
}
@@ -7545,11 +7545,11 @@ static void ncr_alloc_ccb (ncb_p np, u_long target, u_long lun)
/*
** Chain into reselect list
*/
- cp->jump_ccb.l_cmd = SCR_BO(SCR_JUMP);
+ cp->jump_ccb.l_cmd = htole32(SCR_JUMP);
cp->jump_ccb.l_paddr = lp->jump_ccb.l_paddr;
- lp->jump_ccb.l_paddr = SCR_BO(CCB_PHYS (cp, jump_ccb));
- cp->call_tmp.l_cmd = SCR_BO(SCR_CALL);
- cp->call_tmp.l_paddr = SCR_BO(NCB_SCRIPT_PHYS (np, resel_tmp));
+ lp->jump_ccb.l_paddr = htole32(CCB_PHYS (cp, jump_ccb));
+ cp->call_tmp.l_cmd = htole32(SCR_CALL);
+ cp->call_tmp.l_paddr = htole32(NCB_SCRIPT_PHYS (np, resel_tmp));
/*
** Chain into wakeup list
@@ -7660,9 +7660,9 @@ static int ncr_scatter
for (segment = 0; segment < cp->xfer_dmamap->dm_nsegs; segment++) {
phys->data[segment].addr =
- SCR_BO(cp->xfer_dmamap->dm_segs[segment].ds_addr);
+ htole32(cp->xfer_dmamap->dm_segs[segment].ds_addr);
phys->data[segment].size =
- SCR_BO(cp->xfer_dmamap->dm_segs[segment].ds_len);
+ htole32(cp->xfer_dmamap->dm_segs[segment].ds_len);
}
return (segment);
#else
@@ -7827,7 +7827,7 @@ static int ncr_snooptest (struct ncb* np)
** Set memory and register.
*/
ncr_cache = host_wr;
- OUTL (nc_temp, SCR_BO(ncr_wr)); /* XXX XXX XXX BOGUS SCR_BO */
+ OUTL (nc_temp, htole32(ncr_wr)); /* XXX XXX XXX BOGUS htole32 */
/*
** Start script (exchange values)
*/
@@ -7846,8 +7846,8 @@ static int ncr_snooptest (struct ncb* np)
** Read memory and register.
*/
host_rd = ncr_cache;
- ncr_rd = SCR_BO(INL (nc_scratcha)); /* XXX XXX XXX BOGUS SCR_BO */
- ncr_bk = SCR_BO(INL (nc_temp)); /* XXX XXX XXX BOGUS SCR_BO */
+ ncr_rd = le32toh(INL (nc_scratcha)); /* XXX XXX XXX BOGUS le32toh */
+ ncr_bk = le32toh(INL (nc_temp)); /* XXX XXX XXX BOGUS le32toh */
/*
** Reset ncr chip
*/
diff --git a/sys/dev/pci/ncrreg.h b/sys/dev/pci/ncrreg.h
index bc04d579bbc..661a373147c 100644
--- a/sys/dev/pci/ncrreg.h
+++ b/sys/dev/pci/ncrreg.h
@@ -1,4 +1,4 @@
-/* $NetBSD: ncrreg.h,v 1.16 1999/12/18 07:57:03 tsutsui Exp $ */
+/* $NetBSD: ncrreg.h,v 1.17 1999/12/26 10:41:23 tsutsui Exp $ */
/**************************************************************************
**
@@ -293,12 +293,6 @@ struct ncr_reg {
typedef U_INT32 ncrcmd;
-#if BYTE_ORDER == BIG_ENDIAN
-#define SCR_BO(x) bswap32(x)
-#else
-#define SCR_BO(x) (x)
-#endif
-
/*-----------------------------------------------------------
**
** SCSI phases