summaryrefslogtreecommitdiffstats
path: root/drivers/block/DAC960.h
blob: e93448faba1eda688bf04059a255ae261b118ced (plain)
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
/*

  Linux Driver for Mylex DAC960 and DAC1100 PCI RAID Controllers

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

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

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

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

*/


/*
  Define the maximum number of DAC960 Controllers supported by this driver.
*/

#define DAC960_MaxControllers			8


/*
  Define the maximum number of Controller Channels supported by this driver.
*/

#define DAC960_MaxChannels			3


/*
  Define the maximum number of Targets per Channel supported by this driver.
*/

#define DAC960_MaxTargets			16


/*
  Define the maximum number of Logical Drives supported by any DAC960 model.
*/

#define DAC960_MaxLogicalDrives			32


/*
  Define a Boolean data type.
*/

typedef enum { false, true } __attribute__ ((packed)) boolean;


/*
  Define a 32 bit I/O Address data type.
*/

typedef unsigned int DAC960_IO_Address_T;


/*
  Define a 32 bit PCI Bus Address data type.
*/

typedef unsigned int DAC960_PCI_Address_T;


/*
  Define a 32 bit Bus Address data type.
*/

typedef unsigned int DAC960_BusAddress_T;


/*
  Define a 32 bit Byte Count data type.
*/

typedef unsigned int DAC960_ByteCount_T;


/*
  Define the DAC960 Command Opcodes.
*/

typedef enum
{
  /* I/O Commands */
  DAC960_ReadExtended =				0x33,
  DAC960_WriteExtended =			0x34,
  DAC960_ReadAheadExtended =			0x35,
  DAC960_ReadExtendedWithScatterGather =	0xB3,
  DAC960_WriteExtendedWithScatterGather =	0xB4,
  DAC960_Read =					0x36,
  DAC960_ReadWithOldScatterGather =		0xB6,
  DAC960_Write =				0x37,
  DAC960_WriteWithOldScatterGather =		0xB7,
  DAC960_DCDB =					0x04,
  DAC960_DCDBWithScatterGather =		0x84,
  DAC960_Flush =				0x0A,
  /* Controller Status Related Commands */
  DAC960_Enquiry =				0x53,
  DAC960_Enquiry2 =				0x1C,
  DAC960_GetLogicalDriveElement =		0x55,
  DAC960_GetLogicalDriveInformation =		0x19,
  DAC960_IOPortRead =				0x39,
  DAC960_IOPortWrite =				0x3A,
  DAC960_GetSDStats =				0x3E,
  DAC960_GetPDStats =				0x3F,
  DAC960_PerformEventLogOperation =		0x72,
  /* Device Related Commands */
  DAC960_StartDevice =				0x10,
  DAC960_GetDeviceState =			0x50,
  DAC960_StopChannel =				0x13,
  DAC960_StartChannel =				0x12,
  DAC960_ResetChannel =				0x1A,
  /* Commands Associated with Data Consistency and Errors */
  DAC960_Rebuild =				0x09,
  DAC960_RebuildAsync =				0x16,
  DAC960_CheckConsistency =			0x0F,
  DAC960_CheckConsistencyAsync =		0x1E,
  DAC960_RebuildStat =				0x0C,
  DAC960_GetRebuildProgress =			0x27,
  DAC960_RebuildControl =			0x1F,
  DAC960_ReadBadBlockTable =			0x0B,
  DAC960_ReadBadDataTable =			0x25,
  DAC960_ClearBadDataTable =			0x26,
  DAC960_GetErrorTable =			0x17,
  DAC960_AddCapacityAsync =			0x2A,
  /* Configuration Related Commands */
  DAC960_ReadConfig2 =				0x3D,
  DAC960_WriteConfig2 =				0x3C,
  DAC960_ReadConfigurationOnDisk =		0x4A,
  DAC960_WriteConfigurationOnDisk =		0x4B,
  DAC960_ReadConfiguration =			0x4E,
  DAC960_ReadBackupConfiguration =		0x4D,
  DAC960_WriteConfiguration =			0x4F,
  DAC960_AddConfiguration =			0x4C,
  DAC960_ReadConfigurationLabel =		0x48,
  DAC960_WriteConfigurationLabel =		0x49,
  /* Firmware Upgrade Related Commands */
  DAC960_LoadImage =				0x20,
  DAC960_StoreImage =				0x21,
  DAC960_ProgramImage =				0x22,
  /* Diagnostic Commands */
  DAC960_SetDiagnosticMode =			0x31,
  DAC960_RunDiagnostic =			0x32,
  /* Subsystem Service Commands */
  DAC960_GetSubsystemData =			0x70,
  DAC960_SetSubsystemParameters =		0x71
}
__attribute__ ((packed))
DAC960_CommandOpcode_T;


/*
  Define the DAC960 Command Identifier type.
*/

typedef unsigned char DAC960_CommandIdentifier_T;


/*
  Define the DAC960 Command Status Codes.
*/

#define DAC960_NormalCompletion			0x0000	/* Common */
#define DAC960_CheckConditionReceived		0x0002	/* Common */
#define DAC960_NoDeviceAtAddress		0x0102	/* Common */
#define DAC960_InvalidDeviceAddress		0x0105	/* Common */
#define DAC960_InvalidParameter			0x0105	/* Common */
#define DAC960_IrrecoverableDataError		0x0001	/* I/O */
#define DAC960_LogicalDriveNonexistentOrOffline	0x0002	/* I/O */
#define DAC960_AccessBeyondEndOfLogicalDrive	0x0105	/* I/O */
#define DAC960_BadDataEncountered		0x010C	/* I/O */
#define DAC960_DeviceBusy			0x0008	/* DCDB */
#define DAC960_DeviceNonresponsive		0x000E	/* DCDB */
#define DAC960_CommandTerminatedAbnormally	0x000F	/* DCDB */
#define DAC960_UnableToStartDevice		0x0002	/* Device */
#define DAC960_InvalidChannelOrTargetOrModifier	0x0105	/* Device */
#define DAC960_ChannelBusy			0x0106	/* Device */
#define DAC960_ChannelNotStopped		0x0002	/* Device */
#define DAC960_AttemptToRebuildOnlineDrive	0x0002	/* Consistency */
#define DAC960_RebuildBadBlocksEncountered	0x0003	/* Consistency */
#define DAC960_NewDiskFailedDuringRebuild	0x0004	/* Consistency */
#define DAC960_RebuildOrCheckAlreadyInProgress	0x0106	/* Consistency */
#define DAC960_DependentDiskIsDead		0x0002	/* Consistency */
#define DAC960_InconsistentBlocksFound		0x0003	/* Consistency */
#define DAC960_InvalidOrNonredundantLogicalDrive 0x0105	/* Consistency */
#define DAC960_NoRebuildOrCheckInProgress	0x0105	/* Consistency */
#define DAC960_RebuildInProgress_DataValid	0x0000	/* Consistency */
#define DAC960_RebuildFailed_LogicalDriveFailure 0x0002	/* Consistency */
#define DAC960_RebuildFailed_BadBlocksOnOther	0x0003	/* Consistency */
#define DAC960_RebuildFailed_NewDriveFailed	0x0004	/* Consistency */
#define DAC960_RebuildSuccessful		0x0100	/* Consistency */
#define DAC960_AddCapacityInProgress		0x0004	/* Consistency */
#define DAC960_AddCapacityFailedOrSuspended	0x00F4	/* Consistency */
#define DAC960_Config2ChecksumError		0x0002	/* Configuration */
#define DAC960_ConfigurationSuspended		0x0106	/* Configuration */
#define DAC960_FailedToConfigureNVRAM		0x0105	/* Configuration */
#define DAC960_ConfigurationNotSavedStateChange	0x0106	/* Configuration */
#define DAC960_SubsystemNotInstalled		0x0001	/* Subsystem */
#define DAC960_SubsystemFailed			0x0002	/* Subsystem */
#define DAC960_SubsystemBusy			0x0106	/* Subsystem */

typedef unsigned short DAC960_CommandStatus_T;


/*
  Define the Enquiry reply structure.
*/

typedef struct DAC960_Enquiry
{
  unsigned char NumberOfLogicalDrives;			/* Byte 0 */
  unsigned int :24;					/* Bytes 1-3 */
  unsigned int LogicalDriveSizes[32];			/* Bytes 4-131 */
  unsigned short FlashAge;				/* Bytes 132-133 */
  struct {
    boolean DeferredWriteError:1;			/* Byte 134 Bit 0 */
    boolean BatteryLow:1;				/* Byte 134 Bit 1 */
    unsigned char :6;					/* Byte 134 Bits 2-7 */
  } StatusFlags;
  unsigned char :8;					/* Byte 135 */
  unsigned char MinorFirmwareVersion;			/* Byte 136 */
  unsigned char MajorFirmwareVersion;			/* Byte 137 */
  enum {
    DAC960_NoStandbyRebuildOrCheckInProgress =			0x00,
    DAC960_StandbyRebuildInProgress =				0x01,
    DAC960_BackgroundRebuildInProgress =			0x02,
    DAC960_BackgroundCheckInProgress =				0x03,
    DAC960_StandbyRebuildCompletedWithError =			0xFF,
    DAC960_BackgroundRebuildOrCheckFailed_DriveFailed =		0xF0,
    DAC960_BackgroundRebuildOrCheckFailed_LogicalDriveFailed =	0xF1,
    DAC960_BackgroundRebuildOrCheckFailed_OtherCauses =		0xF2,
    DAC960_BackgroundRebuildOrCheckSuccessfullyTerminated =	0xF3
  } __attribute__ ((packed)) RebuildFlag;		/* Byte 138 */
  unsigned char MaxCommands;				/* Byte 139 */
  unsigned char OfflineLogicalDriveCount;		/* Byte 140 */
  unsigned char :8;					/* Byte 141 */
  unsigned short EventLogSequenceNumber;		/* Bytes 142-143 */
  unsigned char CriticalLogicalDriveCount;		/* Byte 144 */
  unsigned int :24;					/* Bytes 145-147 */
  unsigned char DeadDriveCount;				/* Byte 148 */
  unsigned char :8;					/* Byte 149 */
  unsigned char RebuildCount;				/* Byte 150 */
  struct {
    unsigned char :3;					/* Byte 151 Bits 0-2 */
    boolean BatteryBackupUnitPresent:1;			/* Byte 151 Bit 3 */
    unsigned char :3;					/* Byte 151 Bits 4-6 */
    unsigned char :1;					/* Byte 151 Bit 7 */
  } MiscFlags;
  struct {
    unsigned char TargetID;
    unsigned char Channel;
  } DeadDrives[21];					/* Bytes 152-194 */
  unsigned char Reserved[62];				/* Bytes 195-255 */
}
__attribute__ ((packed))
DAC960_Enquiry_T;


/*
  Define the Enquiry2 reply structure.
*/

