~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/drivers/scsi/BusLogic.h

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  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 
 29 #include <linux/config.h>
 30 
 31 
 32 /*
 33   Define types for some of the structures that interface with the rest
 34   of the Linux Kernel and SCSI Subsystem.
 35 */
 36 
 37 typedef kdev_t KernelDevice_T;
 38 typedef unsigned long ProcessorFlags_T;
 39 typedef struct pt_regs Registers_T;
 40 typedef struct partition PartitionTable_T;
 41 typedef struct pci_dev PCI_Device_T;
 42 typedef Scsi_Host_Template SCSI_Host_Template_T;
 43 typedef struct Scsi_Host SCSI_Host_T;
 44 typedef struct scsi_device SCSI_Device_T;
 45 typedef struct scsi_disk SCSI_Disk_T;
 46 typedef struct scsi_cmnd SCSI_Command_T;
 47 typedef struct scatterlist SCSI_ScatterList_T;
 48 
 49 
 50 /*
 51   Define prototypes for the BusLogic Driver Interface Functions.
 52 */
 53 
 54 extern const char *BusLogic_DriverInfo(SCSI_Host_T *);
 55 extern int BusLogic_DetectHostAdapter(SCSI_Host_Template_T *);
 56 extern int BusLogic_ReleaseHostAdapter(SCSI_Host_T *);
 57 extern int BusLogic_QueueCommand(SCSI_Command_T *,
 58                                  void (*CompletionRoutine)(SCSI_Command_T *));
 59 extern int BusLogic_AbortCommand(SCSI_Command_T *);
 60 extern int BusLogic_ResetCommand(SCSI_Command_T *, unsigned int);
 61 extern int BusLogic_BIOSDiskParameters(SCSI_Disk_T *, KernelDevice_T, int *);
 62 extern int BusLogic_ProcDirectoryInfo(char *, char **, off_t, int, int, int);
 63 
 64 
 65 /*
 66   Define the BusLogic SCSI Host Template structure.
 67 */
 68 
 69 #define BUSLOGIC                                                               \
 70   { proc_name:      "BusLogic",                   /* ProcFS Directory Entry */ \
 71     proc_info:      BusLogic_ProcDirectoryInfo,   /* ProcFS Info Function   */ \
 72     name:           "BusLogic",                   /* Driver Name            */ \
 73     detect:         BusLogic_DetectHostAdapter,   /* Detect Host Adapter    */ \
 74     release:        BusLogic_ReleaseHostAdapter,  /* Release Host Adapter   */ \
 75     info:           BusLogic_DriverInfo,          /* Driver Info Function   */ \
 76     queuecommand:   BusLogic_QueueCommand,        /* Queue Command Function */ \
 77     abort:          BusLogic_AbortCommand,        /* Abort Command Function */ \
 78     reset:          BusLogic_ResetCommand,        /* Reset Command Function */ \
 79     bios_param:     BusLogic_BIOSDiskParameters,  /* BIOS Disk Parameters   */ \
 80     unchecked_isa_dma: 1,                         /* Default Initial Value  */ \
 81     use_clustering: ENABLE_CLUSTERING }           /* Enable Clustering      */
 82 
 83 
 84 /*
 85   BusLogic_DriverVersion protects the private portion of this file.
 86 */
 87 
 88 #ifdef BusLogic_DriverVersion
 89 
 90 
 91 /*
 92   FlashPoint support is only available for the Intel x86 Architecture with
 93   CONFIG_PCI set.
 94 */
 95 
 96 #ifndef __i386__
 97 #undef CONFIG_SCSI_OMIT_FLASHPOINT
 98 #define CONFIG_SCSI_OMIT_FLASHPOINT
 99 #endif
