aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/BusLogic.h
blob: 6c6c13c3be1bc1e3197c2d240073b98d884a2887 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
/*

  Linux Driver for BusLogic MultiMaster and FlashPoint SCSI Host Adapters

  Copyright 1995-1998 by Leonard N. Zubkoff <lnz@dandelion.com>

  This program is free software; you may redistribute and/or modify it under
  the terms of the GNU General Public License Version 2 as published by the
  Free Software Foundation.

  This program is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  for complete details.

  The author respectfully requests that any modifications to this software be
  sent directly to him for evaluation and testing.

  Special thanks to Wayne Yen, Jin-Lon Hon, and Alex Win of BusLogic, whose
  advice has been invaluable, to David Gentzel, for writing the original Linux
  BusLogic driver, and to Paul Gortmaker, for being such a dedicated test site.

  Finally, special thanks to Mylex/BusLogic for making the FlashPoint SCCB
  Manager available as freely redistributable source code.

*/

#ifndef _BUSLOGIC_H
#define _BUSLOGIC_H


#ifndef PACKED
#define PACKED __attribute__((packed))
#endif

/*
  Define the maximum number of BusLogic Host Adapters supported by this driver.
*/

#define BusLogic_MaxHostAdapters		16


/*
  Define the maximum number of Target Devices supported by this driver.
*/

#define BusLogic_MaxTargetDevices		16


/*
  Define the maximum number of Scatter/Gather Segments used by this driver.
  For optimal performance, it is important that this limit be at least as
  large as the largest single request generated by the I/O Subsystem.
*/

#define BusLogic_ScatterGatherLimit		128


/*
  Define the maximum, maximum automatic, minimum automatic, and default Queue
  Depth to allow for Target Devices depending on whether or not they support
  Tagged Queuing and whether or not ISA Bounce Buffers are required.
*/

#define BusLogic_MaxTaggedQueueDepth		64
#define BusLogic_MaxAutomaticTaggedQueueDepth	28
#define BusLogic_MinAutomaticTaggedQueueDepth	7
#define BusLogic_TaggedQueueDepthBB		3
#define BusLogic_UntaggedQueueDepth		3
#define BusLogic_UntaggedQueueDepthBB		2


/*
  Define the default amount of time in seconds to wait between a Host Adapter
  Hard Reset which initiates a SCSI Bus Reset and issuing any SCSI commands.
  Some SCSI devices get confused if they receive SCSI commands too soon after
  a SCSI Bus Reset.
*/

#define BusLogic_DefaultBusSettleTime		2


/*
  Define the maximum number of Mailboxes that should be used for MultiMaster
  Host Adapters.  This number is chosen to be larger than the maximum Host
  Adapter Queue Depth and small enough so that the Host Adapter structure
  does not cross an allocation block size boundary.
*/

#define BusLogic_MaxMailboxes			211


/*
  Define the number of CCBs that should be allocated as a group to optimize
  Kernel memory allocation.
*/

#define BusLogic_CCB_AllocationGroupSize	7


/*
  Define the Host Adapter Line and Message Buffer Sizes.
*/

#define BusLogic_LineBufferSize			100
#define BusLogic_MessageBufferSize		9700


/*
  Define the Driver Message Levels.
*/

enum BusLogic_MessageLevel {
	BusLogic_AnnounceLevel = 0,
	BusLogic_InfoLevel = 1,
	BusLogic_NoticeLevel = 2,
	BusLogic_WarningLevel = 3,
	BusLogic_ErrorLevel = 4
};

static char *BusLogic_MessageLevelMap[] = { KERN_NOTICE, KERN_NOTICE, KERN_NOTICE, KERN_WARNING, KERN_ERR };


/*
  Define Driver Message macros.
*/