typedef struct DAC960_Enquiry2
{
  struct {
    enum {
      DAC960_P_PD_PU =				0x01,
      DAC960_PL =				0x02,
      DAC960_PG =				0x10,
      DAC960_PJ =				0x11,
      DAC960_PR =				0x12,
      DAC960_PT =				0x13,
      DAC960_PTL0 =				0x14,
      DAC960_PRL =				0x15,
      DAC960_PTL1 =				0x16,
      DAC1164_P =				0x20
    } __attribute__ ((packed)) SubModel;		/* Byte 0 */
    unsigned char ActualChannels;			/* Byte 1 */
    enum {
      DAC960_FiveChannelBoard =			0x01,
      DAC960_ThreeChannelBoard =		0x02,
      DAC960_TwoChannelBoard =			0x03,
      DAC960_ThreeChannelASIC_DAC =		0x04
    } __attribute__ ((packed)) Model;			/* Byte 2 */
    enum {
      DAC960_EISA_Controller =			0x01,
      DAC960_MicroChannel_Controller =		0x02,
      DAC960_PCI_Controller =			0x03,
      DAC960_SCSItoSCSI_Controller =		0x08
    } __attribute__ ((packed)) ProductFamily;		/* Byte 3 */
  } HardwareID;						/* Bytes 0-3 */
  /* MajorVersion.MinorVersion-FirmwareType-TurnID */
  struct {
    unsigned char MajorVersion;				/* Byte 4 */
    unsigned char MinorVersion;				/* Byte 5 */
    unsigned char TurnID;				/* Byte 6 */
    char FirmwareType;					/* Byte 7 */
  } FirmwareID;						/* Bytes 4-7 */
  unsigned char :8;					/* Byte 8 */
  unsigned int :24;					/* Bytes 9-11 */
  unsigned char ConfiguredChannels;			/* Byte 12 */
  unsigned char ActualChannels;				/* Byte 13 */
  unsigned char MaxTargets;				/* Byte 14 */
  unsigned char MaxTags;				/* Byte 15 */
  unsigned char MaxLogicalDrives;			/* Byte 16 */
  unsigned char MaxArms;				/* Byte 17 */
  unsigned char MaxSpans;				/* Byte 18 */
  unsigned char :8;					/* Byte 19 */
  unsigned int :32;					/* Bytes 20-23 */
  unsigned int MemorySize;				/* Bytes 24-27 */
  unsigned int CacheSize;				/* Bytes 28-31 */
  unsigned int FlashMemorySize;				/* Bytes 32-35 */
  unsigned int NonVolatileMemorySize;			/* Bytes 36-39 */
  struct {
    enum {
      DAC960_DRAM =				0x00,
      DAC960_EDO =				0x01,
      DAC960_SDRAM =				0x02
    } __attribute__ ((packed)) RamType:3;		/* Byte 40 Bits 0-2 */
    enum {
      DAC960_None =				0x00,
      DAC960_Parity =				0x01,
      DAC960_ECC =				0x02
    } __attribute__ ((packed)) ErrorCorrection:3;	/* Byte 40 Bits 3-5 */
    boolean FastPageMode:1;				/* Byte 40 Bit 6 */
    boolean LowPowerMemory:1;				/* Byte 40 Bit 7 */
    unsigned char :8;					/* Bytes 41 */
  } MemoryType;
  unsigned short ClockSpeed;				/* Bytes 42-43 */
  unsigned short MemorySpeed;				/* Bytes 44-45 */
  unsigned short HardwareSpeed;				/* Bytes 46-47 */
  unsigned int :32;					/* Bytes 48-51 */
  unsigned int :32;					/* Bytes 52-55 */
  unsigned char :8;					/* Byte 56 */
  unsigned char :8;					/* Byte 57 */
  unsigned short :16;					/* Bytes 58-59 */
  unsigned short MaxCommands;				/* Bytes 60-61 */
  unsigned short MaxScatterGatherEntries;		/* Bytes 62-63 */
  unsigned short MaxDriveCommands;			/* Bytes 64-65 */
  unsigned short MaxIODescriptors;			/* Bytes 66-67 */
  unsigned short MaxCombinedSectors;			/* Bytes 68-69 */
  unsigned char Latency;				/* Byte 70 */
  unsigned char :8;					/* Byte 71 */
  unsigned char SCSITimeout;				/* Byte 72 */
  unsigned char :8;					/* Byte 73 */
  unsigned short MinFreeLines;				/* Bytes 74-75 */
  unsigned int :32;					/* Bytes 76-79 */
  unsigned int :32;					/* Bytes 80-83 */
  unsigned char RebuildRateConstant;			/* Byte 84 */
  unsigned char :8;					/* Byte 85 */
  unsigned char :8;					/* Byte 86 */
  unsigned char :8;					/* Byte 87 */
  unsigned int :32;					/* Bytes 88-91 */
  unsigned int :32;					/* Bytes 92-95 */
  unsigned short PhysicalDriveBlockSize;		/* Bytes 96-97 */
  unsigned short LogicalDriveBlockSize;			/* Bytes 98-99 */
  unsigned short MaxBlocksPerCommand;			/* Bytes 100-101 */
  unsigned short BlockFactor;				/* Bytes 102-103 */
  unsigned short CacheLineSize;				/* Bytes 104-105 */
  struct {
    enum {
      DAC960_Narrow_8bit =			0x00,
      DAC960_Wide_16bit =			0x01,
      DAC960_Wide_32bit =			0x02
    } __attribute__ ((packed)) BusWidth:2;		/* Byte 106 Bits 0-1 */
    enum {
      DAC960_Fast =				0x00,
      DAC960_Ultra =				0x01,
      DAC960_Ultra2 =				0x02
    } __attribute__ ((packed)) BusSpeed:2;		/* Byte 106 Bits 2-3 */
    boolean Differential:1;				/* Byte 106 Bit 4 */
    unsigned char :3;					/* Byte 106 Bits 5-7 */
  } SCSICapability;
  unsigned char :8;					/* Byte 107 */
  unsigned int :32;					/* Bytes 108-111 */
  unsigned short FirmwareBuildNumber;			/* Bytes 112-113 */
  enum {
    DAC960_AEMI =				0x01,
    DAC960_OEM1 =				0x02,
    DAC960_OEM2 =				0x04,
    DAC960_OEM3 =				0x08,
    DAC960_Conner =				0x10,
    DAC960_SAFTE =				0x20
  } __attribute__ ((packed)) FaultManagementType;	/* Byte 114 */
  unsigned char :8;					/* Byte 115 */
  struct {
    boolean Clustering:1;				/* Byte 116 Bit 0 */
    boolean MylexOnlineRAIDExpansion:1;			/* Byte 116 Bit 1 */
    unsigned int :30;					/* Bytes 116-119 */
  } FirmwareFeatures;
  unsigned int :32;					/* Bytes 120-123 */
  unsigned int :32;					/* Bytes 124-127 */
}
DAC960_Enquiry2_T;


/*
  Define the Logical Drive State type.
*/

typedef enum
{
    DAC960_LogicalDrive_Online =		0x03,
    DAC960_LogicalDrive_Critical =		0x04,
    DAC960_LogicalDrive_Offline =		0xFF
}
__attribute__ ((packed))
DAC960_LogicalDriveState_T;


/*
  Define the Get Logical Drive Information reply structure.
*/

typedef struct DAC960_LogicalDriveInformation
{
  unsigned int LogicalDriveSize;			/* Bytes 0-3 */
  DAC960_LogicalDriveState_T LogicalDriveState;		/* Byte 4 */
  unsigned char RAIDLevel:7;				/* Byte 5 Bits 0-6 */
  boolean WriteBack:1;					/* Byte 5 Bit 7 */
  unsigned int :16;					/* Bytes 6-7 */
}
DAC960_LogicalDriveInformation_T;


/*
  Define the Perform Event Log Operation Types.
*/

typedef enum
{
  DAC960_GetEventLogEntry =			0x00
}
__attribute__ ((packed))
DAC960_PerformEventLogOpType_T;


/*
  Define the Get Event Log Entry reply structure.
*/

typedef struct DAC960_EventLogEntry
{
  unsigned char MessageType;				/* Byte 0 */
  unsigned char MessageLength;				/* Byte 1 */
  unsigned char TargetID:5;				/* Byte 2 Bits 0-4 */
  unsigned char Channel:3;				/* Byte 2 Bits 5-7 */
  unsigned char LogicalUnit:6;				/* Byte 3 Bits 0-5 */
  unsigned char :2;					/* Byte 3 Bits 6-7 */
  unsigned short SequenceNumber;			/* Bytes 4-5 */
  unsigned char ErrorCode:7;				/* Byte 6 Bits 0-6 */
  boolean Valid:1;					/* Byte 6 Bit 7 */
  unsigned char SegmentNumber;				/* Byte 7 */
  unsigned char SenseKey:4;				/* Byte 8 Bits 0-3 */
  unsigned char :1;					/* Byte 8 Bit 4 */
  boolean ILI:1;					/* Byte 8 Bit 5 */
  boolean EOM:1;					/* Byte 8 Bit 6 */
  boolean Filemark:1;					/* Byte 8 Bit 7 */
  unsigned char Information[4];				/* Bytes 9-12 */
  unsigned char AdditionalSenseLength;			/* Byte 13 */
  unsigned char CommandSpecificInformation[4];		/* Bytes 14-17 */
  unsigned char AdditionalSenseCode;			/* Byte 18 */
  unsigned char AdditionalSenseCodeQualifier;		/* Byte 19 */
  unsigned char Dummy[12];				/* Bytes 20-31 */
}
DAC960_EventLogEntry_T;


/*
  Define the Physical Device State type.
*/

typedef enum
{
    DAC960_Device_Dead =			0x00,
    DAC960_Device_WriteOnly =			0x02,
    DAC960_Device_Online =			0x03,
    DAC960_Device_Standby =			0x10
}
__attribute__ ((packed))
DAC960_PhysicalDeviceState_T;


/*
  Define the Get Device State reply structure.
*/

typedef struct DAC960_DeviceState
{
  boolean Present:1;					/* Byte 0 Bit 0 */
  unsigned char :7;					/* Byte 0 Bits 1-7 */
  enum {
    DAC960_OtherType =				0x00,
    DAC960_DiskType =				0x01,
    DAC960_SequentialType =			0x02,
    DAC960_CDROM_or_WORM_Type =			0x03
    } __attribute__ ((packed)) DeviceType:2;		/* Byte 1 Bits 0-1 */
  boolean :1;						/* Byte 1 Bit 2 */
  boolean Fast20:1;					/* Byte 1 Bit 3 */
  boolean Sync:1;					/* Byte 1 Bit 4 */
  boolean Fast:1;					/* Byte 1 Bit 5 */
  boolean Wide:1;					/* Byte 1 Bit 6 */
  boolean TaggedQueuingSupported:1;			/* Byte 1 Bit 7 */
  DAC960_PhysicalDeviceState_T DeviceState;		/* Byte 2 */
  unsigned char :8;					/* Byte 3 */
  unsigned char SynchronousMultiplier;			/* Byte 4 */
  unsigned char SynchronousOffset:5;			/* Byte 5 Bits 0-4 */
  unsigned char :3;					/* Byte 5 Bits 5-7 */
  unsigned long DiskSize __attribute__ ((packed));	/* Bytes 6-9 */
}
DAC960_DeviceState_T;


