1 /* $OpenBSD: scsi_disk.h,v 1.16 2005/07/03 04:03:25 krw 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 struct scsi_rezero_unit { 153 u_int8_t opcode; 154 u_int8_t byte2; 155 u_int8_t reserved[3]; 156 u_int8_t control; 157 }; 158 159 struct scsi_rw { 160 u_int8_t opcode; 161 u_int8_t addr[3]; 162 #define SRW_TOPADDR 0x1F /* only 5 bits here */ 163 u_int8_t length; 164 u_int8_t control; 165 }; 166 167 struct scsi_rw_big { 168 u_int8_t opcode; 169 u_int8_t byte2; 170 #define SRWB_RELADDR 0x01 171 u_int8_t addr[4]; 172 u_int8_t reserved; 173 u_int8_t length[2]; 174 u_int8_t control; 175 }; 176 177 struct scsi_read_capacity { 178 u_int8_t opcode; 179 u_int8_t byte2; 180 u_int8_t addr[4]; 181 u_int8_t unused[3]; 182 u_int8_t control; 183 }; 184 185 struct scsi_start_stop { 186 u_int8_t opcode; 187 u_int8_t byte2; 188 u_int8_t unused[2]; 189 u_int8_t how; 190 #define SSS_STOP 0x00 191 #define SSS_START 0x01 192 #define SSS_LOEJ 0x02 193 u_int8_t control; 194 }; 195 196 197 /* 198 * XXX Does ATAPI have an equivalent? 199 */ 200 #define SYNCHRONIZE_CACHE 0x35 201 struct scsi_synchronize_cache { 202 u_int8_t opcode; 203 u_int8_t flags; 204 #define SSC_RELADR 0x01 205 #define SSC_IMMED 0x02 206 u_int8_t addr[4]; 207 u_int8_t reserved; 208 u_int8_t length[2]; 209 u_int8_t control; 210 }; 211 212 213 214 /* 215 * Disk specific opcodes 216 */ 217 #define REASSIGN_BLOCKS 0x07 218 #define READ_COMMAND 0x08 219 #define WRITE_COMMAND 0x0a 220 #define READ_CAPACITY 0x25 221 #define READ_BIG 0x28 222 #define WRITE_BIG 0x2a 223 #define SYNCHRONIZE_CACHE 0x35 224 225 226 struct scsi_read_cap_data { 227 u_int8_t addr[4]; 228 u_int8_t length[4]; 229 }; 230 231 struct scsi_reassign_blocks_data { 232 u_int8_t reserved[2]; 233 u_int8_t length[2]; 234 struct { 235 u_int8_t dlbaddr[4]; 236 } defect_descriptor[1]; 237 }; 238 239 union scsi_disk_pages { 240 #define DISK_PGCODE 0x3F /* only 6 bits valid */ 241 struct page_disk_format { 242 u_int8_t pg_code; /* page code (should be 3) */ 243 u_int8_t pg_length; /* page length (should be 0x16) */ 244 u_int8_t trk_z[2]; /* tracks per zone */ 245 u_int8_t alt_sec[2]; /* alternate sectors per zone */ 246 u_int8_t alt_trk_z[2]; /* alternate tracks per zone */ 247 u_int8_t alt_trk_v[2]; /* alternate tracks per volume */ 248 u_int8_t ph_sec_t[2]; /* physical sectors per track */ 249 u_int8_t bytes_s[2]; /* bytes per sector */ 250 u_int8_t interleave[2]; /* interleave */ 251 u_int8_t trk_skew[2]; /* track skew factor */ 252 u_int8_t cyl_skew[2]; /* cylinder skew */ 253 u_int8_t flags; /* various */ 254 #define DISK_FMT_SURF 0x10 255 #define DISK_FMT_RMB 0x20 256 #define DISK_FMT_HSEC 0x40 257 #define DISK_FMT_SSEC 0x80 258 u_int8_t reserved1; 259 u_int8_t reserved2; 260 u_int8_t reserved3; 261 } disk_format; 262 struct page_rigid_geometry { 263 u_int8_t pg_code; /* page code (should be 4) */ 264 u_int8_t pg_length; /* page length (should be 0x16) */ 265 u_int8_t ncyl[3]; /* number of cylinders */ 266 u_int8_t nheads; /* number of heads */ 267 u_int8_t st_cyl_wp[3]; /* starting cyl., write precomp */ 268 u_int8_t st_cyl_rwc[3]; /* starting cyl., red. write cur */ 269 u_int8_t driv_step[2]; /* drive step rate */ 270 u_int8_t land_zone[3]; /* landing zone cylinder */ 271 u_int8_t sp_sync_ctl; /* spindle synch control */ 272 #define SPINDLE_SYNCH_MASK 0x03 /* mask of valid bits */ 273 #define SPINDLE_SYNCH_NONE 0x00 /* synch disabled or not supported */ 274 #define SPINDLE_SYNCH_SLAVE 0x01 /* disk is a slave */ 275 #define SPINDLE_SYNCH_MASTER 0x02 /* disk is a master */ 276 #define SPINDLE_SYNCH_MCONTROL 0x03 /* disk is a master control */ 277 u_int8_t rot_offset; /* rotational offset (for spindle synch) */ 278 u_int8_t reserved1; 279 u_int8_t rpm[2]; /* media rotation speed */ 280 u_int8_t reserved2; 281 u_int8_t reserved3; 282 } rigid_geometry; 283 struct page_flex_geometry { 284 u_int8_t pg_code; /* page code (should be 5) */ 285 u_int8_t pg_length; /* page length (should be 0x1e) */ 286 u_int8_t xfr_rate[2]; 287 u_int8_t nheads; /* number of heads */ 288 u_int8_t ph_sec_tr; /* physical sectors per track */ 289 u_int8_t bytes_s[2]; /* bytes per sector */ 290 u_int8_t ncyl[2]; /* number of cylinders */ 291 u_int8_t st_cyl_wp[2]; /* start cyl., write precomp */ 292 u_int8_t st_cyl_rwc[2]; /* start cyl., red. write cur */ 293 u_int8_t driv_step[2]; /* drive step rate */ 294 u_int8_t driv_step_w; /* drive step pulse width */ 295 u_int8_t head_settle[2];/* head settle delay */ 296 u_int8_t motor_on; /* motor on delay */ 297 u_int8_t motor_off; /* motor off delay */ 298 u_int8_t flags; /* various flags */ 299 #define MOTOR_ON 0x20 /* motor on (pin 16)? */ 300 #define START_AT_SECTOR_1 0x40 /* start at sector 1 */ 301 #define READY_VALID 0x20 /* RDY (pin 34) valid */ 302 u_int8_t step_p_cyl; /* step pulses per cylinder */ 303 u_int8_t write_pre; /* write precompensation */ 304 u_int8_t head_load; /* head load delay */ 305 u_int8_t head_unload; /* head unload delay */ 306 u_int8_t pin_34_2; /* pin 34 (6) pin 2 (7/11) definition */ 307 u_int8_t pin_4_1; /* pin 4 (8/9) pin 1 (13) definition */ 308 u_int8_t rpm[2]; /* media rotation speed */ 309 u_int8_t reserved1; 310 u_int8_t reserved2; 311 } flex_geometry; 312 struct page_reduced_geometry { 313 u_int8_t pg_code; /* page code (should be 6) */ 314 u_int8_t pg_length; /* page length (should be 0x0B) */ 315 u_int8_t wcd; /* bit 0 = write cache disable */ 316 u_int8_t bytes_s[2]; /* bytes per sector */ 317 u_int8_t sectors[5]; /* total number of sectors */ 318 u_int8_t pow_perf; /* power/performance level */ 319 u_int8_t flags; /* various */ 320 #define LOCK_DISABLED 0x1 321 #define FORMAT_DISABLED 0x2 322 #define WRITE_DISABLED 0x4 323 #define READ_DISABLED 0x8 324 u_int8_t reserved; 325 } reduced_geometry; 326 }; 327 328 #endif /* _SCSI_SCSI_DISK_H */ 329