Annotation of Gnu-Mach/i386/i386at/gpl/linux/scsi/scsi.h, revision 1.1

1.1     ! root        1: /*
        !             2:  *  scsi.h Copyright (C) 1992 Drew Eckhardt 
        !             3:  *         Copyright (C) 1993, 1994, 1995 Eric Youngdale
        !             4:  *  generic SCSI package header file by
        !             5:  *      Initial versions: Drew Eckhardt
        !             6:  *      Subsequent revisions: Eric Youngdale
        !             7:  *
        !             8:  *  <[email protected]>
        !             9:  *
        !            10:  *       Modified by Eric Youngdale [email protected] to
        !            11:  *       add scatter-gather, multiple outstanding request, and other
        !            12:  *       enhancements.
        !            13:  */
        !            14: 
        !            15: #ifndef _SCSI_H
        !            16: #define _SCSI_H
        !            17: 
        !            18: /*
        !            19:  * Some of the public constants are being moved to this file.
        !            20:  * We include it here so that what came from where is transparent.
        !            21:  */
        !            22: #include <linux/scsi.h>
        !            23: 
        !            24: 
        !            25: /*
        !            26:  * Some defs, in case these are not defined elsewhere.
        !            27:  */
        !            28: #ifndef TRUE
        !            29: # define TRUE 1
        !            30: #endif
        !            31: #ifndef FALSE
        !            32: # define FALSE 0
        !            33: #endif
        !            34: 
        !            35: #ifdef MACH
        !            36: #ifndef LINUX_SCSI_DEBUG
        !            37: #undef DEBUG
        !            38: #endif
        !            39: #endif
        !            40: 
        !            41: extern void scsi_make_blocked_list(void);
        !            42: extern volatile int in_scan_scsis;
        !            43: extern const unsigned char scsi_command_size[8];
        !            44: #define COMMAND_SIZE(opcode) scsi_command_size[((opcode) >> 5) & 7]
        !            45: 
        !            46: #define IDENTIFY_BASE       0x80
        !            47: #define IDENTIFY(can_disconnect, lun)   (IDENTIFY_BASE |\
        !            48:                     ((can_disconnect) ?  0x40 : 0) |\
        !            49:                     ((lun) & 0x07)) 
        !            50: 
        !            51:                 
        !            52:     
        !            53: /*
        !            54:  *  the return of the status word will be in the following format :
        !            55:  *  The low byte is the status returned by the SCSI command, 
        !            56:  *  with vendor specific bits masked.
        !            57:  *  
        !            58:  *  The next byte is the message which followed the SCSI status.
        !            59:  *  This allows a stos to be used, since the Intel is a little
        !            60:  *  endian machine.
        !            61:  *  
        !            62:  *  The final byte is a host return code, which is one of the following.
        !            63:  *  
        !            64:  *  IE 
        !            65:  *  lsb     msb
        !            66:  *  status  msg host code   
        !            67:  *  
        !            68:  *  Our errors returned by OUR driver, NOT SCSI message.  Or'd with
        !            69:  *  SCSI message passed back to driver <IF any>.
        !            70:  */
        !            71: 
        !            72: 
        !            73: #define DID_OK          0x00 /* NO error                                */
        !            74: #define DID_NO_CONNECT  0x01 /* Couldn't connect before timeout period  */
        !            75: #define DID_BUS_BUSY    0x02 /* BUS stayed busy through time out period */
        !            76: #define DID_TIME_OUT    0x03 /* TIMED OUT for other reason              */
        !            77: #define DID_BAD_TARGET  0x04 /* BAD target.                             */
        !            78: #define DID_ABORT       0x05 /* Told to abort for some other reason     */
        !            79: #define DID_PARITY      0x06 /* Parity error                            */
        !            80: #define DID_ERROR       0x07 /* Internal error                          */
        !            81: #define DID_RESET       0x08 /* Reset by somebody.                      */
        !            82: #define DID_BAD_INTR    0x09 /* Got an interrupt we weren't expecting.  */ 
        !            83: #define DRIVER_OK       0x00 /* Driver status                           */ 
        !            84: 
        !            85: /*
        !            86:  *  These indicate the error that occurred, and what is available.
        !            87:  */
        !            88: 
        !            89: #define DRIVER_BUSY         0x01
        !            90: #define DRIVER_SOFT         0x02
        !            91: #define DRIVER_MEDIA        0x03
        !            92: #define DRIVER_ERROR        0x04    
        !            93: 
        !            94: #define DRIVER_INVALID      0x05
        !            95: #define DRIVER_TIMEOUT      0x06
        !            96: #define DRIVER_HARD         0x07
        !            97: #define DRIVER_SENSE       0x08
        !            98: 
        !            99: #define SUGGEST_RETRY       0x10
        !           100: #define SUGGEST_ABORT       0x20 
        !           101: #define SUGGEST_REMAP       0x30
        !           102: #define SUGGEST_DIE         0x40
        !           103: #define SUGGEST_SENSE       0x80
        !           104: #define SUGGEST_IS_OK       0xff
        !           105: 
        !           106: #define DRIVER_MASK         0x0f
        !           107: #define SUGGEST_MASK        0xf0
        !           108: 
        !           109: #define MAX_COMMAND_SIZE    12
        !           110: 
        !           111: /*
        !           112:  *  SCSI command sets
        !           113:  */
        !           114: 
        !           115: #define SCSI_UNKNOWN    0
        !           116: #define SCSI_1          1
        !           117: #define SCSI_1_CCS      2
        !           118: #define SCSI_2          3
        !           119: 
        !           120: /*
        !           121:  *  Every SCSI command starts with a one byte OP-code.
        !           122:  *  The next byte's high three bits are the LUN of the
        !           123:  *  device.  Any multi-byte quantities are stored high byte
        !           124:  *  first, and may have a 5 bit MSB in the same byte
        !           125:  *  as the LUN.
        !           126:  */
        !           127: 
        !           128: /*
        !           129:  *      Manufacturers list
        !           130:  */
        !           131: 
        !           132: #define SCSI_MAN_UNKNOWN     0
        !           133: #define SCSI_MAN_NEC         1
        !           134: #define SCSI_MAN_TOSHIBA     2
        !           135: #define SCSI_MAN_NEC_OLDCDR  3
        !           136: #define SCSI_MAN_SONY        4
        !           137: #define SCSI_MAN_PIONEER     5
        !           138: 
        !           139: /*
        !           140:  *  As the scsi do command functions are intelligent, and may need to
        !           141:  *  redo a command, we need to keep track of the last command
        !           142:  *  executed on each one.
        !           143:  */
        !           144: 
        !           145: #define WAS_RESET       0x01
        !           146: #define WAS_TIMEDOUT    0x02
        !           147: #define WAS_SENSE       0x04
        !           148: #define IS_RESETTING    0x08
        !           149: #define IS_ABORTING     0x10
        !           150: #define ASKED_FOR_SENSE 0x20
        !           151: 
        !           152: /*
        !           153:  *  The scsi_device struct contains what we know about each given scsi
        !           154:  *  device.
        !           155:  */
        !           156: 
        !           157: typedef struct scsi_device {
        !           158:     struct scsi_device * next;      /* Used for linked list */
        !           159: 
        !           160:     unsigned char id, lun, channel;
        !           161: 
        !           162:     unsigned int manufacturer;      /* Manufacturer of device, for using 
        !           163:                                     * vendor-specific cmd's */
        !           164:     int attached;                   /* # of high level drivers attached to 
        !           165:                                     * this */
        !           166:     int access_count;               /* Count of open channels/mounts */
        !           167:     struct wait_queue * device_wait;/* Used to wait if device is busy */
        !           168:     struct Scsi_Host * host;
        !           169:     void (*scsi_request_fn)(void);  /* Used to jumpstart things after an 
        !           170:                                     * ioctl */
        !           171:     void *hostdata;                 /* available to low-level driver */
        !           172:     char type;
        !           173:     char scsi_level;
        !           174:     char vendor[8], model[16], rev[4];
        !           175:     unsigned char current_tag;      /* current tag */
        !           176:     unsigned char sync_min_period;  /* Not less than this period */
        !           177:     unsigned char sync_max_offset;  /* Not greater than this offset */
        !           178: 
        !           179:     unsigned writeable:1;
        !           180:     unsigned removable:1; 
        !           181:     unsigned random:1;
        !           182:     unsigned has_cmdblocks:1;
        !           183:     unsigned changed:1;             /* Data invalid due to media change */
        !           184:     unsigned busy:1;                /* Used to prevent races */
        !           185:     unsigned lockable:1;            /* Able to prevent media removal */
        !           186:     unsigned borken:1;              /* Tell the Seagate driver to be 
        !           187:                                     * painfully slow on this device */ 
        !           188:     unsigned tagged_supported:1;    /* Supports SCSI-II tagged queuing */
        !           189:     unsigned tagged_queue:1;        /* SCSI-II tagged queuing enabled */
        !           190:     unsigned disconnect:1;          /* can disconnect */
        !           191:     unsigned soft_reset:1;          /* Uses soft reset option */
        !           192:     unsigned sync:1;                /* Negotiate for sync transfers */
        !           193:     unsigned single_lun:1;          /* Indicates we should only allow I/O to
        !           194:                                        one of the luns for the device at a time. */
        !           195:     unsigned was_reset:1;      /* There was a bus reset on the bus for this
        !           196:                                    device */
        !           197:     unsigned expecting_cc_ua:1;    /* Expecting a CHECK_CONDITION/UNIT_ATTN
        !           198:                                       because we did a bus reset. */
        !           199: } Scsi_Device;
        !           200: 
        !           201: /*
        !           202:  *  Use these to separate status msg and our bytes
        !           203:  */
        !           204: 
        !           205: #define status_byte(result) (((result) >> 1) & 0xf)
        !           206: #define msg_byte(result)    (((result) >> 8) & 0xff)
        !           207: #define host_byte(result)   (((result) >> 16) & 0xff)
        !           208: #define driver_byte(result) (((result) >> 24) & 0xff)
        !           209: #define suggestion(result)  (driver_byte(result) & SUGGEST_MASK)
        !           210: 
        !           211: #define sense_class(sense)  (((sense) >> 4) & 0x7)
        !           212: #define sense_error(sense)  ((sense) & 0xf)
        !           213: #define sense_valid(sense)  ((sense) & 0x80);
        !           214: 
        !           215: /*
        !           216:  *  These are the SCSI devices available on the system.
        !           217:  */
        !           218: 
        !           219: extern Scsi_Device * scsi_devices;
        !           220: 
        !           221: /*
        !           222:  *  Initializes all SCSI devices.  This scans all scsi busses.
        !           223:  */ 
        !           224: 
        !           225: extern int scsi_dev_init (void);
        !           226: 
        !           227: struct scatterlist {
        !           228:     char *  address;    /* Location data is to be transferred to */
        !           229:     char * alt_address; /* Location of actual if address is a 
        !           230:                         * dma indirect buffer.  NULL otherwise */
        !           231:     unsigned int length;
        !           232: };
        !           233: 
        !           234: #ifdef __alpha__
        !           235: # define ISA_DMA_THRESHOLD (~0UL)
        !           236: #else
        !           237: # define ISA_DMA_THRESHOLD (0x00ffffff)
        !           238: #endif
        !           239: #define CONTIGUOUS_BUFFERS(X,Y) ((X->b_data+X->b_size) == Y->b_data)
        !           240: 
        !           241: 
        !           242: /*
        !           243:  * These are the return codes for the abort and reset functions.  The mid-level
        !           244:  * code uses these to decide what to do next.  Each of the low level abort
        !           245:  * and reset functions must correctly indicate what it has done.
        !           246:  * The descriptions are written from the point of view of the mid-level code,
        !           247:  * so that the return code is telling the mid-level drivers exactly what
        !           248:  * the low level driver has already done, and what remains to be done.
        !           249:  */
        !           250: 
        !           251: /* We did not do anything.  
        !           252:  * Wait some more for this command to complete, and if this does not work, 
        !           253:  * try something more serious. */ 
        !           254: #define SCSI_ABORT_SNOOZE 0
        !           255: 
        !           256: /* This means that we were able to abort the command.  We have already
        !           257:  * called the mid-level done function, and do not expect an interrupt that 
        !           258:  * will lead to another call to the mid-level done function for this command */
        !           259: #define SCSI_ABORT_SUCCESS 1
        !           260: 
        !           261: /* We called for an abort of this command, and we should get an interrupt 
        !           262:  * when this succeeds.  Thus we should not restore the timer for this
        !           263:  * command in the mid-level abort function. */
        !           264: #define SCSI_ABORT_PENDING 2
        !           265: 
        !           266: /* Unable to abort - command is currently on the bus.  Grin and bear it. */
        !           267: #define SCSI_ABORT_BUSY 3
        !           268: 
        !           269: /* The command is not active in the low level code. Command probably
        !           270:  * finished. */
        !           271: #define SCSI_ABORT_NOT_RUNNING 4
        !           272: 
        !           273: /* Something went wrong.  The low level driver will indicate the correct
        !           274:  * error condition when it calls scsi_done, so the mid-level abort function
        !           275:  * can simply wait until this comes through */
        !           276: #define SCSI_ABORT_ERROR 5
        !           277: 
        !           278: /* We do not know how to reset the bus, or we do not want to.  Bummer.
        !           279:  * Anyway, just wait a little more for the command in question, and hope that
        !           280:  * it eventually finishes.  If it never finishes, the SCSI device could
        !           281:  * hang, so use this with caution. */
        !           282: #define SCSI_RESET_SNOOZE 0
        !           283: 
        !           284: /* We do not know how to reset the bus, or we do not want to.  Bummer.
        !           285:  * We have given up on this ever completing.  The mid-level code will
        !           286:  * request sense information to decide how to proceed from here. */
        !           287: #define SCSI_RESET_PUNT 1
        !           288: 
        !           289: /* This means that we were able to reset the bus.  We have restarted all of
        !           290:  * the commands that should be restarted, and we should be able to continue
        !           291:  * on normally from here.  We do not expect any interrupts that will return
        !           292:  * DID_RESET to any of the other commands in the host_queue, and the mid-level
        !           293:  * code does not need to do anything special to keep the commands alive. 
        !           294:  * If a hard reset was performed then all outstanding commands on the
        !           295:  * bus have been restarted. */
        !           296: #define SCSI_RESET_SUCCESS 2
        !           297: 
        !           298: /* We called for a reset of this bus, and we should get an interrupt 
        !           299:  * when this succeeds.  Each command should get its own status
        !           300:  * passed up to scsi_done, but this has not happened yet. 
        !           301:  * If a hard reset was performed, then we expect an interrupt
        !           302:  * for *each* of the outstanding commands that will have the
        !           303:  * effect of restarting the commands.
        !           304:  */
        !           305: #define SCSI_RESET_PENDING 3
        !           306: 
        !           307: /* We did a reset, but do not expect an interrupt to signal DID_RESET.
        !           308:  * This tells the upper level code to request the sense info, and this
        !           309:  * should keep the command alive. */
        !           310: #define SCSI_RESET_WAKEUP 4
        !           311: 
        !           312: /* Something went wrong, and we do not know how to fix it. */
        !           313: #define SCSI_RESET_ERROR 5
        !           314: 
        !           315: /*
        !           316:  * This is a bitmask that is ored with one of the above codes.
        !           317:  * It tells the mid-level code that we did a hard reset.
        !           318:  */
        !           319: #define SCSI_RESET_BUS_RESET 0x100
        !           320: /*
        !           321:  * Used to mask off bits and to obtain the basic action that was
        !           322:  * performed.  
        !           323:  */
        !           324: #define SCSI_RESET_ACTION   0xff
        !           325: 
        !           326: void *   scsi_malloc(unsigned int);
        !           327: int      scsi_free(void *, unsigned int);
        !           328: extern unsigned int dma_free_sectors;  /* How much room do we have left */
        !           329: extern unsigned int need_isa_buffer;   /* True if some devices need indirection
        !           330:                                        * buffers */
        !           331: 
        !           332: /*
        !           333:  * The Scsi_Cmnd structure is used by scsi.c internally, and for communication
        !           334:  * with low level drivers that support multiple outstanding commands.
        !           335:  */
        !           336: typedef struct scsi_pointer {
        !           337:     char * ptr;                     /* data pointer */
        !           338:     int this_residual;              /* left in this buffer */
        !           339:     struct scatterlist *buffer;     /* which buffer */
        !           340:     int buffers_residual;           /* how many buffers left */
        !           341:     
        !           342:     volatile int Status;
        !           343:     volatile int Message;
        !           344:     volatile int have_data_in;
        !           345:     volatile int sent_command;
        !           346:     volatile int phase;
        !           347: } Scsi_Pointer;
        !           348: 
        !           349: typedef struct scsi_cmnd {
        !           350:     struct Scsi_Host * host;
        !           351:     Scsi_Device * device;
        !           352:     unsigned char target, lun, channel;
        !           353:     unsigned char cmd_len;
        !           354:     unsigned char old_cmd_len;
        !           355:     struct scsi_cmnd *next, *prev;  
        !           356:     
        !           357:     /* These elements define the operation we are about to perform */
        !           358:     unsigned char cmnd[12];
        !           359:     unsigned request_bufflen;  /* Actual request size */
        !           360:     
        !           361:     void * request_buffer;     /* Actual requested buffer */
        !           362:     
        !           363:     /* These elements define the operation we ultimately want to perform */
        !           364:     unsigned char data_cmnd[12];
        !           365:     unsigned short old_use_sg; /* We save  use_sg here when requesting
        !           366:                                 * sense info */
        !           367:     unsigned short use_sg;     /* Number of pieces of scatter-gather */
        !           368:     unsigned short sglist_len; /* size of malloc'd scatter-gather list */
        !           369:     unsigned short abort_reason;/* If the mid-level code requests an
        !           370:                                 * abort, this is the reason. */
        !           371:     unsigned bufflen;          /* Size of data buffer */
        !           372:     void *buffer;              /* Data buffer */
        !           373:     
        !           374:     unsigned underflow;                /* Return error if less than this amount is 
        !           375:                                 * transfered */
        !           376:     
        !           377:     unsigned transfersize;     /* How much we are guaranteed to transfer with
        !           378:                                 * each SCSI transfer (ie, between disconnect /
        !           379:                                 * reconnects.   Probably == sector size */
        !           380:     
        !           381:     
        !           382:     struct request request;    /* A copy of the command we are working on */
        !           383: 
        !           384:     unsigned char sense_buffer[16];  /* Sense for this command, if needed */
        !           385: 
        !           386: 
        !           387:     int retries;
        !           388:     int allowed;
        !           389:     int timeout_per_command, timeout_total, timeout;
        !           390: 
        !           391:     /*
        !           392:      * We handle the timeout differently if it happens when a reset, 
        !           393:      * abort, etc are in process. 
        !           394:      */
        !           395:     unsigned volatile char internal_timeout;
        !           396:     
        !           397:     unsigned flags;
        !           398:     
        !           399:     /* These variables are for the cdrom only. Once we have variable size 
        !           400:      * buffers in the buffer cache, they will go away. */
        !           401:     int this_count; 
        !           402:     /* End of special cdrom variables */
        !           403:     
        !           404:     /* Low-level done function - can be used by low-level driver to point
        !           405:      * to completion function.  Not used by mid/upper level code. */
        !           406:     void (*scsi_done)(struct scsi_cmnd *);  
        !           407:     void (*done)(struct scsi_cmnd *);  /* Mid-level done function */
        !           408:     
        !           409:     /*
        !           410:      * The following fields can be written to by the host specific code. 
        !           411:      * Everything else should be left alone. 
        !           412:      */
        !           413:     
        !           414:     Scsi_Pointer SCp;  /* Scratchpad used by some host adapters */
        !           415:     
        !           416:     unsigned char * host_scribble; /* The host adapter is allowed to
        !           417:                                    * call scsi_malloc and get some memory
        !           418:                                    * and hang it here.  The host adapter
        !           419:                                    * is also expected to call scsi_free
        !           420:                                    * to release this memory.  (The memory
        !           421:                                    * obtained by scsi_malloc is guaranteed
        !           422:                                    * to be at an address < 16Mb). */
        !           423:     
        !           424:     int result;                           /* Status code from lower level driver */
        !           425:     
        !           426:     unsigned char tag;            /* SCSI-II queued command tag */
        !           427:     unsigned long pid;            /* Process ID, starts at 0 */
        !           428: } Scsi_Cmnd;        
        !           429: 
        !           430: /*
        !           431:  *  scsi_abort aborts the current command that is executing on host host.
        !           432:  *  The error code, if non zero is returned in the host byte, otherwise 
        !           433:  *  DID_ABORT is returned in the hostbyte.
        !           434:  */
        !           435: 
        !           436: extern int scsi_abort (Scsi_Cmnd *, int code, int pid);
        !           437: 
        !           438: extern void scsi_do_cmd (Scsi_Cmnd *, const void *cmnd ,
        !           439:                         void *buffer, unsigned bufflen, 
        !           440:                         void (*done)(struct scsi_cmnd *),
        !           441:                         int timeout, int retries);
        !           442: 
        !           443: 
        !           444: extern Scsi_Cmnd * allocate_device(struct request **, Scsi_Device *, int);
        !           445: 
        !           446: extern Scsi_Cmnd * request_queueable(struct request *, Scsi_Device *);
        !           447: extern int scsi_reset (Scsi_Cmnd *, int);
        !           448: 
        !           449: extern int max_scsi_hosts;
        !           450: 
        !           451: extern void proc_print_scsidevice(Scsi_Device *, char *, int *, int);
        !           452: 
        !           453: extern void print_command(unsigned char *);
        !           454: extern void print_sense(const char *, Scsi_Cmnd *);
        !           455: extern void print_driverbyte(int scsiresult);
        !           456: extern void print_hostbyte(int scsiresult);
        !           457: 
        !           458: extern void scsi_mark_host_bus_reset(struct Scsi_Host *Host);
        !           459: 
        !           460: #if defined(MAJOR_NR) && (MAJOR_NR != SCSI_TAPE_MAJOR)
        !           461: #include "hosts.h"
        !           462: 
        !           463: static Scsi_Cmnd * end_scsi_request(Scsi_Cmnd * SCpnt, int uptodate, int sectors)
        !           464: {
        !           465:     struct request * req;
        !           466:     struct buffer_head * bh;
        !           467:     
        !           468:     req = &SCpnt->request;
        !           469:     if (!uptodate) {
        !           470:        printk(DEVICE_NAME " I/O error: dev %s, sector %lu\n",
        !           471:               kdevname(req->rq_dev), req->sector);
        !           472: #ifdef MACH
        !           473:         req->errors = 1;
        !           474:         while (req->bh) {
        !           475:             bh = req->bh;
        !           476:             req->bh = bh->b_reqnext;
        !           477:             mark_buffer_uptodate(bh, 0);
        !           478:             unlock_buffer(bh);
        !           479:         }
        !           480:         goto done;
        !           481: #endif
        !           482:     }
        !           483:     
        !           484:     do {
        !           485:        if ((bh = req->bh) != NULL) {
        !           486:            req->bh = bh->b_reqnext;
        !           487:            req->nr_sectors -= bh->b_size >> 9;
        !           488:            req->sector += bh->b_size >> 9;
        !           489:            bh->b_reqnext = NULL;
        !           490:            mark_buffer_uptodate(bh, uptodate);
        !           491:            unlock_buffer(bh);
        !           492:            sectors -= bh->b_size >> 9;
        !           493:            if ((bh = req->bh) != NULL) {
        !           494:                req->current_nr_sectors = bh->b_size >> 9;
        !           495:                if (req->nr_sectors < req->current_nr_sectors) {
        !           496:                    req->nr_sectors = req->current_nr_sectors;
        !           497:                    printk("end_scsi_request: buffer-list destroyed\n");
        !           498:                }
        !           499:            }
        !           500:        }
        !           501:     } while(sectors && bh);
        !           502:     if (req->bh){
        !           503:        req->buffer = bh->b_data;
        !           504:        return SCpnt;
        !           505:     };
        !           506: #ifdef MACH
        !           507:     req->errors = 0;
        !           508: 
        !           509: done:
        !           510: #endif
        !           511:     DEVICE_OFF(req->rq_dev);
        !           512:     if (req->sem != NULL) {
        !           513:        up(req->sem);
        !           514:     }
        !           515:     
        !           516:     if (SCpnt->host->block) {
        !           517:        struct Scsi_Host * next;
        !           518:        
        !           519:        for (next = SCpnt->host->block; next != SCpnt->host;
        !           520:             next = next->block)
        !           521:            wake_up(&next->host_wait);
        !           522:     }
        !           523:     
        !           524:     req->rq_status = RQ_INACTIVE;
        !           525: #ifndef MACH
        !           526:     wake_up(&wait_for_request);
        !           527: #endif
        !           528:     wake_up(&SCpnt->device->device_wait);
        !           529: #ifdef MACH
        !           530:     {
        !           531:         unsigned long flags;
        !           532: 
        !           533:         save_flags(flags);
        !           534:         cli();
        !           535:         (*blk_dev[MAJOR(req->rq_dev)].request_fn)();
        !           536:         restore_flags(flags);
        !           537:     }
        !           538: #endif
        !           539:     return NULL;
        !           540: }
        !           541: 
        !           542: 
        !           543: /* This is just like INIT_REQUEST, but we need to be aware of the fact
        !           544:  * that an interrupt may start another request, so we run this with interrupts
        !           545:  * turned off 
        !           546:  */
        !           547: #define INIT_SCSI_REQUEST       \
        !           548:     if (!CURRENT) {             \
        !           549:        CLEAR_INTR;             \
        !           550:        restore_flags(flags);   \
        !           551:        return;                 \
        !           552:     }                           \
        !           553:     if (MAJOR(CURRENT->rq_dev) != MAJOR_NR)           \
        !           554:        panic(DEVICE_NAME ": request list destroyed");\
        !           555:     if (CURRENT->bh) {                                \
        !           556:        if (!buffer_locked(CURRENT->bh))              \
        !           557:            panic(DEVICE_NAME ": block not locked");  \
        !           558:     }
        !           559: #endif
        !           560: 
        !           561: #ifdef MACH
        !           562: #define SCSI_SLEEP(QUEUE, CONDITION) {             \
        !           563:     if (CONDITION) {                               \
        !           564:        struct wait_queue wait = { NULL, NULL};     \
        !           565:        add_wait_queue(QUEUE, &wait);               \
        !           566:        for(;;) {                                   \
        !           567:        if (CONDITION) {                            \
        !           568:             if (intr_count)                        \
        !           569:                panic("scsi: trying to call schedule() in interrupt" \
        !           570:                      ", file %s, line %d.\n", __FILE__, __LINE__);  \
        !           571:            schedule();                 \
        !           572:         }                              \
        !           573:        else                            \
        !           574:            break;                      \
        !           575:        }                               \
        !           576:        remove_wait_queue(QUEUE, &wait);\
        !           577:     }; }
        !           578: #else /* ! MACH */
        !           579: #define SCSI_SLEEP(QUEUE, CONDITION) {             \
        !           580:     if (CONDITION) {                               \
        !           581:        struct wait_queue wait = { current, NULL};  \
        !           582:        add_wait_queue(QUEUE, &wait);               \
        !           583:        for(;;) {                                   \
        !           584:        current->state = TASK_UNINTERRUPTIBLE;      \
        !           585:        if (CONDITION) {                            \
        !           586:             if (intr_count)                        \
        !           587:                panic("scsi: trying to call schedule() in interrupt" \
        !           588:                      ", file %s, line %d.\n", __FILE__, __LINE__);  \
        !           589:            schedule();                 \
        !           590:         }                              \
        !           591:        else                            \
        !           592:            break;                      \
        !           593:        }                               \
        !           594:        remove_wait_queue(QUEUE, &wait);\
        !           595:        current->state = TASK_RUNNING;  \
        !           596:     }; }
        !           597: #endif /* ! MACH */
        !           598: 
        !           599: #endif
        !           600: 
        !           601: /*
        !           602:  * Overrides for Emacs so that we follow Linus's tabbing style.
        !           603:  * Emacs will notice this stuff at the end of the file and automatically
        !           604:  * adjust the settings for this buffer only.  This must remain at the end
        !           605:  * of the file.
        !           606:  * ---------------------------------------------------------------------------
        !           607:  * Local variables:
        !           608:  * c-indent-level: 4 
        !           609:  * c-brace-imaginary-offset: 0
        !           610:  * c-brace-offset: -4
        !           611:  * c-argdecl-indent: 4
        !           612:  * c-label-offset: -4
        !           613:  * c-continued-statement-offset: 4
        !           614:  * c-continued-brace-offset: 0
        !           615:  * indent-tabs-mode: nil
        !           616:  * tab-width: 8
        !           617:  * End:
        !           618:  */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.