Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
BusLogic.h
Go to the documentation of this file.
1 /*
2 
3  Linux Driver for BusLogic MultiMaster and FlashPoint SCSI Host Adapters
4 
5  Copyright 1995-1998 by Leonard N. Zubkoff <[email protected]>
6 
7  This program is free software; you may redistribute and/or modify it under
8  the terms of the GNU General Public License Version 2 as published by the
9  Free Software Foundation.
10 
11  This program is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
13  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14  for complete details.
15 
16  The author respectfully requests that any modifications to this software be
17  sent directly to him for evaluation and testing.
18 
19  Special thanks to Wayne Yen, Jin-Lon Hon, and Alex Win of BusLogic, whose
20  advice has been invaluable, to David Gentzel, for writing the original Linux
21  BusLogic driver, and to Paul Gortmaker, for being such a dedicated test site.
22 
23  Finally, special thanks to Mylex/BusLogic for making the FlashPoint SCCB
24  Manager available as freely redistributable source code.
25 
26 */
27 
28 #ifndef _BUSLOGIC_H
29 #define _BUSLOGIC_H
30 
31 
32 #ifndef PACKED
33 #define PACKED __attribute__((packed))
34 #endif
35 
36 /*
37  Define the maximum number of BusLogic Host Adapters supported by this driver.
38 */
39 
40 #define BusLogic_MaxHostAdapters 16
41 
42 
43 /*
44  Define the maximum number of Target Devices supported by this driver.
45 */
46 
47 #define BusLogic_MaxTargetDevices 16
48 
49 
50 /*
51  Define the maximum number of Scatter/Gather Segments used by this driver.
52  For optimal performance, it is important that this limit be at least as
53  large as the largest single request generated by the I/O Subsystem.
54 */
55 
56 #define BusLogic_ScatterGatherLimit 128
57 
58 
59 /*
60  Define the maximum, maximum automatic, minimum automatic, and default Queue
61  Depth to allow for Target Devices depending on whether or not they support
62  Tagged Queuing and whether or not ISA Bounce Buffers are required.
63 */
64 
65 #define BusLogic_MaxTaggedQueueDepth 64
66 #define BusLogic_MaxAutomaticTaggedQueueDepth 28
67 #define BusLogic_MinAutomaticTaggedQueueDepth 7
68 #define BusLogic_TaggedQueueDepthBB 3
69 #define BusLogic_UntaggedQueueDepth 3
70 #define BusLogic_UntaggedQueueDepthBB 2
71 
72 
73 /*
74  Define the default amount of time in seconds to wait between a Host Adapter
75  Hard Reset which initiates a SCSI Bus Reset and issuing any SCSI commands.
76  Some SCSI devices get confused if they receive SCSI commands too soon after
77  a SCSI Bus Reset.
78 */
79 
80 #define BusLogic_DefaultBusSettleTime 2
81 
82 
83 /*
84  Define the maximum number of Mailboxes that should be used for MultiMaster
85  Host Adapters. This number is chosen to be larger than the maximum Host
86  Adapter Queue Depth and small enough so that the Host Adapter structure
87  does not cross an allocation block size boundary.
88 */
89 
90 #define BusLogic_MaxMailboxes 211
91 
92 
93 /*
94  Define the number of CCBs that should be allocated as a group to optimize
95  Kernel memory allocation.
96 */
97 
98 #define BusLogic_CCB_AllocationGroupSize 7
99 
100 
101 /*
102  Define the Host Adapter Line and Message Buffer Sizes.
103 */
104 
105 #define BusLogic_LineBufferSize 100
106 #define BusLogic_MessageBufferSize 9700
107 
108 
109 /*
110  Define the Driver Message Levels.
111 */
112 
119 };
120 
121 static char *BusLogic_MessageLevelMap[] = { KERN_NOTICE, KERN_NOTICE, KERN_NOTICE, KERN_WARNING, KERN_ERR };
122 
123 
124 /*
125  Define Driver Message macros.
126 */
127 
128 #define BusLogic_Announce(Format, Arguments...) \
129  BusLogic_Message(BusLogic_AnnounceLevel, Format, ##Arguments)
130 
131 #define BusLogic_Info(Format, Arguments...) \
132  BusLogic_Message(BusLogic_InfoLevel, Format, ##Arguments)
133 
134 #define BusLogic_Notice(Format, Arguments...) \
135  BusLogic_Message(BusLogic_NoticeLevel, Format, ##Arguments)
136 
137 #define BusLogic_Warning(Format, Arguments...) \
138  BusLogic_Message(BusLogic_WarningLevel, Format, ##Arguments)
139 
140 #define BusLogic_Error(Format, Arguments...) \
141  BusLogic_Message(BusLogic_ErrorLevel, Format, ##Arguments)
142 
143 
144 /*
145  Define the types of BusLogic Host Adapters that are supported and the number
146  of I/O Addresses required by each type.
147 */
148 
152 } PACKED;
153 
154 #define BusLogic_MultiMasterAddressCount 4
155 #define BusLogic_FlashPointAddressCount 256
156 
157 static int BusLogic_HostAdapterAddressCount[3] = { 0, BusLogic_MultiMasterAddressCount, BusLogic_FlashPointAddressCount };
158 
159 
160 /*
161  Define macros for testing the Host Adapter Type.
162 */
163 
164 #ifdef CONFIG_SCSI_FLASHPOINT
165 
166 #define BusLogic_MultiMasterHostAdapterP(HostAdapter) \
167  (HostAdapter->HostAdapterType == BusLogic_MultiMaster)
168 
169 #define BusLogic_FlashPointHostAdapterP(HostAdapter) \
170  (HostAdapter->HostAdapterType == BusLogic_FlashPoint)
171 
172 #else
173 
174 #define BusLogic_MultiMasterHostAdapterP(HostAdapter) \
175  (true)
176 
177 #define BusLogic_FlashPointHostAdapterP(HostAdapter) \
178  (false)
179 
180 #endif
181 
182 
183 /*
184  Define the possible Host Adapter Bus Types.
185 */
186 
194 } PACKED;
195 
196 static char *BusLogic_HostAdapterBusNames[] = { "Unknown", "ISA", "EISA", "PCI", "VESA", "MCA" };
197 
198 static enum BusLogic_HostAdapterBusType BusLogic_HostAdapterBusTypes[] = {
199  BusLogic_VESA_Bus, /* BT-4xx */
200  BusLogic_ISA_Bus, /* BT-5xx */
201  BusLogic_MCA_Bus, /* BT-6xx */
202  BusLogic_EISA_Bus, /* BT-7xx */
203  BusLogic_Unknown_Bus, /* BT-8xx */
204  BusLogic_PCI_Bus /* BT-9xx */
205 };
206 
207 /*
208  Define the possible Host Adapter BIOS Disk Geometry Translations.
209 */
210 
216 } PACKED;
217 
218 
219 /*
220  Define a 10^18 Statistics Byte Counter data type.
221 */
222 
224  unsigned int Units;
225  unsigned int Billions;
226 };
227 
228 
229 /*
230  Define the structure for I/O Address and Bus Probing Information.
231 */
232 
236  unsigned long IO_Address;
237  unsigned long PCI_Address;
239  unsigned char Bus;
240  unsigned char Device;
241  unsigned char IRQ_Channel;
242 };
243 
244 /*
245  Define the Probe Options.
246 */
247 
249  bool NoProbe:1; /* Bit 0 */
250  bool NoProbeISA:1; /* Bit 1 */
251  bool NoProbePCI:1; /* Bit 2 */
252  bool NoSortPCI:1; /* Bit 3 */
253  bool MultiMasterFirst:1;/* Bit 4 */
254  bool FlashPointFirst:1; /* Bit 5 */
255  bool LimitedProbeISA:1; /* Bit 6 */
256  bool Probe330:1; /* Bit 7 */
257  bool Probe334:1; /* Bit 8 */
258  bool Probe230:1; /* Bit 9 */
259  bool Probe234:1; /* Bit 10 */
260  bool Probe130:1; /* Bit 11 */
261  bool Probe134:1; /* Bit 12 */
262 };
263 
264 /*
265  Define the Global Options.
266 */
267 
269  bool TraceProbe:1; /* Bit 0 */
270  bool TraceHardwareReset:1; /* Bit 1 */
271  bool TraceConfiguration:1; /* Bit 2 */
272  bool TraceErrors:1; /* Bit 3 */
273 };
274 
275 /*
276  Define the Local Options.
277 */
278 
280  bool InhibitTargetInquiry:1; /* Bit 0 */
281 };
282 
283 /*
284  Define the BusLogic SCSI Host Adapter I/O Register Offsets.
285 */
286 
287 #define BusLogic_ControlRegisterOffset 0 /* WO register */
288 #define BusLogic_StatusRegisterOffset 0 /* RO register */
289 #define BusLogic_CommandParameterRegisterOffset 1 /* WO register */
290 #define BusLogic_DataInRegisterOffset 1 /* RO register */
291 #define BusLogic_InterruptRegisterOffset 2 /* RO register */
292 #define BusLogic_GeometryRegisterOffset 3 /* RO register */
293 
294 /*
295  Define the structure of the write-only Control Register.
296 */
297 
299  unsigned char All;
300  struct {
301  unsigned char:4; /* Bits 0-3 */
302  bool SCSIBusReset:1; /* Bit 4 */
303  bool InterruptReset:1; /* Bit 5 */
304  bool SoftReset:1; /* Bit 6 */
305  bool HardReset:1; /* Bit 7 */
306  } cr;
307 };
308 
309 /*
310  Define the structure of the read-only Status Register.
311 */
312 
314  unsigned char All;
315  struct {
316  bool CommandInvalid:1; /* Bit 0 */
317  bool Reserved:1; /* Bit 1 */
318  bool DataInRegisterReady:1; /* Bit 2 */
319  bool CommandParameterRegisterBusy:1; /* Bit 3 */
320  bool HostAdapterReady:1; /* Bit 4 */
321  bool InitializationRequired:1; /* Bit 5 */
322  bool DiagnosticFailure:1; /* Bit 6 */
323  bool DiagnosticActive:1; /* Bit 7 */
324  } sr;
325 };
326 
327 /*
328  Define the structure of the read-only Interrupt Register.
329 */
330 
332  unsigned char All;
333  struct {
334  bool IncomingMailboxLoaded:1; /* Bit 0 */
335  bool OutgoingMailboxAvailable:1;/* Bit 1 */
336  bool CommandComplete:1; /* Bit 2 */
337  bool ExternalBusReset:1; /* Bit 3 */
338  unsigned char Reserved:3; /* Bits 4-6 */
339  bool InterruptValid:1; /* Bit 7 */
340  } ir;
341 };
342 
343 /*
344  Define the structure of the read-only Geometry Register.
345 */
346 
348  unsigned char All;
349  struct {
350  enum BusLogic_BIOS_DiskGeometryTranslation Drive0Geometry:2; /* Bits 0-1 */
351  enum BusLogic_BIOS_DiskGeometryTranslation Drive1Geometry:2; /* Bits 2-3 */
352  unsigned char:3; /* Bits 4-6 */
353  bool ExtendedTranslationEnabled:1; /* Bit 7 */
354  } gr;
355 };
356 
357 /*
358  Define the BusLogic SCSI Host Adapter Command Register Operation Codes.
359 */
360 
406 };
407 
408 /*
409  Define the Inquire Board ID reply structure.
410 */
411 
413  unsigned char BoardType; /* Byte 0 */
414  unsigned char CustomFeatures; /* Byte 1 */
415  unsigned char FirmwareVersion1stDigit; /* Byte 2 */
416  unsigned char FirmwareVersion2ndDigit; /* Byte 3 */
417 };
418 
419 /*
420  Define the Inquire Configuration reply structure.
421 */
422 
424  unsigned char:5; /* Byte 0 Bits 0-4 */
425  bool DMA_Channel5:1; /* Byte 0 Bit 5 */
426  bool DMA_Channel6:1; /* Byte 0 Bit 6 */
427  bool DMA_Channel7:1; /* Byte 0 Bit 7 */
428  bool IRQ_Channel9:1; /* Byte 1 Bit 0 */
429  bool IRQ_Channel10:1; /* Byte 1 Bit 1 */
430  bool IRQ_Channel11:1; /* Byte 1 Bit 2 */
431  bool IRQ_Channel12:1; /* Byte 1 Bit 3 */
432  unsigned char:1; /* Byte 1 Bit 4 */
433  bool IRQ_Channel14:1; /* Byte 1 Bit 5 */
434  bool IRQ_Channel15:1; /* Byte 1 Bit 6 */
435  unsigned char:1; /* Byte 1 Bit 7 */
436  unsigned char HostAdapterID:4; /* Byte 2 Bits 0-3 */
437  unsigned char:4; /* Byte 2 Bits 4-7 */
438 };
439 
440 /*
441  Define the Inquire Setup Information reply structure.
442 */
443 
445  unsigned char Offset:4; /* Bits 0-3 */
446  unsigned char TransferPeriod:3; /* Bits 4-6 */
447  bool Synchronous:1; /* Bit 7 */
448 };
449 
451  bool SynchronousInitiationEnabled:1; /* Byte 0 Bit 0 */
452  bool ParityCheckingEnabled:1; /* Byte 0 Bit 1 */
453  unsigned char:6; /* Byte 0 Bits 2-7 */
454  unsigned char BusTransferRate; /* Byte 1 */
455  unsigned char PreemptTimeOnBus; /* Byte 2 */
456  unsigned char TimeOffBus; /* Byte 3 */
457  unsigned char MailboxCount; /* Byte 4 */
458  unsigned char MailboxAddress[3]; /* Bytes 5-7 */
460  unsigned char DisconnectPermittedID0to7; /* Byte 16 */
461  unsigned char Signature; /* Byte 17 */
462  unsigned char CharacterD; /* Byte 18 */
463  unsigned char HostBusType; /* Byte 19 */
464  unsigned char WideTransfersPermittedID0to7; /* Byte 20 */
465  unsigned char WideTransfersActiveID0to7; /* Byte 21 */
467  unsigned char DisconnectPermittedID8to15; /* Byte 30 */
468  unsigned char:8; /* Byte 31 */
469  unsigned char WideTransfersPermittedID8to15; /* Byte 32 */
470  unsigned char WideTransfersActiveID8to15; /* Byte 33 */
471 };
472 
473 /*
474  Define the Initialize Extended Mailbox request structure.
475 */
476 
478  unsigned char MailboxCount; /* Byte 0 */
479  u32 BaseMailboxAddress; /* Bytes 1-4 */
480 } PACKED;
481 
482 
483 /*
484  Define the Inquire PCI Host Adapter Information reply type. The ISA
485  Compatible I/O Port values are defined here and are also used with
486  the Modify I/O Address command.
487 */
488 
498 } PACKED;
499 
502  unsigned char PCIAssignedIRQChannel; /* Byte 1 */
503  bool LowByteTerminated:1; /* Byte 2 Bit 0 */
504  bool HighByteTerminated:1; /* Byte 2 Bit 1 */
505  unsigned char:2; /* Byte 2 Bits 2-3 */
506  bool JP1:1; /* Byte 2 Bit 4 */
507  bool JP2:1; /* Byte 2 Bit 5 */
508  bool JP3:1; /* Byte 2 Bit 6 */
509  bool GenericInfoValid:1;/* Byte 2 Bit 7 */
510  unsigned char:8; /* Byte 3 */
511 };
512 
513 /*
514  Define the Inquire Extended Setup Information reply structure.
515 */
516 
518  unsigned char BusType; /* Byte 0 */
519  unsigned char BIOS_Address; /* Byte 1 */
520  unsigned short ScatterGatherLimit; /* Bytes 2-3 */
521  unsigned char MailboxCount; /* Byte 4 */
522  u32 BaseMailboxAddress; /* Bytes 5-8 */
523  struct {
524  unsigned char:2; /* Byte 9 Bits 0-1 */
525  bool FastOnEISA:1; /* Byte 9 Bit 2 */
526  unsigned char:3; /* Byte 9 Bits 3-5 */
527  bool LevelSensitiveInterrupt:1; /* Byte 9 Bit 6 */
528  unsigned char:1; /* Byte 9 Bit 7 */
529  } Misc;
530  unsigned char FirmwareRevision[3]; /* Bytes 10-12 */
531  bool HostWideSCSI:1; /* Byte 13 Bit 0 */
532  bool HostDifferentialSCSI:1; /* Byte 13 Bit 1 */
533  bool HostSupportsSCAM:1; /* Byte 13 Bit 2 */
534  bool HostUltraSCSI:1; /* Byte 13 Bit 3 */
535  bool HostSmartTermination:1; /* Byte 13 Bit 4 */
536  unsigned char:3; /* Byte 13 Bits 5-7 */
537 } PACKED;
538 
539 /*
540  Define the Enable Strict Round Robin Mode request type.
541 */
542 
546 } PACKED;
547 
548 
549 /*
550  Define the Fetch Host Adapter Local RAM request type.
551 */
552 
553 #define BusLogic_BIOS_BaseOffset 0
554 #define BusLogic_AutoSCSI_BaseOffset 64
555 
557  unsigned char ByteOffset; /* Byte 0 */
558  unsigned char ByteCount; /* Byte 1 */
559 };
560 
561 /*
562  Define the Host Adapter Local RAM AutoSCSI structure.
563 */
564 
566  unsigned char InternalFactorySignature[2]; /* Bytes 0-1 */
567  unsigned char InformationByteCount; /* Byte 2 */
568  unsigned char HostAdapterType[6]; /* Bytes 3-8 */
569  unsigned char:8; /* Byte 9 */
570  bool FloppyEnabled:1; /* Byte 10 Bit 0 */
571  bool FloppySecondary:1; /* Byte 10 Bit 1 */
572  bool LevelSensitiveInterrupt:1; /* Byte 10 Bit 2 */
573  unsigned char:2; /* Byte 10 Bits 3-4 */
574  unsigned char SystemRAMAreaForBIOS:3; /* Byte 10 Bits 5-7 */
575  unsigned char DMA_Channel:7; /* Byte 11 Bits 0-6 */
576  bool DMA_AutoConfiguration:1; /* Byte 11 Bit 7 */
577  unsigned char IRQ_Channel:7; /* Byte 12 Bits 0-6 */
578  bool IRQ_AutoConfiguration:1; /* Byte 12 Bit 7 */
579  unsigned char DMA_TransferRate; /* Byte 13 */
580  unsigned char SCSI_ID; /* Byte 14 */
581  bool LowByteTerminated:1; /* Byte 15 Bit 0 */
582  bool ParityCheckingEnabled:1; /* Byte 15 Bit 1 */
583  bool HighByteTerminated:1; /* Byte 15 Bit 2 */
584  bool NoisyCablingEnvironment:1; /* Byte 15 Bit 3 */
585  bool FastSynchronousNegotiation:1; /* Byte 15 Bit 4 */
586  bool BusResetEnabled:1; /* Byte 15 Bit 5 */
587  bool:1; /* Byte 15 Bit 6 */
588  bool ActiveNegationEnabled:1; /* Byte 15 Bit 7 */
589  unsigned char BusOnDelay; /* Byte 16 */
590  unsigned char BusOffDelay; /* Byte 17 */
591  bool HostAdapterBIOSEnabled:1; /* Byte 18 Bit 0 */
592  bool BIOSRedirectionOfINT19Enabled:1; /* Byte 18 Bit 1 */
593  bool ExtendedTranslationEnabled:1; /* Byte 18 Bit 2 */
594  bool MapRemovableAsFixedEnabled:1; /* Byte 18 Bit 3 */
595  bool:1; /* Byte 18 Bit 4 */
596  bool BIOSSupportsMoreThan2DrivesEnabled:1; /* Byte 18 Bit 5 */
597  bool BIOSInterruptModeEnabled:1; /* Byte 18 Bit 6 */
598  bool FlopticalSupportEnabled:1; /* Byte 19 Bit 7 */
599  unsigned short DeviceEnabled; /* Bytes 19-20 */
600  unsigned short WidePermitted; /* Bytes 21-22 */
601  unsigned short FastPermitted; /* Bytes 23-24 */
602  unsigned short SynchronousPermitted; /* Bytes 25-26 */
603  unsigned short DisconnectPermitted; /* Bytes 27-28 */
604  unsigned short SendStartUnitCommand; /* Bytes 29-30 */
605  unsigned short IgnoreInBIOSScan; /* Bytes 31-32 */
606  unsigned char PCIInterruptPin:2; /* Byte 33 Bits 0-1 */
607  unsigned char HostAdapterIOPortAddress:2; /* Byte 33 Bits 2-3 */
608  bool StrictRoundRobinModeEnabled:1; /* Byte 33 Bit 4 */
609  bool VESABusSpeedGreaterThan33MHz:1; /* Byte 33 Bit 5 */
610  bool VESABurstWriteEnabled:1; /* Byte 33 Bit 6 */
611  bool VESABurstReadEnabled:1; /* Byte 33 Bit 7 */
612  unsigned short UltraPermitted; /* Bytes 34-35 */
613  unsigned int:32; /* Bytes 36-39 */
614  unsigned char:8; /* Byte 40 */
615  unsigned char AutoSCSIMaximumLUN; /* Byte 41 */
616  bool:1; /* Byte 42 Bit 0 */
617  bool SCAM_Dominant:1; /* Byte 42 Bit 1 */
618  bool SCAM_Enabled:1; /* Byte 42 Bit 2 */
619  bool SCAM_Level2:1; /* Byte 42 Bit 3 */
620  unsigned char:4; /* Byte 42 Bits 4-7 */
621  bool INT13ExtensionEnabled:1; /* Byte 43 Bit 0 */
622  bool:1; /* Byte 43 Bit 1 */
623  bool CDROMBootEnabled:1; /* Byte 43 Bit 2 */
624  unsigned char:5; /* Byte 43 Bits 3-7 */
625  unsigned char BootTargetID:4; /* Byte 44 Bits 0-3 */
626  unsigned char BootChannel:4; /* Byte 44 Bits 4-7 */
627  unsigned char ForceBusDeviceScanningOrder:1; /* Byte 45 Bit 0 */
628  unsigned char:7; /* Byte 45 Bits 1-7 */
629  unsigned short NonTaggedToAlternateLUNPermitted; /* Bytes 46-47 */
630  unsigned short RenegotiateSyncAfterCheckCondition; /* Bytes 48-49 */
631  unsigned char Reserved[10]; /* Bytes 50-59 */
632  unsigned char ManufacturingDiagnostic[2]; /* Bytes 60-61 */
633  unsigned short Checksum; /* Bytes 62-63 */
634 } PACKED;
635 
636 /*
637  Define the Host Adapter Local RAM Auto SCSI Byte 45 structure.
638 */
639 
641  unsigned char ForceBusDeviceScanningOrder:1; /* Bit 0 */
642  unsigned char:7; /* Bits 1-7 */
643 };
644 
645 /*
646  Define the Host Adapter Local RAM BIOS Drive Map Byte structure.
647 */
648 
649 #define BusLogic_BIOS_DriveMapOffset 17
650 
652  unsigned char TargetIDBit3:1; /* Bit 0 */
653  unsigned char:2; /* Bits 1-2 */
654  enum BusLogic_BIOS_DiskGeometryTranslation DiskGeometry:2; /* Bits 3-4 */
655  unsigned char TargetID:3; /* Bits 5-7 */
656 };
657 
658 /*
659  Define the Set CCB Format request type. Extended LUN Format CCBs are
660  necessary to support more than 8 Logical Units per Target Device.
661 */
662 
666 } PACKED;
667 
668 /*
669  Define the Outgoing Mailbox Action Codes.
670 */
671 
676 } PACKED;
677 
678 
679 /*
680  Define the Incoming Mailbox Completion Codes. The MultiMaster Firmware
681  only uses codes 0 - 4. The FlashPoint SCCB Manager has no mailboxes, so
682  completion codes are stored in the CCB; it only uses codes 1, 2, 4, and 5.
683 */
684 
692 } PACKED;
693 
694 /*
695  Define the Command Control Block (CCB) Opcodes.
696 */
697 
705 } PACKED;
706 
707 
708 /*
709  Define the CCB Data Direction Codes.
710 */
711 
717 };
718 
719 
720 /*
721  Define the Host Adapter Status Codes. The MultiMaster Firmware does not
722  return status code 0x0C; it uses 0x12 for both overruns and underruns.
723 */
724 
751 } PACKED;
752 
753 
754 /*
755  Define the SCSI Target Device Status Codes.
756 */
757 
762 } PACKED;
763 
764 /*
765  Define the Queue Tag Codes.
766 */
767 
773 };
774 
775 /*
776  Define the SCSI Command Descriptor Block (CDB).
777 */
778 
779 #define BusLogic_CDB_MaxLength 12
780 
781 typedef unsigned char SCSI_CDB_T[BusLogic_CDB_MaxLength];
782 
783 
784 /*
785  Define the Scatter/Gather Segment structure required by the MultiMaster
786  Firmware Interface and the FlashPoint SCCB Manager.
787 */
788 
790  u32 SegmentByteCount; /* Bytes 0-3 */
791  u32 SegmentDataPointer; /* Bytes 4-7 */
792 };
793 
794 /*
795  Define the Driver CCB Status Codes.
796 */
797 
803 } PACKED;
804 
805 
806 /*
807  Define the 32 Bit Mode Command Control Block (CCB) structure. The first 40
808  bytes are defined by and common to both the MultiMaster Firmware and the
809  FlashPoint SCCB Manager. The next 60 bytes are defined by the FlashPoint
810  SCCB Manager. The remaining components are defined by the Linux BusLogic
811  Driver. Extended LUN Format CCBs differ from Legacy LUN Format 32 Bit Mode
812  CCBs only in having the TagEnable and QueueTag fields moved from byte 17 to
813  byte 1, and the Logical Unit field in byte 17 expanded to 6 bits. In theory,
814  Extended LUN Format CCBs can support up to 64 Logical Units, but in practice
815  many devices will respond improperly to Logical Units between 32 and 63, and
816  the SCSI-2 specification defines Bit 5 as LUNTAR. Extended LUN Format CCBs
817  are used by recent versions of the MultiMaster Firmware, as well as by the
818  FlashPoint SCCB Manager; the FlashPoint SCCB Manager only supports 32 Logical
819  Units. Since 64 Logical Units are unlikely to be needed in practice, and
820  since they are problematic for the above reasons, and since limiting them to
821  5 bits simplifies the CCB structure definition, this driver only supports
822  32 Logical Units per Target Device.
823 */
824 
825 struct BusLogic_CCB {
826  /*
827  MultiMaster Firmware and FlashPoint SCCB Manager Common Portion.
828  */
829  enum BusLogic_CCB_Opcode Opcode; /* Byte 0 */
830  unsigned char:3; /* Byte 1 Bits 0-2 */
831  enum BusLogic_DataDirection DataDirection:2; /* Byte 1 Bits 3-4 */
832  bool TagEnable:1; /* Byte 1 Bit 5 */
833  enum BusLogic_QueueTag QueueTag:2; /* Byte 1 Bits 6-7 */
834  unsigned char CDB_Length; /* Byte 2 */
835  unsigned char SenseDataLength; /* Byte 3 */
836  u32 DataLength; /* Bytes 4-7 */
837  u32 DataPointer; /* Bytes 8-11 */
838  unsigned char:8; /* Byte 12 */
839  unsigned char:8; /* Byte 13 */
842  unsigned char TargetID; /* Byte 16 */
843  unsigned char LogicalUnit:5; /* Byte 17 Bits 0-4 */
844  bool LegacyTagEnable:1; /* Byte 17 Bit 5 */
845  enum BusLogic_QueueTag LegacyQueueTag:2; /* Byte 17 Bits 6-7 */
846  SCSI_CDB_T CDB; /* Bytes 18-29 */
847  unsigned char:8; /* Byte 30 */
848  unsigned char:8; /* Byte 31 */
849  unsigned int:32; /* Bytes 32-35 */
850  u32 SenseDataPointer; /* Bytes 36-39 */
851  /*
852  FlashPoint SCCB Manager Defined Portion.
853  */
854  void (*CallbackFunction) (struct BusLogic_CCB *); /* Bytes 40-43 */
855  u32 BaseAddress; /* Bytes 44-47 */
857 #ifdef CONFIG_SCSI_FLASHPOINT
858  unsigned char:8; /* Byte 49 */
859  unsigned short OS_Flags; /* Bytes 50-51 */
860  unsigned char Private[48]; /* Bytes 52-99 */
861 #endif
862  /*
863  BusLogic Linux Driver Defined Portion.
864  */
866  unsigned int AllocationGroupSize;
869  unsigned long SerialNumber;
876 };
877 
878 /*
879  Define the 32 Bit Mode Outgoing Mailbox structure.
880 */
881 
883  u32 CCB; /* Bytes 0-3 */
884  unsigned int:24; /* Bytes 4-6 */
885  enum BusLogic_ActionCode ActionCode; /* Byte 7 */
886 };
887 
888 /*
889  Define the 32 Bit Mode Incoming Mailbox structure.
890 */
891 
893  u32 CCB; /* Bytes 0-3 */
896  unsigned char:8; /* Byte 6 */
898 };
899 
900 
901 /*
902  Define the BusLogic Driver Options structure.
903 */
904 
906  unsigned short TaggedQueuingPermitted;
908  unsigned short BusSettleTime;
910  unsigned char CommonQueueDepth;
912 };
913 
914 /*
915  Define the Host Adapter Target Flags structure.
916 */
917 
919  bool TargetExists:1;
926 };
927 
928 /*
929  Define the Host Adapter Target Statistics structure.
930 */
931 
932 #define BusLogic_SizeBuckets 10
933 
935 
937  unsigned int CommandsAttempted;
938  unsigned int CommandsCompleted;
939  unsigned int ReadCommands;
940  unsigned int WriteCommands;
945  unsigned short CommandAbortsRequested;
946  unsigned short CommandAbortsAttempted;
947  unsigned short CommandAbortsCompleted;
948  unsigned short BusDeviceResetsRequested;
949  unsigned short BusDeviceResetsAttempted;
950  unsigned short BusDeviceResetsCompleted;
954 };
955 
956 /*
957  Define the FlashPoint Card Handle data type.
958 */
959 
960 #define FlashPoint_BadCardHandle 0xFFFFFFFF
961 
962 typedef unsigned int FlashPoint_CardHandle_T;
963 
964 
965 /*
966  Define the FlashPoint Information structure. This structure is defined
967  by the FlashPoint SCCB Manager.
968 */
969 
971  u32 BaseAddress; /* Bytes 0-3 */
972  bool Present; /* Byte 4 */
973  unsigned char IRQ_Channel; /* Byte 5 */
974  unsigned char SCSI_ID; /* Byte 6 */
975  unsigned char SCSI_LUN; /* Byte 7 */
976  unsigned short FirmwareRevision; /* Bytes 8-9 */
977  unsigned short SynchronousPermitted; /* Bytes 10-11 */
978  unsigned short FastPermitted; /* Bytes 12-13 */
979  unsigned short UltraPermitted; /* Bytes 14-15 */
980  unsigned short DisconnectPermitted; /* Bytes 16-17 */
981  unsigned short WidePermitted; /* Bytes 18-19 */
982  bool ParityCheckingEnabled:1; /* Byte 20 Bit 0 */
983  bool HostWideSCSI:1; /* Byte 20 Bit 1 */
984  bool HostSoftReset:1; /* Byte 20 Bit 2 */
985  bool ExtendedTranslationEnabled:1; /* Byte 20 Bit 3 */
986  bool LowByteTerminated:1; /* Byte 20 Bit 4 */
987  bool HighByteTerminated:1; /* Byte 20 Bit 5 */
988  bool ReportDataUnderrun:1; /* Byte 20 Bit 6 */
989  bool SCAM_Enabled:1; /* Byte 20 Bit 7 */
990  bool SCAM_Level2:1; /* Byte 21 Bit 0 */
991  unsigned char:7; /* Byte 21 Bits 1-7 */
992  unsigned char Family; /* Byte 22 */
993  unsigned char BusType; /* Byte 23 */
994  unsigned char ModelNumber[3]; /* Bytes 24-26 */
995  unsigned char RelativeCardNumber; /* Byte 27 */
996  unsigned char Reserved[4]; /* Bytes 28-31 */
997  unsigned int OS_Reserved; /* Bytes 32-35 */
998  unsigned char TranslationInfo[4]; /* Bytes 36-39 */
999  unsigned int Reserved2[5]; /* Bytes 40-59 */
1000  unsigned int SecondaryRange; /* Bytes 60-63 */
1001 };
1002 
1003 /*
1004  Define the BusLogic Driver Host Adapter structure.
1005 */
1006 
1012  unsigned long IO_Address;
1013  unsigned long PCI_Address;
1014  unsigned short AddressCount;
1015  unsigned char HostNumber;
1016  unsigned char ModelName[9];
1017  unsigned char FirmwareVersion[6];
1018  unsigned char FullModelName[18];
1019  unsigned char Bus;
1020  unsigned char Device;
1021  unsigned char IRQ_Channel;
1022  unsigned char DMA_Channel;
1023  unsigned char SCSI_ID;
1041  bool SCAM_Level2:1;
1049  unsigned short MaxTargetDevices;
1050  unsigned short MaxLogicalUnits;
1051  unsigned short MailboxCount;
1052  unsigned short InitialCCBs;
1053  unsigned short IncrementalCCBs;
1054  unsigned short AllocatedCCBs;
1055  unsigned short DriverQueueDepth;
1056  unsigned short HostAdapterQueueDepth;
1057  unsigned short UntaggedQueueDepth;
1058  unsigned short CommonQueueDepth;
1059  unsigned short BusSettleTime;
1060  unsigned short SynchronousPermitted;
1061  unsigned short FastPermitted;
1062  unsigned short UltraPermitted;
1063  unsigned short WidePermitted;
1064  unsigned short DisconnectPermitted;
1065  unsigned short TaggedQueuingPermitted;
1068  unsigned short TargetDeviceCount;
1069  unsigned short MessageBufferLength;
1096  unsigned char *MailboxSpace;
1098  unsigned int MailboxSize;
1099  unsigned long CCB_Offset;
1101 };
1102 
1103 /*
1104  Define a structure for the BIOS Disk Parameters.
1105 */
1106 
1108  int Heads;
1109  int Sectors;
1111 };
1112 
1113 /*
1114  Define a structure for the SCSI Inquiry command results.
1115 */
1116 
1118  unsigned char PeripheralDeviceType:5; /* Byte 0 Bits 0-4 */
1119  unsigned char PeripheralQualifier:3; /* Byte 0 Bits 5-7 */
1120  unsigned char DeviceTypeModifier:7; /* Byte 1 Bits 0-6 */
1121  bool RMB:1; /* Byte 1 Bit 7 */
1122  unsigned char ANSI_ApprovedVersion:3; /* Byte 2 Bits 0-2 */
1123  unsigned char ECMA_Version:3; /* Byte 2 Bits 3-5 */
1124  unsigned char ISO_Version:2; /* Byte 2 Bits 6-7 */
1125  unsigned char ResponseDataFormat:4; /* Byte 3 Bits 0-3 */
1126  unsigned char:2; /* Byte 3 Bits 4-5 */
1127  bool TrmIOP:1; /* Byte 3 Bit 6 */
1128  bool AENC:1; /* Byte 3 Bit 7 */
1129  unsigned char AdditionalLength; /* Byte 4 */
1130  unsigned char:8; /* Byte 5 */
1131  unsigned char:8; /* Byte 6 */
1132  bool SftRe:1; /* Byte 7 Bit 0 */
1133  bool CmdQue:1; /* Byte 7 Bit 1 */
1134  bool:1; /* Byte 7 Bit 2 */
1135  bool Linked:1; /* Byte 7 Bit 3 */
1136  bool Sync:1; /* Byte 7 Bit 4 */
1137  bool WBus16:1; /* Byte 7 Bit 5 */
1138  bool WBus32:1; /* Byte 7 Bit 6 */
1139  bool RelAdr:1; /* Byte 7 Bit 7 */
1140  unsigned char VendorIdentification[8]; /* Bytes 8-15 */
1141  unsigned char ProductIdentification[16]; /* Bytes 16-31 */
1142  unsigned char ProductRevisionLevel[4]; /* Bytes 32-35 */
1143 };
1144 
1145 
1146 /*
1147  Define functions to provide an abstraction for reading and writing the
1148  Host Adapter I/O Registers.
1149 */
1150 
1151 static inline void BusLogic_SCSIBusReset(struct BusLogic_HostAdapter *HostAdapter)
1152 {
1153  union BusLogic_ControlRegister ControlRegister;
1154  ControlRegister.All = 0;
1155  ControlRegister.cr.SCSIBusReset = true;
1156  outb(ControlRegister.All, HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
1157 }
1158 
1159 static inline void BusLogic_InterruptReset(struct BusLogic_HostAdapter *HostAdapter)
1160 {
1161  union BusLogic_ControlRegister ControlRegister;
1162  ControlRegister.All = 0;
1163  ControlRegister.cr.InterruptReset = true;
1164  outb(ControlRegister.All, HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
1165 }
1166 
1167 static inline void BusLogic_SoftReset(struct BusLogic_HostAdapter *HostAdapter)
1168 {
1169  union BusLogic_ControlRegister ControlRegister;
1170  ControlRegister.All = 0;
1171  ControlRegister.cr.SoftReset = true;
1172  outb(ControlRegister.All, HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
1173 }
1174 
1175 static inline void BusLogic_HardReset(struct BusLogic_HostAdapter *HostAdapter)
1176 {
1177  union BusLogic_ControlRegister ControlRegister;
1178  ControlRegister.All = 0;
1179  ControlRegister.cr.HardReset = true;
1180  outb(ControlRegister.All, HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
1181 }
1182 
1183 static inline unsigned char BusLogic_ReadStatusRegister(struct BusLogic_HostAdapter *HostAdapter)
1184 {
1185  return inb(HostAdapter->IO_Address + BusLogic_StatusRegisterOffset);
1186 }
1187 
1188 static inline void BusLogic_WriteCommandParameterRegister(struct BusLogic_HostAdapter
1189  *HostAdapter, unsigned char Value)
1190 {
1192 }
1193 
1194 static inline unsigned char BusLogic_ReadDataInRegister(struct BusLogic_HostAdapter *HostAdapter)
1195 {
1196  return inb(HostAdapter->IO_Address + BusLogic_DataInRegisterOffset);
1197 }
1198 
1199 static inline unsigned char BusLogic_ReadInterruptRegister(struct BusLogic_HostAdapter *HostAdapter)
1200 {
1201  return inb(HostAdapter->IO_Address + BusLogic_InterruptRegisterOffset);
1202 }
1203 
1204 static inline unsigned char BusLogic_ReadGeometryRegister(struct BusLogic_HostAdapter *HostAdapter)
1205 {
1206  return inb(HostAdapter->IO_Address + BusLogic_GeometryRegisterOffset);
1207 }
1208 
1209 /*
1210  BusLogic_StartMailboxCommand issues an Execute Mailbox Command, which
1211  notifies the Host Adapter that an entry has been made in an Outgoing
1212  Mailbox.
1213 */
1214 
1215 static inline void BusLogic_StartMailboxCommand(struct BusLogic_HostAdapter *HostAdapter)
1216 {
1217  BusLogic_WriteCommandParameterRegister(HostAdapter, BusLogic_ExecuteMailboxCommand);
1218 }
1219 
1220 /*
1221  BusLogic_Delay waits for Seconds to elapse.
1222 */
1223 
1224 static inline void BusLogic_Delay(int Seconds)
1225 {
1226  mdelay(1000 * Seconds);
1227 }
1228 
1229 /*
1230  Virtual_to_Bus and Bus_to_Virtual map between Kernel Virtual Addresses
1231  and PCI/VLB/EISA/ISA Bus Addresses.
1232 */
1233 
1234 static inline u32 Virtual_to_Bus(void *VirtualAddress)
1235 {
1236  return (u32) virt_to_bus(VirtualAddress);
1237 }
1238 
1239 static inline void *Bus_to_Virtual(u32 BusAddress)
1240 {
1241  return (void *) bus_to_virt(BusAddress);
1242 }
1243 
1244 /*
1245  Virtual_to_32Bit_Virtual maps between Kernel Virtual Addresses and
1246  32 bit Kernel Virtual Addresses. This avoids compilation warnings
1247  on 64 bit architectures.
1248 */
1249 
1250 static inline u32 Virtual_to_32Bit_Virtual(void *VirtualAddress)
1251 {
1252  return (u32) (unsigned long) VirtualAddress;
1253 }
1254 
1255 /*
1256  BusLogic_IncrementErrorCounter increments Error Counter by 1, stopping at
1257  65535 rather than wrapping around to 0.
1258 */
1259 
1260 static inline void BusLogic_IncrementErrorCounter(unsigned short *ErrorCounter)
1261 {
1262  if (*ErrorCounter < 65535)
1263  (*ErrorCounter)++;
1264 }
1265 
1266 /*
1267  BusLogic_IncrementByteCounter increments Byte Counter by Amount.
1268 */
1269 
1270 static inline void BusLogic_IncrementByteCounter(struct BusLogic_ByteCounter
1271  *ByteCounter, unsigned int Amount)
1272 {
1273  ByteCounter->Units += Amount;
1274  if (ByteCounter->Units > 999999999) {
1275  ByteCounter->Units -= 1000000000;
1276  ByteCounter->Billions++;
1277  }
1278 }
1279 
1280 /*
1281  BusLogic_IncrementSizeBucket increments the Bucket for Amount.
1282 */
1283 
1284 static inline void BusLogic_IncrementSizeBucket(BusLogic_CommandSizeBuckets_T CommandSizeBuckets, unsigned int Amount)
1285 {
1286  int Index = 0;
1287  if (Amount < 8 * 1024) {
1288  if (Amount < 2 * 1024)
1289  Index = (Amount < 1 * 1024 ? 0 : 1);
1290  else
1291  Index = (Amount < 4 * 1024 ? 2 : 3);
1292  } else if (Amount < 128 * 1024) {
1293  if (Amount < 32 * 1024)
1294  Index = (Amount < 16 * 1024 ? 4 : 5);
1295  else
1296  Index = (Amount < 64 * 1024 ? 6 : 7);
1297  } else
1298  Index = (Amount < 256 * 1024 ? 8 : 9);
1299  CommandSizeBuckets[Index]++;
1300 }
1301 
1302 /*
1303  Define the version number of the FlashPoint Firmware (SCCB Manager).
1304 */
1305 
1306 #define FlashPoint_FirmwareVersion "5.02"
1307 
1308 /*
1309  Define the possible return values from FlashPoint_HandleInterrupt.
1310 */
1311 
1312 #define FlashPoint_NormalInterrupt 0x00
1313 #define FlashPoint_InternalError 0xFE
1314 #define FlashPoint_ExternalBusReset 0xFF
1315 
1316 /*
1317  Define prototypes for the forward referenced BusLogic Driver
1318  Internal Functions.
1319 */
1320 
1321 static const char *BusLogic_DriverInfo(struct Scsi_Host *);
1322 static int BusLogic_QueueCommand(struct Scsi_Host *h, struct scsi_cmnd *);
1323 static int BusLogic_BIOSDiskParameters(struct scsi_device *, struct block_device *, sector_t, int *);
1324 static int BusLogic_ProcDirectoryInfo(struct Scsi_Host *, char *, char **, off_t, int, int);
1325 static int BusLogic_SlaveConfigure(struct scsi_device *);
1326 static void BusLogic_QueueCompletedCCB(struct BusLogic_CCB *);
1327 static irqreturn_t BusLogic_InterruptHandler(int, void *);
1328 static int BusLogic_ResetHostAdapter(struct BusLogic_HostAdapter *, bool HardReset);
1329 static void BusLogic_Message(enum BusLogic_MessageLevel, char *, struct BusLogic_HostAdapter *, ...);
1330 static int __init BusLogic_Setup(char *);
1331 
1332 #endif /* _BUSLOGIC_H */