100 
101 #ifndef CONFIG_PCI
102 #undef CONFIG_SCSI_OMIT_FLASHPOINT
103 #define CONFIG_SCSI_OMIT_FLASHPOINT
104 #define BusLogic_InitializeProbeInfoListISA \
105   BusLogic_InitializeProbeInfoList
106 #endif
107 
108 
109 /*
110   Define the maximum number of BusLogic Host Adapters supported by this driver.
111 */
112 
113 #define BusLogic_MaxHostAdapters                16
114 
115 
116 /*
117   Define the maximum number of Target Devices supported by this driver.
118 */
119 
120 #define BusLogic_MaxTargetDevices               16
121 
122 
123 /*
124   Define the maximum number of Scatter/Gather Segments used by this driver.
125   For optimal performance, it is important that this limit be at least as
126   large as the largest single request generated by the I/O Subsystem.
127 */
128 
129 #define BusLogic_ScatterGatherLimit             128
130 
131 
132 /*
133   Define the maximum, maximum automatic, minimum automatic, and default Queue
134   Depth to allow for Target Devices depending on whether or not they support
135   Tagged Queuing and whether or not ISA Bounce Buffers are required.
136 */
137 
138 #define BusLogic_MaxTaggedQueueDepth            64
139 #define BusLogic_MaxAutomaticTaggedQueueDepth   28
140 #define BusLogic_MinAutomaticTaggedQueueDepth   7
141 #define BusLogic_TaggedQueueDepthBB             3
142 #define BusLogic_UntaggedQueueDepth             3
143 #define BusLogic_UntaggedQueueDepthBB           2
144 
145 
146 /*
147   Define the default amount of time in seconds to wait between a Host Adapter
148   Hard Reset which initiates a SCSI Bus Reset and issuing any SCSI commands.
149   Some SCSI devices get confused if they receive SCSI commands too soon after
150   a SCSI Bus Reset.
151 */
152 
153 #define BusLogic_DefaultBusSettleTime           2
154 
155 
156 /*
157   Define the maximum number of Mailboxes that should be used for MultiMaster
158   Host Adapters.  This number is chosen to be larger than the maximum Host
159   Adapter Queue Depth and small enough so that the Host Adapter structure
160   does not cross an allocation block size boundary.
161 */
162 
163 #define BusLogic_MaxMailboxes                   211
164 
165 
166 /*
167   Define the number of CCBs that should be allocated as a group to optimize
168   Kernel memory allocation.
169 */
170 
171 #define BusLogic_CCB_AllocationGroupSize        7
172 
173 
174 /*
175   Define the Host Adapter Line and Message Buffer Sizes.
176 */
177 
178 #define BusLogic_LineBufferSize                 100
179 #define BusLogic_MessageBufferSize              9700
180 
181 
182 /*
183   Define the Driver Message Levels.
184 */
185 
186 typedef enum BusLogic_MessageLevel
187 {
188   BusLogic_AnnounceLevel =                      0,
189   BusLogic_InfoLevel =                          1,
190   BusLogic_NoticeLevel =                        2,
191   BusLogic_WarningLevel =                       3,
192   BusLogic_ErrorLevel =                         4
193 }
194 BusLogic_MessageLevel_T;
195 
196 static char
197   *BusLogic_MessageLevelMap[] =
198     { KERN_NOTICE, KERN_NOTICE, KERN_NOTICE, KERN_WARNING, KERN_ERR };
199 
200 
201 /*
202   Define Driver Message macros.
203 */
204 
205 #define BusLogic_Announce(Format, Arguments...) \
206   BusLogic_Message(BusLogic_AnnounceLevel, Format, ##Arguments)
207 
208 #define BusLogic_Info(Format, Arguments...) \
209   BusLogic_Message(BusLogic_InfoLevel, Format, ##Arguments)
210 
211 #define BusLogic_Notice(Format, Arguments...) \
212   BusLogic_Message(BusLogic_NoticeLevel, Format, ##Arguments)
213 
214 #define BusLogic_Warning(Format, Arguments...) \
215   BusLogic_Message(BusLogic_WarningLevel, Format, ##Arguments)
216 
217 #define BusLogic_Error(Format, Arguments...) \
218   BusLogic_Message(BusLogic_ErrorLevel, Format, ##Arguments)
219 
220 
221 /*
222   Define the types of BusLogic Host Adapters that are supported and the number
223   of I/O Addresses required by each type.
224 */
225 
226 typedef enum
227 {
228   BusLogic_MultiMaster =                        1,
229   BusLogic_FlashPoint =                         2
230 }
231 __attribute__ ((packed))
232 BusLogic_HostAdapterType_T;
233 
234 #define BusLogic_MultiMasterAddressCount        4
235 #define BusLogic_FlashPointAddressCount         256
236 
237 static int
238   BusLogic_HostAdapterAddressCount[3] =
239     { 0, BusLogic_MultiMasterAddressCount, BusLogic_FlashPointAddressCount };
240 
241 
242 /*
243   Define macros for testing the Host Adapter Type.
244 */
245 
246 #ifndef CONFIG_SCSI_OMIT_FLASHPOINT
247 
248 #define BusLogic_MultiMasterHostAdapterP(HostAdapter) \
249   (HostAdapter->HostAdapterType == BusLogic_MultiMaster)
250 
251 #define BusLogic_FlashPointHostAdapterP(HostAdapter) \
252   (HostAdapter->HostAdapterType == BusLogic_FlashPoint)
253 
254 #else
255 
256 #define BusLogic_MultiMasterHostAdapterP(HostAdapter) \
257   (true)
258 
259 #define BusLogic_FlashPointHostAdapterP(HostAdapter) \
260   (false)
261 
262 #endif
263 
264 
265 /*
266   Define the possible Host Adapter Bus Types.
267 */
268 
269 typedef enum
270 {
271   BusLogic_Unknown_Bus =                        0,
272   BusLogic_ISA_Bus =                            1,
273   BusLogic_EISA_Bus =                           2,
274   BusLogic_PCI_Bus =                            3,
275   BusLogic_VESA_Bus =                           4,
276   BusLogic_MCA_Bus =                            5
277 }
278 __attribute__ ((packed))
279 BusLogic_HostAdapterBusType_T;
280 
281 static char
282   *BusLogic_HostAdapterBusNames[] =
283     { "Unknown", "ISA", "EISA", "PCI", "VESA", "MCA" };
284 
285 static BusLogic_HostAdapterBusType_T
286   BusLogic_HostAdapterBusTypes[] =
287     { BusLogic_VESA_Bus,                                /* BT-4xx */
288       BusLogic_ISA_Bus,                                 /* BT-5xx */
289       BusLogic_MCA_Bus,                                 /* BT-6xx */
290       BusLogic_EISA_Bus,                                /* BT-7xx */
291       BusLogic_Unknown_Bus,                             /* BT-8xx */
292       BusLogic_PCI_Bus };                               /* BT-9xx */
293 
294 
295 /*
296   Define the possible Host Adapter BIOS Disk Geometry Translations.
297 */
298 
299 typedef enum BusLogic_BIOS_DiskGeometryTranslation
300 {
301   BusLogic_BIOS_Disk_Not_Installed =            0,
302   BusLogic_BIOS_Disk_Installed_64x32 =          1,
303   BusLogic_BIOS_Disk_Installed_128x32 =         2,
304   BusLogic_BIOS_Disk_Installed_255x63 =         3
305 }
306 __attribute__ ((packed))
307 BusLogic_BIOS_DiskGeometryTranslation_T;
308 
309 
310 /*
311   Define a Boolean data type.
312 */
313 
314 typedef enum { false, true } __attribute__ ((packed)) boolean;
315 
316 
317 /*
318   Define a 32 bit I/O Address data type.
319 */
320 
321 typedef unsigned int BusLogic_IO_Address_T;
322 
323 
324 /*
325   Define a 32 bit PCI Bus Address data type.
326 */
327 
328 typedef unsigned int BusLogic_PCI_Address_T;
329 
330 
331 /*
332   Define a 32 bit Base Address data type.
333 */
334 
335 typedef unsigned int BusLogic_Base_Address_T;
336 
337 
338 /*
339   Define a 32 bit Bus Address data type.
340 */
341 
342 typedef unsigned int BusLogic_BusAddress_T;
343 
344 
345 /*
346   Define a 32 bit Byte Count data type.
347 */
348 
349 typedef unsigned int BusLogic_ByteCount_T;
350 
351 
352 /*
353   Define a 10^18 Statistics Byte Counter data type.
354 */
355 
356 typedef struct BusLogic_ByteCounter
357 {
358   unsigned int Units;
359   unsigned int Billions;
360 }
361 BusLogic_ByteCounter_T;
362 
363 
364 /*
365   Define the structure for I/O Address and Bus Probing Information.
366 */
367 
368 typedef struct BusLogic_ProbeInfo
369 {
370   BusLogic_HostAdapterType_T HostAdapterType;
371   BusLogic_HostAdapterBusType_T HostAdapterBusType;
372   BusLogic_IO_Address_T IO_Address;
373   BusLogic_PCI_Address_T PCI_Address;
374   unsigned char Bus;
375   unsigned char Device;
376   unsigned char IRQ_Channel;
377 }
378 BusLogic_ProbeInfo_T;
379 
380 
381 /*
382   Define the Probe Options.
383 */
384 
385 typedef struct BusLogic_ProbeOptions
386 {
387   boolean NoProbe:1;                                    /* Bit 0 */
388   boolean NoProbeISA:1;                                 /* Bit 1 */
389   boolean NoProbePCI:1;                                 /* Bit 2 */
390   boolean NoSortPCI:1;                                  /* Bit 3 */
391   boolean MultiMasterFirst:1;                           /* Bit 4 */
392   boolean FlashPointFirst:1;                            /* Bit 5 */
393   boolean LimitedProbeISA:1;                            /* Bit 6 */
394   boolean Probe330:1;                                   /* Bit 7 */
395   boolean Probe334:1;                                   /* Bit 8 */
396   boolean Probe230:1;                                   /* Bit 9 */
397   boolean Probe234:1;                                   /* Bit 10 */
398   boolean Probe130:1;                                   /* Bit 11 */
399   boolean Probe134:1;                                   /* Bit 12 */
400 }
401 BusLogic_ProbeOptions_T;
402 
403 
404 /*
405   Define the Global Options.
406 */
407 
408 typedef struct BusLogic_GlobalOptions
409 {
410   boolean TraceProbe:1;                                 /* Bit 0 */
411   boolean TraceHardwareReset:1;                         /* Bit 1 */
412   boolean TraceConfiguration:1;                         /* Bit 2 */
413   boolean TraceErrors:1;                                /* Bit 3 */
414 }
415 BusLogic_GlobalOptions_T;
416 
417 
418 /*
419   Define the Local Options.
420 */
421 
422 typedef struct BusLogic_LocalOptions
423 {
424   boolean InhibitTargetInquiry:1;                       /* Bit 0 */
425 }
426 BusLogic_LocalOptions_T;
427 
428 
429 /*
430   Define the Error Recovery Strategy Options.
431 */
432 
433 typedef enum
434 {
435   BusLogic_ErrorRecovery_Default =              0,
436   BusLogic_ErrorRecovery_BusDeviceReset =       1,
437   BusLogic_ErrorRecovery_HardReset =            2,
438   BusLogic_ErrorRecovery_None =                 3
439 }
440 __attribute__ ((packed))
441 BusLogic_ErrorRecoveryStrategy_T;
442 
443 static char
444   *BusLogic_ErrorRecoveryStrategyNames[] =
445     { "Default", "Bus Device Reset", "Hard Reset", "None" },
446   BusLogic_ErrorRecoveryStrategyLetters[] =
447     { 'D', 'B', 'H', 'N' };
448 
449 
450 /*
451   Define the BusLogic SCSI Host Adapter I/O Register Offsets.
452 */
453 
454 #define BusLogic_ControlRegisterOffset          0       /* WO register */
455 #define BusLogic_StatusRegisterOffset           0       /* RO register */
456 #define BusLogic_CommandParameterRegisterOffset 1       /* WO register */
457 #define BusLogic_DataInRegisterOffset           1       /* RO register */
458 #define BusLogic_InterruptRegisterOffset        2       /* RO register */
459 #define BusLogic_GeometryRegisterOffset         3       /* RO register */
460 
461 
462 /*
463   Define the structure of the write-only Control Register.
464 */
465 
466 typedef union BusLogic_ControlRegister
467 {
468   unsigned char All;
469   struct {
470     unsigned char :4;                                   /* Bits 0-3 */
471     boolean SCSIBusReset:1;                             /* Bit 4 */
472     boolean InterruptReset:1;                           /* Bit 5 */
473     boolean SoftReset:1;                                /* Bit 6 */
474     boolean HardReset:1;                                /* Bit 7 */
475   } Bits;
476 }
477 BusLogic_ControlRegister_T;
478 
479 
480 /*
481   Define the structure of the read-only Status Register.
482 */
483 
484 typedef union BusLogic_StatusRegister
485 {
486   unsigned char All;
487   struct {
488     boolean CommandInvalid:1;                           /* Bit 0 */
489     boolean Reserved:1;                                 /* Bit 1 */
490     boolean DataInRegisterReady:1;                      /* Bit 2 */
491     boolean CommandParameterRegisterBusy:1;             /* Bit 3 */
492     boolean HostAdapterReady:1;                         /* Bit 4 */
493     boolean InitializationRequired:1;                   /* Bit 5 */
494     boolean DiagnosticFailure:1;                        /* Bit 6 */
495     boolean DiagnosticActive:1;                         /* Bit 7 */
496   } Bits;
497 }
498 BusLogic_StatusRegister_T;
499 
500 
501 /*
502   Define the structure of the read-only Interrupt Register.
503 */
504 
505 typedef union BusLogic_InterruptRegister
506 {
507   unsigned char All;
508   struct {
509     boolean IncomingMailboxLoaded:1;                    /* Bit 0 */
510     boolean OutgoingMailboxAvailable:1;                 /* Bit 1 */
511     boolean CommandComplete:1;                          /* Bit 2 */
512     boolean ExternalBusReset:1;                         /* Bit 3 */
513     unsigned char Reserved:3;                           /* Bits 4-6 */
514     boolean InterruptValid:1;                           /* Bit 7 */
515   } Bits;
516 }
517 BusLogic_InterruptRegister_T;
518 
519 
520 /*
521   Define the structure of the read-only Geometry Register.
522 */
523 
524 typedef union BusLogic_GeometryRegister
525 {
526   unsigned char All;
527   struct {
528     BusLogic_BIOS_DiskGeometryTranslation_T Drive0Geometry:2; /* Bits 0-1 */
529     BusLogic_BIOS_DiskGeometryTranslation_T Drive1Geometry:2; /* Bits 2-3 */
530     unsigned char :3;                                   /* Bits 4-6 */
531     boolean ExtendedTranslationEnabled:1;               /* Bit 7 */
532   } Bits;
533 }
534 BusLogic_GeometryRegister_T;
535 
536 
537 /*
538   Define the BusLogic SCSI Host Adapter Command Register Operation Codes.
539 */
540 
541 typedef enum
542 {
543   BusLogic_TestCommandCompleteInterrupt =       0x00,
544   BusLogic_InitializeMailbox =                  0x01,
545   BusLogic_ExecuteMailboxCommand =              0x02,
546   BusLogic_ExecuteBIOSCommand =                 0x03,
547   BusLogic_InquireBoardID =                     0x04,
548   BusLogic_EnableOutgoingMailboxAvailableInt =  0x05,
549   BusLogic_SetSCSISelectionTimeout =            0x06,
550   BusLogic_SetPreemptTimeOnBus =                0x07,
551   BusLogic_SetTimeOffBus =                      0x08,
552   BusLogic_SetBusTransferRate =                 0x09,
553   BusLogic_InquireInstalledDevicesID0to7 =      0x0A,
554   BusLogic_InquireConfiguration =               0x0B,
555   BusLogic_EnableTargetMode =                   0x0C,
556   BusLogic_InquireSetupInformation =            0x0D,
557   BusLogic_WriteAdapterLocalRAM =               0x1A,
558   BusLogic_ReadAdapterLocalRAM =                0x1B,
559   BusLogic_WriteBusMasterChipFIFO =             0x1C,
560   BusLogic_ReadBusMasterChipFIFO =              0x1D,
561   BusLogic_EchoCommandData =                    0x1F,
562   BusLogic_HostAdapterDiagnostic =              0x20,
563   BusLogic_SetAdapterOptions =                  0x21,
564   BusLogic_InquireInstalledDevicesID8to15 =     0x23,
565   BusLogic_InquireTargetDevices =               0x24,
566   BusLogic_DisableHostAdapterInterrupt =        0x25,
567   BusLogic_InitializeExtendedMailbox =          0x81,
568   BusLogic_ExecuteSCSICommand =                 0x83,
569   BusLogic_InquireFirmwareVersion3rdDigit =     0x84,
570   BusLogic_InquireFirmwareVersionLetter =       0x85,
571   BusLogic_InquirePCIHostAdapterInformation =   0x86,
572   BusLogic_InquireHostAdapterModelNumber =      0x8B,
573   BusLogic_InquireSynchronousPeriod =           0x8C,
574   BusLogic_InquireExtendedSetupInformation =    0x8D,
575   BusLogic_EnableStrictRoundRobinMode =         0x8F,
576   BusLogic_StoreHostAdapterLocalRAM =           0x90,
577   BusLogic_FetchHostAdapterLocalRAM =           0x91,
578   BusLogic_StoreLocalDataInEEPROM =             0x92,
579   BusLogic_UploadAutoSCSICode =                 0x94,
580   BusLogic_ModifyIOAddress =                    0x95,
581   BusLogic_SetCCBFormat =                       0x96,
582   BusLogic_WriteInquiryBuffer =                 0x9A,
583   BusLogic_ReadInquiryBuffer =                  0x9B,
584   BusLogic_FlashROMUploadDownload =             0xA7,
585   BusLogic_ReadSCAMData =                       0xA8,
586   BusLogic_WriteSCAMData =                      0xA9
587 }
588 BusLogic_OperationCode_T;
589 
590 
591 /*
592   Define the Inquire Board ID reply structure.
593 */
594 
595 typedef struct BusLogic_BoardID
596 {
597   unsigned char BoardType;                              /* Byte 0 */
598   unsigned char CustomFeatures;                         /* Byte 1 */
599   unsigned char FirmwareVersion1stDigit;                /* Byte 2 */
600   unsigned char FirmwareVersion2ndDigit;                /* Byte 3 */
601 }
602 BusLogic_BoardID_T;
603 
604 
605 /*
606   Define the Inquire Installed Devices ID 0 to 7 and Inquire Installed
607   Devices ID 8 to 15 reply type.  For each Target Device, a byte is returned
608   where bit 0 set indicates that Logical Unit 0 exists, bit 1 set indicates
609   that Logical Unit 1 exists, and so on.
610 */
611 
612 typedef unsigned char BusLogic_InstalledDevices8_T[8];
613 
614 
615 /*
616   Define the Inquire Target Devices reply type.  Inquire Target Devices only
617   tests Logical Unit 0 of each Target Device unlike the Inquire Installed
618   Devices commands which test Logical Units 0 - 7.  Two bytes are returned,
619   where byte 0 bit 0 set indicates that Target Device 0 exists, and so on.
620 */
621 
622 typedef unsigned short BusLogic_InstalledDevices_T;
623 
624 
625 /*
626   Define the Inquire Configuration reply structure.
627 */
628 
629 typedef struct BusLogic_Configuration
630 {
631   unsigned char :5;                                     /* Byte 0 Bits 0-4 */
632   boolean DMA_Channel5:1;                               /* Byte 0 Bit 5 */
633   boolean DMA_Channel6:1;                               /* Byte 0 Bit 6 */
634   boolean DMA_Channel7:1;                               /* Byte 0 Bit 7 */
635   boolean IRQ_Channel9:1;                               /* Byte 1 Bit 0 */
636   boolean IRQ_Channel10:1;                              /* Byte 1 Bit 1 */
637   boolean IRQ_Channel11:1;                              /* Byte 1 Bit 2 */
638   boolean IRQ_Channel12:1;                              /* Byte 1 Bit 3 */
639   unsigned char :1;                                     /* Byte 1 Bit 4 */
640   boolean IRQ_Channel14:1;                              /* Byte 1 Bit 5 */
641   boolean IRQ_Channel15:1;                              /* Byte 1 Bit 6 */
642   unsigned char :1;                                     /* Byte 1 Bit 7 */
643   unsigned char HostAdapterID:4;                        /* Byte 2 Bits 0-3 */
644   unsigned char :4;                                     /* Byte 2 Bits 4-7 */
645 }
646 BusLogic_Configuration_T;
647 
648 
649 /*
650   Define the Inquire Setup Information reply structure.
651 */
652 
653 typedef struct BusLogic_SynchronousValue
654 {
655   unsigned char Offset:4;                               /* Bits 0-3 */
656   unsigned char TransferPeriod:3;                       /* Bits 4-6 */
657   boolean Synchronous:1;                                /* Bit 7 */
658 }
659 BusLogic_SynchronousValue_T;
660 
661 typedef BusLogic_SynchronousValue_T
662   BusLogic_SynchronousValues8_T[8];
663 
664 typedef BusLogic_SynchronousValue_T
665   BusLogic_SynchronousValues_T[BusLogic_MaxTargetDevices];
666 
667 typedef struct BusLogic_SetupInformation
668 {
669   boolean SynchronousInitiationEnabled:1;               /* Byte 0 Bit 0 */
670   boolean ParityCheckingEnabled:1;                      /* Byte 0 Bit 1 */
671   unsigned char :6;                                     /* Byte 0 Bits 2-7 */
672   unsigned char BusTransferRate;                        /* Byte 1 */
673   unsigned char PreemptTimeOnBus;                       /* Byte 2 */
674   unsigned char TimeOffBus;                             /* Byte 3 */
675   unsigned char MailboxCount;                           /* Byte 4 */
676   unsigned char MailboxAddress[3];                      /* Bytes 5-7 */
677   BusLogic_SynchronousValues8_T SynchronousValuesID0to7; /* Bytes 8-15 */
678   unsigned char DisconnectPermittedID0to7;              /* Byte 16 */
679   unsigned char Signature;                              /* Byte 17 */
680   unsigned char CharacterD;                             /* Byte 18 */
681   unsigned char HostBusType;                            /* Byte 19 */
682   unsigned char WideTransfersPermittedID0to7;           /* Byte 20 */
683   unsigned char WideTransfersActiveID0to7;              /* Byte 21 */
684   BusLogic_SynchronousValues8_T SynchronousValuesID8to15; /* Bytes 22-29 */
685   unsigned char DisconnectPermittedID8to15;             /* Byte 30 */
686   unsigned char :8;                                     /* Byte 31 */
687   unsigned char WideTransfersPermittedID8to15;          /* Byte 32 */
688   unsigned char WideTransfersActiveID8to15;             /* Byte 33 */
689 }
690 BusLogic_SetupInformation_T;
691 
692 
693 /*
694   Define the Initialize Extended Mailbox request structure.
695 */
696 
697 typedef struct BusLogic_ExtendedMailboxRequest
698 {
699   unsigned char MailboxCount;                           /* Byte 0 */
700   BusLogic_BusAddress_T BaseMailboxAddress;             /* Bytes 1-4 */
701 }
702 __attribute__ ((packed))
703 BusLogic_ExtendedMailboxRequest_T;
704 
705 
706 /*
707   Define the Inquire Firmware Version 3rd Digit reply type.
708 */
709 
710 typedef unsigned char BusLogic_FirmwareVersion3rdDigit_T;
711 
712 
713 /*
714   Define the Inquire Firmware Version Letter reply type.
715 */
716 
717 typedef unsigned char BusLogic_FirmwareVersionLetter_T;
718 
719 
720 /*
721   Define the Inquire PCI Host Adapter Information reply type.  The ISA
722   Compatible I/O Port values are defined here and are also used with
723   the Modify I/O Address command.
724 */
725 
726 typedef enum BusLogic_ISACompatibleIOPort
727 {
728   BusLogic_IO_330 =                             0,
729   BusLogic_IO_334 =                             1,
730   BusLogic_IO_230 =                             2,
731   BusLogic_IO_234 =                             3,
732   BusLogic_IO_130 =                             4,
733   BusLogic_IO_134 =                             5,
734   BusLogic_IO_Disable =                         6,
735   BusLogic_IO_Disable2 =                        7
736 }
737 __attribute__ ((packed))
738 BusLogic_ISACompatibleIOPort_T;
739 
740 typedef struct BusLogic_PCIHostAdapterInformation
741 {
742   BusLogic_ISACompatibleIOPort_T ISACompatibleIOPort;   /* Byte 0 */
743   unsigned char PCIAssignedIRQChannel;                  /* Byte 1 */
744   boolean LowByteTerminated:1;                          /* Byte 2 Bit 0 */
745   boolean HighByteTerminated:1;                         /* Byte 2 Bit 1 */
746   unsigned char :2;                                     /* Byte 2 Bits 2-3 */
747   boolean JP1:1;                                        /* Byte 2 Bit 4 */
748   boolean JP2:1;                                        /* Byte 2 Bit 5 */
749   boolean JP3:1;                                        /* Byte 2 Bit 6 */
750   boolean GenericInfoValid:1;                           /* Byte 2 Bit 7 */
751   unsigned char :8;                                     /* Byte 3 */
752 }
753 BusLogic_PCIHostAdapterInformation_T;
754 
755 
756 /*
757   Define the Inquire Host Adapter Model Number reply type.
758 */
759 
760 typedef unsigned char BusLogic_HostAdapterModelNumber_T[5];
761 
762 
763 /*
764   Define the Inquire Synchronous Period reply type.  For each Target Device,
765   a byte is returned which represents the Synchronous Transfer Period in units
766   of 10 nanoseconds.
767 */
768 
769 typedef unsigned char BusLogic_SynchronousPeriod_T[BusLogic_MaxTargetDevices];
770 
771 
772 /*
773   Define the Inquire Extended Setup Information reply structure.
774 */
775 
776 typedef struct BusLogic_ExtendedSetupInformation
777 {
778   unsigned char BusType;                                /* Byte 0 */
779   unsigned char BIOS_Address;                           /* Byte 1 */
780   unsigned short ScatterGatherLimit;                    /* Bytes 2-3 */
781   unsigned char MailboxCount;                           /* Byte 4 */
782   BusLogic_BusAddress_T BaseMailboxAddress;             /* Bytes 5-8 */
783   struct { unsigned char :2;                            /* Byte 9 Bits 0-1 */
784            boolean FastOnEISA:1;                        /* Byte 9 Bit 2 */
785            unsigned char :3;                            /* Byte 9 Bits 3-5 */
786            boolean LevelSensitiveInterrupt:1;           /* Byte 9 Bit 6 */
787            unsigned char :1; } Misc;                    /* Byte 9 Bit 7 */
788   unsigned char FirmwareRevision[3];                    /* Bytes 10-12 */
789   boolean HostWideSCSI:1;                               /* Byte 13 Bit 0 */
790   boolean HostDifferentialSCSI:1;                       /* Byte 13 Bit 1 */
791   boolean HostSupportsSCAM:1;                           /* Byte 13 Bit 2 */
792   boolean HostUltraSCSI:1;                              /* Byte 13 Bit 3 */
793   boolean HostSmartTermination:1;                       /* Byte 13 Bit 4 */
794   unsigned char :3;                                     /* Byte 13 Bits 5-7 */
795 }
796 __attribute__ ((packed))
797 BusLogic_ExtendedSetupInformation_T;
798 
799 
800 /*
801   Define the Enable Strict Round Robin Mode request type.
802 */
803 
804 typedef enum BusLogic_RoundRobinModeRequest
805 {
806   BusLogic_AggressiveRoundRobinMode =           0,
807   BusLogic_StrictRoundRobinMode =               1
808 }
809 __attribute__ ((packed))
810 BusLogic_RoundRobinModeRequest_T;
811 
812 
813 /*
814   Define the Fetch Host Adapter Local RAM request type.
815 */
816 
817 #define BusLogic_BIOS_BaseOffset                0
818 #define BusLogic_AutoSCSI_BaseOffset            64
819 
820 typedef struct BusLogic_FetchHostAdapterLocalRAMRequest
821 {
822   unsigned char ByteOffset;                             /* Byte 0 */
823   unsigned char ByteCount;                              /* Byte 1 */
824 }
825 BusLogic_FetchHostAdapterLocalRAMRequest_T;
826 
827 
828 /*
829   Define the Host Adapter Local RAM AutoSCSI structure.
830 */
831 
832 typedef struct BusLogic_AutoSCSIData
833 {
834   unsigned char InternalFactorySignature[2];            /* Bytes 0-1 */
835   unsigned char InformationByteCount;                   /* Byte 2 */
836   unsigned char HostAdapterType[6];                     /* Bytes 3-8 */
837   unsigned char :8;                                     /* Byte 9 */
838   boolean FloppyEnabled:1;                              /* Byte 10 Bit 0 */
839   boolean FloppySecondary:1;                            /* Byte 10 Bit 1 */
840   boolean LevelSensitiveInterrupt:1;                    /* Byte 10 Bit 2 */
841   unsigned char :2;                                     /* Byte 10 Bits 3-4 */
842   unsigned char SystemRAMAreaForBIOS:3;                 /* Byte 10 Bits 5-7 */
843   unsigned char DMA_Channel:7;                          /* Byte 11 Bits 0-6 */
844   boolean DMA_AutoConfiguration:1;                      /* Byte 11 Bit 7 */
845   unsigned char IRQ_Channel:7;                          /* Byte 12 Bits 0-6 */
846   boolean IRQ_AutoConfiguration:1;                      /* Byte 12 Bit 7 */
847   unsigned char DMA_TransferRate;                       /* Byte 13 */
848   unsigned char SCSI_ID;                                /* Byte 14 */
849   boolean LowByteTerminated:1;                          /* Byte 15 Bit 0 */
850   boolean ParityCheckingEnabled:1;                      /* Byte 15 Bit 1 */
851   boolean HighByteTerminated:1;                         /* Byte 15 Bit 2 */
852   boolean NoisyCablingEnvironment:1;                    /* Byte 15 Bit 3 */
853   boolean FastSynchronousNegotiation:1;                 /* Byte 15 Bit 4 */
854   boolean BusResetEnabled:1;                            /* Byte 15 Bit 5 */
855   boolean :1;                                           /* Byte 15 Bit 6 */
856   boolean ActiveNegationEnabled:1;                      /* Byte 15 Bit 7 */
857   unsigned char BusOnDelay;                             /* Byte 16 */
858   unsigned char BusOffDelay;                            /* Byte 17 */
859   boolean HostAdapterBIOSEnabled:1;                     /* Byte 18 Bit 0 */
860   boolean BIOSRedirectionOfINT19Enabled:1;              /* Byte 18 Bit 1 */
861   boolean ExtendedTranslationEnabled:1;                 /* Byte 18 Bit 2 */
862   boolean MapRemovableAsFixedEnabled:1;                 /* Byte 18 Bit 3 */
863   boolean :1;                                           /* Byte 18 Bit 4 */
864   boolean BIOSSupportsMoreThan2DrivesEnabled:1;         /* Byte 18 Bit 5 */
865   boolean BIOSInterruptModeEnabled:1;                   /* Byte 18 Bit 6 */
866   boolean FlopticalSupportEnabled:1;                    /* Byte 19 Bit 7 */
867   unsigned short DeviceEnabled;                         /* Bytes 19-20 */
868   unsigned short WidePermitted;                         /* Bytes 21-22 */
869   unsigned short FastPermitted;                         /* Bytes 23-24 */
870   unsigned short SynchronousPermitted;                  /* Bytes 25-26 */
871   unsigned short DisconnectPermitted;                   /* Bytes 27-28 */
872   unsigned short SendStartUnitCommand;                  /* Bytes 29-30 */
873   unsigned short IgnoreInBIOSScan;                      /* Bytes 31-32 */
874   unsigned char PCIInterruptPin:2;                      /* Byte 33 Bits 0-1 */
875   unsigned char HostAdapterIOPortAddress:2;             /* Byte 33 Bits 2-3 */
876   boolean StrictRoundRobinModeEnabled:1;                /* Byte 33 Bit 4 */
877   boolean VESABusSpeedGreaterThan33MHz:1;               /* Byte 33 Bit 5 */
878   boolean VESABurstWriteEnabled:1;                      /* Byte 33 Bit 6 */
879   boolean VESABurstReadEnabled:1;                       /* Byte 33 Bit 7 */
880   unsigned short UltraPermitted;                        /* Bytes 34-35 */
881   unsigned int :32;                                     /* Bytes 36-39 */
882   unsigned char :8;                                     /* Byte 40 */
883   unsigned char AutoSCSIMaximumLUN;                     /* Byte 41 */
884   boolean :1;                                           /* Byte 42 Bit 0 */
885   boolean SCAM_Dominant:1;                              /* Byte 42 Bit 1 */
886   boolean SCAM_Enabled:1;                               /* Byte 42 Bit 2 */
887   boolean SCAM_Level2:1;                                /* Byte 42 Bit 3 */
888   unsigned char :4;                                     /* Byte 42 Bits 4-7 */
889   boolean INT13ExtensionEnabled:1;                      /* Byte 43 Bit 0 */
890   boolean :1;                                           /* Byte 43 Bit 1 */
891   boolean CDROMBootEnabled:1;                           /* Byte 43 Bit 2 */
892   unsigned char :5;                                     /* Byte 43 Bits 3-7 */
893   unsigned char BootTargetID:4;                         /* Byte 44 Bits 0-3 */
894   unsigned char BootChannel:4;                          /* Byte 44 Bits 4-7 */
895   unsigned char ForceBusDeviceScanningOrder:1;          /* Byte 45 Bit 0 */
896   unsigned char :7;                                     /* Byte 45 Bits 1-7 */
897   unsigned short NonTaggedToAlternateLUNPermitted;      /* Bytes 46-47 */
898   unsigned short RenegotiateSyncAfterCheckCondition;    /* Bytes 48-49 */
899   unsigned char Reserved[10];                           /* Bytes 50-59 */
900   unsigned char ManufacturingDiagnostic[2];             /* Bytes 60-61 */
901   unsigned short Checksum;                              /* Bytes 62-63 */
902 }
903 __attribute__ ((packed))
904 BusLogic_AutoSCSIData_T;
905 
906 
907 /*
908   Define the Host Adapter Local RAM Auto SCSI Byte 45 structure.
909 */
910 
911 typedef struct BusLogic_AutoSCSIByte45
912 {
913   unsigned char ForceBusDeviceScanningOrder:1;          /* Bit 0 */
914   unsigned char :7;                                     /* Bits 1-7 */
915 }
916 BusLogic_AutoSCSIByte45_T;
917 
918 
919 /*
920   Define the Host Adapter Local RAM BIOS Drive Map Byte structure.
921 */
922 
923 #define BusLogic_BIOS_DriveMapOffset            17
924 
925 typedef struct BusLogic_BIOSDriveMapByte
926 {
927   unsigned char TargetIDBit3:1;                         /* Bit 0 */
928   unsigned char :2;                                     /* Bits 1-2 */
929   BusLogic_BIOS_DiskGeometryTranslation_T DiskGeometry:2; /* Bits 3-4 */
930   unsigned char TargetID:3;                             /* Bits 5-7 */
931 }
932 BusLogic_BIOSDriveMapByte_T;
933 
934 
935 /*
936   Define the Modify I/O Address request type.  On PCI Host Adapters, the
937   Modify I/O Address command allows modification of the ISA compatible I/O
938   Address that the Host Adapter responds to; it does not affect the PCI
939   compliant I/O Address assigned at system initialization.
940 */
941 
942 typedef BusLogic_ISACompatibleIOPort_T BusLogic_ModifyIOAddressRequest_T;
943 
944 
945 /*
946   Define the Set CCB Format request type.  Extended LUN Format CCBs are
947   necessary to support more than 8 Logical Units per Target Device.
948 */
949 
950 typedef enum BusLogic_SetCCBFormatRequest
951 {
952   BusLogic_LegacyLUNFormatCCB =                 0,
953   BusLogic_ExtendedLUNFormatCCB =               1
954 }
955 __attribute__ ((packed))
956 BusLogic_SetCCBFormatRequest_T;
957 
958 
959 /*
960   Define the Requested Reply Length type used by the Inquire Setup Information,
961   Inquire Host Adapter Model Number, Inquire Synchronous Period, and Inquire
962   Extended Setup Information commands.
963 */
964 
965 typedef unsigned char BusLogic_RequestedReplyLength_T;
966 
967 
968 /*
969   Define the Outgoing Mailbox Action Codes.
970 */
971 
972 typedef enum
973 {
974   BusLogic_OutgoingMailboxFree =                0x00,
975   BusLogic_MailboxStartCommand =                0x01,
976   BusLogic_MailboxAbortCommand =                0x02
977 }
978 __attribute__ ((packed))
979 BusLogic_ActionCode_T;
980 
981 
982 /*
983   Define the Incoming Mailbox Completion Codes.  The MultiMaster Firmware
984   only uses codes 0 - 4.  The FlashPoint SCCB Manager has no mailboxes, so
985   completion codes are stored in the CCB; it only uses codes 1, 2, 4, and 5.
986 */
987 
988 typedef enum
989 {
990   BusLogic_IncomingMailboxFree =                0x00,
991   BusLogic_CommandCompletedWithoutError =       0x01,
992   BusLogic_CommandAbortedAtHostRequest =        0x02,
993   BusLogic_AbortedCommandNotFound =             0x03,
994   BusLogic_CommandCompletedWithError =          0x04,
995   BusLogic_InvalidCCB =                         0x05
996 }
997 __attribute__ ((packed))
998 BusLogic_CompletionCode_T;
999 
1000 
1001 /*
1002   Define the Command Control Block (CCB) Opcodes.
1003 */
1004 
1005 typedef enum
1006 {
1007   BusLogic_InitiatorCCB =                       0x00,
1008   BusLogic_TargetCCB =                          0x01,
1009   BusLogic_InitiatorCCB_ScatterGather =         0x02,
1010   BusLogic_InitiatorCCB_ResidualDataLength =    0x03,
1011   BusLogic_InitiatorCCB_ScatterGatherResidual = 0x04,
1012   BusLogic_BusDeviceReset =                     0x81
1013 }
1014 __attribute__ ((packed))
1015 BusLogic_CCB_Opcode_T;
1016 
1017 
1018 /*
1019   Define the CCB Data Direction Codes.
1020 */
1021 
1022 typedef enum
1023 {
1024   BusLogic_UncheckedDataTransfer =              0,
1025   BusLogic_DataInLengthChecked =                1,
1026   BusLogic_DataOutLengthChecked =               2,
1027   BusLogic_NoDataTransfer =                     3
1028 }
1029 BusLogic_DataDirection_T;
1030 
1031 
1032 /*
1033   Define the Host Adapter Status Codes.  The MultiMaster Firmware does not
1034   return status code 0x0C; it uses 0x12 for both overruns and underruns.
1035 */
1036 
1037 typedef enum
1038 {
1039   BusLogic_CommandCompletedNormally =           0x00,
1040   BusLogic_LinkedCommandCompleted =             0x0A,
1041   BusLogic_LinkedCommandCompletedWithFlag =     0x0B,
1042   BusLogic_DataUnderRun =                       0x0C,
1043   BusLogic_SCSISelectionTimeout =               0x11,
1044   BusLogic_DataOverRun =                        0x12,
1045   BusLogic_UnexpectedBusFree =                  0x13,
1046   BusLogic_InvalidBusPhaseRequested =           0x14,
1047   BusLogic_InvalidOutgoingMailboxActionCode =   0x15,
1048   BusLogic_InvalidCommandOperationCode =        0x16,
1049   BusLogic_LinkedCCBhasInvalidLUN =             0x17,
1050   BusLogic_InvalidCommandParameter =            0x1A,
1051   BusLogic_AutoRequestSenseFailed =             0x1B,
1052   BusLogic_TaggedQueuingMessageRejected =       0x1C,
1053   BusLogic_UnsupportedMessageReceived =         0x1D,
1054   BusLogic_HostAdapterHardwareFailed =          0x20,
1055   BusLogic_TargetFailedResponseToATN =          0x21,
1056   BusLogic_HostAdapterAssertedRST =             0x22,
1057   BusLogic_OtherDeviceAssertedRST =             0x23,
1058   BusLogic_TargetDeviceReconnectedImproperly =  0x24,
1059   BusLogic_HostAdapterAssertedBusDeviceReset =  0x25,
1060   BusLogic_AbortQueueGenerated =                0x26,
1061   BusLogic_HostAdapterSoftwareError =           0x27,
1062   BusLogic_HostAdapterHardwareTimeoutError =    0x30,
1063   BusLogic_SCSIParityErrorDetected =            0x34
1064 }
1065 __attribute__ ((packed))
1066 BusLogic_HostAdapterStatus_T;
1067 
1068 
1069 /*
1070   Define the SCSI Target Device Status Codes.
1071 */
1072 
1073 typedef enum
1074 {
1075   BusLogic_OperationGood =                      0x00,
1076   BusLogic_CheckCondition =                     0x02,
1077   BusLogic_DeviceBusy =                         0x08
1078 }
1079 __attribute__ ((packed))
1080 BusLogic_TargetDeviceStatus_T;
1081 
1082 
1083 /*
1084   Define the Queue Tag Codes.
1085 */
1086 
1087 typedef enum
1088 {
1089   BusLogic_SimpleQueueTag =                     0,
1090   BusLogic_HeadOfQueueTag =                     1,
1091   BusLogic_OrderedQueueTag =                    2,
1092   BusLogic_ReservedQT =                         3
1093 }
1094 BusLogic_QueueTag_T;
1095 
1096 
1097 /*
1098   Define the SCSI Command Descriptor Block (CDB).
1099 */
1100 
1101 #define BusLogic_CDB_MaxLength                  12
1102 
1103 typedef unsigned char SCSI_CDB_T[BusLogic_CDB_MaxLength];
1104 
1105 
1106 /*
1107   Define the Scatter/Gather Segment structure required by the MultiMaster
1108   Firmware Interface and the FlashPoint SCCB Manager.
1109 */
1110 
1111 typedef struct BusLogic_ScatterGatherSegment
1112 {
1113   BusLogic_ByteCount_T SegmentByteCount;                /* Bytes 0-3 */
1114   BusLogic_BusAddress_T SegmentDataPointer;             /* Bytes 4-7 */
1115 }
1116 BusLogic_ScatterGatherSegment_T;
1117 
1118 
1119 /*
1120   Define the Driver CCB Status Codes.
1121 */
1122 
1123 typedef enum
1124 {
1125   BusLogic_CCB_Free =                           0,
1126   BusLogic_CCB_Active =                         1,
1127   BusLogic_CCB_Completed =                      2,
1128   BusLogic_CCB_Reset =                          3
1129 }
1130 __attribute__ ((packed))
1131 BusLogic_CCB_Status_T;
1132 
1133 
1134 /*
1135   Define the 32 Bit Mode Command Control Block (CCB) structure.  The first 40
1136   bytes are defined by and common to both the MultiMaster Firmware and the
1137   FlashPoint SCCB Manager.  The next 60 bytes are defined by the FlashPoint
1138   SCCB Manager.  The remaining components are defined by the Linux BusLogic
1139   Driver.  Extended LUN Format CCBs differ from Legacy LUN Format 32 Bit Mode
1140   CCBs only in having the TagEnable and QueueTag fields moved from byte 17 to
1141   byte 1, and the Logical Unit field in byte 17 expanded to 6 bits.  In theory,
1142   Extended LUN Format CCBs can support up to 64 Logical Units, but in practice
1143   many devices will respond improperly to Logical Units between 32 and 63, and
1144   the SCSI-2 specification defines Bit 5 as LUNTAR.  Extended LUN Format CCBs
1145   are used by recent versions of the MultiMaster Firmware, as well as by the
1146   FlashPoint SCCB Manager; the FlashPoint SCCB Manager only supports 32 Logical
1147   Units.  Since 64 Logical Units are unlikely to be needed in practice, and
1148   since they are problematic for the above reasons, and since limiting them to
1149   5 bits simplifies the CCB structure definition, this driver only supports
1150   32 Logical Units per Target Device.
1151 */
1152 
1153 typedef struct BusLogic_CCB
1154 {
1155   /*
1156     MultiMaster Firmware and FlashPoint SCCB Manager Common Portion.
1157   */
1158   BusLogic_CCB_Opcode_T Opcode;                         /* Byte 0 */
1159   unsigned char :3;                                     /* Byte 1 Bits 0-2 */
1160   BusLogic_DataDirection_T DataDirection:2;             /* Byte 1 Bits 3-4 */
1161   boolean TagEnable:1;                                  /* Byte 1 Bit 5 */
1162   BusLogic_QueueTag_T QueueTag:2;                       /* Byte 1 Bits 6-7 */
1163   unsigned char CDB_Length;                             /* Byte 2 */
1164   unsigned char SenseDataLength;                        /* Byte 3 */
1165   BusLogic_ByteCount_T DataLength;                      /* Bytes 4-7 */
1166   BusLogic_BusAddress_T DataPointer;                    /* Bytes 8-11 */
1167   unsigned char :8;                                     /* Byte 12 */
1168   unsigned char :8;                                     /* Byte 13 */
1169   BusLogic_HostAdapterStatus_T HostAdapterStatus;       /* Byte 14 */
1170   BusLogic_TargetDeviceStatus_T TargetDeviceStatus;     /* Byte 15 */
1171   unsigned char TargetID;                               /* Byte 16 */
1172   unsigned char LogicalUnit:5;                          /* Byte 17 Bits 0-4 */
1173   boolean LegacyTagEnable:1;                            /* Byte 17 Bit 5 */
1174   BusLogic_QueueTag_T LegacyQueueTag:2;                 /* Byte 17 Bits 6-7 */
1175   SCSI_CDB_T CDB;                                       /* Bytes 18-29 */
1176   unsigned char :8;                                     /* Byte 30 */
1177   unsigned char :8;                                     /* Byte 31 */
1178   unsigned int :32;                                     /* Bytes 32-35 */
1179   BusLogic_BusAddress_T SenseDataPointer;               /* Bytes 36-39 */
1180   /*
1181     FlashPoint SCCB Manager Defined Portion.
1182   */
1183   void (*CallbackFunction)(struct BusLogic_CCB *);      /* Bytes 40-43 */
1184   BusLogic_Base_Address_T BaseAddress;                  /* Bytes 44-47 */
1185   BusLogic_CompletionCode_T CompletionCode;             /* Byte 48 */
1186 #ifndef CONFIG_SCSI_OMIT_FLASHPOINT
1187   unsigned char :8;                                     /* Byte 49 */
1188   unsigned short OS_Flags;                              /* Bytes 50-51 */
1189   unsigned char Private[48];                            /* Bytes 52-99 */
1190 #endif
1191   /*
1192     BusLogic Linux Driver Defined Portion.
1193   */
1194   boolean AllocationGroupHead;
1195   BusLogic_CCB_Status_T Status;
1196   unsigned long SerialNumber;
1197   SCSI_Command_T *Command;
1198   struct BusLogic_HostAdapter *HostAdapter;
1199   struct BusLogic_CCB *Next;
1200   struct BusLogic_CCB *NextAll;
1201   BusLogic_ScatterGatherSegment_T
1202     ScatterGatherList[BusLogic_ScatterGatherLimit];
1203 }
1204 BusLogic_CCB_T;
1205 
1206 
1207 /*
1208   Define the 32 Bit Mode Outgoing Mailbox structure.
1209 */
1210 
1211 typedef struct BusLogic_OutgoingMailbox
1212 {
1213   BusLogic_BusAddress_T CCB;                            /* Bytes 0-3 */
1214   unsigned int :24;                                     /* Bytes 4-6 */
1215   BusLogic_ActionCode_T ActionCode;                     /* Byte 7 */
1216 }
1217 BusLogic_OutgoingMailbox_T;
1218 
1219 
1220 /*
1221   Define the 32 Bit Mode Incoming Mailbox structure.
1222 */
1223 
1224 typedef struct BusLogic_IncomingMailbox
1225 {
1226   BusLogic_BusAddress_T CCB;                            /* Bytes 0-3 */
1227   BusLogic_HostAdapterStatus_T HostAdapterStatus;       /* Byte 4 */
1228   BusLogic_TargetDeviceStatus_T TargetDeviceStatus;     /* Byte 5 */
1229   unsigned char :8;                                     /* Byte 6 */
1230   BusLogic_CompletionCode_T CompletionCode;             /* Byte 7 */
1231 }
1232 BusLogic_IncomingMailbox_T;
1233 
1234 
1235 /*
1236   Define the BusLogic Driver Options structure.
1237 */
1238 
1239 typedef struct BusLogic_DriverOptions
1240 {
1241   unsigned short TaggedQueuingPermitted;
1242   unsigned short TaggedQueuingPermittedMask;
1243   unsigned short BusSettleTime;
1244   BusLogic_LocalOptions_T LocalOptions;
1245   unsigned char CommonQueueDepth;
1246   unsigned char QueueDepth[BusLogic_MaxTargetDevices];
1247   BusLogic_ErrorRecoveryStrategy_T
1248     ErrorRecoveryStrategy[BusLogic_MaxTargetDevices];
1249 }
1250 BusLogic_DriverOptions_T;
1251 
1252 
1253 /*
1254   Define the Host Adapter Target Flags structure.
1255 */
1256 
1257 typedef struct BusLogic_TargetFlags
1258 {
1259   boolean TargetExists:1;
1260   boolean TaggedQueuingSupported:1;
1261   boolean WideTransfersSupported:1;
1262   boolean TaggedQueuingActive:1;
1263   boolean WideTransfersActive:1;
1264   boolean CommandSuccessfulFlag:1;
1265   boolean TargetInfoReported:1;
1266 }
1267 BusLogic_TargetFlags_T;
1268 
1269 
1270 /*
1271   Define the Host Adapter Target Statistics structure.
1272 */
1273 
1274 #define BusLogic_SizeBuckets                    10
1275 
1276 typedef unsigned int BusLogic_CommandSizeBuckets_T[BusLogic_SizeBuckets];
1277 
1278 typedef struct BusLogic_TargetStatistics
1279 {
1280   unsigned int CommandsAttempted;
1281   unsigned int CommandsCompleted;
1282   unsigned int ReadCommands;
1283   unsigned int WriteCommands;
1284   BusLogic_ByteCounter_T TotalBytesRead;
1285   BusLogic_ByteCounter_T TotalBytesWritten;
1286   BusLogic_CommandSizeBuckets_T ReadCommandSizeBuckets;
1287   BusLogic_CommandSizeBuckets_T WriteCommandSizeBuckets;
1288   unsigned short CommandAbortsRequested;
1289   unsigned short CommandAbortsAttempted;
1290   unsigned short CommandAbortsCompleted;
1291   unsigned short BusDeviceResetsRequested;
1292   unsigned short BusDeviceResetsAttempted;
1293   unsigned short BusDeviceResetsCompleted;
1294   unsigned short HostAdapterResetsRequested;
1295   unsigned short HostAdapterResetsAttempted;
1296   unsigned short HostAdapterResetsCompleted;
1297 }
1298 BusLogic_TargetStatistics_T;
1299 
1300 
1301 /*
1302   Define the FlashPoint Card Handle data type.
1303 */
1304 
1305 #define FlashPoint_BadCardHandle                0xFFFFFFFF
1306 
1307 typedef unsigned int FlashPoint_CardHandle_T;
1308 
1309 
1310 /*
1311   Define the FlashPoint Information structure.  This structure is defined
1312   by the FlashPoint SCCB Manager.
1313 */
1314 
1315 typedef struct FlashPoint_Info
1316 {
1317   BusLogic_Base_Address_T BaseAddress;                  /* Bytes 0-3 */
1318   boolean Present;                                      /* Byte 4 */
1319   unsigned char IRQ_Channel;                            /* Byte 5 */
1320   unsigned char SCSI_ID;                                /* Byte 6 */
1321   unsigned char SCSI_LUN;                               /* Byte 7 */
1322   unsigned short FirmwareRevision;                      /* Bytes 8-9 */
1323   unsigned short SynchronousPermitted;                  /* Bytes 10-11 */
1324   unsigned short FastPermitted;                         /* Bytes 12-13 */
1325   unsigned short UltraPermitted;                        /* Bytes 14-15 */
1326   unsigned short DisconnectPermitted;                   /* Bytes 16-17 */
1327   unsigned short WidePermitted;                         /* Bytes 18-19 */
1328   boolean ParityCheckingEnabled:1;                      /* Byte 20 Bit 0 */
1329   boolean HostWideSCSI:1;                               /* Byte 20 Bit 1 */
1330   boolean HostSoftReset:1;                              /* Byte 20 Bit 2 */
1331   boolean ExtendedTranslationEnabled:1;                 /* Byte 20 Bit 3 */
1332   boolean LowByteTerminated:1;                          /* Byte 20 Bit 4 */
1333   boolean HighByteTerminated:1;                         /* Byte 20 Bit 5 */
1334   boolean ReportDataUnderrun:1;                         /* Byte 20 Bit 6 */
1335   boolean SCAM_Enabled:1;                               /* Byte 20 Bit 7 */
1336   boolean SCAM_Level2:1;                                /* Byte 21 Bit 0 */
1337   unsigned char :7;                                     /* Byte 21 Bits 1-7 */
1338   unsigned char Family;                                 /* Byte 22 */
1339   unsigned char BusType;                                /* Byte 23 */
1340   unsigned char ModelNumber[3];                         /* Bytes 24-26 */
1341   unsigned char RelativeCardNumber;                     /* Byte 27 */
1342   unsigned char Reserved[4];                            /* Bytes 28-31 */
1343   unsigned int OS_Reserved;                             /* Bytes 32-35 */
1344   unsigned char TranslationInfo[4];                     /* Bytes 36-39 */
1345   unsigned int Reserved2[5];                            /* Bytes 40-59 */
1346   unsigned int SecondaryRange;                          /* Bytes 60-63 */
1347 }
1348 FlashPoint_Info_T;
1349 
1350 
1351 /*
1352   Define the BusLogic Driver Host Adapter structure.
1353 */
1354 
1355 typedef struct BusLogic_HostAdapter
1356 {
1357   SCSI_Host_T *SCSI_Host;
1358   BusLogic_HostAdapterType_T HostAdapterType;
1359   BusLogic_HostAdapterBusType_T HostAdapterBusType;
1360   BusLogic_IO_Address_T IO_Address;
1361   BusLogic_PCI_Address_T PCI_Address;
1362   unsigned short AddressCount;
1363   unsigned char HostNumber;
1364   unsigned char ModelName[9];
1365   unsigned char FirmwareVersion[6];
1366   unsigned char FullModelName[18];
1367   unsigned char Bus;
1368   unsigned char Device;
1369   unsigned char IRQ_Channel;
1370   unsigned char DMA_Channel;
1371   unsigned char SCSI_ID;
1372   boolean IRQ_ChannelAcquired:1;
1373   boolean DMA_ChannelAcquired:1;
1374   boolean ExtendedTranslationEnabled:1;
1375   boolean ParityCheckingEnabled:1;
1376   boolean BusResetEnabled:1;
1377   boolean LevelSensitiveInterrupt:1;
1378   boolean HostWideSCSI:1;
1379   boolean HostDifferentialSCSI:1;
1380   boolean HostSupportsSCAM:1;
1381   boolean HostUltraSCSI:1;
1382   boolean ExtendedLUNSupport:1;
1383   boolean TerminationInfoValid:1;
1384   boolean LowByteTerminated:1;
1385   boolean HighByteTerminated:1;
1386   boolean BounceBuffersRequired:1;
1387   boolean StrictRoundRobinModeSupport:1;
1388   boolean SCAM_Enabled:1;
1389   boolean SCAM_Level2:1;
1390   boolean HostAdapterInitialized:1;
1391   boolean HostAdapterExternalReset:1;
1392   boolean HostAdapterInternalError:1;
1393   boolean ProcessCompletedCCBsActive;
1394   volatile boolean HostAdapterCommandCompleted;
1395   unsigned short HostAdapterScatterGatherLimit;
1396   unsigned short DriverScatterGatherLimit;
1397   unsigned short MaxTargetDevices;
1398   unsigned short MaxLogicalUnits;
1399   unsigned short MailboxCount;
1400   unsigned short InitialCCBs;
1401   unsigned short IncrementalCCBs;
1402   unsigned short AllocatedCCBs;
1403   unsigned short DriverQueueDepth;
1404   unsigned short HostAdapterQueueDepth;
1405   unsigned short UntaggedQueueDepth;
1406   unsigned short CommonQueueDepth;
1407   unsigned short BusSettleTime;
1408   unsigned short SynchronousPermitted;
1409   unsigned short FastPermitted;
1410   unsigned short UltraPermitted;
1411   unsigned short WidePermitted;
1412   unsigned short DisconnectPermitted;
1413   unsigned short TaggedQueuingPermitted;
1414   unsigned short ExternalHostAdapterResets;
1415   unsigned short HostAdapterInternalErrors;
1416   unsigned short TargetDeviceCount;
1417   unsigned short MessageBufferLength;
1418   BusLogic_BusAddress_T BIOS_Address;
1419   BusLogic_DriverOptions_T *DriverOptions;
1420   FlashPoint_Info_T FlashPointInfo;
1421   FlashPoint_CardHandle_T CardHandle;
1422   struct BusLogic_HostAdapter *Next;
1423   BusLogic_CCB_T *All_CCBs;
1424   BusLogic_CCB_T *Free_CCBs;
1425   BusLogic_CCB_T *FirstCompletedCCB;
1426   BusLogic_CCB_T *LastCompletedCCB;
1427   BusLogic_CCB_T *BusDeviceResetPendingCCB[BusLogic_MaxTargetDevices];
1428   BusLogic_ErrorRecoveryStrategy_T
1429     ErrorRecoveryStrategy[BusLogic_MaxTargetDevices];
1430   BusLogic_TargetFlags_T TargetFlags[BusLogic_MaxTargetDevices];
1431   unsigned char QueueDepth[BusLogic_MaxTargetDevices];
1432   unsigned char SynchronousPeriod[BusLogic_MaxTargetDevices];
1433   unsigned char SynchronousOffset[BusLogic_MaxTargetDevices];
1434   unsigned char ActiveCommands[BusLogic_MaxTargetDevices];
1435   unsigned int CommandsSinceReset[BusLogic_MaxTargetDevices];
1436   unsigned long LastSequencePoint[BusLogic_MaxTargetDevices];
1437   unsigned long LastResetAttempted[BusLogic_MaxTargetDevices];
1438   unsigned long LastResetCompleted[BusLogic_MaxTargetDevices];
1439   BusLogic_OutgoingMailbox_T *FirstOutgoingMailbox;
1440   BusLogic_OutgoingMailbox_T *LastOutgoingMailbox;
1441   BusLogic_OutgoingMailbox_T *NextOutgoingMailbox;
1442   BusLogic_IncomingMailbox_T *FirstIncomingMailbox;
1443   BusLogic_IncomingMailbox_T *LastIncomingMailbox;
1444   BusLogic_IncomingMailbox_T *NextIncomingMailbox;
1445   BusLogic_TargetStatistics_T TargetStatistics[BusLogic_MaxTargetDevices];
1446   unsigned char MailboxSpace[BusLogic_MaxMailboxes
1447                              * (sizeof(BusLogic_OutgoingMailbox_T)
1448                                 + sizeof(BusLogic_IncomingMailbox_T))];
1449   char MessageBuffer[BusLogic_MessageBufferSize];
1450 }
1451 BusLogic_HostAdapter_T;
1452 
1453 
1454 /*
1455   Define a structure for the BIOS Disk Parameters.
1456 */
1457 
1458 typedef struct BIOS_DiskParameters
1459 {
1460   int Heads;
1461   int Sectors;
1462   int Cylinders;
1463 }
1464 BIOS_DiskParameters_T;
1465 
1466 
1467 /*
1468   Define a structure for the SCSI Inquiry command results.
1469 */
1470 
1471 typedef struct SCSI_Inquiry
1472 {
1473   unsigned char PeripheralDeviceType:5;                 /* Byte 0 Bits 0-4 */
1474   unsigned char PeripheralQualifier:3;                  /* Byte 0 Bits 5-7 */
1475   unsigned char DeviceTypeModifier:7;                   /* Byte 1 Bits 0-6 */
1476   boolean RMB:1;                                        /* Byte 1 Bit 7 */
1477   unsigned char ANSI_ApprovedVersion:3;                 /* Byte 2 Bits 0-2 */
1478   unsigned char ECMA_Version:3;                         /* Byte 2 Bits 3-5 */
1479   unsigned char ISO_Version:2;                          /* Byte 2 Bits 6-7 */
1480   unsigned char ResponseDataFormat:4;                   /* Byte 3 Bits 0-3 */
1481   unsigned char :2;                                     /* Byte 3 Bits 4-5 */
1482   boolean TrmIOP:1;                                     /* Byte 3 Bit 6 */
1483   boolean AENC:1;                                       /* Byte 3 Bit 7 */
1484   unsigned char AdditionalLength;                       /* Byte 4 */
1485   unsigned char :8;                                     /* Byte 5 */
1486   unsigned char :8;                                     /* Byte 6 */
1487   boolean SftRe:1;                                      /* Byte 7 Bit 0 */
1488   boolean CmdQue:1;                                     /* Byte 7 Bit 1 */
1489   boolean :1;                                           /* Byte 7 Bit 2 */
1490   boolean Linked:1;                                     /* Byte 7 Bit 3 */
1491   boolean Sync:1;                                       /* Byte 7 Bit 4 */
1492   boolean WBus16:1;                                     /* Byte 7 Bit 5 */
1493   boolean WBus32:1;                                     /* Byte 7 Bit 6 */
1494   boolean RelAdr:1;                                     /* Byte 7 Bit 7 */
1495   unsigned char VendorIdentification[8];                /* Bytes 8-15 */
1496   unsigned char ProductIdentification[16];              /* Bytes 16-31 */
1497   unsigned char ProductRevisionLevel[4];                /* Bytes 32-35 */
1498 }
1499 SCSI_Inquiry_T;
1500 
1501 
1502 /*
1503   BusLogic_AcquireHostAdapterLock acquires exclusive access to Host Adapter.
1504 */
1505 
1506 static inline
1507 void BusLogic_AcquireHostAdapterLock(BusLogic_HostAdapter_T *HostAdapter,
1508                                      ProcessorFlags_T *ProcessorFlags)
1509 {
1510 }
1511 
1512 
1513 /*
1514   BusLogic_ReleaseHostAdapterLock releases exclusive access to Host Adapter.
1515 */
1516 
1517 static inline
1518 void BusLogic_ReleaseHostAdapterLock(BusLogic_HostAdapter_T *HostAdapter,
1519                                      ProcessorFlags_T *ProcessorFlags)
1520 {
1521 }
1522 
1523 
1524 /*
1525   BusLogic_AcquireHostAdapterLockIH acquires exclusive access to Host Adapter,
1526   but is only called from the interrupt handler.
1527 */
1528 
1529 static inline
1530 void BusLogic_AcquireHostAdapterLockIH(BusLogic_HostAdapter_T *HostAdapter,
1531                                        ProcessorFlags_T *ProcessorFlags)
1532 {
1533   spin_lock_irqsave(&io_request_lock, *ProcessorFlags);
1534 }
1535 
1536 
1537 /*
1538   BusLogic_ReleaseHostAdapterLockIH releases exclusive access to Host Adapter,
1539   but is only called from the interrupt handler.
1540 */
1541 
1542 static inline
1543 void BusLogic_ReleaseHostAdapterLockIH(BusLogic_HostAdapter_T *HostAdapter,
1544                                        ProcessorFlags_T *ProcessorFlags)
1545 {
1546   spin_unlock_irqrestore(&io_request_lock, *ProcessorFlags);
1547 }
1548 
1549 
1550 /*
1551   Define functions to provide an abstraction for reading and writing the
1552   Host Adapter I/O Registers.
1553 */
1554 
1555 static inline
1556 void BusLogic_SCSIBusReset(BusLogic_HostAdapter_T *HostAdapter)
1557 {
1558   BusLogic_ControlRegister_T ControlRegister;
1559   ControlRegister.All = 0;
1560   ControlRegister.Bits.SCSIBusReset = true;
1561   outb(ControlRegister.All,
1562        HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
1563 }
1564 
1565 static inline
1566 void BusLogic_InterruptReset(BusLogic_HostAdapter_T *HostAdapter)
1567 {
1568   BusLogic_ControlRegister_T ControlRegister;
1569   ControlRegister.All = 0;
1570   ControlRegister.Bits.InterruptReset = true;
1571   outb(ControlRegister.All,
1572        HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
1573 }
1574 
1575 static inline
1576 void BusLogic_SoftReset(BusLogic_HostAdapter_T *HostAdapter)
1577 {
1578   BusLogic_ControlRegister_T ControlRegister;
1579   ControlRegister.All = 0;
1580   ControlRegister.Bits.SoftReset = true;
1581   outb(ControlRegister.All,
1582        HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
1583 }
1584 
1585 static inline
1586 void BusLogic_HardReset(BusLogic_HostAdapter_T *HostAdapter)
1587 {
1588   BusLogic_ControlRegister_T ControlRegister;
1589   ControlRegister.All = 0;
1590   ControlRegister.Bits.HardReset = true;
1591   outb(ControlRegister.All,
1592        HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
1593 }
1594 
1595 static inline
1596 unsigned char BusLogic_ReadStatusRegister(BusLogic_HostAdapter_T *HostAdapter)
1597 {
1598   return inb(HostAdapter->IO_Address + BusLogic_StatusRegisterOffset);
1599 }
1600 
1601 static inline
1602 void BusLogic_WriteCommandParameterRegister(BusLogic_HostAdapter_T
1603                                               *HostAdapter,
1604                                             unsigned char Value)
1605 {
1606   outb(Value,
1607        HostAdapter->IO_Address + BusLogic_CommandParameterRegisterOffset);
1608 }
1609 
1610 static inline
1611 unsigned char BusLogic_ReadDataInRegister(BusLogic_HostAdapter_T *HostAdapter)
1612 {
1613   return inb(HostAdapter->IO_Address + BusLogic_DataInRegisterOffset);
1614 }
1615 
1616 static inline
1617 unsigned char BusLogic_ReadInterruptRegister(BusLogic_HostAdapter_T
1618                                              *HostAdapter)
1619 {
1620   return inb(HostAdapter->IO_Address + BusLogic_InterruptRegisterOffset);
1621 }
1622 
1623 static inline
1624 unsigned char BusLogic_ReadGeometryRegister(BusLogic_HostAdapter_T
1625                                             *HostAdapter)
1626 {
1627   return inb(HostAdapter->IO_Address + BusLogic_GeometryRegisterOffset);
1628 }
1629 
1630 
1631 /*
1632   BusLogic_StartMailboxCommand issues an Execute Mailbox Command, which
1633   notifies the Host Adapter that an entry has been made in an Outgoing
1634   Mailbox.
1635 */
1636 
1637 static inline
1638 void BusLogic_StartMailboxCommand(BusLogic_HostAdapter_T *HostAdapter)
1639 {
1640   BusLogic_WriteCommandParameterRegister(HostAdapter,
1641                                          BusLogic_ExecuteMailboxCommand);
1642 }
1643 
1644 
1645 /*
1646   BusLogic_Delay waits for Seconds to elapse.
1647 */
1648 
1649 static inline void BusLogic_Delay(int Seconds)
1650 {
1651   int Milliseconds = 1000 * Seconds;
1652   unsigned long ProcessorFlags;
1653   save_flags(ProcessorFlags);
1654   sti();
1655   while (--Milliseconds >= 0) udelay(1000);
1656   restore_flags(ProcessorFlags);
1657 }
1658 
1659 
1660 /*
1661   Virtual_to_Bus and Bus_to_Virtual map between Kernel Virtual Addresses
1662   and PCI/VLB/EISA/ISA Bus Addresses.
1663 */
1664 
1665 static inline BusLogic_BusAddress_T Virtual_to_Bus(void *VirtualAddress)
1666 {
1667   return (BusLogic_BusAddress_T) virt_to_bus(VirtualAddress);
1668 }
1669 
1670 static inline void *Bus_to_Virtual(BusLogic_BusAddress_T BusAddress)
1671 {
1672   return (void *) bus_to_virt(BusAddress);
1673 }
1674 
1675 
1676 /*
1677   Virtual_to_32Bit_Virtual maps between Kernel Virtual Addresses and
1678   32 bit Kernel Virtual Addresses.  This avoids compilation warnings
1679   on 64 bit architectures.
1680 */
1681 
1682 static inline
1683 BusLogic_BusAddress_T Virtual_to_32Bit_Virtual(void *VirtualAddress)
1684 {
1685   return (BusLogic_BusAddress_T) (unsigned long) VirtualAddress;
1686 }
1687 
1688 
1689 /*
1690   BusLogic_IncrementErrorCounter increments Error Counter by 1, stopping at
1691   65535 rather than wrapping around to 0.
1692 */
1693 
1694 static inline void BusLogic_IncrementErrorCounter(unsigned short *ErrorCounter)
1695 {
1696   if (*ErrorCounter < 65535) (*ErrorCounter)++;
1697 }
1698 
1699 
1700 /*
1701   BusLogic_IncrementByteCounter increments Byte Counter by Amount.
1702 */
1703 
1704 static inline void BusLogic_IncrementByteCounter(BusLogic_ByteCounter_T
1705                                                    *ByteCounter,
1706                                                  unsigned int Amount)
1707 {
1708   ByteCounter->Units += Amount;
1709   if (ByteCounter->Units > 999999999)
1710     {
1711       ByteCounter->Units -= 1000000000;
1712       ByteCounter->Billions++;
1713     }
1714 }
1715 
1716 
1717 /*
1718   BusLogic_IncrementSizeBucket increments the Bucket for Amount.
1719 */
1720 
1721 static inline void BusLogic_IncrementSizeBucket(BusLogic_CommandSizeBuckets_T
1722                                                   CommandSizeBuckets,
1723                                                 unsigned int Amount)
1724 {
1725   int Index = 0;
1726   if (Amount < 8*1024)
1727     {
1728       if (Amount < 2*1024)
1729         Index = (Amount < 1*1024 ? 0 : 1);
1730       else Index = (Amount < 4*1024 ? 2 : 3);
1731     }
1732   else if (Amount < 128*1024)
1733     {
1734       if (Amount < 32*1024)
1735         Index = (Amount < 16*1024 ? 4 : 5);
1736       else Index = (Amount < 64*1024 ? 6 : 7);
1737     }
1738   else Index = (Amount < 256*1024 ? 8 : 9);
1739   CommandSizeBuckets[Index]++;
1740 }
1741 
1742 
1743 /*
1744   Define the version number of the FlashPoint Firmware (SCCB Manager).
1745 */
1746 
1747 #define FlashPoint_FirmwareVersion              "5.02"
1748 
1749 
1750 /*
1751   Define the possible return values from FlashPoint_HandleInterrupt.
1752 */
1753 
1754 #define FlashPoint_NormalInterrupt              0x00
1755 #define FlashPoint_InternalError                0xFE
1756 #define FlashPoint_ExternalBusReset             0xFF
1757 
1758 
1759 /*
1760   Define prototypes for the forward referenced BusLogic Driver
1761   Internal Functions.
1762 */
1763 
1764 static void BusLogic_QueueCompletedCCB(BusLogic_CCB_T *);
1765 static void BusLogic_InterruptHandler(int, void *, Registers_T *);
1766 static int BusLogic_ResetHostAdapter(BusLogic_HostAdapter_T *,
1767                                      SCSI_Command_T *, unsigned int);
1768 static void BusLogic_Message(BusLogic_MessageLevel_T, char *,
1769                              BusLogic_HostAdapter_T *, ...);
1770 
1771 /*
1772   Declare the Initialization Functions.
1773 */
1774 
1775 static void BusLogic_AnnounceDriver(BusLogic_HostAdapter_T *) __init;
1776 static void BusLogic_RegisterHostAdapter(BusLogic_HostAdapter_T *) __init;
1777 static void BusLogic_UnregisterHostAdapter(BusLogic_HostAdapter_T *) __init;
1778 static boolean BusLogic_CreateInitialCCBs(BusLogic_HostAdapter_T *) __init;
1779 static void BusLogic_DestroyCCBs(BusLogic_HostAdapter_T *) __init;
1780 static void BusLogic_AppendProbeAddressISA(BusLogic_IO_Address_T) __init;
1781 static void
1782 BusLogic_InitializeProbeInfoListISA(BusLogic_HostAdapter_T *) __init;
1783 static void BusLogic_SortProbeInfo(BusLogic_ProbeInfo_T *, int) __init;
1784 static int
1785 BusLogic_InitializeMultiMasterProbeInfo(BusLogic_HostAdapter_T *) __init;
1786 static int
1787 BusLogic_InitializeFlashPointProbeInfo(BusLogic_HostAdapter_T *) __init;
1788 static void BusLogic_InitializeProbeInfoList(BusLogic_HostAdapter_T *) __init;
1789 static boolean BusLogic_Failure(BusLogic_HostAdapter_T *, char *) __init;
1790 static boolean BusLogic_ProbeHostAdapter(BusLogic_HostAdapter_T *) __init;
1791 static boolean BusLogic_CheckHostAdapter(BusLogic_HostAdapter_T *) __init;
1792 static boolean
1793 BusLogic_ReadHostAdapterConfiguration(BusLogic_HostAdapter_T *) __init;
1794 static boolean
1795 BusLogic_ReportHostAdapterConfiguration(BusLogic_HostAdapter_T *) __init;
1796 static boolean BusLogic_AcquireResources(BusLogic_HostAdapter_T *) __init;
1797 static void BusLogic_ReleaseResources(BusLogic_HostAdapter_T *) __init;
1798 static boolean BusLogic_TargetDeviceInquiry(BusLogic_HostAdapter_T *) __init;
1799 static void BusLogic_InitializeHostStructure(BusLogic_HostAdapter_T *,
1800                                              SCSI_Host_T *) __init;
1801 int BusLogic_DetectHostAdapter(SCSI_Host_Template_T *) __init;
1802 int BusLogic_ReleaseHostAdapter(SCSI_Host_T *) __init;
1803 static boolean BusLogic_ParseKeyword(char **, char *) __init;
1804 static int BusLogic_ParseDriverOptions(char *) __init;
1805 static int BusLogic_Setup(char *) __init;
1806 
1807 
1808 #endif /* BusLogic_DriverVersion */
1809 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.