Annotation of Gnu-Mach/scsi/scsi_defs.h, revision 1.1

1.1     ! root        1: /* 
        !             2:  * Mach Operating System
        !             3:  * Copyright (c) 1993-1989 Carnegie Mellon University
        !             4:  * All Rights Reserved.
        !             5:  * 
        !             6:  * Permission to use, copy, modify and distribute this software and its
        !             7:  * documentation is hereby granted, provided that both the copyright
        !             8:  * notice and this permission notice appear in all copies of the
        !             9:  * software, derivative works or modified versions, and any portions
        !            10:  * thereof, and that both notices appear in supporting documentation.
        !            11:  * 
        !            12:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            13:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
        !            14:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            15:  * 
        !            16:  * Carnegie Mellon requests users of this software to return to
        !            17:  * 
        !            18:  *  Software Distribution Coordinator  or  [email protected]
        !            19:  *  School of Computer Science
        !            20:  *  Carnegie Mellon University
        !            21:  *  Pittsburgh PA 15213-3890
        !            22:  * 
        !            23:  * any improvements or extensions that they make and grant Carnegie Mellon
        !            24:  * the rights to redistribute these changes.
        !            25:  */
        !            26: /*
        !            27:  *     File: scsi_defs.h
        !            28:  *     Author: Alessandro Forin, Carnegie Mellon University
        !            29:  *     Date:   9/90
        !            30:  *
        !            31:  *     Controller-independent definitions for the SCSI driver
        !            32:  */
        !            33: 
        !            34: #ifndef        _SCSI_SCSI_DEFS_H_
        !            35: #define        _SCSI_SCSI_DEFS_H_
        !            36: 
        !            37: #include <kern/queue.h>
        !            38: #include <kern/lock.h>
        !            39: 
        !            40: #include <rz_labels.h>
        !            41: 
        !            42: #define        await(event)    sleep(event,0)
        !            43: extern void wakeup();
        !            44: 
        !            45: typedef        vm_offset_t     opaque_t;       /* should be elsewhere */
        !            46: 
        !            47: /*
        !            48:  * Internal error codes, and return values
        !            49:  * XXX use the mach/error.h scheme XXX
        !            50:  */
        !            51: typedef unsigned int           scsi_ret_t;
        !            52: 
        !            53: #define        SCSI_ERR_GRAVITY(x)     ((unsigned)(x)&0xf0000000U)
        !            54: #define        SCSI_ERR_GRAVE          0x80000000U
        !            55: #define SCSI_ERR_BAD           0x40000000
        !            56: 
        !            57: #define        SCSI_ERR_CLASS(x)       ((unsigned)(x)&0x0fffffffU)
        !            58: #define        SCSI_ERR_STATUS         0x00000001
        !            59: #define        SCSI_ERR_SENSE          0x00000002
        !            60: #define SCSI_ERR_MSEL          0x00000004
        !            61: 
        !            62: extern void    scsi_error(/* target_info_t *, unsigned, unsigned */);
        !            63: 
        !            64: #define        SCSI_RET_IN_PROGRESS    0x00
        !            65: #define        SCSI_RET_SUCCESS        0x01
        !            66: #define        SCSI_RET_RETRY          0x02
        !            67: #define SCSI_RET_NEED_SENSE    0x04
        !            68: #define SCSI_RET_ABORTED       0x08
        !            69: #define        SCSI_RET_DEVICE_DOWN    0x10
        !            70: 
        !            71: /*
        !            72:  * Device-specific information kept by driver
        !            73:  */
        !            74: #define MAX_SCSI_PARTS 32      /* maximum partitions on a disk;can be larger */
        !            75: typedef struct {
        !            76:        struct disklabel        l;  /* NOT accurate. partitions stored below */
        !            77:        struct {
        !            78:            unsigned int        badblockno;
        !            79:            unsigned int        save_rec;
        !            80:            char                *save_addr;
        !            81:            int                 save_count;
        !            82:            int                 save_resid;
        !            83:            int                 retry_count;
        !            84:        } b;
        !            85: #if 0 /* no longer used by partition code */
        !            86:        int                     labelsector;
        !            87:        int                     labeloffset;
        !            88: #endif 0
        !            89:        struct diskpart scsi_array[MAX_SCSI_PARTS]; /* new partition info */
        !            90: } scsi_disk_info_t;
        !            91: 
        !            92: typedef struct {
        !            93:        boolean_t       read_only;
        !            94:        unsigned int    speed;
        !            95:        unsigned int    density;
        !            96:        unsigned int    maxreclen;
        !            97:        boolean_t       fixed_size;
        !            98: } scsi_tape_info_t;
        !            99: 
        !           100: typedef struct {
        !           101:        char            req_pending;
        !           102:        char            req_id;
        !           103:        char            req_lun;
        !           104:        char            req_cmd;
        !           105:        unsigned int    req_len;
        !           106:        /* more later */
        !           107: } scsi_processor_info_t;
        !           108: 
        !           109: typedef struct {
        !           110:        void            *result;
        !           111:        boolean_t       result_available;
        !           112:        int             result_size;
        !           113:        struct red_list *violates_standards;
        !           114: } scsi_cdrom_info_t;
        !           115: 
        !           116: typedef struct {
        !           117: #      define SCSI_MAX_COMM_TTYS       16
        !           118:        struct tty      *tty[SCSI_MAX_COMM_TTYS];
        !           119:        io_req_t        ior;
        !           120: } scsi_comm_info_t;
        !           121: 
        !           122: /*
        !           123:  * Device descriptor
        !           124:  */
        !           125: 
        !           126: #define        SCSI_TARGET_NAME_LEN    8+16+4+8        /* our way to keep it */
        !           127: 
        !           128: typedef struct target_info {
        !           129:        queue_chain_t   links;                  /* to queue for bus */
        !           130:        io_req_t        ior;                    /* what we are doing */
        !           131: 
        !           132:        unsigned int    flags;
        !           133: #define        TGT_DID_SYNCH           0x00000001      /* finished the synch neg */
        !           134: #define        TGT_TRY_SYNCH           0x00000002      /* do the synch negotiation */
        !           135: #define        TGT_FULLY_PROBED        0x00000004      /* can sleep to wait */
        !           136: #define        TGT_ONLINE              0x00000008      /* did the once-only stuff */
        !           137: #define        TGT_ALIVE               0x00000010
        !           138: #define        TGT_BBR_ACTIVE          0x00000020      /* bad block replc in progress */
        !           139: #define        TGT_DISCONNECTED        0x00000040      /* waiting for reconnect */
        !           140: #define        TGT_WRITTEN_TO          0x00000080      /* tapes: needs a filemark on close */
        !           141: #define        TGT_REWIND_ON_CLOSE     0x00000100      /* tapes: rewind */
        !           142: #define        TGT_BIG                 0x00000200      /* disks: > 1Gb, use long R/W */
        !           143: #define        TGT_REMOVABLE_MEDIA     0x00000400      /* e.g. floppy, cd-rom,.. */
        !           144: #define        TGT_READONLY            0x00000800      /* cd-rom, scanner, .. */
        !           145: #define        TGT_OPTIONAL_CMD        0x00001000      /* optional cmd, ignore errors */
        !           146: #define TGT_WRITE_LABEL                0x00002000      /* disks: enable overwriting of label */
        !           147: #define        TGT_US                  0x00004000      /* our desc, when target role */
        !           148: 
        !           149: #define        TGT_HW_SPECIFIC_BITS    0xffff0000U     /* see specific HBA */
        !           150:        char            *hw_state;              /* opaque */
        !           151:        char            *dma_ptr;
        !           152:        char            *cmd_ptr;
        !           153:        struct scsi_devsw_struct        *dev_ops;       /* circularity */
        !           154:        struct target_info      *next_lun;      /* if multi-LUN */
        !           155:        char            target_id;
        !           156:        char            unit_no;
        !           157:        unsigned char   sync_period;
        !           158:        unsigned char   sync_offset;
        !           159:        decl_simple_lock_data(,target_lock)
        !           160: #ifdef MACH_KERNEL
        !           161: #else  /*MACH_KERNEL*/
        !           162:        struct fdma     fdma;
        !           163: #endif /*MACH_KERNEL*/
        !           164:        /*
        !           165:         * State info kept while waiting to seize bus, either for first
        !           166:         * selection or while in disconnected state
        !           167:         */
        !           168:        struct {
        !           169:            struct script       *script;
        !           170:            int                 (*handler)();
        !           171:            unsigned int        out_count;
        !           172:            unsigned int        in_count;
        !           173:            unsigned int        copy_count;     /* optional */
        !           174:            unsigned int        dma_offset;
        !           175:            unsigned char       identify;
        !           176:            unsigned char       cmd_count;
        !           177:            unsigned char       hba_dep[2];
        !           178:        } transient_state;
        !           179:        unsigned int    block_size;
        !           180:        volatile char   done;
        !           181:        unsigned char   cur_cmd;
        !           182:        unsigned char   lun;
        !           183:        char            masterno;
        !           184:        char            tgt_name[SCSI_TARGET_NAME_LEN];
        !           185:        union {
        !           186:            scsi_disk_info_t    disk;
        !           187:            scsi_tape_info_t    tape;
        !           188:            scsi_cdrom_info_t   cdrom;
        !           189:            scsi_processor_info_t       cpu;
        !           190:            scsi_comm_info_t    comm;
        !           191:        } dev_info;
        !           192: } target_info_t;
        !           193: 
        !           194: 
        !           195: /*
        !           196:  * Device-specific operations
        !           197:  */
        !           198: typedef struct scsi_devsw_struct {
        !           199:        char            *(*driver_name)(boolean_t);       /* my driver's name */
        !           200:        void            (*optimize)(target_info_t *);     /* tune up internal params */
        !           201:        scsi_ret_t      (*open)(target_info_t *,io_req_t);/* open time ops */
        !           202:        scsi_ret_t      (*close)(target_info_t *);        /* close time ops */
        !           203:        int             (*strategy)(io_req_t);            /* sort/start routine */
        !           204:        void            (*restart)(target_info_t *,
        !           205:                                   boolean_t);            /* completion routine */
        !           206:        io_return_t     (*get_status)(int, 
        !           207:                                      target_info_t *,
        !           208:                                      dev_flavor_t,
        !           209:                                      dev_status_t,
        !           210:                                      natural_t *);       /* specialization */
        !           211:        io_return_t     (*set_status)(int, 
        !           212:                                      target_info_t *,
        !           213:                                      dev_flavor_t,
        !           214:                                      dev_status_t,
        !           215:                                      natural_t);         /* specialization */
        !           216: } scsi_devsw_t;
        !           217: 
        !           218: #define SCSI_OPTIMIZE_NULL ((void (*)(target_info_t *)) 0)
        !           219: #define SCSI_OPEN_NULL ((scsi_ret_t (*)(target_info_t *,io_req_t)) 0)
        !           220: #define SCSI_CLOSE_NULL ((scsi_ret_t (*)(target_info_t *)) 0)
        !           221: 
        !           222: extern scsi_devsw_t    scsi_devsw[];
        !           223: 
        !           224: /*
        !           225:  * HBA descriptor
        !           226:  */
        !           227: 
        !           228: typedef struct {
        !           229:        /* initiator (us) state */
        !           230:        unsigned char   initiator_id;
        !           231:        unsigned char   masterno;
        !           232:        unsigned int    max_dma_data;
        !           233:        char            *hw_state;              /* opaque */
        !           234:        int             (*go)();
        !           235:        void            (*watchdog)();
        !           236:        boolean_t       (*probe)();
        !           237:        /* per-target state */
        !           238:        target_info_t           *target[8];
        !           239: } scsi_softc_t;
        !           240: 
        !           241: extern scsi_softc_t    *scsi_softc[];
        !           242: extern scsi_softc_t    *scsi_master_alloc(/* int unit */);
        !           243: extern target_info_t   *scsi_slave_alloc(/* int unit, int slave, char *hw */);
        !           244: 
        !           245: #define        BGET(d,mid,id)  (d[mid] & (1 << id))            /* bitmap ops */
        !           246: #define BSET(d,mid,id) d[mid] |= (1 << id)
        !           247: #define BCLR(d,mid,id) d[mid] &= ~(1 << id)
        !           248: 
        !           249: extern unsigned char   scsi_no_synchronous_xfer[];     /* one bitmap per ctlr */
        !           250: extern unsigned char   scsi_use_long_form[];           /* one bitmap per ctlr */
        !           251: extern unsigned char   scsi_might_disconnect[];        /* one bitmap per ctlr */
        !           252: extern unsigned char   scsi_should_disconnect[];       /* one bitmap per ctlr */
        !           253: extern unsigned char   scsi_initiator_id[];            /* one id per ctlr */
        !           254: 
        !           255: extern boolean_t       scsi_exabyte_filemarks;
        !           256: extern boolean_t       scsi_no_automatic_bbr;
        !           257: extern int             scsi_bbr_retries;
        !           258: extern int             scsi_watchdog_period;
        !           259: extern int             scsi_delay_after_reset;
        !           260: extern unsigned int    scsi_per_target_virtual;        /* 2.5 only */
        !           261: 
        !           262: extern int             scsi_debug;
        !           263: 
        !           264: /*
        !           265:  * HBA-independent Watchdog
        !           266:  */
        !           267: typedef struct {
        !           268: 
        !           269:        unsigned short  reset_count;
        !           270:        char            nactive;
        !           271: 
        !           272:        char            watchdog_state;
        !           273: 
        !           274: #define SCSI_WD_INACTIVE       0
        !           275: #define        SCSI_WD_ACTIVE          1
        !           276: #define SCSI_WD_EXPIRED                2
        !           277: 
        !           278:        int             (*reset)();
        !           279: 
        !           280: } watchdog_t;
        !           281: 
        !           282: extern void scsi_watchdog( watchdog_t* );
        !           283: 
        !           284: #endif _SCSI_SCSI_DEFS_H_

unix.superglobalmegacorp.com

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