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