1 /* $OpenBSD: scsiio.h,v 1.10 2012/09/05 17:17:47 deraadt Exp $ */ 2 /* $NetBSD: scsiio.h,v 1.3 1994/06/29 06:45:09 cgd Exp $ */ 3 4 #ifndef _SYS_SCSIIO_H_ 5 #define _SYS_SCSIIO_H_ 6 7 8 #include <sys/types.h> 9 #include <sys/ioctl.h> 10 11 #define SENSEBUFLEN 48 12 #define CMDBUFLEN 16 13 14 typedef struct scsireq { 15 u_long flags; /* info about the request status and type */ 16 u_long timeout; 17 u_char cmd[CMDBUFLEN]; 18 u_char cmdlen; 19 caddr_t databuf; /* address in user space of buffer */ 20 u_long datalen; /* size of user buffer (request) */ 21 u_long datalen_used; /* size of user buffer (used)*/ 22 u_char sense[SENSEBUFLEN]; /* returned sense will be in here */ 23 u_char senselen; /* sensedata request size (MAX of SENSEBUFLEN)*/ 24 u_char senselen_used; /* return value only */ 25 u_char status; /* what the scsi status was from the adapter */ 26 u_char retsts; /* the return status for the command */ 27 int error; /* error bits */ 28 } scsireq_t; 29 30 /* bit definitions for flags */ 31 #define SCCMD_READ 0x00000001 32 #define SCCMD_WRITE 0x00000002 33 #define SCCMD_IOV 0x00000004 34 #define SCCMD_ESCAPE 0x00000010 35 #define SCCMD_TARGET 0x00000020 36 37 38 /* definitions for the return status (retsts) */ 39 #define SCCMD_OK 0x00 40 #define SCCMD_TIMEOUT 0x01 41 #define SCCMD_BUSY 0x02 42 #define SCCMD_SENSE 0x03 43 #define SCCMD_UNKNOWN 0x04 44 45 #define SCIOCCOMMAND _IOWR('Q', 1, scsireq_t) 46 47 #define SC_DB_CMDS 0x00000001 /* show all scsi cmds and errors */ 48 #define SC_DB_FLOW 0x00000002 /* show routines entered */ 49 #define SC_DB_FLOW2 0x00000004 /* show path INSIDE routines */ 50 #define SC_DB_DMA 0x00000008 /* show DMA segments etc */ 51 #define SCIOCDEBUG _IOW('Q', 2, int) /* from 0 to 15 */ 52 53 struct scsi_addr { 54 int type; 55 #define TYPE_SCSI 0 56 #define TYPE_ATAPI 1 57 int scbus; /* -1 if wildcard */ 58 int target; /* -1 if wildcard */ 59 int lun; /* -1 if wildcard */ 60 }; 61 62 #define SCIOCRESET _IO('Q', 7) /* reset the device */ 63 #define SCIOCIDENTIFY _IOR('Q', 9, struct scsi_addr) 64 65 struct sbioc_device { 66 void *sd_cookie; 67 int sd_target; 68 int sd_lun; 69 }; 70 71 #define SBIOCPROBE _IOWR('Q', 127, struct sbioc_device) 72 #define SBIOCDETACH _IOWR('Q', 128, struct sbioc_device) 73 74 #endif /* _SYS_SCSIIO_H_ */ 75