1993-06-12 14:58:17 +00:00
|
|
|
/*
|
|
|
|
* Written by Julian Elischer (julian@tfs.com)
|
|
|
|
* for TRW Financial Systems for use under the MACH(2.5) operating system.
|
|
|
|
*
|
|
|
|
* TRW Financial Systems, in accordance with their agreement with Carnegie
|
|
|
|
* Mellon University, makes this software available to CMU to distribute
|
|
|
|
* or use in any manner that they see fit as long as this message is kept with
|
|
|
|
* the software. For this reason TFS also grants any other persons or
|
|
|
|
* organisations permission to use or modify this software.
|
|
|
|
*
|
|
|
|
* TFS supplies this software to be publicly redistributed
|
|
|
|
* on the understanding that TFS is not responsible for the correct
|
|
|
|
* functioning of this software in any circumstances.
|
|
|
|
*
|
|
|
|
* Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
|
1993-08-21 20:01:59 +00:00
|
|
|
*
|
1996-02-03 13:31:13 +00:00
|
|
|
* $Id: scsiconf.h,v 1.38 1996/01/20 15:05:53 joerg Exp $
|
1993-06-12 14:58:17 +00:00
|
|
|
*/
|
1993-11-18 05:03:27 +00:00
|
|
|
#ifndef SCSI_SCSICONF_H
|
|
|
|
#define SCSI_SCSICONF_H 1
|
|
|
|
typedef int boolean;
|
|
|
|
typedef int errval;
|
|
|
|
typedef long int int32;
|
|
|
|
typedef short int int16;
|
|
|
|
typedef char int8;
|
|
|
|
typedef unsigned long int u_int32;
|
|
|
|
typedef unsigned short int u_int16;
|
|
|
|
typedef unsigned char u_int8;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1993-11-18 05:03:27 +00:00
|
|
|
#include <scsi/scsi_debug.h>
|
1995-01-08 13:38:38 +00:00
|
|
|
#include <scsi/scsi_all.h>
|
1995-03-01 22:24:47 +00:00
|
|
|
#include <scsi/scsi_driver.h>
|
1995-01-08 13:38:38 +00:00
|
|
|
|
1993-11-18 05:03:27 +00:00
|
|
|
/*
|
|
|
|
* The following documentation tries to describe the relationship between the
|
|
|
|
* various structures defined in this file:
|
|
|
|
*
|
|
|
|
* each adapter type has a scsi_adapter struct. This describes the adapter and
|
|
|
|
* identifies routines that can be called to use the adapter.
|
|
|
|
* each device type has a scsi_device struct. This describes the device and
|
|
|
|
* identifies routines that can be called to use the device.
|
|
|
|
* each existing device position (scsibus + target + lun)
|
|
|
|
* can be described by a scsi_link struct.
|
|
|
|
* Only scsi positions that actually have devices, have a scsi_link
|
|
|
|
* structure assigned. so in effect each device has scsi_link struct.
|
|
|
|
* The scsi_link structure contains information identifying both the
|
|
|
|
* device driver and the adapter driver for that position on that scsi bus,
|
|
|
|
* and can be said to 'link' the two.
|
|
|
|
* each individual scsi bus has an array that points to all the scsi_link
|
|
|
|
* structs associated with that scsi bus. Slots with no device have
|
|
|
|
* a NULL pointer.
|
|
|
|
* each individual device also knows the address of it's own scsi_link
|
|
|
|
* structure.
|
|
|
|
*
|
|
|
|
* -------------
|
|
|
|
*
|
1995-05-30 08:16:23 +00:00
|
|
|
* The key to all this is the scsi_link structure which associates all the
|
1993-11-18 05:03:27 +00:00
|
|
|
* other structures with each other in the correct configuration. The
|
1995-05-30 08:16:23 +00:00
|
|
|
* scsi_link is the connecting information that allows each part of the
|
1993-11-18 05:03:27 +00:00
|
|
|
* scsi system to find the associated other parts.
|
|
|
|
*/
|
|
|
|
|
1995-11-21 12:55:26 +00:00
|
|
|
struct buf;
|
|
|
|
struct scsi_xfer;
|
1993-11-18 05:03:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* These entrypoints are called by the high-end drivers to get services from
|
|
|
|
* whatever low-end drivers they are attached to each adapter type has one of
|
|
|
|
* these statically allocated.
|
|
|
|
*/
|
|
|
|
struct scsi_adapter
|
1993-06-12 14:58:17 +00:00
|
|
|
{
|
1995-11-21 12:55:26 +00:00
|
|
|
/* 04*/ int32 (*scsi_cmd) __P((struct scsi_xfer *xs));
|
|
|
|
/* 08*/ void (*scsi_minphys) __P((struct buf *bp));
|
|
|
|
/* 12*/ int32 (*open_target_lu) __P((void));
|
|
|
|
/* 16*/ int32 (*close_target_lu) __P((void));
|
|
|
|
/* 20*/ u_int32 (*adapter_info) __P((int unit)); /* see definitions below */
|
1993-11-18 05:03:27 +00:00
|
|
|
/* 24*/ char *name; /* name of scsi bus controller */
|
|
|
|
/* 32*/ u_long spare[2];
|
1993-06-12 14:58:17 +00:00
|
|
|
};
|
|
|
|
|
1993-11-18 05:03:27 +00:00
|
|
|
/*
|
|
|
|
* return values for scsi_cmd()
|
|
|
|
*/
|
1993-06-12 14:58:17 +00:00
|
|
|
#define SUCCESSFULLY_QUEUED 0
|
|
|
|
#define TRY_AGAIN_LATER 1
|
|
|
|
#define COMPLETE 2
|
1993-11-18 05:03:27 +00:00
|
|
|
#define HAD_ERROR 3 /* do not use this, use COMPLETE */
|
1993-08-28 03:08:59 +00:00
|
|
|
#define ESCAPE_NOT_SUPPORTED 4
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1995-01-08 13:38:38 +00:00
|
|
|
/*
|
|
|
|
* Return value from sense handler. IMHO, These ought to be merged
|
|
|
|
* in with the return codes above, all made negative to distinguish
|
|
|
|
* from valid errno values, and replace "try again later" with "do retry"
|
|
|
|
*/
|
|
|
|
#define SCSIRET_CONTINUE -1 /* Continue with standard sense processing */
|
|
|
|
#define SCSIRET_DO_RETRY -2 /* Retry the command that got this sense */
|
|
|
|
|
1993-11-18 05:03:27 +00:00
|
|
|
/*
|
|
|
|
* Format of adapter_info() response data
|
|
|
|
* e.g. maximum number of entries queuable to a device by the adapter
|
|
|
|
*/
|
|
|
|
|
1995-03-01 22:24:47 +00:00
|
|
|
/* Don't poke around inside of "scsi_data". Each low level
|
|
|
|
* driver has its own definition for it.
|
|
|
|
*/
|
|
|
|
struct scsi_data;
|
|
|
|
struct scsi_link; /* scsi_link refers to scsi_device and vice-versa */
|
1995-03-04 20:51:10 +00:00
|
|
|
|
|
|
|
struct proc;
|
|
|
|
|
1993-11-18 05:03:27 +00:00
|
|
|
/*
|
|
|
|
* These entry points are called by the low-end drivers to get services from
|
|
|
|
* whatever high-end drivers they are attached to. Each device type has one
|
|
|
|
* of these statically allocated.
|
1995-03-01 22:24:47 +00:00
|
|
|
*
|
|
|
|
* XXX dufault@hda.com: Each adapter driver has a scsi_device structure
|
|
|
|
* that I don't think should be there.
|
|
|
|
* This structure should be rearranged and cleaned up once the
|
|
|
|
* instance down in the adapter drivers is removed.
|
1993-11-18 05:03:27 +00:00
|
|
|
*/
|
1995-03-01 22:24:47 +00:00
|
|
|
|
1995-11-21 12:55:26 +00:00
|
|
|
/*
|
|
|
|
* XXX <devconf.h> already includes too much; avoid including <conf.h>.
|
|
|
|
*/
|
|
|
|
typedef int yet_another_d_open_t __P((dev_t, int, int, struct proc *));
|
|
|
|
|
1993-11-18 05:03:27 +00:00
|
|
|
struct scsi_device
|
|
|
|
{
|
1995-05-03 18:09:20 +00:00
|
|
|
/* 4*/ errval (*err_handler)(struct scsi_xfer *xs); /* return -1 to say
|
|
|
|
* err processing complete */
|
|
|
|
/* 8*/ void (*start)(u_int32 unit, u_int32 flags);
|
1995-11-21 12:55:26 +00:00
|
|
|
/* 12*/ int32 (*async) __P((void));
|
|
|
|
/* 16*/ int32 (*done) __P((struct scsi_xfer *xs)); /* returns -1 to say done processing complete */
|
1993-11-18 05:03:27 +00:00
|
|
|
/* 20*/ char *name; /* name of device type */
|
|
|
|
/* 24*/ u_int32 flags; /* device type dependent flags */
|
|
|
|
/* 32*/ int32 spare[2];
|
1995-03-01 22:24:47 +00:00
|
|
|
|
1995-05-03 18:09:20 +00:00
|
|
|
/* 36*/ int32 link_flags; /* Flags OR'd into sc_link at attach time */
|
1995-03-01 22:24:47 +00:00
|
|
|
/* 40*/ errval (*attach)(struct scsi_link *sc_link);
|
1995-03-04 20:51:10 +00:00
|
|
|
/* 44*/ char *desc; /* Description of device */
|
1995-11-21 12:55:26 +00:00
|
|
|
/* 48*/ yet_another_d_open_t *open;
|
1995-03-04 20:51:10 +00:00
|
|
|
/* 52*/ int sizeof_scsi_data;
|
1995-05-03 18:09:20 +00:00
|
|
|
/* 56*/ int type; /* Type of device this supports */
|
1995-03-04 20:51:10 +00:00
|
|
|
/* 60*/ int (*getunit)(dev_t dev);
|
|
|
|
/* 64*/ dev_t (*setunit)(dev_t dev, int unit);
|
|
|
|
|
|
|
|
/* 68*/ int (*dev_open)(dev_t dev, int flags, int fmt, struct proc *p,
|
1995-03-01 22:24:47 +00:00
|
|
|
struct scsi_link *sc_link);
|
1995-03-04 20:51:10 +00:00
|
|
|
/* 72*/ int (*dev_ioctl)(dev_t dev, int cmd, caddr_t arg, int mode,
|
|
|
|
struct proc *p, struct scsi_link *sc_link);
|
|
|
|
/* 76*/ int (*dev_close)(dev_t dev, int flag, int fmt, struct proc *p,
|
|
|
|
struct scsi_link *sc_link);
|
|
|
|
/* 80*/ void (*dev_strategy)(struct buf *bp, struct scsi_link *sc_link);
|
1995-03-01 22:24:47 +00:00
|
|
|
|
|
|
|
/* Not initialized after this */
|
|
|
|
|
|
|
|
#define SCSI_LINK(DEV, UNIT) ( \
|
|
|
|
(struct scsi_link *)(extend_get((DEV)->links, (UNIT))) \
|
|
|
|
)
|
|
|
|
|
|
|
|
#define SCSI_DATA(DEV, UNIT) ( \
|
|
|
|
(SCSI_LINK((DEV), (UNIT)) ? \
|
|
|
|
(SCSI_LINK((DEV), (UNIT))->sd) : \
|
|
|
|
(struct scsi_data *)0) \
|
|
|
|
)
|
|
|
|
|
|
|
|
/* 80*/ struct extend_array *links;
|
|
|
|
|
|
|
|
/* 84*/ int free_unit;
|
|
|
|
/* 88*/ struct scsi_device *next; /* Next in list in the registry. */
|
1993-11-18 05:03:27 +00:00
|
|
|
};
|
|
|
|
|
1995-03-01 22:24:47 +00:00
|
|
|
/* SCSI_DEVICE_ENTRIES: A macro to generate all the entry points from the
|
|
|
|
* name.
|
|
|
|
*/
|
1995-05-03 18:09:20 +00:00
|
|
|
#define SCSI_DEVICE_ENTRIES(NAME) \
|
1995-10-21 23:13:11 +00:00
|
|
|
static errval NAME##attach(struct scsi_link *sc_link); \
|
1995-12-14 19:38:40 +00:00
|
|
|
extern struct scsi_device NAME##_switch; /* XXX actually static */ \
|
1995-05-03 18:09:20 +00:00
|
|
|
void NAME##init(void) { \
|
|
|
|
scsi_device_register(&NAME##_switch); \
|
|
|
|
} \
|
1995-12-14 19:38:40 +00:00
|
|
|
static int NAME##open(dev_t dev, int flags, int fmt, struct proc *p) { \
|
1995-05-03 18:09:20 +00:00
|
|
|
return scsi_open(dev, flags, fmt, p, &NAME##_switch); \
|
|
|
|
} \
|
1995-12-14 19:38:40 +00:00
|
|
|
static int NAME##ioctl(dev_t dev, int cmd, caddr_t addr, int flag, struct proc *p) { \
|
1995-05-03 18:09:20 +00:00
|
|
|
return scsi_ioctl(dev, cmd, addr, flag, p, &NAME##_switch); \
|
1995-03-01 22:24:47 +00:00
|
|
|
} \
|
1995-12-14 19:38:40 +00:00
|
|
|
static int NAME##close(dev_t dev, int flag, int fmt, struct proc *p) { \
|
1995-05-03 18:09:20 +00:00
|
|
|
return scsi_close(dev, flag, fmt, p, &NAME##_switch); \
|
|
|
|
} \
|
1995-10-21 23:13:11 +00:00
|
|
|
static void NAME##minphys(struct buf *bp) { \
|
1995-05-03 18:09:20 +00:00
|
|
|
scsi_minphys(bp, &NAME##_switch); \
|
|
|
|
} \
|
1995-12-14 19:38:40 +00:00
|
|
|
static void NAME##strategy(struct buf *bp) { \
|
1995-05-03 18:09:20 +00:00
|
|
|
scsi_strategy(bp, &NAME##_switch); \
|
1995-03-01 22:24:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef KERNEL
|
|
|
|
/* Configuration tables for config.
|
|
|
|
*/
|
|
|
|
/* A unit, type, etc can be SCCONF_ANY to indicate it is a '?'
|
|
|
|
* in the config.
|
|
|
|
*/
|
1995-04-14 15:10:44 +00:00
|
|
|
#define SCCONF_UNSPEC 255
|
|
|
|
#define SCCONF_ANY 254
|
1995-03-01 22:24:47 +00:00
|
|
|
|
|
|
|
struct isa_driver;
|
|
|
|
struct scsi_ctlr_config
|
|
|
|
{
|
1995-07-17 23:38:16 +00:00
|
|
|
int scbus;
|
1995-03-01 22:24:47 +00:00
|
|
|
char *driver;
|
|
|
|
int unit;
|
1995-07-17 23:38:16 +00:00
|
|
|
int bus;
|
1995-03-01 22:24:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct scsi_device_config
|
|
|
|
{
|
|
|
|
char *name; /* SCSI device name (sd, st, etc) */
|
|
|
|
int unit; /* desired device unit */
|
|
|
|
int cunit; /* Controller unit */
|
|
|
|
int target; /* SCSI ID (target) */
|
|
|
|
int lun; /* SCSI lun */
|
|
|
|
int flags; /* Flags from config */
|
|
|
|
};
|
|
|
|
|
|
|
|
extern void (*scsi_tinit[])(void);
|
|
|
|
extern struct scsi_ctlr_config scsi_cinit[];
|
|
|
|
extern struct scsi_device_config scsi_dinit[];
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
1994-09-28 20:16:45 +00:00
|
|
|
/*
|
|
|
|
* Define various devices that we know mis-behave in some way,
|
|
|
|
* and note how they are bad, so we can correct for them
|
|
|
|
*/
|
|
|
|
struct st_mode {
|
|
|
|
/* 4*/ u_int32 blksiz;
|
|
|
|
/* 6*/ u_int16 quirks; /* same definitions as in XXX */
|
|
|
|
/* 7*/ char density;
|
|
|
|
/* 8*/ char spare[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct st_mode st_modes[4];
|
|
|
|
|
|
|
|
/* define behaviour codes (quirks) */
|
|
|
|
/* common to all SCSI devices */
|
|
|
|
#define SCSI_Q_NO_SYNC 0x8000
|
|
|
|
#define SCSI_Q_NO_FAST 0x4000
|
|
|
|
#define SCSI_Q_NO_WIDE 0x2000
|
|
|
|
|
|
|
|
/* tape specific ST_Q_* */
|
|
|
|
#define ST_Q_NEEDS_PAGE_0 0x0001
|
|
|
|
#define ST_Q_FORCE_FIXED_MODE 0x0002
|
|
|
|
#define ST_Q_FORCE_VAR_MODE 0x0004
|
|
|
|
#define ST_Q_SNS_HLP 0x0008 /* must do READ for good MODE SENSE */
|
|
|
|
#define ST_Q_IGNORE_LOADS 0x0010
|
|
|
|
#define ST_Q_BLKSIZ 0x0020 /* variable-block media_blksiz > 0 */
|
|
|
|
#define ST_Q_CC_NOMSG 0x0040 /* no messages accepted in CC state */
|
1996-02-03 13:31:13 +00:00
|
|
|
#define ST_Q_NO_1024 0x0080 /* never ever use 1024-byte fix blk */
|
1994-09-28 20:16:45 +00:00
|
|
|
|
|
|
|
#define ST_Q_NO_SYNC SCSI_Q_NO_SYNC
|
|
|
|
#define ST_Q_NO_FAST SCSI_Q_NO_FAST
|
|
|
|
#define ST_Q_NO_WIDE SCSI_Q_NO_WIDE
|
|
|
|
|
|
|
|
/* disk specific SD_Q_* */
|
|
|
|
#define SD_Q_NO_TAGS 0x0001
|
|
|
|
|
|
|
|
#define SD_Q_NO_SYNC SCSI_Q_NO_SYNC
|
|
|
|
#define SD_Q_NO_FAST SCSI_Q_NO_FAST
|
|
|
|
#define SD_Q_NO_WIDE SCSI_Q_NO_WIDE
|
|
|
|
|
1995-12-10 10:58:30 +00:00
|
|
|
/* cd specific CD_Q_* */
|
|
|
|
#define CD_Q_NO_TOUCH 0x0001
|
|
|
|
|
1994-09-28 20:16:45 +00:00
|
|
|
|
1993-11-18 05:03:27 +00:00
|
|
|
/*
|
|
|
|
* This structure describes the connection between an adapter driver and
|
|
|
|
* a device driver, and is used by each to call services provided by
|
|
|
|
* the other, and to allow generic scsi glue code to call these services
|
|
|
|
* as well.
|
|
|
|
*/
|
|
|
|
struct scsi_link
|
|
|
|
{
|
1995-07-17 23:38:16 +00:00
|
|
|
u_int8 target; /* targ of this dev */
|
|
|
|
u_int8 lun; /* lun of this dev */
|
|
|
|
u_int8 adapter_targ; /* what are we on the scsi bus */
|
|
|
|
u_int8 adapter_unit; /* e.g. the 0 in aha0 */
|
|
|
|
u_int8 adapter_bus; /* e.g. the 0 in bus0 */
|
|
|
|
u_int8 scsibus; /* the Nth scsibus */
|
|
|
|
u_int8 dev_unit; /* e.g. the 0 in sd0 */
|
|
|
|
u_int8 opennings; /* available operations */
|
|
|
|
u_int8 active; /* operations in progress */
|
|
|
|
u_int16 flags; /* flags that all devices have */
|
|
|
|
u_int16 quirks; /* device specific quirks */
|
|
|
|
struct scsi_adapter *adapter; /* adapter entry points etc. */
|
|
|
|
struct scsi_device *device; /* device entry points etc. */
|
|
|
|
struct scsi_xfer *active_xs; /* operations under way */
|
|
|
|
void * fordriver; /* for private use by the driver */
|
|
|
|
void * devmodes; /* device specific mode tables */
|
|
|
|
dev_t dev; /* Device major number (character) */
|
|
|
|
struct scsi_data *sd; /* Device data structure */
|
|
|
|
struct scsi_inquiry_data inqbuf; /* Inquiry data */
|
1996-01-07 19:27:06 +00:00
|
|
|
void *adapter_softc; /* needed for call to foo_scsi_cmd */
|
1993-11-18 05:03:27 +00:00
|
|
|
};
|
1995-03-01 22:24:47 +00:00
|
|
|
|
1995-04-14 15:10:44 +00:00
|
|
|
/* XXX-HA: dufault@hda.com: SDEV_BOUNCE is set down in the adapter drivers
|
1995-03-01 22:24:47 +00:00
|
|
|
* in an sc_link structure to indicate that this host adapter requires
|
1995-03-21 11:21:08 +00:00
|
|
|
* ISA DMA bounce buffers. I think the link structure should
|
1995-03-01 22:24:47 +00:00
|
|
|
* be associated only with the type drive and not the adapter driver,
|
|
|
|
* and the bounce flag should be in something associated with the
|
|
|
|
* adapter driver.
|
1995-04-14 15:10:44 +00:00
|
|
|
* XXX-HA And I added the "supports residuals properly" flag that ALSO goes
|
|
|
|
* in an adapter structure. I figure I'll fix both at once.
|
1995-05-03 18:09:20 +00:00
|
|
|
*
|
|
|
|
* XXX SDEV_OPEN is used for two things: To prevent more than one
|
|
|
|
* open and to make unit attentions errors be logged on the console.
|
|
|
|
* These should be split up; I'm adding SDEV_IS_OPEN to enforce one
|
|
|
|
* open only.
|
1996-01-20 15:05:55 +00:00
|
|
|
*
|
|
|
|
* XXX SDEV_UK is used to mark the "uk" device.
|
1995-03-01 22:24:47 +00:00
|
|
|
*/
|
1995-04-14 15:10:44 +00:00
|
|
|
|
1995-03-21 11:21:08 +00:00
|
|
|
#define SDEV_MEDIA_LOADED 0x0001 /* device figures are still valid */
|
|
|
|
#define SDEV_WAITING 0x0002 /* a process is waiting for this */
|
|
|
|
#define SDEV_OPEN 0x0004 /* at least 1 open session */
|
1995-04-14 15:10:44 +00:00
|
|
|
#define SDEV_BOUNCE 0x0008 /* XXX-HA: unit needs DMA bounce buffer */
|
1995-05-30 08:16:23 +00:00
|
|
|
#define SDEV_DBX 0x00F0 /* debugging flags (scsi_debug.h) */
|
1995-03-21 11:21:08 +00:00
|
|
|
#define SDEV_ONCE_ONLY 0x0100 /* unit can only be opened once */
|
|
|
|
#define SDEV_BOOTVERBOSE 0x0200 /* be noisy during boot */
|
1995-04-14 15:10:44 +00:00
|
|
|
#define SDEV_RESIDS_WORK 0x0400 /* XXX-HA: Residuals work */
|
|
|
|
#define SDEV_TARGET_OPS 0x0800 /* XXX-HA: Supports target ops */
|
1995-05-03 18:09:20 +00:00
|
|
|
#define SDEV_IS_OPEN 0x1000 /* at least 1 open session */
|
1996-01-20 15:05:55 +00:00
|
|
|
#define SDEV_UK 0x2000 /* this is the "uk" device */
|
1993-11-18 05:03:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* One of these is allocated and filled in for each scsi bus.
|
|
|
|
* it holds pointers to allow the scsi bus to get to the driver
|
|
|
|
* That is running each LUN on the bus
|
|
|
|
* it also has a template entry which is the prototype struct
|
|
|
|
* supplied by the adapter driver, this is used to initialise
|
|
|
|
* the others, before they have the rest of the fields filled in
|
|
|
|
*/
|
|
|
|
struct scsibus_data {
|
1995-08-23 23:03:34 +00:00
|
|
|
u_char maxtarg;
|
|
|
|
u_char maxlun;
|
|
|
|
struct scsi_link *adapter_link; /* prototype supplied by adapter */
|
|
|
|
struct scsi_link *(*sc_link)[][8]; /* dynamically allocated */
|
1993-11-18 05:03:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Each scsi transaction is fully described by one of these structures
|
|
|
|
* It includes information about the source of the command and also the
|
|
|
|
* device and adapter for which the command is destined.
|
|
|
|
* (via the scsi_link structure) *
|
|
|
|
*/
|
1993-06-12 14:58:17 +00:00
|
|
|
struct scsi_xfer
|
|
|
|
{
|
1993-11-18 05:03:27 +00:00
|
|
|
/*04*/ struct scsi_xfer *next; /* when free */
|
|
|
|
/*08*/ u_int32 flags;
|
|
|
|
/*12*/ struct scsi_link *sc_link; /* all about our device and adapter */
|
|
|
|
/*13*/ u_int8 retries; /* the number of times to retry */
|
|
|
|
/*16*/ u_int8 spare[3];
|
|
|
|
/*20*/ int32 timeout; /* in milliseconds */
|
|
|
|
/*24*/ struct scsi_generic *cmd; /* The scsi command to execute */
|
|
|
|
/*28*/ int32 cmdlen; /* how long it is */
|
|
|
|
/*32*/ u_char *data; /* dma address OR a uio address */
|
|
|
|
/*36*/ int32 datalen; /* data len (blank if uio) */
|
|
|
|
/*40*/ int32 resid; /* how much buffer was not touched */
|
|
|
|
/*44*/ int32 error; /* an error value */
|
|
|
|
/*48*/ struct buf *bp; /* If we need to associate with a buf */
|
|
|
|
/*80*/ struct scsi_sense_data sense; /* 32 bytes*/
|
|
|
|
/*
|
|
|
|
* Believe it or not, Some targets fall on the ground with
|
1993-08-28 03:08:59 +00:00
|
|
|
* anything but a certain sense length.
|
|
|
|
*/
|
1993-11-18 05:03:27 +00:00
|
|
|
/*84*/ int32 req_sense_length; /* Explicit request sense length */
|
|
|
|
/*88*/ int32 status; /* SCSI status */
|
|
|
|
/*100*/ struct scsi_generic cmdstore; /* stash the command in here */
|
1993-06-12 14:58:17 +00:00
|
|
|
};
|
1993-11-18 05:03:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Per-request Flag values
|
|
|
|
*/
|
1993-06-12 14:58:17 +00:00
|
|
|
#define SCSI_NOSLEEP 0x01 /* Not a user... don't sleep */
|
|
|
|
#define SCSI_NOMASK 0x02 /* dont allow interrupts.. booting */
|
|
|
|
#define SCSI_NOSTART 0x04 /* left over from ancient history */
|
1993-11-18 05:03:27 +00:00
|
|
|
#define SCSI_USER 0x08 /* Is a user cmd, call scsi_user_done */
|
1995-04-14 15:10:44 +00:00
|
|
|
#define SCSI_ITSDONE 0x10 /* the transfer is as done as it gets */
|
1993-06-12 14:58:17 +00:00
|
|
|
#define ITSDONE 0x10 /* the transfer is as done as it gets */
|
1995-04-14 15:10:44 +00:00
|
|
|
#define SCSI_INUSE 0x20 /* The scsi_xfer block is in use */
|
1993-06-12 14:58:17 +00:00
|
|
|
#define INUSE 0x20 /* The scsi_xfer block is in use */
|
|
|
|
#define SCSI_SILENT 0x40 /* Don't report errors to console */
|
|
|
|
#define SCSI_ERR_OK 0x80 /* An error on this operation is OK. */
|
|
|
|
#define SCSI_RESET 0x100 /* Reset the device in question */
|
|
|
|
#define SCSI_DATA_UIO 0x200 /* The data address refers to a UIO */
|
|
|
|
#define SCSI_DATA_IN 0x400 /* expect data to come INTO memory */
|
|
|
|
#define SCSI_DATA_OUT 0x800 /* expect data to flow OUT of memory */
|
|
|
|
#define SCSI_TARGET 0x1000 /* This defines a TARGET mode op. */
|
1993-08-28 03:08:59 +00:00
|
|
|
#define SCSI_ESCAPE 0x2000 /* Escape operation */
|
1995-04-14 15:10:44 +00:00
|
|
|
#define SCSI_EOF 0x4000 /* The operation should return EOF */
|
|
|
|
#define SCSI_RESID_VALID 0x8000 /* The resid field contains valid data */
|
1993-08-28 03:08:59 +00:00
|
|
|
|
1993-11-18 05:03:27 +00:00
|
|
|
/*
|
|
|
|
* Escape op codes. This provides an extensible setup for operations
|
|
|
|
* that are not scsi commands. They are intended for modal operations.
|
|
|
|
*/
|
1993-08-28 03:08:59 +00:00
|
|
|
|
|
|
|
#define SCSI_OP_TARGET 0x0001
|
|
|
|
#define SCSI_OP_RESET 0x0002
|
|
|
|
#define SCSI_OP_BDINFO 0x0003
|
|
|
|
|
1993-11-18 05:03:27 +00:00
|
|
|
/*
|
|
|
|
* Error values an adapter driver may return
|
|
|
|
*/
|
1993-06-12 14:58:17 +00:00
|
|
|
#define XS_NOERROR 0x0 /* there is no error, (sense is invalid) */
|
|
|
|
#define XS_SENSE 0x1 /* Check the returned sense for the error */
|
|
|
|
#define XS_DRIVER_STUFFUP 0x2 /* Driver failed to perform operation */
|
|
|
|
#define XS_TIMEOUT 0x03 /* The device timed out.. turned off? */
|
|
|
|
#define XS_SWTIMEOUT 0x04 /* The Timeout reported was caught by SW */
|
|
|
|
#define XS_BUSY 0x08 /* The device busy, try again later? */
|
1995-01-08 13:38:38 +00:00
|
|
|
#define XS_LENGTH 0x09 /* Illegal length (over/under run) */
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1994-10-19 01:20:44 +00:00
|
|
|
#ifdef KERNEL
|
1995-03-16 18:17:34 +00:00
|
|
|
void *extend_get(struct extend_array *ea, int index);
|
1995-08-23 23:03:34 +00:00
|
|
|
void scsi_attachdevs __P((struct scsibus_data *scbus));
|
1995-03-04 20:51:10 +00:00
|
|
|
u_int32 scsi_read_capacity __P(( struct scsi_link *sc_link,
|
|
|
|
u_int32 *blk_size, u_int32 flags));
|
1995-08-23 23:03:34 +00:00
|
|
|
errval scsi_test_unit_ready __P(( struct scsi_link *sc_link, u_int32 flags));
|
1995-04-14 15:10:44 +00:00
|
|
|
errval scsi_reset_target __P((struct scsi_link *));
|
|
|
|
errval scsi_target_mode __P((struct scsi_link *, int));
|
1993-11-18 05:03:27 +00:00
|
|
|
errval scsi_inquire( struct scsi_link *sc_link,
|
|
|
|
struct scsi_inquiry_data *inqbuf, u_int32 flags);
|
|
|
|
errval scsi_prevent( struct scsi_link *sc_link, u_int32 type,u_int32 flags);
|
1995-11-21 12:55:26 +00:00
|
|
|
struct scsibus_data *scsi_alloc_bus __P((void));
|
1995-04-14 15:10:44 +00:00
|
|
|
errval scsi_probe_bus __P((int, int, int));
|
1995-02-14 06:17:23 +00:00
|
|
|
errval scsi_probe_busses __P(( int, int, int));
|
1993-11-18 05:03:27 +00:00
|
|
|
errval scsi_start_unit( struct scsi_link *sc_link, u_int32 flags);
|
1995-03-16 18:17:34 +00:00
|
|
|
errval scsi_stop_unit(struct scsi_link *sc_link, u_int32 eject, u_int32 flags);
|
1993-11-18 05:03:27 +00:00
|
|
|
void scsi_done(struct scsi_xfer *xs);
|
1995-03-16 18:17:34 +00:00
|
|
|
void scsi_user_done(struct scsi_xfer *xs);
|
1995-03-21 11:21:08 +00:00
|
|
|
errval scsi_scsi_cmd __P(( struct scsi_link *, struct scsi_generic *,
|
|
|
|
u_int32, u_char *,
|
|
|
|
u_int32, u_int32,
|
|
|
|
u_int32, struct buf *,
|
|
|
|
u_int32));
|
1995-03-04 20:51:10 +00:00
|
|
|
int scsi_do_ioctl __P((dev_t dev, int cmd, caddr_t addr, int mode,
|
|
|
|
struct proc *p, struct scsi_link *sc_link));
|
1995-01-08 13:38:38 +00:00
|
|
|
|
|
|
|
struct scsi_link *scsi_link_get __P((int bus, int targ, int lun));
|
1995-03-04 20:51:10 +00:00
|
|
|
dev_t scsi_dev_lookup __P((int (*opener)(dev_t dev, int flags, int fmt,
|
|
|
|
struct proc *p)));
|
1995-01-08 13:38:38 +00:00
|
|
|
|
|
|
|
int scsi_opened_ok __P((dev_t dev, int flag, int type, struct scsi_link *sc_link));
|
1995-04-14 15:10:44 +00:00
|
|
|
errval scsi_set_bus __P((int, struct scsi_link *));
|
1995-01-08 13:38:38 +00:00
|
|
|
|
1995-03-21 11:21:08 +00:00
|
|
|
char *scsi_sense_desc __P((int, int));
|
|
|
|
void scsi_sense_print __P((struct scsi_xfer *));
|
|
|
|
void show_scsi_cmd __P((struct scsi_xfer *));
|
1993-11-18 05:03:27 +00:00
|
|
|
|
1995-03-21 11:21:08 +00:00
|
|
|
void scsi_uto3b __P((u_int32 , u_char *));
|
|
|
|
u_int32 scsi_3btou __P((u_char *));
|
|
|
|
int32 scsi_3btoi __P((u_char *));
|
|
|
|
void scsi_uto4b __P((u_int32, u_char *));
|
|
|
|
u_int32 scsi_4btou __P((u_char *));
|
|
|
|
void scsi_uto2b __P((u_int32, u_char *));
|
|
|
|
u_int32 scsi_2btou __P((u_char *));
|
1993-11-18 05:03:27 +00:00
|
|
|
|
1995-03-21 11:21:08 +00:00
|
|
|
void sc_print_addr __P((struct scsi_link *));
|
|
|
|
void sc_print_start __P((struct scsi_link *));
|
|
|
|
void sc_print_finish __P((void));
|
1993-12-19 00:55:01 +00:00
|
|
|
|
1995-12-14 19:38:40 +00:00
|
|
|
int scsi_externalize __P((struct scsi_link *, struct sysctl_req *));
|
1995-03-01 22:24:47 +00:00
|
|
|
|
1995-03-21 11:21:08 +00:00
|
|
|
void scsi_device_register __P((struct scsi_device *sd));
|
1995-03-01 22:24:47 +00:00
|
|
|
|
1994-10-23 21:28:03 +00:00
|
|
|
extern struct kern_devconf kdc_scbus0; /* XXX should go away */
|
1994-10-19 01:20:44 +00:00
|
|
|
|
1995-04-14 15:10:44 +00:00
|
|
|
void scsi_configure_start __P((void));
|
|
|
|
void scsi_configure_finish __P((void));
|
|
|
|
|
1995-11-21 12:55:26 +00:00
|
|
|
void ukinit __P((void));
|
|
|
|
|
1995-12-17 21:23:44 +00:00
|
|
|
#ifdef SCSI_2_DEF
|
|
|
|
errval scsi_change_def( struct scsi_link *sc_link, u_int32 flags);
|
|
|
|
#endif
|
1995-04-14 15:10:44 +00:00
|
|
|
#endif /* KERNEL */
|
1994-10-19 01:20:44 +00:00
|
|
|
|
1994-10-19 01:49:23 +00:00
|
|
|
#define SCSI_EXTERNALLEN (sizeof(struct scsi_link))
|
|
|
|
|
1995-05-03 18:09:20 +00:00
|
|
|
|
|
|
|
/* XXX This belongs in a tape file.
|
|
|
|
*/
|
|
|
|
|
1994-09-28 20:16:45 +00:00
|
|
|
/**********************************************************************
|
|
|
|
from the scsi2 spec
|
|
|
|
Value Tracks Density(bpi) Code Type Reference Note
|
|
|
|
0x1 9 800 NRZI R X3.22-1983 2
|
|
|
|
0x2 9 1600 PE R X3.39-1986 2
|
|
|
|
0x3 9 6250 GCR R X3.54-1986 2
|
|
|
|
0x5 4/9 8000 GCR C X3.136-1986 1
|
|
|
|
0x6 9 3200 PE R X3.157-1987 2
|
|
|
|
0x7 4 6400 IMFM C X3.116-1986 1
|
|
|
|
0x8 4 8000 GCR CS X3.158-1986 1
|
|
|
|
0x9 18 37871 GCR C X3B5/87-099 2
|
|
|
|
0xA 22 6667 MFM C X3B5/86-199 1
|
|
|
|
0xB 4 1600 PE C X3.56-1986 1
|
|
|
|
0xC 24 12690 GCR C HI-TC1 1,5
|
|
|
|
0xD 24 25380 GCR C HI-TC2 1,5
|
|
|
|
0xF 15 10000 GCR C QIC-120 1,5
|
|
|
|
0x10 18 10000 GCR C QIC-150 1,5
|
|
|
|
0x11 26 16000 GCR C QIC-320(525?) 1,5
|
|
|
|
0x12 30 51667 RLL C QIC-1350 1,5
|
|
|
|
0x13 1 61000 DDS CS X3B5/88-185A 4
|
|
|
|
0x14 1 43245 RLL CS X3.202-1991 4
|
|
|
|
0x15 1 45434 RLL CS ECMA TC17 4
|
|
|
|
0x16 48 10000 MFM C X3.193-1990 1
|
|
|
|
0x17 48 42500 MFM C X3B5/91-174 1
|
|
|
|
|
|
|
|
where Code means:
|
|
|
|
NRZI Non Return to Zero, change on ones
|
|
|
|
GCR Group Code Recording
|
|
|
|
PE Phase Encoded
|
|
|
|
IMFM Inverted Modified Frequency Modulation
|
|
|
|
MFM Modified Frequency Modulation
|
|
|
|
DDS Dat Data Storage
|
|
|
|
RLL Run Length Encoding
|
|
|
|
|
|
|
|
where Type means:
|
|
|
|
R Real-to-Real
|
|
|
|
C Cartridge
|
|
|
|
CS cassette
|
|
|
|
|
|
|
|
where Notes means:
|
|
|
|
1 Serial Recorded
|
|
|
|
2 Parallel Recorded
|
|
|
|
3 Old format know as QIC-11
|
|
|
|
4 Helical Scan
|
|
|
|
5 Not ANSI standard, rather industry standard.
|
|
|
|
|
|
|
|
********************************************************************/
|
|
|
|
|
|
|
|
#define HALFINCH_800 0x01
|
|
|
|
#define HALFINCH_1600 0x02
|
|
|
|
#define HALFINCH_6250 0x03
|
|
|
|
#define QIC_11 0x04 /* from Archive 150S Theory of Op. XXX */
|
|
|
|
#define QIC_24 0x05 /* may be bad, works for CIPHER ST150S XXX */
|
|
|
|
#define QIC_120 0x0f
|
|
|
|
#define QIC_150 0x10
|
|
|
|
#define QIC_320 0x11
|
|
|
|
#define QIC_525 0x11
|
|
|
|
#define QIC_1320 0x12
|
|
|
|
#define DDS 0x13
|
|
|
|
#define DAT_1 0x13
|
1995-12-10 10:58:30 +00:00
|
|
|
#define QIC_3080 0x29
|
|
|
|
|
1994-09-28 20:16:45 +00:00
|
|
|
|
1995-05-03 18:09:20 +00:00
|
|
|
/* XXX (dufault@hda.com) This is used only by "su" and "sctarg".
|
|
|
|
* The minor number field conflicts with the disk slice code,
|
|
|
|
* and so it is tough to access the disks through the "su" device.
|
1995-01-08 13:38:38 +00:00
|
|
|
*/
|
|
|
|
|
1995-05-03 18:09:20 +00:00
|
|
|
/* Device number fields:
|
|
|
|
*
|
|
|
|
* NON-FIXED SCSI devices:
|
|
|
|
*
|
|
|
|
* ?FC? ???? ???? ???? MMMMMMMM mmmmmmmm
|
|
|
|
*
|
|
|
|
* F: Fixed device (nexus in number): must be 0.
|
|
|
|
* C: Control device; only user mode ioctl is supported.
|
|
|
|
* ?: Don't know; those bits didn't use to exist, currently always 0.
|
|
|
|
* M: Major device number.
|
|
|
|
* m: Old style minor device number.
|
|
|
|
*
|
|
|
|
* FIXED SCSI devices:
|
1995-01-08 13:38:38 +00:00
|
|
|
*
|
1995-05-03 18:09:20 +00:00
|
|
|
* XXX Conflicts with the slice code. Maybe the slice code can be
|
|
|
|
* changed to respect the F bit?
|
1995-01-08 13:38:38 +00:00
|
|
|
*
|
1995-05-03 18:09:20 +00:00
|
|
|
* ?FC? ?BBB TTTT ?LLL MMMMMMMM mmmmmmmm
|
|
|
|
*
|
|
|
|
* F: Fixed device (nexus in number); must be 1.
|
|
|
|
* C: Control device; only user mode ioctl is supported.
|
|
|
|
* B: SCSI bus
|
|
|
|
* T: SCSI target ID
|
|
|
|
* L: Logical unit
|
|
|
|
* M: Major device number
|
|
|
|
* m: Old style minor device number.
|
1995-01-08 13:38:38 +00:00
|
|
|
*/
|
1995-05-03 18:09:20 +00:00
|
|
|
|
|
|
|
#define SCSI_FIXED_MASK 0x40000000
|
1995-12-05 07:14:27 +00:00
|
|
|
#define SCSI_FIXED(DEV) (((DEV) & SCSI_FIXED_MASK))
|
|
|
|
#define SCSI_CONTROL_MASK 0x20000000
|
|
|
|
#define SCSI_CONTROL(DEV) (((DEV) & SCSI_CONTROL_MASK))
|
1995-05-03 18:09:20 +00:00
|
|
|
|
|
|
|
#define SCSI_BUS(DEV) (((DEV) & 0x07000000) >> 24)
|
|
|
|
#define SCSI_ID(DEV) (((DEV) & 0x00F00000) >> 20)
|
|
|
|
#define SCSI_LUN(DEV) (((DEV) & 0x00070000) >> 16)
|
|
|
|
|
|
|
|
#define SCSI_MKFIXED(B, T, L) ( \
|
|
|
|
((B) << 24) | \
|
|
|
|
((T) << 20) | \
|
|
|
|
((L) << 16) | \
|
|
|
|
SCSI_FIXED_MASK )
|
1995-01-08 13:38:38 +00:00
|
|
|
|
1993-11-18 05:03:27 +00:00
|
|
|
#endif /*SCSI_SCSICONF_H*/
|
|
|
|
/* END OF FILE */
|