diff options
author | dufault <dufault@FreeBSD.org> | 1995-01-31 11:41:47 +0000 |
---|---|---|
committer | dufault <dufault@FreeBSD.org> | 1995-01-31 11:41:47 +0000 |
commit | 331e8d8b9c94fdc232ed5c04ccf4a8f77be71d34 (patch) | |
tree | e0d623e59f11589bbed1b851634cec2bf41ce894 /sys/scsi | |
parent | 5902fd25c28494ce194edad49898610e485c708f (diff) | |
download | FreeBSD-src-331e8d8b9c94fdc232ed5c04ccf4a8f77be71d34.zip FreeBSD-src-331e8d8b9c94fdc232ed5c04ccf4a8f77be71d34.tar.gz |
Split byte packing functions into signed and unsigned versions.
Left most current invocations as signed, though that could be wrong.
Diffstat (limited to 'sys/scsi')
-rw-r--r-- | sys/scsi/scsi_base.c | 29 | ||||
-rw-r--r-- | sys/scsi/scsiconf.h | 7 | ||||
-rw-r--r-- | sys/scsi/sd.c | 8 | ||||
-rw-r--r-- | sys/scsi/st.c | 22 |
4 files changed, 41 insertions, 25 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index 6dc2249..fbb6e34 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -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; } /* diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h index 7744387..92fafee 100644 --- a/sys/scsi/scsiconf.h +++ b/sys/scsi/scsiconf.h @@ -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 *); diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index a448169..584b3f2 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -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; diff --git a/sys/scsi/st.c b/sys/scsi/st.c index 86f31e7..415c2e9 100644 --- a/sys/scsi/st.c +++ b/sys/scsi/st.c @@ -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), |