| 1 | /* $NetBSD: scsiio.h,v 1.13 2020/05/18 09:52:30 rkujawa Exp $ */ |
| 2 | |
| 3 | #ifndef _SYS_SCSIIO_H_ |
| 4 | #define _SYS_SCSIIO_H_ |
| 5 | |
| 6 | |
| 7 | #include <sys/types.h> |
| 8 | #include <sys/ioctl.h> |
| 9 | |
| 10 | #define	SENSEBUFLEN 48 |
| 11 | |
| 12 | typedef struct	scsireq { |
| 13 | 	u_long	flags;		/* info about the request status and type */ |
| 14 | 	u_long	timeout; |
| 15 | 	u_char	cmd[16]; |
| 16 | 	u_char	cmdlen; |
| 17 | 	void *	databuf;	/* address in user space of buffer */ |
| 18 | 	u_long	datalen;	/* size of user buffer (request) */ |
| 19 | 	u_long	datalen_used;	/* size of user buffer (used)*/ |
| 20 | 	u_char	sense[SENSEBUFLEN]; /* returned sense will be in here */ |
| 21 | 	u_char	senselen;	/* sensedata request size (MAX of SENSEBUFLEN)*/ |
| 22 | 	u_char	senselen_used;	/* return value only */ |
| 23 | 	u_char	status;		/* what the scsi status was from the adapter */ |
| 24 | 	u_char	retsts;		/* the return status for the command */ |
| 25 | 	int	error;		/* error bits */ |
| 26 | } scsireq_t; |
| 27 | |
| 28 | /* bit definitions for flags */ |
| 29 | #define SCCMD_READ		0x00000001 |
| 30 | #define SCCMD_WRITE		0x00000002 |
| 31 | #define SCCMD_IOV		0x00000004 |
| 32 | #define SCCMD_ESCAPE		0x00000010 |
| 33 | #define SCCMD_TARGET		0x00000020 |
| 34 | |
| 35 | |
| 36 | /* definitions for the return status (retsts) */ |
| 37 | #define SCCMD_OK	0x00 |
| 38 | #define SCCMD_TIMEOUT	0x01 |
| 39 | #define SCCMD_BUSY	0x02 |
| 40 | #define SCCMD_SENSE	0x03 |
| 41 | #define SCCMD_UNKNOWN	0x04 |
| 42 | |
| 43 | #define SCIOCCOMMAND	_IOWR('Q', 1, scsireq_t) |
| 44 | |
| 45 | #define SC_DB_CMDS	0x00000001	/* show all scsi cmds and errors */ |
| 46 | #define SC_DB_FLOW	0x00000002	/* show routines entered	*/ |
| 47 | #define SC_DB_FLOW2	0x00000004	/* show path INSIDE routines	*/ |
| 48 | #define SC_DB_DMA	0x00000008	/* show DMA segments etc	*/ |
| 49 | #define SCIOCDEBUG	_IOW('Q', 2, int)	/* from 0 to 15 */ |
| 50 | |
| 51 | struct	oscsi_addr { |
| 52 | 	int	scbus;		/* -1 if wildcard */ |
| 53 | 	int	target;		/* -1 if wildcard */ |
| 54 | 	int	lun;		/* -1 if wildcard */ |
| 55 | }; |
| 56 | |
| 57 | struct	scsi_addr { |
| 58 | 	int type; /* bus type */ |
| 59 | #define TYPE_SCSI 0 |
| 60 | #define TYPE_ATAPI 1 |
| 61 | 	union { |
| 62 | 		struct oscsi_addr scsi; |
| 63 | 		struct _atapi { |
| 64 | 			int atbus; /* -1 if wildcard */ |
| 65 | 			int drive; /* -1 if wildcard */ |
| 66 | 		} atapi; |
| 67 | 	} addr; |
| 68 | }; |
| 69 | |
| 70 | /* |
| 71 | * SCSI device ioctls |
| 72 | */ |
| 73 | |
| 74 | #define SCIOCIDENTIFY	_IOR('Q', 4, struct scsi_addr) /* where are you? */ |
| 75 | #define OSCIOCIDENTIFY	_IOR('Q', 4, struct oscsi_addr) |
| 76 | #define SCIOCDECONFIG	_IO('Q', 5)	/* please disappear */ |
| 77 | #define SCIOCRECONFIG	_IO('Q', 6)	/* please check again */ |
| 78 | #define SCIOCRESET	_IO('Q', 7)	/* reset the device */ |
| 79 | |
| 80 | /* |
| 81 | * SCSI bus ioctls |
| 82 | */ |
| 83 | |
| 84 | /* Scan bus for new devices. */ |
| 85 | struct scbusioscan_args { |
| 86 | 	int	sa_target;	/* target to scan; -1 for wildcard */ |
| 87 | 	int	sa_lun;		/* lun to scan; -1 for wildcard */ |
| 88 | }; |
| 89 | #define	SCBUSIOSCAN	_IOW('U', 0, struct scbusioscan_args) |
| 90 | |
| 91 | #define	SCBUSIORESET	_IO('U', 1)	/* reset SCSI bus */ |
| 92 | |
| 93 | struct scbusiodetach_args { |
| 94 | 	int	sa_target;	/* target to scan; -1 for wildcard */ |
| 95 | 	int	sa_lun;		/* lun to scan; -1 for wildcard */ |
| 96 | }; |
| 97 | #define	SCBUSIODETACH	_IOW('U', 2, struct scbusiodetach_args) |
| 98 | |
| 99 | /* enable/disable device properties */ |
| 100 | struct scbusaccel_args { |
| 101 | 	int	sa_target;	/* target to set property on */ |
| 102 | 	int	sa_lun;		/* lun to set property on */ |
| 103 | 	int	sa_flags;	/* flags to set or clear */ |
| 104 | }; |
| 105 | #define	SC_ACCEL_SYNC	0x01	/* enable sync mode */ |
| 106 | #define	SC_ACCEL_WIDE	0x02	/* enable wide transfers */ |
| 107 | #define	SC_ACCEL_TAGS	0x04	/* enable tagged queuing */ |
| 108 | #define	SCBUSACCEL	_IOW('U', 2, struct scbusaccel_args) |
| 109 | |
| 110 | #define	SCBUSIOLLSCAN	_IO('U', 3)	/* perform low-level scan */ |
| 111 | |
| 112 | #endif /* _SYS_SCSIIO_H_ */ |