3 * Copyright (c) 1998 T.Hepper
5 #ifndef WORDS_BIGENDIAN
6 #define LITTLE_ENDIAN_BITFIELDS
9 typedef enum { Input, Output } Direction_T;
10 typedef unsigned char CDB_T[12];
13 typedef unsigned int PackedBit;
16 typedef unsigned char PackedBit;
19 #define INDEX_CHANGER 0
21 #define INDEX_TAPECTL 2
23 #define CHG_MAXDEV 32 /* Maximum number of devices handled by pDev */
24 /* Must be large to hold the result of ScanBus */
32 #define MAXTRIES 100 /* How many tries until SCSI_TestUnitReady should return an ok */
34 * Sense Key definitions
37 #define SENSE_RECOVERED_ERROR 1
39 #define SENSE_NOT_READY 2
40 #define SENSE_MEDIUM_ERROR 3
41 #define SENSE_HARDWARE_ERROR 4
42 #define HARDWARE_ERROR 4
43 #define ILLEGAL_REQUEST 5
44 #define SENSE_ILLEGAL_REQUEST 5
45 #define UNIT_ATTENTION 6
46 #define SENSE_UNIT_ATTENTION 6
47 #define SENSE_DATA_PROTECT 7
48 #define SENSE_BLANK_CHECK 8
49 #define SENSE_VENDOR_SPECIFIC 0x9
50 #define SENSE_ABORTED_COMMAND 0xb
51 #define SENSE_VOLUME_OVERFLOW 0xd
52 #define SENSE_CHG_ELEMENT_STATUS 0xe
54 #define MAX_RETRIES 100
56 #define INQUIRY_SIZE sizeof(SCSIInquiry_T)
59 * Return values from the OS dependent part
60 * of the SCSI interface
62 * The underlaying functions must decide what to do
74 #define SC_COM_TEST_UNIT_READY 0
75 #define SC_COM_REWIND 0x1
76 #define SC_COM_REQUEST_SENSE 0x3
77 #define SC_COM_IES 0x7
78 #define SC_COM_INQUIRY 0x12
79 #define SC_COM_MODE_SELECT 0x15
80 #define SC_COM_ERASE 0x19
81 #define SC_COM_MODE_SENSE 0x1A
82 #define SC_COM_UNLOAD 0x1B
83 #define SC_COM_LOCATE 0x2B
84 #define SC_COM_LOG_SELECT 0x4C
85 #define SC_COM_LOG_SENSE 0x4d
86 #define SC_MOVE_MEDIUM 0xa5
87 #define SC_COM_RES 0xb8
89 * Define for LookupDevice
94 #define LOOKUP_CONFIG 4
96 * Define for the return codes from SenseHandler
98 #define SENSE_ABORT -1
99 #define SENSE_IGNORE 0
100 #define SENSE_RETRY 2
102 #define SENSE_TAPE_NOT_ONLINE 4
103 #define SENSE_TAPE_NOT_LOADED 5
105 #define SENSE_TAPE_NOT_UNLOADED 7
106 #define SENSE_CHM_FULL 8
108 * Defines for the type field in the inquiry command
112 #define TYPE_PRINTER 2
113 #define TYPE_PROCESSOR 3
116 #define TYPE_SCANNER 6
117 #define TYPE_OPTICAL 7
118 #define TYPE_CHANGER 8
121 /* Defines for Tape_Status */
122 #define TAPE_ONLINE 1 /* Tape is loaded */
123 #define TAPE_BOT 2 /* Tape is at begin of tape */
124 #define TAPE_EOT 4 /* Tape is at end of tape */
125 #define TAPE_WR_PROT 8 /* Tape is write protected */
126 #define TAPE_NOT_LOADED 16 /* Tape is not loaded */
128 /* Defines for the function Tape_Ioctl */
129 #define IOCTL_EJECT 0
131 /* Defines for exit status */
135 /* macros for building scsi msb array parameter lists */
137 #define B(s,i) ((unsigned char)((s) >> i))
140 #define B1(s) ((unsigned char)(s))
142 #define B2(s) B((s),8), B1(s)
143 #define B3(s) B((s),16), B((s),8), B1(s)
144 #define B4(s) B((s),24), B((s),16), B((s),8), B1(s)
146 /* macros for converting scsi msb array to binary */
148 #define V2(s) (((s)[0] << 8) | (s)[1])
149 #define V3(s) (((((s)[0] << 8) | (s)[1]) << 8) | (s)[2])
150 #define V4(s) (((((((s)[0] << 8) | (s)[1]) << 8) | (s)[2]) << 8) | (s)[3])
151 #define V5(s) (((((((((s)[0] << 8) | (s)[1]) << 8) | (s)[2]) << 8) | (s)[3]) << 8) | (s)[4])
152 #define V6(s) (((((((((((s)[0] << 8) | (s)[1]) << 8) | (s)[2]) << 8) | (s)[3]) << 8) | (s)[4]) << 8) | (s)[5])
154 /* macros for converting binary into scsi msb array */
155 #define MSB1(s,v) *(s)=B1(v)
156 #define MSB2(s,v) *(s)=B(v,8), (s)[1]=B1(v)
157 #define MSB3(s,v) *(s)=B(v,16), (s)[1]=B(v,8), (s)[2]=B1(v)
158 #define MSB4(s,v) *(s)=B(v,24),(s)[1]=B(v,16), (s)[2]=B(v,8), (s)[3]=B1(v)
160 #define LABEL_DB_VERSION 2
163 #define DEBUG_ERROR 1
166 #define SECTION_ALL 0
167 #define SECTION_INFO 1
168 #define SECTION_SCSI 2
169 #define SECTION_MAP_BARCODE 3
170 #define SECTION_ELEMENT 4
171 #define SECTION_BARCODE 5
172 #define SECTION_TAPE 6
173 #define SECTION_MOVE 7
174 /*----------------------------------------------------------------------------*/
175 /* Some stuff for our own configurationfile */
176 typedef struct { /* The information we can get for any drive (configuration) */
177 int drivenum; /* Which drive to use in the library */
178 int start; /* Which is the first slot we may use */
179 int end; /* The last slot we are allowed to use */
180 int cleanslot; /* Where the cleaningcartridge stays */
181 char *scsitapedev; /* Where can we send raw SCSI commands to the tape */
182 char *device; /* Which device is associated to the drivenum */
183 char *slotfile; /* Where we should have our memory */
184 char *cleanfile; /* Where we count how many cleanings we did */
185 char *timefile; /* Where we count the time the tape was used*/
186 char *tapestatfile;/* Where can we place some drive stats */
187 char *changerident;/* Config to use foe changer control, ovverride result from inquiry */
188 char *tapeident; /* Same as above for the tape device */
192 int number_of_configs; /* How many different configurations are used */
193 int eject; /* Do the drives need an eject-command */
194 int autoinv; /* Do automaticly an inventory if an tape is not in the db or not active in the db */
195 int havebarcode; /* Do we have an barcode reader installed */
196 char *debuglevel; /* How many debug info to print */
197 unsigned char emubarcode; /* Emulate the barcode feature, used for keeping an inventory of the lib */
198 int sleep; /* How many seconds to wait for the drive to get ready */
199 int cleanmax; /* How many runs could be done with one cleaning tape */
200 char *device; /* Which device is our changer */
201 char *labelfile; /* Mapping from Barcode labels to volume labels */
207 char barcode[TAG_SIZE];
212 char voltag[128]; /* Tape volume label */
213 char barcode[TAG_SIZE]; /* Barcode of the tape */
214 unsigned int slot; /* in which slot is the tape */
215 unsigned int from; /* from where it comes, needed to move
216 * a tape back to the right slot from the drive
219 unsigned int LoadCount; /* How many times has the tape been loaded */
220 unsigned int RecovError; /* How many recovered errors */
221 unsigned int UnrecovError; /* How man unrecoverd errors */
222 unsigned char valid; /* Is this tape in the current magazin */
225 typedef enum {BARCODE_PUT, BARCODE_VOL, BARCODE_BARCODE, BARCODE_DUMP, RESET_VALID, FIND_SLOT, UPDATE_SLOT } MBCAction_T;
232 /* ======================================================= */
234 /* ======================================================= */
237 #ifdef LITTLE_ENDIAN_BITFIELDS
238 PackedBit ErrorCode:7; /* Byte 0 Bits 0-6 */
239 PackedBit Valid:1; /* Byte 0 Bit 7 */
241 PackedBit Valid:1; /* Byte 0 Bit 7 */
242 PackedBit ErrorCode:7; /* Byte 0 Bits 0-6 */
244 unsigned char SegmentNumber; /* Byte 1 */
245 #ifdef LITTLE_ENDIAN_BITFIELDS
246 PackedBit SenseKey:4; /* Byte 2 Bits 0-3 */
247 PackedBit :1; /* Byte 2 Bit 4 */
248 PackedBit RILI:1; /* Byte 2 Bit 5 */
249 PackedBit REOM:1; /* Byte 2 Bit 6 */
250 PackedBit Filemark:1; /* Byte 2 Bit 7 */
252 PackedBit Filemark:1; /* Byte 2 Bit 7 */
253 PackedBit REOM:1; /* Byte 2 Bit 6 */
254 PackedBit RILI:1; /* Byte 2 Bit 5 */
255 PackedBit :1; /* Byte 2 Bit 4 */
256 PackedBit SenseKey:4; /* Byte 2 Bits 0-3 */
258 unsigned char Information[4]; /* Bytes 3-6 */
259 unsigned char AdditionalSenseLength; /* Byte 7 */
260 unsigned char CommandSpecificInformation[4]; /* Bytes 8-11 */
261 unsigned char AdditionalSenseCode; /* Byte 12 */
262 unsigned char AdditionalSenseCodeQualifier; /* Byte 13 */
263 unsigned char Byte14; /* Byte 14 */
264 unsigned char Byte15; /* Byte 15 */
268 /* ======================================================= */
269 /* ExtendedRequestSense_T */
270 /* ======================================================= */
273 #ifdef LITTLE_ENDIAN_BITFIELDS
274 PackedBit ErrorCode:7; /* Byte 0 Bits 0-6 */
275 PackedBit Valid:1; /* Byte 0 Bit 7 */
277 PackedBit Valid:1; /* Byte 0 Bit 7 */
278 PackedBit ErrorCode:7; /* Byte 0 Bits 0-6 */
280 unsigned char SegmentNumber; /* Byte 1 */
281 #ifdef LITTLE_ENDIAN_BITFIELDS
282 PackedBit SenseKey:4; /* Byte 2 Bits 0-3 */
283 PackedBit :1; /* Byte 2 Bit 4 */
284 PackedBit RILI:1; /* Byte 2 Bit 5 */
285 PackedBit REOM:1; /* Byte 2 Bit 6 */
286 PackedBit Filemark:1; /* Byte 2 Bit 7 */
288 PackedBit Filemark:1; /* Byte 2 Bit 7 */
289 PackedBit REOM:1; /* Byte 2 Bit 6 */
290 PackedBit RILI:1; /* Byte 2 Bit 5 */
291 PackedBit :1; /* Byte 2 Bit 4 */
292 PackedBit SenseKey:4; /* Byte 2 Bits 0-3 */
294 unsigned char Information[4]; /* Bytes 3-6 */
295 unsigned char AdditionalSenseLength; /* Byte 7 */
296 unsigned char LogParameterPageCode; /* Bytes 8 */
297 unsigned char LogParameterCode; /* Bytes 9 */
298 unsigned char Byte10; /* Bytes 10 */
299 unsigned char UnderrunOverrunCounter; /* Bytes 11 */
300 unsigned char AdditionalSenseCode; /* Byte 12 */
301 unsigned char AdditionalSenseCodeQualifier; /* Byte 13 */
302 unsigned char Byte14; /* Byte 14 */
303 unsigned char Byte15; /* Byte 15 */
304 unsigned char ReadWriteDataErrorCounter[3]; /* Byte 16-18 */
305 #ifdef LITTLE_ENDIAN_BITFIELDS
306 PackedBit LBOT:1; /* Byte 19 Bits 0 */
307 PackedBit TNP:1; /* Byte 19 Bits 1 */
308 PackedBit TME:1; /* Byte 19 Bits 2 */
309 PackedBit ECO:1; /* Byte 19 Bits 3 */
310 PackedBit ME:1; /* Byte 19 Bits 4 */
311 PackedBit FPE:1; /* Byte 19 Bits 5 */
312 PackedBit BPE:1; /* Byte 19 Bits 6 */
313 PackedBit PF:1; /* Byte 19 Bits 7 */
315 PackedBit PF:1; /* Byte 19 Bits 7 */
316 PackedBit BPE:1; /* Byte 19 Bits 6 */
317 PackedBit FPE:1; /* Byte 19 Bits 5 */
318 PackedBit ME:1; /* Byte 19 Bits 4 */
319 PackedBit ECO:1; /* Byte 19 Bits 3 */
320 PackedBit TME:1; /* Byte 19 Bits 2 */
321 PackedBit TNP:1; /* Byte 19 Bits 1 */
322 PackedBit LBOT:1; /* Byte 19 Bits 0 */
324 #ifdef LITTLE_ENDIAN_BITFIELDS
325 PackedBit FE:1; /* Byte 20 Bits 0 */
326 PackedBit SSE:1; /* Byte 20 Bits 1 */
327 PackedBit WEI:1; /* Byte 20 Bits 2 */
328 PackedBit URE:1; /* Byte 20 Bits 3 */
329 PackedBit FMKE:1; /* Byte 20 Bits 4 */
330 PackedBit WP:1; /* Byte 20 Bits 5 */
331 PackedBit TMD:1; /* Byte 20 Bits 6 */
332 PackedBit :1; /* Byte 20 Bits 7 */
334 PackedBit :1; /* Byte 20 Bits 7 */
335 PackedBit TMD:1; /* Byte 20 Bits 6 */
336 PackedBit WP:1; /* Byte 20 Bits 5 */
337 PackedBit FMKE:1; /* Byte 20 Bits 4 */
338 PackedBit URE:1; /* Byte 20 Bits 3 */
339 PackedBit WEI:1; /* Byte 20 Bits 2 */
340 PackedBit SSE:1; /* Byte 20 Bits 1 */
341 PackedBit FE:1; /* Byte 20 Bits 0 */
343 #ifdef LITTLE_ENDIAN_BITFIELDS
344 PackedBit WSEO:1; /* Byte 21 Bits 0 */
345 PackedBit WSEB:1; /* Byte 21 Bits 1 */
346 PackedBit PEOT:1; /* Byte 21 Bits 2 */
347 PackedBit CLN:1; /* Byte 21 Bits 3 */
348 PackedBit CLND:1; /* Byte 21 Bits 4 */
349 PackedBit RRR:1; /* Byte 21 Bits 5 */
350 PackedBit UCLN:1; /* Byte 21 Bits 6 */
351 PackedBit :1; /* Byte 21 Bits 7 */
353 PackedBit :1; /* Byte 21 Bits 7 */
354 PackedBit UCLN:1; /* Byte 21 Bits 6 */
355 PackedBit RRR:1; /* Byte 21 Bits 5 */
356 PackedBit CLND:1; /* Byte 21 Bits 4 */
357 PackedBit CLN:1; /* Byte 21 Bits 3 */
358 PackedBit PEOT:1; /* Byte 21 Bits 2 */
359 PackedBit WSEB:1; /* Byte 21 Bits 1 */
360 PackedBit WSEO:1; /* Byte 21 Bits 0 */
362 unsigned char Byte21; /* Byte 22 */
363 unsigned char RemainingTape[3]; /* Byte 23-25 */
364 unsigned char TrackingRetryCounter; /* Byte 26 */
365 unsigned char ReadWriteRetryCounter; /* Byte 27 */
366 unsigned char FaultSymptomCode; /* Byte 28 */
368 } ExtendedRequestSense_T;
370 /* ======================================================= */
371 /* ReadElementStatus_T */
372 /* ======================================================= */
375 unsigned char cmd; /* Byte 1 */
376 #ifdef LITTLE_ENDIAN_BITFIELDS
385 unsigned char start[2]; /* Byte 3-4 */
386 unsigned char number[2]; /* Byte 5-6 */
387 unsigned char byte4; /* Byte 7 */
388 unsigned char length[4]; /* Byte 8-11 */
389 unsigned char byte78[2]; /* Byte 12-13 */
390 } ReadElementStatus_T;
392 /* ======================================================= */
393 /* ElementStatusPage_T */
394 /* ======================================================= */
397 unsigned char type; /* Byte 1 = Element Type Code*/
398 #ifdef LITTLE_ENDIAN_BITFIELDS
399 PackedBit bitres : 6;
400 PackedBit avoltag : 1;
401 PackedBit pvoltag : 1;
403 PackedBit pvoltag : 1;
404 PackedBit avoltag : 1;
405 PackedBit bitres : 6;
407 unsigned char length[2]; /* Byte 2-3 = Element Descriptor Length */
408 unsigned char byte4; /* Byte 4 */
409 unsigned char count[3]; /* Byte 5-7 = Byte Count of Descriptor Available */
410 } ElementStatusPage_T;
413 /* ======================================================= */
414 /* ElementStatusData_T */
415 /* ======================================================= */
418 unsigned char first[2]; /* Byte 1-2 = First Element Adress Reported */
419 unsigned char number[2]; /* Byte 3-4 = Number of Elements Available */
420 unsigned char byte5; /* Reserved */
421 unsigned char count[3]; /* Byte 6-8 = Byte Count of Report Available */
422 } ElementStatusData_T;
424 /* ======================================================= */
425 /* MediumTransportElementDescriptor_T */
426 /* ======================================================= */
429 unsigned char address[2]; /* Byte 1-2 = Element Address */
430 #ifdef LITTLE_ENDIAN_BITFIELDS
433 PackedBit except : 1;
437 PackedBit except : 1;
441 unsigned char byte4; /* Byte 4 */
442 unsigned char asc; /* Byte 5 ASC */
443 unsigned char ascq; /* Byte 6 ASCQ */
444 unsigned char byte79[3]; /* Byte 7-9 */
445 #ifdef LITTLE_ENDIAN_BITFIELDS
446 PackedBit byte10res : 6;
447 PackedBit invert : 1;
448 PackedBit svalid : 1;
450 PackedBit svalid : 1;
451 PackedBit invert : 1;
452 PackedBit byte10res : 6;
454 unsigned char source[2];
455 unsigned char pvoltag[36];
456 unsigned char res4[4];
457 } MediumTransportElementDescriptor_T;
459 /* ======================================================= */
460 /* ImportExportElementDescriptor_T */
461 /* ======================================================= */
464 unsigned char address[2]; /* Byte 1 = Element Address */
465 #ifdef LITTLE_ENDIAN_BITFIELDS
467 PackedBit impexp : 1;
468 PackedBit except : 1;
469 PackedBit access : 1;
470 PackedBit exenab : 1;
471 PackedBit inenab : 1;
475 PackedBit inenab : 1;
476 PackedBit exenab : 1;
477 PackedBit access : 1;
478 PackedBit except : 1;
485 unsigned char byte79[3];
486 #ifdef LITTLE_ENDIAN_BITFIELDS
487 PackedBit byte10res : 6;
488 PackedBit invert : 1;
489 PackedBit svalid : 1;
491 PackedBit svalid : 1;
492 PackedBit invert : 1;
493 PackedBit byte10res : 6;
495 unsigned char source[2];
496 unsigned char pvoltag[36];
497 unsigned char res4[4];
498 unsigned char mediadomain[1];
499 unsigned char mediatype[1];
500 unsigned char res5[2];
501 } ImportExportElementDescriptor_T;
503 /* ======================================================= */
504 /* StorageElementDescriptor_T */
505 /* ======================================================= */
508 unsigned char address[2];
509 #ifdef LITTLE_ENDIAN_BITFIELDS
512 PackedBit except : 1;
513 PackedBit access : 1;
517 PackedBit access : 1;
518 PackedBit except : 1;
525 unsigned char res2[3];
526 #ifdef LITTLE_ENDIAN_BITFIELDS
528 PackedBit invert : 1;
529 PackedBit svalid : 1;
531 PackedBit svalid : 1;
532 PackedBit invert : 1;
535 unsigned char source[2];
536 unsigned char pvoltag[36];
537 unsigned char res4[4];
538 unsigned char mediadomain[1];
539 unsigned char mediatype[1];
540 unsigned char res5[2];
541 } StorageElementDescriptor_T;
543 /* ======================================================= */
544 /* DataTransferElementDescriptor_T */
545 /* ======================================================= */
548 unsigned char address[2];
549 #ifdef LITTLE_ENDIAN_BITFIELDS
552 PackedBit except : 1;
553 PackedBit access : 1;
557 PackedBit access : 1;
558 PackedBit except : 1;
565 #ifdef LITTLE_ENDIAN_BITFIELDS
568 PackedBit luvalid : 1;
569 PackedBit idvalid : 1;
571 PackedBit notbus : 1;
573 PackedBit notbus : 1;
575 PackedBit idvalid : 1;
576 PackedBit luvalid : 1;
582 #ifdef LITTLE_ENDIAN_BITFIELDS
584 PackedBit invert : 1;
585 PackedBit svalid : 1;
587 PackedBit svalid : 1;
588 PackedBit invert : 1;
591 unsigned char source[2];
592 unsigned char pvoltag[36];
593 unsigned char res4[42];
594 } DataTransferElementDescriptor_T;
596 /* ======================================================= */
598 /* ======================================================= */
601 #ifdef LITTLE_ENDIAN_BITFIELDS
603 PackedBit qualifier : 3;
605 PackedBit type_modifier : 7;
606 PackedBit removable : 1;
608 PackedBit ansi_version : 3;
609 PackedBit ecma_version : 3;
610 PackedBit iso_version : 2;
612 PackedBit data_format : 4;
613 PackedBit res3_54 : 2;
614 PackedBit termiop : 1;
617 PackedBit qualifier : 3;
620 PackedBit removable : 1;
621 PackedBit type_modifier : 7;
623 PackedBit iso_version : 2;
624 PackedBit ecma_version : 3;
625 PackedBit ansi_version : 3;
628 PackedBit termiop : 1;
629 PackedBit res3_54 : 2;
630 PackedBit data_format : 4;
633 unsigned char add_len;
638 #ifdef LITTLE_ENDIAN_BITFIELDS
639 PackedBit softreset : 1;
640 PackedBit cmdque : 1;
641 PackedBit res7_2 : 1;
642 PackedBit linked : 1;
644 PackedBit wbus16 : 1;
645 PackedBit wbus32 : 1;
646 PackedBit reladr : 1;
648 PackedBit reladr : 1;
649 PackedBit wbus32 : 1;
650 PackedBit wbus16 : 1;
652 PackedBit linked : 1;
653 PackedBit res7_2 : 1;
654 PackedBit cmdque : 1;
655 PackedBit softreset : 1;
659 char prod_version[4];
660 char vendor_specific[20];
663 /* ======================================================= */
664 /* ModeSenseHeader_T */
665 /* ======================================================= */
668 unsigned char DataLength;
669 unsigned char MediumType;
670 #ifdef LITTLE_ENDIAN_BITFIELDS
672 PackedBit BufferedMode:3;
676 PackedBit BufferedMode:3;
679 unsigned char BlockDescLength;
681 /* ======================================================= */
682 /* ModeBlockDescriptor_T */
683 /* ======================================================= */
686 unsigned char DensityCode;
687 unsigned char NumberOfBlocks[3];
688 unsigned char Reserved;
689 unsigned char BlockLength[3];
690 } ModeBlockDescriptor_T;
691 /* ======================================================= */
692 /* LogSenseHeader_T */
693 /* ======================================================= */
696 #ifdef LITTLE_ENDIAN_BITFIELDS
697 PackedBit PageCode:6;
698 PackedBit Reserved:2;
700 PackedBit Reserved:2;
701 PackedBit PageCode:6;
703 unsigned char Reserved1;
704 unsigned char PageLength[2];
706 /* ======================================================= */
707 /* LogParameters_T */
708 /* ======================================================= */
711 unsigned char ParameterCode[2];
712 #ifdef LITTLE_ENDIAN_BITFIELDS
729 char ParameterLength;
732 * Pages returned by the MODE_SENSE command
735 unsigned char SenseDataLength;
737 } ParameterListHeader_T;
738 /* ======================================================= */
739 /* ReadWriteErrorRecoveryPage_T */
740 /* ======================================================= */
743 #ifdef LITTLE_ENDIAN_BITFIELDS
744 PackedBit PageCode : 6;
750 PackedBit PageCode : 6;
752 unsigned char ParameterListLength;
753 #ifdef LITTLE_ENDIAN_BITFIELDS
754 PackedBit dcr :1; /* Disable ECC Correction */
755 PackedBit dte :1; /* Disable Transfer on Error */
756 PackedBit per :1; /* Enable Post Error reporting */
757 PackedBit eer :1; /* Enable early recovery */
759 PackedBit tb :1; /* Transfer block (when not fully recovered) */
772 unsigned char ReadRetryCount;
773 unsigned char res4[4];
774 unsigned char WriteRetryCount;
775 unsigned char res5[3];
776 } ReadWriteErrorRecoveryPage_T;
777 /* ======================================================= */
778 /* EDisconnectReconnectPage_T */
779 /* ======================================================= */
782 #ifdef LITTLE_ENDIAN_BITFIELDS
783 PackedBit PageCode : 6;
789 PackedBit PageCode : 6;
792 unsigned char BufferFullRatio;
793 unsigned char BufferEmptyRatio;
794 unsigned char BusInactivityLimit[2];
795 unsigned char DisconnectTimeLimit[2];
796 unsigned char ConnectTimeLimit[2];
797 unsigned char MaximumBurstSize[2];
799 #ifdef LITTLE_ENDIAN_BITFIELDS
806 unsigned char res1[3];
807 } DisconnectReconnectPage_T;
809 /* ======================================================= */
811 /* ======================================================= */
814 #ifdef LITTLE_ENDIAN_BITFIELDS
815 PackedBit PageCode : 6;
821 PackedBit PageCode : 6;
823 unsigned char ParameterListLength;
824 unsigned char MediumTransportElementAddress[2];
825 unsigned char NoMediumTransportElements[2];
826 unsigned char FirstStorageElementAddress[2];
827 unsigned char NoStorageElements[2];
828 unsigned char FirstImportExportElementAddress[2];
829 unsigned char NoImportExportElements[2];
830 unsigned char FirstDataTransferElementAddress[2];
831 unsigned char NoDataTransferElements[2];
832 unsigned char res[2];
834 /* ======================================================= */
835 /* TransPortGeometryDescriptorPage_T */
836 /* ======================================================= */
838 #ifdef LITTLE_ENDIAN_BITFIELDS
839 PackedBit PageCode : 6;
845 PackedBit PageCode : 6;
847 unsigned char ParameterListLength;
848 #ifdef LITTLE_ENDIAN_BITFIELDS
849 PackedBit Rotate : 1;
853 PackedBit Rotate : 1;
855 unsigned char MemberNumber;
856 } TransportGeometryDescriptorPage_T;
857 /* ======================================================= */
858 /* DeviceCapabilitiesPage_T */
859 /* ======================================================= */
862 #ifdef LITTLE_ENDIAN_BITFIELDS
863 PackedBit PageCode : 6;
869 PackedBit PageCode : 6;
871 unsigned char ParameterLength;
872 #ifdef LITTLE_ENDIAN_BITFIELDS
886 #ifdef LITTLE_ENDIAN_BITFIELDS
900 #ifdef LITTLE_ENDIAN_BITFIELDS
914 #ifdef LITTLE_ENDIAN_BITFIELDS
928 #ifdef LITTLE_ENDIAN_BITFIELDS
941 unsigned char res0819[12];
942 } DeviceCapabilitiesPage_T;
943 /* ======================================================= */
944 /* ModePageEXB10hLCD_T */
945 /* ======================================================= */
946 typedef struct ModePageEXB10hLCD
948 unsigned char PageCode;
949 unsigned char ParameterListLength;
951 #ifdef LITTLE_ENDIAN_BITFIELDS
952 PackedBit WriteLine4 : 1;
953 PackedBit WriteLine3 : 1;
954 PackedBit WriteLine2 : 1;
955 PackedBit WriteLine1 : 1;
959 PackedBit WriteLine1 : 1;
960 PackedBit WriteLine2 : 1;
961 PackedBit WriteLine3 : 1;
962 PackedBit WriteLine4 : 1;
964 unsigned char reserved;
965 unsigned char line1[20];
966 unsigned char line2[20];
967 unsigned char line3[20];
968 unsigned char line4[20];
969 } ModePageEXB10hLCD_T;
970 /* ======================================================= */
971 /* ModePageEXBBaudRatePage_T */
972 /* ======================================================= */
973 typedef struct ModePageEXBBaudRatePage
975 unsigned char PageCode;
976 unsigned char ParameterListLength;
977 unsigned char BaudRate[2];
978 } ModePageEXBBaudRatePage_T;
979 /* ======================================================= */
980 /* ModePageEXB120VendorUnique_T */
981 /* ======================================================= */
982 typedef struct ModePageEXB120VendorUnique
984 #ifdef LITTLE_ENDIAN_BITFIELDS
985 PackedBit PageCode : 6;
991 PackedBit PageCode : 6;
993 unsigned char ParameterListLength;
994 #ifdef LITTLE_ENDIAN_BITFIELDS
1011 unsigned char MaxParityRetries;
1012 unsigned char DisplayMessage[60];
1013 } ModePageEXB120VendorUnique_T;
1014 /* ======================================================= */
1015 /* ModePageTreeFrogVendorUnique_T */
1016 /* ======================================================= */
1017 typedef struct ModePageTreeFrogVendorUnique
1019 #ifdef LITTLE_ENDIAN_BITFIELDS
1020 PackedBit PageCode : 6;
1026 PackedBit PageCode : 6;
1028 unsigned char ParameterListLength;
1029 #ifdef LITTLE_ENDIAN_BITFIELDS
1030 PackedBit EBARCO : 1;
1031 PackedBit CHKSUM : 1;
1035 PackedBit CHKSUM : 1;
1036 PackedBit EBARCO : 1;
1045 } ModePageTreeFrogVendorUnique_T;
1046 /* ======================================================= */
1048 /* ======================================================= */
1049 typedef struct ElementInfo
1051 int type; /* CHANGER - 1, STORAGE - 2, TAPE - 4 */
1052 int address; /* Adress of this Element */
1053 int from; /* From where did it come */
1054 char status; /* F -> Full, E -> Empty */
1055 char VolTag[TAG_SIZE+1]; /* Label Info if Barcode reader exsist */
1056 int ASC; /* Additional Sense Code from read element status */
1058 unsigned char scsi; /* if DTE, which scsi address */
1060 PackedBit svalid : 1;
1061 PackedBit invert : 1;
1063 PackedBit impexp : 1;
1064 PackedBit except : 1;
1065 PackedBit access : 1;
1066 PackedBit inenab : 1;
1067 PackedBit exenab : 1;
1074 char *ident; /* Name of the device from inquiry */
1075 char *type; /* Device Type, tape|robot */
1076 int (*function_move)(int, int, int);
1077 int (*function_status)(int, int);
1078 int (*function_reset_status)(int);
1079 int (*function_free)();
1080 int (*function_eject)(char *, int);
1081 int (*function_clean)(char *);
1082 int (*function_rewind)(int);
1083 int (*function_barcode)(int);
1084 int (*function_search)();
1085 int (*function_error)(int, int, unsigned char, unsigned char, unsigned char, char *);
1089 unsigned char command; /* The SCSI command byte */
1090 int length; /* How long */
1091 char *name; /* Name of the command */
1094 typedef struct OpenFiles {
1095 int fd; /* The filedescriptor */
1096 #ifdef HAVE_CAM_LIKE_SCSI
1097 struct cam_device *curdev;
1099 unsigned char avail; /* Is this device available */
1100 unsigned char devopen; /* Is the device open */
1101 unsigned char inqdone; /* Did we try to get device infos, was an open sucessfull */
1102 unsigned char SCSI; /* Can we send SCSI commands */
1103 int flags; /* Can be used for some flags ... */
1104 char *dev; /* The device which is used */
1105 char *type; /* Type of device, tape/changer */
1106 char *ConfigName; /* The name in the config */
1107 char ident[17]; /* The identifier from the inquiry command */
1108 ChangerCMD_T *functions; /* Pointer to the function array for this device */
1109 SCSIInquiry_T *inquiry; /* The result from the Inquiry */
1112 typedef struct LogPageDecode {
1115 void (*decode)(LogParameter_T *, int);
1119 char *ident; /* Ident as returned from the inquiry */
1120 char *vendor; /* Vendor as returned from the inquiry */
1121 int type; /* removable .... */
1122 int sense; /* Sense key as returned from the device */
1123 int asc; /* ASC as set in the sense struct */
1124 int ascq; /* ASCQ as set in the sense struct */
1125 int ret; /* What we think that we should return on this conditon */
1126 char text[80]; /* A short text describing this condition */
1129 /* ======================================================= */
1130 /* Funktion-Declaration */
1131 /* ======================================================= */
1132 int SCSI_OpenDevice(int );
1133 int OpenDevice(int ,char *DeviceName, char *ConfigName, char *ident);
1135 int SCSI_CloseDevice(int DeviceFD);
1136 int CloseDevice(int );
1137 int Tape_Eject(int);
1138 int Tape_Status(int);
1140 int Sense2Action(char *ident, unsigned char type, unsigned char ignsense, unsigned char sense, unsigned
1141 char asc, unsigned char ascq, char **text) ;
1143 int SCSI_ExecuteCommand(int DeviceFD,
1144 Direction_T Direction,
1148 int DataBufferLength,
1150 int RequestSenseLength);
1152 int Tape_Ioctl( int DeviceFD, int command);
1153 void ChangerStatus(char * option, char * labelfile, int HasBarCode, char *changer_file, char *changer_dev, char *tape_device);
1155 int SCSI_Inquiry(int, SCSIInquiry_T *, unsigned char);
1156 int PrintInquiry(SCSIInquiry_T *);
1157 int DecodeSCSI(CDB_T CDB, char *string);
1159 int RequestSense P((int fd, ExtendedRequestSense_T *s, int ClearErrorCounters));
1160 int DecodeSense P((RequestSense_T *sense, char *pstring, FILE *out));
1161 int DecodeExtSense P((ExtendedRequestSense_T *sense, char *pstring, FILE *out));
1163 void ChgExit(char *, char *, int);
1165 void ChangerReplay(char *option);
1166 void ChangerStatus(char * option, char * labelfile, int HasBarCode, char *changer_file, char *changer_dev, char *tape_device);
1167 int BarCode(int fd);
1168 int MapBarCode(char *labelfile, MBC_T *);
1170 int Tape_Ready(int fd, int wait_time);
1172 void Inventory(char *labelfile, int drive, int eject, int start, int stop, int clean);
1173 void ChangerDriverVersion();
1175 int LogSense(int fd);
1176 int ScanBus(int print);
1177 void DebugPrint(int level, int section, char * fmt, ...);
1178 int DecodeSense(RequestSense_T *sense, char *pstring, FILE *out);
1179 void SCSI_OS_Version();
1182 * indent-tabs-mode: nil