diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-11-10 18:04:42 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-11-10 18:04:42 +0000 |
commit | dedcf7dabb00172eb049d9c7114d62454caaa2f3 (patch) | |
tree | 7392dc4027b1b65bf38bd42dec24558801e68abe /sys | |
parent | 8b8ed604b4dcbfad046c7ee3f8502c90843db3a7 (diff) |
clean namespace a fair bit; wrap kernel-use-only structures and gunk in
#ifdef _KERNEL
Diffstat (limited to 'sys')
-rw-r--r-- | sys/scsi/scsi_debug.h | 4 | ||||
-rw-r--r-- | sys/scsi/scsiconf.h | 373 | ||||
-rw-r--r-- | sys/scsi/sdvar.h | 5 | ||||
-rw-r--r-- | sys/scsi/ssvar.h | 6 |
4 files changed, 188 insertions, 200 deletions
diff --git a/sys/scsi/scsi_debug.h b/sys/scsi/scsi_debug.h index caf8b5db069..66f2e4890f8 100644 --- a/sys/scsi/scsi_debug.h +++ b/sys/scsi/scsi_debug.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_debug.h,v 1.8 2004/01/25 00:09:20 krw Exp $ */ +/* $OpenBSD: scsi_debug.h,v 1.9 2008/11/10 18:04:41 deraadt Exp $ */ /* $NetBSD: scsi_debug.h,v 1.7 1996/10/12 23:23:16 christos Exp $ */ /* @@ -6,6 +6,7 @@ */ #ifndef _SCSI_SCSI_DEBUG_H #define _SCSI_SCSI_DEBUG_H 1 +#ifdef _KERNEL /* * These are the new debug bits. (Sat Oct 2 12:46:46 WST 1993) @@ -52,4 +53,5 @@ extern int scsidebug_buses, scsidebug_targets, scsidebug_luns, scsidebug_level; #define SC_DEBUGN(A,B,C) #endif +#endif /* _KERNEL */ #endif /* _SCSI_SCSI_DEBUG_H */ diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h index c44c9e63fcd..a38f054540f 100644 --- a/sys/scsi/scsiconf.h +++ b/sys/scsi/scsiconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.h,v 1.96 2008/11/09 17:01:10 deraadt Exp $ */ +/* $OpenBSD: scsiconf.h,v 1.97 2008/11/10 18:04:41 deraadt Exp $ */ /* $NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $ */ /* @@ -48,7 +48,7 @@ */ #ifndef SCSI_SCSICONF_H -#define SCSI_SCSICONF_H 1 +#define SCSI_SCSICONF_H #include <sys/queue.h> #include <sys/timeout.h> @@ -56,6 +56,178 @@ #include <machine/cpu.h> #include <scsi/scsi_debug.h> +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 _5btol(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); +static __inline void _lto4l(u_int32_t val, u_int8_t *bytes); +static __inline u_int32_t _2ltol(u_int8_t *bytes); +static __inline u_int32_t _3ltol(u_int8_t *bytes); +static __inline u_int32_t _4ltol(u_int8_t *bytes); + +static __inline void +_lto2b(u_int32_t val, u_int8_t *bytes) +{ + + bytes[0] = (val >> 8) & 0xff; + bytes[1] = val & 0xff; +} + +static __inline void +_lto3b(u_int32_t val, u_int8_t *bytes) +{ + + bytes[0] = (val >> 16) & 0xff; + bytes[1] = (val >> 8) & 0xff; + bytes[2] = val & 0xff; +} + +static __inline void +_lto4b(u_int32_t val, u_int8_t *bytes) +{ + + bytes[0] = (val >> 24) & 0xff; + bytes[1] = (val >> 16) & 0xff; + bytes[2] = (val >> 8) & 0xff; + bytes[3] = val & 0xff; +} + +static __inline void +_lto8b(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(u_int8_t *bytes) +{ + u_int32_t rv; + + rv = (bytes[0] << 8) | bytes[1]; + return (rv); +} + +static __inline u_int32_t +_3btol(u_int8_t *bytes) +{ + u_int32_t rv; + + rv = (bytes[0] << 16) | (bytes[1] << 8) | bytes[2]; + return (rv); +} + +static __inline u_int32_t +_4btol(u_int8_t *bytes) +{ + u_int32_t rv; + + rv = (bytes[0] << 24) | (bytes[1] << 16) | + (bytes[2] << 8) | bytes[3]; + return (rv); +} + +static __inline u_int64_t +_5btol(u_int8_t *bytes) +{ + u_int64_t rv; + + rv = ((u_int64_t)bytes[0] << 32) | + ((u_int64_t)bytes[1] << 24) | + ((u_int64_t)bytes[2] << 16) | + ((u_int64_t)bytes[3] << 8) | + (u_int64_t)bytes[4]; + return (rv); +} + +static __inline u_int64_t +_8btol(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(u_int32_t val, u_int8_t *bytes) +{ + + bytes[0] = val & 0xff; + bytes[1] = (val >> 8) & 0xff; +} + +static __inline void +_lto3l(u_int32_t val, u_int8_t *bytes) +{ + + bytes[0] = val & 0xff; + bytes[1] = (val >> 8) & 0xff; + bytes[2] = (val >> 16) & 0xff; +} + +static __inline void +_lto4l(u_int32_t val, u_int8_t *bytes) +{ + + bytes[0] = val & 0xff; + bytes[1] = (val >> 8) & 0xff; + bytes[2] = (val >> 16) & 0xff; + bytes[3] = (val >> 24) & 0xff; +} + +static __inline u_int32_t +_2ltol(u_int8_t *bytes) +{ + u_int32_t rv; + + rv = bytes[0] | (bytes[1] << 8); + return (rv); +} + +static __inline u_int32_t +_3ltol(u_int8_t *bytes) +{ + u_int32_t rv; + + rv = bytes[0] | (bytes[1] << 8) | (bytes[2] << 16); + return (rv); +} + +static __inline u_int32_t +_4ltol(u_int8_t *bytes) +{ + u_int32_t rv; + + rv = bytes[0] | (bytes[1] << 8) | + (bytes[2] << 16) | (bytes[3] << 24); + return (rv); +} + +#ifdef _KERNEL + #define DEVID_NONE 0 #define DEVID_NAA 1 #define DEVID_EUI 2 @@ -105,8 +277,6 @@ struct devid { * scsi system to find the associated other parts. */ -struct buf; -struct proc; struct scsi_xfer; struct scsi_link; struct scsibus_softc; @@ -383,199 +553,8 @@ int scsi_detach_bus(struct scsibus_softc *, int); int scsi_detach_target(struct scsibus_softc *, int, int); int scsi_detach_lun(struct scsibus_softc *, int, int, 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 _5btol(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); -static __inline void _lto4l(u_int32_t val, u_int8_t *bytes); -static __inline u_int32_t _2ltol(u_int8_t *bytes); -static __inline u_int32_t _3ltol(u_int8_t *bytes); -static __inline u_int32_t _4ltol(u_int8_t *bytes); - -static __inline void -_lto2b(val, bytes) - u_int32_t val; - u_int8_t *bytes; -{ - - bytes[0] = (val >> 8) & 0xff; - bytes[1] = val & 0xff; -} - -static __inline void -_lto3b(val, bytes) - u_int32_t val; - u_int8_t *bytes; -{ - - bytes[0] = (val >> 16) & 0xff; - bytes[1] = (val >> 8) & 0xff; - bytes[2] = val & 0xff; -} - -static __inline void -_lto4b(val, bytes) - u_int32_t val; - u_int8_t *bytes; -{ - - bytes[0] = (val >> 24) & 0xff; - bytes[1] = (val >> 16) & 0xff; - bytes[2] = (val >> 8) & 0xff; - 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; -{ - u_int32_t rv; - - rv = (bytes[0] << 8) | bytes[1]; - return (rv); -} - -static __inline u_int32_t -_3btol(bytes) - u_int8_t *bytes; -{ - u_int32_t rv; - - rv = (bytes[0] << 16) | (bytes[1] << 8) | bytes[2]; - return (rv); -} - -static __inline u_int32_t -_4btol(bytes) - u_int8_t *bytes; -{ - u_int32_t rv; - - rv = (bytes[0] << 24) | (bytes[1] << 16) | - (bytes[2] << 8) | bytes[3]; - return (rv); -} - -static __inline u_int64_t -_5btol(bytes) - u_int8_t *bytes; -{ - u_int64_t rv; - - rv = ((u_int64_t)bytes[0] << 32) | - ((u_int64_t)bytes[1] << 24) | - ((u_int64_t)bytes[2] << 16) | - ((u_int64_t)bytes[3] << 8) | - (u_int64_t)bytes[4]; - 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; - u_int8_t *bytes; -{ - - bytes[0] = val & 0xff; - bytes[1] = (val >> 8) & 0xff; -} - -static __inline void -_lto3l(val, bytes) - u_int32_t val; - u_int8_t *bytes; -{ - - bytes[0] = val & 0xff; - bytes[1] = (val >> 8) & 0xff; - bytes[2] = (val >> 16) & 0xff; -} - -static __inline void -_lto4l(val, bytes) - u_int32_t val; - u_int8_t *bytes; -{ - - bytes[0] = val & 0xff; - bytes[1] = (val >> 8) & 0xff; - bytes[2] = (val >> 16) & 0xff; - bytes[3] = (val >> 24) & 0xff; -} - -static __inline u_int32_t -_2ltol(bytes) - u_int8_t *bytes; -{ - u_int32_t rv; - - rv = bytes[0] | (bytes[1] << 8); - return (rv); -} - -static __inline u_int32_t -_3ltol(bytes) - u_int8_t *bytes; -{ - u_int32_t rv; - - rv = bytes[0] | (bytes[1] << 8) | (bytes[2] << 16); - return (rv); -} - -static __inline u_int32_t -_4ltol(bytes) - u_int8_t *bytes; -{ - u_int32_t rv; - - rv = bytes[0] | (bytes[1] << 8) | - (bytes[2] << 16) | (bytes[3] << 24); - return (rv); -} - -extern const u_int8_t version_to_spc []; +extern const u_int8_t version_to_spc[]; #define SCSISPC(x)(version_to_spc[(x) & SID_ANSII]) +#endif /* _KERNEL */ #endif /* SCSI_SCSICONF_H */ diff --git a/sys/scsi/sdvar.h b/sys/scsi/sdvar.h index 996192cb8bd..ba0519634d0 100644 --- a/sys/scsi/sdvar.h +++ b/sys/scsi/sdvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sdvar.h,v 1.15 2008/06/26 05:42:20 ray Exp $ */ +/* $OpenBSD: sdvar.h,v 1.16 2008/11/10 18:04:41 deraadt Exp $ */ /* $NetBSD: sdvar.h,v 1.7 1998/08/17 00:49:03 mycroft Exp $ */ /*- @@ -47,6 +47,7 @@ * Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992 */ +#ifdef _KERNEL struct sd_softc { struct device sc_dev; struct disk sc_dk; @@ -75,3 +76,5 @@ struct sd_softc { #define SDGP_RESULT_OK 0 /* parameters obtained */ #define SDGP_RESULT_OFFLINE 1 /* no media, or otherwise losing */ + +#endif /* _KERNEL */ diff --git a/sys/scsi/ssvar.h b/sys/scsi/ssvar.h index be9f3fbedbb..0c5d39546b3 100644 --- a/sys/scsi/ssvar.h +++ b/sys/scsi/ssvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ssvar.h,v 1.11 2006/11/28 16:56:50 dlg Exp $ */ +/* $OpenBSD: ssvar.h,v 1.12 2008/11/10 18:04:41 deraadt Exp $ */ /* $NetBSD: ssvar.h,v 1.2 1996/03/30 21:47:11 christos Exp $ */ /* @@ -31,6 +31,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef _KERNEL + /* * SCSI scanner interface description */ @@ -77,3 +79,5 @@ struct ss_softc { */ void mustek_attach(struct ss_softc *, struct scsi_attach_args *); void scanjet_attach(struct ss_softc *, struct scsi_attach_args *); + +#endif /* _KERNEL */ |