1 /* $NetBSD: scsi_disk.h,v 1.10 1996/07/05 16:19:05 christos Exp $ */ 2 3 /* 4 * SCSI interface description 5 */ 6 7 /* 8 * Some lines of this file come from a file of the name "scsi.h" 9 * distributed by OSF as part of mach2.5, 10 * so the following disclaimer has been kept. 11 * 12 * Copyright 1990 by Open Software Foundation, 13 * Grenoble, FRANCE 14 * 15 * All Rights Reserved 16 * 17 * Permission to use, copy, modify, and distribute this software and 18 * its documentation for any purpose and without fee is hereby granted, 19 * provided that the above copyright notice appears in all copies and 20 * that both the copyright notice and this permission notice appear in 21 * supporting documentation, and that the name of OSF or Open Software 22 * Foundation not be used in advertising or publicity pertaining to 23 * distribution of the software without specific, written prior 24 * permission. 25 * 26 * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 27 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, 28 * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR 29 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 30 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, 31 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 32 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 33 */ 34 35 /* 36 * Largely written by Julian Elischer (julian@tfs.com) 37 * for TRW Financial Systems. 38 * 39 * TRW Financial Systems, in accordance with their agreement with Carnegie 40 * Mellon University, makes this software available to CMU to distribute 41 * or use in any manner that they see fit as long as this message is kept with 42 * the software. For this reason TFS also grants any other persons or 43 * organisations permission to use or modify this software. 44 * 45 * TFS supplies this software to be publicly redistributed 46 * on the understanding that TFS is not responsible for the correct 47 * functioning of this software in any circumstances. 48 * 49 * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 50 */ 51 52 /* 53 * SCSI command format 54 */ 55 56 #ifndef _SCSI_SCSI_DISK_H 57 #define _SCSI_SCSI_DISK_H 1 58 59 struct scsi_reassign_blocks { 60 u_int8_t opcode; 61 u_int8_t byte2; 62 u_int8_t unused[3]; 63 u_int8_t control; 64 }; 65 66 struct scsi_rw { 67 u_int8_t opcode; 68 u_int8_t addr[3]; 69 #define SRW_TOPADDR 0x1F /* only 5 bits here */ 70 u_int8_t length; 71 u_int8_t control; 72 }; 73 74 struct scsi_rw_big { 75 u_int8_t opcode; 76 u_int8_t byte2; 77 #define SRWB_RELADDR 0x01 78 u_int8_t addr[4]; 79 u_int8_t reserved; 80 u_int8_t length[2]; 81 u_int8_t control; 82 }; 83 84 struct scsi_read_capacity { 85 u_int8_t opcode; 86 u_int8_t byte2; 87 u_int8_t addr[4]; 88 u_int8_t unused[3]; 89 u_int8_t control; 90 }; 91 92 struct scsi_start_stop { 93 u_int8_t opcode; 94 u_int8_t byte2; 95 u_int8_t unused[2]; 96 u_int8_t how; 97 #define SSS_STOP 0x00 98 #define SSS_START 0x01 99 #define SSS_LOEJ 0x02 100 u_int8_t control; 101 }; 102 103 104 105 /* 106 * Opcodes 107 */ 108 109 #define REASSIGN_BLOCKS 0x07 110 #define READ_COMMAND 0x08 111 #define WRITE_COMMAND 0x0a 112 #define MODE_SELECT 0x15 113 #define MODE_SENSE 0x1a 114 #define START_STOP 0x1b 115 #define PREVENT_ALLOW 0x1e 116 #define READ_CAPACITY 0x25 117 #define READ_BIG 0x28 118 #define WRITE_BIG 0x2a 119 120 121 struct scsi_read_cap_data { 122 u_int8_t addr[4]; 123 u_int8_t length[4]; 124 }; 125 126 struct scsi_reassign_blocks_data { 127 u_int8_t reserved[2]; 128 u_int8_t length[2]; 129 struct { 130 u_int8_t dlbaddr[4]; 131 } defect_descriptor[1]; 132 }; 133 134 union disk_pages { 135 #define DISK_PGCODE 0x3F /* only 6 bits valid */ 136 struct page_disk_format { 137 u_int8_t pg_code; /* page code (should be 3) */ 138 u_int8_t pg_length; /* page length (should be 0x16) */ 139 u_int8_t trk_z[2]; /* tracks per zone */ 140 u_int8_t alt_sec[2]; /* alternate sectors per zone */ 141 u_int8_t alt_trk_z[2]; /* alternate tracks per zone */ 142 u_int8_t alt_trk_v[2]; /* alternate tracks per volume */ 143 u_int8_t ph_sec_t[2]; /* physical sectors per track */ 144 u_int8_t bytes_s[2]; /* bytes per sector */ 145 u_int8_t interleave[2]; /* interleave */ 146 u_int8_t trk_skew[2]; /* track skew factor */ 147 u_int8_t cyl_skew[2]; /* cylinder skew */ 148 u_int8_t flags; /* various */ 149 #define DISK_FMT_SURF 0x10 150 #define DISK_FMT_RMB 0x20 151 #define DISK_FMT_HSEC 0x40 152 #define DISK_FMT_SSEC 0x80 153 u_int8_t reserved2; 154 u_int8_t reserved3; 155 } disk_format; 156 struct page_rigid_geometry { 157 u_int8_t pg_code; /* page code (should be 4) */ 158 u_int8_t pg_length; /* page length (should be 0x16) */ 159 u_int8_t ncyl[3]; /* number of cylinders */ 160 u_int8_t nheads; /* number of heads */ 161 u_int8_t st_cyl_wp[3]; /* starting cyl., write precomp */ 162 u_int8_t st_cyl_rwc[3]; /* starting cyl., red. write cur */ 163 u_int8_t driv_step[2]; /* drive step rate */ 164 u_int8_t land_zone[3]; /* landing zone cylinder */ 165 u_int8_t sp_sync_ctl; /* spindle synch control */ 166 #define SPINDLE_SYNCH_MASK 0x03 /* mask of valid bits */ 167 #define SPINDLE_SYNCH_NONE 0x00 /* synch disabled or not supported */ 168 #define SPINDLE_SYNCH_SLAVE 0x01 /* disk is a slave */ 169 #define SPINDLE_SYNCH_MASTER 0x02 /* disk is a master */ 170 #define SPINDLE_SYNCH_MCONTROL 0x03 /* disk is a master control */ 171 u_int8_t rot_offset; /* rotational offset (for spindle synch) */ 172 u_int8_t reserved1; 173 u_int8_t rpm[2]; /* media rotation speed */ 174 u_int8_t reserved2; 175 u_int8_t reserved3; 176 } rigid_geometry; 177 struct page_flex_geometry { 178 u_int8_t pg_code; /* page code (should be 5) */ 179 u_int8_t pg_length; /* page length (should be 0x1e) */ 180 u_int8_t xfr_rate[2]; 181 u_int8_t nheads; /* number of heads */ 182 u_int8_t ph_sec_tr; /* physical sectors per track */ 183 u_int8_t bytes_s[2]; /* bytes per sector */ 184 u_int8_t ncyl[2]; /* number of cylinders */ 185 u_int8_t st_cyl_wp[2]; /* start cyl., write precomp */ 186 u_int8_t st_cyl_rwc[2]; /* start cyl., red. write cur */ 187 u_int8_t driv_step[2]; /* drive step rate */ 188 u_int8_t driv_step_w; /* drive step pulse width */ 189 u_int8_t head_settle[2];/* head settle delay */ 190 u_int8_t motor_on; /* motor on delay */ 191 u_int8_t motor_off; /* motor off delay */ 192 u_int8_t flags; /* various flags */ 193 #define MOTOR_ON 0x20 /* motor on (pin 16)? */ 194 #define START_AT_SECTOR_1 0x40 /* start at sector 1 */ 195 #define READY_VALID 0x20 /* RDY (pin 34) valid */ 196 u_int8_t step_p_cyl; /* step pulses per cylinder */ 197 u_int8_t write_pre; /* write precompensation */ 198 u_int8_t head_load; /* head load delay */ 199 u_int8_t head_unload; /* head unload delay */ 200 u_int8_t pin_34_2; /* pin 34 (6) pin 2 (7/11) definition */ 201 u_int8_t pin_4_1; /* pin 4 (8/9) pin 1 (13) definition */ 202 u_int8_t reserved1; 203 u_int8_t reserved2; 204 u_int8_t reserved3; 205 u_int8_t reserved4; 206 } flex_geometry; 207 }; 208 209 #endif /* _SCSI_SCSI_DISK_H */ 210