📄 scsi.h
字号:
SCSI_SET_LOGGING(SCSI_LOG_HLCOMPLETE_SHIFT, SCSI_LOG_HLCOMPLETE_BITS, LEVEL);#define SCSI_SET_IOCTL_LOGGING(LEVEL) \ SCSI_SET_LOGGING(SCSI_LOG_IOCTL_SHIFT, SCSI_LOG_IOCTL_BITS, LEVEL);/* * the return of the status word will be in the following format : * The low byte is the status returned by the SCSI command, * with vendor specific bits masked. * * The next byte is the message which followed the SCSI status. * This allows a stos to be used, since the Intel is a little * endian machine. * * The final byte is a host return code, which is one of the following. * * IE * lsb msb * status msg host code * * Our errors returned by OUR driver, NOT SCSI message. Or'd with * SCSI message passed back to driver <IF any>. */#define DID_OK 0x00 /* NO error */#define DID_NO_CONNECT 0x01 /* Couldn't connect before timeout period */#define DID_BUS_BUSY 0x02 /* BUS stayed busy through time out period */#define DID_TIME_OUT 0x03 /* TIMED OUT for other reason */#define DID_BAD_TARGET 0x04 /* BAD target. */#define DID_ABORT 0x05 /* Told to abort for some other reason */#define DID_PARITY 0x06 /* Parity error */#define DID_ERROR 0x07 /* Internal error */#define DID_RESET 0x08 /* Reset by somebody. */#define DID_BAD_INTR 0x09 /* Got an interrupt we weren't expecting. */#define DID_PASSTHROUGH 0x0a /* Force command past mid-layer */#define DID_SOFT_ERROR 0x0b /* The low level driver just wish a retry */#define DRIVER_OK 0x00 /* Driver status *//* * These indicate the error that occurred, and what is available. */#define DRIVER_BUSY 0x01#define DRIVER_SOFT 0x02#define DRIVER_MEDIA 0x03#define DRIVER_ERROR 0x04#define DRIVER_INVALID 0x05#define DRIVER_TIMEOUT 0x06#define DRIVER_HARD 0x07#define DRIVER_SENSE 0x08#define SUGGEST_RETRY 0x10#define SUGGEST_ABORT 0x20#define SUGGEST_REMAP 0x30#define SUGGEST_DIE 0x40#define SUGGEST_SENSE 0x80#define SUGGEST_IS_OK 0xff#define DRIVER_MASK 0x0f#define SUGGEST_MASK 0xf0#define MAX_COMMAND_SIZE 16#define SCSI_SENSE_BUFFERSIZE 64/* * SCSI command sets */#define SCSI_UNKNOWN 0#define SCSI_1 1#define SCSI_1_CCS 2#define SCSI_2 3#define SCSI_3 4/* * Every SCSI command starts with a one byte OP-code. * The next byte's high three bits are the LUN of the * device. Any multi-byte quantities are stored high byte * first, and may have a 5 bit MSB in the same byte * as the LUN. *//* * As the scsi do command functions are intelligent, and may need to * redo a command, we need to keep track of the last command * executed on each one. */#define WAS_RESET 0x01#define WAS_TIMEDOUT 0x02#define WAS_SENSE 0x04#define IS_RESETTING 0x08#define IS_ABORTING 0x10#define ASKED_FOR_SENSE 0x20#define SYNC_RESET 0x40#if defined(__mc68000__) || defined(CONFIG_APUS)#include <asm/pgtable.h>#define CONTIGUOUS_BUFFERS(X,Y) \ (virt_to_phys((X)->b_data+(X)->b_size-1)+1==virt_to_phys((Y)->b_data))#else#define CONTIGUOUS_BUFFERS(X,Y) ((X->b_data+X->b_size) == Y->b_data)#endif/* * This is the crap from the old error handling code. We have it in a special * place so that we can more easily delete it later on. */#include "scsi_obsolete.h"/* * Add some typedefs so that we can prototyope a bunch of the functions. */typedef struct scsi_device Scsi_Device;typedef struct scsi_cmnd Scsi_Cmnd;typedef struct scsi_request Scsi_Request;#define SCSI_CMND_MAGIC 0xE25C23A5#define SCSI_REQ_MAGIC 0x75F6D354/* * Here is where we prototype most of the mid-layer. *//* * Initializes all SCSI devices. This scans all scsi busses. */extern unsigned int scsi_logging_level; /* What do we log? */extern unsigned int scsi_dma_free_sectors; /* How much room do we have left */extern unsigned int scsi_need_isa_buffer; /* True if some devices need indirection * buffers */extern volatile int in_scan_scsis;extern const unsigned char scsi_command_size[8];/* * These are the error handling functions defined in scsi_error.c */extern void scsi_times_out(Scsi_Cmnd * SCpnt);extern void scsi_add_timer(Scsi_Cmnd * SCset, int timeout, void (*complete) (Scsi_Cmnd *));extern int scsi_delete_timer(Scsi_Cmnd * SCset);extern void scsi_error_handler(void *host);extern int scsi_sense_valid(Scsi_Cmnd *);extern int scsi_decide_disposition(Scsi_Cmnd * SCpnt);extern int scsi_block_when_processing_errors(Scsi_Device *);extern void scsi_sleep(int);/* * Prototypes for functions in scsicam.c */extern int scsi_partsize(struct buffer_head *bh, unsigned long capacity, unsigned int *cyls, unsigned int *hds, unsigned int *secs);/* * Prototypes for functions in scsi_dma.c */void scsi_resize_dma_pool(void);int scsi_init_minimal_dma_pool(void);void *scsi_malloc(unsigned int);int scsi_free(void *, unsigned int);/* * Prototypes for functions in scsi_merge.c */extern void recount_segments(Scsi_Cmnd * SCpnt);extern void initialize_merge_fn(Scsi_Device * SDpnt);/* * Prototypes for functions in scsi_queue.c */extern int scsi_mlqueue_insert(Scsi_Cmnd * cmd, int reason);/* * Prototypes for functions in scsi_lib.c */extern int scsi_maybe_unblock_host(Scsi_Device * SDpnt);extern Scsi_Cmnd *scsi_end_request(Scsi_Cmnd * SCpnt, int uptodate, int sectors);extern struct Scsi_Device_Template *scsi_get_request_dev(struct request *);extern int scsi_init_cmd_errh(Scsi_Cmnd * SCpnt);extern int scsi_insert_special_cmd(Scsi_Cmnd * SCpnt, int);extern void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors, int block_sectors);extern void scsi_queue_next_request(request_queue_t * q, Scsi_Cmnd * SCpnt);extern void scsi_request_fn(request_queue_t * q);extern int scsi_starvation_completion(Scsi_Device * SDpnt);/* * Prototypes for functions in scsi.c */extern int scsi_dispatch_cmd(Scsi_Cmnd * SCpnt);extern void scsi_bottom_half_handler(void);extern void scsi_release_commandblocks(Scsi_Device * SDpnt);extern void scsi_build_commandblocks(Scsi_Device * SDpnt);extern void scsi_done(Scsi_Cmnd * SCpnt);extern void scsi_finish_command(Scsi_Cmnd *);extern int scsi_retry_command(Scsi_Cmnd *);extern Scsi_Cmnd *scsi_allocate_device(Scsi_Device *, int, int);extern void __scsi_release_command(Scsi_Cmnd *);extern void scsi_release_command(Scsi_Cmnd *);extern void scsi_do_cmd(Scsi_Cmnd *, const void *cmnd, void *buffer, unsigned bufflen, void (*done) (struct scsi_cmnd *), int timeout, int retries);extern int scsi_dev_init(void);/* * Newer request-based interfaces. */extern Scsi_Request *scsi_allocate_request(Scsi_Device *);extern void scsi_release_request(Scsi_Request *);extern void scsi_wait_req(Scsi_Request *, const void *cmnd, void *buffer, unsigned bufflen, int timeout, int retries);extern void scsi_do_req(Scsi_Request *, const void *cmnd, void *buffer, unsigned bufflen, void (*done) (struct scsi_cmnd *), int timeout, int retries);extern int scsi_insert_special_req(Scsi_Request * SRpnt, int);extern void scsi_init_cmd_from_req(Scsi_Cmnd *, Scsi_Request *);/* * Prototypes for functions/data in hosts.c */extern int max_scsi_hosts;/* * Prototypes for functions in scsi_proc.c */extern void proc_print_scsidevice(Scsi_Device *, char *, int *, int);extern struct proc_dir_entry *proc_scsi;/* * Prototypes for functions in constants.c */extern void print_command(unsigned char *);extern void print_sense(const char *, Scsi_Cmnd *);extern void print_req_sense(const char *, Scsi_Request *);extern void print_driverbyte(int scsiresult);extern void print_hostbyte(int scsiresult);extern void print_status (int status);/* * The scsi_device struct contains what we know about each given scsi * device. * * FIXME(eric) - one of the great regrets that I have is that I failed to define * these structure elements as something like sdev_foo instead of foo. This would * make it so much easier to grep through sources and so forth. I propose that * all new elements that get added to these structures follow this convention. * As time goes on and as people have the stomach for it, it should be possible to * go back and retrofit at least some of the elements here with with the prefix. */struct scsi_device {/* private: */ /* * This information is private to the scsi mid-layer. Wrapping it in a * struct private is a way of marking it in a sort of C++ type of way. */ struct scsi_device *next; /* Used for linked list */ struct scsi_device *prev; /* Used for linked list */ wait_queue_head_t scpnt_wait; /* Used to wait if device is busy */ struct Scsi_Host *host; request_queue_t request_queue; atomic_t device_active; /* commands checked out for device */ volatile unsigned short device_busy; /* commands actually active on low-level */ int (*scsi_init_io_fn) (Scsi_Cmnd *); /* Used to initialize new request */ Scsi_Cmnd *device_queue; /* queue of SCSI Command structures *//* public: */ unsigned int id, lun, channel; unsigned int manufacturer; /* Manufacturer of device, for using * vendor-specific cmd's */ unsigned sector_size; /* size in bytes */ int attached; /* # of high level drivers attached to this */ int detected; /* Delta attached - don't use in drivers! */ int access_count; /* Count of open channels/mounts */ void *hostdata; /* available to low-level driver */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -