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
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
|
/*
Linux Driver for BusLogic MultiMaster SCSI Host Adapters
Copyright 1995 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, provided that none of the source code or runtime
copyright notices are removed or modified.
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 all modifications to this software be
sent directly to him for evaluation and testing.
Special thanks to Alex T. Win of BusLogic, whose advice has been invaluable,
to David B. Gentzel, for writing the original Linux BusLogic driver, and to
Paul Gortmaker, for being such a dedicated test site.
*/
#define BusLogic_DriverVersion "1.3.1"
#define BusLogic_DriverDate "31 December 1995"
#include <linux/module.h>
#include <linux/config.h>
#include <linux/types.h>
#include <linux/blkdev.h>
#include <linux/delay.h>
#include <linux/ioport.h>
#include <linux/kernel_stat.h>
#include <linux/mm.h>
#include <linux/sched.h>
#include <linux/stat.h>
#include <linux/pci.h>
#include <linux/bios32.h>
#include <asm/dma.h>
#include <asm/io.h>
#include <asm/system.h>
#include "scsi.h"
#include "hosts.h"
#include "sd.h"
#include "BusLogic.h"
/*
BusLogic_CommandLineEntryCount is a count of the number of "BusLogic="
entries provided on the Linux Kernel Command Line.
*/
static int
BusLogic_CommandLineEntryCount = 0;
/*
BusLogic_CommandLineEntries is an array of Command Line Entry structures
representing the "BusLogic=" entries provided on the Linux Kernel Command
Line.
*/
static BusLogic_CommandLineEntry_T
BusLogic_CommandLineEntries[BusLogic_MaxHostAdapters];
/*
BusLogic_GlobalOptions is a bit mask of Global Options to be applied
across all Host Adapters.
*/
static int
BusLogic_GlobalOptions = 0;
/*
BusLogic_RegisteredHostAdapters is a linked list of all the registered
BusLogic Host Adapters.
*/
static BusLogic_HostAdapter_T
*BusLogic_RegisteredHostAdapters = NULL;
/*
BusLogic_Standard_IO_Addresses is the list of standard I/O Addresses at which
BusLogic Host Adapters may potentially be found.
*/
static unsigned short
BusLogic_IO_StandardAddresses[] =
{ 0x330, 0x334, 0x230, 0x234, 0x130, 0x134, 0 };
/*
BusLogic_IO_AddressProbeList is the list of I/O Addresses to be probed for
potential BusLogic Host Adapters. It is initialized by interrogating the
PCI Configuration Space on PCI machines as well as from the list of
standard BusLogic I/O Addresses.
*/
static unsigned short
BusLogic_IO_AddressProbeList[BusLogic_IO_MaxProbeAddresses+1] = { 0 };
/*
BusLogic_IRQ_UsageCount stores a count of the number of Host Adapters using
a given IRQ Channel, which is necessary to support PCI, EISA, or MCA shared
interrupts. Only IRQ Channels 9, 10, 11, 12, 14, and 15 are supported by
BusLogic Host Adapters.
*/
static short
BusLogic_IRQ_UsageCount[7] = { 0 };
/*
BusLogic_CommandFailureReason holds a string identifying the reason why a
call to BusLogic_Command failed. It is only valid when BusLogic_Command
returns a failure code.
*/
static char
*BusLogic_CommandFailureReason;
/*
BusLogic_ProcDirectoryEntry is the BusLogic /proc/scsi directory entry.
*/
static struct proc_dir_entry
BusLogic_ProcDirectoryEntry =
{ PROC_SCSI_BUSLOGIC, 8, "BusLogic", S_IFDIR | S_IRUGO | S_IXUGO, 2 };
/*
BusLogic_AnnounceDriver announces the Driver Version and Date, Author's
Name, Copyright Notice, and Contact Address.
*/
static void BusLogic_AnnounceDriver(void)
{
static boolean DriverAnnouncementPrinted = false;
if (DriverAnnouncementPrinted) return;
printk("scsi: ***** BusLogic SCSI Driver Version "
BusLogic_DriverVersion " of " BusLogic_DriverDate " *****\n");
printk("scsi: Copyright 1995 by Leonard N. Zubkoff <lnz@dandelion.com>\n");
DriverAnnouncementPrinted = true;
}
/*
BusLogic_DriverInfo returns the Board Name to identify this SCSI Driver
and Host Adapter.
*/
const char *BusLogic_DriverInfo(SCSI_Host_T *Host)
{
BusLogic_HostAdapter_T *HostAdapter =
(BusLogic_HostAdapter_T *) Host->hostdata;
return HostAdapter->BoardName;
}
/*
BusLogic_InitializeAddressProbeList initializes the list of I/O Addresses
to be probed for potential BusLogic SCSI Host Adapters by interrogating the
PCI Configuration Space on PCI machines as well as from the list of standard
BusLogic I/O Addresses.
*/
static void BusLogic_InitializeAddressProbeList(void)
{
int DestinationIndex = 0, SourceIndex = 0;
/*
If BusLogic_Setup has been called, do not override the Kernel Command
Line specifications.
*/
if (BusLogic_IO_AddressProbeList[0] != 0) return;
#ifdef CONFIG_PCI
/*
Interrogate PCI Configuration Space for any BusLogic SCSI Host Adapters.
*/
if (pcibios_present())
{
unsigned short Index = 0, VendorID;
unsigned char Bus, DeviceAndFunction;
unsigned int BaseAddress0;
while (pcibios_find_class(PCI_CLASS_STORAGE_SCSI<<8, Index++,
&Bus, &DeviceAndFunction) == 0)
if (pcibios_read_config_word(Bus, DeviceAndFunction,
PCI_VENDOR_ID, &VendorID) == 0 &&
VendorID == PCI_VENDOR_ID_BUSLOGIC &&
pcibios_read_config_dword(Bus, DeviceAndFunction,
PCI_BASE_ADDRESS_0, &BaseAddress0) == 0 &&
(BaseAddress0 & PCI_BASE_ADDRESS_SPACE) ==
PCI_BASE_ADDRESS_SPACE_IO)
{
BusLogic_IO_AddressProbeList[DestinationIndex++] =
BaseAddress0 & PCI_BASE_ADDRESS_IO_MASK;
}
}
#endif
/*
Append the list of standard BusLogic I/O Addresses.
*/
while (DestinationIndex < BusLogic_IO_MaxProbeAddresses &&
BusLogic_IO_StandardAddresses[SourceIndex] > 0)
BusLogic_IO_AddressProbeList[DestinationIndex++] =
BusLogic_IO_StandardAddresses[SourceIndex++];
BusLogic_IO_AddressProbeList[DestinationIndex] = 0;
}
/*
BusLogic_RegisterHostAdapter adds Host Adapter to the list of registered
BusLogic Host Adapters.
*/
static void BusLogic_RegisterHostAdapter(BusLogic_HostAdapter_T *HostAdapter)
{
HostAdapter->Next = NULL;
if (BusLogic_RegisteredHostAdapters != NULL)
{
BusLogic_HostAdapter_T *LastHostAdapter = BusLogic_RegisteredHostAdapters;
BusLogic_HostAdapter_T *NextHostAdapter;
while ((NextHostAdapter = LastHostAdapter->Next) != NULL)
LastHostAdapter = NextHostAdapter;
LastHostAdapter->Next = HostAdapter;
}
else BusLogic_RegisteredHostAdapters = HostAdapter;
}
/*
BusLogic_UnregisterHostAdapter removes Host Adapter from the list of
registered BusLogic Host Adapters.
*/
static void BusLogic_UnregisterHostAdapter(BusLogic_HostAdapter_T *HostAdapter)
{
if (BusLogic_RegisteredHostAdapters != HostAdapter)
{
BusLogic_HostAdapter_T *LastHostAdapter = BusLogic_RegisteredHostAdapters;
while (LastHostAdapter != NULL && LastHostAdapter->Next != HostAdapter)
LastHostAdapter = LastHostAdapter->Next;
if (LastHostAdapter != NULL)
LastHostAdapter->Next = HostAdapter->Next;
}
else BusLogic_RegisteredHostAdapters = HostAdapter->Next;
HostAdapter->Next = NULL;
}
/*
BusLogic_CreateCCBs allocates the initial Command Control Blocks (CCBs)
for Host Adapter.
*/
static boolean BusLogic_CreateCCBs(BusLogic_HostAdapter_T *HostAdapter)
{
int i;
for (i = 0; i < BusLogic_InitialCCBs; i++)
{
BusLogic_CCB_T *CCB = (BusLogic_CCB_T *)
scsi_init_malloc(sizeof(BusLogic_CCB_T), GFP_ATOMIC | GFP_DMA);
if (CCB == NULL)
{
printk("scsi%d: UNABLE TO ALLOCATE CCB %d - DETACHING\n",
HostAdapter->HostNumber, i);
return false;
}
memset(CCB, 0, sizeof(BusLogic_CCB_T));
CCB->HostAdapter = HostAdapter;
CCB->Status = BusLogic_CCB_Free;
CCB->Next = HostAdapter->Free_CCBs;
CCB->NextAll = HostAdapter->All_CCBs;
HostAdapter->Free_CCBs = CCB;
HostAdapter->All_CCBs = CCB;
}
return true;
}
/*
BusLogic_DestroyCCBs deallocates the CCBs for Host Adapter.
*/
static void BusLogic_DestroyCCBs(BusLogic_HostAdapter_T *HostAdapter)
{
BusLogic_CCB_T *NextCCB = HostAdapter->All_CCBs, *CCB;
HostAdapter->All_CCBs = NULL;
HostAdapter->Free_CCBs = NULL;
while ((CCB = NextCCB) != NULL)
{
NextCCB = CCB->NextAll;
scsi_init_free((char *) CCB, sizeof(BusLogic_CCB_T));
}
}
/*
BusLogic_AllocateCCB allocates a CCB from the Host Adapter's free list,
allocating more memory from the Kernel if necessary.
*/
static BusLogic_CCB_T *BusLogic_AllocateCCB(BusLogic_HostAdapter_T *HostAdapter)
{
static unsigned int SerialNumber = 0;
BusLogic_CCB_T *CCB;
BusLogic_LockHostAdapter(HostAdapter);
CCB = HostAdapter->Free_CCBs;
if (CCB != NULL)
{
CCB->SerialNumber = ++SerialNumber;
HostAdapter->Free_CCBs = CCB->Next;
CCB->Next = NULL;
BusLogic_UnlockHostAdapter(HostAdapter);
return CCB;
}
BusLogic_UnlockHostAdapter(HostAdapter);
CCB = (BusLogic_CCB_T *) scsi_init_malloc(sizeof(BusLogic_CCB_T),
GFP_ATOMIC | GFP_DMA);
if (CCB == NULL)
{
printk("scsi%d: Failed to allocate an additional CCB\n",
HostAdapter->HostNumber);
return NULL;
}
printk("scsi%d: Allocated an additional CCB\n", HostAdapter->HostNumber);
memset(CCB, 0, sizeof(BusLogic_CCB_T));
CCB->HostAdapter = HostAdapter;
CCB->Status = BusLogic_CCB_Free;
BusLogic_LockHostAdapter(HostAdapter);
CCB->SerialNumber = ++SerialNumber;
CCB->NextAll = HostAdapter->All_CCBs;
HostAdapter->All_CCBs = CCB;
BusLogic_UnlockHostAdapter(HostAdapter);
return CCB;
}
/*
BusLogic_DeallocateCCB deallocates a CCB, returning it to the Host Adapter's
free list.
*/
static void BusLogic_DeallocateCCB(BusLogic_CCB_T *CCB)
{
BusLogic_HostAdapter_T *HostAdapter = CCB->HostAdapter;
BusLogic_LockHostAdapter(HostAdapter);
CCB->Command = NULL;
CCB->Status = BusLogic_CCB_Free;
CCB->Next = HostAdapter->Free_CCBs;
HostAdapter->Free_CCBs = CCB;
BusLogic_UnlockHostAdapter(HostAdapter);
}
/*
BusLogic_Command sends the command OperationCode to HostAdapter, optionally
providing ParameterLength bytes of ParameterData and receiving at most
ReplyLength bytes of ReplyData; any excess reply data is received but
discarded.
On success, this function returns the number of reply bytes read from
the Host Adapter (including any discarded data); on failure, it returns
-1 if the command was invalid, or -2 if a timeout occurred.
This function is only called during board detection and initialization, so
performance and latency are not critical, and exclusive access to the Host
Adapter hardware is assumed. Once the board and driver are initialized, the
only Host Adapter command that is issued is the single byte Start Mailbox
Scan command, which does not require waiting for the Host Adapter Ready bit
to be set in the Status Register.
*/
static int BusLogic_Command(BusLogic_HostAdapter_T *HostAdapter,
BusLogic_OperationCode_T OperationCode,
void *ParameterData,
int ParameterLength,
void *ReplyData,
int ReplyLength)
{
unsigned char *ParameterPointer = (unsigned char *) ParameterData;
unsigned char *ReplyPointer = (unsigned char *) ReplyData;
unsigned char StatusRegister = 0, InterruptRegister;
long TimeoutCounter;
int ReplyBytes = 0;
/*
Clear out the Reply Data if provided.
*/
if (ReplyLength > 0)
memset(ReplyData, 0, ReplyLength);
/*
Wait for the Host Adapter Ready bit to be set and the Command/Parameter
Register Busy bit to be reset in the Status Register.
*/
TimeoutCounter = loops_per_sec >> 3;
while (--TimeoutCounter >= 0)
{
StatusRegister = BusLogic_ReadStatusRegister(HostAdapter);
if ((StatusRegister & BusLogic_HostAdapterReady) &&
!(StatusRegister & BusLogic_CommandParameterRegisterBusy))
break;
}
BusLogic_CommandFailureReason = "Timeout waiting for Host Adapter Ready";
if (TimeoutCounter < 0) return -2;
/*
Write the OperationCode to the Command/Parameter Register.
*/
HostAdapter->HostAdapterCommandCompleted = false;
BusLogic_WriteCommandParameterRegister(HostAdapter, OperationCode);
/*
Write any additional Parameter Bytes.
*/
TimeoutCounter = 10000;
while (ParameterLength > 0 && --TimeoutCounter >= 0)
{
/*
Wait 100 microseconds to give the Host Adapter enough time to determine
whether the last value written to the Command/Parameter Register was
valid or not. If the Command Complete bit is set in the Interrupt
Register, then the Command Invalid bit in the Status Register will be
reset if the Operation Code or Parameter was valid and the command
has completed, or set if the Operation Code or Parameter was invalid.
If the Data In Register Ready bit is set in the Status Register, then
the Operation Code was valid, and data is waiting to be read back
from the Host Adapter. Otherwise, wait for the Command/Parameter
Register Busy bit in the Status Register to be reset.
*/
udelay(100);
InterruptRegister = BusLogic_ReadInterruptRegister(HostAdapter);
StatusRegister = BusLogic_ReadStatusRegister(HostAdapter);
if (InterruptRegister & BusLogic_CommandComplete) break;
if (HostAdapter->HostAdapterCommandCompleted) break;
if (StatusRegister & BusLogic_DataInRegisterReady) break;
if (StatusRegister & BusLogic_CommandParameterRegisterBusy) continue;
BusLogic_WriteCommandParameterRegister(HostAdapter, *ParameterPointer++);
ParameterLength--;
}
BusLogic_CommandFailureReason = "Timeout waiting for Parameter Acceptance";
if (TimeoutCounter < 0) return -2;
/*
The Modify I/O Address command does not cause a Command Complete Interrupt.
*/
if (OperationCode == BusLogic_ModifyIOAddress)
{
StatusRegister = BusLogic_ReadStatusRegister(HostAdapter);
BusLogic_CommandFailureReason = "Modify I/O Address Invalid";
if (StatusRegister & BusLogic_CommandInvalid) return -1;
BusLogic_CommandFailureReason = NULL;
return 0;
}
/*
Select an appropriate timeout value for awaiting command completion.
*/
switch (OperationCode)
{
case BusLogic_InquireInstalledDevicesID0to7:
case BusLogic_InquireInstalledDevicesID8to15:
/* Approximately 60 seconds. */
TimeoutCounter = loops_per_sec << 2;
break;
default:
/* Approximately 1 second. */
TimeoutCounter = loops_per_sec >> 4;
break;
}
/*
Receive any Reply Bytes, waiting for either the Command Complete bit to
be set in the Interrupt Register, or for the Interrupt Handler to set the
Host Adapter Command Completed bit in the Host Adapter structure.
*/
while (--TimeoutCounter >= 0)
{
InterruptRegister = BusLogic_ReadInterruptRegister(HostAdapter);
StatusRegister = BusLogic_ReadStatusRegister(HostAdapter);
if (InterruptRegister & BusLogic_CommandComplete) break;
if (HostAdapter->HostAdapterCommandCompleted) break;
if (StatusRegister & BusLogic_DataInRegisterReady)
if (++ReplyBytes <= ReplyLength)
*ReplyPointer++ = BusLogic_ReadDataInRegister(HostAdapter);
else BusLogic_ReadDataInRegister(HostAdapter);
}
BusLogic_CommandFailureReason = "Timeout waiting for Command Complete";
if (TimeoutCounter < 0) return -2;
/*
If testing Command Complete Interrupts, wait a short while in case the
loop immediately above terminated due to the Command Complete bit being
set in the Interrupt Register, but the interrupt hasn't actually been
processed yet. Otherwise, acknowledging the interrupt here could prevent
the interrupt test from succeeding.
*/
if (OperationCode == BusLogic_TestCommandCompleteInterrupt)
udelay(10000);
/*
Clear any pending Command Complete Interrupt.
*/
BusLogic_WriteControlRegister(HostAdapter, BusLogic_InterruptReset);
if (BusLogic_GlobalOptions & BusLogic_TraceConfiguration)
if (OperationCode != BusLogic_TestCommandCompleteInterrupt)
{
int i;
printk("BusLogic_Command(%02X) Status = %02X: %2d ==> %2d:",
OperationCode, StatusRegister, ReplyLength, ReplyBytes);
if (ReplyLength > ReplyBytes) ReplyLength = ReplyBytes;
for (i = 0; i < ReplyLength; i++)
printk(" %02X", ((unsigned char *) ReplyData)[i]);
printk("\n");
}
/*
Process Command Invalid conditions.
*/
if (StatusRegister & BusLogic_CommandInvalid)
{
/*
Some early BusLogic Host Adapters may not recover properly from
a Command Invalid condition, so if this appears to be the case,
a Soft Reset is issued to the Host Adapter. Potentially invalid
commands are never attempted after Mailbox Initialization is
performed, so there should be no Host Adapter state lost by a
Soft Reset in response to a Command Invalid condition.
*/
udelay(1000);
StatusRegister = BusLogic_ReadStatusRegister(HostAdapter);
if (StatusRegister != (BusLogic_HostAdapterReady |
BusLogic_InitializationRequired))
{
BusLogic_WriteControlRegister(HostAdapter, BusLogic_SoftReset);
udelay(1000);
}
BusLogic_CommandFailureReason = "Command Invalid";
return -1;
}
/*
Handle Excess Parameters Supplied conditions.
*/
BusLogic_CommandFailureReason = "Excess Parameters Supplied";
if (ParameterLength > 0) return -1;
/*
Indicate the command completed successfully.
*/
BusLogic_CommandFailureReason = NULL;
return ReplyBytes;
}
/*
BusLogic_Failure prints a standardized error message, and then returns false.
*/
static boolean BusLogic_Failure(BusLogic_HostAdapter_T *HostAdapter,
char *ErrorMessage)
{
BusLogic_AnnounceDriver();
printk("While configuring BusLogic Host Adapter at I/O Address 0x%X:\n",
HostAdapter->IO_Address);
printk("%s FAILED - DETACHING\n", ErrorMessage);
if (BusLogic_CommandFailureReason != NULL)
printk("ADDITIONAL FAILURE INFO - %s\n", BusLogic_CommandFailureReason);
return false;
}
/*
BusLogic_ProbeHostAdapter probes for a BusLogic Host Adapter.
*/
static boolean BusLogic_ProbeHostAdapter(BusLogic_HostAdapter_T *HostAdapter)
{
boolean TraceProbe = (BusLogic_GlobalOptions & BusLogic_TraceProbe);
unsigned char StatusRegister, GeometryRegister;
/*
Read the Status Register to test if there is an I/O port that responds. A
nonexistent I/O port will return 0xFF, in which case there is definitely no
BusLogic Host Adapter at this base I/O Address.
*/
StatusRegister = BusLogic_ReadStatusRegister(HostAdapter);
if (TraceProbe)
printk("BusLogic_Probe(0x%X): Status 0x%02X\n",
HostAdapter->IO_Address, StatusRegister);
if (StatusRegister == 0xFF) return false;
/*
Read the undocumented BusLogic Geometry Register to test if there is an I/O
port that responds. Adaptec Host Adapters do not implement the Geometry
Register, so this test helps serve to avoid incorrectly recognizing an
Adaptec 1542A or 1542B as a BusLogic. Unfortunately, the Adaptec 1542C
series does respond to the Geometry Register I/O port, but it will be
rejected later when the Inquire Extended Setup Information command is
issued in BusLogic_CheckHostAdapter. The AMI FastDisk Host Adapter is a
BusLogic clone that implements the same interface as earlier BusLogic
boards, including the undocumented commands, and is therefore supported by
this driver. However, the AMI FastDisk always returns 0x00 upon reading
the Geometry Register, so the extended translation option should always be
left disabled on the AMI FastDisk.
*/
GeometryRegister = BusLogic_ReadGeometryRegister(HostAdapter);
if (TraceProbe)
printk("BusLogic_Probe(0x%X): Geometry 0x%02X\n",
HostAdapter->IO_Address, GeometryRegister);
if (GeometryRegister == 0xFF) return false;
/*
Indicate the Host Adapter Probe completed successfully.
*/
return true;
}
/*
BusLogic_HardResetHostAdapter issues a Hard Reset to the Host Adapter,
and waits for Host Adapter Diagnostics to complete.
*/
static boolean BusLogic_HardResetHostAdapter(BusLogic_HostAdapter_T
*HostAdapter)
{
boolean TraceHardReset = (BusLogic_GlobalOptions & BusLogic_TraceHardReset);
long TimeoutCounter = loops_per_sec >> 2;
unsigned char StatusRegister = 0;
/*
Issue a Hard Reset Command to the Host Adapter. The Host Adapter should
respond by setting Diagnostic Active in the Status Register.
*/
BusLogic_WriteControlRegister(HostAdapter, BusLogic_HardReset);
/*
Wait until Diagnostic Active is set in the Status Register.
*/
while (--TimeoutCounter >= 0)
{
StatusRegister = BusLogic_ReadStatusRegister(HostAdapter);
if ((StatusRegister & BusLogic_DiagnosticActive)) break;
}
if (TraceHardReset)
printk("BusLogic_HardReset(0x%X): Diagnostic Active, Status 0x%02X\n",
HostAdapter->IO_Address, StatusRegister);
if (TimeoutCounter < 0) return false;
/*
Wait 100 microseconds to allow completion of any initial diagnostic
activity which might leave the contents of the Status Register
unpredictable.
*/
udelay(100);
/*
Wait until Diagnostic Active is reset in the Status Register.
*/
while (--TimeoutCounter >= 0)
{
StatusRegister = BusLogic_ReadStatusRegister(HostAdapter);
if (!(StatusRegister & BusLogic_DiagnosticActive)) break;
}
if (TraceHardReset)
printk("BusLogic_HardReset(0x%X): Diagnostic Completed, Status 0x%02X\n",
HostAdapter->IO_Address, StatusRegister);
if (TimeoutCounter < 0) return false;
/*
Wait until at least one of the Diagnostic Failure, Host Adapter Ready,
or Data In Register Ready bits is set in the Status Register.
*/
while (--TimeoutCounter >= 0)
{
StatusRegister = BusLogic_ReadStatusRegister(HostAdapter);
if (StatusRegister & (BusLogic_DiagnosticFailure |
BusLogic_HostAdapterReady |
BusLogic_DataInRegisterReady))
break;
}
if (TraceHardReset)
printk("BusLogic_HardReset(0x%X): Host Adapter Ready, Status 0x%02X\n",
HostAdapter->IO_Address, StatusRegister);
if (TimeoutCounter < 0) return false;
/*
If Diagnostic Failure is set or Host Adapter Ready is reset, then an
error occurred during the Host Adapter diagnostics. If Data In Register
Ready is set, then there is an Error Code available.
*/
if ((StatusRegister & BusLogic_DiagnosticFailure) ||
!(StatusRegister & BusLogic_HostAdapterReady))
{
BusLogic_CommandFailureReason = NULL;
BusLogic_Failure(HostAdapter, "HARD RESET DIAGNOSTICS");
printk("HOST ADAPTER STATUS REGISTER = %02X\n", StatusRegister);
if (StatusRegister & BusLogic_DataInRegisterReady)
{
unsigned char ErrorCode = BusLogic_ReadDataInRegister(HostAdapter);
printk("HOST ADAPTER ERROR CODE = %d\n", ErrorCode);
}
return false;
}
/*
Indicate the Host Adapter Hard Reset completed successfully.
*/
return true;
}
/*
BusLogic_CheckHostAdapter checks to be sure this really is a BusLogic
Host Adapter.
*/
static boolean BusLogic_CheckHostAdapter(BusLogic_HostAdapter_T *HostAdapter)
{
BusLogic_ExtendedSetupInformation_T ExtendedSetupInformation;
BusLogic_RequestedReplyLength_T RequestedReplyLength;
unsigned long ProcessorFlags;
int Result;
/*
Issue the Inquire Extended Setup Information command. Only genuine
BusLogic Host Adapters and true clones support this command. Adaptec 1542C
series Host Adapters that respond to the Geometry Register I/O port will
fail this command. Interrupts must be disabled around the call to
BusLogic_Command since a Command Complete interrupt could occur if the IRQ
Channel was previously enabled for another BusLogic Host Adapter sharing
the same IRQ Channel.
*/
save_flags(ProcessorFlags);
cli();
RequestedReplyLength = sizeof(ExtendedSetupInformation);
Result = BusLogic_Command(HostAdapter,
BusLogic_InquireExtendedSetupInformation,
&RequestedReplyLength, sizeof(RequestedReplyLength),
&ExtendedSetupInformation,
sizeof(ExtendedSetupInformation));
restore_flags(ProcessorFlags);
if (BusLogic_GlobalOptions & BusLogic_TraceProbe)
printk("BusLogic_Check(0x%X): Result %d\n",
HostAdapter->IO_Address, Result);
return (Result == sizeof(ExtendedSetupInformation));
}
/*
BusLogic_ReadHostAdapterConfiguration reads the Configuration Information
from Host Adapter.
*/
static boolean BusLogic_ReadHostAdapterConfiguration(BusLogic_HostAdapter_T
*HostAdapter)
{
BusLogic_BoardID_T BoardID;
BusLogic_Configuration_T Configuration;
BusLogic_SetupInformation_T SetupInformation;
BusLogic_ExtendedSetupInformation_T ExtendedSetupInformation;
BusLogic_BoardModelNumber_T BoardModelNumber;
BusLogic_FirmwareVersion3rdDigit_T FirmwareVersion3rdDigit;
BusLogic_FirmwareVersionLetter_T FirmwareVersionLetter;
BusLogic_RequestedReplyLength_T RequestedReplyLength;
unsigned char GeometryRegister, *TargetPointer, Character;
unsigned short AllTargetsMask, DisconnectPermitted;
unsigned short TaggedQueuingPermitted, TaggedQueuingPermittedDefault;
boolean CommonErrorRecovery;
int TargetID, i;
/*
Issue the Inquire Board ID command.
*/
if (BusLogic_Command(HostAdapter, BusLogic_InquireBoardID, NULL, 0,
&BoardID, sizeof(BoardID)) != sizeof(BoardID))
return BusLogic_Failure(HostAdapter, "INQUIRE BOARD ID");
/*
Issue the Inquire Configuration command.
*/
if (BusLogic_Command(HostAdapter, BusLogic_InquireConfiguration, NULL, 0,
&Configuration, sizeof(Configuration))
!= sizeof(Configuration))
return BusLogic_Failure(HostAdapter, "INQUIRE CONFIGURATION");
/*
Issue the Inquire Setup Information command.
*/
RequestedReplyLength = sizeof(SetupInformation);
if (BusLogic_Command(HostAdapter, BusLogic_InquireSetupInformation,
&RequestedReplyLength, sizeof(RequestedReplyLength),
&SetupInformation, sizeof(SetupInformation))
!= sizeof(SetupInformation))
return BusLogic_Failure(HostAdapter, "INQUIRE SETUP INFORMATION");
/*
Issue the Inquire Extended Setup Information command.
*/
RequestedReplyLength = sizeof(ExtendedSetupInformation);
if (BusLogic_Command(HostAdapter, BusLogic_InquireExtendedSetupInformation,
&RequestedReplyLength, sizeof(RequestedReplyLength),
&ExtendedSetupInformation,
sizeof(ExtendedSetupInformation))
!= sizeof(ExtendedSetupInformation))
return BusLogic_Failure(HostAdapter, "INQUIRE EXTENDED SETUP INFORMATION");
/*
Issue the Inquire Board Model Number command.
*/
if (!(BoardID.FirmwareVersion1stDigit == '2' &&
ExtendedSetupInformation.BusType == 'A'))
{
RequestedReplyLength = sizeof(BoardModelNumber);
if (BusLogic_Command(HostAdapter, BusLogic_InquireBoardModelNumber,
&RequestedReplyLength, sizeof(RequestedReplyLength),
&BoardModelNumber, sizeof(BoardModelNumber))
!= sizeof(BoardModelNumber))
return BusLogic_Failure(HostAdapter, "INQUIRE BOARD MODEL NUMBER");
}
else strcpy(BoardModelNumber, "542B");
/*
Issue the Inquire Firmware Version 3rd Digit command.
*/
if (BusLogic_Command(HostAdapter, BusLogic_InquireFirmwareVersion3rdDigit,
NULL, 0, &FirmwareVersion3rdDigit,
sizeof(FirmwareVersion3rdDigit))
!= sizeof(FirmwareVersion3rdDigit))
return BusLogic_Failure(HostAdapter, "INQUIRE FIRMWARE 3RD DIGIT");
/*
Issue the Inquire Firmware Version Letter command.
*/
FirmwareVersionLetter = '\0';
if (BoardID.FirmwareVersion1stDigit > '3' ||
(BoardID.FirmwareVersion1stDigit == '3' &&
BoardID.FirmwareVersion2ndDigit >= '3'))
if (BusLogic_Command(HostAdapter, BusLogic_InquireFirmwareVersionLetter,
NULL, 0, &FirmwareVersionLetter,
sizeof(FirmwareVersionLetter))
!= sizeof(FirmwareVersionLetter))
return BusLogic_Failure(HostAdapter, "INQUIRE FIRMWARE VERSION LETTER");
/*
BusLogic Host Adapters can be identified by their model number and
the major version number of their firmware as follows:
4.xx BusLogic "C" Series Host Adapters:
BT-946C/956C/956CD/747C/757C/757CD/445C/545C/540CF
3.xx BusLogic "S" Series Host Adapters:
BT-747S/747D/757S/757D/445S/545S/542D
BT-542B/742A (revision H)
2.xx BusLogic "A" Series Host Adapters:
BT-542B/742A (revision G and below)
0.xx AMI FastDisk VLB/EISA BusLogic Clone Host Adapter
*/
/*
Save the Model Name and Board Name in the Host Adapter structure.
*/
TargetPointer = HostAdapter->ModelName;
*TargetPointer++ = 'B';
*TargetPointer++ = 'T';
*TargetPointer++ = '-';
for (i = 0; i < sizeof(BoardModelNumber); i++)
{
Character = BoardModelNumber[i];
if (Character == ' ' || Character == '\0') break;
*TargetPointer++ = Character;
}
*TargetPointer++ = '\0';
strcpy(HostAdapter->BoardName, "BusLogic ");
strcat(HostAdapter->BoardName, HostAdapter->ModelName);
strcpy(HostAdapter->InterruptLabel, HostAdapter->BoardName);
/*
Save the Firmware Version in the Host Adapter structure.
*/
TargetPointer = HostAdapter->FirmwareVersion;
*TargetPointer++ = BoardID.FirmwareVersion1stDigit;
*TargetPointer++ = '.';
*TargetPointer++ = BoardID.FirmwareVersion2ndDigit;
if (FirmwareVersion3rdDigit != ' ' && FirmwareVersion3rdDigit != '\0')
*TargetPointer++ = FirmwareVersion3rdDigit;
if (FirmwareVersionLetter != ' ' && FirmwareVersionLetter != '\0')
*TargetPointer++ = FirmwareVersionLetter;
*TargetPointer++ = '\0';
/*
Determine the IRQ Channel and save it in the Host Adapter structure.
*/
if (Configuration.IRQ_Channel9)
HostAdapter->IRQ_Channel = 9;
else if (Configuration.IRQ_Channel10)
HostAdapter->IRQ_Channel = 10;
else if (Configuration.IRQ_Channel11)
HostAdapter->IRQ_Channel = 11;
else if (Configuration.IRQ_Channel12)
HostAdapter->IRQ_Channel = 12;
else if (Configuration.IRQ_Channel14)
HostAdapter->IRQ_Channel = 14;
else if (Configuration.IRQ_Channel15)
HostAdapter->IRQ_Channel = 15;
/*
Determine the DMA Channel and save it in the Host Adapter structure.
*/
if (Configuration.DMA_Channel5)
HostAdapter->DMA_Channel = 5;
else if (Configuration.DMA_Channel6)
HostAdapter->DMA_Channel = 6;
else if (Configuration.DMA_Channel7)
HostAdapter->DMA_Channel = 7;
/*
Save the Host Adapter SCSI ID in the Host Adapter structure.
*/
HostAdapter->SCSI_ID = Configuration.HostAdapterID;
/*
Save the Synchronous Initiation flag and SCSI Parity Checking flag
in the Host Adapter structure.
*/
HostAdapter->SynchronousInitiation =
SetupInformation.SynchronousInitiationEnabled;
HostAdapter->ParityChecking = SetupInformation.ParityCheckEnabled;
/*
Determine the Bus Type and save it in the Host Adapter structure,
overriding the DMA Channel if it is inappropriate for the bus type.
*/
if (ExtendedSetupInformation.BusType == 'A')
HostAdapter->BusType = BusLogic_ISA_Bus;
else
switch (HostAdapter->ModelName[3])
{
case '4':
HostAdapter->BusType = BusLogic_VESA_Bus;
HostAdapter->DMA_Channel = 0;
break;
case '5':
HostAdapter->BusType = BusLogic_ISA_Bus;
break;
case '6':
HostAdapter->BusType = BusLogic_MCA_Bus;
HostAdapter->DMA_Channel = 0;
break;
case '7':
HostAdapter->BusType = BusLogic_EISA_Bus;
HostAdapter->DMA_Channel = 0;
break;
case '9':
HostAdapter->BusType = BusLogic_PCI_Bus;
HostAdapter->DMA_Channel = 0;
break;
}
/*
Determine whether Extended Translation is enabled and save it in
the Host Adapter structure.
*/
GeometryRegister = BusLogic_ReadGeometryRegister(HostAdapter);
if (GeometryRegister & BusLogic_ExtendedTranslationEnabled)
HostAdapter->ExtendedTranslation = true;
/*
Save the Disconnect/Reconnect Permitted flag bits in the Host Adapter
structure. The Disconnect Permitted information is only valid on "C"
Series boards, but Disconnect/Reconnect is always permitted on "S" and
"A" Series boards.
*/
if (HostAdapter->FirmwareVersion[0] >= '4')
HostAdapter->DisconnectPermitted =
(SetupInformation.DisconnectPermittedID8to15 << 8)
| SetupInformation.DisconnectPermittedID0to7;
else HostAdapter->DisconnectPermitted = 0xFF;
/*
Save the Scatter Gather Limits, Level Sensitive Interrupts flag,
Wide SCSI flag, and Differential SCSI flag in the Host Adapter structure.
*/
HostAdapter->HostAdapterScatterGatherLimit =
ExtendedSetupInformation.ScatterGatherLimit;
HostAdapter->DriverScatterGatherLimit =
HostAdapter->HostAdapterScatterGatherLimit;
if (HostAdapter->HostAdapterScatterGatherLimit > BusLogic_ScatterGatherLimit)
HostAdapter->DriverScatterGatherLimit = BusLogic_ScatterGatherLimit;
if (ExtendedSetupInformation.Misc.LevelSensitiveInterrupts)
HostAdapter->LevelSensitiveInterrupts = true;
if (ExtendedSetupInformation.HostWideSCSI)
{
HostAdapter->HostWideSCSI = true;
HostAdapter->MaxTargetIDs = 16;
HostAdapter->MaxLogicalUnits = 64;
}
else
{
HostAdapter->HostWideSCSI = false;
HostAdapter->MaxTargetIDs = 8;
HostAdapter->MaxLogicalUnits = 8;
}
HostAdapter->HostDifferentialSCSI =
ExtendedSetupInformation.HostDifferentialSCSI;
/*
Determine the Host Adapter BIOS Address if the BIOS is enabled and
save it in the Host Adapter structure. The BIOS is disabled if the
BIOS_Address is 0.
*/
HostAdapter->BIOS_Address = ExtendedSetupInformation.BIOS_Address << 12;
/*
BusLogic BT-445S Host Adapters prior to board revision D have a hardware
bug whereby when the BIOS is enabled, transfers to/from the same address
range the BIOS occupies modulo 16MB are handled incorrectly. Only properly
functioning BT-445S boards have firmware version 3.37, so we require that
ISA bounce buffers be used for the buggy BT-445S models as well as for all
ISA models.
*/
if (HostAdapter->BusType == BusLogic_ISA_Bus ||
(HostAdapter->BIOS_Address > 0 &&
strcmp(HostAdapter->ModelName, "BT-445S") == 0 &&
strcmp(HostAdapter->FirmwareVersion, "3.37") < 0))
HostAdapter->BounceBuffersRequired = true;
/*
Select an appropriate value for Concurrency (Commands per Logical Unit)
either from a Command Line Entry, or based on whether this Host Adapter
requires that ISA bounce buffers be used.
*/
if (HostAdapter->CommandLineEntry != NULL &&
HostAdapter->CommandLineEntry->Concurrency > 0)
HostAdapter->Concurrency = HostAdapter->CommandLineEntry->Concurrency;
else if (HostAdapter->BounceBuffersRequired)
HostAdapter->Concurrency = BusLogic_Concurrency_BB;
else HostAdapter->Concurrency = BusLogic_Concurrency;
/*
Select an appropriate value for Bus Settle Time either from a Command
Line Entry, or from BusLogic_DefaultBusSettleTime.
*/
if (HostAdapter->CommandLineEntry != NULL &&
HostAdapter->CommandLineEntry->BusSettleTime > 0)
HostAdapter->BusSettleTime = HostAdapter->CommandLineEntry->BusSettleTime;
else HostAdapter->BusSettleTime = BusLogic_DefaultBusSettleTime;
/*
Select an appropriate value for Local Options from a Command Line Entry.
*/
if (HostAdapter->CommandLineEntry != NULL)
HostAdapter->LocalOptions = HostAdapter->CommandLineEntry->LocalOptions;
/*
Select appropriate values for the Error Recovery Option array either from
a Command Line Entry, or using BusLogic_ErrorRecoveryDefault.
*/
if (HostAdapter->CommandLineEntry != NULL)
memcpy(HostAdapter->ErrorRecoveryOption,
HostAdapter->CommandLineEntry->ErrorRecoveryOption,
sizeof(HostAdapter->ErrorRecoveryOption));
else memset(HostAdapter->ErrorRecoveryOption,
BusLogic_ErrorRecoveryDefault,
sizeof(HostAdapter->ErrorRecoveryOption));
/*
Tagged Queuing support is available and operates properly only on "C"
Series boards with firmware version 4.22 and above and on "S" Series
boards with firmware version 3.35 and above. Tagged Queuing is disabled
by default when the Concurrency value is 1 since queuing multiple commands
is not possible.
*/
TaggedQueuingPermittedDefault = 0;
if (HostAdapter->Concurrency > 1)
switch (HostAdapter->FirmwareVersion[0])
{
case '5':
TaggedQueuingPermittedDefault = 0xFFFF;
break;
case '4':
if (strcmp(HostAdapter->FirmwareVersion, "4.22") >= 0)
TaggedQueuingPermittedDefault = 0xFFFF;
break;
case '3':
if (strcmp(HostAdapter->FirmwareVersion, "3.35") >= 0)
TaggedQueuingPermittedDefault = 0xFFFF;
break;
}
/*
Tagged Queuing is only useful if Disconnect/Reconnect is permitted.
Therefore, mask the Tagged Queuing Permitted Default bits with the
Disconnect/Reconnect Permitted bits.
*/
TaggedQueuingPermittedDefault &= HostAdapter->DisconnectPermitted;
/*
Combine the default Tagged Queuing Permitted Default bits with any
Command Line Entry Tagged Queuing specification.
*/
if (HostAdapter->CommandLineEntry != NULL)
HostAdapter->TaggedQueuingPermitted =
(HostAdapter->CommandLineEntry->TaggedQueuingPermitted &
HostAdapter->CommandLineEntry->TaggedQueuingPermittedMask) |
(TaggedQueuingPermittedDefault &
~HostAdapter->CommandLineEntry->TaggedQueuingPermittedMask);
else HostAdapter->TaggedQueuingPermitted = TaggedQueuingPermittedDefault;
/*
Announce the Host Adapter Configuration.
*/
printk("scsi%d: Configuring BusLogic Model %s %s%s%s SCSI Host Adapter\n",
HostAdapter->HostNumber, HostAdapter->ModelName,
BusLogic_BusNames[HostAdapter->BusType],
(HostAdapter->HostWideSCSI ? " Wide" : ""),
(HostAdapter->HostDifferentialSCSI ? " Differential" : ""));
printk("scsi%d: Firmware Version: %s, I/O Address: 0x%X, "
"IRQ Channel: %d/%s\n",
HostAdapter->HostNumber, HostAdapter->FirmwareVersion,
HostAdapter->IO_Address, HostAdapter->IRQ_Channel,
(HostAdapter->LevelSensitiveInterrupts ? "Level" : "Edge"));
printk("scsi%d: DMA Channel: ", HostAdapter->HostNumber);
if (HostAdapter->DMA_Channel > 0)
printk("%d, ", HostAdapter->DMA_Channel);
else printk("None, ");
if (HostAdapter->BIOS_Address > 0)
printk("BIOS Address: 0x%lX, ", HostAdapter->BIOS_Address);
else printk("BIOS Address: None, ");
printk("Host Adapter SCSI ID: %d\n", HostAdapter->SCSI_ID);
printk("scsi%d: Scatter/Gather Limit: %d segments, "
"Synchronous Initiation: %s\n", HostAdapter->HostNumber,
HostAdapter->HostAdapterScatterGatherLimit,
(HostAdapter->SynchronousInitiation ? "Enabled" : "Disabled"));
printk("scsi%d: SCSI Parity Checking: %s, "
"Extended Disk Translation: %s\n", HostAdapter->HostNumber,
(HostAdapter->ParityChecking ? "Enabled" : "Disabled"),
(HostAdapter->ExtendedTranslation ? "Enabled" : "Disabled"));
AllTargetsMask = (1 << HostAdapter->MaxTargetIDs) - 1;
DisconnectPermitted = HostAdapter->DisconnectPermitted & AllTargetsMask;
printk("scsi%d: Disconnect/Reconnect: ", HostAdapter->HostNumber);
if (DisconnectPermitted == 0)
printk("Disabled");
else if (DisconnectPermitted == AllTargetsMask)
printk("Enabled");
else
for (TargetID = 0; TargetID < HostAdapter->MaxTargetIDs; TargetID++)
printk("%c", (DisconnectPermitted & (1 << TargetID)) ? 'Y' : 'N');
printk(", Tagged Queuing: ");
TaggedQueuingPermitted =
HostAdapter->TaggedQueuingPermitted & AllTargetsMask;
if (TaggedQueuingPermitted == 0)
printk("Disabled");
else if (TaggedQueuingPermitted == AllTargetsMask)
printk("Enabled");
else
for (TargetID = 0; TargetID < HostAdapter->MaxTargetIDs; TargetID++)
printk("%c", (TaggedQueuingPermitted & (1 << TargetID)) ? 'Y' : 'N');
printk("\n");
CommonErrorRecovery = true;
for (TargetID = 1; TargetID < HostAdapter->MaxTargetIDs; TargetID++)
if (HostAdapter->ErrorRecoveryOption[TargetID] !=
HostAdapter->ErrorRecoveryOption[0])
{
CommonErrorRecovery = false;
break;
}
printk("scsi%d: Error Recovery: ", HostAdapter->HostNumber);
if (CommonErrorRecovery)
printk("%s", BusLogic_ErrorRecoveryOptions[
HostAdapter->ErrorRecoveryOption[0]]);
else
for (TargetID = 0; TargetID < HostAdapter->MaxTargetIDs; TargetID++)
printk("%s", BusLogic_ErrorRecoveryOptions2[
HostAdapter->ErrorRecoveryOption[TargetID]]);
printk(", Mailboxes: %d, Initial CCBs: %d\n",
BusLogic_MailboxCount, BusLogic_InitialCCBs);
printk("scsi%d: Driver Scatter/Gather Limit: %d segments, "
"Concurrency: %d\n", HostAdapter->HostNumber,
HostAdapter->DriverScatterGatherLimit, HostAdapter->Concurrency);
/*
Indicate reading the Host Adapter Configuration completed successfully.
*/
return true;
}
/*
BusLogic_AcquireResources acquires the system resources necessary to use Host
Adapter, and initializes the fields in the SCSI Host structure. The base,
io_port, n_io_ports, irq, and dma_channel fields in the SCSI Host structure
are intentionally left uninitialized, as this driver handles acquisition and
release of these resources explicitly, as well as ensuring exclusive access
to the Host Adapter hardware and data structures through explicit locking.
*/
static boolean BusLogic_AcquireResources(BusLogic_HostAdapter_T *HostAdapter,
SCSI_Host_T *Host)
{
/*
Acquire exclusive or shared access to the IRQ Channel. A usage count is
maintained so that PCI, EISA, or MCA shared Interrupts can be supported.
*/
if (BusLogic_IRQ_UsageCount[HostAdapter->IRQ_Channel - 9]++ == 0)
{
if (request_irq(HostAdapter->IRQ_Channel, BusLogic_InterruptHandler,
SA_INTERRUPT, HostAdapter->InterruptLabel) < 0)
{
BusLogic_IRQ_UsageCount[HostAdapter->IRQ_Channel - 9]--;
printk("scsi%d: UNABLE TO ACQUIRE IRQ CHANNEL %d - DETACHING\n",
HostAdapter->HostNumber, HostAdapter->IRQ_Channel);
return false;
}
}
else
{
BusLogic_HostAdapter_T *FirstHostAdapter =
BusLogic_RegisteredHostAdapters;
while (FirstHostAdapter != NULL)
{
if (FirstHostAdapter->IRQ_Channel == HostAdapter->IRQ_Channel)
{
if (strlen(FirstHostAdapter->InterruptLabel) + 11
< sizeof(FirstHostAdapter->InterruptLabel))
{
strcat(FirstHostAdapter->InterruptLabel, " + ");
strcat(FirstHostAdapter->InterruptLabel,
HostAdapter->ModelName);
}
break;
}
FirstHostAdapter = FirstHostAdapter->Next;
}
}
HostAdapter->IRQ_ChannelAcquired = true;
/*
Acquire exclusive access to the DMA Channel.
*/
if (HostAdapter->DMA_Channel > 0)
{
if (request_dma(HostAdapter->DMA_Channel, HostAdapter->BoardName) < 0)
{
printk("scsi%d: UNABLE TO ACQUIRE DMA CHANNEL %d - DETACHING\n",
HostAdapter->HostNumber, HostAdapter->DMA_Channel);
return false;
}
set_dma_mode(HostAdapter->DMA_Channel, DMA_MODE_CASCADE);
enable_dma(HostAdapter->DMA_Channel);
HostAdapter->DMA_ChannelAcquired = true;
}
/*
Initialize necessary fields in the SCSI Host structure.
*/
Host->max_id = HostAdapter->MaxTargetIDs;
Host->max_lun = HostAdapter->MaxLogicalUnits;
Host->max_channel = 0;
Host->this_id = HostAdapter->SCSI_ID;
Host->can_queue = BusLogic_MailboxCount;
Host->cmd_per_lun = HostAdapter->Concurrency;
Host->sg_tablesize = HostAdapter->DriverScatterGatherLimit;
Host->unchecked_isa_dma = HostAdapter->BounceBuffersRequired;
/*
Indicate the System Resource Acquisition completed successfully,
*/
return true;
}
/*
BusLogic_ReleaseResources releases any system resources previously acquired
by BusLogic_AcquireResources.
*/
static void BusLogic_ReleaseResources(BusLogic_HostAdapter_T *HostAdapter)
{
/*
Release exclusive or shared access to the IRQ Channel.
*/
if (HostAdapter->IRQ_ChannelAcquired)
if (--BusLogic_IRQ_UsageCount[HostAdapter->IRQ_Channel - 9] == 0)
free_irq(HostAdapter->IRQ_Channel);
/*
Release exclusive access to the DMA Channel.
*/
if (HostAdapter->DMA_ChannelAcquired)
free_dma(HostAdapter->DMA_Channel);
}
/*
BusLogic_TestInterrupts tests for proper functioning of the Host Adapter
Interrupt Register and that interrupts generated by the Host Adapter are
getting through to the Interrupt Handler. A large proportion of initial
problems with installing PCI Host Adapters are due to configuration problems
where either the Host Adapter or Motherboard is configured incorrectly, and
interrupts do not get through as a result.
*/
static boolean BusLogic_TestInterrupts(BusLogic_HostAdapter_T *HostAdapter)
{
unsigned int InitialInterruptCount, FinalInterruptCount;
int TestCount = 5, i;
InitialInterruptCount = kstat.interrupts[HostAdapter->IRQ_Channel];
/*
Issue the Test Command Complete Interrupt commands.
*/
for (i = 0; i < TestCount; i++)
BusLogic_Command(HostAdapter, BusLogic_TestCommandCompleteInterrupt,
NULL, 0, NULL, 0);
/*
Verify that BusLogic_InterruptHandler was called at least TestCount times.
Shared IRQ Channels could cause more than TestCount interrupts to occur,
but there should never be fewer than TestCount.
*/
FinalInterruptCount = kstat.interrupts[HostAdapter->IRQ_Channel];
if (FinalInterruptCount < InitialInterruptCount + TestCount)
{
BusLogic_Failure(HostAdapter, "HOST ADAPTER INTERRUPT TEST");
printk("\n\
Interrupts are not getting through from the Host Adapter to the BusLogic\n\
Driver Interrupt Handler. The most likely cause is that either the Host\n\
Adapter or Motherboard is configured incorrectly. Please check the Host\n\
Adapter configuration with AutoSCSI or by examining any dip switch and\n\
jumper settings on the Host Adapter, and verify that no other device is\n\
attempting to use the same IRQ Channel. For PCI Host Adapters, it may also\n\
be necessary to investigate and manually set the PCI interrupt assignments\n\
and edge/level interrupt type selection in the BIOS Setup Program or with\n\
Motherboard jumpers.\n\n");
return false;
}
/*
Indicate the Host Adapter Interrupt Test completed successfully.
*/
return true;
}
/*
BusLogic_InitializeHostAdapter initializes Host Adapter. This is the only
function called during SCSI Host Adapter detection which modifies the state
of the Host Adapter from its initial power on or hard reset state.
*/
static boolean BusLogic_InitializeHostAdapter(BusLogic_HostAdapter_T
*HostAdapter)
{
BusLogic_ExtendedMailboxRequest_T ExtendedMailboxRequest;
BusLogic_RoundRobinModeRequest_T RoundRobinModeRequest;
BusLogic_WideModeCCBRequest_T WideModeCCBRequest;
BusLogic_ModifyIOAddressRequest_T ModifyIOAddressRequest;
/*
Initialize the Command Successful Flag, Read/Write Operation Count,
and Queued Operation Count for each Target.
*/
memset(HostAdapter->CommandSuccessfulFlag, false,
sizeof(HostAdapter->CommandSuccessfulFlag));
memset(HostAdapter->ReadWriteOperationCount, 0,
sizeof(HostAdapter->ReadWriteOperationCount));
memset(HostAdapter->QueuedOperationCount, 0,
sizeof(HostAdapter->QueuedOperationCount));
/*
Initialize the Outgoing and Incoming Mailbox structures.
*/
memset(HostAdapter->OutgoingMailboxes, 0,
sizeof(HostAdapter->OutgoingMailboxes));
memset(HostAdapter->IncomingMailboxes, 0,
sizeof(HostAdapter->IncomingMailboxes));
/*
Initialize the pointers to the First, Last, and Next Mailboxes.
*/
HostAdapter->FirstOutgoingMailbox = &HostAdapter->OutgoingMailboxes[0];
HostAdapter->LastOutgoingMailbox =
&HostAdapter->OutgoingMailboxes[BusLogic_MailboxCount-1];
HostAdapter->NextOutgoingMailbox = HostAdapter->FirstOutgoingMailbox;
HostAdapter->FirstIncomingMailbox = &HostAdapter->IncomingMailboxes[0];
HostAdapter->LastIncomingMailbox =
&HostAdapter->IncomingMailboxes[BusLogic_MailboxCount-1];
HostAdapter->NextIncomingMailbox = HostAdapter->FirstIncomingMailbox;
/*
Initialize the Host Adapter's Pointer to the Outgoing/Incoming Mailboxes.
*/
ExtendedMailboxRequest.MailboxCount = BusLogic_MailboxCount;
ExtendedMailboxRequest.BaseMailboxAddress = HostAdapter->OutgoingMailboxes;
if (BusLogic_Command(HostAdapter, BusLogic_InitializeExtendedMailbox,
&ExtendedMailboxRequest,
sizeof(ExtendedMailboxRequest), NULL, 0) < 0)
return BusLogic_Failure(HostAdapter, "MAILBOX INITIALIZATION");
/*
Enable Strict Round Robin Mode if supported by the Host Adapter. In Strict
Round Robin Mode, the Host Adapter only looks at the next Outgoing Mailbox
for each new command, rather than scanning through all the Outgoing
Mailboxes to find any that have new commands in them. BusLogic indicates
that Strict Round Robin Mode is significantly more efficient.
*/
if (strcmp(HostAdapter->FirmwareVersion, "3.31") >= 0)
{
RoundRobinModeRequest = BusLogic_StrictRoundRobinMode;
if (BusLogic_Command(HostAdapter, BusLogic_EnableStrictRoundRobinMode,
&RoundRobinModeRequest,
sizeof(RoundRobinModeRequest), NULL, 0) < 0)
return BusLogic_Failure(HostAdapter, "ENABLE STRICT ROUND ROBIN MODE");
}
/*
For Wide SCSI Host Adapters, issue the Enable Wide Mode CCB command to
allow more than 8 Logical Units per Target to be supported.
*/
if (HostAdapter->HostWideSCSI)
{
WideModeCCBRequest = BusLogic_WideModeCCB;
if (BusLogic_Command(HostAdapter, BusLogic_EnableWideModeCCB,
&WideModeCCBRequest,
sizeof(WideModeCCBRequest), NULL, 0) < 0)
return BusLogic_Failure(HostAdapter, "ENABLE WIDE MODE CCB");
}
/*
For PCI Host Adapters being accessed through the PCI compliant I/O
Address, disable the ISA compatible I/O Address to avoid detecting the
same Host Adapter at both I/O Addresses.
*/
if (HostAdapter->BusType == BusLogic_PCI_Bus)
{
int Index;
for (Index = 0; BusLogic_IO_StandardAddresses[Index] > 0; Index++)
if (HostAdapter->IO_Address == BusLogic_IO_StandardAddresses[Index])
break;
if (BusLogic_IO_StandardAddresses[Index] == 0)
{
ModifyIOAddressRequest = BusLogic_ModifyIO_Disable;
if (BusLogic_Command(HostAdapter, BusLogic_ModifyIOAddress,
&ModifyIOAddressRequest,
sizeof(ModifyIOAddressRequest), NULL, 0) < 0)
return BusLogic_Failure(HostAdapter, "MODIFY I/O ADDRESS");
}
}
/*
Announce Successful Initialization.
*/
printk("scsi%d: *** %s Initialized Successfully ***\n",
HostAdapter->HostNumber, HostAdapter->BoardName);
/*
Indicate the Host Adapter Initialization completed successfully.
*/
return true;
}
/*
BusLogic_InquireTargetDevices inquires about the Target Devices accessible
through Host Adapter and reports on the results.
*/
static boolean BusLogic_InquireTargetDevices(BusLogic_HostAdapter_T
*HostAdapter)
{
BusLogic_InstalledDevices8_T InstalledDevicesID0to7;
BusLogic_InstalledDevices8_T InstalledDevicesID8to15;
BusLogic_SetupInformation_T SetupInformation;
BusLogic_SynchronousPeriod_T SynchronousPeriod;
BusLogic_RequestedReplyLength_T RequestedReplyLength;
int TargetDevicesFound = 0, TargetID;
/*
Wait a few seconds between the 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.
*/
BusLogic_Delay(HostAdapter->BusSettleTime);
/*
Inhibit the Target Devices Inquiry if requested.
*/
if (HostAdapter->LocalOptions & BusLogic_InhibitTargetInquiry)
{
printk("scsi%d: Target Device Inquiry Inhibited\n",
HostAdapter->HostNumber);
return true;
}
/*
Issue the Inquire Installed Devices ID 0 to 7 command, and for Wide SCSI
Host Adapters the Inquire Installed Devices ID 8 to 15 command. This is
necessary to force Synchronous Transfer Negotiation so that the Inquire
Setup Information and Inquire Synchronous Period commands will return
valid data.
*/
if (BusLogic_Command(HostAdapter, BusLogic_InquireInstalledDevicesID0to7,
NULL, 0, &InstalledDevicesID0to7,
sizeof(InstalledDevicesID0to7))
!= sizeof(InstalledDevicesID0to7))
return BusLogic_Failure(HostAdapter, "INQUIRE INSTALLED DEVICES ID 0 TO 7");
if (HostAdapter->HostWideSCSI)
if (BusLogic_Command(HostAdapter, BusLogic_InquireInstalledDevicesID8to15,
NULL, 0, &InstalledDevicesID8to15,
sizeof(InstalledDevicesID8to15))
!= sizeof(InstalledDevicesID8to15))
return BusLogic_Failure(HostAdapter,
"INQUIRE INSTALLED DEVICES ID 8 TO 15");
/*
Issue the Inquire Setup Information command.
*/
RequestedReplyLength = sizeof(SetupInformation);
if (BusLogic_Command(HostAdapter, BusLogic_InquireSetupInformation,
&RequestedReplyLength, sizeof(RequestedReplyLength),
&SetupInformation, sizeof(SetupInformation))
!= sizeof(SetupInformation))
return BusLogic_Failure(HostAdapter, "INQUIRE SETUP INFORMATION");
/*
Issue the Inquire Synchronous Period command.
*/
if (HostAdapter->FirmwareVersion[0] >= '3')
{
RequestedReplyLength = sizeof(SynchronousPeriod);
if (BusLogic_Command(HostAdapter, BusLogic_InquireSynchronousPeriod,
&RequestedReplyLength, sizeof(RequestedReplyLength),
&SynchronousPeriod, sizeof(SynchronousPeriod))
!= sizeof(SynchronousPeriod))
return BusLogic_Failure(HostAdapter, "INQUIRE SYNCHRONOUS PERIOD");
}
else
for (TargetID = 0; TargetID < HostAdapter->MaxTargetIDs; TargetID++)
if (SetupInformation.SynchronousValuesID0to7[TargetID].Offset > 0)
SynchronousPeriod[TargetID] =
20 + 5 * SetupInformation.SynchronousValuesID0to7[TargetID]
.TransferPeriod;
else SynchronousPeriod[TargetID] = 0;
/*
Save the Installed Devices, Synchronous Values, and Synchronous Period
information in the Host Adapter structure.
*/
memcpy(HostAdapter->InstalledDevices, InstalledDevicesID0to7,
sizeof(BusLogic_InstalledDevices8_T));
memcpy(HostAdapter->SynchronousValues,
SetupInformation.SynchronousValuesID0to7,
sizeof(BusLogic_SynchronousValues8_T));
if (HostAdapter->HostWideSCSI)
{
memcpy(&HostAdapter->InstalledDevices[8], InstalledDevicesID8to15,
sizeof(BusLogic_InstalledDevices8_T));
memcpy(&HostAdapter->SynchronousValues[8],
SetupInformation.SynchronousValuesID8to15,
sizeof(BusLogic_SynchronousValues8_T));
}
memcpy(HostAdapter->SynchronousPeriod, SynchronousPeriod,
sizeof(BusLogic_SynchronousPeriod_T));
for (TargetID = 0; TargetID < HostAdapter->MaxTargetIDs; TargetID++)
if (HostAdapter->InstalledDevices[TargetID] != 0)
{
int SynchronousPeriod = HostAdapter->SynchronousPeriod[TargetID];
if (SynchronousPeriod > 10)
{
int SynchronousTransferRate = 100000000 / SynchronousPeriod;
int RoundedSynchronousTransferRate =
(SynchronousTransferRate + 5000) / 10000;
printk("scsi%d: Target %d: Synchronous at "
"%d.%02d mega-transfers/second, offset %d\n",
HostAdapter->HostNumber, TargetID,
RoundedSynchronousTransferRate / 100,
RoundedSynchronousTransferRate % 100,
HostAdapter->SynchronousValues[TargetID].Offset);
}
else if (SynchronousPeriod > 0)
{
int SynchronousTransferRate = 100000000 / SynchronousPeriod;
int RoundedSynchronousTransferRate =
(SynchronousTransferRate + 50000) / 100000;
printk("scsi%d: Target %d: Synchronous at "
"%d.%01d mega-transfers/second, offset %d\n",
HostAdapter->HostNumber, TargetID,
RoundedSynchronousTransferRate / 10,
RoundedSynchronousTransferRate % 10,
HostAdapter->SynchronousValues[TargetID].Offset);
}
else printk("scsi%d: Target %d: Asynchronous\n",
HostAdapter->HostNumber, TargetID);
TargetDevicesFound++;
}
if (TargetDevicesFound == 0)
printk("scsi%d: No Target Devices Found\n", HostAdapter->HostNumber);
/*
Indicate the Target Device Inquiry completed successfully.
*/
return true;
}
/*
BusLogic_DetectHostAdapter probes for BusLogic Host Adapters at the standard
I/O Addresses where they may be located, initializing, registering, and
reporting the configuration of each BusLogic Host Adapter it finds. It
returns the number of BusLogic Host Adapters successfully initialized and
registered.
*/
int BusLogic_DetectHostAdapter(SCSI_Host_Template_T *HostTemplate)
{
int BusLogicHostAdapterCount = 0, CommandLineEntryIndex = 0;
int AddressProbeIndex = 0;
BusLogic_InitializeAddressProbeList();
while (BusLogic_IO_AddressProbeList[AddressProbeIndex] > 0)
{
BusLogic_HostAdapter_T HostAdapterPrototype;
BusLogic_HostAdapter_T *HostAdapter = &HostAdapterPrototype;
SCSI_Host_T *Host;
memset(HostAdapter, 0, sizeof(BusLogic_HostAdapter_T));
HostAdapter->IO_Address =
BusLogic_IO_AddressProbeList[AddressProbeIndex++];
/*
Initialize the Command Line Entry field if an explicit I/O Address
was specified.
*/
if (CommandLineEntryIndex < BusLogic_CommandLineEntryCount &&
BusLogic_CommandLineEntries[CommandLineEntryIndex].IO_Address ==
HostAdapter->IO_Address)
HostAdapter->CommandLineEntry =
&BusLogic_CommandLineEntries[CommandLineEntryIndex++];
/*
Check whether the I/O Address range is already in use.
*/
if (check_region(HostAdapter->IO_Address, BusLogic_IO_PortCount) < 0)
continue;
/*
Probe the Host Adapter. If unsuccessful, abort further initialization.
*/
if (!BusLogic_ProbeHostAdapter(HostAdapter)) continue;
/*
Hard Reset the Host Adapter. If unsuccessful, abort further
initialization.
*/
if (!BusLogic_HardResetHostAdapter(HostAdapter)) continue;
/*
Check the Host Adapter. If unsuccessful, abort further initialization.
*/
if (!BusLogic_CheckHostAdapter(HostAdapter)) continue;
/*
Initialize the Command Line Entry field if an explicit I/O Address
was not specified.
*/
if (CommandLineEntryIndex < BusLogic_CommandLineEntryCount &&
BusLogic_CommandLineEntries[CommandLineEntryIndex].IO_Address == 0)
HostAdapter->CommandLineEntry =
&BusLogic_CommandLineEntries[CommandLineEntryIndex++];
/*
Announce the Driver Version and Date, Author's Name, Copyright Notice,
and Contact Address.
*/
BusLogic_AnnounceDriver();
/*
Register usage of the I/O Address range. From this point onward, any
failure will be assumed to be due to a problem with the Host Adapter,
rather than due to having mistakenly identified this port as belonging
to a BusLogic Host Adapter. The I/O Address range will not be
released, thereby preventing it from being incorrectly identified as
any other type of Host Adapter.
*/
request_region(HostAdapter->IO_Address, BusLogic_IO_PortCount,
"BusLogic");
/*
Register the SCSI Host structure.
*/
HostTemplate->proc_dir = &BusLogic_ProcDirectoryEntry;
Host = scsi_register(HostTemplate, sizeof(BusLogic_HostAdapter_T));
HostAdapter = (BusLogic_HostAdapter_T *) Host->hostdata;
memcpy(HostAdapter, &HostAdapterPrototype,
sizeof(BusLogic_HostAdapter_T));
HostAdapter->SCSI_Host = Host;
HostAdapter->HostNumber = Host->host_no;
/*
Add Host Adapter to the end of the list of registered BusLogic
Host Adapters. In order for Command Complete Interrupts to be
properly dismissed by BusLogic_InterruptHandler, the Host Adapter
must be registered. This must be done before the IRQ Channel is
acquired, and in a shared IRQ Channel environment, must be done
before any Command Complete Interrupts occur, since the IRQ Channel
may have already been acquired by a previous BusLogic Host Adapter.
*/
BusLogic_RegisterHostAdapter(HostAdapter);
/*
Read the Host Adapter Configuration, Acquire the System Resources
necessary to use Host Adapter and initialize the fields in the SCSI
Host structure, then Test Interrupts, Create the CCBs, Initialize
the Host Adapter, and finally Inquire about the Target Devices.
*/
if (BusLogic_ReadHostAdapterConfiguration(HostAdapter) &&
BusLogic_AcquireResources(HostAdapter, Host) &&
BusLogic_TestInterrupts(HostAdapter) &&
BusLogic_CreateCCBs(HostAdapter) &&
BusLogic_InitializeHostAdapter(HostAdapter) &&
BusLogic_InquireTargetDevices(HostAdapter))
{
/*
Initialization has been completed successfully. Release and
re-register usage of the I/O Address range so that the Model
Name of the Host Adapter will appear.
*/
release_region(HostAdapter->IO_Address, BusLogic_IO_PortCount);
request_region(HostAdapter->IO_Address, BusLogic_IO_PortCount,
HostAdapter->BoardName);
BusLogicHostAdapterCount++;
}
else
{
/*
An error occurred during Host Adapter Configuration Querying,
Resource Acquisition, Interrupt Testing, CCB Creation, Host
Adapter Initialization, or Target Device Inquiry, so remove
Host Adapter from the list of registered BusLogic Host Adapters,
destroy the CCBs, Release the System Resources, and Unregister
the SCSI Host.
*/
BusLogic_DestroyCCBs(HostAdapter);
BusLogic_ReleaseResources(HostAdapter);
BusLogic_UnregisterHostAdapter(HostAdapter);
scsi_unregister(Host);
}
}
return BusLogicHostAdapterCount;
}
/*
BusLogic_ReleaseHostAdapter releases all resources previously acquired to
support a specific Host Adapter, including the I/O Address range, and
unregisters the BusLogic Host Adapter.
*/
int BusLogic_ReleaseHostAdapter(SCSI_Host_T *Host)
{
BusLogic_HostAdapter_T *HostAdapter =
(BusLogic_HostAdapter_T *) Host->hostdata;
/*
Destroy the CCBs and release any system resources acquired to use
Host Adapter.
*/
BusLogic_DestroyCCBs(HostAdapter);
BusLogic_ReleaseResources(HostAdapter);
/*
Release usage of the I/O Address range.
*/
release_region(HostAdapter->IO_Address, BusLogic_IO_PortCount);
/*
Remove Host Adapter from the list of registered BusLogic Host Adapters.
*/
BusLogic_UnregisterHostAdapter(HostAdapter);
return 0;
}
/*
BusLogic_ComputeResultCode computes a SCSI Subsystem Result Code from
the Host Adapter Status and Target Device Status.
*/
static int BusLogic_ComputeResultCode(BusLogic_HostAdapterStatus_T
HostAdapterStatus,
BusLogic_TargetDeviceStatus_T
TargetDeviceStatus)
{
int HostStatus;
switch (HostAdapterStatus)
{
case BusLogic_CommandCompletedNormally:
case BusLogic_LinkedCommandCompleted:
case BusLogic_LinkedCommandCompletedWithFlag:
HostStatus = DID_OK;
break;
case BusLogic_SCSISelectionTimeout:
HostStatus = DID_TIME_OUT;
break;
case BusLogic_InvalidOutgoingMailboxActionCode:
case BusLogic_InvalidCommandOperationCode:
case BusLogic_InvalidCommandParameter:
printk("BusLogic: BusLogic Driver Protocol Error 0x%02X\n",
HostAdapterStatus);
case BusLogic_DataOverUnderRun:
case BusLogic_UnexpectedBusFree:
case BusLogic_LinkedCCBhasInvalidLUN:
case BusLogic_AutoRequestSenseFailed:
case BusLogic_TaggedQueuingMessageRejected:
case BusLogic_UnsupportedMessageReceived:
case BusLogic_HostAdapterHardwareFailed:
case BusLogic_TargetDeviceReconnectedImproperly:
case BusLogic_AbortQueueGenerated:
case BusLogic_HostAdapterSoftwareError:
case BusLogic_HostAdapterHardwareTimeoutError:
case BusLogic_SCSIParityErrorDetected:
HostStatus = DID_ERROR;
break;
case BusLogic_InvalidBusPhaseRequested:
case BusLogic_TargetFailedResponseToATN:
case BusLogic_HostAdapterAssertedRST:
case BusLogic_OtherDeviceAssertedRST:
case BusLogic_HostAdapterAssertedBusDeviceReset:
HostStatus = DID_RESET;
break;
default:
printk("BusLogic: unknown Host Adapter Status 0x%02X\n",
HostAdapterStatus);
HostStatus = DID_ERROR;
break;
}
return (HostStatus << 16) | TargetDeviceStatus;
}
/*
BusLogic_InterruptHandler handles hardware interrupts from BusLogic Host
Adapters. To simplify handling shared IRQ Channels, all installed BusLogic
Host Adapters are scanned whenever any one of them signals a hardware
interrupt.
*/
static void BusLogic_InterruptHandler(int IRQ_Channel,
Registers_T *InterruptRegisters)
{
BusLogic_CCB_T *FirstCompletedCCB = NULL, *LastCompletedCCB = NULL;
BusLogic_HostAdapter_T *HostAdapter;
int HostAdapterResetPendingCount = 0;
/*
Iterate over the installed BusLogic Host Adapters accepting any Incoming
Mailbox entries and saving the completed CCBs for processing. This
interrupt handler is installed with SA_INTERRUPT, so interrupts are
disabled when the interrupt handler is entered.
*/
for (HostAdapter = BusLogic_RegisteredHostAdapters;
HostAdapter != NULL;
HostAdapter = HostAdapter->Next)
{
unsigned char InterruptRegister;
/*
Acquire exclusive access to Host Adapter.
*/
BusLogic_LockHostAdapterID(HostAdapter);
/*
Read the Host Adapter Interrupt Register.
*/
InterruptRegister = BusLogic_ReadInterruptRegister(HostAdapter);
if (InterruptRegister & BusLogic_InterruptValid)
{
/*
Acknowledge the interrupt and reset the Host Adapter
Interrupt Register.
*/
BusLogic_WriteControlRegister(HostAdapter, BusLogic_InterruptReset);
/*
Process valid SCSI Reset State and Incoming Mailbox Loaded
interrupts. Command Complete interrupts are noted, and
Outgoing Mailbox Available interrupts are ignored, as they
are never enabled.
*/
if (InterruptRegister & BusLogic_SCSIResetState)
{
HostAdapter->HostAdapterResetPending = true;
HostAdapterResetPendingCount++;
}
else if (InterruptRegister & BusLogic_IncomingMailboxLoaded)
{
/*
Scan through the Incoming Mailboxes in Strict Round Robin
fashion, saving any completed CCBs for further processing.
It is essential that for each CCB and SCSI Command issued,
command completion processing is performed exactly once.
Therefore, only Incoming Mailboxes with completion code
Command Completed Without Error, Command Completed With
Error, or Command Aborted At Host Request are saved for
completion processing. When an Incoming Mailbox has a
completion code of Aborted Command Not Found, the CCB had
already completed or been aborted before the current Abort
request was processed, and so completion processing has
already occurred and no further action should be taken.
*/
BusLogic_IncomingMailbox_T *NextIncomingMailbox =
HostAdapter->NextIncomingMailbox;
BusLogic_CompletionCode_T MailboxCompletionCode;
while ((MailboxCompletionCode =
NextIncomingMailbox->CompletionCode) !=
BusLogic_IncomingMailboxFree)
{
BusLogic_CCB_T *CCB = NextIncomingMailbox->CCB;
if (MailboxCompletionCode != BusLogic_AbortedCommandNotFound)
if (CCB->Status == BusLogic_CCB_Active)
{
/*
Mark this CCB as completed and add it to the end
of the list of completed CCBs.
*/
CCB->Status = BusLogic_CCB_Completed;
CCB->MailboxCompletionCode = MailboxCompletionCode;
CCB->Next = NULL;
if (FirstCompletedCCB == NULL)
{
FirstCompletedCCB = CCB;
LastCompletedCCB = CCB;
}
else
{
LastCompletedCCB->Next = CCB;
LastCompletedCCB = CCB;
}
HostAdapter->QueuedOperationCount[CCB->TargetID]--;
}
else
{
/*
If a CCB ever appears in an Incoming Mailbox and
is not marked as status Active, then there is
most likely a bug in the Host Adapter firmware.
*/
printk("scsi%d: Illegal CCB #%d status %d in "
"Incoming Mailbox\n", HostAdapter->HostNumber,
CCB->SerialNumber, CCB->Status);
}
else printk("scsi%d: Aborted CCB #%d to Target %d "
"Not Found\n", HostAdapter->HostNumber,
CCB->SerialNumber, CCB->TargetID);
NextIncomingMailbox->CompletionCode =
BusLogic_IncomingMailboxFree;
if (++NextIncomingMailbox > HostAdapter->LastIncomingMailbox)
NextIncomingMailbox = HostAdapter->FirstIncomingMailbox;
}
HostAdapter->NextIncomingMailbox = NextIncomingMailbox;
}
else if (InterruptRegister & BusLogic_CommandComplete)
HostAdapter->HostAdapterCommandCompleted = true;
}
/*
Release exclusive access to Host Adapter.
*/
BusLogic_UnlockHostAdapterID(HostAdapter);
}
/*
Enable interrupts while the completed CCBs are processed.
*/
sti();
/*
Iterate over the Host Adapters performing any pending Host Adapter Resets.
*/
if (HostAdapterResetPendingCount > 0)
for (HostAdapter = BusLogic_RegisteredHostAdapters;
HostAdapter != NULL;
HostAdapter = HostAdapter->Next)
if (HostAdapter->HostAdapterResetPending)
{
BusLogic_ResetHostAdapter(HostAdapter, NULL);
HostAdapter->HostAdapterResetPending = false;
scsi_mark_host_bus_reset(HostAdapter->SCSI_Host);
}
/*
Iterate over the completed CCBs setting the SCSI Command Result Codes,
deallocating the CCBs, and calling the Completion Routines.
*/
while (FirstCompletedCCB != NULL)
{
BusLogic_CCB_T *CCB = FirstCompletedCCB;
SCSI_Command_T *Command = CCB->Command;
FirstCompletedCCB = FirstCompletedCCB->Next;
HostAdapter = CCB->HostAdapter;
/*
Bus Device Reset CCBs have the Command field non-NULL only when a Bus
Device Reset was requested for a command that was not currently active
in the Host Adapter, and hence would not have its Completion Routine
called otherwise.
*/
if (CCB->Opcode == BusLogic_SCSIBusDeviceReset)
{
printk("scsi%d: Bus Device Reset CCB #%d to Target %d Completed\n",
HostAdapter->HostNumber, CCB->SerialNumber, CCB->TargetID);
if (Command != NULL) Command->result = DID_RESET << 16;
}
else
/*
Translate the Mailbox Completion Code, Host Adapter Status, and
Target Device Status into a SCSI Subsystem Result Code.
*/
switch (CCB->MailboxCompletionCode)
{
case BusLogic_IncomingMailboxFree:
case BusLogic_AbortedCommandNotFound:
printk("scsi%d: CCB #%d to Target %d Impossible State\n",
HostAdapter->HostNumber, CCB->SerialNumber, CCB->TargetID);
break;
case BusLogic_CommandCompletedWithoutError:
HostAdapter->CommandSuccessfulFlag[CCB->TargetID] = true;
Command->result = DID_OK << 16;
break;
case BusLogic_CommandAbortedAtHostRequest:
printk("scsi%d: CCB #%d to Target %d Aborted\n",
HostAdapter->HostNumber, CCB->SerialNumber, CCB->TargetID);
Command->result = DID_ABORT << 16;
break;
case BusLogic_CommandCompletedWithError:
Command->result =
BusLogic_ComputeResultCode(CCB->HostAdapterStatus,
CCB->TargetDeviceStatus);
if (BusLogic_GlobalOptions & BusLogic_TraceErrors)
if (CCB->HostAdapterStatus != BusLogic_SCSISelectionTimeout)
{
int i;
printk("scsi%d: CCB #%d Target %d: Result %X "
"Host Adapter Status %02X Target Status %02X\n",
HostAdapter->HostNumber, CCB->SerialNumber,
CCB->TargetID, Command->result,
CCB->HostAdapterStatus, CCB->TargetDeviceStatus);
printk("scsi%d: CDB ", HostAdapter->HostNumber);
for (i = 0; i < CCB->CDB_Length; i++)
printk(" %02X", CCB->CDB[i]);
printk("\n");
printk("scsi%d: Sense ", HostAdapter->HostNumber);
for (i = 0; i < CCB->SenseDataLength; i++)
printk(" %02X", (*CCB->SenseDataPointer)[i]);
printk("\n");
}
break;
}
/*
Place CCB back on the Host Adapter's free list.
*/
BusLogic_DeallocateCCB(CCB);
/*
Call the SCSI Command Completion Routine if appropriate.
*/
if (Command != NULL) Command->scsi_done(Command);
}
}
/*
BusLogic_WriteOutgoingMailbox places CCB and Action Code into an Outgoing
Mailbox for execution by Host Adapter.
*/
static boolean BusLogic_WriteOutgoingMailbox(BusLogic_HostAdapter_T
*HostAdapter,
BusLogic_ActionCode_T ActionCode,
BusLogic_CCB_T *CCB)
{
BusLogic_OutgoingMailbox_T *NextOutgoingMailbox;
boolean Result = false;
BusLogic_LockHostAdapter(HostAdapter);
NextOutgoingMailbox = HostAdapter->NextOutgoingMailbox;
if (NextOutgoingMailbox->ActionCode == BusLogic_OutgoingMailboxFree)
{
CCB->Status = BusLogic_CCB_Active;
/*
The CCB field must be written before the Action Code field since
the Host Adapter is operating asynchronously and the locking code
does not protect against simultaneous access by the Host Adapter.
*/
NextOutgoingMailbox->CCB = CCB;
NextOutgoingMailbox->ActionCode = ActionCode;
BusLogic_StartMailboxScan(HostAdapter);
if (++NextOutgoingMailbox > HostAdapter->LastOutgoingMailbox)
NextOutgoingMailbox = HostAdapter->FirstOutgoingMailbox;
HostAdapter->NextOutgoingMailbox = NextOutgoingMailbox;
if (ActionCode == BusLogic_MailboxStartCommand)
HostAdapter->QueuedOperationCount[CCB->TargetID]++;
Result = true;
}
BusLogic_UnlockHostAdapter(HostAdapter);
return Result;
}
/*
BusLogic_QueueCommand creates a CCB for Command and places it into an
Outgoing Mailbox for execution by the associated Host Adapter.
*/
int BusLogic_QueueCommand(SCSI_Command_T *Command,
void (*CompletionRoutine)(SCSI_Command_T *))
{
BusLogic_HostAdapter_T *HostAdapter =
(BusLogic_HostAdapter_T *) Command->host->hostdata;
unsigned char *CDB = Command->cmnd;
unsigned char CDB_Length = Command->cmd_len;
unsigned char TargetID = Command->target;
unsigned char LogicalUnit = Command->lun;
void *BufferPointer = Command->request_buffer;
int BufferLength = Command->request_bufflen;
int SegmentCount = Command->use_sg;
BusLogic_CCB_T *CCB;
long EnableTQ;
/*
SCSI REQUEST_SENSE commands will be executed automatically by the Host
Adapter for any errors, so they should not be executed explicitly unless
the Sense Data is zero indicating that no error occurred.
*/
if (CDB[0] == REQUEST_SENSE && Command->sense_buffer[0] != 0)
{
Command->result = DID_OK << 16;
CompletionRoutine(Command);
return 0;
}
/*
Allocate a CCB from the Host Adapter's free list. If there are none
available and memory allocation fails, return a result code of Bus Busy
so that this Command will be retried.
*/
CCB = BusLogic_AllocateCCB(HostAdapter);
if (CCB == NULL)
{
Command->result = DID_BUS_BUSY << 16;
CompletionRoutine(Command);
return 0;
}
/*
Initialize the fields in the BusLogic Command Control Block (CCB).
*/
if (SegmentCount == 0)
{
CCB->Opcode = BusLogic_InitiatorCCB;
CCB->DataLength = BufferLength;
CCB->DataPointer = BufferPointer;
}
else
{
SCSI_ScatterList_T *ScatterList = (SCSI_ScatterList_T *) BufferPointer;
int Segment;
CCB->Opcode = BusLogic_InitiatorCCB_ScatterGather;
CCB->DataLength = SegmentCount * sizeof(BusLogic_ScatterGatherSegment_T);
CCB->DataPointer = CCB->ScatterGatherList;
for (Segment = 0; Segment < SegmentCount; Segment++)
{
CCB->ScatterGatherList[Segment].SegmentByteCount =
ScatterList[Segment].length;
CCB->ScatterGatherList[Segment].SegmentDataPointer =
ScatterList[Segment].address;
}
}
switch (CDB[0])
{
case READ_6:
case READ_10:
CCB->DataDirection = BusLogic_DataInLengthChecked;
HostAdapter->ReadWriteOperationCount[TargetID]++;
break;
case WRITE_6:
case WRITE_10:
CCB->DataDirection = BusLogic_DataOutLengthChecked;
HostAdapter->ReadWriteOperationCount[TargetID]++;
break;
default:
CCB->DataDirection = BusLogic_UncheckedDataTransfer;
break;
}
CCB->CDB_Length = CDB_Length;
CCB->SenseDataLength = sizeof(Command->sense_buffer);
CCB->HostAdapterStatus = 0;
CCB->TargetDeviceStatus = 0;
CCB->TargetID = TargetID;
CCB->LogicalUnit = LogicalUnit;
/*
For Wide SCSI Host Adapters, Wide Mode CCBs are used to support more than
8 Logical Units per Target, and this requires setting the overloaded
TagEnable field to Logical Unit bit 5.
*/
if (HostAdapter->HostWideSCSI)
{
CCB->TagEnable = LogicalUnit >> 5;
CCB->WideModeTagEnable = false;
}
else CCB->TagEnable = false;
/*
BusLogic recommends that after a Reset the first couple of commands that
are sent to a Target be sent in a non Tagged Queue fashion so that the Host
Adapter and Target can establish Synchronous Transfer before Queue Tag
messages can interfere with the Synchronous Negotiation message. By
waiting to enable tagged Queuing until after the first 16 read/write
commands have been sent, it is assured that the Tagged Queuing message
will not occur while the partition table is printed.
*/
if ((HostAdapter->TaggedQueuingPermitted & (1 << TargetID)) &&
Command->device->tagged_supported &&
(EnableTQ = HostAdapter->ReadWriteOperationCount[TargetID] - 16) >= 0)
{
BusLogic_QueueTag_T QueueTag = BusLogic_SimpleQueueTag;
unsigned long CurrentTime = jiffies;
if (EnableTQ == 0)
printk("scsi%d: Tagged Queuing now active for Target %d\n",
HostAdapter->HostNumber, TargetID);
/*
When using Tagged Queuing with Simple Queue Tags, it appears that disk
drive controllers do not guarantee that a queued command will not
remain in a disconnected state indefinitely if commands that read or
write nearer the head position continue to arrive without interruption.
Therefore, for each Target Device this driver keeps track of the last
time either the queue was empty or an Ordered Queue Tag was issued. If
more than 2 seconds have elapsed since this last sequence point, this
command will be issued with an Ordered Queue Tag rather than a Simple
Queue Tag, which forces the Target Device to complete all previously
queued commands before this command may be executed.
*/
if (HostAdapter->QueuedOperationCount[TargetID] == 0)
HostAdapter->LastSequencePoint[TargetID] = CurrentTime;
else if (CurrentTime - HostAdapter->LastSequencePoint[TargetID] > 2*HZ)
{
HostAdapter->LastSequencePoint[TargetID] = CurrentTime;
QueueTag = BusLogic_OrderedQueueTag;
}
if (HostAdapter->HostWideSCSI)
{
CCB->WideModeTagEnable = true;
CCB->WideModeQueueTag = QueueTag;
}
else
{
CCB->TagEnable = true;
CCB->QueueTag = QueueTag;
}
}
memcpy(CCB->CDB, CDB, CDB_Length);
CCB->SenseDataPointer = (SCSI_SenseData_T *) &Command->sense_buffer;
CCB->Command = Command;
Command->scsi_done = CompletionRoutine;
/*
Place the CCB in an Outgoing Mailbox. If there are no Outgoing
Mailboxes available, return a result code of Bus Busy so that this
Command will be retried.
*/
if (!(BusLogic_WriteOutgoingMailbox(HostAdapter,
BusLogic_MailboxStartCommand, CCB)))
{
printk("scsi%d: cannot write Outgoing Mailbox\n",
HostAdapter->HostNumber);
BusLogic_DeallocateCCB(CCB);
Command->result = DID_BUS_BUSY << 16;
CompletionRoutine(Command);
}
return 0;
}
/*
BusLogic_AbortCommand aborts Command if possible.
*/
int BusLogic_AbortCommand(SCSI_Command_T *Command)
{
BusLogic_HostAdapter_T *HostAdapter =
(BusLogic_HostAdapter_T *) Command->host->hostdata;
unsigned long CommandPID = Command->pid;
unsigned char InterruptRegister;
BusLogic_CCB_T *CCB;
int Result;
/*
If the Host Adapter has posted an interrupt but the Interrupt Handler
has not been called for some reason (i.e. the interrupt was lost), try
calling the Interrupt Handler directly to process the commands that
have been completed.
*/
InterruptRegister = BusLogic_ReadInterruptRegister(HostAdapter);
if (InterruptRegister & BusLogic_InterruptValid)
{
unsigned long ProcessorFlags;
printk("scsi%d: Recovering Lost/Delayed Interrupt for IRQ Channel %d\n",
HostAdapter->HostNumber, HostAdapter->IRQ_Channel);
save_flags(ProcessorFlags);
cli();
BusLogic_InterruptHandler(HostAdapter->IRQ_Channel, NULL);
restore_flags(ProcessorFlags);
return SCSI_ABORT_SNOOZE;
}
/*
Find the CCB to be aborted if possible.
*/
BusLogic_LockHostAdapter(HostAdapter);
for (CCB = HostAdapter->All_CCBs; CCB != NULL; CCB = CCB->NextAll)
if (CCB->Command == Command) break;
BusLogic_UnlockHostAdapter(HostAdapter);
if (CCB == NULL)
{
printk("scsi%d: Unable to Abort Command to Target %d - No CCB Found\n",
HostAdapter->HostNumber, Command->target);
return SCSI_ABORT_NOT_RUNNING;
}
/*
Briefly pause to see if this command will complete.
*/
printk("scsi%d: Pausing briefly to see if CCB #%d "
"to Target %d will complete\n",
HostAdapter->HostNumber, CCB->SerialNumber, CCB->TargetID);
BusLogic_Delay(2);
/*
If this CCB is still Active and still refers to the same Command, then
actually aborting this Command is necessary.
*/
BusLogic_LockHostAdapter(HostAdapter);
Result = SCSI_ABORT_NOT_RUNNING;
if (CCB->Status == BusLogic_CCB_Active &&
CCB->Command == Command && Command->pid == CommandPID)
{
/*
Attempt to abort this CCB.
*/
if (BusLogic_WriteOutgoingMailbox(HostAdapter,
BusLogic_MailboxAbortCommand, CCB))
{
printk("scsi%d: Aborting CCB #%d to Target %d\n",
HostAdapter->HostNumber, CCB->SerialNumber, CCB->TargetID);
Result = SCSI_ABORT_PENDING;
}
else
{
printk("scsi%d: Unable to Abort CCB #%d to Target %d - "
"No Outgoing Mailboxes\n", HostAdapter->HostNumber,
CCB->SerialNumber, CCB->TargetID);
Result = SCSI_ABORT_BUSY;
}
}
else printk("scsi%d: CCB #%d to Target %d completed\n",
HostAdapter->HostNumber, CCB->SerialNumber, CCB->TargetID);
BusLogic_UnlockHostAdapter(HostAdapter);
return Result;
}
/*
BusLogic_ResetHostAdapter resets Host Adapter if possible, marking all
currently executing SCSI commands as having been reset, as well as
the specified Command if non-NULL.
*/
static int BusLogic_ResetHostAdapter(BusLogic_HostAdapter_T *HostAdapter,
SCSI_Command_T *Command)
{
BusLogic_CCB_T *CCB;
if (Command == NULL)
printk("scsi%d: Resetting %s due to SCSI Reset State Interrupt\n",
HostAdapter->HostNumber, HostAdapter->BoardName);
else printk("scsi%d: Resetting %s due to Target %d\n",
HostAdapter->HostNumber, HostAdapter->BoardName, Command->target);
/*
Attempt to Reset and Reinitialize the Host Adapter.
*/
BusLogic_LockHostAdapter(HostAdapter);
if (!(BusLogic_HardResetHostAdapter(HostAdapter) &&
BusLogic_InitializeHostAdapter(HostAdapter)))
{
printk("scsi%d: Resetting %s Failed\n",
HostAdapter->HostNumber, HostAdapter->BoardName);
BusLogic_UnlockHostAdapter(HostAdapter);
return SCSI_RESET_ERROR;
}
BusLogic_UnlockHostAdapter(HostAdapter);
/*
Wait a few seconds between the 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.
*/
BusLogic_Delay(HostAdapter->BusSettleTime);
/*
Mark all currently executing CCBs as having been reset.
*/
BusLogic_LockHostAdapter(HostAdapter);
for (CCB = HostAdapter->All_CCBs; CCB != NULL; CCB = CCB->NextAll)
if (CCB->Status == BusLogic_CCB_Active)
{
CCB->Status = BusLogic_CCB_Reset;
if (CCB->Command == Command)
{
CCB->Command = NULL;
/*
Disable Tagged Queuing if it was active for this Target Device.
*/
if (((HostAdapter->HostWideSCSI && CCB->WideModeTagEnable) ||
(!HostAdapter->HostWideSCSI && CCB->TagEnable)) &&
(HostAdapter->TaggedQueuingPermitted & (1 << CCB->TargetID)))
{
HostAdapter->TaggedQueuingPermitted &= ~(1 << CCB->TargetID);
printk("scsi%d: Tagged Queuing now disabled for Target %d\n",
HostAdapter->HostNumber, CCB->TargetID);
}
}
}
BusLogic_UnlockHostAdapter(HostAdapter);
/*
Perform completion processing for the Command being Reset.
*/
if (Command != NULL)
{
Command->result = DID_RESET << 16;
Command->scsi_done(Command);
}
/*
Perform completion processing for any other active CCBs.
*/
for (CCB = HostAdapter->All_CCBs; CCB != NULL; CCB = CCB->NextAll)
if (CCB->Status == BusLogic_CCB_Reset)
{
Command = CCB->Command;
BusLogic_DeallocateCCB(CCB);
if (Command != NULL)
{
Command->result = DID_RESET << 16;
Command->scsi_done(Command);
}
}
return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
}
/*
BusLogic_BusDeviceReset sends a Bus Device Reset to the Target
associated with Command.
*/
static int BusLogic_BusDeviceReset(BusLogic_HostAdapter_T *HostAdapter,
SCSI_Command_T *Command)
{
BusLogic_CCB_T *CCB = BusLogic_AllocateCCB(HostAdapter), *XCCB;
unsigned char TargetID = Command->target;
/*
If sending a Bus Device Reset is impossible, attempt a full Host
Adapter Hard Reset and SCSI Bus Reset.
*/
if (CCB == NULL)
return BusLogic_ResetHostAdapter(HostAdapter, Command);
printk("scsi%d: Sending Bus Device Reset CCB #%d to Target %d\n",
HostAdapter->HostNumber, CCB->SerialNumber, TargetID);
CCB->Opcode = BusLogic_SCSIBusDeviceReset;
CCB->TargetID = TargetID;
CCB->Command = Command;
/*
If there is a currently executing CCB in the Host Adapter for this Command,
then an Incoming Mailbox entry will be made with a completion code of
BusLogic_HostAdapterAssertedBusDeviceReset. Otherwise, the CCB's Command
field will be left pointing to the Command so that the interrupt for the
completion of the Bus Device Reset can call the Completion Routine for the
Command.
*/
BusLogic_LockHostAdapter(HostAdapter);
for (XCCB = HostAdapter->All_CCBs; XCCB != NULL; XCCB = XCCB->NextAll)
if (XCCB->Command == Command && XCCB->Status == BusLogic_CCB_Active)
{
CCB->Command = NULL;
/*
Disable Tagged Queuing if it was active for this Target Device.
*/
if (((HostAdapter->HostWideSCSI && XCCB->WideModeTagEnable) ||
(!HostAdapter->HostWideSCSI && XCCB->TagEnable)) &&
(HostAdapter->TaggedQueuingPermitted & (1 << TargetID)))
{
HostAdapter->TaggedQueuingPermitted &= ~(1 << TargetID);
printk("scsi%d: Tagged Queuing now disabled for Target %d\n",
HostAdapter->HostNumber, TargetID);
}
break;
}
BusLogic_UnlockHostAdapter(HostAdapter);
/*
Attempt to write an Outgoing Mailbox with the Bus Device Reset CCB.
If sending a Bus Device Reset is impossible, attempt a full Host
Adapter Hard Reset and SCSI Bus Reset.
*/
if (!(BusLogic_WriteOutgoingMailbox(HostAdapter,
BusLogic_MailboxStartCommand, CCB)))
{
printk("scsi%d: cannot write Outgoing Mailbox for Bus Device Reset\n",
HostAdapter->HostNumber);
BusLogic_DeallocateCCB(CCB);
return BusLogic_ResetHostAdapter(HostAdapter, Command);
}
HostAdapter->ReadWriteOperationCount[TargetID] = 0;
HostAdapter->QueuedOperationCount[TargetID] = 0;
return SCSI_RESET_PENDING;
}
/*
BusLogic_ResetCommand takes appropriate action to reset Command.
*/
int BusLogic_ResetCommand(SCSI_Command_T *Command)
{
BusLogic_HostAdapter_T *HostAdapter =
(BusLogic_HostAdapter_T *) Command->host->hostdata;
unsigned char TargetID = Command->target;
unsigned char ErrorRecoveryOption =
HostAdapter->ErrorRecoveryOption[TargetID];
if (ErrorRecoveryOption == BusLogic_ErrorRecoveryDefault)
if (Command->host->suggest_bus_reset)
ErrorRecoveryOption = BusLogic_ErrorRecoveryHardReset;
else ErrorRecoveryOption = BusLogic_ErrorRecoveryBusDeviceReset;
switch (ErrorRecoveryOption)
{
case BusLogic_ErrorRecoveryHardReset:
return BusLogic_ResetHostAdapter(HostAdapter, Command);
case BusLogic_ErrorRecoveryBusDeviceReset:
if (HostAdapter->CommandSuccessfulFlag[TargetID])
{
HostAdapter->CommandSuccessfulFlag[TargetID] = false;
return BusLogic_BusDeviceReset(HostAdapter, Command);
}
else return BusLogic_ResetHostAdapter(HostAdapter, Command);
}
printk("scsi%d: Error Recovery for Target %d Suppressed\n",
HostAdapter->HostNumber, TargetID);
return SCSI_RESET_PUNT;
}
/*
BusLogic_BIOSDiskParameters returns the Heads/Sectors/Cylinders BIOS Disk
Parameters for Disk. The default disk geometry is 64 heads, 32 sectors, and
the appropriate number of cylinders so as not to exceed drive capacity. In
order for disks equal to or larger than 1 GB to be addressable by the BIOS
without exceeding the BIOS limitation of 1024 cylinders, Extended Translation
may be enabled in AutoSCSI on "C" Series boards or by a dip switch setting
on older boards. With Extended Translation enabled, drives between 1 GB
inclusive and 2 GB exclusive are given a disk geometry of 128 heads and 32
sectors, and drives between 2 GB inclusive and 8 GB exclusive are given a
disk geometry of 255 heads and 63 sectors. On "C" Series boards the firmware
can be queried for the precise translation in effect for each drive
individually, but there is really no need to do so since we know the total
capacity of the drive and whether Extended Translation is enabled, hence we
can deduce the BIOS disk geometry that must be in effect.
*/
int BusLogic_BIOSDiskParameters(SCSI_Disk_T *Disk, KernelDevice_T Device,
int *Parameters)
{
BusLogic_HostAdapter_T *HostAdapter =
(BusLogic_HostAdapter_T *) Disk->device->host->hostdata;
BIOS_DiskParameters_T *DiskParameters = (BIOS_DiskParameters_T *) Parameters;
if (HostAdapter->ExtendedTranslation &&
Disk->capacity >= 2*1024*1024 /* 1 GB in 512 byte sectors */)
if (Disk->capacity >= 4*1024*1024 /* 2 GB in 512 byte sectors */)
{
DiskParameters->Heads = 255;
DiskParameters->Sectors = 63;
}
else
{
DiskParameters->Heads = 128;
DiskParameters->Sectors = 32;
}
else
{
DiskParameters->Heads = 64;
DiskParameters->Sectors = 32;
}
DiskParameters->Cylinders =
Disk->capacity / (DiskParameters->Heads * DiskParameters->Sectors);
return 0;
}
/*
BusLogic_Setup handles processing of Kernel Command Line Arguments.
For the BusLogic driver, a kernel command line entry comprises the driver
identifier "BusLogic=" optionally followed by a comma-separated sequence of
integers and then optionally followed by a comma-separated sequence of
strings. Each command line entry applies to one BusLogic Host Adapter.
Multiple command line entries may be used in systems which contain multiple
BusLogic Host Adapters.
The first integer specified is the I/O Address at which the Host Adapter is
located. If unspecified, it defaults to 0 which means to apply this entry to
the first BusLogic Host Adapter found during the default probe sequence. If
any I/O Address parameters are provided on the command line, then the default
probe sequence is omitted.
The second integer specified is the number of Concurrent Commands per Logical
Unit to allow for Target Devices on the Host Adapter. If unspecified, it
defaults to 0 which means to use the value of BusLogic_Concurrency for
non-ISA Host Adapters, or BusLogic_Concurrency_ISA for ISA Host Adapters.
The third integer specified is the Bus Settle Time in seconds. This is
the amount of time to wait between a Host Adapter Hard Reset which initiates
a SCSI Bus Reset and issuing any SCSI commands. If unspecified, it defaults
to 0 which means to use the value of BusLogic_DefaultBusSettleTime.
The fourth integer specified is the Local Options. If unspecified, it
defaults to 0. Note that Local Options are only applied to a specific Host
Adapter.
The fifth integer specified is the Global Options. If unspecified, it
defaults to 0. Note that Global Options are applied across all Host
Adapters.
The string options are used to provide control over Tagged Queuing and Error
Recovery. If both Tagged Queuing and Error Recovery strings are provided, the
Tagged Queuing specification string must come first.
The Tagged Queuing specification begins with "TQ:" and allows for explicitly
specifying whether Tagged Queuing is permitted on Target Devices that support
it. The following specification options are available:
TQ:Default Tagged Queuing will be permitted based on the firmware
version of the BusLogic Host Adapter and based on
whether the Concurrency value allows queuing multiple
commands.
TQ:Enable Tagged Queuing will be enabled for all Target Devices
on this Host Adapter overriding any limitation that
would otherwise be imposed based on the Host Adapter
firmware version.
TQ:Disable Tagged Queuing will be disabled for all Target Devices
on this Host Adapter.
TQ:<Per-Target-Spec> Tagged Queuing will be controlled individually for each
Target Device. <Per-Target-Spec> is a sequence of "Y",
"N", and "X" characters. "Y" enabled Tagged Queuing,
"N" disables Tagged Queuing, and "X" accepts the
default based on the firmware version. The first
character refers to Target 0, the second to Target 1,
and so on; if the sequence of "Y", "N", and "X"
characters does not cover all the Target Devices,
unspecified characters are assumed to be "X".
Note that explicitly requesting Tagged Queuing may lead to problems; this
facility is provided primarily to allow disabling Tagged Queuing on Target
Devices that do not implement it correctly.
The Error Recovery specification begins with "ER:" and allows for explicitly
specifying the Error Recovery action to be performed when ResetCommand is
called due to a SCSI Command failing to complete successfully. The following
specification options are available:
ER:Default Error Recovery will select between the Hard Reset and
Bus Device Reset options based on the recommendation
of the SCSI Subsystem.
ER:HardReset Error Recovery will initiate a Host Adapter Hard Reset
which also causes a SCSI Bus Reset.
ER:BusDeviceReset Error Recovery will send a Bus Device Reset message to
the individual Target Device causing the error. If
Error Recovery is again initiated for this Target
Device and no SCSI Command to this Target Device has
completed successfully since the Bus Device Reset
message was sent, then a Hard Reset will be attempted.
ER:None Error Recovery will be suppressed. This option should
only be selected if a SCSI Bus Reset or Bus Device
Reset will cause the Target Device to fail completely
and unrecoverably.
ER:<Per-Target-Spec> Error Recovery will be controlled individually for each
Target Device. <Per-Target-Spec> is a sequence of "D",
"H", "B", and "N" characters. "D" selects Default, "H"
selects Hard Reset, "B" selects Bus Device Reset, and
"N" selects None. The first character refers to Target
0, the second to Target 1, and so on; if the sequence
of "D", "H", "B", and "N" characters does not cover all
the Target Devices, unspecified characters are assumed
to be "D".
*/
void BusLogic_Setup(char *Strings, int *Integers)
{
BusLogic_CommandLineEntry_T *CommandLineEntry =
&BusLogic_CommandLineEntries[BusLogic_CommandLineEntryCount++];
static int ProbeListIndex = 0;
int IntegerCount = Integers[0], TargetID, i;
CommandLineEntry->IO_Address = 0;
CommandLineEntry->Concurrency = 0;
CommandLineEntry->BusSettleTime = 0;
CommandLineEntry->LocalOptions = 0;
CommandLineEntry->TaggedQueuingPermitted = 0;
CommandLineEntry->TaggedQueuingPermittedMask = 0;
memset(CommandLineEntry->ErrorRecoveryOption,
BusLogic_ErrorRecoveryDefault,
sizeof(CommandLineEntry->ErrorRecoveryOption));
if (IntegerCount > 5)
printk("BusLogic: Unexpected Command Line Integers ignored\n");
if (IntegerCount >= 1)
{
unsigned short IO_Address = Integers[1];
if (IO_Address > 0)
{
for (i = 0; ; i++)
if (BusLogic_IO_StandardAddresses[i] == 0)
{
printk("BusLogic: Invalid Command Line Entry "
"(illegal I/O Address 0x%X)\n", IO_Address);
return;
}
else if (i < ProbeListIndex &&
IO_Address == BusLogic_IO_AddressProbeList[i])
{
printk("BusLogic: Invalid Command Line Entry "
"(duplicate I/O Address 0x%X)\n", IO_Address);
return;
}
else if (IO_Address >= 0x1000 ||
IO_Address == BusLogic_IO_StandardAddresses[i]) break;
BusLogic_IO_AddressProbeList[ProbeListIndex++] = IO_Address;
BusLogic_IO_AddressProbeList[ProbeListIndex] = 0;
}
CommandLineEntry->IO_Address = IO_Address;
}
if (IntegerCount >= 2)
{
unsigned short Concurrency = Integers[2];
if (Concurrency > BusLogic_MailboxCount)
{
printk("BusLogic: Invalid Command Line Entry "
"(illegal Concurrency %d)\n", Concurrency);
return;
}
CommandLineEntry->Concurrency = Concurrency;
}
if (IntegerCount >= 3)
CommandLineEntry->BusSettleTime = Integers[3];
if (IntegerCount >= 4)
CommandLineEntry->LocalOptions = Integers[4];
if (IntegerCount >= 5)
BusLogic_GlobalOptions |= Integers[5];
if (!(BusLogic_CommandLineEntryCount == 0 || ProbeListIndex == 0 ||
BusLogic_CommandLineEntryCount == ProbeListIndex))
{
printk("BusLogic: Invalid Command Line Entry "
"(all or no I/O Addresses must be specified)\n");
return;
}
if (Strings == NULL) return;
if (strncmp(Strings, "TQ:", 3) == 0)
{
Strings += 3;
if (strncmp(Strings, "Default", 7) == 0)
Strings += 7;
else if (strncmp(Strings, "Enable", 6) == 0)
{
Strings += 6;
CommandLineEntry->TaggedQueuingPermitted = 0xFFFF;
CommandLineEntry->TaggedQueuingPermittedMask = 0xFFFF;
}
else if (strncmp(Strings, "Disable", 7) == 0)
{
Strings += 7;
CommandLineEntry->TaggedQueuingPermitted = 0x0000;
CommandLineEntry->TaggedQueuingPermittedMask = 0xFFFF;
}
else
for (TargetID = 0; TargetID < BusLogic_MaxTargetIDs; TargetID++)
switch (*Strings++)
{
case 'Y':
CommandLineEntry->TaggedQueuingPermitted |= 1 << TargetID;
CommandLineEntry->TaggedQueuingPermittedMask |= 1 << TargetID;
break;
case 'N':
CommandLineEntry->TaggedQueuingPermittedMask |= 1 << TargetID;
break;
case 'X':
break;
default:
Strings--;
TargetID = BusLogic_MaxTargetIDs;
break;
}
}
if (*Strings == ',') Strings++;
if (strncmp(Strings, "ER:", 3) == 0)
{
Strings += 3;
if (strncmp(Strings, "Default", 7) == 0)
Strings += 7;
else if (strncmp(Strings, "HardReset", 9) == 0)
{
Strings += 9;
memset(CommandLineEntry->ErrorRecoveryOption,
BusLogic_ErrorRecoveryHardReset,
sizeof(CommandLineEntry->ErrorRecoveryOption));
}
else if (strncmp(Strings, "BusDeviceReset", 14) == 0)
{
Strings += 14;
memset(CommandLineEntry->ErrorRecoveryOption,
BusLogic_ErrorRecoveryBusDeviceReset,
sizeof(CommandLineEntry->ErrorRecoveryOption));
}
else if (strncmp(Strings, "None", 4) == 0)
{
Strings += 4;
memset(CommandLineEntry->ErrorRecoveryOption,
BusLogic_ErrorRecoveryNone,
sizeof(CommandLineEntry->ErrorRecoveryOption));
}
else
for (TargetID = 0; TargetID < BusLogic_MaxTargetIDs; TargetID++)
switch (*Strings++)
{
case 'D':
CommandLineEntry->ErrorRecoveryOption[TargetID] =
BusLogic_ErrorRecoveryDefault;
break;
case 'H':
CommandLineEntry->ErrorRecoveryOption[TargetID] =
BusLogic_ErrorRecoveryHardReset;
break;
case 'B':
CommandLineEntry->ErrorRecoveryOption[TargetID] =
BusLogic_ErrorRecoveryBusDeviceReset;
break;
case 'N':
CommandLineEntry->ErrorRecoveryOption[TargetID] =
BusLogic_ErrorRecoveryNone;
break;
default:
Strings--;
TargetID = BusLogic_MaxTargetIDs;
break;
}
}
if (*Strings != '\0')
printk("BusLogic: Unexpected Command Line String '%s' ignored\n", Strings);
}
/*
Include Module support if requested.
*/
#ifdef MODULE
SCSI_Host_Template_T driver_template = BUSLOGIC;
#include "scsi_module.c"
#endif
|