Home | History | Annotate | Line # | Download | only in scsipi
scsi_disk.h revision 1.17.26.2
      1  1.17.26.2  jdolecek /*	$NetBSD: scsi_disk.h,v 1.17.26.2 2002/09/06 08:46:22 jdolecek Exp $	*/
      2        1.5       cgd 
      3        1.1       cgd /*
      4       1.11    bouyer  * SCSI-specific interface description
      5        1.4   mycroft  */
      6        1.4   mycroft 
      7        1.4   mycroft /*
      8        1.4   mycroft  * Some lines of this file come from a file of the name "scsi.h"
      9        1.1       cgd  * distributed by OSF as part of mach2.5,
     10        1.1       cgd  *  so the following disclaimer has been kept.
     11        1.1       cgd  *
     12        1.1       cgd  * Copyright 1990 by Open Software Foundation,
     13        1.1       cgd  * Grenoble, FRANCE
     14        1.1       cgd  *
     15        1.1       cgd  * 		All Rights Reserved
     16       1.12     enami  *
     17        1.1       cgd  *   Permission to use, copy, modify, and distribute this software and
     18        1.1       cgd  * its documentation for any purpose and without fee is hereby granted,
     19        1.1       cgd  * provided that the above copyright notice appears in all copies and
     20        1.1       cgd  * that both the copyright notice and this permission notice appear in
     21        1.1       cgd  * supporting documentation, and that the name of OSF or Open Software
     22        1.1       cgd  * Foundation not be used in advertising or publicity pertaining to
     23        1.1       cgd  * distribution of the software without specific, written prior
     24        1.1       cgd  * permission.
     25       1.12     enami  *
     26        1.1       cgd  *   OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
     27        1.1       cgd  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
     28        1.1       cgd  * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
     29        1.1       cgd  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
     30        1.1       cgd  * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
     31        1.1       cgd  * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
     32        1.1       cgd  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     33        1.1       cgd  */
     34        1.1       cgd 
     35        1.1       cgd /*
     36        1.1       cgd  * Largely written by Julian Elischer (julian (at) tfs.com)
     37        1.1       cgd  * for TRW Financial Systems.
     38        1.1       cgd  *
     39        1.1       cgd  * TRW Financial Systems, in accordance with their agreement with Carnegie
     40        1.1       cgd  * Mellon University, makes this software available to CMU to distribute
     41       1.12     enami  * or use in any manner that they see fit as long as this message is kept with
     42        1.1       cgd  * the software. For this reason TFS also grants any other persons or
     43        1.1       cgd  * organisations permission to use or modify this software.
     44        1.1       cgd  *
     45        1.1       cgd  * TFS supplies this software to be publicly redistributed
     46        1.1       cgd  * on the understanding that TFS is not responsible for the correct
     47        1.1       cgd  * functioning of this software in any circumstances.
     48        1.1       cgd  *
     49        1.1       cgd  * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992
     50        1.1       cgd  */
     51        1.1       cgd 
     52        1.1       cgd /*
     53        1.1       cgd  * SCSI command format
     54        1.1       cgd  */
     55       1.17   thorpej 
     56       1.17   thorpej /*
     57       1.17   thorpej  * XXX Is this also used by ATAPI?
     58       1.17   thorpej  */
     59       1.17   thorpej #define	SCSI_FORMAT_UNIT		0x04
     60       1.17   thorpej struct scsi_format_unit {
     61       1.17   thorpej 	u_int8_t opcode;
     62       1.17   thorpej 	u_int8_t flags;
     63       1.17   thorpej #define	SFU_DLF_MASK	0x07
     64       1.17   thorpej #define	SFU_CMPLST	0x08
     65       1.17   thorpej #define	SFU_FMTDATA	0x10
     66       1.17   thorpej 	u_int8_t vendor_specific;
     67       1.17   thorpej 	u_int8_t interleave[2];
     68       1.17   thorpej 	u_int8_t control;
     69       1.17   thorpej };
     70       1.17   thorpej 
     71       1.17   thorpej /*
     72       1.17   thorpej  * If the FmtData bit is set, a FORMAT UNIT parameter list is transfered
     73       1.17   thorpej  * to the target during the DATA OUT phase.  The parameter list includes
     74       1.17   thorpej  *
     75       1.17   thorpej  *	Defect list header
     76       1.17   thorpej  *	Initialization pattern descriptor (if any)
     77       1.17   thorpej  *	Defect descriptor(s) (if any)
     78       1.17   thorpej  */
     79       1.17   thorpej 
     80       1.17   thorpej struct scsi_format_unit_defect_list_header {
     81       1.17   thorpej 	u_int8_t reserved;
     82       1.17   thorpej 	u_int8_t flags;
     83       1.17   thorpej #define	DLH_VS		0x01		/* vendor specific */
     84       1.17   thorpej #define	DLH_IMMED	0x02		/* immediate return */
     85       1.17   thorpej #define	DLH_DSP		0x04		/* disable saving parameters */
     86       1.17   thorpej #define	DLH_IP		0x08		/* initialization pattern */
     87       1.17   thorpej #define	DLH_STPF	0x10		/* stop format */
     88       1.17   thorpej #define	DLH_DCRT	0x20		/* disable certification */
     89       1.17   thorpej #define	DLH_DPRY	0x40		/* disable primary */
     90       1.17   thorpej #define	DLH_FOV		0x80		/* format options valid */
     91       1.17   thorpej 	u_int8_t defect_lst_len[2];
     92       1.17   thorpej };
     93       1.17   thorpej 
     94       1.17   thorpej /*
     95       1.17   thorpej  * See Table 117 of the SCSI-2 specification for a description of
     96       1.17   thorpej  * the IP modifier.
     97       1.17   thorpej  */
     98       1.17   thorpej struct scsi_initialization_pattern_descriptor {
     99       1.17   thorpej 	u_int8_t ip_modifier;
    100       1.17   thorpej 	u_int8_t pattern_type;
    101       1.17   thorpej #define	IP_TYPE_DEFAULT		0x01
    102       1.17   thorpej #define	IP_TYPE_REPEAT		0x01
    103       1.17   thorpej 				/* 0x02 -> 0x7f: reserved */
    104       1.17   thorpej 				/* 0x80 -> 0xff: vendor-specific */
    105       1.17   thorpej 	u_int8_t pattern_length[2];
    106       1.17   thorpej #if 0
    107       1.17   thorpej 	u_int8_t pattern[...];
    108       1.17   thorpej #endif
    109       1.17   thorpej };
    110       1.17   thorpej 
    111       1.17   thorpej /*
    112       1.17   thorpej  * Defect desciptors.  These are used as the defect lists in the FORMAT UNIT
    113       1.17   thorpej  * and READ DEFECT DATA commands, and as the translate page of the
    114       1.17   thorpej  * SEND DIAGNOSTIC and RECEIVE DIAGNOSTIC RESULTS commands.
    115       1.17   thorpej  */
    116       1.17   thorpej 
    117       1.17   thorpej /* Block format */
    118       1.17   thorpej struct scsi_defect_descriptor_bf {
    119       1.17   thorpej 	u_int8_t block_address[4];
    120       1.17   thorpej };
    121       1.17   thorpej 
    122       1.17   thorpej /* Bytes from index format */
    123       1.17   thorpej struct scsi_defect_descriptor_bfif {
    124  1.17.26.2  jdolecek 	u_int8_t cylinder[3];
    125       1.17   thorpej 	u_int8_t head;
    126  1.17.26.2  jdolecek 	u_int8_t bytes_from_index[4];
    127       1.17   thorpej };
    128       1.17   thorpej 
    129       1.17   thorpej /* Physical sector format */
    130       1.17   thorpej struct scsi_defect_descriptor_psf {
    131  1.17.26.2  jdolecek 	u_int8_t cylinder[3];
    132       1.17   thorpej 	u_int8_t head;
    133  1.17.26.2  jdolecek 	u_int8_t sector[4];
    134       1.17   thorpej };
    135        1.1       cgd 
    136       1.11    bouyer /*
    137       1.11    bouyer  * XXX for now this isn't in the ATAPI specs, but if there are on day
    138       1.11    bouyer  * ATAPI hard disks, it is likely that they implement this command (or a
    139       1.11    bouyer  * command like this ?
    140       1.11    bouyer  */
    141       1.11    bouyer #define	SCSI_REASSIGN_BLOCKS		0x07
    142        1.7   mycroft struct scsi_reassign_blocks {
    143        1.9   mycroft 	u_int8_t opcode;
    144        1.9   mycroft 	u_int8_t byte2;
    145        1.9   mycroft 	u_int8_t unused[3];
    146       1.13   thorpej 	u_int8_t control;
    147       1.13   thorpej };
    148       1.13   thorpej 
    149       1.13   thorpej /*
    150       1.13   thorpej  * XXX Is this also used by ATAPI?
    151       1.13   thorpej  */
    152       1.13   thorpej #define	SCSI_REZERO_UNIT		0x01
    153       1.13   thorpej struct scsi_rezero_unit {
    154       1.13   thorpej 	u_int8_t opcode;
    155       1.13   thorpej 	u_int8_t byte2;
    156       1.13   thorpej 	u_int8_t reserved[3];
    157        1.9   mycroft 	u_int8_t control;
    158        1.1       cgd };
    159        1.1       cgd 
    160       1.11    bouyer #define	SCSI_READ_COMMAND		0x08
    161       1.11    bouyer #define SCSI_WRITE_COMMAND		0x0a
    162        1.7   mycroft struct scsi_rw {
    163        1.9   mycroft 	u_int8_t opcode;
    164        1.9   mycroft 	u_int8_t addr[3];
    165        1.4   mycroft #define	SRW_TOPADDR	0x1F	/* only 5 bits here */
    166        1.9   mycroft 	u_int8_t length;
    167       1.16   thorpej 	u_int8_t control;
    168       1.16   thorpej };
    169       1.16   thorpej 
    170       1.16   thorpej /*
    171       1.16   thorpej  * XXX Does ATAPI have an equivalent?
    172       1.16   thorpej  */
    173       1.16   thorpej #define	SCSI_SYNCHRONIZE_CACHE		0x35
    174       1.16   thorpej struct scsi_synchronize_cache {
    175       1.16   thorpej 	u_int8_t opcode;
    176       1.16   thorpej 	u_int8_t flags;
    177       1.16   thorpej #define	SSC_RELADR	0x01
    178       1.16   thorpej #define	SSC_IMMED	0x02
    179       1.16   thorpej 	u_int8_t addr[4];
    180       1.16   thorpej 	u_int8_t reserved;
    181       1.16   thorpej 	u_int8_t length[2];
    182        1.9   mycroft 	u_int8_t control;
    183        1.1       cgd };
    184        1.1       cgd 
    185       1.11    bouyer /* DATAs definitions for the above commands */
    186        1.1       cgd 
    187        1.7   mycroft struct scsi_reassign_blocks_data {
    188        1.9   mycroft 	u_int8_t reserved[2];
    189        1.9   mycroft 	u_int8_t length[2];
    190        1.7   mycroft 	struct {
    191        1.9   mycroft 		u_int8_t dlbaddr[4];
    192        1.1       cgd 	} defect_descriptor[1];
    193        1.1       cgd };
    194        1.1       cgd 
    195       1.11    bouyer union scsi_disk_pages {
    196        1.9   mycroft #define	DISK_PGCODE	0x3F	/* only 6 bits valid */
    197        1.1       cgd 	struct page_disk_format {
    198        1.9   mycroft 		u_int8_t pg_code;	/* page code (should be 3) */
    199        1.9   mycroft 		u_int8_t pg_length;	/* page length (should be 0x16) */
    200        1.9   mycroft 		u_int8_t trk_z[2];	/* tracks per zone */
    201        1.9   mycroft 		u_int8_t alt_sec[2];	/* alternate sectors per zone */
    202        1.9   mycroft 		u_int8_t alt_trk_z[2];	/* alternate tracks per zone */
    203        1.9   mycroft 		u_int8_t alt_trk_v[2];	/* alternate tracks per volume */
    204        1.9   mycroft 		u_int8_t ph_sec_t[2];	/* physical sectors per track */
    205        1.9   mycroft 		u_int8_t bytes_s[2];	/* bytes per sector */
    206        1.9   mycroft 		u_int8_t interleave[2];	/* interleave */
    207        1.9   mycroft 		u_int8_t trk_skew[2];	/* track skew factor */
    208        1.9   mycroft 		u_int8_t cyl_skew[2];	/* cylinder skew */
    209        1.9   mycroft 		u_int8_t flags;		/* various */
    210        1.9   mycroft #define	DISK_FMT_SURF	0x10
    211        1.9   mycroft #define	DISK_FMT_RMB	0x20
    212        1.9   mycroft #define	DISK_FMT_HSEC	0x40
    213        1.9   mycroft #define	DISK_FMT_SSEC	0x80
    214        1.9   mycroft 		u_int8_t reserved2;
    215        1.9   mycroft 		u_int8_t reserved3;
    216        1.1       cgd 	} disk_format;
    217        1.1       cgd 	struct page_rigid_geometry {
    218        1.9   mycroft 		u_int8_t pg_code;	/* page code (should be 4) */
    219        1.9   mycroft 		u_int8_t pg_length;	/* page length (should be 0x16)	*/
    220        1.9   mycroft 		u_int8_t ncyl[3];	/* number of cylinders */
    221        1.9   mycroft 		u_int8_t nheads;	/* number of heads */
    222        1.9   mycroft 		u_int8_t st_cyl_wp[3];	/* starting cyl., write precomp */
    223        1.9   mycroft 		u_int8_t st_cyl_rwc[3];	/* starting cyl., red. write cur */
    224        1.9   mycroft 		u_int8_t driv_step[2];	/* drive step rate */
    225        1.9   mycroft 		u_int8_t land_zone[3];	/* landing zone cylinder */
    226        1.9   mycroft 		u_int8_t sp_sync_ctl;	/* spindle synch control */
    227        1.8   thorpej #define SPINDLE_SYNCH_MASK	0x03	/* mask of valid bits */
    228        1.8   thorpej #define SPINDLE_SYNCH_NONE	0x00	/* synch disabled or not supported */
    229        1.8   thorpej #define SPINDLE_SYNCH_SLAVE	0x01	/* disk is a slave */
    230        1.8   thorpej #define SPINDLE_SYNCH_MASTER	0x02	/* disk is a master */
    231        1.8   thorpej #define SPINDLE_SYNCH_MCONTROL	0x03	/* disk is a master control */
    232        1.9   mycroft 		u_int8_t rot_offset;	/* rotational offset (for spindle synch) */
    233        1.9   mycroft 		u_int8_t reserved1;
    234        1.9   mycroft 		u_int8_t rpm[2];	/* media rotation speed */
    235        1.9   mycroft 		u_int8_t reserved2;
    236        1.9   mycroft 		u_int8_t reserved3;
    237        1.1       cgd     	} rigid_geometry;
    238       1.10  christos 	struct page_flex_geometry {
    239       1.10  christos 		u_int8_t pg_code;	/* page code (should be 5) */
    240       1.10  christos 		u_int8_t pg_length;	/* page length (should be 0x1e) */
    241       1.10  christos 		u_int8_t xfr_rate[2];
    242       1.10  christos 		u_int8_t nheads;	/* number of heads */
    243       1.10  christos 		u_int8_t ph_sec_tr;	/* physical sectors per track */
    244       1.10  christos 		u_int8_t bytes_s[2];	/* bytes per sector */
    245       1.10  christos 		u_int8_t ncyl[2];	/* number of cylinders */
    246       1.10  christos 		u_int8_t st_cyl_wp[2];	/* start cyl., write precomp */
    247       1.10  christos 		u_int8_t st_cyl_rwc[2];	/* start cyl., red. write cur */
    248       1.10  christos 		u_int8_t driv_step[2];	/* drive step rate */
    249       1.10  christos 		u_int8_t driv_step_w;	/* drive step pulse width */
    250       1.10  christos 		u_int8_t head_settle[2];/* head settle delay */
    251       1.10  christos 		u_int8_t motor_on;	/* motor on delay */
    252       1.10  christos 		u_int8_t motor_off;	/* motor off delay */
    253       1.10  christos 		u_int8_t flags;		/* various flags */
    254       1.10  christos #define MOTOR_ON		0x20	/* motor on (pin 16)? */
    255       1.10  christos #define START_AT_SECTOR_1	0x40	/* start at sector 1  */
    256       1.10  christos #define READY_VALID		0x20	/* RDY (pin 34) valid */
    257       1.10  christos 		u_int8_t step_p_cyl;	/* step pulses per cylinder */
    258       1.10  christos 		u_int8_t write_pre;	/* write precompensation */
    259       1.10  christos 		u_int8_t head_load;	/* head load delay */
    260       1.10  christos 		u_int8_t head_unload;	/* head unload delay */
    261       1.10  christos 		u_int8_t pin_34_2;	/* pin 34 (6) pin 2 (7/11) definition */
    262       1.10  christos 		u_int8_t pin_4_1;	/* pin 4 (8/9) pin 1 (13) definition */
    263       1.10  christos 		u_int8_t reserved1;
    264       1.10  christos 		u_int8_t reserved2;
    265       1.10  christos 		u_int8_t reserved3;
    266       1.10  christos 		u_int8_t reserved4;
    267       1.10  christos 	} flex_geometry;
    268  1.17.26.1   thorpej 	struct page_caching {
    269  1.17.26.1   thorpej 		u_int8_t pg_code;	/* page code (should be 8) */
    270  1.17.26.1   thorpej 		u_int8_t pg_length;	/* page length (should be 0x0a) */
    271  1.17.26.1   thorpej 		u_int8_t flags;		/* cache parameter flags */
    272  1.17.26.1   thorpej #define	CACHING_RCD	0x01		/* read cache disable */
    273  1.17.26.1   thorpej #define	CACHING_MF	0x02		/* multiplcation factor */
    274  1.17.26.1   thorpej #define	CACHING_WCE	0x04		/* write cache enable (write-back) */
    275  1.17.26.1   thorpej #define	CACHING_SIZE	0x08		/* use CACHE SEGMENT SIZE */
    276  1.17.26.1   thorpej #define	CACHING_DISC	0x10		/* pftch across time discontinuities */
    277  1.17.26.1   thorpej #define	CACHING_CAP	0x20		/* caching analysis permitted */
    278  1.17.26.1   thorpej #define	CACHING_ABPF	0x40		/* abort prefetch */
    279  1.17.26.1   thorpej #define	CACHING_IC	0x80		/* initiator control */
    280  1.17.26.1   thorpej 		u_int8_t ret_prio;	/* retention priority */
    281  1.17.26.1   thorpej #define	READ_RET_PRIO_SHIFT 4
    282  1.17.26.1   thorpej #define	RET_PRIO_DONT_DISTINGUISH	0x0
    283  1.17.26.1   thorpej #define	RET_PRIO_REPLACE_READ_WRITE	0x1
    284  1.17.26.1   thorpej #define	RET_PRIO_REPLACE_PREFETCH	0xf
    285  1.17.26.1   thorpej 		u_int8_t dis_prefetch_xfer_len[2];
    286  1.17.26.1   thorpej 		u_int8_t min_prefetch[2];
    287  1.17.26.1   thorpej 		u_int8_t max_prefetch[2];
    288  1.17.26.1   thorpej 		u_int8_t max_prefetch_ceiling[2];
    289  1.17.26.1   thorpej 		u_int8_t flags2;	/* additional cache param flags */
    290  1.17.26.1   thorpej #define	CACHING2_VS0	0x08		/* vendor specific bit */
    291  1.17.26.1   thorpej #define	CACHING2_VS1	0x10		/* vendor specific bit */
    292  1.17.26.1   thorpej #define	CACHING2_DRA	0x20		/* disable read ahead */
    293  1.17.26.1   thorpej #define	CACHING2_LBCSS	0x40		/* CACHE SEGMENT SIZE is blocks */
    294  1.17.26.1   thorpej #define	CACHING2_FSW	0x80		/* force sequential write */
    295  1.17.26.1   thorpej 		u_int8_t num_cache_segments;
    296  1.17.26.1   thorpej 		u_int8_t cache_segment_size[2];
    297  1.17.26.1   thorpej 		u_int8_t reserved1;
    298  1.17.26.1   thorpej 		u_int8_t non_cache_segment_size[2];
    299  1.17.26.1   thorpej 	} caching_params;
    300        1.7   mycroft };
    301