1 /* $Id: scsi-tape.h,v 1.3 2006/11/15 23:10:33 fredette Exp $ */ 2 3 /* tme/scsi/scsi-tape.h - header file for generic SCSI tape emulation: */ 4 5 /* 6 * Copyright (c) 2003 Matt Fredette 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by Matt Fredette. 20 * 4. The name of the author may not be used to endorse or promote products 21 * derived from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36 #ifndef _TME_SCSI_SCSI_TAPE_H 37 #define _TME_SCSI_SCSI_TAPE_H 38 39 #include <tme/common.h> 40 _TME_RCSID("$Id: scsi-tape.h,v 1.3 2006/11/15 23:10:33 fredette Exp $"); 41 42 /* includes: */ 43 #include <tme/generic/tape.h> 44 #include <tme/scsi/scsi-device.h> 45 #include <tme/scsi/scsi-cdb.h> 46 #include <tme/scsi/scsi-msg.h> 47 48 /* macros: */ 49 50 /* "Group 0 Commands for Sequential-Access Devices" */ 51 /* 0x00 common */ 52 #define TME_SCSI_CDB_TAPE_REWIND (0x01) 53 /* 0x02 vendor unique */ 54 /* 0x03 common */ 55 /* 0x04 reserved */ 56 #define TME_SCSI_CDB_TAPE_BLOCK_LIMITS (0x05) 57 /* 0x06 vendor unique */ 58 /* 0x07 vendor unique */ 59 #define TME_SCSI_CDB_TAPE_READ0 (0x08) 60 /* 0x09 vendor unique */ 61 #define TME_SCSI_CDB_TAPE_WRITE0 (0x0a) 62 #define TME_SCSI_CDB_TAPE_TRACK_SELECT (0x0b) 63 /* 0x0c vendor unique */ 64 /* 0x0d vendor unique */ 65 /* 0x0e vendor unique */ 66 #define TME_SCSI_CDB_TAPE_READ_REVERSE (0x0f) 67 #define TME_SCSI_CDB_TAPE_WRITE_MARKS (0x10) 68 #define TME_SCSI_CDB_TAPE_SPACE (0x11) 69 /* 0x12 common */ 70 #define TME_SCSI_CDB_TAPE_VERIFY (0x13) 71 #define TME_SCSI_CDB_TAPE_RECOVER_BUF (0x14) 72 #define TME_SCSI_CDB_TAPE_MODE_SELECT (0x15) 73 #define TME_SCSI_CDB_TAPE_RESERVE (0x16) 74 #define TME_SCSI_CDB_TAPE_RELEASE (0x17) 75 /* 0x18 common */ 76 #define TME_SCSI_CDB_TAPE_ERASE (0x19) 77 #define TME_SCSI_CDB_TAPE_MODE_SENSE (0x1a) 78 #define TME_SCSI_CDB_TAPE_LOAD_UNLOAD (0x1b) 79 /* 0x1c common */ 80 /* 0x1d common */ 81 #define TME_SCSI_CDB_TAPE_PREVENT_ALLOW (0x1e) 82 /* 0x1f common */ 83 84 /* flags: */ 85 #define TME_SCSI_TAPE_FLAG_LOADED TME_BIT(0) 86 #define TME_SCSI_TAPE_FLAG_ATTENTION TME_BIT(1) 87 88 /* types: */ 89 90 /* a SCSI tape device tape connection: */ 91 struct tme_scsi_tape_connection { 92 93 /* the regular tape connection: */ 94 struct tme_tape_connection tme_scsi_tape_connection; 95 96 /* the LUN for this tape: */ 97 int tme_scsi_tape_connection_lun; 98 99 /* the flags for this tape: */ 100 unsigned int tme_scsi_tape_connection_flags; 101 }; 102 103 /* a SCSI tape: */ 104 struct tme_scsi_tape { 105 106 /* our SCSI device structure: */ 107 struct tme_scsi_device tme_scsi_tape_device; 108 #define tme_scsi_tape_element tme_scsi_tape_device.tme_scsi_device_element 109 #define tme_scsi_tape_mutex tme_scsi_tape_device.tme_scsi_device_mutex 110 111 /* our type name: */ 112 char *tme_scsi_tape_type; 113 114 /* our tape connections: */ 115 struct tme_scsi_tape_connection *tme_scsi_tape_connections[TME_SCSI_DEVICE_LUN_COUNT]; 116 117 /* a type-specific connected function: */ 118 void (*tme_scsi_tape_connected) _TME_P((struct tme_scsi_tape *, int)); 119 120 /* a type-specific transfer status function: */ 121 tme_uint8_t (*tme_scsi_tape_xfer_status) _TME_P((struct tme_scsi_tape *, 122 int flags, 123 unsigned long)); 124 125 /* the minimum and maximum block sizes, in bytes: */ 126 tme_uint32_t tme_scsi_tape_block_size_min; 127 tme_uint32_t tme_scsi_tape_block_size_max; 128 129 /* the current block size, in bytes: */ 130 tme_uint32_t tme_scsi_tape_block_size_current; 131 }; 132 133 /* prototypes: */ 134 int tme_scsi_tape_tme_init _TME_P((struct tme_scsi_tape *)); 135 int tme_scsi_tape_emulexmt02_init _TME_P((struct tme_scsi_tape *)); 136 137 _TME_SCSI_DEVICE_CDB_P(tme_scsi_tape_cdb_rewind); 138 _TME_SCSI_DEVICE_CDB_P(tme_scsi_tape_cdb_block_limits); 139 _TME_SCSI_DEVICE_CDB_P(tme_scsi_tape_cdb_read0); 140 _TME_SCSI_DEVICE_CDB_P(tme_scsi_tape_cdb_write0); 141 _TME_SCSI_DEVICE_CDB_P(tme_scsi_tape_cdb_inquiry); 142 _TME_SCSI_DEVICE_CDB_P(tme_scsi_tape_cdb_write_marks); 143 _TME_SCSI_DEVICE_CDB_P(tme_scsi_tape_cdb_space); 144 _TME_SCSI_DEVICE_CDB_P(tme_scsi_tape_cdb_mode_select); 145 _TME_SCSI_DEVICE_CDB_P(tme_scsi_tape_cdb_mode_sense); 146 _TME_SCSI_DEVICE_CDB_P(tme_scsi_tape_cdb_load_unload); 147 _TME_SCSI_DEVICE_CDB_P(tme_scsi_tape_cdb_prevent_allow); 148 149 tme_uint8_t tme_scsi_tape_xfer_status _TME_P((struct tme_scsi_tape *, 150 int, 151 unsigned long)); 152 void tme_scsi_tape_cdb_xfer0 _TME_P((struct tme_scsi_device *, 153 int)); 154 155 #endif /* !_TME_SCSI_SCSI_TAPE_H */ 156