3 * Copyright (c) 1998 T.Hepper
8 #ifndef WORDS_BIGENDIAN
9 #define LITTLE_ENDIAN_BITFIELDS
12 typedef enum { Input, Output } Direction_T;
13 typedef unsigned char CDB_T[12];
16 typedef unsigned int PackedBit;
19 typedef unsigned char PackedBit;
22 #define INDEX_CHANGER 0
24 #define INDEX_TAPECTL 2
26 #define CHG_MAXDEV 32 /* Maximum number of devices handled by pDev */
27 /* Must be large to hold the result of ScanBus */
35 #define MAXTRIES 100 /* How many tries until SCSI_TestUnitReady should return an ok */
37 * Sense Key definitions
40 #define SENSE_RECOVERED_ERROR 1
42 #define SENSE_NOT_READY 2
43 #define SENSE_MEDIUM_ERROR 3
44 #define SENSE_HARDWARE_ERROR 4
45 #define HARDWARE_ERROR 4
46 #define ILLEGAL_REQUEST 5
47 #define SENSE_ILLEGAL_REQUEST 5
48 #define UNIT_ATTENTION 6
49 #define SENSE_UNIT_ATTENTION 6
50 #define SENSE_DATA_PROTECT 7
51 #define SENSE_BLANK_CHECK 8
52 #define SENSE_VENDOR_SPECIFIC 0x9
53 #define SENSE_ABORTED_COMMAND 0xb
54 #define SENSE_VOLUME_OVERFLOW 0xd
55 #define SENSE_CHG_ELEMENT_STATUS 0xe
57 #define MAX_RETRIES 100
59 #define INQUIRY_SIZE SIZEOF(SCSIInquiry_T)
62 * Return values from the OS dependent part
63 * of the SCSI interface
65 * The underlaying functions must decide what to do
77 #define SC_COM_TEST_UNIT_READY 0
78 #define SC_COM_REWIND 0x1
79 #define SC_COM_REQUEST_SENSE 0x3
80 #define SC_COM_IES 0x7
81 #define SC_COM_INQUIRY 0x12
82 #define SC_COM_MODE_SELECT 0x15
83 #define SC_COM_ERASE 0x19
84 #define SC_COM_MODE_SENSE 0x1A
85 #define SC_COM_UNLOAD 0x1B
86 #define SC_COM_LOCATE 0x2B
87 #define SC_COM_LOG_SELECT 0x4C
88 #define SC_COM_LOG_SENSE 0x4d
89 #define SC_MOVE_MEDIUM 0xa5
90 #define SC_COM_RES 0xb8
92 * Define for LookupDevice
97 #define LOOKUP_CONFIG 4
99 * Define for the return codes from SenseHandler
101 #define SENSE_ABORT -1
102 #define SENSE_IGNORE 0
103 #define SENSE_RETRY 2
105 #define SENSE_TAPE_NOT_ONLINE 4
106 #define SENSE_TAPE_NOT_LOADED 5
108 #define SENSE_TAPE_NOT_UNLOADED 7
109 #define SENSE_CHM_FULL 8
111 * Defines for the type field in the inquiry command
115 #define TYPE_PRINTER 2
116 #define TYPE_PROCESSOR 3
119 #define TYPE_SCANNER 6
120 #define TYPE_OPTICAL 7
121 #define TYPE_CHANGER 8
124 /* Defines for Tape_Status */
125 #define TAPE_ONLINE 1 /* Tape is loaded */
126 #define TAPE_BOT 2 /* Tape is at begin of tape */
127 #define TAPE_EOT 4 /* Tape is at end of tape */
128 #define TAPE_WR_PROT 8 /* Tape is write protected */
129 #define TAPE_NOT_LOADED 16 /* Tape is not loaded */
131 /* Defines for the function Tape_Ioctl */
132 #define IOCTL_EJECT 0
134 /* Defines for exit status */
138 /* macros for building scsi msb array parameter lists */
140 #define B(s,i) ((unsigned char)(((s) >> (i)) & 0xff))
143 #define B1(s) ((unsigned char)((s) & 0xff))
145 #define B2(s) B((s),8), B1(s)
146 #define B3(s) B((s),16), B((s),8), B1(s)
147 #define B4(s) B((s),24), B((s),16), B((s),8), B1(s)
149 /* macros for converting scsi msb array to binary */
151 #define V2(s) (((s)[0] << 8) | (s)[1])
152 #define V3(s) (((((s)[0] << 8) | (s)[1]) << 8) | (s)[2])
153 #define V4(s) (((((((s)[0] << 8) | (s)[1]) << 8) | (s)[2]) << 8) | (s)[3])
154 #define V5(s) (((((((((s)[0] << 8) | (s)[1]) << 8) | (s)[2]) << 8) | (s)[3]) << 8) | (s)[4])
155 #define V6(s) (((((((((((s)[0] << 8) | (s)[1]) << 8) | (s)[2]) << 8) | (s)[3]) << 8) | (s)[4]) << 8) | (s)[5])
157 /* macros for converting binary into scsi msb array */
158 #define MSB1(s,v) (s)[0]=B1(v)
159 #define MSB2(s,v) (s)[0]=B(v,8), (s)[1]=B1(v)
160 #define MSB3(s,v) (s)[0]=B(v,16), (s)[1]=B(v,8), (s)[2]=B1(v)
161 #define MSB4(s,v) (s)[0]=B(v,24), (s)[1]=B(v,16), (s)[2]=B(v,8), (s)[3]=B1(v)
163 #define LABEL_DB_VERSION 2
166 #define DEBUG_ERROR 1
169 #define SECTION_ALL 0
170 #define SECTION_INFO 1
171 #define SECTION_SCSI 2
172 #define SECTION_MAP_BARCODE 3
173 #define SECTION_ELEMENT 4
174 #define SECTION_BARCODE 5
175 #define SECTION_TAPE 6
176 #define SECTION_MOVE 7
177 /*----------------------------------------------------------------------------*/
178 /* Some stuff for our own configurationfile */
179 typedef struct { /* The information we can get for any drive (configuration) */
180 int drivenum; /* Which drive to use in the library */
181 int start; /* Which is the first slot we may use */
182 int end; /* The last slot we are allowed to use */
183 int cleanslot; /* Where the cleaningcartridge stays */
184 char *scsitapedev; /* Where can we send raw SCSI commands to the tape */
185 char *device; /* Which device is associated to the drivenum */
186 char *slotfile; /* Where we should have our memory */
187 char *cleanfile; /* Where we count how many cleanings we did */
188 char *timefile; /* Where we count the time the tape was used*/
189 char *tapestatfile;/* Where can we place some drive stats */
190 char *changerident;/* Config to use for changer control, ovverride result from inquiry */
191 char *tapeident; /* Same as above for the tape device */
195 int number_of_configs; /* How many different configurations are used */
196 int eject; /* Do the drives need an eject-command */
197 int autoinv; /* Do automaticly an inventory if an tape is not in the db or not active in the db */
198 int havebarcode; /* Do we have an barcode reader installed */
199 char *debuglevel; /* How many debug info to print */
200 unsigned char emubarcode; /* Emulate the barcode feature, used for keeping an inventory of the lib */
201 time_t sleep; /* How many seconds to wait for the drive to get ready */
202 int cleanmax; /* How many runs could be done with one cleaning tape */
203 char *device; /* Which device is our changer */
204 char *labelfile; /* Mapping from Barcode labels to volume labels */
210 char barcode[TAG_SIZE];
215 char voltag[128]; /* Tape volume label */
216 char barcode[TAG_SIZE]; /* Barcode of the tape */
217 int slot; /* in which slot is the tape */
218 int from; /* from where it comes, needed to move a tape
219 * back to the right slot from the drive
222 unsigned int LoadCount; /* How many times has the tape been loaded */
223 unsigned int RecovError; /* How many recovered errors */
224 unsigned int UnrecovError; /* How man unrecoverd errors */
225 unsigned char valid; /* Is this tape in the current magazin */
228 typedef enum {BARCODE_PUT, BARCODE_VOL, BARCODE_BARCODE, BARCODE_DUMP, RESET_VALID, FIND_SLOT, UPDATE_SLOT } MBCAction_T;
235 /* ======================================================= */
237 /* ======================================================= */
240 #ifdef LITTLE_ENDIAN_BITFIELDS
241 PackedBit ErrorCode:7; /* Byte 0 Bits 0-6 */
242 PackedBit Valid:1; /* Byte 0 Bit 7 */
244 PackedBit Valid:1; /* Byte 0 Bit 7 */
245 PackedBit ErrorCode:7; /* Byte 0 Bits 0-6 */
247 unsigned char SegmentNumber; /* Byte 1 */
248 #ifdef LITTLE_ENDIAN_BITFIELDS
249 PackedBit SenseKey:4; /* Byte 2 Bits 0-3 */
250 PackedBit :1; /* Byte 2 Bit 4 */
251 PackedBit RILI:1; /* Byte 2 Bit 5 */
252 PackedBit REOM:1; /* Byte 2 Bit 6 */
253 PackedBit Filemark:1; /* Byte 2 Bit 7 */
255 PackedBit Filemark:1; /* Byte 2 Bit 7 */
256 PackedBit REOM:1; /* Byte 2 Bit 6 */
257 PackedBit RILI:1; /* Byte 2 Bit 5 */
258 PackedBit :1; /* Byte 2 Bit 4 */
259 PackedBit SenseKey:4; /* Byte 2 Bits 0-3 */
261 unsigned char Information[4]; /* Bytes 3-6 */
262 unsigned char AdditionalSenseLength; /* Byte 7 */
263 unsigned char CommandSpecificInformation[4]; /* Bytes 8-11 */
264 unsigned char AdditionalSenseCode; /* Byte 12 */
265 unsigned char AdditionalSenseCodeQualifier; /* Byte 13 */
266 unsigned char Byte14; /* Byte 14 */
267 unsigned char Byte15; /* Byte 15 */
271 /* ======================================================= */
272 /* ExtendedRequestSense_T */
273 /* ======================================================= */
276 #ifdef LITTLE_ENDIAN_BITFIELDS
277 PackedBit ErrorCode:7; /* Byte 0 Bits 0-6 */
278 PackedBit Valid:1; /* Byte 0 Bit 7 */
280 PackedBit Valid:1; /* Byte 0 Bit 7 */
281 PackedBit ErrorCode:7; /* Byte 0 Bits 0-6 */
283 unsigned char SegmentNumber; /* Byte 1 */
284 #ifdef LITTLE_ENDIAN_BITFIELDS
285 PackedBit SenseKey:4; /* Byte 2 Bits 0-3 */
286 PackedBit :1; /* Byte 2 Bit 4 */
287 PackedBit RILI:1; /* Byte 2 Bit 5 */
288 PackedBit REOM:1; /* Byte 2 Bit 6 */
289 PackedBit Filemark:1; /* Byte 2 Bit 7 */
291 PackedBit Filemark:1; /* Byte 2 Bit 7 */
292 PackedBit REOM:1; /* Byte 2 Bit 6 */
293 PackedBit RILI:1; /* Byte 2 Bit 5 */
294 PackedBit :1; /* Byte 2 Bit 4 */
295 PackedBit SenseKey:4; /* Byte 2 Bits 0-3 */
297 unsigned char Information[4]; /* Bytes 3-6 */
298 unsigned char AdditionalSenseLength; /* Byte 7 */
299 unsigned char LogParameterPageCode; /* Bytes 8 */
300 unsigned char LogParameterCode; /* Bytes 9 */
301 unsigned char Byte10; /* Bytes 10 */
302 unsigned char UnderrunOverrunCounter; /* Bytes 11 */
303 unsigned char AdditionalSenseCode; /* Byte 12 */
304 unsigned char AdditionalSenseCodeQualifier; /* Byte 13 */
305 unsigned char Byte14; /* Byte 14 */
306 unsigned char Byte15; /* Byte 15 */
307 unsigned char ReadWriteDataErrorCounter[3]; /* Byte 16-18 */
308 #ifdef LITTLE_ENDIAN_BITFIELDS
309 PackedBit LBOT:1; /* Byte 19 Bits 0 */
310 PackedBit TNP:1; /* Byte 19 Bits 1 */
311 PackedBit TME:1; /* Byte 19 Bits 2 */
312 PackedBit ECO:1; /* Byte 19 Bits 3 */
313 PackedBit ME:1; /* Byte 19 Bits 4 */
314 PackedBit FPE:1; /* Byte 19 Bits 5 */
315 PackedBit BPE:1; /* Byte 19 Bits 6 */
316 PackedBit PF:1; /* Byte 19 Bits 7 */
318 PackedBit PF:1; /* Byte 19 Bits 7 */
319 PackedBit BPE:1; /* Byte 19 Bits 6 */
320 PackedBit FPE:1; /* Byte 19 Bits 5 */
321 PackedBit ME:1; /* Byte 19 Bits 4 */
322 PackedBit ECO:1; /* Byte 19 Bits 3 */
323 PackedBit TME:1; /* Byte 19 Bits 2 */
324 PackedBit TNP:1; /* Byte 19 Bits 1 */
325 PackedBit LBOT:1; /* Byte 19 Bits 0 */
327 #ifdef LITTLE_ENDIAN_BITFIELDS
328 PackedBit FE:1; /* Byte 20 Bits 0 */
329 PackedBit SSE:1; /* Byte 20 Bits 1 */
330 PackedBit WEI:1; /* Byte 20 Bits 2 */
331 PackedBit URE:1; /* Byte 20 Bits 3 */
332 PackedBit FMKE:1; /* Byte 20 Bits 4 */
333 PackedBit WP:1; /* Byte 20 Bits 5 */
334 PackedBit TMD:1; /* Byte 20 Bits 6 */
335 PackedBit :1; /* Byte 20 Bits 7 */
337 PackedBit :1; /* Byte 20 Bits 7 */
338 PackedBit TMD:1; /* Byte 20 Bits 6 */
339 PackedBit WP:1; /* Byte 20 Bits 5 */
340 PackedBit FMKE:1; /* Byte 20 Bits 4 */
341 PackedBit URE:1; /* Byte 20 Bits 3 */
342 PackedBit WEI:1; /* Byte 20 Bits 2 */
343 PackedBit SSE:1; /* Byte 20 Bits 1 */
344 PackedBit FE:1; /* Byte 20 Bits 0 */
346 #ifdef LITTLE_ENDIAN_BITFIELDS
347 PackedBit WSEO:1; /* Byte 21 Bits 0 */
348 PackedBit WSEB:1; /* Byte 21 Bits 1 */
349 PackedBit PEOT:1; /* Byte 21 Bits 2 */
350 PackedBit CLN:1; /* Byte 21 Bits 3 */
351 PackedBit CLND:1; /* Byte 21 Bits 4 */
352 PackedBit RRR:1; /* Byte 21 Bits 5 */
353 PackedBit UCLN:1; /* Byte 21 Bits 6 */
354 PackedBit :1; /* Byte 21 Bits 7 */
356 PackedBit :1; /* Byte 21 Bits 7 */
357 PackedBit UCLN:1; /* Byte 21 Bits 6 */
358 PackedBit RRR:1; /* Byte 21 Bits 5 */
359 PackedBit CLND:1; /* Byte 21 Bits 4 */
360 PackedBit CLN:1; /* Byte 21 Bits 3 */
361 PackedBit PEOT:1; /* Byte 21 Bits 2 */
362 PackedBit WSEB:1; /* Byte 21 Bits 1 */
363 PackedBit WSEO:1; /* Byte 21 Bits 0 */
365 unsigned char Byte21; /* Byte 22 */
366 unsigned char RemainingTape[3]; /* Byte 23-25 */
367 unsigned char TrackingRetryCounter; /* Byte 26 */
368 unsigned char ReadWriteRetryCounter; /* Byte 27 */
369 unsigned char FaultSymptomCode; /* Byte 28 */
371 } ExtendedRequestSense_T;
373 /* ======================================================= */
374 /* ReadElementStatus_T */
375 /* ======================================================= */
378 unsigned char cmd; /* Byte 1 */
379 #ifdef LITTLE_ENDIAN_BITFIELDS
388 unsigned char start[2]; /* Byte 3-4 */
389 unsigned char number[2]; /* Byte 5-6 */
390 unsigned char byte4; /* Byte 7 */
391 unsigned char length[4]; /* Byte 8-11 */
392 unsigned char byte78[2]; /* Byte 12-13 */
393 } ReadElementStatus_T;
395 /* ======================================================= */
396 /* ElementStatusPage_T */
397 /* ======================================================= */
400 unsigned char type; /* Byte 1 = Element Type Code*/
401 #ifdef LITTLE_ENDIAN_BITFIELDS
402 PackedBit bitres : 6;
403 PackedBit avoltag : 1;
404 PackedBit pvoltag : 1;
406 PackedBit pvoltag : 1;
407 PackedBit avoltag : 1;
408 PackedBit bitres : 6;
410 unsigned char length[2]; /* Byte 2-3 = Element Descriptor Length */
411 unsigned char byte4; /* Byte 4 */
412 unsigned char count[3]; /* Byte 5-7 = Byte Count of Descriptor Available */
413 } ElementStatusPage_T;
416 /* ======================================================= */
417 /* ElementStatusData_T */
418 /* ======================================================= */
421 unsigned char first[2]; /* Byte 1-2 = First Element Adress Reported */
422 unsigned char number[2]; /* Byte 3-4 = Number of Elements Available */
423 unsigned char byte5; /* Reserved */
424 unsigned char count[3]; /* Byte 6-8 = Byte Count of Report Available */
425 } ElementStatusData_T;
427 /* ======================================================= */
428 /* MediumTransportElementDescriptor_T */
429 /* ======================================================= */
432 unsigned char address[2]; /* Byte 1-2 = Element Address */
433 #ifdef LITTLE_ENDIAN_BITFIELDS
436 PackedBit except : 1;
440 PackedBit except : 1;
444 unsigned char byte4; /* Byte 4 */
445 unsigned char asc; /* Byte 5 ASC */
446 unsigned char ascq; /* Byte 6 ASCQ */
447 unsigned char byte79[3]; /* Byte 7-9 */
448 #ifdef LITTLE_ENDIAN_BITFIELDS
449 PackedBit byte10res : 6;
450 PackedBit invert : 1;
451 PackedBit svalid : 1;
453 PackedBit svalid : 1;
454 PackedBit invert : 1;
455 PackedBit byte10res : 6;
457 unsigned char source[2];
458 unsigned char pvoltag[36];
459 unsigned char res4[4];
460 } MediumTransportElementDescriptor_T;
462 /* ======================================================= */
463 /* ImportExportElementDescriptor_T */
464 /* ======================================================= */
467 unsigned char address[2]; /* Byte 1 = Element Address */
468 #ifdef LITTLE_ENDIAN_BITFIELDS
470 PackedBit impexp : 1;
471 PackedBit except : 1;
472 PackedBit access : 1;
473 PackedBit exenab : 1;
474 PackedBit inenab : 1;
478 PackedBit inenab : 1;
479 PackedBit exenab : 1;
480 PackedBit access : 1;
481 PackedBit except : 1;
488 unsigned char byte79[3];
489 #ifdef LITTLE_ENDIAN_BITFIELDS
490 PackedBit byte10res : 6;
491 PackedBit invert : 1;
492 PackedBit svalid : 1;
494 PackedBit svalid : 1;
495 PackedBit invert : 1;
496 PackedBit byte10res : 6;
498 unsigned char source[2];
499 unsigned char pvoltag[36];
500 unsigned char res4[4];
501 unsigned char mediadomain[1];
502 unsigned char mediatype[1];
503 unsigned char res5[2];
504 } ImportExportElementDescriptor_T;
506 /* ======================================================= */
507 /* StorageElementDescriptor_T */
508 /* ======================================================= */
511 unsigned char address[2];
512 #ifdef LITTLE_ENDIAN_BITFIELDS
515 PackedBit except : 1;
516 PackedBit access : 1;
520 PackedBit access : 1;
521 PackedBit except : 1;
528 unsigned char res2[3];
529 #ifdef LITTLE_ENDIAN_BITFIELDS
531 PackedBit invert : 1;
532 PackedBit svalid : 1;
534 PackedBit svalid : 1;
535 PackedBit invert : 1;
538 unsigned char source[2];
539 unsigned char pvoltag[36];
540 unsigned char res4[4];
541 unsigned char mediadomain[1];
542 unsigned char mediatype[1];
543 unsigned char res5[2];
544 } StorageElementDescriptor_T;
546 /* ======================================================= */
547 /* DataTransferElementDescriptor_T */
548 /* ======================================================= */
551 unsigned char address[2];
552 #ifdef LITTLE_ENDIAN_BITFIELDS
555 PackedBit except : 1;
556 PackedBit access : 1;
560 PackedBit access : 1;
561 PackedBit except : 1;
568 #ifdef LITTLE_ENDIAN_BITFIELDS
571 PackedBit luvalid : 1;
572 PackedBit idvalid : 1;
574 PackedBit notbus : 1;
576 PackedBit notbus : 1;
578 PackedBit idvalid : 1;
579 PackedBit luvalid : 1;
585 #ifdef LITTLE_ENDIAN_BITFIELDS
587 PackedBit invert : 1;
588 PackedBit svalid : 1;
590 PackedBit svalid : 1;
591 PackedBit invert : 1;
594 unsigned char source[2];
595 unsigned char pvoltag[36];
596 unsigned char res4[42];
597 } DataTransferElementDescriptor_T;
599 /* ======================================================= */
601 /* ======================================================= */
604 #ifdef LITTLE_ENDIAN_BITFIELDS
606 PackedBit qualifier : 3;
608 PackedBit type_modifier : 7;
609 PackedBit removable : 1;
611 PackedBit ansi_version : 3;
612 PackedBit ecma_version : 3;
613 PackedBit iso_version : 2;
615 PackedBit data_format : 4;
616 PackedBit res3_54 : 2;
617 PackedBit termiop : 1;
620 PackedBit qualifier : 3;
623 PackedBit removable : 1;
624 PackedBit type_modifier : 7;
626 PackedBit iso_version : 2;
627 PackedBit ecma_version : 3;
628 PackedBit ansi_version : 3;
631 PackedBit termiop : 1;
632 PackedBit res3_54 : 2;
633 PackedBit data_format : 4;
636 unsigned char add_len;
641 #ifdef LITTLE_ENDIAN_BITFIELDS
642 PackedBit softreset : 1;
643 PackedBit cmdque : 1;
644 PackedBit res7_2 : 1;
645 PackedBit linked : 1;
647 PackedBit wbus16 : 1;
648 PackedBit wbus32 : 1;
649 PackedBit reladr : 1;
651 PackedBit reladr : 1;
652 PackedBit wbus32 : 1;
653 PackedBit wbus16 : 1;
655 PackedBit linked : 1;
656 PackedBit res7_2 : 1;
657 PackedBit cmdque : 1;
658 PackedBit softreset : 1;
662 char prod_version[4];
663 char vendor_specific[20];
666 /* ======================================================= */
667 /* ModeSenseHeader_T */
668 /* ======================================================= */
671 unsigned char DataLength;
672 unsigned char MediumType;
673 #ifdef LITTLE_ENDIAN_BITFIELDS
675 PackedBit BufferedMode:3;
679 PackedBit BufferedMode:3;
682 unsigned char BlockDescLength;
684 /* ======================================================= */
685 /* ModeBlockDescriptor_T */
686 /* ======================================================= */
689 unsigned char DensityCode;
690 unsigned char NumberOfBlocks[3];
691 unsigned char Reserved;
692 unsigned char BlockLength[3];
693 } ModeBlockDescriptor_T;
694 /* ======================================================= */
695 /* LogSenseHeader_T */
696 /* ======================================================= */
699 #ifdef LITTLE_ENDIAN_BITFIELDS
700 PackedBit PageCode:6;
701 PackedBit Reserved:2;
703 PackedBit Reserved:2;
704 PackedBit PageCode:6;
706 unsigned char Reserved1;
707 unsigned char PageLength[2];
709 /* ======================================================= */
710 /* LogParameters_T */
711 /* ======================================================= */
714 unsigned char ParameterCode[2];
715 #ifdef LITTLE_ENDIAN_BITFIELDS
732 char ParameterLength;
735 * Pages returned by the MODE_SENSE command
738 unsigned char SenseDataLength;
740 } ParameterListHeader_T;
741 /* ======================================================= */
742 /* ReadWriteErrorRecoveryPage_T */
743 /* ======================================================= */
746 #ifdef LITTLE_ENDIAN_BITFIELDS
747 PackedBit PageCode : 6;
753 PackedBit PageCode : 6;
755 unsigned char ParameterListLength;
756 #ifdef LITTLE_ENDIAN_BITFIELDS
757 PackedBit dcr :1; /* Disable ECC Correction */
758 PackedBit dte :1; /* Disable Transfer on Error */
759 PackedBit per :1; /* Enable Post Error reporting */
760 PackedBit eer :1; /* Enable early recovery */
762 PackedBit tb :1; /* Transfer block (when not fully recovered) */
775 unsigned char ReadRetryCount;
776 unsigned char res4[4];
777 unsigned char WriteRetryCount;
778 unsigned char res5[3];
779 } ReadWriteErrorRecoveryPage_T;
780 /* ======================================================= */
781 /* EDisconnectReconnectPage_T */
782 /* ======================================================= */
785 #ifdef LITTLE_ENDIAN_BITFIELDS
786 PackedBit PageCode : 6;
792 PackedBit PageCode : 6;
795 unsigned char BufferFullRatio;
796 unsigned char BufferEmptyRatio;
797 unsigned char BusInactivityLimit[2];
798 unsigned char DisconnectTimeLimit[2];
799 unsigned char ConnectTimeLimit[2];
800 unsigned char MaximumBurstSize[2];
802 #ifdef LITTLE_ENDIAN_BITFIELDS
809 unsigned char res1[3];
810 } DisconnectReconnectPage_T;
812 /* ======================================================= */
814 /* ======================================================= */
817 #ifdef LITTLE_ENDIAN_BITFIELDS
818 PackedBit PageCode : 6;
824 PackedBit PageCode : 6;
826 unsigned char ParameterListLength;
827 unsigned char MediumTransportElementAddress[2];
828 unsigned char NoMediumTransportElements[2];
829 unsigned char FirstStorageElementAddress[2];
830 unsigned char NoStorageElements[2];
831 unsigned char FirstImportExportElementAddress[2];
832 unsigned char NoImportExportElements[2];
833 unsigned char FirstDataTransferElementAddress[2];
834 unsigned char NoDataTransferElements[2];
835 unsigned char res[2];
837 /* ======================================================= */
838 /* TransPortGeometryDescriptorPage_T */
839 /* ======================================================= */
841 #ifdef LITTLE_ENDIAN_BITFIELDS
842 PackedBit PageCode : 6;
848 PackedBit PageCode : 6;
850 unsigned char ParameterListLength;
851 #ifdef LITTLE_ENDIAN_BITFIELDS
852 PackedBit Rotate : 1;
856 PackedBit Rotate : 1;
858 unsigned char MemberNumber;
859 } TransportGeometryDescriptorPage_T;
860 /* ======================================================= */
861 /* DeviceCapabilitiesPage_T */
862 /* ======================================================= */
865 #ifdef LITTLE_ENDIAN_BITFIELDS
866 PackedBit PageCode : 6;
872 PackedBit PageCode : 6;
874 unsigned char ParameterLength;
875 #ifdef LITTLE_ENDIAN_BITFIELDS
889 #ifdef LITTLE_ENDIAN_BITFIELDS
903 #ifdef LITTLE_ENDIAN_BITFIELDS
917 #ifdef LITTLE_ENDIAN_BITFIELDS
931 #ifdef LITTLE_ENDIAN_BITFIELDS
944 unsigned char res0819[12];
945 } DeviceCapabilitiesPage_T;
946 /* ======================================================= */
947 /* ModePageEXB10hLCD_T */
948 /* ======================================================= */
949 typedef struct ModePageEXB10hLCD
951 unsigned char PageCode;
952 unsigned char ParameterListLength;
954 #ifdef LITTLE_ENDIAN_BITFIELDS
955 PackedBit WriteLine4 : 1;
956 PackedBit WriteLine3 : 1;
957 PackedBit WriteLine2 : 1;
958 PackedBit WriteLine1 : 1;
962 PackedBit WriteLine1 : 1;
963 PackedBit WriteLine2 : 1;
964 PackedBit WriteLine3 : 1;
965 PackedBit WriteLine4 : 1;
967 unsigned char reserved;
968 unsigned char line1[20];
969 unsigned char line2[20];
970 unsigned char line3[20];
971 unsigned char line4[20];
972 } ModePageEXB10hLCD_T;
973 /* ======================================================= */
974 /* ModePageEXBBaudRatePage_T */
975 /* ======================================================= */
976 typedef struct ModePageEXBBaudRatePage
978 unsigned char PageCode;
979 unsigned char ParameterListLength;
980 unsigned char BaudRate[2];
981 } ModePageEXBBaudRatePage_T;
982 /* ======================================================= */
983 /* ModePageEXB120VendorUnique_T */
984 /* ======================================================= */
985 typedef struct ModePageEXB120VendorUnique
987 #ifdef LITTLE_ENDIAN_BITFIELDS
988 PackedBit PageCode : 6;
994 PackedBit PageCode : 6;
996 unsigned char ParameterListLength;
997 #ifdef LITTLE_ENDIAN_BITFIELDS
1014 unsigned char MaxParityRetries;
1015 unsigned char DisplayMessage[60];
1016 } ModePageEXB120VendorUnique_T;
1017 /* ======================================================= */
1018 /* ModePageTreeFrogVendorUnique_T */
1019 /* ======================================================= */
1020 typedef struct ModePageTreeFrogVendorUnique
1022 #ifdef LITTLE_ENDIAN_BITFIELDS
1023 PackedBit PageCode : 6;
1029 PackedBit PageCode : 6;
1031 unsigned char ParameterListLength;
1032 #ifdef LITTLE_ENDIAN_BITFIELDS
1033 PackedBit EBARCO : 1;
1034 PackedBit CHKSUM : 1;
1038 PackedBit CHKSUM : 1;
1039 PackedBit EBARCO : 1;
1048 } ModePageTreeFrogVendorUnique_T;
1049 /* ======================================================= */
1051 /* ======================================================= */
1052 typedef struct ElementInfo
1054 int type; /* CHANGER - 1, STORAGE - 2, TAPE - 4 */
1055 int address; /* Adress of this Element */
1056 int from; /* From where did it come */
1057 char status; /* F -> Full, E -> Empty */
1058 char VolTag[TAG_SIZE+1]; /* Label Info if Barcode reader exsist */
1059 unsigned char ASC; /* Additional Sense Code from read element status */
1060 unsigned char ASCQ; /* */
1061 unsigned char scsi; /* if DTE, which scsi address */
1063 PackedBit svalid : 1;
1064 PackedBit invert : 1;
1066 PackedBit impexp : 1;
1067 PackedBit except : 1;
1068 PackedBit access : 1;
1069 PackedBit inenab : 1;
1070 PackedBit exenab : 1;
1077 char *ident; /* Name of the device from inquiry */
1078 char *type; /* Device Type, tape|robot */
1079 int (*function_move)(int, int, int);
1080 int (*function_status)(int, int);
1081 int (*function_reset_status)(int);
1082 int (*function_free)(void);
1083 int (*function_eject)(char *, int);
1084 int (*function_clean)(char *);
1085 int (*function_rewind)(int);
1086 int (*function_barcode)(int);
1087 int (*function_search)(void);
1088 int (*function_error)(int, unsigned char, unsigned char, unsigned char, unsigned char, RequestSense_T *);
1092 unsigned char command; /* The SCSI command byte */
1093 int length; /* How long */
1094 char *name; /* Name of the command */
1097 typedef struct OpenFiles {
1098 int fd; /* The filedescriptor */
1099 #ifdef HAVE_CAM_LIKE_SCSI
1100 struct cam_device *curdev;
1102 unsigned char avail; /* Is this device available */
1103 unsigned char devopen; /* Is the device open */
1104 unsigned char inqdone; /* Did we try to get device infos, was an open sucessfull */
1105 unsigned char SCSI; /* Can we send SCSI commands */
1106 int flags; /* Can be used for some flags ... */
1107 char *dev; /* The device which is used */
1108 char *type; /* Type of device, tape/changer */
1109 char *ConfigName; /* The name in the config */
1110 char ident[17]; /* The identifier from the inquiry command */
1111 ChangerCMD_T *functions; /* Pointer to the function array for this device */
1112 SCSIInquiry_T *inquiry; /* The result from the Inquiry */
1115 typedef struct LogPageDecode {
1118 void (*decode)(LogParameter_T *, size_t);
1122 char *ident; /* Ident as returned from the inquiry */
1123 char *vendor; /* Vendor as returned from the inquiry */
1124 unsigned char type; /* removable .... */
1125 unsigned char sense;/* Sense key as returned from the device */
1126 unsigned char asc; /* ASC as set in the sense struct */
1127 unsigned char ascq; /* ASCQ as set in the sense struct */
1128 int ret; /* What we think that we should return on this conditon */
1129 char text[80]; /* A short text describing this condition */
1132 /* ======================================================= */
1133 /* Function-Declaration */
1134 /* ======================================================= */
1135 int SCSI_OpenDevice(int);
1136 int OpenDevice(int, char *DeviceName, char *ConfigName, char *ident);
1138 int SCSI_CloseDevice(int DeviceFD);
1139 int CloseDevice(char *, int);
1140 int Tape_Eject(int);
1141 int Tape_Status(int);
1142 void DumpSense(void);
1143 int Sense2Action(char *ident,
1145 unsigned char ignsense,
1146 unsigned char sense,
1151 int SCSI_ExecuteCommand(int DeviceFD,
1152 Direction_T Direction,
1156 size_t DataBufferLength,
1157 RequestSense_T *RequestSense,
1158 size_t RequestSenseLength);
1160 int Tape_Ioctl(int DeviceFD, int command);
1161 void ChangerStatus(char * option,
1168 int SCSI_Inquiry(int, SCSIInquiry_T *, size_t);
1169 int PrintInquiry(SCSIInquiry_T *);
1170 int DecodeSCSI(CDB_T CDB, char *string);
1172 int RequestSense(int fd, ExtendedRequestSense_T *s, int ClearErrorCounters);
1173 int DecodeSense(RequestSense_T *sense, char *pstring, FILE *out);
1174 int DecodeExtSense(ExtendedRequestSense_T *sense, char *pstring, FILE *out);
1176 void ChgExit(char *, char *, int);
1178 void ChangerReplay(char *option);
1179 void ChangerStatus(char *option, char *labelfile, int HasBarCode, char *changer_file, char *changer_dev, char *tape_device);
1180 int BarCode(int fd);
1181 int MapBarCode(char *labelfile, MBC_T *);
1183 int Tape_Ready(int fd, time_t wait_time);
1185 void Inventory(char *labelfile, int drive, int eject, int start, int stop, int clean);
1186 void ChangerDriverVersion(void);
1187 void PrintConf(void);
1188 int LogSense(int fd);
1189 int ScanBus(int print);
1190 void DebugPrint(int level, int section, char * fmt, ...);
1191 int DecodeSense(RequestSense_T *sense, char *pstring, FILE *out);
1192 void SCSI_OS_Version(void);
1193 int get_clean_state(char *tapedev);
1194 int find_empty(int fd, int start, int count);
1195 int get_slot_count(int fd);
1196 int get_drive_count(int fd);
1197 int GetCurrentSlot(int fd, int drive);
1198 void DumpDev(OpenFiles_T *p, char *device);
1199 int isempty(int fd, int slot);
1201 #endif /* !SCSIDEFS_H */
1204 * indent-tabs-mode: nil