1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
38
39
40
41#ifndef __i386__
42#undef CONFIG_SCSI_OMIT_FLASHPOINT
43#define CONFIG_SCSI_OMIT_FLASHPOINT
44#endif
45
46#ifndef CONFIG_PCI
47#undef CONFIG_SCSI_OMIT_FLASHPOINT
48#define CONFIG_SCSI_OMIT_FLASHPOINT
49#define BusLogic_InitializeProbeInfoListISA BusLogic_InitializeProbeInfoList
50#endif
51
52
53
54
55
56
57#define BusLogic_MaxHostAdapters 16
58
59
60
61
62
63
64#define BusLogic_MaxTargetDevices 16
65
66
67
68
69
70
71
72
73#define BusLogic_ScatterGatherLimit 128
74
75
76
77
78
79
80
81
82#define BusLogic_MaxTaggedQueueDepth 64
83#define BusLogic_MaxAutomaticTaggedQueueDepth 28
84#define BusLogic_MinAutomaticTaggedQueueDepth 7
85#define BusLogic_TaggedQueueDepthBB 3
86#define BusLogic_UntaggedQueueDepth 3
87#define BusLogic_UntaggedQueueDepthBB 2
88
89
90
91
92
93
94
95
96
97#define BusLogic_DefaultBusSettleTime 2
98
99
100
101
102
103
104
105
106
107#define BusLogic_MaxMailboxes 211
108
109
110
111
112
113
114
115#define BusLogic_CCB_AllocationGroupSize 7
116
117
118
119
120
121
122#define BusLogic_LineBufferSize 100
123#define BusLogic_MessageBufferSize 9700
124
125
126
127
128
129
130enum BusLogic_MessageLevel {
131 BusLogic_AnnounceLevel = 0,
132 BusLogic_InfoLevel = 1,
133 BusLogic_NoticeLevel = 2,
134 BusLogic_WarningLevel = 3,
135 BusLogic_ErrorLevel = 4
136};
137
138static char *BusLogic_MessageLevelMap[] = { KERN_NOTICE, KERN_NOTICE, KERN_NOTICE, KERN_WARNING, KERN_ERR };
139
140
141
142
143
144
145#define BusLogic_Announce(Format, Arguments...) \
146 BusLogic_Message(BusLogic_AnnounceLevel, Format, ##Arguments)
147
148#define BusLogic_Info(Format, Arguments...) \
149 BusLogic_Message(BusLogic_InfoLevel, Format, ##Arguments)
150
151#define BusLogic_Notice(Format, Arguments...) \
152 BusLogic_Message(BusLogic_NoticeLevel, Format, ##Arguments)
153
154#define BusLogic_Warning(Format, Arguments...) \
155 BusLogic_Message(BusLogic_WarningLevel, Format, ##Arguments)
156
157#define BusLogic_Error(Format, Arguments...) \
158 BusLogic_Message(BusLogic_ErrorLevel, Format, ##Arguments)
159
160
161
162
163
164
165
166enum BusLogic_HostAdapterType {
167 BusLogic_MultiMaster = 1,
168 BusLogic_FlashPoint = 2
169} PACKED;
170
171#define BusLogic_MultiMasterAddressCount 4
172#define BusLogic_FlashPointAddressCount 256
173
174static int BusLogic_HostAdapterAddressCount[3] = { 0, BusLogic_MultiMasterAddressCount, BusLogic_FlashPointAddressCount };
175
176
177
178
179
180
181#ifndef CONFIG_SCSI_OMIT_FLASHPOINT
182
183#define BusLogic_MultiMasterHostAdapterP(HostAdapter) \
184 (HostAdapter->HostAdapterType == BusLogic_MultiMaster)
185
186#define BusLogic_FlashPointHostAdapterP(HostAdapter) \
187 (HostAdapter->HostAdapterType == BusLogic_FlashPoint)
188
189#else
190
191#define BusLogic_MultiMasterHostAdapterP(HostAdapter) \
192 (true)
193
194#define BusLogic_FlashPointHostAdapterP(HostAdapter) \
195 (false)
196
197#endif
198
199
200
201
202
203
204enum BusLogic_HostAdapterBusType {
205 BusLogic_Unknown_Bus = 0,
206 BusLogic_ISA_Bus = 1,
207 BusLogic_EISA_Bus = 2,
208 BusLogic_PCI_Bus = 3,
209 BusLogic_VESA_Bus = 4,
210 BusLogic_MCA_Bus = 5
211} PACKED;
212
213static char *BusLogic_HostAdapterBusNames[] = { "Unknown", "ISA", "EISA", "PCI", "VESA", "MCA" };
214
215static enum BusLogic_HostAdapterBusType BusLogic_HostAdapterBusTypes[] = {
216 BusLogic_VESA_Bus,
217 BusLogic_ISA_Bus,
218 BusLogic_MCA_Bus,
219 BusLogic_EISA_Bus,
220 BusLogic_Unknown_Bus,
221 BusLogic_PCI_Bus
222};
223
224
225
226
227
228enum BusLogic_BIOS_DiskGeometryTranslation {
229 BusLogic_BIOS_Disk_Not_Installed = 0,
230 BusLogic_BIOS_Disk_Installed_64x32 = 1,
231 BusLogic_BIOS_Disk_Installed_128x32 = 2,
232 BusLogic_BIOS_Disk_Installed_255x63 = 3
233} PACKED;
234
235
236
237
238
239
240struct BusLogic_ByteCounter {
241 unsigned int Units;
242 unsigned int Billions;
243};
244
245
246
247
248
249
250struct BusLogic_ProbeInfo {
251 enum BusLogic_HostAdapterType HostAdapterType;
252 enum BusLogic_HostAdapterBusType HostAdapterBusType;
253 unsigned long IO_Address;
254 unsigned long PCI_Address;
255 struct pci_dev *PCI_Device;
256 unsigned char Bus;
257 unsigned char Device;
258 unsigned char IRQ_Channel;
259};
260
261
262
263
264
265struct BusLogic_ProbeOptions {
266 bool NoProbe:1;
267 bool NoProbeISA:1;
268 bool NoProbePCI:1;
269 bool NoSortPCI:1;
270 bool MultiMasterFirst:1;
271 bool FlashPointFirst:1;
272 bool LimitedProbeISA:1;
273 bool Probe330:1;
274 bool Probe334:1;
275 bool Probe230:1;
276 bool Probe234:1;
277 bool Probe130:1;
278 bool Probe134:1;
279};
280
281
282
283
284
285struct BusLogic_GlobalOptions {
286 bool TraceProbe:1;
287 bool TraceHardwareReset:1;
288 bool TraceConfiguration:1;
289 bool TraceErrors:1;
290};
291
292
293
294
295
296struct BusLogic_LocalOptions {
297 bool InhibitTargetInquiry:1;
298};
299
300
301
302
303
304#define BusLogic_ControlRegisterOffset 0
305#define BusLogic_StatusRegisterOffset 0
306#define BusLogic_CommandParameterRegisterOffset 1
307#define BusLogic_DataInRegisterOffset 1
308#define BusLogic_InterruptRegisterOffset 2
309#define BusLogic_GeometryRegisterOffset 3
310
311
312
313
314
315union BusLogic_ControlRegister {
316 unsigned char All;
317 struct {
318 unsigned char:4;
319 bool SCSIBusReset:1;
320 bool InterruptReset:1;
321 bool SoftReset:1;
322 bool HardReset:1;
323 } cr;
324};
325
326
327
328
329
330union BusLogic_StatusRegister {
331 unsigned char All;
332 struct {
333 bool CommandInvalid:1;
334 bool Reserved:1;
335 bool DataInRegisterReady:1;
336 bool CommandParameterRegisterBusy:1;
337 bool HostAdapterReady:1;
338 bool InitializationRequired:1;
339 bool DiagnosticFailure:1;
340 bool DiagnosticActive:1;
341 } sr;
342};
343
344
345
346
347
348union BusLogic_InterruptRegister {
349 unsigned char All;
350 struct {
351 bool IncomingMailboxLoaded:1;
352 bool OutgoingMailboxAvailable:1;
353 bool CommandComplete:1;
354 bool ExternalBusReset:1;
355 unsigned char Reserved:3;
356 bool InterruptValid:1;
357 } ir;
358};
359
360
361
362
363
364union BusLogic_GeometryRegister {
365 unsigned char All;
366 struct {
367 enum BusLogic_BIOS_DiskGeometryTranslation Drive0Geometry:2;
368 enum BusLogic_BIOS_DiskGeometryTranslation Drive1Geometry:2;
369 unsigned char:3;
370 bool ExtendedTranslationEnabled:1;
371 } gr;
372};
373
374
375
376
377
378enum BusLogic_OperationCode {
379 BusLogic_TestCommandCompleteInterrupt = 0x00,
380 BusLogic_InitializeMailbox = 0x01,
381 BusLogic_ExecuteMailboxCommand = 0x02,
382 BusLogic_ExecuteBIOSCommand = 0x03,
383 BusLogic_InquireBoardID = 0x04,
384 BusLogic_EnableOutgoingMailboxAvailableInt = 0x05,
385 BusLogic_SetSCSISelectionTimeout = 0x06,
386 BusLogic_SetPreemptTimeOnBus = 0x07,
387 BusLogic_SetTimeOffBus = 0x08,
388 BusLogic_SetBusTransferRate = 0x09,
389 BusLogic_InquireInstalledDevicesID0to7 = 0x0A,
390 BusLogic_InquireConfiguration = 0x0B,
391 BusLogic_EnableTargetMode = 0x0C,
392 BusLogic_InquireSetupInformation = 0x0D,
393 BusLogic_WriteAdapterLocalRAM = 0x1A,
394 BusLogic_ReadAdapterLocalRAM = 0x1B,
395 BusLogic_WriteBusMasterChipFIFO = 0x1C,
396 BusLogic_ReadBusMasterChipFIFO = 0x1D,
397 BusLogic_EchoCommandData = 0x1F,
398 BusLogic_HostAdapterDiagnostic = 0x20,
399 BusLogic_SetAdapterOptions = 0x21,
400 BusLogic_InquireInstalledDevicesID8to15 = 0x23,
401 BusLogic_InquireTargetDevices = 0x24,
402 BusLogic_DisableHostAdapterInterrupt = 0x25,
403 BusLogic_InitializeExtendedMailbox = 0x81,
404 BusLogic_ExecuteSCSICommand = 0x83,
405 BusLogic_InquireFirmwareVersion3rdDigit = 0x84,
406 BusLogic_InquireFirmwareVersionLetter = 0x85,
407 BusLogic_InquirePCIHostAdapterInformation = 0x86,
408 BusLogic_InquireHostAdapterModelNumber = 0x8B,
409 BusLogic_InquireSynchronousPeriod = 0x8C,
410 BusLogic_InquireExtendedSetupInformation = 0x8D,
411 BusLogic_EnableStrictRoundRobinMode = 0x8F,
412 BusLogic_StoreHostAdapterLocalRAM = 0x90,
413 BusLogic_FetchHostAdapterLocalRAM = 0x91,
414 BusLogic_StoreLocalDataInEEPROM = 0x92,
415 BusLogic_UploadAutoSCSICode = 0x94,
416 BusLogic_ModifyIOAddress = 0x95,
417 BusLogic_SetCCBFormat = 0x96,
418 BusLogic_WriteInquiryBuffer = 0x9A,
419 BusLogic_ReadInquiryBuffer = 0x9B,
420 BusLogic_FlashROMUploadDownload = 0xA7,
421 BusLogic_ReadSCAMData = 0xA8,
422 BusLogic_WriteSCAMData = 0xA9
423};
424
425
426
427
428
429struct BusLogic_BoardID {
430 unsigned char BoardType;
431 unsigned char CustomFeatures;
432 unsigned char FirmwareVersion1stDigit;
433 unsigned char FirmwareVersion2ndDigit;
434};
435
436
437
438
439
440struct BusLogic_Configuration {
441 unsigned char:5;
442 bool DMA_Channel5:1;
443 bool DMA_Channel6:1;
444 bool DMA_Channel7:1;
445 bool IRQ_Channel9:1;
446 bool IRQ_Channel10:1;
447 bool IRQ_Channel11:1;
448 bool IRQ_Channel12:1;
449 unsigned char:1;
450 bool IRQ_Channel14:1;
451 bool IRQ_Channel15:1;
452 unsigned char:1;
453 unsigned char HostAdapterID:4;
454 unsigned char:4;
455};
456
457
458
459
460
461struct BusLogic_SynchronousValue {
462 unsigned char Offset:4;
463 unsigned char TransferPeriod:3;
464 bool Synchronous:1;
465};
466
467struct BusLogic_SetupInformation {
468 bool SynchronousInitiationEnabled:1;
469 bool ParityCheckingEnabled:1;
470 unsigned char:6;
471 unsigned char BusTransferRate;
472 unsigned char PreemptTimeOnBus;
473 unsigned char TimeOffBus;
474 unsigned char MailboxCount;
475 unsigned char MailboxAddress[3];
476 struct BusLogic_SynchronousValue SynchronousValuesID0to7[8];
477 unsigned char DisconnectPermittedID0to7;
478 unsigned char Signature;
479 unsigned char CharacterD;
480 unsigned char HostBusType;
481 unsigned char WideTransfersPermittedID0to7;
482 unsigned char WideTransfersActiveID0to7;
483 struct BusLogic_SynchronousValue SynchronousValuesID8to15[8];
484 unsigned char DisconnectPermittedID8to15;
485 unsigned char:8;
486 unsigned char WideTransfersPermittedID8to15;
487 unsigned char WideTransfersActiveID8to15;
488};
489
490
491
492
493
494struct BusLogic_ExtendedMailboxRequest {
495 unsigned char MailboxCount;
496 u32 BaseMailboxAddress;
497} PACKED;
498
499
500
501
502
503
504
505
506enum BusLogic_ISACompatibleIOPort {
507 BusLogic_IO_330 = 0,
508 BusLogic_IO_334 = 1,
509 BusLogic_IO_230 = 2,
510 BusLogic_IO_234 = 3,
511 BusLogic_IO_130 = 4,
512 BusLogic_IO_134 = 5,
513 BusLogic_IO_Disable = 6,
514 BusLogic_IO_Disable2 = 7
515} PACKED;
516
517struct BusLogic_PCIHostAdapterInformation {
518 enum BusLogic_ISACompatibleIOPort ISACompatibleIOPort;
519 unsigned char PCIAssignedIRQChannel;
520 bool LowByteTerminated:1;
521 bool HighByteTerminated:1;
522 unsigned char:2;
523 bool JP1:1;
524 bool JP2:1;
525 bool JP3:1;
526 bool GenericInfoValid:1;
527 unsigned char:8;
528};
529
530
531
532
533
534struct BusLogic_ExtendedSetupInformation {
535 unsigned char BusType;
536 unsigned char BIOS_Address;
537 unsigned short ScatterGatherLimit;
538 unsigned char MailboxCount;
539 u32 BaseMailboxAddress;
540 struct {
541 unsigned char:2;
542 bool FastOnEISA:1;
543 unsigned char:3;
544 bool LevelSensitiveInterrupt:1;
545 unsigned char:1;
546 } Misc;
547 unsigned char FirmwareRevision[3];
548 bool HostWideSCSI:1;
549 bool HostDifferentialSCSI:1;
550 bool HostSupportsSCAM:1;
551 bool HostUltraSCSI:1;
552 bool HostSmartTermination:1;
553 unsigned char:3;
554} PACKED;
555
556
557
558
559
560enum BusLogic_RoundRobinModeRequest {
561 BusLogic_AggressiveRoundRobinMode = 0,
562 BusLogic_StrictRoundRobinMode = 1
563} PACKED;
564
565
566
567
568
569
570#define BusLogic_BIOS_BaseOffset 0
571#define BusLogic_AutoSCSI_BaseOffset 64
572
573struct BusLogic_FetchHostAdapterLocalRAMRequest {
574 unsigned char ByteOffset;
575 unsigned char ByteCount;
576};
577
578
579
580
581
582struct BusLogic_AutoSCSIData {
583 unsigned char InternalFactorySignature[2];
584 unsigned char InformationByteCount;
585 unsigned char HostAdapterType[6];
586 unsigned char:8;
587 bool FloppyEnabled:1;
588 bool FloppySecondary:1;
589 bool LevelSensitiveInterrupt:1;
590 unsigned char:2;
591 unsigned char SystemRAMAreaForBIOS:3;
592 unsigned char DMA_Channel:7;
593 bool DMA_AutoConfiguration:1;
594 unsigned char IRQ_Channel:7;
595 bool IRQ_AutoConfiguration:1;
596 unsigned char DMA_TransferRate;
597 unsigned char SCSI_ID;
598 bool LowByteTerminated:1;
599 bool ParityCheckingEnabled:1;
600 bool HighByteTerminated:1;
601 bool NoisyCablingEnvironment:1;
602 bool FastSynchronousNegotiation:1;
603 bool BusResetEnabled:1;
604 bool:1;
605 bool ActiveNegationEnabled:1;
606 unsigned char BusOnDelay;
607 unsigned char BusOffDelay;
608 bool HostAdapterBIOSEnabled:1;
609 bool BIOSRedirectionOfINT19Enabled:1;
610 bool ExtendedTranslationEnabled:1;
611 bool MapRemovableAsFixedEnabled:1;
612 bool:1;
613 bool BIOSSupportsMoreThan2DrivesEnabled:1;
614 bool BIOSInterruptModeEnabled:1;
615 bool FlopticalSupportEnabled:1;
616 unsigned short DeviceEnabled;
617 unsigned short WidePermitted;
618 unsigned short FastPermitted;
619 unsigned short SynchronousPermitted;
620 unsigned short DisconnectPermitted;
621 unsigned short SendStartUnitCommand;
622 unsigned short IgnoreInBIOSScan;
623 unsigned char PCIInterruptPin:2;
624 unsigned char HostAdapterIOPortAddress:2;
625 bool StrictRoundRobinModeEnabled:1;
626 bool VESABusSpeedGreaterThan33MHz:1;
627 bool VESABurstWriteEnabled:1;
628 bool VESABurstReadEnabled:1;
629 unsigned short UltraPermitted;
630 unsigned int:32;
631 unsigned char:8;
632 unsigned char AutoSCSIMaximumLUN;
633 bool:1;
634 bool SCAM_Dominant:1;
635 bool SCAM_Enabled:1;
636 bool SCAM_Level2:1;
637 unsigned char:4;
638 bool INT13ExtensionEnabled:1;
639 bool:1;
640 bool CDROMBootEnabled:1;
641 unsigned char:5;
642 unsigned char BootTargetID:4;
643 unsigned char BootChannel:4;
644 unsigned char ForceBusDeviceScanningOrder:1;
645 unsigned char:7;
646 unsigned short NonTaggedToAlternateLUNPermitted;
647 unsigned short RenegotiateSyncAfterCheckCondition;
648 unsigned char Reserved[10];
649 unsigned char ManufacturingDiagnostic[2];
650 unsigned short Checksum;
651} PACKED;
652
653
654
655
656
657struct BusLogic_AutoSCSIByte45 {
658 unsigned char ForceBusDeviceScanningOrder:1;
659 unsigned char:7;
660};
661
662
663
664
665
666#define BusLogic_BIOS_DriveMapOffset 17
667
668struct BusLogic_BIOSDriveMapByte {
669 unsigned char TargetIDBit3:1;
670 unsigned char:2;
671 enum BusLogic_BIOS_DiskGeometryTranslation DiskGeometry:2;
672 unsigned char TargetID:3;
673};
674
675
676
677
678
679
680enum BusLogic_SetCCBFormatRequest {
681 BusLogic_LegacyLUNFormatCCB = 0,
682 BusLogic_ExtendedLUNFormatCCB = 1
683} PACKED;
684
685
686
687
688
689enum BusLogic_ActionCode {
690 BusLogic_OutgoingMailboxFree = 0x00,
691 BusLogic_MailboxStartCommand = 0x01,
692 BusLogic_MailboxAbortCommand = 0x02
693} PACKED;
694
695
696
697
698
699
700
701
702enum BusLogic_CompletionCode {
703 BusLogic_IncomingMailboxFree = 0x00,
704 BusLogic_CommandCompletedWithoutError = 0x01,
705 BusLogic_CommandAbortedAtHostRequest = 0x02,
706 BusLogic_AbortedCommandNotFound = 0x03,
707 BusLogic_CommandCompletedWithError = 0x04,
708 BusLogic_InvalidCCB = 0x05
709} PACKED;
710
711
712
713
714
715enum BusLogic_CCB_Opcode {
716 BusLogic_InitiatorCCB = 0x00,
717 BusLogic_TargetCCB = 0x01,
718 BusLogic_InitiatorCCB_ScatterGather = 0x02,
719 BusLogic_InitiatorCCB_ResidualDataLength = 0x03,
720 BusLogic_InitiatorCCB_ScatterGatherResidual = 0x04,
721 BusLogic_BusDeviceReset = 0x81
722} PACKED;
723
724
725
726
727
728
729enum BusLogic_DataDirection {
730 BusLogic_UncheckedDataTransfer = 0,
731 BusLogic_DataInLengthChecked = 1,
732 BusLogic_DataOutLengthChecked = 2,
733 BusLogic_NoDataTransfer = 3
734};
735
736
737
738
739
740
741
742enum BusLogic_HostAdapterStatus {
743 BusLogic_CommandCompletedNormally = 0x00,
744 BusLogic_LinkedCommandCompleted = 0x0A,
745 BusLogic_LinkedCommandCompletedWithFlag = 0x0B,
746 BusLogic_DataUnderRun = 0x0C,
747 BusLogic_SCSISelectionTimeout = 0x11,
748 BusLogic_DataOverRun = 0x12,
749 BusLogic_UnexpectedBusFree = 0x13,
750 BusLogic_InvalidBusPhaseRequested = 0x14,
751 BusLogic_InvalidOutgoingMailboxActionCode = 0x15,
752 BusLogic_InvalidCommandOperationCode = 0x16,
753 BusLogic_LinkedCCBhasInvalidLUN = 0x17,
754 BusLogic_InvalidCommandParameter = 0x1A,
755 BusLogic_AutoRequestSenseFailed = 0x1B,
756 BusLogic_TaggedQueuingMessageRejected = 0x1C,
757 BusLogic_UnsupportedMessageReceived = 0x1D,
758 BusLogic_HostAdapterHardwareFailed = 0x20,
759 BusLogic_TargetFailedResponseToATN = 0x21,
760 BusLogic_HostAdapterAssertedRST = 0x22,
761 BusLogic_OtherDeviceAssertedRST = 0x23,
762 BusLogic_TargetDeviceReconnectedImproperly = 0x24,
763 BusLogic_HostAdapterAssertedBusDeviceReset = 0x25,
764 BusLogic_AbortQueueGenerated = 0x26,
765 BusLogic_HostAdapterSoftwareError = 0x27,
766 BusLogic_HostAdapterHardwareTimeoutError = 0x30,
767 BusLogic_SCSIParityErrorDetected = 0x34
768} PACKED;
769
770
771
772
773
774
775enum BusLogic_TargetDeviceStatus {
776 BusLogic_OperationGood = 0x00,
777 BusLogic_CheckCondition = 0x02,
778 BusLogic_DeviceBusy = 0x08
779} PACKED;
780
781
782
783
784
785enum BusLogic_QueueTag {
786 BusLogic_SimpleQueueTag = 0,
787 BusLogic_HeadOfQueueTag = 1,
788 BusLogic_OrderedQueueTag = 2,
789 BusLogic_ReservedQT = 3
790};
791
792
793
794
795
796#define BusLogic_CDB_MaxLength 12
797
798typedef unsigned char SCSI_CDB_T[BusLogic_CDB_MaxLength];
799
800
801
802
803
804
805
806struct BusLogic_ScatterGatherSegment {
807 u32 SegmentByteCount;
808 u32 SegmentDataPointer;
809};
810
811
812
813
814
815enum BusLogic_CCB_Status {
816 BusLogic_CCB_Free = 0,
817 BusLogic_CCB_Active = 1,
818 BusLogic_CCB_Completed = 2,
819 BusLogic_CCB_Reset = 3
820} PACKED;
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842struct BusLogic_CCB {
843
844
845
846 enum BusLogic_CCB_Opcode Opcode;
847 unsigned char:3;
848 enum BusLogic_DataDirection DataDirection:2;
849 bool TagEnable:1;
850 enum BusLogic_QueueTag QueueTag:2;
851 unsigned char CDB_Length;
852 unsigned char SenseDataLength;
853 u32 DataLength;
854 u32 DataPointer;
855 unsigned char:8;
856 unsigned char:8;
857 enum BusLogic_HostAdapterStatus HostAdapterStatus;
858 enum BusLogic_TargetDeviceStatus TargetDeviceStatus;
859 unsigned char TargetID;
860 unsigned char LogicalUnit:5;
861 bool LegacyTagEnable:1;
862 enum BusLogic_QueueTag LegacyQueueTag:2;
863 SCSI_CDB_T CDB;
864 unsigned char:8;
865 unsigned char:8;
866 unsigned int:32;
867 u32 SenseDataPointer;
868
869
870
871 void (*CallbackFunction) (struct BusLogic_CCB *);
872 u32 BaseAddress;
873 enum BusLogic_CompletionCode CompletionCode;
874#ifndef CONFIG_SCSI_OMIT_FLASHPOINT
875 unsigned char:8;
876 unsigned short OS_Flags;
877 unsigned char Private[48];
878#endif
879
880
881
882 dma_addr_t AllocationGroupHead;
883 unsigned int AllocationGroupSize;
884 u32 DMA_Handle;
885 enum BusLogic_CCB_Status Status;
886 unsigned long SerialNumber;
887 struct scsi_cmnd *Command;
888 struct BusLogic_HostAdapter *HostAdapter;
889 struct BusLogic_CCB *Next;
890 struct BusLogic_CCB *NextAll;
891 struct BusLogic_ScatterGatherSegment
892 ScatterGatherList[BusLogic_ScatterGatherLimit];
893};
894
895
896
897
898
899struct BusLogic_OutgoingMailbox {
900 u32 CCB;
901 unsigned int:24;
902 enum BusLogic_ActionCode ActionCode;
903};
904
905
906
907
908
909struct BusLogic_IncomingMailbox {
910 u32 CCB;
911 enum BusLogic_HostAdapterStatus HostAdapterStatus;
912 enum BusLogic_TargetDeviceStatus TargetDeviceStatus;
913 unsigned char:8;
914 enum BusLogic_CompletionCode CompletionCode;
915};
916
917
918
919
920
921
922struct BusLogic_DriverOptions {
923 unsigned short TaggedQueuingPermitted;
924 unsigned short TaggedQueuingPermittedMask;
925 unsigned short BusSettleTime;
926 struct BusLogic_LocalOptions LocalOptions;
927 unsigned char CommonQueueDepth;
928 unsigned char QueueDepth[BusLogic_MaxTargetDevices];
929};
930
931
932
933
934
935struct BusLogic_TargetFlags {
936 bool TargetExists:1;
937 bool TaggedQueuingSupported:1;
938 bool WideTransfersSupported:1;
939 bool TaggedQueuingActive:1;
940 bool WideTransfersActive:1;
941 bool CommandSuccessfulFlag:1;
942 bool TargetInfoReported:1;
943};
944
945
946
947
948
949#define BusLogic_SizeBuckets 10
950
951typedef unsigned int BusLogic_CommandSizeBuckets_T[BusLogic_SizeBuckets];
952
953struct BusLogic_TargetStatistics {
954 unsigned int CommandsAttempted;
955 unsigned int CommandsCompleted;
956 unsigned int ReadCommands;
957 unsigned int WriteCommands;
958 struct BusLogic_ByteCounter TotalBytesRead;
959 struct BusLogic_ByteCounter TotalBytesWritten;
960 BusLogic_CommandSizeBuckets_T ReadCommandSizeBuckets;
961 BusLogic_CommandSizeBuckets_T WriteCommandSizeBuckets;
962 unsigned short CommandAbortsRequested;
963 unsigned short CommandAbortsAttempted;
964 unsigned short CommandAbortsCompleted;
965 unsigned short BusDeviceResetsRequested;
966 unsigned short BusDeviceResetsAttempted;
967 unsigned short BusDeviceResetsCompleted;
968 unsigned short HostAdapterResetsRequested;
969 unsigned short HostAdapterResetsAttempted;
970 unsigned short HostAdapterResetsCompleted;
971};
972
973
974
975
976
977#define FlashPoint_BadCardHandle 0xFFFFFFFF
978
979typedef unsigned int FlashPoint_CardHandle_T;
980
981
982
983
984
985
986
987struct FlashPoint_Info {
988 u32 BaseAddress;
989 bool Present;
990 unsigned char IRQ_Channel;
991 unsigned char SCSI_ID;
992 unsigned char SCSI_LUN;
993 unsigned short FirmwareRevision;
994 unsigned short SynchronousPermitted;
995 unsigned short FastPermitted;
996 unsigned short UltraPermitted;
997 unsigned short DisconnectPermitted;
998 unsigned short WidePermitted;
999 bool ParityCheckingEnabled:1;
1000 bool HostWideSCSI:1;
1001 bool HostSoftReset:1;
1002 bool ExtendedTranslationEnabled:1;
1003 bool LowByteTerminated:1;
1004 bool HighByteTerminated:1;
1005 bool ReportDataUnderrun:1;
1006 bool SCAM_Enabled:1;
1007 bool SCAM_Level2:1;
1008 unsigned char:7;
1009 unsigned char Family;
1010 unsigned char BusType;
1011 unsigned char ModelNumber[3];
1012 unsigned char RelativeCardNumber;
1013 unsigned char Reserved[4];
1014 unsigned int OS_Reserved;
1015 unsigned char TranslationInfo[4];
1016 unsigned int Reserved2[5];
1017 unsigned int SecondaryRange;
1018};
1019
1020
1021
1022
1023
1024struct BusLogic_HostAdapter {
1025 struct Scsi_Host *SCSI_Host;
1026 struct pci_dev *PCI_Device;
1027 enum BusLogic_HostAdapterType HostAdapterType;
1028 enum BusLogic_HostAdapterBusType HostAdapterBusType;
1029 unsigned long IO_Address;
1030 unsigned long PCI_Address;
1031 unsigned short AddressCount;
1032 unsigned char HostNumber;
1033 unsigned char ModelName[9];
1034 unsigned char FirmwareVersion[6];
1035 unsigned char FullModelName[18];
1036 unsigned char Bus;
1037 unsigned char Device;
1038 unsigned char IRQ_Channel;
1039 unsigned char DMA_Channel;
1040 unsigned char SCSI_ID;
1041 bool IRQ_ChannelAcquired:1;
1042 bool DMA_ChannelAcquired:1;
1043 bool ExtendedTranslationEnabled:1;
1044 bool ParityCheckingEnabled:1;
1045 bool BusResetEnabled:1;
1046 bool LevelSensitiveInterrupt:1;
1047 bool HostWideSCSI:1;
1048 bool HostDifferentialSCSI:1;
1049 bool HostSupportsSCAM:1;
1050 bool HostUltraSCSI:1;
1051 bool ExtendedLUNSupport:1;
1052 bool TerminationInfoValid:1;
1053 bool LowByteTerminated:1;
1054 bool HighByteTerminated:1;
1055 bool BounceBuffersRequired:1;
1056 bool StrictRoundRobinModeSupport:1;
1057 bool SCAM_Enabled:1;
1058 bool SCAM_Level2:1;
1059 bool HostAdapterInitialized:1;
1060 bool HostAdapterExternalReset:1;
1061 bool HostAdapterInternalError:1;
1062 bool ProcessCompletedCCBsActive;
1063 volatile bool HostAdapterCommandCompleted;
1064 unsigned short HostAdapterScatterGatherLimit;
1065 unsigned short DriverScatterGatherLimit;
1066 unsigned short MaxTargetDevices;
1067 unsigned short MaxLogicalUnits;
1068 unsigned short MailboxCount;
1069 unsigned short InitialCCBs;
1070 unsigned short IncrementalCCBs;
1071 unsigned short AllocatedCCBs;
1072 unsigned short DriverQueueDepth;
1073 unsigned short HostAdapterQueueDepth;
1074 unsigned short UntaggedQueueDepth;
1075 unsigned short CommonQueueDepth;
1076 unsigned short BusSettleTime;
1077 unsigned short SynchronousPermitted;
1078 unsigned short FastPermitted;
1079 unsigned short UltraPermitted;
1080 unsigned short WidePermitted;
1081 unsigned short DisconnectPermitted;
1082 unsigned short TaggedQueuingPermitted;
1083 unsigned short ExternalHostAdapterResets;
1084 unsigned short HostAdapterInternalErrors;
1085 unsigned short TargetDeviceCount;
1086 unsigned short MessageBufferLength;
1087 u32 BIOS_Address;
1088 struct BusLogic_DriverOptions *DriverOptions;
1089 struct FlashPoint_Info FlashPointInfo;
1090 FlashPoint_CardHandle_T CardHandle;
1091 struct list_head host_list;
1092 struct BusLogic_CCB *All_CCBs;
1093 struct BusLogic_CCB *Free_CCBs;
1094 struct BusLogic_CCB *FirstCompletedCCB;
1095 struct BusLogic_CCB *LastCompletedCCB;
1096 struct BusLogic_CCB *BusDeviceResetPendingCCB[BusLogic_MaxTargetDevices];
1097 struct BusLogic_TargetFlags TargetFlags[BusLogic_MaxTargetDevices];
1098 unsigned char QueueDepth[BusLogic_MaxTargetDevices];
1099 unsigned char SynchronousPeriod[BusLogic_MaxTargetDevices];
1100 unsigned char SynchronousOffset[BusLogic_MaxTargetDevices];
1101 unsigned char ActiveCommands[BusLogic_MaxTargetDevices];
1102 unsigned int CommandsSinceReset[BusLogic_MaxTargetDevices];
1103 unsigned long LastSequencePoint[BusLogic_MaxTargetDevices];
1104 unsigned long LastResetAttempted[BusLogic_MaxTargetDevices];
1105 unsigned long LastResetCompleted[BusLogic_MaxTargetDevices];
1106 struct BusLogic_OutgoingMailbox *FirstOutgoingMailbox;
1107 struct BusLogic_OutgoingMailbox *LastOutgoingMailbox;
1108 struct BusLogic_OutgoingMailbox *NextOutgoingMailbox;
1109 struct BusLogic_IncomingMailbox *FirstIncomingMailbox;
1110 struct BusLogic_IncomingMailbox *LastIncomingMailbox;
1111 struct BusLogic_IncomingMailbox *NextIncomingMailbox;
1112 struct BusLogic_TargetStatistics TargetStatistics[BusLogic_MaxTargetDevices];
1113 unsigned char *MailboxSpace;
1114 dma_addr_t MailboxSpaceHandle;
1115 unsigned int MailboxSize;
1116 unsigned long CCB_Offset;
1117 char MessageBuffer[BusLogic_MessageBufferSize];
1118};
1119
1120
1121
1122
1123
1124struct BIOS_DiskParameters {
1125 int Heads;
1126 int Sectors;
1127 int Cylinders;
1128};
1129
1130
1131
1132
1133
1134struct SCSI_Inquiry {
1135 unsigned char PeripheralDeviceType:5;
1136 unsigned char PeripheralQualifier:3;
1137 unsigned char DeviceTypeModifier:7;
1138 bool RMB:1;
1139 unsigned char ANSI_ApprovedVersion:3;
1140 unsigned char ECMA_Version:3;
1141 unsigned char ISO_Version:2;
1142 unsigned char ResponseDataFormat:4;
1143 unsigned char:2;
1144 bool TrmIOP:1;
1145 bool AENC:1;
1146 unsigned char AdditionalLength;
1147 unsigned char:8;
1148 unsigned char:8;
1149 bool SftRe:1;
1150 bool CmdQue:1;
1151 bool:1;
1152 bool Linked:1;
1153 bool Sync:1;
1154 bool WBus16:1;
1155 bool WBus32:1;
1156 bool RelAdr:1;
1157 unsigned char VendorIdentification[8];
1158 unsigned char ProductIdentification[16];
1159 unsigned char ProductRevisionLevel[4];
1160};
1161
1162
1163
1164
1165
1166
1167
1168static inline void BusLogic_SCSIBusReset(struct BusLogic_HostAdapter *HostAdapter)
1169{
1170 union BusLogic_ControlRegister ControlRegister;
1171 ControlRegister.All = 0;
1172 ControlRegister.cr.SCSIBusReset = true;
1173 outb(ControlRegister.All, HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
1174}
1175
1176static inline void BusLogic_InterruptReset(struct BusLogic_HostAdapter *HostAdapter)
1177{
1178 union BusLogic_ControlRegister ControlRegister;
1179 ControlRegister.All = 0;
1180 ControlRegister.cr.InterruptReset = true;
1181 outb(ControlRegister.All, HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
1182}
1183
1184static inline void BusLogic_SoftReset(struct BusLogic_HostAdapter *HostAdapter)
1185{
1186 union BusLogic_ControlRegister ControlRegister;
1187 ControlRegister.All = 0;
1188 ControlRegister.cr.SoftReset = true;
1189 outb(ControlRegister.All, HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
1190}
1191
1192static inline void BusLogic_HardReset(struct BusLogic_HostAdapter *HostAdapter)
1193{
1194 union BusLogic_ControlRegister ControlRegister;
1195 ControlRegister.All = 0;
1196 ControlRegister.cr.HardReset = true;
1197 outb(ControlRegister.All, HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
1198}
1199
1200static inline unsigned char BusLogic_ReadStatusRegister(struct BusLogic_HostAdapter *HostAdapter)
1201{
1202 return inb(HostAdapter->IO_Address + BusLogic_StatusRegisterOffset);
1203}
1204
1205static inline void BusLogic_WriteCommandParameterRegister(struct BusLogic_HostAdapter
1206 *HostAdapter, unsigned char Value)
1207{
1208 outb(Value, HostAdapter->IO_Address + BusLogic_CommandParameterRegisterOffset);
1209}
1210
1211static inline unsigned char BusLogic_ReadDataInRegister(struct BusLogic_HostAdapter *HostAdapter)
1212{
1213 return inb(HostAdapter->IO_Address + BusLogic_DataInRegisterOffset);
1214}
1215
1216static inline unsigned char BusLogic_ReadInterruptRegister(struct BusLogic_HostAdapter *HostAdapter)
1217{
1218 return inb(HostAdapter->IO_Address + BusLogic_InterruptRegisterOffset);
1219}
1220
1221static inline unsigned char BusLogic_ReadGeometryRegister(struct BusLogic_HostAdapter *HostAdapter)
1222{
1223 return inb(HostAdapter->IO_Address + BusLogic_GeometryRegisterOffset);
1224}
1225
1226
1227
1228
1229
1230
1231
1232static inline void BusLogic_StartMailboxCommand(struct BusLogic_HostAdapter *HostAdapter)
1233{
1234 BusLogic_WriteCommandParameterRegister(HostAdapter, BusLogic_ExecuteMailboxCommand);
1235}
1236
1237
1238
1239
1240
1241static inline void BusLogic_Delay(int Seconds)
1242{
1243 mdelay(1000 * Seconds);
1244}
1245
1246
1247
1248
1249
1250
1251static inline u32 Virtual_to_Bus(void *VirtualAddress)
1252{
1253 return (u32) virt_to_bus(VirtualAddress);
1254}
1255
1256static inline void *Bus_to_Virtual(u32 BusAddress)
1257{
1258 return (void *) bus_to_virt(BusAddress);
1259}
1260
1261
1262
1263
1264
1265
1266
1267static inline u32 Virtual_to_32Bit_Virtual(void *VirtualAddress)
1268{
1269 return (u32) (unsigned long) VirtualAddress;
1270}
1271
1272
1273
1274
1275
1276
1277static inline void BusLogic_IncrementErrorCounter(unsigned short *ErrorCounter)
1278{
1279 if (*ErrorCounter < 65535)
1280 (*ErrorCounter)++;
1281}
1282
1283
1284
1285
1286
1287static inline void BusLogic_IncrementByteCounter(struct BusLogic_ByteCounter
1288 *ByteCounter, unsigned int Amount)
1289{
1290 ByteCounter->Units += Amount;
1291 if (ByteCounter->Units > 999999999) {
1292 ByteCounter->Units -= 1000000000;
1293 ByteCounter->Billions++;
1294 }
1295}
1296
1297
1298
1299
1300
1301static inline void BusLogic_IncrementSizeBucket(BusLogic_CommandSizeBuckets_T CommandSizeBuckets, unsigned int Amount)
1302{
1303 int Index = 0;
1304 if (Amount < 8 * 1024) {
1305 if (Amount < 2 * 1024)
1306 Index = (Amount < 1 * 1024 ? 0 : 1);
1307 else
1308 Index = (Amount < 4 * 1024 ? 2 : 3);
1309 } else if (Amount < 128 * 1024) {
1310 if (Amount < 32 * 1024)
1311 Index = (Amount < 16 * 1024 ? 4 : 5);
1312 else
1313 Index = (Amount < 64 * 1024 ? 6 : 7);
1314 } else
1315 Index = (Amount < 256 * 1024 ? 8 : 9);
1316 CommandSizeBuckets[Index]++;
1317}
1318
1319
1320
1321
1322
1323#define FlashPoint_FirmwareVersion "5.02"
1324
1325
1326
1327
1328
1329#define FlashPoint_NormalInterrupt 0x00
1330#define FlashPoint_InternalError 0xFE
1331#define FlashPoint_ExternalBusReset 0xFF
1332
1333
1334
1335
1336
1337
1338static const char *BusLogic_DriverInfo(struct Scsi_Host *);
1339static int BusLogic_QueueCommand(struct scsi_cmnd *, void (*CompletionRoutine) (struct scsi_cmnd *));
1340static int BusLogic_BIOSDiskParameters(struct scsi_device *, struct block_device *, sector_t, int *);
1341static int BusLogic_ProcDirectoryInfo(struct Scsi_Host *, char *, char **, off_t, int, int);
1342static int BusLogic_SlaveConfigure(struct scsi_device *);
1343static void BusLogic_QueueCompletedCCB(struct BusLogic_CCB *);
1344static irqreturn_t BusLogic_InterruptHandler(int, void *);
1345static int BusLogic_ResetHostAdapter(struct BusLogic_HostAdapter *, bool HardReset);
1346static void BusLogic_Message(enum BusLogic_MessageLevel, char *, struct BusLogic_HostAdapter *, ...);
1347static int __init BusLogic_Setup(char *);
1348
1349#endif
1350