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