⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scsi.h

📁 GNU Mach 微内核源代码, 基于美国卡内基美隆大学的 Mach 研究项目
💻 H
📖 第 1 页 / 共 2 页
字号:
#define SCSI_RESET_ASYNCHRONOUS		0x02#define SCSI_RESET_SUGGEST_BUS_RESET	0x04#define SCSI_RESET_SUGGEST_HOST_RESET	0x08/* * This is a bitmask that is ored with one of the above codes. * It tells the mid-level code that we did a hard reset. */#define SCSI_RESET_BUS_RESET 0x100/* * This is a bitmask that is ored with one of the above codes. * It tells the mid-level code that we did a host adapter reset. */#define SCSI_RESET_HOST_RESET 0x200/* * Used to mask off bits and to obtain the basic action that was * performed.   */#define SCSI_RESET_ACTION   0xffvoid *   scsi_malloc(unsigned int);int      scsi_free(void *, unsigned int);extern unsigned int dma_free_sectors;  /* How much room do we have left */extern unsigned int need_isa_buffer;   /* True if some devices need indirection					* buffers *//* * The Scsi_Cmnd structure is used by scsi.c internally, and for communication * with low level drivers that support multiple outstanding commands. */typedef struct scsi_pointer {    char * ptr;                     /* data pointer */    int this_residual;              /* left in this buffer */    struct scatterlist *buffer;     /* which buffer */    int buffers_residual;           /* how many buffers left */        volatile int Status;    volatile int Message;    volatile int have_data_in;    volatile int sent_command;    volatile int phase;} Scsi_Pointer;typedef struct scsi_cmnd {    struct Scsi_Host * host;    Scsi_Device * device;    unsigned char target, lun, channel;    unsigned char cmd_len;    unsigned char old_cmd_len;    struct scsi_cmnd *next, *prev, *device_next, *reset_chain;        /* These elements define the operation we are about to perform */    unsigned char cmnd[12];    unsigned request_bufflen;	/* Actual request size */        void * request_buffer;	/* Actual requested buffer */        /* These elements define the operation we ultimately want to perform */    unsigned char data_cmnd[12];    unsigned short old_use_sg;	/* We save  use_sg here when requesting				 * sense info */    unsigned short use_sg;	/* Number of pieces of scatter-gather */    unsigned short sglist_len;	/* size of malloc'd scatter-gather list */    unsigned short abort_reason;/* If the mid-level code requests an				 * abort, this is the reason. */    unsigned bufflen;		/* Size of data buffer */    void *buffer;		/* Data buffer */        unsigned underflow;		/* Return error if less than this amount is 				 * transfered */        unsigned transfersize;	/* How much we are guaranteed to transfer with				 * each SCSI transfer (ie, between disconnect /				 * reconnects.	 Probably == sector size */            struct request request;	/* A copy of the command we are working on */    unsigned char sense_buffer[16];  /* Sense for this command, if needed */    /*      A SCSI Command is assigned a nonzero serial_number when internal_cmnd      passes it to the driver's queue command function.  The serial_number      is cleared when scsi_done is entered indicating that the command has      been completed.  If a timeout occurs, the serial number at the moment      of timeout is copied into serial_number_at_timeout.  By subsequently      comparing the serial_number and serial_number_at_timeout fields      during abort or reset processing, we can detect whether the command      has already completed.  This also detects cases where the command has      completed and the SCSI Command structure has already being reused      for another command, so that we can avoid incorrectly aborting or      resetting the new command.    */    unsigned long serial_number;    unsigned long serial_number_at_timeout;    int retries;    int allowed;    int timeout_per_command, timeout_total, timeout;    /*     *	We handle the timeout differently if it happens when a reset,      *	abort, etc are in process.      */    unsigned volatile char internal_timeout;        unsigned flags;        /* These variables are for the cdrom only. Once we have variable size      * buffers in the buffer cache, they will go away. */    int this_count;     /* End of special cdrom variables */        /* Low-level done function - can be used by low-level driver to point     *	to completion function.	 Not used by mid/upper level code. */    void (*scsi_done)(struct scsi_cmnd *);      void (*done)(struct scsi_cmnd *);  /* Mid-level done function */        /*     * The following fields can be written to by the host specific code.      * Everything else should be left alone.      */        Scsi_Pointer SCp;	/* Scratchpad used by some host adapters */        unsigned char * host_scribble; /* The host adapter is allowed to				    * call scsi_malloc and get some memory				    * and hang it here.	 The host adapter				    * is also expected to call scsi_free				    * to release this memory.  (The memory				    * obtained by scsi_malloc is guaranteed				    * to be at an address < 16Mb). */        int result;			   /* Status code from lower level driver */        unsigned char tag;		   /* SCSI-II queued command tag */    unsigned long pid;		   /* Process ID, starts at 0 */} Scsi_Cmnd;	     /* *  scsi_abort aborts the current command that is executing on host host. *  The error code, if non zero is returned in the host byte, otherwise  *  DID_ABORT is returned in the hostbyte. */extern int scsi_abort (Scsi_Cmnd *, int code);extern void scsi_do_cmd (Scsi_Cmnd *, const void *cmnd ,			 void *buffer, unsigned bufflen, 			 void (*done)(struct scsi_cmnd *),			 int timeout, int retries);extern Scsi_Cmnd * allocate_device(struct request **, Scsi_Device *, int);extern Scsi_Cmnd * request_queueable(struct request *, Scsi_Device *);extern int scsi_reset (Scsi_Cmnd *, unsigned int);extern int max_scsi_hosts;extern void proc_print_scsidevice(Scsi_Device *, char *, int *, int);extern void print_command(unsigned char *);extern void print_sense(const char *, Scsi_Cmnd *);extern void print_driverbyte(int scsiresult);extern void print_hostbyte(int scsiresult);extern void scsi_mark_host_reset(struct Scsi_Host *Host);extern void scsi_mark_bus_reset(struct Scsi_Host *Host, int channel);#if defined(MAJOR_NR) && (MAJOR_NR != SCSI_TAPE_MAJOR)#include "hosts.h"static Scsi_Cmnd * end_scsi_request(Scsi_Cmnd * SCpnt, int uptodate, int sectors){    struct request * req;    struct buffer_head * bh;        req = &SCpnt->request;    req->errors = 0;    if (!uptodate) {#if defined(MAJOR_NR) && (MAJOR_NR == SCSI_DISK_MAJOR)	printk(DEVICE_NAME " I/O error: dev %s, sector %lu, absolute sector %lu\n",	       kdevname(req->rq_dev), req->sector, 	       req->sector + sd[MINOR(SCpnt->request.rq_dev)].start_sect);#else	printk(DEVICE_NAME " I/O error: dev %s, sector %lu\n",	       kdevname(req->rq_dev), req->sector);#endif    }        do {	if ((bh = req->bh) != NULL) {	    req->bh = bh->b_reqnext;	    req->nr_sectors -= bh->b_size >> 9;	    req->sector += bh->b_size >> 9;	    bh->b_reqnext = NULL;	    /*	     * This is our 'MD IO has finished' event handler.	     * note that b_state should be cached in a register	     * anyways, so the overhead if this checking is almost 	     * zero. But anyways .. we never get OO for free :)	     */	    if (test_bit(BH_MD, &bh->b_state)) {		struct md_personality * pers=(struct md_personality *)bh->personality;		pers->end_request(bh,uptodate);	    }	    /*	     * the normal (nonmirrored and no RAID5) case:	     */	    else {		mark_buffer_uptodate(bh, uptodate);		unlock_buffer(bh);	    }	    sectors -= bh->b_size >> 9;	    if ((bh = req->bh) != NULL) {		req->current_nr_sectors = bh->b_size >> 9;		if (req->nr_sectors < req->current_nr_sectors) {		    req->nr_sectors = req->current_nr_sectors;		    printk("end_scsi_request: buffer-list destroyed\n");		}	    }	}    } while(sectors && bh);    if (req->bh){	req->buffer = bh->b_data;	return SCpnt;    }    DEVICE_OFF(req->rq_dev);    if (req->sem != NULL) {	up(req->sem);    }    add_blkdev_randomness(MAJOR(req->rq_dev));        if (SCpnt->host->block) {	struct Scsi_Host * next;		for (next = SCpnt->host->block; next != SCpnt->host;	     next = next->block)	    wake_up(&next->host_wait);    }        req->rq_status = RQ_INACTIVE;    wake_up(&wait_for_request);    wake_up(&SCpnt->device->device_wait);    return NULL;}/* This is just like INIT_REQUEST, but we need to be aware of the fact * that an interrupt may start another request, so we run this with interrupts * turned off  */#define INIT_SCSI_REQUEST       \    if (!CURRENT) {             \	CLEAR_INTR;             \	restore_flags(flags);	\	return;                 \    }                           \    if (MAJOR(CURRENT->rq_dev) != MAJOR_NR)           \	panic(DEVICE_NAME ": request list destroyed");\    if (CURRENT->bh) {                                \	if (!buffer_locked(CURRENT->bh))              \	    panic(DEVICE_NAME ": block not locked");  \    }#endif#ifdef MACH#define SCSI_SLEEP(QUEUE, CONDITION) {		    \    if (CONDITION) {			            \	struct wait_queue wait = { NULL, NULL};     \	add_wait_queue(QUEUE, &wait);		    \	for(;;) {			            \	if (CONDITION) {		            \            if (intr_count)	                    \	        panic("scsi: trying to call schedule() in interrupt" \		      ", file %s, line %d.\n", __FILE__, __LINE__);  \	    schedule();			\        }				\	else			        \	    break;      		\	}			        \	remove_wait_queue(QUEUE, &wait);\    }; }#else /* !MACH */#define SCSI_SLEEP(QUEUE, CONDITION) {		    \    if (CONDITION) {			            \	struct wait_queue wait = { current, NULL};  \	add_wait_queue(QUEUE, &wait);		    \	for(;;) {			            \	current->state = TASK_UNINTERRUPTIBLE;	    \	if (CONDITION) {		            \            if (intr_count)	                    \	        panic("scsi: trying to call schedule() in interrupt" \		      ", file %s, line %d.\n", __FILE__, __LINE__);  \	    schedule();			\        }				\	else			        \	    break;      		\	}			        \	remove_wait_queue(QUEUE, &wait);\	current->state = TASK_RUNNING;	\    }; }#endif /* !MACH */#endif/* * Overrides for Emacs so that we follow Linus's tabbing style. * Emacs will notice this stuff at the end of the file and automatically * adjust the settings for this buffer only.  This must remain at the end * of the file. * --------------------------------------------------------------------------- * Local variables: * c-indent-level: 4  * c-brace-imaginary-offset: 0 * c-brace-offset: -4 * c-argdecl-indent: 4 * c-label-offset: -4 * c-continued-statement-offset: 4 * c-continued-brace-offset: 0 * indent-tabs-mode: nil * tab-width: 8 * End: */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -