summaryrefslogtreecommitdiff
path: root/sys/scsi
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2005-05-28 06:16:34 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2005-05-28 06:16:34 +0000
commit8867169aa39629c7991c639c003af9cb095e7a73 (patch)
tree1530183b24770bfa0d1e8d127c1c8b122ccf2b24 /sys/scsi
parent1dcd23cf610eed2bb363b7889f224424b8b80cee (diff)
Add _lto8b() and _8btol() to decode nblocks field of
scsi_mode_blk_desc_big. Will be needed to move st to new mode sense function. Be a bit more careful with types of parameters to scsi_do_mode_sense, using u_int32_t instead of int. No functional change.
Diffstat (limited to 'sys/scsi')
-rw-r--r--sys/scsi/scsi_base.c11
-rw-r--r--sys/scsi/scsiconf.h41
-rw-r--r--sys/scsi/sd_scsi.c5
3 files changed, 49 insertions, 8 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c
index 2153cddbac3..53d6379c8f0 100644
--- a/sys/scsi/scsi_base.c
+++ b/sys/scsi/scsi_base.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_base.c,v 1.70 2005/05/25 20:52:41 krw Exp $ */
+/* $OpenBSD: scsi_base.c,v 1.71 2005/05/28 06:16:33 krw Exp $ */
/* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */
/*
@@ -459,7 +459,9 @@ scsi_do_mode_sense(sc_link, page, buf, page_data, density, block_count,
block_size, page_len, flags)
struct scsi_link *sc_link;
struct scsi_mode_sense_buf *buf;
- int page, page_len, *density, *block_count, *block_size;
+ int page, page_len;
+ u_int32_t *density, *block_size;
+ u_int64_t *block_count;
void **page_data;
{
struct scsi_mode_blk_desc_big *desc_big;
@@ -474,7 +476,6 @@ scsi_do_mode_sense(sc_link, page, buf, page_data, density, block_count,
if (density)
*density = 0;
if (block_count)
- /* XXX We don't do block_count at this time. */
*block_count = 0;
if (block_size)
*block_size = 0;
@@ -497,6 +498,8 @@ scsi_do_mode_sense(sc_link, page, buf, page_data, density, block_count,
*density = desc_big->density;
if (block_size)
*block_size = _4btol(desc_big->blklen);
+ if (block_count)
+ *block_count = _8btol(desc_big->nblocks);
return (0);
}
@@ -526,6 +529,8 @@ eight_byte:
*density = desc->density;
if (block_size)
*block_size = _3btol(desc->blklen);
+ if (block_count)
+ *block_count = (u_int64_t)_4btol(desc_big->nblocks);
return (0);
}
diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h
index 319996a41e9..f60fd206e25 100644
--- a/sys/scsi/scsiconf.h
+++ b/sys/scsi/scsiconf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsiconf.h,v 1.54 2005/05/25 21:39:08 krw Exp $ */
+/* $OpenBSD: scsiconf.h,v 1.55 2005/05/28 06:16:33 krw Exp $ */
/* $NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $ */
/*
@@ -337,8 +337,8 @@ int scsi_mode_sense_big(struct scsi_link *, int, int,
void * scsi_mode_sense_page(struct scsi_mode_header *, int);
void * scsi_mode_sense_big_page(struct scsi_mode_header_big *, int);
int scsi_do_mode_sense(struct scsi_link *, int,
- struct scsi_mode_sense_buf *, void **, int *, int *, int *, int,
- int);
+ struct scsi_mode_sense_buf *, void **, u_int32_t *, u_int64_t *,
+ u_int32_t *, int, int);
int scsi_mode_select(struct scsi_link *, int, struct scsi_mode_header *,
size_t, int, int);
int scsi_mode_select_big(struct scsi_link *, int,
@@ -362,9 +362,11 @@ void scsi_strvis(u_char *, u_char *, int);
static __inline void _lto2b(u_int32_t val, u_int8_t *bytes);
static __inline void _lto3b(u_int32_t val, u_int8_t *bytes);
static __inline void _lto4b(u_int32_t val, u_int8_t *bytes);
+static __inline void _lto8b(u_int64_t val, u_int8_t *bytes);
static __inline u_int32_t _2btol(u_int8_t *bytes);
static __inline u_int32_t _3btol(u_int8_t *bytes);
static __inline u_int32_t _4btol(u_int8_t *bytes);
+static __inline u_int64_t _8btol(u_int8_t *bytes);
static __inline void _lto2l(u_int32_t val, u_int8_t *bytes);
static __inline void _lto3l(u_int32_t val, u_int8_t *bytes);
@@ -406,6 +408,22 @@ _lto4b(val, bytes)
bytes[3] = val & 0xff;
}
+static __inline void
+_lto8b(val, bytes)
+ u_int64_t val;
+ u_int8_t *bytes;
+{
+
+ bytes[0] = (val >> 56) & 0xff;
+ bytes[1] = (val >> 48) & 0xff;
+ bytes[2] = (val >> 40) & 0xff;
+ bytes[3] = (val >> 32) & 0xff;
+ bytes[4] = (val >> 24) & 0xff;
+ bytes[5] = (val >> 16) & 0xff;
+ bytes[6] = (val >> 8) & 0xff;
+ bytes[7] = val & 0xff;
+}
+
static __inline u_int32_t
_2btol(bytes)
u_int8_t *bytes;
@@ -437,6 +455,23 @@ _4btol(bytes)
return (rv);
}
+static __inline u_int64_t
+_8btol(bytes)
+ u_int8_t *bytes;
+{
+ u_int64_t rv;
+
+ rv = (((u_int64_t)bytes[0]) << 56) |
+ (((u_int64_t)bytes[1]) << 48) |
+ (((u_int64_t)bytes[2]) << 40) |
+ (((u_int64_t)bytes[3]) << 32) |
+ (((u_int64_t)bytes[4]) << 24) |
+ (((u_int64_t)bytes[5]) << 16) |
+ (((u_int64_t)bytes[6]) << 8) |
+ ((u_int64_t)bytes[7]);
+ return (rv);
+}
+
static __inline void
_lto2l(val, bytes)
u_int32_t val;
diff --git a/sys/scsi/sd_scsi.c b/sys/scsi/sd_scsi.c
index 47785001fc4..c1ffd2b4510 100644
--- a/sys/scsi/sd_scsi.c
+++ b/sys/scsi/sd_scsi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd_scsi.c,v 1.12 2005/05/25 20:52:41 krw Exp $ */
+/* $OpenBSD: sd_scsi.c,v 1.13 2005/05/28 06:16:33 krw Exp $ */
/* $NetBSD: sd_scsi.c,v 1.8 1998/10/08 20:21:13 thorpej Exp $ */
/*-
@@ -140,8 +140,9 @@ sd_scsibus_get_parms(sd, dp, flags)
struct sd_scsibus_mode_sense_data scsi_sense;
struct scsi_mode_sense_buf buf;
union scsi_disk_pages *sense_pages = NULL;
+ u_int32_t blksize;
u_int16_t rpm = 0;
- int page, error, blksize;
+ int page, error;
dp->rot_rate = 3600;