/*
  Define the Get Rebuild Progress reply structure.
*/

typedef struct DAC960_RebuildProgress
{
  unsigned int LogicalDriveNumber;			/* Bytes 0-3 */
  unsigned int LogicalDriveSize;			/* Bytes 4-7 */
  unsigned int RemainingBlocks;				/* Bytes 8-11 */
}
DAC960_RebuildProgress_T;


/*
  Define the Error Table Entry and Get Error Table reply structure.
*/

typedef struct DAC960_ErrorTableEntry
{
  unsigned char ParityErrorCount;			/* Byte 0 */
  unsigned char SoftErrorCount;				/* Byte 1 */
  unsigned char HardErrorCount;				/* Byte 2 */
  unsigned char MiscErrorCount;				/* Byte 3 */
}
DAC960_ErrorTableEntry_T;


/*
  Define the Get Error Table reply structure.
*/

typedef struct DAC960_ErrorTable
{
  DAC960_ErrorTableEntry_T
    ErrorTableEntries[DAC960_MaxChannels][DAC960_MaxTargets];
}
DAC960_ErrorTable_T;


/*
  Define the Config2 reply structure.
*/

typedef struct DAC960_Config2
{
  unsigned char :1;					/* Byte 0 Bit 0 */
  boolean ActiveNegationEnabled:1;			/* Byte 0 Bit 1 */
  unsigned char :5;					/* Byte 0 Bits 2-6 */
  boolean NoRescanIfResetReceivedDuringScan:1;		/* Byte 0 Bit 7 */
  boolean StorageWorksSupportEnabled:1;			/* Byte 1 Bit 0 */
  boolean HewlettPackardSupportEnabled:1;		/* Byte 1 Bit 1 */
  boolean NoDisconnectOnFirstCommand:1;			/* Byte 1 Bit 2 */
  unsigned char :2;					/* Byte 1 Bits 3-4 */
  boolean AEMI_ARM:1;					/* Byte 1 Bit 5 */
  boolean AEMI_OFM:1;					/* Byte 1 Bit 6 */
  unsigned char :1;					/* Byte 1 Bit 7 */
  enum {
    DAC960_OEMID_Mylex =			0x00,
    DAC960_OEMID_IBM =				0x08,
    DAC960_OEMID_HP =				0x0A,
    DAC960_OEMID_DEC =				0x0C,
    DAC960_OEMID_Siemens =			0x10,
    DAC960_OEMID_Intel =			0x12
  } __attribute__ ((packed)) OEMID;			/* Byte 2 */
  unsigned char OEMModelNumber;				/* Byte 3 */
  unsigned char PhysicalSector;				/* Byte 4 */
  unsigned char LogicalSector;				/* Byte 5 */
  unsigned char BlockFactor;				/* Byte 6 */
  boolean ReadAheadEnabled:1;				/* Byte 7 Bit 0 */
  boolean LowBIOSDelay:1;				/* Byte 7 Bit 1 */
  unsigned char :2;					/* Byte 7 Bits 2-3 */
  boolean ReassignRestrictedToOneSector:1;		/* Byte 7 Bit 4 */
  unsigned char :1;					/* Byte 7 Bit 5 */
  boolean ForceUnitAccessDuringWriteRecovery:1;		/* Byte 7 Bit 6 */
  boolean EnableLeftSymmetricRAID5Algorithm:1;		/* Byte 7 Bit 7 */
  unsigned char DefaultRebuildRate;			/* Byte 8 */
  unsigned char :8;					/* Byte 9 */
  unsigned char BlocksPerCacheLine;			/* Byte 10 */
  unsigned char BlocksPerStripe;			/* Byte 11 */
  struct {
    enum {
      DAC960_Async =				0x00,
      DAC960_Sync_8MHz =			0x01,
      DAC960_Sync_5MHz =			0x02,
      DAC960_Sync_10or20MHz =			0x03	/* Bits 0-1 */
    } __attribute__ ((packed)) Speed:2;
    boolean Force8Bit:1;				/* Bit 2 */
    boolean DisableFast20:1;				/* Bit 3 */
    unsigned char :3;					/* Bits 4-6 */
    boolean EnableTaggedQueuing:1;			/* Bit 7 */
  } __attribute__ ((packed)) ChannelParameters[6];	/* Bytes 12-17 */
  unsigned char SCSIInitiatorID;			/* Byte 18 */
  unsigned char :8;					/* Byte 19 */
  enum {
    DAC960_StartupMode_ControllerSpinUp =	0x00,
    DAC960_StartupMode_PowerOnSpinUp =		0x01
  } __attribute__ ((packed)) StartupMode;		/* Byte 20 */
  unsigned char SimultaneousDeviceSpinUpCount;		/* Byte 21 */
  unsigned char SecondsDelayBetweenSpinUps;		/* Byte 22 */
  unsigned char Reserved1[29];				/* Bytes 23-51 */
  boolean BIOSDisabled:1;				/* Byte 52 Bit 0 */
  boolean CDROMBootEnabled:1;				/* Byte 52 Bit 1 */
  unsigned char :3;					/* Byte 52 Bits 2-4 */
  enum {
    DAC960_Geometry_128_32 =			0x00,
    DAC960_Geometry_255_63 =			0x01,
    DAC960_Geometry_Reserved1 =			0x02,
    DAC960_Geometry_Reserved2 =			0x03
  } __attribute__ ((packed)) DriveGeometry:2;		/* Byte 52 Bits 5-6 */
  unsigned char :1;					/* Byte 52 Bit 7 */
  unsigned char Reserved2[9];				/* Bytes 53-61 */
  unsigned short Checksum;				/* Bytes 62-63 */
}
DAC960_Config2_T;


/*
  Define the DCDB request structure.
*/

typedef struct DAC960_DCDB
{
  unsigned char TargetID:4;				 /* Byte 0 Bits 0-3 */
  unsigned char Channel:4;				 /* Byte 0 Bits 4-7 */
  enum {
    DAC960_DCDB_NoDataTransfer = 0,
    DAC960_DCDB_DataTransferDeviceToSystem = 1,
    DAC960_DCDB_DataTransferSystemToDevice = 2,
    DAC960_DCDB_IllegalDataTransfer = 3
  } __attribute__ ((packed)) Direction:2;		 /* Byte 1 Bits 0-1 */
  boolean EarlyStatus:1;				 /* Byte 1 Bit 2 */
  unsigned char :1;					 /* Byte 1 Bit 3 */
  enum {
    DAC960_DCDB_Timeout_24_hours = 0,
    DAC960_DCDB_Timeout_10_seconds = 1,
    DAC960_DCDB_Timeout_60_seconds = 2,
    DAC960_DCDB_Timeout_10_minutes = 3
  } __attribute__ ((packed)) Timeout:2;			 /* Byte 1 Bits 4-5 */
  boolean NoAutomaticRequestSense:1;			 /* Byte 1 Bit 6 */
  boolean DisconnectPermitted:1;			 /* Byte 1 Bit 7 */
  unsigned short TransferLength;			 /* Bytes 2-3 */
  DAC960_BusAddress_T BusAddress;			 /* Bytes 4-7 */
  unsigned char CDBLength:4;				 /* Byte 8 Bits 0-3 */
  unsigned char TransferLengthHigh4:4;			 /* Byte 8 Bits 4-7 */
  unsigned char SenseLength;				 /* Byte 9 */
  unsigned char CDB[12];				 /* Bytes 10-21 */
  unsigned char SenseData[64];				 /* Bytes 22-85 */
  unsigned char Status;					 /* Byte 86 */
  unsigned char :8;					 /* Byte 87 */
}
DAC960_DCDB_T;


/*
  Define the SCSI INQUIRY Standard Data reply structure.
*/

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


/*
  Define the SCSI INQUIRY Unit Serial Number reply structure.
*/

typedef struct DAC960_SCSI_Inquiry_UnitSerialNumber
{
  unsigned char PeripheralDeviceType:5;			/* Byte 0 Bits 0-4 */
  unsigned char PeripheralQualifier:3;			/* Byte 0 Bits 5-7 */
  unsigned char PageCode;				/* Byte 1 */
  unsigned char :8;					/* Byte 2 */
  unsigned char PageLength;				/* Byte 3 */
  unsigned char ProductSerialNumber[28];		/* Bytes 4 - 31 */
}
DAC960_SCSI_Inquiry_UnitSerialNumber_T;


/*
  Define the Scatter/Gather List Type 1 32 Bit Address 32 Bit Byte Count
  structure.
*/

typedef struct DAC960_ScatterGatherSegment
{
  DAC960_BusAddress_T SegmentDataPointer;		/* Bytes 0-3 */
  DAC960_ByteCount_T SegmentByteCount;			/* Bytes 4-7 */
}
DAC960_ScatterGatherSegment_T;


/*
  Define the 13 Byte DAC960 Command Mailbox structure.  Bytes 13-15 are
  not used.  The Command Mailbox structure is padded to 16 bytes for
  efficient access.
*/

