Split byte packing functions into signed and unsigned versions.
Left most current invocations as signed, though that could be wrong.
This commit is contained in:
parent
5902fd25c2
commit
331e8d8b9c
@ -12,7 +12,7 @@
|
||||
* on the understanding that TFS is not responsible for the correct
|
||||
* functioning of this software in any circumstances.
|
||||
*
|
||||
* $Id: aha1542.c,v 1.39 1995/01/08 13:41:28 dufault Exp $
|
||||
* $Id: aha1542.c,v 1.40 1995/01/19 12:33:10 dufault Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -676,7 +676,7 @@ ahaintr(unit)
|
||||
for (i = 0; i < AHA_MBX_SIZE; i++) {
|
||||
if (aha->aha_mbx.mbi[i].stat != AHA_MBI_FREE) {
|
||||
ccb = (struct aha_ccb *) PHYSTOKV(
|
||||
(_3btol(aha->aha_mbx.mbi[i].ccb_addr)));
|
||||
(scsi_3btou(aha->aha_mbx.mbi[i].ccb_addr)));
|
||||
|
||||
if ((stat = aha->aha_mbx.mbi[i].stat) != AHA_MBI_OK) {
|
||||
switch (stat) {
|
||||
@ -834,14 +834,14 @@ aha_done(unit, ccb)
|
||||
switch(ccb->opcode)
|
||||
{
|
||||
case AHA_TARGET_CCB:
|
||||
xs->resid = xs->datalen - _3btol(ccb->data_length);
|
||||
xs->resid = xs->datalen - scsi_3btoi(ccb->data_length);
|
||||
if (xs->resid <= 0)
|
||||
xs->error = XS_LENGTH;
|
||||
break;
|
||||
|
||||
case AHA_INIT_RESID_CCB:
|
||||
case AHA_INIT_SG_RESID_CCB:
|
||||
xs->resid = _3btol(ccb->data_length);
|
||||
xs->resid = scsi_3btoi(ccb->data_length);
|
||||
if (xs->resid <= 0)
|
||||
xs->error = XS_LENGTH;
|
||||
printf("aha over under: resid %d error %d.\n",
|
||||
@ -1092,7 +1092,7 @@ aha_init(unit)
|
||||
/*
|
||||
* Initialize mail box
|
||||
*/
|
||||
lto3b(KVTOPHYS(&aha->aha_mbx), ad);
|
||||
scsi_uto3b(KVTOPHYS(&aha->aha_mbx), ad);
|
||||
|
||||
aha_cmd(unit, 4, 0, 0, 0, AHA_MBX_INIT,
|
||||
AHA_MBX_SIZE,
|
||||
@ -1110,7 +1110,7 @@ aha_init(unit)
|
||||
aha->aha_ccb_free = &aha->aha_ccb[i];
|
||||
aha->aha_ccb_free->flags = CCB_FREE;
|
||||
aha->aha_ccb_free->mbx = &aha->aha_mbx.mbo[i];
|
||||
lto3b(KVTOPHYS(aha->aha_ccb_free), aha->aha_mbx.mbo[i].ccb_addr);
|
||||
scsi_uto3b(KVTOPHYS(aha->aha_ccb_free), aha->aha_mbx.mbo[i].ccb_addr);
|
||||
}
|
||||
/*
|
||||
* Note that we are going and return (to probe)
|
||||
@ -1193,7 +1193,7 @@ aha_scsi_cmd(xs)
|
||||
|
||||
if ((xs->datalen) && (!(flags & SCSI_RESET))) {
|
||||
/* can use S/G only if not zero length */
|
||||
lto3b(KVTOPHYS(ccb->scat_gath), ccb->data_addr);
|
||||
scsi_uto3b(KVTOPHYS(ccb->scat_gath), ccb->data_addr);
|
||||
sg = ccb->scat_gath;
|
||||
seg = 0;
|
||||
#ifdef TFS_ONLY
|
||||
@ -1201,8 +1201,8 @@ aha_scsi_cmd(xs)
|
||||
iovp = ((struct uio *) xs->data)->uio_iov;
|
||||
datalen = ((struct uio *) xs->data)->uio_iovcnt;
|
||||
while ((datalen) && (seg < AHA_NSEG)) {
|
||||
lto3b(iovp->iov_base, sg->seg_addr);
|
||||
lto3b(iovp->iov_len, sg->seg_len);
|
||||
scsi_uto3b(iovp->iov_base, sg->seg_addr);
|
||||
scsi_uto3b(iovp->iov_len, sg->seg_len);
|
||||
SC_DEBUGN(xs->sc_link, SDEV_DB4, ("UIO(0x%x@0x%x)"
|
||||
,iovp->iov_len
|
||||
,iovp->iov_base));
|
||||
@ -1228,7 +1228,7 @@ aha_scsi_cmd(xs)
|
||||
bytes_this_seg = 0;
|
||||
|
||||
/* put in the base address */
|
||||
lto3b(thisphys, sg->seg_addr);
|
||||
scsi_uto3b(thisphys, sg->seg_addr);
|
||||
|
||||
SC_DEBUGN(xs->sc_link, SDEV_DB4,
|
||||
("0x%x", thisphys));
|
||||
@ -1271,12 +1271,12 @@ aha_scsi_cmd(xs)
|
||||
*/
|
||||
SC_DEBUGN(xs->sc_link, SDEV_DB4,
|
||||
("(0x%x)", bytes_this_seg));
|
||||
lto3b(bytes_this_seg, sg->seg_len);
|
||||
scsi_uto3b(bytes_this_seg, sg->seg_len);
|
||||
sg++;
|
||||
seg++;
|
||||
}
|
||||
}
|
||||
lto3b(seg * sizeof(struct aha_scat_gath), ccb->data_length);
|
||||
scsi_uto3b(seg * sizeof(struct aha_scat_gath), ccb->data_length);
|
||||
SC_DEBUGN(xs->sc_link, SDEV_DB4, ("\n"));
|
||||
|
||||
if (datalen) { /* there's still data, must have run out of segs! */
|
||||
@ -1287,10 +1287,10 @@ aha_scsi_cmd(xs)
|
||||
return (HAD_ERROR);
|
||||
}
|
||||
} else { /* No data xfer, use non S/G values */
|
||||
lto3b(0, ccb->data_addr);
|
||||
lto3b(0, ccb->data_length);
|
||||
scsi_uto3b(0, ccb->data_addr);
|
||||
scsi_uto3b(0, ccb->data_length);
|
||||
}
|
||||
lto3b(0, ccb->link_addr);
|
||||
scsi_uto3b(0, ccb->link_addr);
|
||||
/*
|
||||
* Put the scsi command in the ccb and start it
|
||||
*/
|
||||
@ -1486,7 +1486,7 @@ aha_bus_speed_check(unit, speed)
|
||||
* put the test data into the buffer and calculate
|
||||
* it's address. Read it onto the board
|
||||
*/
|
||||
lto3b(KVTOPHYS(aha_scratch_buf), ad);
|
||||
scsi_uto3b(KVTOPHYS(aha_scratch_buf), ad);
|
||||
for(loopcount = 2000;loopcount;loopcount--)
|
||||
{
|
||||
strcpy(aha_scratch_buf, aha_test_string);
|
||||
|
@ -348,13 +348,13 @@ wds_scsi_cmd(struct scsi_xfer *sxp)
|
||||
return TRY_AGAIN_LATER;
|
||||
}
|
||||
|
||||
lto3b(KVTOPHYS(&r->cmd),wds[unit].ombs[r->ombn].addr);
|
||||
scsi_uto3b(KVTOPHYS(&r->cmd),wds[unit].ombs[r->ombn].addr);
|
||||
|
||||
bzero(&r->cmd, sizeof r->cmd);
|
||||
r->cmd.cmd = WDSX_SCSICMD;
|
||||
r->cmd.targ = (sxp->sc_link->target << 5) | sxp->sc_link->lun;
|
||||
bcopy(sxp->cmd, &r->cmd.scb, sxp->cmdlen<12 ? sxp->cmdlen : 12);
|
||||
lto3b(sxp->datalen, r->cmd.len);
|
||||
scsi_uto3b(sxp->datalen, r->cmd.len);
|
||||
|
||||
if(wds_data_in_use[unit])
|
||||
{
|
||||
@ -367,18 +367,18 @@ wds_scsi_cmd(struct scsi_xfer *sxp)
|
||||
if(sxp->datalen && !(sxp->flags&SCSI_DATA_IN))
|
||||
bcopy(sxp->data, wds_data[unit], sxp->datalen);
|
||||
|
||||
lto3b(sxp->datalen ? KVTOPHYS(wds_data[unit]) : 0, r->cmd.data);
|
||||
scsi_uto3b(sxp->datalen ? KVTOPHYS(wds_data[unit]) : 0, r->cmd.data);
|
||||
|
||||
r->cmd.write = (sxp->flags&SCSI_DATA_IN)? 0x80 : 0x00;
|
||||
|
||||
lto3b(KVTOPHYS(&r->sense),r->cmd.next);
|
||||
scsi_uto3b(KVTOPHYS(&r->sense),r->cmd.next);
|
||||
|
||||
bzero(&r->sense, sizeof r->sense);
|
||||
r->sense.cmd = r->cmd.cmd;
|
||||
r->sense.targ = r->cmd.targ;
|
||||
r->sense.scb[0] = REQUEST_SENSE;
|
||||
lto3b(KVTOPHYS(&sxp->sense),r->sense.data);
|
||||
lto3b(sizeof(sxp->sense), r->sense.len);
|
||||
scsi_uto3b(KVTOPHYS(&sxp->sense),r->sense.data);
|
||||
scsi_uto3b(sizeof(sxp->sense), r->sense.len);
|
||||
r->sense.write = 0x80;
|
||||
|
||||
if(sxp->flags & SCSI_NOMASK)
|
||||
@ -458,7 +458,7 @@ wdsintr(int unit)
|
||||
c = c & ~WDSI_MASK;
|
||||
in = &wds[unit].imbs[c];
|
||||
|
||||
pc = (struct wds_cmd *)_3btol(in->addr);
|
||||
pc = (struct wds_cmd *)scsi_3btou(in->addr);
|
||||
vc = (struct wds_cmd *)PHYSTOKV((long)pc);
|
||||
stat = in->stat;
|
||||
|
||||
@ -564,7 +564,7 @@ wds_getvers(int unit)
|
||||
r->done = 0;
|
||||
r->sxp = NULL;
|
||||
|
||||
lto3b(KVTOPHYS(&r->cmd), wds[unit].ombs[r->ombn].addr);
|
||||
scsi_uto3b(KVTOPHYS(&r->cmd), wds[unit].ombs[r->ombn].addr);
|
||||
|
||||
bzero(&r->cmd, sizeof r->cmd);
|
||||
r->cmd.cmd = WDSX_GETFIRMREV;
|
||||
@ -686,7 +686,7 @@ wds_init(struct isa_device *dev)
|
||||
init.scsi_id = 7;
|
||||
init.buson_t = 24;
|
||||
init.busoff_t = 48;
|
||||
lto3b(KVTOPHYS(wds[unit].ombs), init.mbaddr);
|
||||
scsi_uto3b(KVTOPHYS(wds[unit].ombs), init.mbaddr);
|
||||
init.xx = 0;
|
||||
init.nomb = WDS_NOMB;
|
||||
init.nimb = WDS_NIMB;
|
||||
|
@ -8,7 +8,7 @@
|
||||
* file.
|
||||
*
|
||||
* Written by Julian Elischer (julian@dialix.oz.au)
|
||||
* $Id: scsi_base.c,v 1.17 1995/01/19 12:41:35 dufault Exp $
|
||||
* $Id: scsi_base.c,v 1.18 1995/01/24 12:04:54 dufault Exp $
|
||||
*/
|
||||
|
||||
#define SPLSD splbio
|
||||
@ -923,8 +923,8 @@ scsi_interpret_sense(xs)
|
||||
* LSB at the highest.
|
||||
*/
|
||||
void
|
||||
lto3b(val, bytes)
|
||||
int val;
|
||||
scsi_uto3b(val, bytes)
|
||||
u_int32 val;
|
||||
u_char *bytes;
|
||||
{
|
||||
*bytes++ = (val & 0xff0000) >> 16;
|
||||
@ -933,17 +933,32 @@ lto3b(val, bytes)
|
||||
}
|
||||
|
||||
/*
|
||||
* The reverse of lto3b
|
||||
* The reverse of scsi_uto3b
|
||||
*/
|
||||
int
|
||||
_3btol(bytes)
|
||||
u_int32
|
||||
scsi_3btou(bytes)
|
||||
u_char *bytes;
|
||||
{
|
||||
u_int32 rc;
|
||||
rc = (*bytes++ << 16);
|
||||
rc += (*bytes++ << 8);
|
||||
rc += *bytes;
|
||||
return ((int) rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* scsi_3btoi: scsi_3btou for twos complement signed integers:
|
||||
*/
|
||||
int32
|
||||
scsi_3btoi(bytes)
|
||||
u_char *bytes;
|
||||
{
|
||||
u_int32 rc = scsi_3btou(bytes);
|
||||
|
||||
if (rc & 0x00800000)
|
||||
rc |= 0xff000000;
|
||||
|
||||
return (int32) rc;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
|
||||
*
|
||||
* $Id: scsiconf.h,v 1.14 1994/11/14 23:39:33 ats Exp $
|
||||
* $Id: scsiconf.h,v 1.15 1995/01/08 13:38:33 dufault Exp $
|
||||
*/
|
||||
#ifndef SCSI_SCSICONF_H
|
||||
#define SCSI_SCSICONF_H 1
|
||||
@ -342,8 +342,9 @@ void show_scsi_xs(struct scsi_xfer *xs);
|
||||
void show_scsi_cmd(struct scsi_xfer *xs);
|
||||
void show_mem(unsigned char * , u_int32);
|
||||
|
||||
void lto3b __P((int val, u_char *bytes));
|
||||
int _3btol __P((u_char *bytes));
|
||||
void scsi_uto3b __P((u_int32 val, u_char *bytes));
|
||||
u_int32 scsi_3btou __P((u_char *bytes));
|
||||
int32 scsi_3btoi __P((u_char *bytes));
|
||||
|
||||
extern void sc_print_addr(struct scsi_link *);
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992
|
||||
*
|
||||
* $Id: sd.c,v 1.48 1994/12/24 09:19:00 bde Exp $
|
||||
* $Id: sd.c,v 1.49 1995/01/08 13:38:34 dufault Exp $
|
||||
*/
|
||||
|
||||
#define SPLSD splbio
|
||||
@ -989,7 +989,7 @@ sd_get_parms(unit, flags)
|
||||
|
||||
SC_DEBUG(sd->sc_link, SDEV_DB3,
|
||||
("%d cyls, %d heads, %d precomp, %d red_write, %d land_zone\n",
|
||||
_3btol(&scsi_sense.pages.rigid_geometry.ncyl_2),
|
||||
scsi_3btou(&scsi_sense.pages.rigid_geometry.ncyl_2),
|
||||
scsi_sense.pages.rigid_geometry.nheads,
|
||||
b2tol(scsi_sense.pages.rigid_geometry.st_cyl_wp),
|
||||
b2tol(scsi_sense.pages.rigid_geometry.st_cyl_rwc),
|
||||
@ -1002,8 +1002,8 @@ sd_get_parms(unit, flags)
|
||||
* can lead to wasted space! THINK ABOUT THIS !
|
||||
*/
|
||||
disk_parms->heads = scsi_sense.pages.rigid_geometry.nheads;
|
||||
disk_parms->cyls = _3btol(&scsi_sense.pages.rigid_geometry.ncyl_2);
|
||||
disk_parms->secsiz = _3btol(scsi_sense.blk_desc.blklen);
|
||||
disk_parms->cyls = scsi_3btou(&scsi_sense.pages.rigid_geometry.ncyl_2);
|
||||
disk_parms->secsiz = scsi_3btou(scsi_sense.blk_desc.blklen);
|
||||
|
||||
sectors = sd_size(unit, flags);
|
||||
disk_parms->disksize = sectors;
|
||||
|
@ -12,7 +12,7 @@
|
||||
* on the understanding that TFS is not responsible for the correct
|
||||
* functioning of this software in any circumstances.
|
||||
*
|
||||
* $Id: st.c,v 1.24 1995/01/08 13:38:36 dufault Exp $
|
||||
* $Id: st.c,v 1.25 1995/01/24 12:04:56 dufault Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -1156,9 +1156,9 @@ ststart(unit)
|
||||
*/
|
||||
if (st->flags & ST_FIXEDBLOCKS) {
|
||||
cmd.byte2 |= SRWT_FIXED;
|
||||
lto3b(bp->b_bcount / st->blksiz, cmd.len);
|
||||
scsi_uto3b(bp->b_bcount / st->blksiz, cmd.len);
|
||||
} else {
|
||||
lto3b(bp->b_bcount, cmd.len);
|
||||
scsi_uto3b(bp->b_bcount, cmd.len);
|
||||
}
|
||||
/*
|
||||
* go ask the adapter to do all this for us
|
||||
@ -1382,10 +1382,10 @@ st_read(unit, buf, size, flags)
|
||||
scsi_cmd.op_code = READ_COMMAND_TAPE;
|
||||
if (st->flags & ST_FIXEDBLOCKS) {
|
||||
scsi_cmd.byte2 |= SRWT_FIXED;
|
||||
lto3b(size / (st->blksiz ? st->blksiz : DEF_FIXED_BSIZE),
|
||||
scsi_uto3b(size / (st->blksiz ? st->blksiz : DEF_FIXED_BSIZE),
|
||||
scsi_cmd.len);
|
||||
} else {
|
||||
lto3b(size, scsi_cmd.len);
|
||||
scsi_uto3b(size, scsi_cmd.len);
|
||||
}
|
||||
return (scsi_scsi_cmd(st->sc_link,
|
||||
(struct scsi_generic *) &scsi_cmd,
|
||||
@ -1443,7 +1443,7 @@ st_rd_blk_lim(unit, flags)
|
||||
return errno;
|
||||
}
|
||||
st->blkmin = b2tol(scsi_blkl.min_length);
|
||||
st->blkmax = _3btol(&scsi_blkl.max_length_2);
|
||||
st->blkmax = scsi_3btou(&scsi_blkl.max_length_2);
|
||||
|
||||
SC_DEBUG(sc_link, SDEV_DB3,
|
||||
("(%d <= blksiz <= %d)\n", st->blkmin, st->blkmax));
|
||||
@ -1522,8 +1522,8 @@ st_mode_sense(unit, flags)
|
||||
flags | SCSI_DATA_IN)) {
|
||||
return errno;
|
||||
}
|
||||
st->numblks = _3btol(((struct scsi_sense *)scsi_sense_ptr)->blk_desc.nblocks);
|
||||
st->media_blksiz = _3btol(((struct scsi_sense *)scsi_sense_ptr)->blk_desc.blklen);
|
||||
st->numblks = scsi_3btou(((struct scsi_sense *)scsi_sense_ptr)->blk_desc.nblocks);
|
||||
st->media_blksiz = scsi_3btou(((struct scsi_sense *)scsi_sense_ptr)->blk_desc.blklen);
|
||||
st->media_density = ((struct scsi_sense *) scsi_sense_ptr)->blk_desc.density;
|
||||
if (((struct scsi_sense *) scsi_sense_ptr)->header.dev_spec &
|
||||
SMH_DSP_WRITE_PROT) {
|
||||
@ -1589,7 +1589,7 @@ st_mode_select(unit, flags)
|
||||
((struct dat *) dat_ptr)->header.dev_spec |= SMH_DSP_BUFF_MODE_ON;
|
||||
((struct dat *) dat_ptr)->blk_desc.density = st->density;
|
||||
if (st->flags & ST_FIXEDBLOCKS) {
|
||||
lto3b(st->blksiz, ((struct dat *) dat_ptr)->blk_desc.blklen);
|
||||
scsi_uto3b(st->blksiz, ((struct dat *) dat_ptr)->blk_desc.blklen);
|
||||
}
|
||||
if (st->quirks & ST_Q_NEEDS_PAGE_0) {
|
||||
bcopy(st->sense_data, ((struct dat_page_0 *) dat_ptr)->sense_data,
|
||||
@ -1673,7 +1673,7 @@ st_space(unit, number, what, flags)
|
||||
bzero(&scsi_cmd, sizeof(scsi_cmd));
|
||||
scsi_cmd.op_code = SPACE;
|
||||
scsi_cmd.byte2 = what & SS_CODE;
|
||||
lto3b(number, scsi_cmd.number);
|
||||
scsi_uto3b(number, scsi_cmd.number);
|
||||
return (scsi_scsi_cmd(st->sc_link,
|
||||
(struct scsi_generic *) &scsi_cmd,
|
||||
sizeof(scsi_cmd),
|
||||
@ -1719,7 +1719,7 @@ st_write_filemarks(unit, number, flags)
|
||||
}
|
||||
bzero(&scsi_cmd, sizeof(scsi_cmd));
|
||||
scsi_cmd.op_code = WRITE_FILEMARKS;
|
||||
lto3b(number, scsi_cmd.number);
|
||||
scsi_uto3b(number, scsi_cmd.number);
|
||||
return scsi_scsi_cmd(st->sc_link,
|
||||
(struct scsi_generic *) &scsi_cmd,
|
||||
sizeof(scsi_cmd),
|
||||
|
Loading…
Reference in New Issue
Block a user