1 /* 2 * minitape.h 3 * 4 * Minitape driver interface 5 * 6 * This file is part of the w32api package. 7 * 8 * Contributors: 9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net> 10 * 11 * THIS SOFTWARE IS NOT COPYRIGHTED 12 * 13 * This source code is offered for use in the public domain. You may 14 * use, modify or distribute it freely. 15 * 16 * This code is distributed in the hope that it will be useful but 17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 * DISCLAIMED. This includes but is not limited to warranties of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 * 21 */ 22 #ifndef _MINITAPE_ 23 #define _MINITAPE_ 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 #pragma pack(push,4) 30 31 #define MEDIA_ERASEABLE 0x00000001 32 #define MEDIA_WRITE_ONCE 0x00000002 33 #define MEDIA_READ_ONLY 0x00000004 34 #define MEDIA_READ_WRITE 0x00000008 35 #define MEDIA_WRITE_PROTECTED 0x00000100 36 #define MEDIA_CURRENTLY_MOUNTED 0x80000000 37 38 typedef enum _TAPE_STATUS { 39 TAPE_STATUS_SEND_SRB_AND_CALLBACK, 40 TAPE_STATUS_CALLBACK, 41 TAPE_STATUS_CHECK_TEST_UNIT_READY, 42 TAPE_STATUS_SUCCESS, 43 TAPE_STATUS_INSUFFICIENT_RESOURCES, 44 TAPE_STATUS_NOT_IMPLEMENTED, 45 TAPE_STATUS_INVALID_DEVICE_REQUEST, 46 TAPE_STATUS_INVALID_PARAMETER, 47 TAPE_STATUS_MEDIA_CHANGED, 48 TAPE_STATUS_BUS_RESET, 49 TAPE_STATUS_SETMARK_DETECTED, 50 TAPE_STATUS_FILEMARK_DETECTED, 51 TAPE_STATUS_BEGINNING_OF_MEDIA, 52 TAPE_STATUS_END_OF_MEDIA, 53 TAPE_STATUS_BUFFER_OVERFLOW, 54 TAPE_STATUS_NO_DATA_DETECTED, 55 TAPE_STATUS_EOM_OVERFLOW, 56 TAPE_STATUS_NO_MEDIA, 57 TAPE_STATUS_IO_DEVICE_ERROR, 58 TAPE_STATUS_UNRECOGNIZED_MEDIA, 59 TAPE_STATUS_DEVICE_NOT_READY, 60 TAPE_STATUS_MEDIA_WRITE_PROTECTED, 61 TAPE_STATUS_DEVICE_DATA_ERROR, 62 TAPE_STATUS_NO_SUCH_DEVICE, 63 TAPE_STATUS_INVALID_BLOCK_LENGTH, 64 TAPE_STATUS_IO_TIMEOUT, 65 TAPE_STATUS_DEVICE_NOT_CONNECTED, 66 TAPE_STATUS_DATA_OVERRUN, 67 TAPE_STATUS_DEVICE_BUSY, 68 TAPE_STATUS_REQUIRES_CLEANING, 69 TAPE_STATUS_CLEANER_CARTRIDGE_INSTALLED 70 } TAPE_STATUS, *PTAPE_STATUS; 71 72 #define INQUIRYDATABUFFERSIZE 36 73 74 #ifndef _INQUIRYDATA_DEFINED /* also in scsi.h */ 75 #define _INQUIRYDATA_DEFINED 76 77 typedef struct _INQUIRYDATA { 78 UCHAR DeviceType:5; 79 UCHAR DeviceTypeQualifier:3; 80 UCHAR DeviceTypeModifier:7; 81 UCHAR RemovableMedia:1; 82 __GNU_EXTENSION union { 83 UCHAR Versions; 84 __GNU_EXTENSION struct { 85 UCHAR ANSIVersion:3; 86 UCHAR ECMAVersion:3; 87 UCHAR ISOVersion:2; 88 }; 89 }; 90 UCHAR ResponseDataFormat:4; 91 UCHAR HiSupport:1; 92 UCHAR NormACA:1; 93 UCHAR TerminateTask:1; 94 UCHAR AERC:1; 95 UCHAR AdditionalLength; 96 UCHAR Reserved; 97 UCHAR Addr16:1; 98 UCHAR Addr32:1; 99 UCHAR AckReqQ:1; 100 UCHAR MediumChanger:1; 101 UCHAR MultiPort:1; 102 UCHAR ReservedBit2:1; 103 UCHAR EnclosureServices:1; 104 UCHAR ReservedBit3:1; 105 UCHAR SoftReset:1; 106 UCHAR CommandQueue:1; 107 UCHAR TransferDisable:1; 108 UCHAR LinkedCommands:1; 109 UCHAR Synchronous:1; 110 UCHAR Wide16Bit:1; 111 UCHAR Wide32Bit:1; 112 UCHAR RelativeAddressing:1; 113 UCHAR VendorId[8]; 114 UCHAR ProductId[16]; 115 UCHAR ProductRevisionLevel[4]; 116 UCHAR VendorSpecific[20]; 117 UCHAR Reserved3[40]; 118 } INQUIRYDATA, *PINQUIRYDATA; 119 120 #endif /* _INQUIRYDATA_DEFINED */ 121 122 typedef struct _MODE_CAPABILITIES_PAGE { 123 UCHAR PageCode:6; 124 UCHAR Reserved1:2; 125 UCHAR PageLength; 126 UCHAR Reserved2[2]; 127 UCHAR RO:1; 128 UCHAR Reserved3:4; 129 UCHAR SPREV:1; 130 UCHAR Reserved4:2; 131 UCHAR Reserved5:3; 132 UCHAR EFMT:1; 133 UCHAR Reserved6:1; 134 UCHAR QFA:1; 135 UCHAR Reserved7:2; 136 UCHAR LOCK:1; 137 UCHAR LOCKED:1; 138 UCHAR PREVENT:1; 139 UCHAR UNLOAD:1; 140 UCHAR Reserved8:2; 141 UCHAR ECC:1; 142 UCHAR CMPRS:1; 143 UCHAR Reserved9:1; 144 UCHAR BLK512:1; 145 UCHAR BLK1024:1; 146 UCHAR Reserved10:4; 147 UCHAR SLOWB:1; 148 UCHAR MaximumSpeedSupported[2]; 149 UCHAR MaximumStoredDefectedListEntries[2]; 150 UCHAR ContinuousTransferLimit[2]; 151 UCHAR CurrentSpeedSelected[2]; 152 UCHAR BufferSize[2]; 153 UCHAR Reserved11[2]; 154 } MODE_CAPABILITIES_PAGE, *PMODE_CAPABILITIES_PAGE; 155 156 typedef BOOLEAN 157 (NTAPI *TAPE_VERIFY_INQUIRY_ROUTINE)( 158 _In_ PINQUIRYDATA InquiryData, 159 _In_ PMODE_CAPABILITIES_PAGE ModeCapabilitiesPage); 160 161 typedef VOID 162 (NTAPI *TAPE_EXTENSION_INIT_ROUTINE)( 163 _In_ PVOID MinitapeExtension, 164 _In_ PINQUIRYDATA InquiryData, 165 _In_ PMODE_CAPABILITIES_PAGE ModeCapabilitiesPage); 166 167 typedef VOID 168 (NTAPI *TAPE_ERROR_ROUTINE)( 169 _In_ PVOID MinitapeExtension, 170 _In_ PSCSI_REQUEST_BLOCK Srb, 171 _Inout_ PTAPE_STATUS TapeStatus); 172 173 typedef TAPE_STATUS 174 (NTAPI *TAPE_PROCESS_COMMAND_ROUTINE)( 175 _Inout_ PVOID MinitapeExtension, 176 _Inout_ PVOID CommandExtension, 177 _Inout_ PVOID CommandParameters, 178 _Inout_ PSCSI_REQUEST_BLOCK Srb, 179 _In_ ULONG CallNumber, 180 _In_ TAPE_STATUS StatusOfLastCommand, 181 _Inout_ PULONG RetryFlags); 182 183 #define TAPE_RETRY_MASK 0x0000FFFF 184 #define IGNORE_ERRORS 0x00010000 185 #define RETURN_ERRORS 0x00020000 186 187 typedef struct _TAPE_INIT_DATA { 188 TAPE_VERIFY_INQUIRY_ROUTINE VerifyInquiry; 189 BOOLEAN QueryModeCapabilitiesPage; 190 ULONG MinitapeExtensionSize; 191 TAPE_EXTENSION_INIT_ROUTINE ExtensionInit; 192 ULONG DefaultTimeOutValue; 193 TAPE_ERROR_ROUTINE TapeError; 194 ULONG CommandExtensionSize; 195 TAPE_PROCESS_COMMAND_ROUTINE CreatePartition; 196 TAPE_PROCESS_COMMAND_ROUTINE Erase; 197 TAPE_PROCESS_COMMAND_ROUTINE GetDriveParameters; 198 TAPE_PROCESS_COMMAND_ROUTINE GetMediaParameters; 199 TAPE_PROCESS_COMMAND_ROUTINE GetPosition; 200 TAPE_PROCESS_COMMAND_ROUTINE GetStatus; 201 TAPE_PROCESS_COMMAND_ROUTINE Prepare; 202 TAPE_PROCESS_COMMAND_ROUTINE SetDriveParameters; 203 TAPE_PROCESS_COMMAND_ROUTINE SetMediaParameters; 204 TAPE_PROCESS_COMMAND_ROUTINE SetPosition; 205 TAPE_PROCESS_COMMAND_ROUTINE WriteMarks; 206 TAPE_PROCESS_COMMAND_ROUTINE PreProcessReadWrite; /* optional */ 207 } TAPE_INIT_DATA, *PTAPE_INIT_DATA; 208 209 typedef struct _TAPE_PHYS_POSITION { 210 ULONG SeekBlockAddress; 211 ULONG SpaceBlockCount; 212 } TAPE_PHYS_POSITION, PTAPE_PHYS_POSITION; 213 214 #pragma pack(pop) 215 216 #ifdef __cplusplus 217 } 218 #endif 219 220 #endif /* _MINITAPE_ */ 221