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