The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sqtsec/sd.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1991 Carnegie Mellon University
    4  * Copyright (c) 1991 Sequent Computer Systems
    5  * All Rights Reserved.
    6  * 
    7  * Permission to use, copy, modify and distribute this software and its
    8  * documentation is hereby granted, provided that both the copyright
    9  * notice and this permission notice appear in all copies of the
   10  * software, derivative works or modified versions, and any portions
   11  * thereof, and that both notices appear in supporting documentation.
   12  * 
   13  * CARNEGIE MELLON AND SEQUENT COMPUTER SYSTEMS ALLOW FREE USE OF
   14  * THIS SOFTWARE IN ITS "AS IS" CONDITION.  CARNEGIE MELLON AND
   15  * SEQUENT COMPUTER SYSTEMS DISCLAIM ANY LIABILITY OF ANY KIND FOR
   16  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   17  * 
   18  * Carnegie Mellon requests users of this software to return to
   19  * 
   20  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   21  *  School of Computer Science
   22  *  Carnegie Mellon University
   23  *  Pittsburgh PA 15213-3890
   24  * 
   25  * any improvements or extensions that they make and grant Carnegie Mellon 
   26  * the rights to redistribute these changes.
   27  */
   28 
   29 /*
   30  * HISTORY
   31  * $Log:        sd.h,v $
   32  * Revision 2.3  91/07/31  18:07:23  dbg
   33  *      Changed copyright.
   34  *      [91/07/31            dbg]
   35  * 
   36  * Revision 2.2  91/05/08  13:06:52  dbg
   37  *      Adapted for pure Mach kernel.
   38  *      [90/10/04            dbg]
   39  * 
   40  */
   41 
   42 /*
   43  * $Header: sd.h,v 2.3 91/07/31 18:07:23 dbg Exp $
   44  */
   45 
   46 /*
   47  * sd.h
   48  *      SCSI driver definitions.
   49  */
   50 
   51 /*
   52  * Revision 1.1  89/07/05  13:20:14  kak
   53  * Initial revision
   54  * 
   55  */
   56 #ifndef _SQTSEC_SD_H_
   57 #define _SQTSEC_SD_H_
   58 
   59 #include <sys/types.h>
   60 #include <mach/time_value.h>
   61 #include <kern/lock.h>
   62 
   63 #include <device/buf.h>
   64 
   65 #include <sqt/mutex.h>
   66 
   67 /*
   68  * Partition table entry - driver local.
   69  */
   70 struct sd_partition {
   71         int     p_start;        /* starting block */
   72         int     p_length;       /* partition entry size */
   73 };
   74 
   75 /*
   76  * Information structure - one per channel.
   77  */
   78 struct sd_info{
   79         /*
   80          * flags, states, etc...
   81          */
   82         int     sd_stat;                /* low memory area for return status */
   83         int     sd_flags;               /* Local state flags */
   84         int     sd_retrys;              /* Configuration - max retrys */
   85         struct sec_dev_prog *sd_savedp; /* saved error'd device program ptr */
   86         u_char  sd_lun;                 /* Correct lun for this unit */
   87         daddr_t sd_size;                /* usable disk space */
   88 
   89         /*
   90          * Partition tables.
   91          */
   92         struct sd_partition *sd_part;   /* Straight from configuration */
   93 
   94         /*
   95          * Configuration information copied out at boot time.
   96          */
   97         int      sd_thresh;             /* Max to take off queue in sdstart */
   98         int      sd_low;                /* When to recall start from intr */
   99         struct   seddc  *sd_dc;         /* Device queues and controls */
  100         struct   sec_dev *sd_desc;      /* device descriptor for ta */
  101         u_char   *sd_sensebuf;          /* error sense buffer */
  102         u_char   *sd_sensebufptr;       /* iat of error sense buffer */
  103 
  104         /*
  105          * Buffers real and fiction.
  106          */
  107         char    *sd_rawbuf;             /* set at boot time to ..[sdrawsz] */
  108         struct  buf sd_bufh;            /* Header for strat */
  109         struct  buf sd_bp;              /* Header for start */
  110         struct  buf sd_rbufh;           /* Header for raw */
  111 
  112         /*
  113          * Statistics.
  114          */
  115         time_value_t    sd_starttime;   /* for elapse calculations */
  116         struct  dk      *sd_dk;         /* current stats pointer */
  117         int             sd_stat_unit;   /* system unit # for stat's */
  118 
  119         /*
  120          * Local data descriptors to the hardware.
  121          * Allocated and initialized at boot time.
  122          */
  123         simple_lock_data_t sd_lock;
  124         sema_t  sd_sema;
  125         struct  sec_req_sense sd_statb;
  126 };
  127 
  128 /*
  129  * Configuration structures.
  130  */
  131 struct sd_bconf {
  132         int bc_rawbuf_sz;               /* internal raw ioctl buf size */
  133         struct sd_partition  *bc_part;  /* partition table pointer */
  134         int bc_num_iat;                 /* number of iat's per channel */
  135         int bc_low;                     /* Max number before start slows */
  136         int bc_thresh;                  /* Maximum to get off queue each start*/
  137         long bc_blks_per_sec;           /* transfer rate in blocks per second */
  138         int bc_res1;                    /* reserved */
  139 };
  140 
  141 /*
  142  * misc
  143  */
  144 #define SD_ANYBIN       4               /* Only used during probe */
  145 #define SD_BASE         32              /* Start of units for SCSI */
  146 #define SDSPL           SPL5            /* spl priority on locks and semas */
  147 #define SD_ADDRALIGN    16              /* RAWIO must start on 16 byte bound */
  148 
  149 /*
  150  * SCSI driver macros
  151  */
  152 #define SD_PARTSHIFT    3               /* bit to shift to get unit */
  153 #define SD_PARTMASK     0x7             /* mask to get partition entry */
  154 #define SD_UNIT(dev)    (minor((dev)) >> SD_PARTSHIFT)
  155 #define SD_PART(dev)    (minor((dev)) & SD_PARTMASK)
  156 #define SD_IOCTL(bp)    (6)             /* stubbed see below */
  157 #define SD_NO_UNIT      -1              /* No unit number allocated for stats */
  158 #define SD_END          900000
  159 
  160 /*
  161  * The following macros are only for readability and are only
  162  * used in isolated cases. Driver changes that bring up new problems
  163  * should suspect these after verifing code correctness.
  164  */
  165 #define SD_CHANNEL(sd)  ((sd)->sd_chan) /* disk  # */
  166 
  167 /*
  168  *#define SD_IOCTL(bp)  (bp->b_resid)->rawcmd.cmdsize)
  169  * this macro is stubbed but it should really set the command size of
  170  * the requested SCSI io command.
  171  */
  172 
  173 /*
  174  * Scsi Device States and flags
  175  */
  176 #define SDS_IDLE                0               /* bufh == idle */
  177 #define SDS_PROBE               1               /* device is probing */
  178 #define SDS_BUSY                2               /* queue on bufh */
  179 
  180 #define SDF_SENSE               1               /* obtaining sense info */
  181 #define SDF_NOSTART             2               /* slow device stuffing a bit */
  182 
  183 /*
  184  * Additional masks
  185  */
  186 #define SDLUNMSK                0xe0            /* LUN data in SCSI cmd */
  187 #define SDKEY                   0x70            /* error class mask */
  188 
  189 #define SD_DONE                 0               /* stop */
  190 #define SD_NOTDONE              1               /* continue */
  191 
  192 /*
  193  * Ioctl commands.
  194  */
  195 #define SDI_STATS               1
  196 #define SDI_CMD                 2
  197 
  198 /*
  199  * Scsi Device Commands
  200  */
  201 #define SDC_TEST                0x00
  202 #define SDC_REQUEST_SENSE       0x03
  203 #define SDC_FORMAT              0x04
  204 #define SDC_READ                0x08
  205 #define SDC_WRITE               0x0A
  206 #define SDC_INQUIRY             0x12
  207 #define SDC_MODE_SELECT         0x15
  208 #define SDC_MODE_SENSE          0x1A
  209 #define SDC_READ_CAPACITY       0x25
  210 #define SDC_SPECIAL             0xFF    /* user filled out cmd struct */
  211 
  212 /*
  213  * Sizes of SCSI commands
  214  */
  215 #define SD_CMD6SZ       6
  216 #define SD_CMD10SZ      10
  217 
  218 /*
  219  * Length of data returned from SCSI commands
  220  */
  221 #define SDD_TEST        0
  222 #define SDD_INQ         5
  223 #define SDD_READC       8
  224 #define SDD_REQSEN      13
  225 #define SDD_MODE        20
  226 #define SDMAXDATASZ     20
  227 
  228 /*
  229  * Read Capacity command returned data
  230  */
  231 struct sdcap {
  232                                 /* highest addressable block on disk: */
  233         u_char sdc_nblocks0;    /* MSB */
  234         u_char sdc_nblocks1;
  235         u_char sdc_nblocks2;
  236         u_char sdc_nblocks3;    /* LSB */
  237                                 /* formatted size of disk blocks: */
  238         u_char sdc_bsize0;      /* MSB */
  239         u_char sdc_bsize1;
  240         u_char sdc_bsize2;
  241         u_char sdc_bsize3;      /* LSB */
  242 };
  243 
  244 /*
  245  * Request Sense returned data - supply support for both extended sense and
  246  * non-extended.
  247  */
  248 
  249 struct sdreqsense {
  250         u_char sdr_class;       /* valid bit, error class - 0xf0 in CCS disks */
  251         u_char sdr_segnum;      /* segment number */
  252         u_char sdr_sensekey;    /* which error group */
  253         u_char sdr_info[4];     /* information - sometimes block # of error */
  254         u_char sdr_other[5];
  255         u_char sdr_errorcode;   /* specific error */
  256 };
  257 
  258 /*
  259  * defines which deal with request sense data
  260  */
  261 
  262 #define SD_SENSEKEYMASK         0x0f            /* valid part of sdr_sensekey */
  263 #define SD_RECOVERED            0x01            /* drive recovered error */
  264 #define SD_UNIT_ATTN            0x06            /* Unit Attention sense key */
  265 
  266 /*
  267  * Inquiry command returned data
  268  */
  269 
  270 struct sdinq {
  271         u_char sdq_devtype;
  272         u_char sdq_rmb;
  273         u_char sdq_pad;
  274         u_char sdq_format;      /* always 0 for adaptec, always 1 for CCS */
  275 };
  276 
  277 /*
  278  * Mode Sense - Mode Select data
  279  */
  280 
  281 struct sd_modes {
  282         u_char sdm_sdlength;    /* sense data length */
  283         u_char sdm_type;        /* medium type */
  284         u_char sdm_pad0;
  285         u_char sdm_bdlength;    /* block descriptor length */
  286         u_char sdm_density;     /* density code */
  287         u_char sdm_nblks[3];    /* number of blocks */
  288         u_char sdm_pad1;
  289         u_char sdm_blength[3];  /* block length */
  290                                 /* error recovery page - page code 1 */
  291         u_char sdm_pgcode;      /* page code */
  292         u_char sdm_pglength;    /* page length */
  293         u_char sdm_bits;        /* various error-recovery bits */
  294         u_char sdm_retry;       /* retry count */
  295         u_char sdm_corr;        /* correction span */
  296         u_char sdm_headoff;     /* head offset count */
  297         u_char sdm_dsoff;       /* data strobe offset count */
  298         u_char sdm_recov;       /* recovery time limit */
  299 };
  300 
  301 /*
  302  * mode sense/select page codes
  303  */
  304 
  305 #define SDM_MODES       0x0     /* just return block descriptor */
  306 #define SDM_ERROR       0x1     /* error recovery page */
  307 #define SDM_CONN        0x2     /* disconnect/reconnect page */
  308 #define SDM_FORMAT      0x3     /* format parameter page */
  309 #define SDM_GEOM        0x4     /* rigid disk drive geometry page */
  310 #define SDM_ALL         0x3f    /* return all of the above pages */
  311 
  312 /*
  313  * sdm_bits defines
  314  */
  315 
  316 #define SDE_DCR         0x1     /* Disable Correction */
  317 #define SDE_DTE         0x2     /* Disable transfer on error */
  318 #define SDE_PER         0x4     /* Post error */
  319 #define SDE_EEC         0x8     /* Enable early correction */
  320 #define SDE_RC          0x10    /* Read continuous */
  321 #define SDE_TB          0x20    /* Transfer block */
  322 #define SDE_ARRE        0x40    /* Automatic read reallocation enabled */
  323 #define SDE_AWRE        0x80    /* Automatic write reallocation enabled */
  324 
  325 /*
  326  * misc defines for mode sense/select
  327  */
  328 
  329 #define SDM_PF          0x10    /* Page Format bit for mode select */
  330 
  331 /*
  332  * macros for extracting the LBA from extended and non-extended Request
  333  * sense bytes.
  334  */
  335 
  336 #define XgetLBA(b) \
  337         (u_int) (((((b[3] << 8) | b[4]) << 8) | b[5]) << 8) | b[6]
  338 
  339 #define getLBA(b) \
  340         (u_int) (((b[1]<< 8) | b[2]) << 8) | b[3]
  341 
  342 #endif  /* _SQTSEC_SD_H_ */

Cache object: 5899c5a44f3499873980e89d60aaa9a4


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.