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