1 /* $NetBSD: scsipi_disk.h,v 1.24 2025/02/27 17:00:47 jakllsch Exp $ */ 2 3 /* 4 * SCSI and SCSI-like interfaces 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 (at) 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 (at) tfs.com) Sept 1992 50 */ 51 52 #ifndef _DEV_SCSIPI_SCSIPI_DISK_H_ 53 #define _DEV_SCSIPI_SCSIPI_DISK_H_ 54 55 /* 56 * SCSI command format 57 */ 58 59 #define READ_10 0x28 60 #define WRITE_10 0x2a 61 struct scsipi_rw_10 { 62 u_int8_t opcode; 63 u_int8_t byte2; 64 #define SRWB_RELADDR 0x01 /* obsolete */ 65 #define SRWB_FUA_NV 0x02 /* force unit access non-volatile cache (SCSI-3) */ 66 #define SRWB_RESV2 0x04 /* reserved (SCSI-2) */ 67 #define SRWB_FUA 0x08 /* force unit access volatile cache (SCSI-2) */ 68 #define SRWB_DPO 0x10 /* disable page out (SCSI-2) */ 69 #define SRWB_PROTECT(x) ((x) << 5) 70 u_int8_t addr[4]; 71 u_int8_t reserved; 72 u_int8_t length[2]; 73 u_int8_t control; 74 } __packed; 75 76 #define READ_12 0xa8 77 #define WRITE_12 0xaa 78 struct scsipi_rw_12 { 79 u_int8_t opcode; 80 u_int8_t byte2; /* see scsipi_rw_10 bits */ 81 u_int8_t addr[4]; 82 u_int8_t length[4]; 83 u_int8_t byte11; 84 u_int8_t control; 85 } __packed; 86 87 #define READ_16 0x88 88 #define WRITE_16 0x8a 89 struct scsipi_rw_16 { 90 u_int8_t opcode; 91 u_int8_t byte2; /* see scsipi_rw_10 bits */ 92 u_int8_t addr[8]; 93 u_int8_t length[4]; 94 u_int8_t byte15; 95 u_int8_t control; 96 } __packed; 97 98 #define READ_CAPACITY_10 0x25 99 struct scsipi_read_capacity_10 { 100 u_int8_t opcode; 101 u_int8_t byte2; 102 u_int8_t addr[4]; 103 u_int8_t unused[3]; 104 u_int8_t control; 105 } __packed; 106 107 /* DATAs definitions for the above commands */ 108 109 struct scsipi_read_capacity_10_data { 110 u_int8_t addr[4]; 111 u_int8_t length[4]; 112 } __packed; 113 114 #define READ_CAPACITY_16 0x9e /* really SERVICE ACTION IN */ 115 struct scsipi_read_capacity_16 { 116 u_int8_t opcode; 117 u_int8_t byte2; 118 #define SRC16_SERVICE_ACTION 0x10 119 u_int8_t addr[8]; 120 u_int8_t len[4]; 121 u_int8_t byte15; 122 #define SRC16_PMI 0x01 123 u_int8_t control; 124 } __packed; 125 126 struct scsipi_read_capacity_16_data { 127 u_int8_t addr[8]; 128 u_int8_t length[4]; 129 u_int8_t byte13; 130 #define SRC16D_PROT_EN 0x01 131 #define SRC16D_RTO_EN 0x02 132 u_int8_t byte14; 133 #define SRC16D_LBPPB_EXPONENT 0x0f 134 #define SRC16D_P_I_EXPONENT 0xf0 135 u_int8_t lowest_aligned[2]; 136 #define SRC16D_LALBA 0x3fff 137 #define SRC16D_LBPRZ 0x4000 138 #define SRC16D_LBPME 0x8000 139 u_int8_t reserved17[16]; 140 } __packed; 141 142 /* XXX SBC-2 says this is vendor-specific */ 143 #define READ_FORMAT_CAPACITIES 0x23 144 struct scsipi_read_format_capacities { 145 u_int8_t opcode; 146 u_int8_t byte2; 147 u_int8_t reserved1[5]; 148 u_int8_t length[2]; 149 u_int8_t reserved2[3]; 150 } __packed; 151 152 struct scsipi_capacity_list_header { 153 u_int8_t reserved[3]; 154 u_int8_t length; 155 } __packed; 156 157 struct scsipi_capacity_descriptor { 158 u_int8_t nblks[4]; 159 u_int8_t byte5; 160 u_int8_t blklen[3]; 161 } __packed; 162 163 /* codes only valid in the current/maximum capacity descriptor */ 164 #define SCSIPI_CAP_DESC_CODE_MASK 0x3 165 #define SCSIPI_CAP_DESC_CODE_RESERVED 0x0 166 #define SCSIPI_CAP_DESC_CODE_UNFORMATTED 0x1 167 #define SCSIPI_CAP_DESC_CODE_FORMATTED 0x2 168 #define SCSIPI_CAP_DESC_CODE_NONE 0x3 169 170 /* defines for the device specific byte in the mode select/sense header */ 171 #define SMH_DSP_DPOFUA 0x10 172 173 #endif /* _DEV_SCSIPI_SCSIPI_DISK_H_ */ 174