typedef union DAC960_CommandMailbox
{
  unsigned int Words[4];				/* Words 0-3 */
  unsigned char Bytes[16];				/* Bytes 0-15 */
  struct {
    DAC960_CommandOpcode_T CommandOpcode;		/* Byte 0 */
    DAC960_CommandIdentifier_T CommandIdentifier;	/* Byte 1 */
    unsigned char Dummy[14];				/* Bytes 2-15 */
  } __attribute__ ((packed)) Common;
  struct {
    DAC960_CommandOpcode_T CommandOpcode;		/* Byte 0 */
    DAC960_CommandIdentifier_T CommandIdentifier;	/* Byte 1 */
    unsigned char Dummy1[6];				/* Bytes 2-7 */
    DAC960_BusAddress_T BusAddress;			/* Bytes 8-11 */
    unsigned char Dummy2[4];				/* Bytes 12-15 */
  } __attribute__ ((packed)) Type3;
  struct {
    DAC960_CommandOpcode_T CommandOpcode;		/* Byte 0 */
    DAC960_CommandIdentifier_T CommandIdentifier;	/* Byte 1 */
    unsigned char Dummy1[5];				/* Bytes 2-6 */
    unsigned char LogicalDriveNumber:6;			/* Byte 7 Bits 0-6 */
    boolean AutoRestore:1;				/* Byte 7 Bit 7 */
    unsigned char Dummy2[8];				/* Bytes 8-15 */
  } __attribute__ ((packed)) Type3C;
  struct {
    DAC960_CommandOpcode_T CommandOpcode;		/* Byte 0 */
    DAC960_CommandIdentifier_T CommandIdentifier;	/* Byte 1 */
    unsigned char Channel;				/* Byte 2 */
    unsigned char TargetID;				/* Byte 3 */
    DAC960_PhysicalDeviceState_T DeviceState:5;		/* Byte 4 Bits 0-4 */
    unsigned char Modifier:3;				/* Byte 4 Bits 5-7 */
    unsigned char Dummy1[3];				/* Bytes 5-7 */
    DAC960_BusAddress_T BusAddress;			/* Bytes 8-11 */
    unsigned char Dummy2[4];				/* Bytes 12-15 */
  } __attribute__ ((packed)) Type3D;
  struct {
    DAC960_CommandOpcode_T CommandOpcode;		/* Byte 0 */
    DAC960_CommandIdentifier_T CommandIdentifier;	/* Byte 1 */
    DAC960_PerformEventLogOpType_T OperationType;	/* Byte 2 */
    unsigned char OperationQualifier;			/* Byte 3 */
    unsigned short SequenceNumber;			/* Bytes 4-5 */
    unsigned char Dummy1[2];				/* Bytes 6-7 */
    DAC960_BusAddress_T BusAddress;			/* Bytes 8-11 */
    unsigned char Dummy2[4];				/* Bytes 12-15 */
  } __attribute__ ((packed)) Type3E;
  struct {
    DAC960_CommandOpcode_T CommandOpcode;		/* Byte 0 */
    DAC960_CommandIdentifier_T CommandIdentifier;	/* Byte 1 */
    unsigned char Dummy1[2];				/* Bytes 2-3 */
    unsigned char RebuildRateConstant;			/* Byte 4 */
    unsigned char Dummy2[3];				/* Bytes 5-7 */
    DAC960_BusAddress_T BusAddress;			/* Bytes 8-11 */
    unsigned char Dummy3[4];				/* Bytes 12-15 */
  } __attribute__ ((packed)) Type3R;
  struct {
    DAC960_CommandOpcode_T CommandOpcode;		/* Byte 0 */
    DAC960_CommandIdentifier_T CommandIdentifier;	/* Byte 1 */
    unsigned short TransferLength;			/* Bytes 2-3 */
    unsigned int LogicalBlockAddress;			/* Bytes 4-7 */
    DAC960_BusAddress_T BusAddress;			/* Bytes 8-11 */
    unsigned char LogicalDriveNumber;			/* Byte 12 */
    unsigned char Dummy[3];				/* Bytes 13-15 */
  } __attribute__ ((packed)) Type4;
  struct {
    DAC960_CommandOpcode_T CommandOpcode;		/* Byte 0 */
    DAC960_CommandIdentifier_T CommandIdentifier;	/* Byte 1 */
    struct {
      unsigned short TransferLength:11;			/* Bytes 2-3 */
      unsigned char LogicalDriveNumber:5;		/* Byte 3 Bits 3-7 */
    } __attribute__ ((packed)) LD;
    unsigned int LogicalBlockAddress;			/* Bytes 4-7 */
    DAC960_BusAddress_T BusAddress;			/* Bytes 8-11 */
    unsigned char ScatterGatherCount:6;			/* Byte 12 Bits 0-5 */
    enum {
      DAC960_ScatterGather_32BitAddress_32BitByteCount =	0x0,
      DAC960_ScatterGather_32BitAddress_16BitByteCount =	0x1,
      DAC960_ScatterGather_32BitByteCount_32BitAddress =	0x2,
      DAC960_ScatterGather_16BitByteCount_32BitAddress =	0x3
    } __attribute__ ((packed)) ScatterGatherType:2;	/* Byte 12 Bits 6-7 */
    unsigned char Dummy[3];				/* Bytes 13-15 */
  } __attribute__ ((packed)) Type5;
  struct {
    DAC960_CommandOpcode_T CommandOpcode;		/* Byte 0 */
    DAC960_CommandIdentifier_T CommandIdentifier;	/* Byte 1 */
    unsigned char CommandOpcode2;			/* Byte 2 */
    unsigned char :8;					/* Byte 3 */
    DAC960_BusAddress_T CommandMailboxesBusAddress;	/* Bytes 4-7 */
    DAC960_BusAddress_T StatusMailboxesBusAddress;	/* Bytes 8-11 */
    unsigned char Dummy[4];				/* Bytes 12-15 */
  } __attribute__ ((packed)) TypeX;
}
DAC960_CommandMailbox_T;


/*
  Define the DAC960 Driver IOCTL requests.
*/

#define DAC960_IOCTL_GET_CONTROLLER_COUNT	0xDAC001
#define DAC960_IOCTL_GET_CONTROLLER_INFO	0xDAC002
#define DAC960_IOCTL_EXECUTE_COMMAND		0xDAC003


/*
  Define the DAC960_IOCTL_GET_CONTROLLER_INFO reply structure.
*/

typedef struct DAC960_ControllerInfo
{
  unsigned char ControllerNumber;
  unsigned char PCI_Bus;
  unsigned char PCI_Device;
  unsigned char PCI_Function;
  unsigned char IRQ_Channel;
  unsigned char Channels;
  DAC960_PCI_Address_T PCI_Address;
  unsigned char ModelName[16];
  unsigned char FirmwareVersion[16];
}
DAC960_ControllerInfo_T;


/*
  Define the User Mode DAC960_IOCTL_EXECUTE_COMMAND request structure.
*/

typedef struct DAC960_UserCommand
{
  unsigned char ControllerNumber;
  DAC960_CommandMailbox_T CommandMailbox;
  int DataTransferLength;
  void *DataTransferBuffer;
  DAC960_DCDB_T *DCDB;
}
DAC960_UserCommand_T;


/*
  Define the Kernel Mode DAC960_IOCTL_EXECUTE_COMMAND request structure.
*/

typedef struct DAC960_KernelCommand
{
  unsigned char ControllerNumber;
  DAC960_CommandMailbox_T CommandMailbox;
  int DataTransferLength;
  void *DataTransferBuffer;
  DAC960_DCDB_T *DCDB;
  DAC960_CommandStatus_T CommandStatus;
  void (*CompletionFunction)(struct DAC960_KernelCommand *);
  void *CompletionData;
}
DAC960_KernelCommand_T;


/*
  Import the Kernel Mode IOCTL interface.
*/

extern int DAC960_KernelIOCTL(unsigned int Request, void *Argument);


/*
  Virtual_to_Bus maps from Kernel Virtual Addresses to PCI Bus Addresses.
*/

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


/*
  Bus_to_Virtual maps from PCI Bus Addresses to Kernel Virtual Addresses.
*/

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


/*
  DAC960_DriverVersion protects the private portion of this file.
*/

#ifdef DAC960_DriverVersion


/*
  Define the maximum Driver Queue Depth and Controller Queue Depth supported
  by any DAC960 model.
*/

#define DAC960_MaxDriverQueueDepth		127
#define DAC960_MaxControllerQueueDepth		128


/*
  Define the maximum number of Scatter/Gather Segments supported by any
  DAC960 model.
*/

#define DAC960_MaxScatterGatherSegments		33


/*
  Define the number of Command Mailboxes and Status Mailboxes used by the
  Memory Mailbox Interface.
*/

#define DAC960_CommandMailboxCount		256
#define DAC960_StatusMailboxCount		1024


/*
  Define the DAC960 Controller Monitoring Timer Interval.
*/

#define DAC960_MonitoringTimerInterval		(10 * HZ)


/*
  Define the DAC960 Controller Secondary Monitoring Interval.
*/

#define DAC960_SecondaryMonitoringInterval	(60 * HZ)


/*
  Define the DAC960 Controller Progress Reporting Interval.
*/

#define DAC960_ProgressReportingInterval	(60 * HZ)


/*
  Define the maximum number of Partitions allowed for each Logical Drive.
*/

#define DAC960_MaxPartitions			8
#define DAC960_MaxPartitionsBits		3


/*
  Define macros to extract the Controller Number, Logical Drive Number, and
  Partition Number from a Kernel Device, and to construct a Major Number, Minor
  Number, and Kernel Device from the Controller Number, Logical Drive Number,
  and Partition Number.  There is one Major Number assigned to each Controller.
  The associated Minor Number is divided into the Logical Drive Number and
  Partition Number.
*/

#define DAC960_ControllerNumber(Device) \
  (MAJOR(Device) - DAC960_MAJOR)

#define DAC960_LogicalDriveNumber(Device) \
  (MINOR(Device) >> DAC960_MaxPartitionsBits)

#define DAC960_PartitionNumber(Device) \
  (MINOR(Device) & (DAC960_MaxPartitions - 1))

#define DAC960_MajorNumber(ControllerNumber) \
  (DAC960_MAJOR + (ControllerNumber))

#define DAC960_MinorNumber(LogicalDriveNumber, PartitionNumber) \
   (((LogicalDriveNumber) << DAC960_MaxPartitionsBits) | (PartitionNumber))

#define DAC960_MinorCount			(DAC960_MaxLogicalDrives \
						 * DAC960_MaxPartitions)

#define DAC960_KernelDevice(ControllerNumber,				       \
			    LogicalDriveNumber,				       \
			    PartitionNumber)				       \
   MKDEV(DAC960_MajorNumber(ControllerNumber),				       \
	 DAC960_MinorNumber(LogicalDriveNumber, PartitionNumber))


/*
  Define the DAC960 Controller fixed Block Size and Block Size Bits.
*/

#define DAC960_BlockSize			512
#define DAC960_BlockSizeBits			9


/*
  Define the Controller Line Buffer, Status Buffer, Rebuild Progress,
  and User Message Sizes.
*/

#define DAC960_LineBufferSize			100
#define DAC960_StatusBufferSize			16384
#define DAC960_RebuildProgressSize		200
#define DAC960_UserMessageSize			200


/*
  Define the types of DAC960 Controllers that are supported.
*/

typedef enum
{
  DAC960_V5_Controller =			1,	/* DAC1164P */
  DAC960_V4_Controller =			2,	/* DAC960PTL/PJ/PG */
  DAC960_V3_Controller =			3	/* DAC960PU/PD/PL */
}
DAC960_ControllerType_T;


/*
  Define the Driver Message Levels.
*/

typedef enum DAC960_MessageLevel
{
  DAC960_AnnounceLevel =			0,
  DAC960_InfoLevel =				1,
  DAC960_NoticeLevel =				2,
  DAC960_WarningLevel =				3,
  DAC960_ErrorLevel =				4,
  DAC960_ProgressLevel =			5,
  DAC960_CriticalLevel =			6,
  DAC960_UserCriticalLevel =			7
}
DAC960_MessageLevel_T;

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


/*
  Define Driver Message macros.
*/