#define BusLogic_Announce(Format, Arguments...) \
  BusLogic_Message(BusLogic_AnnounceLevel, Format, ##Arguments)

#define BusLogic_Info(Format, Arguments...) \
  BusLogic_Message(BusLogic_InfoLevel, Format, ##Arguments)

#define BusLogic_Notice(Format, Arguments...) \
  BusLogic_Message(BusLogic_NoticeLevel, Format, ##Arguments)

#define BusLogic_Warning(Format, Arguments...) \
  BusLogic_Message(BusLogic_WarningLevel, Format, ##Arguments)

#define BusLogic_Error(Format, Arguments...) \
  BusLogic_Message(BusLogic_ErrorLevel, Format, ##Arguments)


/*
  Define the types of BusLogic Host Adapters that are supported and the number
  of I/O Addresses required by each type.
*/

enum BusLogic_HostAdapterType {
	BusLogic_MultiMaster = 1,
	BusLogic_FlashPoint = 2
} PACKED;

#define BusLogic_MultiMasterAddressCount	4
#define BusLogic_FlashPointAddressCount		256

static int BusLogic_HostAdapterAddressCount[3] = { 0, BusLogic_MultiMasterAddressCount, BusLogic_FlashPointAddressCount };


/*
  Define macros for testing the Host Adapter Type.
*/

#ifdef CONFIG_SCSI_FLASHPOINT

#define BusLogic_MultiMasterHostAdapterP(HostAdapter) \
  (HostAdapter->HostAdapterType == BusLogic_MultiMaster)

#define BusLogic_FlashPointHostAdapterP(HostAdapter) \
  (HostAdapter->HostAdapterType == BusLogic_FlashPoint)

#else

#define BusLogic_MultiMasterHostAdapterP(HostAdapter) \
  (true)

#define BusLogic_FlashPointHostAdapterP(HostAdapter) \
  (false)

#endif


/*
  Define the possible Host Adapter Bus Types.
*/

enum BusLogic_HostAdapterBusType {
	BusLogic_Unknown_Bus = 0,
	BusLogic_ISA_Bus = 1,
	BusLogic_EISA_Bus = 2,
	BusLogic_PCI_Bus = 3,
	BusLogic_VESA_Bus = 4,
	BusLogic_MCA_Bus = 5
} PACKED;

static char *BusLogic_HostAdapterBusNames[] = { "Unknown", "ISA", "EISA", "PCI", "VESA", "MCA" };

static enum BusLogic_HostAdapterBusType BusLogic_HostAdapterBusTypes[] = {
	BusLogic_VESA_Bus,	/* BT-4xx */
	BusLogic_ISA_Bus,	/* BT-5xx */
	BusLogic_MCA_Bus,	/* BT-6xx */
	BusLogic_EISA_Bus,	/* BT-7xx */
	BusLogic_Unknown_Bus,	/* BT-8xx */
	BusLogic_PCI_Bus	/* BT-9xx */
};

/*
  Define the possible Host Adapter BIOS Disk Geometry Translations.
*/

enum BusLogic_BIOS_DiskGeometryTranslation {
	BusLogic_BIOS_Disk_Not_Installed = 0,
	BusLogic_BIOS_Disk_Installed_64x32 = 1,
	BusLogic_BIOS_Disk_Installed_128x32 = 2,
	BusLogic_BIOS_Disk_Installed_255x63 = 3
} PACKED;


/*
  Define a 10^18 Statistics Byte Counter data type.
*/

struct BusLogic_ByteCounter {
	unsigned int Units;
	unsigned int Billions;
};


/*
  Define the structure for I/O Address and Bus Probing Information.
*/

struct BusLogic_ProbeInfo {
	enum BusLogic_HostAdapterType HostAdapterType;
	enum BusLogic_HostAdapterBusType HostAdapterBusType;
	unsigned long IO_Address;
	unsigned long PCI_Address;
	struct pci_dev *PCI_Device;
	unsigned char Bus;
	unsigned char Device;
	unsigned char IRQ_Channel;
};

/*
  Define the Probe Options.
*/

struct BusLogic_ProbeOptions {
	bool NoProbe:1;		/* Bit 0 */
	bool NoProbeISA:1;	/* Bit 1 */
	bool NoProbePCI:1;	/* Bit 2 */
	bool NoSortPCI:1;	/* Bit 3 */
	bool MultiMasterFirst:1;/* Bit 4 */
	bool FlashPointFirst:1;	/* Bit 5 */
	bool LimitedProbeISA:1;	/* Bit 6 */
	bool Probe330:1;	/* Bit 7 */
	bool Probe334:1;	/* Bit 8 */
	bool Probe230:1;	/* Bit 9 */
	bool Probe234:1;	/* Bit 10 */
	bool Probe130:1;	/* Bit 11 */
	bool Probe134:1;	/* Bit 12 */
};

/*
  Define the Global Options.
*/

struct BusLogic_GlobalOptions {
	bool TraceProbe:1;	/* Bit 0 */
	bool TraceHardwareReset:1;	/* Bit 1 */
	bool TraceConfiguration:1;	/* Bit 2 */
	bool TraceErrors:1;	/* Bit 3 */
};

/*
  Define the Local Options.
*/

struct BusLogic_LocalOptions {
	bool InhibitTargetInquiry:1;	/* Bit 0 */
};

/*
  Define the BusLogic SCSI Host Adapter I/O Register Offsets.
*/

#define BusLogic_ControlRegisterOffset		0	/* WO register */
#define BusLogic_StatusRegisterOffset		0	/* RO register */
#define BusLogic_CommandParameterRegisterOffset	1	/* WO register */
#define BusLogic_DataInRegisterOffset		1	/* RO register */
#define BusLogic_InterruptRegisterOffset	2	/* RO register */
#define BusLogic_GeometryRegisterOffset		3	/* RO register */

/*
  Define the structure of the write-only Control Register.
*/

union BusLogic_ControlRegister {
	unsigned char All;
	struct {
		unsigned char:4;	/* Bits 0-3 */
		bool SCSIBusReset:1;	/* Bit 4 */
		bool InterruptReset:1;	/* Bit 5 */
		bool SoftReset:1;	/* Bit 6 */
		bool HardReset:1;	/* Bit 7 */
	} cr;
};

/*
  Define the structure of the read-only Status Register.
*/

union BusLogic_StatusRegister {
	unsigned char All;
	struct {
		bool CommandInvalid:1;		/* Bit 0 */
		bool Reserved:1;		/* Bit 1 */
		bool DataInRegisterReady:1;	/* Bit 2 */
		bool CommandParameterRegisterBusy:1;	/* Bit 3 */
		bool HostAdapterReady:1;	/* Bit 4 */
		bool InitializationRequired:1;	/* Bit 5 */
		bool DiagnosticFailure:1;	/* Bit 6 */
		bool DiagnosticActive:1;	/* Bit 7 */
	} sr;
};

/*
  Define the structure of the read-only Interrupt Register.
*/

union BusLogic_InterruptRegister {
	unsigned char All;
	struct {
		bool IncomingMailboxLoaded:1;	/* Bit 0 */
		bool OutgoingMailboxAvailable:1;/* Bit 1 */
		bool CommandComplete:1;		/* Bit 2 */
		bool ExternalBusReset:1;	/* Bit 3 */
		unsigned char Reserved:3;	/* Bits 4-6 */
		bool InterruptValid:1;		/* Bit 7 */
	} ir;
};

/*
  Define the structure of the read-only Geometry Register.
*/

union BusLogic_GeometryRegister {
	unsigned char All;
	struct {
		enum BusLogic_BIOS_DiskGeometryTranslation Drive0Geometry:2;	/* Bits 0-1 */
		enum BusLogic_BIOS_DiskGeometryTranslation Drive1Geometry:2;	/* Bits 2-3 */
		unsigned char:3;	/* Bits 4-6 */
		bool ExtendedTranslationEnabled:1;	/* Bit 7 */
	} gr;
};

/*
  Define the BusLogic SCSI Host Adapter Command Register Operation Codes.
*/

enum BusLogic_OperationCode {
	BusLogic_TestCommandCompleteInterrupt = 0x00,
	BusLogic_InitializeMailbox = 0x01,
	BusLogic_ExecuteMailboxCommand = 0x02,
	BusLogic_ExecuteBIOSCommand = 0x03,
	BusLogic_InquireBoardID = 0x04,
	BusLogic_EnableOutgoingMailboxAvailableInt = 0x05,
	BusLogic_SetSCSISelectionTimeout = 0x06,
	BusLogic_SetPreemptTimeOnBus = 0x07,
	BusLogic_SetTimeOffBus = 0x08,
	BusLogic_SetBusTransferRate = 0x09,
	BusLogic_InquireInstalledDevicesID0to7 = 0x0A,
	BusLogic_InquireConfiguration = 0x0B,
	BusLogic_EnableTargetMode = 0x0C,
	BusLogic_InquireSetupInformation = 0x0D,
	BusLogic_WriteAdapterLocalRAM = 0x1A,
	BusLogic_ReadAdapterLocalRAM = 0x1B,
	BusLogic_WriteBusMasterChipFIFO = 0x1C,
	BusLogic_ReadBusMasterChipFIFO = 0x1D,
	BusLogic_EchoCommandData = 0x1F,
	BusLogic_HostAdapterDiagnostic = 0x20,
	BusLogic_SetAdapterOptions = 0x21,
	BusLogic_InquireInstalledDevicesID8to15 = 0x23,
	BusLogic_InquireTargetDevices = 0x24,
	BusLogic_DisableHostAdapterInterrupt = 0x25,
	BusLogic_InitializeExtendedMailbox = 0x81,
	BusLogic_ExecuteSCSICommand = 0x83,
	BusLogic_InquireFirmwareVersion3rdDigit = 0x84,
	BusLogic_InquireFirmwareVersionLetter = 0x85,
	BusLogic_InquirePCIHostAdapterInformation = 0x86,
	BusLogic_InquireHostAdapterModelNumber = 0x8B,
	BusLogic_InquireSynchronousPeriod = 0x8C,
	BusLogic_InquireExtendedSetupInformation = 0x8D,
	BusLogic_EnableStrictRoundRobinMode = 0x8F,
	BusLogic_StoreHostAdapterLocalRAM = 0x90,
	BusLogic_FetchHostAdapterLocalRAM = 0x91,
	BusLogic_StoreLocalDataInEEPROM = 0x92,
	BusLogic_UploadAutoSCSICode = 0x94,
	BusLogic_ModifyIOAddress = 0x95,
	BusLogic_SetCCBFormat = 0x96,
	BusLogic_WriteInquiryBuffer = 0x9A,
	BusLogic_ReadInquiryBuffer = 0x9B,
	BusLogic_FlashROMUploadDownload = 0xA7,
	BusLogic_ReadSCAMData = 0xA8,
	BusLogic_WriteSCAMData = 0xA9
};

/*
  Define the Inquire Board ID reply structure.
*/

struct BusLogic_BoardID {
	unsigned char BoardType;	/* Byte 0 */
	unsigned char CustomFeatures;	/* Byte 1 */
	unsigned char FirmwareVersion1stDigit;	/* Byte 2 */
	unsigned char FirmwareVersion2ndDigit;	/* Byte 3 */
};

/*
  Define the Inquire Configuration reply structure.
*/

struct BusLogic_Configuration {
	unsigned char:5;	/* Byte 0 Bits 0-4 */
	bool DMA_Channel5:1;	/* Byte 0 Bit 5 */
	bool DMA_Channel6:1;	/* Byte 0 Bit 6 */
	bool DMA_Channel7:1;	/* Byte 0 Bit 7 */
	bool IRQ_Channel9:1;	/* Byte 1 Bit 0 */
	bool IRQ_Channel10:1;	/* Byte 1 Bit 1 */
	bool IRQ_Channel11:1;	/* Byte 1 Bit 2 */
	bool IRQ_Channel12:1;	/* Byte 1 Bit 3 */
	unsigned char:1;	/* Byte 1 Bit 4 */
	bool IRQ_Channel14:1;	/* Byte 1 Bit 5 */
	bool IRQ_Channel15:1;	/* Byte 1 Bit 6 */
	unsigned char:1;	/* Byte 1 Bit 7 */
	unsigned char HostAdapterID:4;	/* Byte 2 Bits 0-3 */
	unsigned char:4;	/* Byte 2 Bits 4-7 */
};

/*
  Define the Inquire Setup Information reply structure.
*/

struct BusLogic_SynchronousValue {
	unsigned char Offset:4;	/* Bits 0-3 */
	unsigned char TransferPeriod:3;	/* Bits 4-6 */
	bool Synchronous:1;	/* Bit 7 */
};

struct BusLogic_SetupInformation {
	bool SynchronousInitiationEnabled:1;	/* Byte 0 Bit 0 */
	bool ParityCheckingEnabled:1;		/* Byte 0 Bit 1 */
	unsigned char:6;	/* Byte 0 Bits 2-7 */
	unsigned char BusTransferRate;	/* Byte 1 */
	unsigned char PreemptTimeOnBus;	/* Byte 2 */
	unsigned char TimeOffBus;	/* Byte 3 */
	unsigned char MailboxCount;	/* Byte 4 */
	unsigned char MailboxAddress[3];	/* Bytes 5-7 */
	struct BusLogic_SynchronousValue SynchronousValuesID0to7[8];	/* Bytes 8-15 */
	unsigned char DisconnectPermittedID0to7;	/* Byte 16 */
	unsigned char Signature;	/* Byte 17 */
	unsigned char CharacterD;	/* Byte 18 */
	unsigned char HostBusType;	/* Byte 19 */
	unsigned char WideTransfersPermittedID0to7;	/* Byte 20 */
	unsigned char WideTransfersActiveID0to7;	/* Byte 21 */
	struct BusLogic_SynchronousValue SynchronousValuesID8to15[8];	/* Bytes 22-29 */
	unsigned char DisconnectPermittedID8to15;	/* Byte 30 */
	unsigned char:8;	/* Byte 31 */
	unsigned char WideTransfersPermittedID8to15;	/* Byte 32 */
	unsigned char WideTransfersActiveID8to15;	/* Byte 33 */
};

/*
  Define the Initialize Extended Mailbox request structure.
*/

struct BusLogic_ExtendedMailboxRequest {
	unsigned char MailboxCount;	/* Byte 0 */
	u32 BaseMailboxAddress;	/* Bytes 1-4 */
} PACKED;


/*
  Define the Inquire PCI Host Adapter Information reply type.  The ISA
  Compatible I/O Port values are defined here and are also used with
  the Modify I/O Address command.
*/

enum BusLogic_ISACompatibleIOPort {
	BusLogic_IO_330 = 0,
	BusLogic_IO_334 = 1,
	BusLogic_IO_230 = 2,
	BusLogic_IO_234 = 3,
	BusLogic_IO_130 = 4,
	BusLogic_IO_134 = 5,
	BusLogic_IO_Disable = 6,
	BusLogic_IO_Disable2 = 7
} PACKED;

struct BusLogic_PCIHostAdapterInformation {
	enum BusLogic_ISACompatibleIOPort ISACompatibleIOPort;	/* Byte 0 */
	unsigned char PCIAssignedIRQChannel;	/* Byte 1 */
	bool LowByteTerminated:1;	/* Byte 2 Bit 0 */
	bool HighByteTerminated:1;	/* Byte 2 Bit 1 */
	unsigned char:2;	/* Byte 2 Bits 2-3 */
	bool JP1:1;		/* Byte 2 Bit 4 */
	bool JP2:1;		/* Byte 2 Bit 5 */
	bool JP3:1;		/* Byte 2 Bit 6 */
	bool GenericInfoValid:1;/* Byte 2 Bit 7 */
	unsigned char:8;	/* Byte 3 */
};

/*
  Define the Inquire Extended Setup Information reply structure.
*/

struct BusLogic_ExtendedSetupInformation {
	unsigned char BusType;	/* Byte 0 */
	unsigned char BIOS_Address;	/* Byte 1 */
	unsigned short ScatterGatherLimit;	/* Bytes 2-3 */
	unsigned char MailboxCount;	/* Byte 4 */
	u32 BaseMailboxAddress;	/* Bytes 5-8 */
	struct {
		unsigned char:2;	/* Byte 9 Bits 0-1 */
		bool FastOnEISA:1;	/* Byte 9 Bit 2 */
		unsigned char:3;	/* Byte 9 Bits 3-5 */
		bool LevelSensitiveInterrupt:1;	/* Byte 9 Bit 6 */
		unsigned char:1;	/* Byte 9 Bit 7 */
	} Misc;
	unsigned char FirmwareRevision[3];	/* Bytes 10-12 */
	bool HostWideSCSI:1;		/* Byte 13 Bit 0 */
	bool HostDifferentialSCSI:1;	/* Byte 13 Bit 1 */
	bool HostSupportsSCAM:1;	/* Byte 13 Bit 2 */
	bool HostUltraSCSI:1;		/* Byte 13 Bit 3 */
	bool HostSmartTermination:1;	/* Byte 13 Bit 4 */
	unsigned char:3;	/* Byte 13 Bits 5-7 */
} PACKED;

/*
  Define the Enable Strict Round Robin Mode request type.
*/

enum BusLogic_RoundRobinModeRequest {
	BusLogic_AggressiveRoundRobinMode = 0,
	BusLogic_StrictRoundRobinMode = 1
} PACKED;


/*
  Define the Fetch Host Adapter Local RAM request type.
*/

#define BusLogic_BIOS_BaseOffset		0
#define BusLogic_AutoSCSI_BaseOffset		64

struct BusLogic_FetchHostAdapterLocalRAMRequest {
	unsigned char ByteOffset;	/* Byte 0 */
	unsigned char ByteCount;	/* Byte 1 */
};

/*
  Define the Host Adapter Local RAM AutoSCSI structure.
*/

struct BusLogic_AutoSCSIData {
	unsigned char InternalFactorySignature[2];	/* Bytes 0-1 */
	unsigned char InformationByteCount;	/* Byte 2 */
	unsigned char HostAdapterType[6];	/* Bytes 3-8 */
	unsigned char:8;	/* Byte 9 */
	bool FloppyEnabled:1;		/* Byte 10 Bit 0 */
	bool FloppySecondary:1;		/* Byte 10 Bit 1 */
	bool LevelSensitiveInterrupt:1;	/* Byte 10 Bit 2 */
	unsigned char:2;	/* Byte 10 Bits 3-4 */
	unsigned char SystemRAMAreaForBIOS:3;	/* Byte 10 Bits 5-7 */
	unsigned char DMA_Channel:7;	/* Byte 11 Bits 0-6 */
	bool DMA_AutoConfiguration:1;	/* Byte 11 Bit 7 */
	unsigned char IRQ_Channel:7;	/* Byte 12 Bits 0-6 */
	bool IRQ_AutoConfiguration:1;	/* Byte 12 Bit 7 */
	unsigned char DMA_TransferRate;	/* Byte 13 */
	unsigned char SCSI_ID;	/* Byte 14 */
	bool LowByteTerminated:1;	/* Byte 15 Bit 0 */
	bool ParityCheckingEnabled:1;	/* Byte 15 Bit 1 */
	bool HighByteTerminated:1;	/* Byte 15 Bit 2 */
	bool NoisyCablingEnvironment:1;	/* Byte 15 Bit 3 */
	bool FastSynchronousNegotiation:1;	/* Byte 15 Bit 4 */
	bool BusResetEnabled:1;		/* Byte 15 Bit 5 */
	 bool:1;		/* Byte 15 Bit 6 */
	bool ActiveNegationEnabled:1;	/* Byte 15 Bit 7 */
	unsigned char BusOnDelay;	/* Byte 16 */
	unsigned char BusOffDelay;	/* Byte 17 */
	bool HostAdapterBIOSEnabled:1;		/* Byte 18 Bit 0 */
	bool BIOSRedirectionOfINT19Enabled:1;	/* Byte 18 Bit 1 */
	bool ExtendedTranslationEnabled:1;	/* Byte 18 Bit 2 */
	bool MapRemovableAsFixedEnabled:1;	/* Byte 18 Bit 3 */
	 bool:1;		/* Byte 18 Bit 4 */
	bool BIOSSupportsMoreThan2DrivesEnabled:1;	/* Byte 18 Bit 5 */
	bool BIOSInterruptModeEnabled:1;	/* Byte 18 Bit 6 */
	bool FlopticalSupportEnabled:1;		/* Byte 19 Bit 7 */
	unsigned short DeviceEnabled;	/* Bytes 19-20 */
	unsigned short WidePermitted;	/* Bytes 21-22 */
	unsigned short FastPermitted;	/* Bytes 23-24 */
	unsigned short SynchronousPermitted;	/* Bytes 25-26 */
	unsigned short DisconnectPermitted;	/* Bytes 27-28 */
	unsigned short SendStartUnitCommand;	/* Bytes 29-30 */
	unsigned short IgnoreInBIOSScan;	/* Bytes 31-32 */
	unsigned char PCIInterruptPin:2;	/* Byte 33 Bits 0-1 */
	unsigned char HostAdapterIOPortAddress:2;	/* Byte 33 Bits 2-3 */
	bool StrictRoundRobinModeEnabled:1;	/* Byte 33 Bit 4 */
	bool VESABusSpeedGreaterThan33MHz:1;	/* Byte 33 Bit 5 */
	bool VESABurstWriteEnabled:1;	/* Byte 33 Bit 6 */
	bool VESABurstReadEnabled:1;	/* Byte 33 Bit 7 */
	unsigned short UltraPermitted;	/* Bytes 34-35 */
	unsigned int:32;	/* Bytes 36-39 */
	unsigned char:8;	/* Byte 40 */
	unsigned char AutoSCSIMaximumLUN;	/* Byte 41 */
	 bool:1;		/* Byte 42 Bit 0 */
	bool SCAM_Dominant:1;	/* Byte 42 Bit 1 */
	bool SCAM_Enabled:1;	/* Byte 42 Bit 2 */
	bool SCAM_Level2:1;	/* Byte 42 Bit 3 */
	unsigned char:4;	/* Byte 42 Bits 4-7 */
	bool INT13ExtensionEnabled:1;	/* Byte 43 Bit 0 */
	 bool:1;		/* Byte 43 Bit 1 */
	bool CDROMBootEnabled:1;	/* Byte 43 Bit 2 */
	unsigned char:5;	/* Byte 43 Bits 3-7 */
	unsigned char BootTargetID:4;	/* Byte 44 Bits 0-3 */
	unsigned char BootChannel:4;	/* Byte 44 Bits 4-7 */
	unsigned char ForceBusDeviceScanningOrder:1;	/* Byte 45 Bit 0 */
	unsigned char:7;	/* Byte 45 Bits 1-7 */
	unsigned short NonTaggedToAlternateLUNPermitted;	/* Bytes 46-47 */
	unsigned short RenegotiateSyncAfterCheckCondition;	/* Bytes 48-49 */
	unsigned char Reserved[10];	/* Bytes 50-59 */
	unsigned char ManufacturingDiagnostic[2];	/* Bytes 60-61 */
	unsigned short Checksum;	/* Bytes 62-63 */
} PACKED;

/*
  Define the Host Adapter Local RAM Auto SCSI Byte 45 structure.
*/

struct BusLogic_AutoSCSIByte45 {
	unsigned char ForceBusDeviceScanningOrder:1;	/* Bit 0 */
	unsigned char:7;	/* Bits 1-7 */
};

/*
  Define the Host Adapter Local RAM BIOS Drive Map Byte structure.
*/

#define BusLogic_BIOS_DriveMapOffset		17

struct BusLogic_BIOSDriveMapByte {
	unsigned char TargetIDBit3:1;	/* Bit 0 */
	unsigned char:2;	/* Bits 1-2 */
	enum BusLogic_BIOS_DiskGeometryTranslation DiskGeometry:2;	/* Bits 3-4 */
	unsigned char TargetID:3;	/* Bits 5-7 */
};

/*
  Define the Set CCB Format request type.  Extended LUN Format CCBs are
  necessary to support more than 8 Logical Units per Target Device.
*/

enum BusLogic_SetCCBFormatRequest {
	BusLogic_LegacyLUNFormatCCB = 0,
	BusLogic_ExtendedLUNFormatCCB = 1
} PACKED;

/*
  Define the Outgoing Mailbox Action Codes.
*/

enum BusLogic_ActionCode {
	BusLogic_OutgoingMailboxFree = 0x00,
	BusLogic_MailboxStartCommand = 0x01,
	BusLogic_MailboxAbortCommand = 0x02
} PACKED;


/*
  Define the Incoming Mailbox Completion Codes.  The MultiMaster Firmware
  only uses codes 0 - 4.  The FlashPoint SCCB Manager has no mailboxes, so
  completion codes are stored in the CCB; it only uses codes 1, 2, 4, and 5.
*/

enum BusLogic_CompletionCode {
	BusLogic_IncomingMailboxFree = 0x00,
	BusLogic_CommandCompletedWithoutError = 0x01,
	BusLogic_CommandAbortedAtHostRequest = 0x02,
	BusLogic_AbortedCommandNotFound = 0x03,
	BusLogic_CommandCompletedWithError = 0x04,
	BusLogic_InvalidCCB = 0x05
} PACKED;

/*
  Define the Command Control Block (CCB) Opcodes.
*/

enum BusLogic_CCB_Opcode {
	BusLogic_InitiatorCCB = 0x00,
	BusLogic_TargetCCB = 0x01,
	BusLogic_InitiatorCCB_ScatterGather = 0x02,
	BusLogic_InitiatorCCB_ResidualDataLength = 0x03,
	BusLogic_InitiatorCCB_ScatterGatherResidual = 0x04,
	BusLogic_BusDeviceReset = 0x81
} PACKED;


/*
  Define the CCB Data Direction Codes.
*/

enum BusLogic_DataDirection {
	BusLogic_UncheckedDataTransfer = 0,
	BusLogic_DataInLengthChecked = 1,
	BusLogic_DataOutLengthChecked = 2,
	BusLogic_NoDataTransfer = 3
};


/*
  Define the Host Adapter Status Codes.  The MultiMaster Firmware does not
  return status code 0x0C; it uses 0x12 for both overruns and underruns.
*/

enum BusLogic_HostAdapterStatus {
	BusLogic_CommandCompletedNormally = 0x00,
	BusLogic_LinkedCommandCompleted = 0x0A,
	BusLogic_LinkedCommandCompletedWithFlag = 0x0B,
	BusLogic_DataUnderRun = 0x0C,
	BusLogic_SCSISelectionTimeout = 0x11,
	BusLogic_DataOverRun = 0x12,
	BusLogic_UnexpectedBusFree = 0x13,
	BusLogic_InvalidBusPhaseRequested = 0x14,
	BusLogic_InvalidOutgoingMailboxActionCode = 0x15,
	BusLogic_InvalidCommandOperationCode = 0x16,
	BusLogic_LinkedCCBhasInvalidLUN = 0x17,
	BusLogic_InvalidCommandParameter = 0x1A,
	BusLogic_AutoRequestSenseFailed = 0x1B,
	BusLogic_TaggedQueuingMessageRejected = 0x1C,
	BusLogic_UnsupportedMessageReceived = 0x1D,
	BusLogic_HostAdapterHardwareFailed = 0x20,
	BusLogic_TargetFailedResponseToATN = 0x21,
	BusLogic_HostAdapterAssertedRST = 0x22,
	BusLogic_OtherDeviceAssertedRST = 0x23,
	BusLogic_TargetDeviceReconnectedImproperly = 0x24,
	BusLogic_HostAdapterAssertedBusDeviceReset = 0x25,
	BusLogic_AbortQueueGenerated = 0x26,
	BusLogic_HostAdapterSoftwareError = 0x27,
	BusLogic_HostAdapterHardwareTimeoutError = 0x30,
	BusLogic_SCSIParityErrorDetected = 0x34
} PACKED;


/*
  Define the SCSI Target Device Status Codes.
*/

enum BusLogic_TargetDeviceStatus {
	BusLogic_OperationGood = 0x00,
	BusLogic_CheckCondition = 0x02,
	BusLogic_DeviceBusy = 0x08
} PACKED;

/*
  Define the Queue Tag Codes.
*/

enum BusLogic_QueueTag {
	BusLogic_SimpleQueueTag = 0,
	BusLogic_HeadOfQueueTag = 1,
	BusLogic_OrderedQueueTag = 2,
	BusLogic_ReservedQT = 3
};

/*
  Define the SCSI Command Descriptor Block (CDB).
*/

#define BusLogic_CDB_MaxLength			12

typedef unsigned char SCSI_CDB_T[BusLogic_CDB_MaxLength];


/*
  Define the Scatter/Gather Segment structure required by the MultiMaster
  Firmware Interface and the FlashPoint SCCB Manager.
*/

struct BusLogic_ScatterGatherSegment {
	u32 SegmentByteCount;	/* Bytes 0-3 */
	u32 SegmentDataPointer;	/* Bytes 4-7 */
};

/*
  Define the Driver CCB Status Codes.
*/

enum BusLogic_CCB_Status {
	BusLogic_CCB_Free = 0,
	BusLogic_CCB_Active = 1,
	BusLogic_CCB_Completed = 2,
	BusLogic_CCB_Reset = 3
} PACKED;


/*
  Define the 32 Bit Mode Command Control Block (CCB) structure.  The first 40
  bytes are defined by and common to both the MultiMaster Firmware and the
  FlashPoint SCCB Manager.  The next 60 bytes are defined by the FlashPoint
  SCCB Manager.  The remaining components are defined by the Linux BusLogic
  Driver.  Extended LUN Format CCBs differ from Legacy LUN Format 32 Bit Mode
  CCBs only in having the TagEnable and QueueTag fields moved from byte 17 to
  byte 1, and the Logical Unit field in byte 17 expanded to 6 bits.  In theory,
  Extended LUN Format CCBs can support up to 64 Logical Units, but in practice
  many devices will respond improperly to Logical Units between 32 and 63, and
  the SCSI-2 specification defines Bit 5 as LUNTAR.  Extended LUN Format CCBs
  are used by recent versions of the MultiMaster Firmware, as well as by the
  FlashPoint SCCB Manager; the FlashPoint SCCB Manager only supports 32 Logical
  Units.  Since 64 Logical Units are unlikely to be needed in practice, and
  since they are problematic for the above reasons, and since limiting them to
  5 bits simplifies the CCB structure definition, this driver only supports
  32 Logical Units per Target Device.
*/

struct BusLogic_CCB {
	/*
	   MultiMaster Firmware and FlashPoint SCCB Manager Common Portion.
	 */
	enum BusLogic_CCB_Opcode Opcode;	/* Byte 0 */
	unsigned char:3;	/* Byte 1 Bits 0-2 */
	enum BusLogic_DataDirection DataDirection:2;	/* Byte 1 Bits 3-4 */
	bool TagEnable:1;	/* Byte 1 Bit 5 */
	enum BusLogic_QueueTag QueueTag:2;	/* Byte 1 Bits 6-7 */
	unsigned char CDB_Length;	/* Byte 2 */
	unsigned char SenseDataLength;	/* Byte 3 */
	u32 DataLength;		/* Bytes 4-7 */
	u32 DataPointer;	/* Bytes 8-11 */
	unsigned char:8;	/* Byte 12 */
	unsigned char:8;	/* Byte 13 */
	enum BusLogic_HostAdapterStatus HostAdapterStatus;	/* Byte 14 */
	enum BusLogic_TargetDeviceStatus TargetDeviceStatus;	/* Byte 15 */
	unsigned char TargetID;	/* Byte 16 */
	unsigned char LogicalUnit:5;	/* Byte 17 Bits 0-4 */
	bool LegacyTagEnable:1;	/* Byte 17 Bit 5 */
	enum BusLogic_QueueTag LegacyQueueTag:2;	/* Byte 17 Bits 6-7 */
	SCSI_CDB_T CDB;		/* Bytes 18-29 */
	unsigned char:8;	/* Byte 30 */
	unsigned char:8;	/* Byte 31 */
	unsigned int:32;	/* Bytes 32-35 */
	u32 SenseDataPointer;	/* Bytes 36-39 */
	/*
	   FlashPoint SCCB Manager Defined Portion.
	 */
	void (*CallbackFunction) (struct BusLogic_CCB *);	/* Bytes 40-43 */
	u32 BaseAddress;	/* Bytes 44-47 */
	enum BusLogic_CompletionCode CompletionCode;	/* Byte 48 */
#ifdef CONFIG_SCSI_FLASHPOINT
	unsigned char:8;	/* Byte 49 */
	unsigned short OS_Flags;	/* Bytes 50-51 */
	unsigned char Private[48];	/* Bytes 52-99 */
#endif
	/*
	   BusLogic Linux Driver Defined Portion.
	 */
	dma_addr_t AllocationGroupHead;
	unsigned int AllocationGroupSize;
	u32 DMA_Handle;
	enum BusLogic_CCB_Status Status;
	unsigned long SerialNumber;
	struct scsi_cmnd *Command;
	struct BusLogic_HostAdapter *HostAdapter;
	struct BusLogic_CCB *Next;
	struct BusLogic_CCB *NextAll;
	struct BusLogic_ScatterGatherSegment
	 ScatterGatherList[BusLogic_ScatterGatherLimit];
};

/*
  Define the 32 Bit Mode Outgoing Mailbox structure.
*/

struct BusLogic_OutgoingMailbox {
	u32 CCB;		/* Bytes 0-3 */
	unsigned int:24;	/* Bytes 4-6 */
	enum BusLogic_ActionCode ActionCode;	/* Byte 7 */
};

/*
  Define the 32 Bit Mode Incoming Mailbox structure.
*/

struct BusLogic_IncomingMailbox {
	u32 CCB;		/* Bytes 0-3 */
	enum BusLogic_HostAdapterStatus HostAdapterStatus;	/* Byte 4 */
	enum BusLogic_TargetDeviceStatus TargetDeviceStatus;	/* Byte 5 */
	unsigned char:8;	/* Byte 6 */
	enum BusLogic_CompletionCode CompletionCode;	/* Byte 7 */
};


/*
  Define the BusLogic Driver Options structure.
*/

struct BusLogic_DriverOptions {
	unsigned short TaggedQueuingPermitted;
	unsigned short TaggedQueuingPermittedMask;
	unsigned short BusSettleTime;
	struct BusLogic_LocalOptions LocalOptions;
	unsigned char CommonQueueDepth;
	unsigned char QueueDepth[BusLogic_MaxTargetDevices];
};

/*
  Define the Host Adapter Target Flags structure.
*/

struct BusLogic_TargetFlags {
	bool TargetExists:1;
	bool TaggedQueuingSupported:1;
	bool WideTransfersSupported:1;
	bool TaggedQueuingActive:1;
	bool WideTransfersActive:1;
	bool CommandSuccessfulFlag:1;
	bool TargetInfoReported:1;
};

/*
  Define the Host Adapter Target Statistics structure.
*/

#define BusLogic_SizeBuckets			10

typedef unsigned int BusLogic_CommandSizeBuckets_T[BusLogic_SizeBuckets];

struct BusLogic_TargetStatistics {
	unsigned int CommandsAttempted;
	unsigned int CommandsCompleted;
	unsigned int ReadCommands;
	unsigned int WriteCommands;
	struct BusLogic_ByteCounter TotalBytesRead;
	struct BusLogic_ByteCounter TotalBytesWritten;
	BusLogic_CommandSizeBuckets_T ReadCommandSizeBuckets;
	BusLogic_CommandSizeBuckets_T WriteCommandSizeBuckets;
	unsigned short CommandAbortsRequested;
	unsigned short CommandAbortsAttempted;
	unsigned short CommandAbortsCompleted;
	unsigned short BusDeviceResetsRequested;
	unsigned short BusDeviceResetsAttempted;
	unsigned short BusDeviceResetsCompleted;
	unsigned short HostAdapterResetsRequested;
	unsigned short HostAdapterResetsAttempted;
	unsigned short HostAdapterResetsCompleted;
};

/*
  Define the FlashPoint Card Handle data type.
*/

#define FlashPoint_BadCardHandle		0xFFFFFFFF

typedef unsigned int FlashPoint_CardHandle_T;


/*
  Define the FlashPoint Information structure.  This structure is defined
  by the FlashPoint SCCB Manager.
*/

struct FlashPoint_Info {
	u32 BaseAddress;	/* Bytes 0-3 */
	bool Present;		/* Byte 4 */
	unsigned char IRQ_Channel;	/* Byte 5 */
	unsigned char SCSI_ID;	/* Byte 6 */
	unsigned char SCSI_LUN;	/* Byte 7 */
	unsigned short FirmwareRevision;	/* Bytes 8-9 */
	unsigned short SynchronousPermitted;	/* Bytes 10-11 */
	unsigned short FastPermitted;	/* Bytes 12-13 */
	unsigned short UltraPermitted;	/* Bytes 14-15 */
	unsigned short DisconnectPermitted;	/* Bytes 16-17 */
	unsigned short WidePermitted;	/* Bytes 18-19 */
	bool ParityCheckingEnabled:1;	/* Byte 20 Bit 0 */
	bool HostWideSCSI:1;		/* Byte 20 Bit 1 */
	bool HostSoftReset:1;		/* Byte 20 Bit 2 */
	bool ExtendedTranslationEnabled:1;	/* Byte 20 Bit 3 */
	bool LowByteTerminated:1;	/* Byte 20 Bit 4 */
	bool HighByteTerminated:1;	/* Byte 20 Bit 5 */
	bool ReportDataUnderrun:1;	/* Byte 20 Bit 6 */
	bool SCAM_Enabled:1;	/* Byte 20 Bit 7 */
	bool SCAM_Level2:1;	/* Byte 21 Bit 0 */
	unsigned char:7;	/* Byte 21 Bits 1-7 */
	unsigned char Family;	/* Byte 22 */
	unsigned char BusType;	/* Byte 23 */
	unsigned char ModelNumber[3];	/* Bytes 24-26 */
	unsigned char RelativeCardNumber;	/* Byte 27 */
	unsigned char Reserved[4];	/* Bytes 28-31 */
	unsigned int OS_Reserved;	/* Bytes 32-35 */
	unsigned char TranslationInfo[4];	/* Bytes 36-39 */
	unsigned int Reserved2[5];	/* Bytes 40-59 */
	unsigned int SecondaryRange;	/* Bytes 60-63 */
};

/*
  Define the BusLogic Driver Host Adapter structure.
*/

struct BusLogic_HostAdapter {
	struct Scsi_Host *SCSI_Host;
	struct pci_dev *PCI_Device;
	enum BusLogic_HostAdapterType HostAdapterType;
	enum BusLogic_HostAdapterBusType HostAdapterBusType;
	unsigned long IO_Address;
	unsigned long PCI_Address;
	unsigned short AddressCount;
	unsigned char HostNumber;
	unsigned char ModelName[9];
	unsigned char FirmwareVersion[6];
	unsigned char FullModelName[18];
	unsigned char Bus;
	unsigned char Device;
	unsigned char IRQ_Channel;
	unsigned char DMA_Channel;
	unsigned char SCSI_ID;
	bool IRQ_ChannelAcquired:1;
	bool DMA_ChannelAcquired:1;
	bool ExtendedTranslationEnabled:1;
	bool ParityCheckingEnabled:1;
	bool BusResetEnabled:1;
	bool LevelSensitiveInterrupt:1;
	bool HostWideSCSI:1;
	bool HostDifferentialSCSI:1;
	bool HostSupportsSCAM:1;
	bool HostUltraSCSI:1;
	bool ExtendedLUNSupport:1;
	bool TerminationInfoValid:1;
	bool LowByteTerminated:1;
	bool HighByteTerminated:1;
	bool BounceBuffersRequired:1;
	bool StrictRoundRobinModeSupport:1;
	bool SCAM_Enabled:1;
	bool SCAM_Level2:1;
	bool HostAdapterInitialized:1;
	bool HostAdapterExternalReset:1;
	bool HostAdapterInternalError:1;
	bool ProcessCompletedCCBsActive;
	volatile bool HostAdapterCommandCompleted;
	unsigned short HostAdapterScatterGatherLimit;
	unsigned short DriverScatterGatherLimit;
	unsigned short MaxTargetDevices;
	unsigned short MaxLogicalUnits;
	unsigned short MailboxCount;
	unsigned short InitialCCBs;
	unsigned short IncrementalCCBs;
	unsigned short AllocatedCCBs;
	unsigned short DriverQueueDepth;
	unsigned short HostAdapterQueueDepth;
	unsigned short UntaggedQueueDepth;
	unsigned short CommonQueueDepth;
	unsigned short BusSettleTime;
	unsigned short SynchronousPermitted;
	unsigned short FastPermitted;
	unsigned short UltraPermitted;
	unsigned short WidePermitted;
	unsigned short DisconnectPermitted;
	unsigned short TaggedQueuingPermitted;
	unsigned short ExternalHostAdapterResets;
	unsigned short HostAdapterInternalErrors;
	unsigned short TargetDeviceCount;
	unsigned short MessageBufferLength;
	u32 BIOS_Address;
	struct BusLogic_DriverOptions *DriverOptions;
	struct FlashPoint_Info FlashPointInfo;
	FlashPoint_CardHandle_T CardHandle;
	struct list_head host_list;
	struct BusLogic_CCB *All_CCBs;
	struct BusLogic_CCB *Free_CCBs;
	struct BusLogic_CCB *FirstCompletedCCB;
	struct BusLogic_CCB *LastCompletedCCB;
	struct BusLogic_CCB *BusDeviceResetPendingCCB[BusLogic_MaxTargetDevices];
	struct BusLogic_TargetFlags TargetFlags[BusLogic_MaxTargetDevices];
	unsigned char QueueDepth[BusLogic_MaxTargetDevices];
	unsigned char SynchronousPeriod[BusLogic_MaxTargetDevices];
	unsigned char SynchronousOffset[BusLogic_MaxTargetDevices];
	unsigned char ActiveCommands[BusLogic_MaxTargetDevices];
	unsigned int CommandsSinceReset[BusLogic_MaxTargetDevices];
	unsigned long LastSequencePoint[BusLogic_MaxTargetDevices];
	unsigned long LastResetAttempted[BusLogic_MaxTargetDevices];
	unsigned long LastResetCompleted[BusLogic_MaxTargetDevices];
	struct BusLogic_OutgoingMailbox *FirstOutgoingMailbox;
	struct BusLogic_OutgoingMailbox *LastOutgoingMailbox;
	struct BusLogic_OutgoingMailbox *NextOutgoingMailbox;
	struct BusLogic_IncomingMailbox *FirstIncomingMailbox;
	struct BusLogic_IncomingMailbox *LastIncomingMailbox;
	struct BusLogic_IncomingMailbox *NextIncomingMailbox;
	struct BusLogic_TargetStatistics TargetStatistics[BusLogic_MaxTargetDevices];
	unsigned char *MailboxSpace;
	dma_addr_t MailboxSpaceHandle;
	unsigned int MailboxSize;
	unsigned long CCB_Offset;
	char MessageBuffer[BusLogic_MessageBufferSize];
};

/*
  Define a structure for the BIOS Disk Parameters.
*/

struct BIOS_DiskParameters {
	int Heads;
	int Sectors;
	int Cylinders;
};

/*
  Define a structure for the SCSI Inquiry command results.
*/

struct SCSI_Inquiry {
	unsigned char PeripheralDeviceType:5;	/* Byte 0 Bits 0-4 */
	unsigned char PeripheralQualifier:3;	/* Byte 0 Bits 5-7 */
	unsigned char DeviceTypeModifier:7;	/* Byte 1 Bits 0-6 */
	bool RMB:1;		/* Byte 1 Bit 7 */
	unsigned char ANSI_ApprovedVersion:3;	/* Byte 2 Bits 0-2 */
	unsigned char ECMA_Version:3;	/* Byte 2 Bits 3-5 */
	unsigned char ISO_Version:2;	/* Byte 2 Bits 6-7 */
	unsigned char ResponseDataFormat:4;	/* Byte 3 Bits 0-3 */
	unsigned char:2;	/* Byte 3 Bits 4-5 */
	bool TrmIOP:1;		/* Byte 3 Bit 6 */
	bool AENC:1;		/* Byte 3 Bit 7 */
	unsigned char AdditionalLength;	/* Byte 4 */
	unsigned char:8;	/* Byte 5 */
	unsigned char:8;	/* Byte 6 */
	bool SftRe:1;		/* Byte 7 Bit 0 */
	bool CmdQue:1;		/* Byte 7 Bit 1 */
	 bool:1;		/* Byte 7 Bit 2 */
	bool Linked:1;		/* Byte 7 Bit 3 */
	bool Sync:1;		/* Byte 7 Bit 4 */
	bool WBus16:1;		/* Byte 7 Bit 5 */
	bool WBus32:1;		/* Byte 7 Bit 6 */
	bool RelAdr:1;		/* Byte 7 Bit 7 */
	unsigned char VendorIdentification[8];	/* Bytes 8-15 */
	unsigned char ProductIdentification[16];	/* Bytes 16-31 */
	unsigned char ProductRevisionLevel[4];	/* Bytes 32-35 */
};


/*
  Define functions to provide an abstraction for reading and writing the
  Host Adapter I/O Registers.
*/

static inline void BusLogic_SCSIBusReset(struct BusLogic_HostAdapter *HostAdapter)
{
	union BusLogic_ControlRegister ControlRegister;
	ControlRegister.All = 0;
	ControlRegister.cr.SCSIBusReset = true;
	outb(ControlRegister.All, HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
}

static inline void BusLogic_InterruptReset(struct BusLogic_HostAdapter *HostAdapter)
{
	union BusLogic_ControlRegister ControlRegister;
	ControlRegister.All = 0;
	ControlRegister.cr.InterruptReset = true;
	outb(ControlRegister.All, HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
}

static inline void BusLogic_SoftReset(struct BusLogic_HostAdapter *HostAdapter)
{
	union BusLogic_ControlRegister ControlRegister;
	ControlRegister.All = 0;
	ControlRegister.cr.SoftReset = true;
	outb(ControlRegister.All, HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
}

static inline void BusLogic_HardReset(struct BusLogic_HostAdapter *HostAdapter)
{
	union BusLogic_ControlRegister ControlRegister;
	ControlRegister.All = 0;
	ControlRegister.cr.HardReset = true;
	outb(ControlRegister.All, HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
}

static inline unsigned char BusLogic_ReadStatusRegister(struct BusLogic_HostAdapter *HostAdapter)
{
	return inb(HostAdapter->IO_Address + BusLogic_StatusRegisterOffset);
}

static inline void BusLogic_WriteCommandParameterRegister(struct BusLogic_HostAdapter
							  *HostAdapter, unsigned char Value)
{
	outb(Value, HostAdapter->IO_Address + BusLogic_CommandParameterRegisterOffset);
}

static inline unsigned char BusLogic_ReadDataInRegister(struct BusLogic_HostAdapter *HostAdapter)
{
	return inb(HostAdapter->IO_Address + BusLogic_DataInRegisterOffset);
}

static inline unsigned char BusLogic_ReadInterruptRegister(struct BusLogic_HostAdapter *HostAdapter)
{
	return inb(HostAdapter->IO_Address + BusLogic_InterruptRegisterOffset);
}

static inline unsigned char BusLogic_ReadGeometryRegister(struct BusLogic_HostAdapter *HostAdapter)
{
	return inb(HostAdapter->IO_Address + BusLogic_GeometryRegisterOffset);
}

/*
  BusLogic_StartMailboxCommand issues an Execute Mailbox Command, which
  notifies the Host Adapter that an entry has been made in an Outgoing
  Mailbox.
*/

static inline void BusLogic_StartMailboxCommand(struct BusLogic_HostAdapter *HostAdapter)
{
	BusLogic_WriteCommandParameterRegister(HostAdapter, BusLogic_ExecuteMailboxCommand);
}

/*
  BusLogic_Delay waits for Seconds to elapse.
*/

static inline void BusLogic_Delay(int Seconds)
{
	mdelay(1000 * Seconds);
}

/*
  Virtual_to_Bus and Bus_to_Virtual map between Kernel Virtual Addresses
  and PCI/VLB/EISA/ISA Bus Addresses.
*/

static inline u32 Virtual_to_Bus(void *VirtualAddress)
{
	return (u32) virt_to_bus(VirtualAddress);
}

static inline void *Bus_to_Virtual(u32 BusAddress)
{
	return (void *) bus_to_virt(BusAddress);
}

/*
  Virtual_to_32Bit_Virtual maps between Kernel Virtual Addresses and
  32 bit Kernel Virtual Addresses.  This avoids compilation warnings
  on 64 bit architectures.
*/

static inline u32 Virtual_to_32Bit_Virtual(void *VirtualAddress)
{
	return (u32) (unsigned long) VirtualAddress;
}

/*
  BusLogic_IncrementErrorCounter increments Error Counter by 1, stopping at
  65535 rather than wrapping around to 0.
*/

static inline void BusLogic_IncrementErrorCounter(unsigned short *ErrorCounter)
{
	if (*ErrorCounter < 65535)
		(*ErrorCounter)++;
}

/*
  BusLogic_IncrementByteCounter increments Byte Counter by Amount.
*/

static inline void BusLogic_IncrementByteCounter(struct BusLogic_ByteCounter
						 *ByteCounter, unsigned int Amount)
{
	ByteCounter->Units += Amount;
	if (ByteCounter->Units > 999999999) {
		ByteCounter->Units -= 1000000000;
		ByteCounter->Billions++;
	}
}

/*
  BusLogic_IncrementSizeBucket increments the Bucket for Amount.
*/

static inline void BusLogic_IncrementSizeBucket(BusLogic_CommandSizeBuckets_T CommandSizeBuckets, unsigned int Amount)
{
	int Index = 0;
	if (Amount < 8 * 1024) {
		if (Amount < 2 * 1024)
			Index = (Amount < 1 * 1024 ? 0 : 1);
		else
			Index = (Amount < 4 * 1024 ? 2 : 3);
	} else if (Amount < 128 * 1024) {
		if (Amount < 32 * 1024)
			Index = (Amount < 16 * 1024 ? 4 : 5);
		else
			Index = (Amount < 64 * 1024 ? 6 : 7);
	} else
		Index = (Amount < 256 * 1024 ? 8 : 9);
	CommandSizeBuckets[Index]++;
}

/*
  Define the version number of the FlashPoint Firmware (SCCB Manager).
*/

#define FlashPoint_FirmwareVersion		"5.02"

/*
  Define the possible return values from FlashPoint_HandleInterrupt.
*/

#define FlashPoint_NormalInterrupt		0x00
#define FlashPoint_InternalError		0xFE
#define FlashPoint_ExternalBusReset		0xFF

/*
  Define prototypes for the forward referenced BusLogic Driver
  Internal Functions.
*/

static const char *BusLogic_DriverInfo(struct Scsi_Host *);
static int BusLogic_QueueCommand(struct Scsi_Host *h, struct scsi_cmnd *);
static int BusLogic_BIOSDiskParameters(struct scsi_device *, struct block_device *, sector_t, int *);
static int BusLogic_SlaveConfigure(struct scsi_device *);
static void BusLogic_QueueCompletedCCB(struct BusLogic_CCB *);
static irqreturn_t BusLogic_InterruptHandler(int, void *);
static int BusLogic_ResetHostAdapter(struct BusLogic_HostAdapter *, bool HardReset);
static void BusLogic_Message(enum BusLogic_MessageLevel, char *, struct BusLogic_HostAdapter *, ...);
static int __init BusLogic_Setup(char *);

#endif				/* _BUSLOGIC_H */