scsiconf.h
来自「基于组件方式开发操作系统的OSKIT源代码」· C头文件 代码 · 共 597 行 · 第 1/2 页
H
597 行
/* * 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 * * $\Id: scsiconf.h,v 1.26.4.6 1996/06/23 14:48:38 joerg Exp $ */#ifndef SCSI_SCSICONF_H#define SCSI_SCSICONF_H 1typedef int boolean;typedef int errval;#include <scsi/scsi_debug.h>#include <scsi/scsi_all.h>#include <scsi/scsi_driver.h>/* * 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. * * ------------- * * The key to all this is the scsi_link structure which associates all the * other structures with each other in the correct configuration. The * scsi_link is the connecting information that allows each part of the * scsi system to find the associated other parts. *//* * 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{/* 04*/ int32_t (*scsi_cmd)();/* 08*/ void (*scsi_minphys)();/* 12*/ int32_t (*open_target_lu)();/* 16*/ int32_t (*close_target_lu)();/* 20*/ u_int32_t (*adapter_info)(); /* see definitions below *//* 24*/ char *name; /* name of scsi bus controller *//* 32*/ u_long spare[2];};/* * return values for scsi_cmd() */#define SUCCESSFULLY_QUEUED 0#define TRY_AGAIN_LATER 1#define COMPLETE 2#define HAD_ERROR 3 /* do not use this, use COMPLETE */#define ESCAPE_NOT_SUPPORTED 4/* * 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 *//* * Format of adapter_info() response data * e.g. maximum number of entries queuable to a device by the adapter *//* 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 */struct scsi_xfer;struct proc;struct buf;/* * 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. * * 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. */struct scsi_device{/* 4*/ errval (*err_handler)(struct scsi_xfer *xs); /* return -1 to say * err processing complete *//* 8*/ void (*start)(u_int32_t unit, u_int32_t flags);/* 12*/ int32_t (*async)();/* 16*/ int32_t (*done)(); /* returns -1 to say done processing complete *//* 20*/ char *name; /* name of device type *//* 24*/ u_int32_t flags; /* device type dependent flags *//* 32*/ int32_t spare[2];/* 36*/ int32_t link_flags; /* Flags OR'd into sc_link at attach time *//* 40*/ errval (*attach)(struct scsi_link *sc_link);/* 44*/ char *desc; /* Description of device *//* 48*/ int (*open)(dev_t dev, int flags, int fmt, struct proc *p);/* 52*/ int sizeof_scsi_data;/* 56*/ int type; /* Type of device this supports *//* 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, struct scsi_link *sc_link);/* 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); /* 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. */};/* SCSI_DEVICE_ENTRIES: A macro to generate all the entry points from the * name. */#define SCSI_DEVICE_ENTRIES(NAME) \errval NAME##attach(struct scsi_link *sc_link); \extern struct scsi_device NAME##_switch; \void NAME##init(void) { \ scsi_device_register(&NAME##_switch); \} \int NAME##open(dev_t dev, int flags, int fmt, struct proc *p) { \ return scsi_open(dev, flags, fmt, p, &NAME##_switch); \} \int NAME##ioctl(dev_t dev, int cmd, caddr_t addr, int flag, struct proc *p) { \ return scsi_ioctl(dev, cmd, addr, flag, p, &NAME##_switch); \} \int NAME##close(dev_t dev, int flag, int fmt, struct proc *p) { \ return scsi_close(dev, flag, fmt, p, &NAME##_switch); \} \void NAME##minphys(struct buf *bp) { \ scsi_minphys(bp, &NAME##_switch); \} \void NAME##strategy(struct buf *bp) { \ scsi_strategy(bp, &NAME##_switch); \}#ifdef KERNEL/* Configuration tables for config. *//* A unit, type, etc can be SCCONF_ANY to indicate it is a '?' * in the config. */#define SCCONF_UNSPEC 255#define SCCONF_ANY 254struct isa_driver;struct scsi_ctlr_config{ int scbus; char *driver; int unit; int bus;};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#ifdef NEW_SCSICONF/* * 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_t blksiz;/* 6*/ u_int16_t 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 */#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#endif/* * 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{ u_int8_t target; /* targ of this dev */ u_int8_t lun; /* lun of this dev */ u_int8_t adapter_targ; /* what are we on the scsi bus */ u_int8_t adapter_unit; /* e.g. the 0 in aha0 */ u_int8_t adapter_bus; /* e.g. the 0 in bus0 */ u_int8_t scsibus; /* the Nth scsibus */ u_int8_t dev_unit; /* e.g. the 0 in sd0 */ u_int8_t opennings; /* available operations */ u_int8_t active; /* operations in progress */ u_int16_t flags; /* flags that all devices have */ u_int16_t 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 */ void *adapter_softc; /* needed for call to foo_scsi_cmd */};/* XXX-HA: dufault@hda.com: SDEV_BOUNCE is set down in the adapter drivers * in an sc_link structure to indicate that this host adapter requires * ISA DMA bounce buffers. I think the link structure should * 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.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?