#define DAC960_Announce(Format, Arguments...) \
  DAC960_Message(DAC960_AnnounceLevel, Format, ##Arguments)

#define DAC960_Info(Format, Arguments...) \
  DAC960_Message(DAC960_InfoLevel, Format, ##Arguments)

#define DAC960_Notice(Format, Arguments...) \
  DAC960_Message(DAC960_NoticeLevel, Format, ##Arguments)

#define DAC960_Warning(Format, Arguments...) \
  DAC960_Message(DAC960_WarningLevel, Format, ##Arguments)

#define DAC960_Error(Format, Arguments...) \
  DAC960_Message(DAC960_ErrorLevel, Format, ##Arguments)

#define DAC960_Progress(Format, Arguments...) \
  DAC960_Message(DAC960_ProgressLevel, Format, ##Arguments)

#define DAC960_Critical(Format, Arguments...) \
  DAC960_Message(DAC960_CriticalLevel, Format, ##Arguments)

#define DAC960_UserCritical(Format, Arguments...) \
  DAC960_Message(DAC960_UserCriticalLevel, Format, ##Arguments)


/*
  Define types for some of the structures that interface with the rest
  of the Linux Kernel and I/O Subsystem.
*/

typedef struct buffer_head BufferHeader_T;
typedef struct file File_T;
typedef struct file_operations FileOperations_T;
typedef struct gendisk GenericDiskInfo_T;
typedef struct hd_geometry DiskGeometry_T;
typedef struct hd_struct DiskPartition_T;
typedef struct inode Inode_T;
typedef struct inode_operations InodeOperations_T;
typedef kdev_t KernelDevice_T;
typedef struct notifier_block NotifierBlock_T;
typedef struct pci_dev PCI_Device_T;
typedef struct proc_dir_entry PROC_DirectoryEntry_T;
typedef unsigned long ProcessorFlags_T;
typedef struct pt_regs Registers_T;
typedef struct request IO_Request_T;
typedef struct semaphore Semaphore_T;
typedef struct super_block SuperBlock_T;
typedef struct timer_list Timer_T;
typedef wait_queue_head_t WaitQueue_T;


/*
  Define the DAC960 Controller Status Mailbox structure.
*/

typedef union DAC960_StatusMailbox
{
  unsigned int Word;					/* Bytes 0-3 */
  struct {
    DAC960_CommandIdentifier_T CommandIdentifier;	/* Byte 0 */
    unsigned char :7;					/* Byte 1 Bits 0-6 */
    boolean Valid:1;					/* Byte 1 Bit 7 */
    DAC960_CommandStatus_T CommandStatus;		/* Bytes 2-3 */
  } Fields;
}
DAC960_StatusMailbox_T;


/*
  Define the DAC960 Driver Command Types.
*/

typedef enum
{
  DAC960_ReadCommand =				1,
  DAC960_WriteCommand =				2,
  DAC960_ReadRetryCommand =			3,
  DAC960_WriteRetryCommand =			4,
  DAC960_MonitoringCommand =			5,
  DAC960_ImmediateCommand =			6,
  DAC960_QueuedCommand =			7
}
DAC960_CommandType_T;


/*
  Define the DAC960 Driver Command structure.
*/

typedef struct DAC960_Command
{
  DAC960_CommandType_T CommandType;
  DAC960_CommandMailbox_T CommandMailbox;
  DAC960_CommandStatus_T CommandStatus;
  struct DAC960_Controller *Controller;
  struct DAC960_Command *Next;
  Semaphore_T *Semaphore;
  unsigned int LogicalDriveNumber;
  unsigned int BlockNumber;
  unsigned int BlockCount;
  unsigned int SegmentCount;
  BufferHeader_T *BufferHeader;
  DAC960_KernelCommand_T *KernelCommand;
  DAC960_ScatterGatherSegment_T
    ScatterGatherList[DAC960_MaxScatterGatherSegments];
}
DAC960_Command_T;


/*
  Define the DAC960 Driver Controller structure.
*/

typedef struct DAC960_Controller
{
  void *BaseAddress;
  void *MemoryMappedAddress;
  DAC960_ControllerType_T ControllerType;
  DAC960_IO_Address_T IO_Address;
  DAC960_PCI_Address_T PCI_Address;
  unsigned char ControllerNumber;
  unsigned char ControllerName[4];
  unsigned char ModelName[12];
  unsigned char FullModelName[18];
  unsigned char FirmwareVersion[14];
  unsigned char Bus;
  unsigned char Device;
  unsigned char Function;
  unsigned char IRQ_Channel;
  unsigned char Channels;
  unsigned char MemorySize;
  unsigned char LogicalDriveCount;
  unsigned char GeometryTranslationHeads;
  unsigned char GeometryTranslationSectors;
  unsigned short ControllerQueueDepth;
  unsigned short DriverQueueDepth;
  unsigned short MaxBlocksPerCommand;
  unsigned short MaxScatterGatherSegments;
  unsigned short StripeSize;
  unsigned short SegmentSize;
  unsigned short NewEventLogSequenceNumber;
  unsigned short OldEventLogSequenceNumber;
  unsigned short InitialStatusLength;
  unsigned short CurrentStatusLength;
  unsigned short UserStatusLength;
  unsigned short RebuildProgressLength;
  unsigned int ControllerUsageCount;
  unsigned int EnquiryIndex;
  unsigned int LogicalDriveInformationIndex;
  unsigned int ErrorTableIndex;
  unsigned int DeviceStateIndex;
  unsigned int DeviceStateChannel;
  unsigned int DeviceStateTargetID;
  unsigned long MonitoringTimerCount;
  unsigned long SecondaryMonitoringTime;
  unsigned long LastProgressReportTime;
  unsigned long LastCurrentStatusTime;
  boolean DualModeMemoryMailboxInterface;
  boolean SAFTE_EnclosureManagementEnabled;
  boolean ControllerInitialized;
  boolean MonitoringCommandDeferred;
  boolean NeedLogicalDriveInformation;
  boolean NeedErrorTableInformation;
  boolean NeedDeviceStateInformation;
  boolean NeedDeviceInquiryInformation;
  boolean NeedDeviceSerialNumberInformation;
  boolean NeedRebuildProgress;
  boolean NeedConsistencyCheckProgress;
  boolean EphemeralProgressMessage;
  Timer_T MonitoringTimer;
  GenericDiskInfo_T GenericDiskInfo;
  DAC960_Command_T *FreeCommands;
  DAC960_CommandMailbox_T *FirstCommandMailbox;
  DAC960_CommandMailbox_T *LastCommandMailbox;
  DAC960_CommandMailbox_T *NextCommandMailbox;
  DAC960_CommandMailbox_T *PreviousCommandMailbox1;
  DAC960_CommandMailbox_T *PreviousCommandMailbox2;
  DAC960_StatusMailbox_T *FirstStatusMailbox;
  DAC960_StatusMailbox_T *LastStatusMailbox;
  DAC960_StatusMailbox_T *NextStatusMailbox;
  WaitQueue_T CommandWaitQueue;
  DAC960_DCDB_T MonitoringDCDB;
  DAC960_Enquiry_T Enquiry[2];
  DAC960_ErrorTable_T ErrorTable[2];
  DAC960_EventLogEntry_T EventLogEntry;
  DAC960_RebuildProgress_T RebuildProgress;
  DAC960_CommandStatus_T LastRebuildStatus;
  DAC960_LogicalDriveInformation_T
    LogicalDriveInformation[2][DAC960_MaxLogicalDrives];
  DAC960_LogicalDriveState_T LogicalDriveInitialState[DAC960_MaxLogicalDrives];
  DAC960_DeviceState_T DeviceState[2][DAC960_MaxChannels][DAC960_MaxTargets];
  DAC960_Command_T Commands[DAC960_MaxDriverQueueDepth];
  DAC960_SCSI_Inquiry_T
    InquiryStandardData[DAC960_MaxChannels][DAC960_MaxTargets];
  DAC960_SCSI_Inquiry_UnitSerialNumber_T
    InquiryUnitSerialNumber[DAC960_MaxChannels][DAC960_MaxTargets];
  DiskPartition_T DiskPartitions[DAC960_MinorCount];
  int LogicalDriveUsageCount[DAC960_MaxLogicalDrives];
  int PartitionSizes[DAC960_MinorCount];
  int BlockSizes[DAC960_MinorCount];
  int MaxSectorsPerRequest[DAC960_MinorCount];
  int MaxSegmentsPerRequest[DAC960_MinorCount];
  int DeviceResetCount[DAC960_MaxChannels][DAC960_MaxTargets];
  boolean DirectCommandActive[DAC960_MaxChannels][DAC960_MaxTargets];
  char InitialStatusBuffer[DAC960_StatusBufferSize];
  char CurrentStatusBuffer[DAC960_StatusBufferSize];
  char UserStatusBuffer[DAC960_UserMessageSize];
  char RebuildProgressBuffer[DAC960_RebuildProgressSize];
}
DAC960_Controller_T;


/*
  DAC960_AcquireControllerLock acquires exclusive access to Controller.
*/

static inline
void DAC960_AcquireControllerLock(DAC960_Controller_T *Controller,
				  ProcessorFlags_T *ProcessorFlags)
{
  spin_lock_irqsave(&io_request_lock, *ProcessorFlags);
}


/*
  DAC960_ReleaseControllerLock releases exclusive access to Controller.
*/

static inline
void DAC960_ReleaseControllerLock(DAC960_Controller_T *Controller,
				  ProcessorFlags_T *ProcessorFlags)
{
  spin_unlock_irqrestore(&io_request_lock, *ProcessorFlags);
}


/*
  DAC960_AcquireControllerLockRF acquires exclusive access to Controller,
  but is only called from the request function with the io_request_lock held.
*/

static inline
void DAC960_AcquireControllerLockRF(DAC960_Controller_T *Controller,
				    ProcessorFlags_T *ProcessorFlags)
{
}


/*
  DAC960_ReleaseControllerLockRF releases exclusive access to Controller,
  but is only called from the request function with the io_request_lock held.
*/

static inline
void DAC960_ReleaseControllerLockRF(DAC960_Controller_T *Controller,
				    ProcessorFlags_T *ProcessorFlags)
{
}


/*
  DAC960_AcquireControllerLockIH acquires exclusive access to Controller,
  but is only called from the interrupt handler.
*/

static inline
void DAC960_AcquireControllerLockIH(DAC960_Controller_T *Controller,
				    ProcessorFlags_T *ProcessorFlags)
{
  spin_lock_irqsave(&io_request_lock, *ProcessorFlags);
}


/*
  DAC960_ReleaseControllerLockIH releases exclusive access to Controller,
  but is only called from the interrupt handler.
*/

static inline
void DAC960_ReleaseControllerLockIH(DAC960_Controller_T *Controller,
				    ProcessorFlags_T *ProcessorFlags)
{
  spin_unlock_irqrestore(&io_request_lock, *ProcessorFlags);
}


/*
  Define the DAC960 V5 Controller Interface Register Offsets.
*/

#define DAC960_V5_RegisterWindowSize		0x80

typedef enum
{
  DAC960_V5_InboundDoorBellRegisterOffset =	0x60,
  DAC960_V5_OutboundDoorBellRegisterOffset =	0x61,
  DAC960_V5_InterruptMaskRegisterOffset =	0x34,
  DAC960_V5_CommandOpcodeRegisterOffset =	0x50,
  DAC960_V5_CommandIdentifierRegisterOffset =	0x51,
  DAC960_V5_MailboxRegister2Offset =		0x52,
  DAC960_V5_MailboxRegister3Offset =		0x53,
  DAC960_V5_MailboxRegister4Offset =		0x54,
  DAC960_V5_MailboxRegister5Offset =		0x55,
  DAC960_V5_MailboxRegister6Offset =		0x56,
  DAC960_V5_MailboxRegister7Offset =		0x57,
  DAC960_V5_MailboxRegister8Offset =		0x58,
  DAC960_V5_MailboxRegister9Offset =		0x59,
  DAC960_V5_MailboxRegister10Offset =		0x5A,
  DAC960_V5_MailboxRegister11Offset =		0x5B,
  DAC960_V5_MailboxRegister12Offset =		0x5C,
  DAC960_V5_StatusCommandIdentifierRegOffset =	0x5D,
  DAC960_V5_StatusRegisterOffset =		0x5E
}
DAC960_V5_RegisterOffsets_T;


/*
  Define the structure of the DAC960 V5 Inbound Door Bell Register.
*/

typedef union DAC960_V5_InboundDoorBellRegister
{
  unsigned char All;
  struct {
    boolean HardwareMailboxNewCommand:1;		/* Bit 0 */
    boolean AcknowledgeHardwareMailboxStatus:1;		/* Bit 1 */
    boolean GenerateInterrupt:1;			/* Bit 2 */
    boolean ControllerReset:1;				/* Bit 3 */
    boolean MemoryMailboxNewCommand:1;			/* Bit 4 */
    unsigned char :3;					/* Bits 5-7 */
  } Write;
  struct {
    boolean HardwareMailboxEmpty:1;			/* Bit 0 */
    unsigned char :7;					/* Bits 1-7 */
  } Read;
}
DAC960_V5_InboundDoorBellRegister_T;


/*
  Define the structure of the DAC960 V5 Outbound Door Bell Register.
*/

typedef union DAC960_V5_OutboundDoorBellRegister
{
  unsigned char All;
  struct {
    boolean AcknowledgeHardwareMailboxInterrupt:1;	/* Bit 0 */
    boolean AcknowledgeMemoryMailboxInterrupt:1;	/* Bit 1 */
    unsigned char :6;					/* Bits 2-7 */
  } Write;
  struct {
    boolean HardwareMailboxStatusAvailable:1;		/* Bit 0 */
    boolean MemoryMailboxStatusAvailable:1;		/* Bit 1 */
    unsigned char :6;					/* Bits 2-7 */
  } Read;
}
DAC960_V5_OutboundDoorBellRegister_T;


/*
  Define the structure of the DAC960 V5 Interrupt Mask Register.
*/

typedef union DAC960_V5_InterruptMaskRegister
{
  unsigned char All;
  struct {
    unsigned char :2;					/* Bits 0-1 */
    boolean DisableInterrupts:1;			/* Bit 2 */
    unsigned char :5;					/* Bits 3-7 */
  } Bits;
}
DAC960_V5_InterruptMaskRegister_T;


/*
  Define inline functions to provide an abstraction for reading and writing the
  DAC960 V5 Controller Interface Registers.
*/

static inline
void DAC960_V5_HardwareMailboxNewCommand(void *ControllerBaseAddress)
{
  DAC960_V5_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All = 0;
  InboundDoorBellRegister.Write.HardwareMailboxNewCommand = true;
  writeb(InboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V5_InboundDoorBellRegisterOffset);
}

static inline
void DAC960_V5_AcknowledgeHardwareMailboxStatus(void *ControllerBaseAddress)
{
  DAC960_V5_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All = 0;
  InboundDoorBellRegister.Write.AcknowledgeHardwareMailboxStatus = true;
  writeb(InboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V5_InboundDoorBellRegisterOffset);
}

static inline
void DAC960_V5_GenerateInterrupt(void *ControllerBaseAddress)
{
  DAC960_V5_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All = 0;
  InboundDoorBellRegister.Write.GenerateInterrupt = true;
  writeb(InboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V5_InboundDoorBellRegisterOffset);
}

static inline
void DAC960_V5_ControllerReset(void *ControllerBaseAddress)
{
  DAC960_V5_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All = 0;
  InboundDoorBellRegister.Write.ControllerReset = true;
  writeb(InboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V5_InboundDoorBellRegisterOffset);
}

static inline
void DAC960_V5_MemoryMailboxNewCommand(void *ControllerBaseAddress)
{
  DAC960_V5_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All = 0;
  InboundDoorBellRegister.Write.MemoryMailboxNewCommand = true;
  writeb(InboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V5_InboundDoorBellRegisterOffset);
}

static inline
boolean DAC960_V5_HardwareMailboxEmptyP(void *ControllerBaseAddress)
{
  DAC960_V5_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All =
    readb(ControllerBaseAddress + DAC960_V5_InboundDoorBellRegisterOffset);
  return InboundDoorBellRegister.Read.HardwareMailboxEmpty;
}

static inline
void DAC960_V5_AcknowledgeHardwareMailboxInterrupt(void *ControllerBaseAddress)
{
  DAC960_V5_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  OutboundDoorBellRegister.All = 0;
  OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  writeb(OutboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V5_OutboundDoorBellRegisterOffset);
}

static inline
void DAC960_V5_AcknowledgeMemoryMailboxInterrupt(void *ControllerBaseAddress)
{
  DAC960_V5_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  OutboundDoorBellRegister.All = 0;
  OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  writeb(OutboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V5_OutboundDoorBellRegisterOffset);
}

static inline
void DAC960_V5_AcknowledgeInterrupt(void *ControllerBaseAddress)
{
  DAC960_V5_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  OutboundDoorBellRegister.All = 0;
  OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  writeb(OutboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V5_OutboundDoorBellRegisterOffset);
}

static inline
boolean DAC960_V5_HardwareMailboxStatusAvailableP(void *ControllerBaseAddress)
{
  DAC960_V5_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  OutboundDoorBellRegister.All =
    readb(ControllerBaseAddress + DAC960_V5_OutboundDoorBellRegisterOffset);
  return OutboundDoorBellRegister.Read.HardwareMailboxStatusAvailable;
}

static inline
boolean DAC960_V5_MemoryMailboxStatusAvailableP(void *ControllerBaseAddress)
{
  DAC960_V5_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  OutboundDoorBellRegister.All =
    readb(ControllerBaseAddress + DAC960_V5_OutboundDoorBellRegisterOffset);
  return OutboundDoorBellRegister.Read.MemoryMailboxStatusAvailable;
}

static inline
void DAC960_V5_EnableInterrupts(void *ControllerBaseAddress)
{
  DAC960_V5_InterruptMaskRegister_T InterruptMaskRegister;
  InterruptMaskRegister.All = 0;
  InterruptMaskRegister.Bits.DisableInterrupts = false;
  writeb(InterruptMaskRegister.All,
	 ControllerBaseAddress + DAC960_V5_InterruptMaskRegisterOffset);
}

static inline
void DAC960_V5_DisableInterrupts(void *ControllerBaseAddress)
{
  DAC960_V5_InterruptMaskRegister_T InterruptMaskRegister;
  InterruptMaskRegister.All = 0;
  InterruptMaskRegister.Bits.DisableInterrupts = true;
  writeb(InterruptMaskRegister.All,
	 ControllerBaseAddress + DAC960_V5_InterruptMaskRegisterOffset);
}

static inline
boolean DAC960_V5_InterruptsEnabledP(void *ControllerBaseAddress)
{
  DAC960_V5_InterruptMaskRegister_T InterruptMaskRegister;
  InterruptMaskRegister.All =
    readb(ControllerBaseAddress + DAC960_V5_InterruptMaskRegisterOffset);
  return !InterruptMaskRegister.Bits.DisableInterrupts;
}

static inline
void DAC960_V5_WriteCommandMailbox(DAC960_CommandMailbox_T *NextCommandMailbox,
				   DAC960_CommandMailbox_T *CommandMailbox)
{
  NextCommandMailbox->Words[1] = CommandMailbox->Words[1];
  NextCommandMailbox->Words[2] = CommandMailbox->Words[2];
  NextCommandMailbox->Words[3] = CommandMailbox->Words[3];
  NextCommandMailbox->Words[0] = CommandMailbox->Words[0];
}

static inline
void DAC960_V5_WriteHardwareMailbox(void *ControllerBaseAddress,
				    DAC960_CommandMailbox_T *CommandMailbox)
{
  writel(CommandMailbox->Words[0],
	 ControllerBaseAddress + DAC960_V5_CommandOpcodeRegisterOffset);
  writel(CommandMailbox->Words[1],
	 ControllerBaseAddress + DAC960_V5_MailboxRegister4Offset);
  writel(CommandMailbox->Words[2],
	 ControllerBaseAddress + DAC960_V5_MailboxRegister8Offset);
  writeb(CommandMailbox->Bytes[12],
	 ControllerBaseAddress + DAC960_V5_MailboxRegister12Offset);
}

static inline DAC960_CommandIdentifier_T
DAC960_V5_ReadStatusCommandIdentifier(void *ControllerBaseAddress)
{
  return readb(ControllerBaseAddress
	       + DAC960_V5_StatusCommandIdentifierRegOffset);
}

static inline DAC960_CommandStatus_T
DAC960_V5_ReadStatusRegister(void *ControllerBaseAddress)
{
  return readw(ControllerBaseAddress + DAC960_V5_StatusRegisterOffset);
}

static inline
void DAC960_V5_SaveMemoryMailboxInfo(DAC960_Controller_T *Controller)
{
  void *ControllerBaseAddress = Controller->BaseAddress;
  writel(0x743C485E,
	 ControllerBaseAddress + DAC960_V5_CommandOpcodeRegisterOffset);
  writel((unsigned long) Controller->FirstCommandMailbox,
	 ControllerBaseAddress + DAC960_V5_MailboxRegister4Offset);
  writew(Controller->NextCommandMailbox - Controller->FirstCommandMailbox,
	 ControllerBaseAddress + DAC960_V5_MailboxRegister8Offset);
  writew(Controller->NextStatusMailbox - Controller->FirstStatusMailbox,
	 ControllerBaseAddress + DAC960_V5_MailboxRegister10Offset);
}

static inline
void DAC960_V5_RestoreMemoryMailboxInfo(DAC960_Controller_T *Controller,
					void **MemoryMailboxAddress,
					short *NextCommandMailboxIndex,
					short *NextStatusMailboxIndex)
{
  void *ControllerBaseAddress = Controller->BaseAddress;
  if (readl(ControllerBaseAddress
	    + DAC960_V5_CommandOpcodeRegisterOffset) != 0x743C485E)
    return;
  *MemoryMailboxAddress =
    (void *) readl(ControllerBaseAddress + DAC960_V5_MailboxRegister4Offset);
  *NextCommandMailboxIndex =
    readw(ControllerBaseAddress + DAC960_V5_MailboxRegister8Offset);
  *NextStatusMailboxIndex =
    readw(ControllerBaseAddress + DAC960_V5_MailboxRegister10Offset);
}


/*
  Define the DAC960 V4 Controller Interface Register Offsets.
*/

#define DAC960_V4_RegisterWindowSize		0x2000

typedef enum
{
  DAC960_V4_InboundDoorBellRegisterOffset =	0x0020,
  DAC960_V4_OutboundDoorBellRegisterOffset =	0x002C,
  DAC960_V4_InterruptMaskRegisterOffset =	0x0034,
  DAC960_V4_CommandOpcodeRegisterOffset =	0x1000,
  DAC960_V4_CommandIdentifierRegisterOffset =	0x1001,
  DAC960_V4_MailboxRegister2Offset =		0x1002,
  DAC960_V4_MailboxRegister3Offset =		0x1003,
  DAC960_V4_MailboxRegister4Offset =		0x1004,
  DAC960_V4_MailboxRegister5Offset =		0x1005,
  DAC960_V4_MailboxRegister6Offset =		0x1006,
  DAC960_V4_MailboxRegister7Offset =		0x1007,
  DAC960_V4_MailboxRegister8Offset =		0x1008,
  DAC960_V4_MailboxRegister9Offset =		0x1009,
  DAC960_V4_MailboxRegister10Offset =		0x100A,
  DAC960_V4_MailboxRegister11Offset =		0x100B,
  DAC960_V4_MailboxRegister12Offset =		0x100C,
  DAC960_V4_StatusCommandIdentifierRegOffset =	0x1018,
  DAC960_V4_StatusRegisterOffset =		0x101A
}
DAC960_V4_RegisterOffsets_T;


/*
  Define the structure of the DAC960 V4 Inbound Door Bell Register.
*/

typedef union DAC960_V4_InboundDoorBellRegister
{
  unsigned int All;
  struct {
    boolean HardwareMailboxNewCommand:1;		/* Bit 0 */
    boolean AcknowledgeHardwareMailboxStatus:1;		/* Bit 1 */
    boolean GenerateInterrupt:1;			/* Bit 2 */
    boolean ControllerReset:1;				/* Bit 3 */
    boolean MemoryMailboxNewCommand:1;			/* Bit 4 */
    unsigned int :27;					/* Bits 5-31 */
  } Write;
  struct {
    boolean HardwareMailboxFull:1;			/* Bit 0 */
    unsigned int :31;					/* Bits 1-31 */
  } Read;
}
DAC960_V4_InboundDoorBellRegister_T;


/*
  Define the structure of the DAC960 V4 Outbound Door Bell Register.
*/

typedef union DAC960_V4_OutboundDoorBellRegister
{
  unsigned int All;
  struct {
    boolean AcknowledgeHardwareMailboxInterrupt:1;	/* Bit 0 */
    boolean AcknowledgeMemoryMailboxInterrupt:1;	/* Bit 1 */
    unsigned int :30;					/* Bits 2-31 */
  } Write;
  struct {
    boolean HardwareMailboxStatusAvailable:1;		/* Bit 0 */
    boolean MemoryMailboxStatusAvailable:1;		/* Bit 1 */
    unsigned int :30;					/* Bits 2-31 */
  } Read;
}
DAC960_V4_OutboundDoorBellRegister_T;


/*
  Define the structure of the DAC960 V4 Interrupt Mask Register.
*/

typedef union DAC960_V4_InterruptMaskRegister
{
  unsigned int All;
  struct {
    unsigned int MessageUnitInterruptMask1:2;		/* Bits 0-1 */
    boolean DisableInterrupts:1;			/* Bit 2 */
    unsigned int MessageUnitInterruptMask2:5;		/* Bits 3-7 */
    unsigned int Reserved0:24;				/* Bits 8-31 */
  } Bits;
}
DAC960_V4_InterruptMaskRegister_T;


/*
  Define inline functions to provide an abstraction for reading and writing the
  DAC960 V4 Controller Interface Registers.
*/

static inline
void DAC960_V4_HardwareMailboxNewCommand(void *ControllerBaseAddress)
{
  DAC960_V4_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All = 0;
  InboundDoorBellRegister.Write.HardwareMailboxNewCommand = true;
  writel(InboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V4_InboundDoorBellRegisterOffset);
}

static inline
void DAC960_V4_AcknowledgeHardwareMailboxStatus(void *ControllerBaseAddress)
{
  DAC960_V4_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All = 0;
  InboundDoorBellRegister.Write.AcknowledgeHardwareMailboxStatus = true;
  writel(InboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V4_InboundDoorBellRegisterOffset);
}

static inline
void DAC960_V4_GenerateInterrupt(void *ControllerBaseAddress)
{
  DAC960_V4_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All = 0;
  InboundDoorBellRegister.Write.GenerateInterrupt = true;
  writel(InboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V4_InboundDoorBellRegisterOffset);
}

static inline
void DAC960_V4_ControllerReset(void *ControllerBaseAddress)
{
  DAC960_V4_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All = 0;
  InboundDoorBellRegister.Write.ControllerReset = true;
  writel(InboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V4_InboundDoorBellRegisterOffset);
}

static inline
void DAC960_V4_MemoryMailboxNewCommand(void *ControllerBaseAddress)
{
  DAC960_V4_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All = 0;
  InboundDoorBellRegister.Write.MemoryMailboxNewCommand = true;
  writel(InboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V4_InboundDoorBellRegisterOffset);
}

static inline
boolean DAC960_V4_HardwareMailboxFullP(void *ControllerBaseAddress)
{
  DAC960_V4_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All =
    readl(ControllerBaseAddress + DAC960_V4_InboundDoorBellRegisterOffset);
  return InboundDoorBellRegister.Read.HardwareMailboxFull;
}

static inline
void DAC960_V4_AcknowledgeHardwareMailboxInterrupt(void *ControllerBaseAddress)
{
  DAC960_V4_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  OutboundDoorBellRegister.All = 0;
  OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  writel(OutboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V4_OutboundDoorBellRegisterOffset);
}

static inline
void DAC960_V4_AcknowledgeMemoryMailboxInterrupt(void *ControllerBaseAddress)
{
  DAC960_V4_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  OutboundDoorBellRegister.All = 0;
  OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  writel(OutboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V4_OutboundDoorBellRegisterOffset);
}

static inline
void DAC960_V4_AcknowledgeInterrupt(void *ControllerBaseAddress)
{
  DAC960_V4_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  OutboundDoorBellRegister.All = 0;
  OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  writel(OutboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V4_OutboundDoorBellRegisterOffset);
}

static inline
boolean DAC960_V4_HardwareMailboxStatusAvailableP(void *ControllerBaseAddress)
{
  DAC960_V4_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  OutboundDoorBellRegister.All =
    readl(ControllerBaseAddress + DAC960_V4_OutboundDoorBellRegisterOffset);
  return OutboundDoorBellRegister.Read.HardwareMailboxStatusAvailable;
}

static inline
boolean DAC960_V4_MemoryMailboxStatusAvailableP(void *ControllerBaseAddress)
{
  DAC960_V4_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  OutboundDoorBellRegister.All =
    readl(ControllerBaseAddress + DAC960_V4_OutboundDoorBellRegisterOffset);
  return OutboundDoorBellRegister.Read.MemoryMailboxStatusAvailable;
}

static inline
void DAC960_V4_EnableInterrupts(void *ControllerBaseAddress)
{
  DAC960_V4_InterruptMaskRegister_T InterruptMaskRegister;
  InterruptMaskRegister.All = 0;
  InterruptMaskRegister.Bits.MessageUnitInterruptMask1 = 0x3;
  InterruptMaskRegister.Bits.DisableInterrupts = false;
  InterruptMaskRegister.Bits.MessageUnitInterruptMask2 = 0x1F;
  writel(InterruptMaskRegister.All,
	 ControllerBaseAddress + DAC960_V4_InterruptMaskRegisterOffset);
}

static inline
void DAC960_V4_DisableInterrupts(void *ControllerBaseAddress)
{
  DAC960_V4_InterruptMaskRegister_T InterruptMaskRegister;
  InterruptMaskRegister.All = 0;
  InterruptMaskRegister.Bits.MessageUnitInterruptMask1 = 0x3;
  InterruptMaskRegister.Bits.DisableInterrupts = true;
  InterruptMaskRegister.Bits.MessageUnitInterruptMask2 = 0x1F;
  writel(InterruptMaskRegister.All,
	 ControllerBaseAddress + DAC960_V4_InterruptMaskRegisterOffset);
}

static inline
boolean DAC960_V4_InterruptsEnabledP(void *ControllerBaseAddress)
{
  DAC960_V4_InterruptMaskRegister_T InterruptMaskRegister;
  InterruptMaskRegister.All =
    readl(ControllerBaseAddress + DAC960_V4_InterruptMaskRegisterOffset);
  return !InterruptMaskRegister.Bits.DisableInterrupts;
}

static inline
void DAC960_V4_WriteCommandMailbox(DAC960_CommandMailbox_T *NextCommandMailbox,
				   DAC960_CommandMailbox_T *CommandMailbox)
{
  NextCommandMailbox->Words[1] = CommandMailbox->Words[1];
  NextCommandMailbox->Words[2] = CommandMailbox->Words[2];
  NextCommandMailbox->Words[3] = CommandMailbox->Words[3];
  NextCommandMailbox->Words[0] = CommandMailbox->Words[0];
}

static inline
void DAC960_V4_WriteHardwareMailbox(void *ControllerBaseAddress,
				    DAC960_CommandMailbox_T *CommandMailbox)
{
  writel(CommandMailbox->Words[0],
	 ControllerBaseAddress + DAC960_V4_CommandOpcodeRegisterOffset);
  writel(CommandMailbox->Words[1],
	 ControllerBaseAddress + DAC960_V4_MailboxRegister4Offset);
  writel(CommandMailbox->Words[2],
	 ControllerBaseAddress + DAC960_V4_MailboxRegister8Offset);
  writeb(CommandMailbox->Bytes[12],
	 ControllerBaseAddress + DAC960_V4_MailboxRegister12Offset);
}

static inline DAC960_CommandIdentifier_T
DAC960_V4_ReadStatusCommandIdentifier(void *ControllerBaseAddress)
{
  return readb(ControllerBaseAddress
	       + DAC960_V4_StatusCommandIdentifierRegOffset);
}

static inline DAC960_CommandStatus_T
DAC960_V4_ReadStatusRegister(void *ControllerBaseAddress)
{
  return readw(ControllerBaseAddress + DAC960_V4_StatusRegisterOffset);
}

static inline
void DAC960_V4_SaveMemoryMailboxInfo(DAC960_Controller_T *Controller)
{
  void *ControllerBaseAddress = Controller->BaseAddress;
  writel(0xAABBFFFF,
	 ControllerBaseAddress + DAC960_V4_CommandOpcodeRegisterOffset);
  writel((unsigned long) Controller->FirstCommandMailbox,
	 ControllerBaseAddress + DAC960_V4_MailboxRegister4Offset);
  writew(Controller->NextCommandMailbox - Controller->FirstCommandMailbox,
	 ControllerBaseAddress + DAC960_V4_MailboxRegister8Offset);
  writew(Controller->NextStatusMailbox - Controller->FirstStatusMailbox,
	 ControllerBaseAddress + DAC960_V4_MailboxRegister10Offset);
}

static inline
void DAC960_V4_RestoreMemoryMailboxInfo(DAC960_Controller_T *Controller,
					void **MemoryMailboxAddress,
					short *NextCommandMailboxIndex,
					short *NextStatusMailboxIndex)
{
  void *ControllerBaseAddress = Controller->BaseAddress;
  if (readl(ControllerBaseAddress
	    + DAC960_V4_CommandOpcodeRegisterOffset) != 0xAABBFFFF)
    return;
  *MemoryMailboxAddress =
    (void *) readl(ControllerBaseAddress + DAC960_V4_MailboxRegister4Offset);
  *NextCommandMailboxIndex =
    readw(ControllerBaseAddress + DAC960_V4_MailboxRegister8Offset);
  *NextStatusMailboxIndex =
    readw(ControllerBaseAddress + DAC960_V4_MailboxRegister10Offset);
}


/*
  Define the DAC960 V3 Controller Interface Register Offsets.
*/

#define DAC960_V3_RegisterWindowSize		0x80

typedef enum
{
  DAC960_V3_CommandOpcodeRegisterOffset =	0x00,
  DAC960_V3_CommandIdentifierRegisterOffset =	0x01,
  DAC960_V3_MailboxRegister2Offset =		0x02,
  DAC960_V3_MailboxRegister3Offset =		0x03,
  DAC960_V3_MailboxRegister4Offset =		0x04,
  DAC960_V3_MailboxRegister5Offset =		0x05,
  DAC960_V3_MailboxRegister6Offset =		0x06,
  DAC960_V3_MailboxRegister7Offset =		0x07,
  DAC960_V3_MailboxRegister8Offset =		0x08,
  DAC960_V3_MailboxRegister9Offset =		0x09,
  DAC960_V3_MailboxRegister10Offset =		0x0A,
  DAC960_V3_MailboxRegister11Offset =		0x0B,
  DAC960_V3_MailboxRegister12Offset =		0x0C,
  DAC960_V3_StatusCommandIdentifierRegOffset =	0x0D,
  DAC960_V3_StatusRegisterOffset =		0x0E,
  DAC960_V3_InboundDoorBellRegisterOffset =	0x40,
  DAC960_V3_OutboundDoorBellRegisterOffset =	0x41,
  DAC960_V3_InterruptEnableRegisterOffset =	0x43
}
DAC960_V3_RegisterOffsets_T;


/*
  Define the structure of the DAC960 V3 Inbound Door Bell Register.
*/

typedef union DAC960_V3_InboundDoorBellRegister
{
  unsigned char All;
  struct {
    boolean NewCommand:1;				/* Bit 0 */
    boolean AcknowledgeStatus:1;			/* Bit 1 */
    boolean GenerateInterrupt:1;			/* Bit 2 */
    boolean ControllerReset:1;				/* Bit 3 */
    unsigned char :4;					/* Bits 4-7 */
  } Write;
  struct {
    boolean MailboxFull:1;				/* Bit 0 */
    unsigned char :7;					/* Bits 1-7 */
  } Read;
}
DAC960_V3_InboundDoorBellRegister_T;


/*
  Define the structure of the DAC960 V3 Outbound Door Bell Register.
*/

typedef union DAC960_V3_OutboundDoorBellRegister
{
  unsigned char All;
  struct {
    boolean AcknowledgeInterrupt:1;			/* Bit 0 */
    unsigned char :7;					/* Bits 1-7 */
  } Write;
  struct {
    boolean StatusAvailable:1;				/* Bit 0 */
    unsigned char :7;					/* Bits 1-7 */
  } Read;
}
DAC960_V3_OutboundDoorBellRegister_T;


/*
  Define the structure of the DAC960 V3 Interrupt Enable Register.
*/

typedef union DAC960_V3_InterruptEnableRegister
{
  unsigned char All;
  struct {
    boolean EnableInterrupts:1;				/* Bit 0 */
    unsigned char :7;					/* Bits 1-7 */
  } Bits;
}
DAC960_V3_InterruptEnableRegister_T;


/*
  Define inline functions to provide an abstraction for reading and writing the
  DAC960 V3 Controller Interface Registers.
*/

static inline
void DAC960_V3_NewCommand(void *ControllerBaseAddress)
{
  DAC960_V3_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All = 0;
  InboundDoorBellRegister.Write.NewCommand = true;
  writeb(InboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V3_InboundDoorBellRegisterOffset);
}

static inline
void DAC960_V3_AcknowledgeStatus(void *ControllerBaseAddress)
{
  DAC960_V3_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All = 0;
  InboundDoorBellRegister.Write.AcknowledgeStatus = true;
  writeb(InboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V3_InboundDoorBellRegisterOffset);
}

static inline
void DAC960_V3_GenerateInterrupt(void *ControllerBaseAddress)
{
  DAC960_V3_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All = 0;
  InboundDoorBellRegister.Write.GenerateInterrupt = true;
  writeb(InboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V3_InboundDoorBellRegisterOffset);
}

static inline
void DAC960_V3_ControllerReset(void *ControllerBaseAddress)
{
  DAC960_V3_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All = 0;
  InboundDoorBellRegister.Write.ControllerReset = true;
  writeb(InboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V3_InboundDoorBellRegisterOffset);
}

static inline
boolean DAC960_V3_MailboxFullP(void *ControllerBaseAddress)
{
  DAC960_V3_InboundDoorBellRegister_T InboundDoorBellRegister;
  InboundDoorBellRegister.All =
    readb(ControllerBaseAddress + DAC960_V3_InboundDoorBellRegisterOffset);
  return InboundDoorBellRegister.Read.MailboxFull;
}

static inline
void DAC960_V3_AcknowledgeInterrupt(void *ControllerBaseAddress)
{
  DAC960_V3_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  OutboundDoorBellRegister.All = 0;
  OutboundDoorBellRegister.Write.AcknowledgeInterrupt = true;
  writeb(OutboundDoorBellRegister.All,
	 ControllerBaseAddress + DAC960_V3_OutboundDoorBellRegisterOffset);
}

static inline
boolean DAC960_V3_StatusAvailableP(void *ControllerBaseAddress)
{
  DAC960_V3_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  OutboundDoorBellRegister.All =
    readb(ControllerBaseAddress + DAC960_V3_OutboundDoorBellRegisterOffset);
  return OutboundDoorBellRegister.Read.StatusAvailable;
}

static inline
void DAC960_V3_EnableInterrupts(void *ControllerBaseAddress)
{
  DAC960_V3_InterruptEnableRegister_T InterruptEnableRegister;
  InterruptEnableRegister.All = 0;
  InterruptEnableRegister.Bits.EnableInterrupts = true;
  writeb(InterruptEnableRegister.All,
	 ControllerBaseAddress + DAC960_V3_InterruptEnableRegisterOffset);
}

static inline
void DAC960_V3_DisableInterrupts(void *ControllerBaseAddress)
{
  DAC960_V3_InterruptEnableRegister_T InterruptEnableRegister;
  InterruptEnableRegister.All = 0;
  InterruptEnableRegister.Bits.EnableInterrupts = false;
  writeb(InterruptEnableRegister.All,
	 ControllerBaseAddress + DAC960_V3_InterruptEnableRegisterOffset);
}

static inline
boolean DAC960_V3_InterruptsEnabledP(void *ControllerBaseAddress)
{
  DAC960_V3_InterruptEnableRegister_T InterruptEnableRegister;
  InterruptEnableRegister.All =
    readb(ControllerBaseAddress + DAC960_V3_InterruptEnableRegisterOffset);
  return InterruptEnableRegister.Bits.EnableInterrupts;
}

static inline
void DAC960_V3_WriteCommandMailbox(void *ControllerBaseAddress,
				   DAC960_CommandMailbox_T *CommandMailbox)
{
  writel(CommandMailbox->Words[0],
	 ControllerBaseAddress + DAC960_V3_CommandOpcodeRegisterOffset);
  writel(CommandMailbox->Words[1],
	 ControllerBaseAddress + DAC960_V3_MailboxRegister4Offset);
  writel(CommandMailbox->Words[2],
	 ControllerBaseAddress + DAC960_V3_MailboxRegister8Offset);
  writeb(CommandMailbox->Bytes[12],
	 ControllerBaseAddress + DAC960_V3_MailboxRegister12Offset);
}

static inline DAC960_CommandIdentifier_T
DAC960_V3_ReadStatusCommandIdentifier(void *ControllerBaseAddress)
{
  return readb(ControllerBaseAddress
	       + DAC960_V3_StatusCommandIdentifierRegOffset);
}

static inline DAC960_CommandStatus_T
DAC960_V3_ReadStatusRegister(void *ControllerBaseAddress)
{
  return readw(ControllerBaseAddress + DAC960_V3_StatusRegisterOffset);
}


/*
  Define compatibility macros between Linux 2.0 and Linux 2.1.
*/

#if LINUX_VERSION_CODE < 0x20100

#define MODULE_PARM(Variable, Type)
#define ioremap_nocache(Offset, Size)	vremap(Offset, Size)
#define iounmap(Address)		vfree(Address)

#endif


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

static void DAC960_FinalizeController(DAC960_Controller_T *);
static int DAC960_Finalize(NotifierBlock_T *, unsigned long, void *);
static void DAC960_RequestFunction0(request_queue_t *);
static void DAC960_RequestFunction1(request_queue_t *);
static void DAC960_RequestFunction2(request_queue_t *);
static void DAC960_RequestFunction3(request_queue_t *);
static void DAC960_RequestFunction4(request_queue_t *);
static void DAC960_RequestFunction5(request_queue_t *);
static void DAC960_RequestFunction6(request_queue_t *);
static void DAC960_RequestFunction7(request_queue_t *);
static void DAC960_InterruptHandler(int, void *, Registers_T *);
static void DAC960_QueueMonitoringCommand(DAC960_Command_T *);
static void DAC960_MonitoringTimerFunction(unsigned long);
static int DAC960_Open(Inode_T *, File_T *);
static int DAC960_Release(Inode_T *, File_T *);
static int DAC960_IOCTL(Inode_T *, File_T *, unsigned int, unsigned long);
static int DAC960_UserIOCTL(Inode_T *, File_T *, unsigned int, unsigned long);
static void DAC960_InitializeGenericDiskInfo(GenericDiskInfo_T *);
static void DAC960_Message(DAC960_MessageLevel_T, char *,
			   DAC960_Controller_T *, ...);
static void DAC960_CreateProcEntries(void);
static void DAC960_DestroyProcEntries(void);


/*
  Export the Kernel Mode IOCTL interface.
*/

EXPORT_SYMBOL(DAC960_KernelIOCTL);


#endif /* DAC960_DriverVersion */