aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/wlags49_h2/hcfcfg.h
blob: 83475b1060a18c5652f057510545ed39da629878 (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
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

//   vim:tw=110:ts=4:
#ifndef HCFCFG_H
#define HCFCFG_H 1

/*************************************************************************************************************
*
* FILE	 : hcfcfg.tpl // hcfcfg.h
*
* DATE   : $Date: 2004/08/05 11:47:10 $   $Revision: 1.6 $
* Original: 2004/04/08 15:18:16    Revision: 1.40      Tag: t20040408_01
* Original: 2004/04/01 15:32:55    Revision: 1.38      Tag: t7_20040401_01
* Original: 2004/03/10 15:39:28    Revision: 1.34      Tag: t20040310_01
* Original: 2004/03/03 14:10:12    Revision: 1.32      Tag: t20040304_01
* Original: 2004/03/02 09:27:12    Revision: 1.30      Tag: t20040302_03
* Original: 2004/02/24 13:00:28    Revision: 1.25      Tag: t20040224_01
* Original: 2004/02/18 17:13:57    Revision: 1.23      Tag: t20040219_01
*
* AUTHOR : Nico Valster
*
* DESC   : HCF Customization Macros
* hcfcfg.tpl list all #defines which must be specified to:
*   adjust the HCF functions defined in HCF.C to the characteristics of a specific environment
*		o maximum sizes for messages
*		o Endianess
*	Compiler specific macros
*		o port I/O macros
*		o type definitions
*
* By copying HCFCFG.TPL to HCFCFG.H and -if needed- modifying the #defines the WCI functionality can be
* tailored
*
* Supported environments:
* WVLAN_41	Miniport								NDIS 3.1
* WVLAN_42	Packet									Microsoft Visual C 1.5
* WVLAN_43	16 bits DOS ODI							Microsoft Visual C 1.5
* WVLAN_44	32 bits ODI (__NETWARE_386__)			WATCOM
* WVLAN_45	MAC_OS									MPW?, Symantec?
* WVLAN_46	Windows CE (_WIN32_WCE)					Microsoft ?
* WVLAN_47	LINUX  (__LINUX__)						GCC, discarded, based on GPL'ed HCF-light
* WVLAN_48	Miniport								NDIS 5
* WVLAN_49	LINUX  (__LINUX__)						GCC, originally based on pre-compiled HCF_library
* 													migrated to use the HCF sources when Lucent Technologies
* 													brought the HCF module under GPL
* WVLAN_51	Miniport USB							NDIS 5
* WVLAN_52	Miniport								NDIS 4
* WVLAN_53	VxWorks END Station driver
* WVLAN_54	VxWorks END Access Point driver
* WVLAN_81	WavePoint								BORLAND C
* WCITST	Inhouse test tool						Microsoft Visual C 1.5
* WSU		WaveLAN Station Update					Microsoft Visual C ??
* SCO UNIX	not yet actually used ?					?
* __ppc		OEM supplied							?
* _AM29K	OEM supplied							?
* ?			OEM supplied							Microtec Research 80X86 Compiler
*
**************************************************************************************************************
*
*
* SOFTWARE LICENSE
*
* This software is provided subject to the following terms and conditions,
* which you should read carefully before using the software.  Using this
* software indicates your acceptance of these terms and conditions.  If you do
* not agree with these terms and conditions, do not use the software.
*
* COPYRIGHT © 1994 - 1995	by AT&T.				All Rights Reserved
* COPYRIGHT © 1996 - 2000 by Lucent Technologies.	All Rights Reserved
* COPYRIGHT © 2001 - 2004	by Agere Systems Inc.	All Rights Reserved
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
* modifications, are permitted provided that the following conditions are met:
*
* . Redistributions of source code must retain the above copyright notice, this
*    list of conditions and the following Disclaimer as comments in the code as
*    well as in the documentation and/or other materials provided with the
*    distribution.
*
* . Redistributions in binary form must reproduce the above copyright notice,
*    this list of conditions and the following Disclaimer in the documentation
*    and/or other materials provided with the distribution.
*
* . Neither the name of Agere Systems Inc. nor the names of the contributors
*    may be used to endorse or promote products derived from this software
*    without specific prior written permission.
*
* Disclaimer
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
* RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*
*************************************************************************************************************/

/*	Alignment
*	Some platforms can access words on odd boundaries (with possibly an performance impact), at other
*	platforms such an access may result in a memory access violation.
*	It is assumed that everywhere where the HCF casts a char pointer into a word pointer, the alignment
*	criteria are met. This put some restrictions on the MSF, which are assumed to be "automatically" fulfilled
*	at the applicable platforms
*	To assert this assumption, the macro HCF_ALIGN can be defined. The default value is 1, meaning byte
*	alignment (or no alignment), a value of 2 means word alignment, a value of 4 means double word alignment
*/

/*****************************    IN_PORT_STRING_8_16  S a m p l e s *****************************************

		// C implementation which let the processor handle the word-at-byte-boundary problem
#define IN_PORT_STRING_8_16( port, addr, n) while ( n-- ) 	\
	{ *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); ((hcf_8 FAR*)addr)+=2; }

		// C implementation which handles the word-at-byte-boundary problem
#define IN_PORT_STRING_8_16( port, addr, n)	while ( n-- )	 \
	{ hcf_16 i = IN_PORT_WORD(port); *((hcf_8 FAR*)addr)++ = (hcf_8)i; *((hcf_8 FAR*)addr)++ = (hcf_8)(i>>8);}

		// Assembler implementation
#define IN_PORT_STRING_8_16( port, addr, len) __asm		\
{														\
	__asm push di										\
	__asm push es										\
	__asm mov cx,len									\
	__asm les di,addr									\
	__asm mov dx,port									\
	__asm rep insw										\
	__asm pop es										\
	__asm pop di										\
}


*****************************   OUT_PORT_STRING_8_16  S a m p l e s ******************************************

		// C implementation which let the processor handle the word-at-byte-boundary problem
#define OUT_PORT_STRING_8_16( port, addr, n)	while ( n-- ) \
	{ OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ) ; ((hcf_8 FAR*)addr)+=2; }

		// C implementation which handles the word-at-byte-boundary problem
#define OUT_PORT_STRING_8_16( port, addr, n)	while ( n-- ) \
	{ OUT_PORT_WORD( port, *((hcf_8 FAR*)addr) | *(((hcf_8 FAR*)addr)+1)<<8  ); (hcf_8 FAR*)addr+=2; }

		// Assembler implementation
#define OUT_PORT_STRING_8_16( port, addr, len) __asm	\
{														\
	__asm push si										\
	__asm push ds										\
	__asm mov cx,len									\
	__asm lds si,addr									\
	__asm mov dx,port									\
	__asm rep outsw										\
	__asm pop ds										\
	__asm pop si										\
}

*************************************************************************************************************/


/************************************************************************************************/
/******************  C O M P I L E R   S P E C I F I C   M A C R O S  ***************************/
/************************************************************************************************/
/*************************************************************************************************
*
*			!!!!!!!!!!!!!!!!!!!!!!!!! Note to the HCF-implementor !!!!!!!!!!!!!!!!!!!!!!!!!
*			!!!! Do not call these macros with parameters which introduce side effects !!!!
*			!!!!!!!!!!!!!!!!!!!!!!!!! Note to the HCF-implementor !!!!!!!!!!!!!!!!!!!!!!!!!
*
*
* By selecting the appropriate Macro definitions by means of modifying the "#ifdef 0/1" lines, the HCF can be
* adjusted for the I/O characteristics of a specific compiler
*
* If needed the macros can be modified or replaced with definitions appropriate for your personal platform.
* If you need to make such changes it is appreciated if you inform Agere Systems
* That way the changes can become part of the next release of the WCI
*
* For convenience of the MSF-programmer, all macros are allowed to modify their parameters (although some
* might argue that this would constitute bad coding practice). This has its implications on the HCF, e.g. as a
* consequence these macros should not be called with parameters which have side effects, e.g auto-increment.
*
* in the Microsoft implementation of inline assembly it is O.K. to corrupt all flags except the direction flag
* and to corrupt all registers except the segment registers and EDI, ESI, ESP and EBP (or their 16 bits
* equivalents).  Other environments may have other constraints
*
* in the Intel environment it is O.K to have a word (as a 16 bits quantity) at a byte boundary, hence
* IN_/OUT_PORT_STRING_8_16 can move words between PC-memory and NIC-memory with as only constraint that the
* words are on a word boundary in NIC-memory. This does not hold true for all conceivable environments, e.g.
* an Motorola 68xxx does not allow this. Probably/hopefully the boundary conditions imposed by these type of
* platforms prevent this case from materializing.  If this is not the case, OUT_PORT_STRING_8_16 must be coded
* by combining two Host memory hcf_8 values at a time to a single hcf_16 value to be passed to the NIC and
* IN_PORT_STRING_8_16 the single hcf_16 retrieved from the NIC must be split in two hcf_8 values to be stored
* in Host memory (see the sample code above)
*
*	The prototypes and functional description of the macros are:
*
*	hcf_16	IN_PORT_WORD( hcf_16 port )
*			Reads a word (16 bits) from the specified port
*
*	void	OUT_PORT_WORD( hcf_16 port, hcf_16 value)
*			Writes a word (16 bits) to the specified port
*
*	hcf_16	IN_PORT_DWORD( hcf_16 port )
*			Reads a dword (32 bits) from the specified port
*
*	void	OUT_PORT_DWORD( hcf_16 port, hcf_32 value)
*			Writes a dword (32 bits) to the specified port
*
*	void	IN_PORT_STRING_8_16( port, addr, len)
*			Reads len number of words (16 bits) from NIC memory via the specified port to the (FAR)
*			byte-pointer addr in PC-RAM
*			Note that len specifies the number of words, NOT the number of bytes
*			!!!NOTE, although len specifies the number of words, addr MUST be a char pointer NOTE!!!
*			See also the common notes for IN_PORT_STRING_8_16 and OUT_PORT_STRING_8_16
*
*	void	OUT_PORT_STRING_8_16( port, addr, len)
*			Writes len number of words (16 bits) from the (FAR) byte-pointer addr in PC-RAM via the specified
*			port to NIC memory
*			Note that len specifies the number of words, NOT the number of bytes.
*			!!!NOTE, although len specifies the number of words, addr MUST be a char pointer NOTE!!!
*
*			The peculiar combination of word-length and char pointers for IN_PORT_STRING_8_16 as well as
*			OUT_PORT_STRING_8_16 is justified by the assumption that it offers a more optimal algorithm
*
*	void	IN_PORT_STRING_32( port, addr, len)
*			Reads len number of double-words (32 bits) from NIC memory via the specified port to the (FAR)
*			double-word address addr in PC-RAM
*
*	void	OUT_PORT_STRING_32( port, addr, len)
*			Writes len number of double-words (32 bits) from the (FAR) double-word address addr in PC-RAM via
*			the specified port to NIC memory
*
*			!!!!!!!!!!!!!!!!!!!!!!!!! Note to the HCF-implementor !!!!!!!!!!!!!!!!!!!!!!!!!
*			!!!! Do not call these macros with parameters which introduce side effects !!!!
*			!!!!!!!!!!!!!!!!!!!!!!!!! Note to the HCF-implementor !!!!!!!!!!!!!!!!!!!!!!!!!
*
*************************************************************************************************/

/****************************  define INT Types  ******************************/
typedef unsigned char			hcf_8;
typedef unsigned short			hcf_16;
typedef unsigned long			hcf_32;

/****************************  define I/O Types  ******************************/
#define HCF_IO_MEM     			0x0001	// memory mapped I/O	( 0: Port I/O )
#define HCF_IO_32BITS   	  	0x0002 	// 32Bits support		( 0: only 16 Bits I/O)

/****************************** #define HCF_TYPE ********************************/
#define HCF_TYPE_NONE			0x0000	// No type
#define HCF_TYPE_WPA			0x0001	// WPA support
#define HCF_TYPE_USB			0x0002	// reserved (USB Dongle driver support)
//#define HCF_TYPE_HII			0x0004	// Hermes-II, to discriminate H-I and H-II CFG_HCF_OPT_STRCT
#define HCF_TYPE_WARP			0x0008	// WARP F/W
#define HCF_TYPE_PRELOADED		0x0040	// pre-loaded F/W
#define HCF_TYPE_HII5			0x0080	// Hermes-2.5 H/W
#define HCF_TYPE_CCX			0x0100	// CKIP
#define HCF_TYPE_BEAGLE_HII5	0x0200	// Beagle Hermes-2.5 H/W
#define HCF_TYPE_TX_DELAY		0x4000	// Delayed transmission ( non-DMA only)

/****************************** #define HCF_ASSERT ******************************/
#define HCF_ASSERT_NONE			0x0000	// No assert support
#define HCF_ASSERT_PRINTF		0x0001	// Hermes generated debug info
#define HCF_ASSERT_SW_SUP		0x0002	// logging via Hermes support register
#define HCF_ASSERT_MB			0x0004	// logging via Mailbox
#define HCF_ASSERT_RT_MSF_RTN	0x4000	// dynamically binding of msf_assert routine
#define HCF_ASSERT_LNK_MSF_RTN	0x8000	// statically binding of msf_assert routine

/****************************** #define HCF_ENCAP *******************************/
#define HCF_ENC_NONE			0x0000	// No encapsulation support
#define HCF_ENC					0x0001	// HCF handles En-/Decapsulation
#define HCF_ENC_SUP				0x0002	// HCF supports MSF to handle En-/Decapsulation

/****************************** #define HCF_EXT *********************************/
#define HCF_EXT_NONE			0x0000	// No expanded features
#define HCF_EXT_INFO_LOG		0x0001	// logging of Hermes Info frames
//#define HCF_EXT_INT_TX_OK		0x0002	// RESERVED!!! monitoring successful Tx message
#define HCF_EXT_INT_TX_EX		0x0004	// monitoring unsuccessful Tx message
//#define HCF_EXT_MON_MODE		0x0008	// LEGACY
#define HCF_EXT_TALLIES_FW		0x0010	// support for up to 32 Hermes Engineering tallies
#define HCF_EXT_TALLIES_HCF		0x0020	// support for up to 8 HCF Engineering tallies
#define HCF_EXT_NIC_ACCESS		0x0040	// direct access via Aux-ports and to Hermes registers and commands
#define HCF_EXT_MB				0x0080	// MailBox code expanded
#define HCF_EXT_IFB_STRCT 		0x0100	// MSF custom pointer in IFB
#define HCF_EXT_DESC_STRCT 		0x0200	// MSF custom pointer in Descriptor
#define HCF_EXT_TX_CONT			0x4000	// Continuous transmit test
#define HCF_EXT_INT_TICK		0x8000	// enables TimerTick interrupt generation

/****************************** #define HCF_SLEEP *******************************/
#define HCF_DDS					0x0001	// Disconnected Deep Sleep
#define HCF_CDS					0x0002	// Connected Deep Sleep

/****************************** #define HCF_TALLIES ******************************/
#define HCF_TALLIES_NONE		0x0000	// No tally support
#define HCF_TALLIES_NIC			0x0001	// Hermes Tallies accumulated in IFB
#define HCF_TALLIES_HCF			0x0002	// HCF Tallies accumulated in IFB
#define HCF_TALLIES_RESET		0x8000	// Tallies in IFB are reset when reported via hcf_get_info


/************************************************************************************************/
/******************************  M I N I P O R T    N D I S *************************************/
/************************************************************************************************/

#if defined WVLAN_41 || defined WVLAN_48 || defined WVLAN_52 || defined _WIN32_WCE

#ifndef WVLAN_46
#define HCF_EXT   (HCF_EXT_INFO_LOG | HCF_EXT_MB | HCF_EXT_NIC_ACCESS )
#else
#define HCF_EXT ( HCF_EXT_TX_CONT | HCF_EXT_INFO_LOG | HCF_EXT_MB | HCF_EXT_NIC_ACCESS )
#endif
#define HCF_DLV 1			//H-I legacy, superfluous for H-II

#ifdef _WIN32_WCE
#define HCF_IO     HCF_IO_MEM
#define HCF_DMA		0			// To enable DMA
#endif

#if _VARIANT == 7
#define HCF_SLEEP HCF_CDS
#endif // _VARIANT == 7

#if _VARIANT == 5 || _VARIANT == 6
#define _WARP
#define _AES
#define HCF_SLEEP HCF_CDS
#if _VARIANT == 6
//! #define _RSN
#endif // _VARIANT == 6
#ifndef _WIN32_WCE
#define HCF_IO     HCF_IO_32BITS
#define HCF_DMA		1			// To enable DMA
#endif
#endif // _VARIANT == 5 || _VARIANT == 6


//HWi for migration purposes I defined a define which will be TRUE for ALL drivers
//Meaning that _CCX defined code which we think will get a all driver OK flag can be defined from _CCX to _CCX_OK
#if defined WVLAN_48 // && !defined _WIN32_WCE
#if _VARIANT == 4 || _VARIANT == 6
#define _CCX_OK		1
#endif // _VARIANT == 4 || _VARIANT == 6
#endif // WVLAN_48

//#if !defined WVLAN_46
#if defined WVLAN_48
#if _VARIANT == 4 || _VARIANT == 6
#define _CCX
#define HCF_MAX_MSG_CKIP_PADDING    86 //, use 86 for rx fragmentation. 28 is enuf for MIC+PPK encapsulation
#define HCF_MAX_MSG					( 1514 + HCF_MAX_MSG_CKIP_PADDING  ) // need extra padding for CKIP (need to subtract 28 for NDIS)
#endif // _VARIANT == 4 || _VARIANT == 6
#endif // WVLAN_48
//#endif // WVLAN_46

#if !defined WVLAN_46
#define _PEEK
#endif

#ifndef _WIN32_WCE
// ASSERT already used by WinCE...
#ifdef ASSERT
#undef ASSERT
#define  ASSERT(x) ASSERTDEBUGMSG((x), (TEXT("SIMULATE ASSERT:")))
#endif
#endif


#if defined WVLAN_41
#define	MSF_COMPONENT_ID			COMP_ID_MINIPORT_NDIS_31
#endif // WVLAN_41
#if defined WVLAN_48 && !defined _WIN32_WCE
#define	MSF_COMPONENT_ID			COMP_ID_MINIPORT_NDIS_50
#endif // WVLAN_48 / _WIN32_WCE
#if defined WVLAN_52 && !defined _WIN32_WCE
#define	MSF_COMPONENT_ID			COMP_ID_MINIPORT_NDIS_40
#endif // WVLAN_52 / _WIN32_WCE
#if defined WVLAN_46
#define	MSF_COMPONENT_ID			COMP_ID_WIN_CE
#endif // _WIN32_WCE

#define	MSF_COMPONENT_VAR			_VARIANT

#define	T1__HCF_TYPE					(HCF_TYPE_NONE)

#define T2__HCF_TYPE					(T1__HCF_TYPE)

#ifdef _WARP
#define T3__HCF_TYPE					(T2__HCF_TYPE | HCF_TYPE_HII5 | HCF_TYPE_WARP )
#else
#if _VARIANT == 7
#define T3__HCF_TYPE					(T2__HCF_TYPE | HCF_TYPE_HII5)
#else // _VARIANT == 7
#define T3__HCF_TYPE					(T2__HCF_TYPE)
#endif // _VARIANT == 7
#endif // _WARP

#ifdef _CCX_OK
#define T4__HCF_TYPE					(T3__HCF_TYPE | HCF_TYPE_CCX)
#else
#define T4__HCF_TYPE					(T3__HCF_TYPE)
#endif // _CCX_OK

//not suitable for H-II #define HCF_CFG_STA_1_BOTTOM        	16

// Default WPA in ON for all drivers except for WARP driver
#ifdef _WARP
#define T5__HCF_TYPE					(T4__HCF_TYPE)
#else // _WARP
#define T5__HCF_TYPE					(T4__HCF_TYPE | HCF_TYPE_WPA)
#endif // _WARP

#define HCF_TYPE						(T5__HCF_TYPE)

// This is needed to get aux_ctrl() from the HCF for WlFreezeAndDump()
#if (defined DBG && DBG != 0)
#ifndef STATIC
#define STATIC
#endif
#endif

#if !defined SOFTRONICS_CODE && !defined _APIDLL && !defined _WIN32_WCE
#include <ndis.h>
#endif // SOFTRONICS_CODE / _APIDLL / _WIN32_WCE
#if defined _WIN32_WCE
#include <windows.h>
#include <winnt.h>
#endif  // _WIN32_WCE
#include "version.h"

#define	MSF_COMPONENT_MAJOR_VER		TPI_MAJOR_VERSION
#define	MSF_COMPONENT_MINOR_VER		TPI_MINOR_VERSION

#if !defined _APIDLL && !defined _WIN32_WCE

__inline UCHAR NDIS_IN_BYTE( ULONG port )
{
    UCHAR value;
    NdisRawReadPortUchar(port , &value);
    return (value);
}

__inline ULONG NDIS_IN_LONG( ULONG port )
{
    ULONG value;
    NdisRawReadPortUlong(port , &value);
    return (value);
}
__inline USHORT NDIS_IN_WORD( ULONG port )
{
    USHORT value;
    NdisRawReadPortUshort(port , &value);
    return (value);
}

#define IN_PORT_DWORD(port)			NDIS_IN_LONG( (ULONG) (port) )
#define IN_PORT_WORD(port)			NDIS_IN_WORD( (ULONG) (port) )
#define OUT_PORT_DWORD(port, value)	NdisRawWritePortUlong((ULONG) (port) , value)
#define OUT_PORT_WORD(port, value)	NdisRawWritePortUshort((ULONG) (port) , (USHORT) (value))

#define  IN_PORT_STRING_8_16(port, addr, len)	IN_PORT_STRING_16(port, addr, len)
#define  OUT_PORT_STRING_8_16(port, addr, len)	OUT_PORT_STRING_16(port, addr, len)

#define IN_PORT_STRING_32(port, addr, len)		{					\
	NdisRawReadPortBufferUlong(port, addr, (len));					\
}

#define OUT_PORT_STRING_32(port, addr, len)	{						\
	NdisRawWritePortBufferUlong(port, addr, (len));					\
}

#define IN_PORT_STRING_16(port, addr, len)	NdisRawReadPortBufferUshort(port, addr, (len));
#define OUT_PORT_STRING_16(port, addr, len)	NdisRawWritePortBufferUshort(port, addr, (len));

#endif //  _APIDLL / _WIN32_WCE

#if defined _WIN32_WCE

#define HCF_ALIGN 2
#define HCF_MEM_IO					1 // overrule standard Port I/O with Memory mapped I/O
#define HCF_PROT_TIME				49

#define  		IN_PORT_BYTE			CE_IN_PORT_BYTE
#define  		OUT_PORT_BYTE			CE_OUT_PORT_BYTE
#define  		IN_PORT_WORD			CE_IN_PORT_WORD
#define  		OUT_PORT_WORD			CE_OUT_PORT_WORD
#define  		IN_PORT_STRING_16		CE_IN_PORT_STRING
#define  		OUT_PORT_STRING_16		CE_OUT_PORT_STRING

extern hcf_8  CE_IN_PORT_BYTE(hcf_32 port);
extern void   CE_OUT_PORT_BYTE(hcf_32 port, hcf_8 value);
extern hcf_16 CE_IN_PORT_WORD(hcf_32 port);
extern void   CE_OUT_PORT_WORD(hcf_32 port, hcf_16 value);
extern void   CE_IN_PORT_STRING(hcf_32 port, void *addr, hcf_16 len);
extern void   CE_OUT_PORT_STRING(hcf_32 port, void *addr, hcf_16 len);


#endif

#if defined _DEBUG || (defined DBG && DBG != 0)
#define HCF_ASSERT ( HCF_ASSERT_LNK_MSF_RTN | HCF_ASSERT_RT_MSF_RTN | HCF_ASSERT_PRINTF ) //0xC001
//#define HCF_ASSERT ( HCF_ASSERT_LNK_MSF_RTN | HCF_ASSERT_RT_MSF_RTN | HCF_ASSERT_PRINTF | HCF_ASSERT_MB ) //just to test
#endif // _DEBUG || DBG

#if defined DEBUG || defined _DEBUG || (defined DBG && DBG != 0)
#ifdef _WIN32_WCE
#define DBGA2W(DBGSTR)	CeConvertAnsiToUnicodeLen((char*)DBGSTR)
#define OUTPUTDEBUGMSG(dprintf_exp)			((void)((! ZONE_DEBUG) ? 0:ce_debug_out dprintf_exp))
#define ASSERTDEBUGMSG(cond, dprintf_exp)			((void)((cond) ? 0:ce_debug_out dprintf_exp))

#define ZONE_ERROR      DEBUGZONE(0)
#define ZONE_WARN       DEBUGZONE(1)
#define ZONE_FUNCTION   DEBUGZONE(2)
#define ZONE_INIT       DEBUGZONE(3)
#define ZONE_INTR       DEBUGZONE(4)
#define ZONE_RCV        DEBUGZONE(5)
#define ZONE_XMIT		DEBUGZONE(6)
#define ZONE_ASSERT 	DEBUGZONE(7)
#define ZONE_DEBUG 		DEBUGZONE(8)
#define ZONE_OEM 		DEBUGZONE(9)
#define ZONE_HCF		DEBUGZONE(10)
#define ZONE_PORTIO		DEBUGZONE(11)
#define ZONE_LOGTOFILE	DEBUGZONE(15)

#else // !(_WIN32_WCE)

#define OUTPUTDEBUGMSG(dprintf_exp)					((void) (DbgPrint dprintf_exp))
// the assertdebugmsg macro will print filename, line followed by a caller-defined text, when cond == 0
#define ASSERTDEBUGMSG(cond, print)	((void)((cond) ? 0: (DbgPrint("%s %s:%d - ", print, __FILE__, __LINE__))))

#define ZONE_ERROR      1
#define ZONE_WARN       1
#define ZONE_FUNCTION   1
#define ZONE_INIT       1
#define ZONE_INTR       1
#define ZONE_RCV        1
#define ZONE_XMIT		1
#define ZONE_ASSERT 	1
#define ZONE_DEBUG 		1
#define ZONE_OEM 		1
#define ZONE_HCF		1
#define ZONE_PORTIO		1
#define ZONE_LOGTOFILE	1

#endif // _WIN32_WCE
#ifndef DBGA2W
#define DBGA2W
#endif	// DBGA2W

#else // !(defined DEBUG || defined _DEBUG || (defined DBG && DBG != 0) )
#define OUTPUTDEBUGMSG(dprintf_exp)
#define ASSERTDEBUGMSG(cond, dprintf_exp)
#endif // DEBUG / DBG

#if !defined HCF_MAX_MSG_CKIP_PADDING
#define HCF_MAX_MSG_CKIP_PADDING 0
#endif // 		HCF_MAX_MSG_CKIP_PADDING

#if !defined	HCF_MAX_MSG
#define			HCF_MAX_MSG				1514
#endif // 		HCF_MAX_MSG

#define			HCF_LEGACY			1	//;?nv je moet wat

#endif //WVLAN_41 / WVLAN_48 / WVLAN_52 / _WIN32_WCE


/************************************************************************************************/
/****************************  P A C K E T   D R I V E R  ***************************************/
/**********************************  D O S   O D I  *********************************************/
/************************************************************************************************/

#if defined WVLAN_42 || defined WVLAN_43

#pragma warning ( disable: 4001 )
#define FAR  __far										//segmented 16 bits mode
#define BASED __based(__segname("_CODE"))				//force all the "const" structures in the CODE segment

//#define HCF_IO     0									//no DMA, no 32 bits

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To ease testing the different options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#define	HCF_EXT						HCF_EXT_MB
#define HCF_PROT_TIME				49					//49*10240 microseconds H/W failure protection timer

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To ease testing the different options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/********************************  CONFIGURATION MANAGEMENT *****************************************/
#ifdef WVLAN_42
#define	MSF_COMPONENT_ID			COMP_ID_PACKET
#define	MSF_COMPONENT_VAR			1
#define	MSF_COMPONENT_MAJOR_VER		6
#define	MSF_COMPONENT_MINOR_VER		12
#endif // WVLAN_42

#ifdef WVLAN_43
#define	MSF_COMPONENT_ID			COMP_ID_ODI_16
#define	MSF_COMPONENT_VAR			1
#define	MSF_COMPONENT_MAJOR_VER		6
#define	MSF_COMPONENT_MINOR_VER		10
#endif // WVLAN_43

/**************************************  INPUT / OUTPUT **********************************************/
#ifndef H_2_INC
#include <stdio.h>
#include <conio.h>
#if 1 //temorary use functions defined in hcf.c
#ifndef _DEBUG
#pragma intrinsic( _inp, _inpw, _outp, _outpw )
#endif // _DEBUG

#define IN_PORT_WORD(port)			((hcf_16)_inpw( (hcf_io)(port) ))
#define OUT_PORT_WORD(port, value)	((void)_outpw( (hcf_io)(port), value ))

#if 1		// C implementation which let the processor handle the word-at-byte-boundary problem
#define IN_PORT_STRING_8_16( port, addr, n)		while (n--) \
	{ *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); ((hcf_8 FAR*)addr)+=2; }
#define OUT_PORT_STRING_8_16( port, addr, n)	while (n--) \
	{ OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ) ; ((hcf_8 FAR*)addr)+=2; }
#elif 0		// C implementation which handles the word-at-byte-boundary problem
#define IN_PORT_STRING_8_16( port, addr, n)		while ( n-- ) \
	{ hcf_16 i = IN_PORT_WORD(port); *((hcf_8 FAR*)addr)++ = (hcf_8)i; *((hcf_8 FAR*)addr)++ = (hcf_8)(i>>8);}
#define OUT_PORT_STRING_8_16( port, addr, n)	while ( n-- ) \
	{ OUT_PORT_WORD( port, *((hcf_8 FAR*)addr) | *(((hcf_8 FAR*)addr)+1)<<8  ); (hcf_8 FAR*)addr+=2; }
#else												// Assembler implementation
#define IN_PORT_STRING_8_16( port, addr, n) __asm	\
{													\
	__asm push di									\
	__asm push es									\
	__asm mov cx,n									\
	__asm les di,addr								\
	__asm mov dx,port								\
	__asm rep insw									\
	__asm pop es									\
	__asm pop di									\
}

#define OUT_PORT_STRING_8_16( port, addr, n) __asm	\
{													\
	__asm push si									\
	__asm push ds									\
	__asm mov cx,n									\
	__asm lds si,addr								\
	__asm mov dx,port								\
	__asm rep outsw									\
	__asm pop ds									\
	__asm pop si									\
}

#endif // Asm or C implementation
#define IN_PORT_STRING_32( port, addr, n)	{ int n2 = 2*n; IN_PORT_STRING_8_16(port, addr, n2) }
#define OUT_PORT_STRING_32( port, addr, n)	{ int n2 = 2*n; OUT_PORT_STRING_8_16(port, addr, n2) }
#endif // 0 //temorary use functions defined in hcf.c
#endif // H_2_INC

#endif	// WVLAN_42 / WVLAN_43



/************************************************************************************************/
/****************************  D O S  H - I / II  L O A D E R  **********************************/
/************************************************************************************************/

#if defined H0_LDR || defined H1_LDR || defined H2_LDR || defined H5_LDR

#if defined H0_LDR				//implies H-I
#define HCF_DLV		0			//H-I legacy, meaningless under H-II
#define HCF_DLNV	1			//H-I legacy, meaningless under H-II
#endif // H0_LDR

#if defined H1_LDR 				//implies H-I
#define HCF_DLV		1			//H-I legacy, meaningless under H-II
#define HCF_DLNV	0			//H-I legacy, meaningless under H-II
#endif // H1_LDR / H2_LDR

//#if defined H2_LDR : not needed, H-II defaults are O.K for H2_LDR

#ifdef H5_LDR
#define HCF_TYPE			(HCF_TYPE_HII5 | HCF_TYPE_WARP )
//;? why does only this subset of the H_LDRs need HCF_TYPE to be defined here
#endif

#define HCF_ASSERT			HCF_ASSERT_LNK_MSF_RTN	//support dynamic linking of msf_assert routine
#define HCF_ENCAP			0
#define HCF_INT_ON			0
#define HCF_TALLIES			0

#define	MSF_COMPONENT_ID			COMP_ID_ODI_16 //;?By lack of any better
#define	MSF_COMPONENT_VAR			1
#define	MSF_COMPONENT_MAJOR_VER		0
#define	MSF_COMPONENT_MINOR_VER		0

#include <stdio.h>
#include <conio.h>
#if defined NDEBUG
#pragma intrinsic( _inp, _inpw, _outp, _outpw )
#endif // NDEBUG

#if 0						//use 0 to replace I/O Macros with logging facility
#define IN_PORT_WORD(port)			((hcf_16)_inpw( (hcf_io)(port) ))
#define OUT_PORT_WORD(port, value)	((void)_outpw( (hcf_io)(port), value ))
#define IN_PORT_STRING_16( port, addr, n)	\
		while ( n-- ) { *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); (cast)addr += 2; }
#define OUT_PORT_STRING_16( port, addr, n)	\
		while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ) ; (cast)addr  += 2; }
#endif						//use 0 to replace I/O Macros with logging facility

#endif	// H0_LDR / H1_LDR / H2_LDR



/************************************************************************************************/
/****************************  H C F  D E M O  P R O G R A M  ***********************************/
/************************************************************************************************/

#if defined HCF_DEMO

#define HCF_DLV		1				//;?should become the default !defaults to 1 anyway for H-II
//#define HCF_DLNV	0				//defaults to 0 anyway for H-II

#define HCF_ASSERT	HCF_ASSERT_LNK_MSF_RTN			//support dynamic linking of msf_assert routine

#define HCF_ENCAP			0
#define HCF_INT_ON			0
#define HCF_TALLIES			( HCF_TALLIES_NIC | HCF_TALLIES_HCF )

//#define	MSF_COMPONENT_ID		NO configuration management

#include <stdio.h>
#include <conio.h>
#if defined NDEBUG
#pragma intrinsic( _inp, _inpw, _outp, _outpw )
#endif // NDEBUG

#if 0						//use 0 to replace I/O Macros with logging facility
#define IN_PORT_WORD(port)			((hcf_16)_inpw( (hcf_io)(port) ))
#define OUT_PORT_WORD(port, value)	((void)_outpw( (hcf_io)(port), value ))
#define IN_PORT_STRING_16( port, addr, n)	\
		while ( n-- ) { *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); (cast)addr += 2; }
#define OUT_PORT_STRING_16( port, addr, n)	\
		while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ) ; (cast)addr  += 2; }
#endif						//use 0 to replace I/O Macros with logging facility

#endif	// HCF_DEMO



/************************************************************************************************/
/***********************************  M A C  O S   **********************************************/
/************************************************************************************************/

#if defined WVLAN_45

#include "Version.h"

#define MSF_COMPONENT_ID            COMP_ID_MAC_OS
#define MSF_COMPONENT_VAR           VARIANT
#define MSF_COMPONENT_MAJOR_VER     VERSION_MAJOR
#define MSF_COMPONENT_MINOR_VER     VERSION_MINOR

#define MAC_OS                      1

#define HCF_BIG_ENDIAN 1       		// selects Big Endian (a.k.a. Motorola), most significant byte first

#if defined DEBUG
#define HCF_ASSERT	HCF_ASSERT_MB	// logging via Mailbox
#endif // DEBUG

#ifdef  __cplusplus
extern "C" {
#endif // __cplusplus
extern volatile unsigned char *MacIOaddr;
extern hcf_16 IN_PORT_WORD(hcf_16 port);
extern void   OUT_PORT_WORD(hcf_16 port, hcf_16 value);
extern void   IN_PORT_STRING_16(hcf_16 port, void *addr, hcf_16 len);
extern void   OUT_PORT_STRING_16(hcf_16 port, void *addr, hcf_16 len);

#define SwapBytes(t)    (((t) >> 8) + (((t) & 0xff) << 8))

#ifdef  __cplusplus
}
#endif // __cplusplus

#endif  // WVLAN_45



/************************************************************************************************/
/******************************************  L I N U X  *****************************************/
/************************************************************************************************/

#ifdef WVLAN_49
#include <asm/io.h>
//#include <linux/module.h>
#include <wl_version.h>

/* The following macro ensures that no symbols are exported, minimizing the chance of a symbol
   collision in the kernel */
//EXPORT_NO_SYMBOLS;  //;?this place seems not appropriately to me

//#define HCF_SLEEP (HCF_CDS | HCF_DDS )
#define HCF_SLEEP (HCF_CDS)

//#define HCF_TYPE    (HCF_TYPE_HII5|HCF_TYPE_STA|HCF_TYPE_AP)
#ifdef HERMES25
#ifdef WARP
#define HCF_TYPE    ( HCF_TYPE_WARP | HCF_TYPE_HII5 )
#else
#define HCF_TYPE    HCF_TYPE_HII5
#endif // WARP
#else
#define HCF_TYPE    HCF_TYPE_NONE
#endif // HERMES25

#ifdef ENABLE_DMA
#define HCF_DMA		1
#endif // ENABLE_DMA

/* We now need a switch to include support for the Mailbox and other necessary extensions */
#define HCF_EXT ( HCF_EXT_MB | HCF_EXT_INFO_LOG | HCF_EXT_INT_TICK )//get deepsleep exercise going

/* ;? The Linux MSF still uses these definitions; define it here until it's removed */
#ifndef HCF_TYPE_HII
#define HCF_TYPE_HII 0x0004
#endif

#ifndef HCF_TYPE_AP
#define HCF_TYPE_AP  0x0010
#endif

#ifndef HCF_TYPE_STA
#define HCF_TYPE_STA 0x0020
#endif  // HCF_TYPE_STA

/* Guarantees word alignment */
#define HCF_ALIGN		2

/* Endian macros CNV_INT_TO_LITTLE() and CNV_LITTLE_TO_INT() were renamed to
   CNV_SHORT_TO_LITTLE() and CNV_LITTLE_TO_SHORT() */
#ifndef CNV_INT_TO_LITTLE
#define CNV_INT_TO_LITTLE   CNV_SHORT_TO_LITTLE
#endif

#ifndef CNV_LITTLE_TO_INT
#define CNV_LITTLE_TO_INT   CNV_LITTLE_TO_SHORT
#endif

#define	HCF_ERR_BUSY			0x06

/* UIL defines were removed from the HCF */
#define UIL_SUCCESS					HCF_SUCCESS
#define UIL_ERR_TIME_OUT			HCF_ERR_TIME_OUT
#define UIL_ERR_NO_NIC				HCF_ERR_NO_NIC
#define UIL_ERR_LEN					HCF_ERR_LEN
#define UIL_ERR_MIN					HCF_ERR_MAX	/*end of HCF errors which are passed through to UIL
												  *** ** *** ****** ***** *** ****** ******* ** ***  */
#define UIL_ERR_IN_USE				0x44
#define UIL_ERR_WRONG_IFB			0x46
#define UIL_ERR_MAX					0x7F		/*upper boundary of UIL errors without HCF-pendant
                                                  ***** ******** ** *** ****** ******* *** *******  */
#define UIL_ERR_BUSY			    HCF_ERR_BUSY
#define UIL_ERR_DIAG_1			    HCF_ERR_DIAG_1
#define UIL_FAILURE					0xFF	/* 20010705 nv this relick should be eridicated */
#define UIL_ERR_PIF_CONFLICT		0x40	//obsolete
#define UIL_ERR_INCOMP_DRV			0x41	//obsolete
#define UIL_ERR_DOS_CALL			0x43	//obsolete
#define UIL_ERR_NO_DRV				0x42	//obsolete
#define UIL_ERR_NSTL				0x45	//obsolete



#if 0  //;? #ifdef get this going LATER HERMES25
#define HCF_IO              HCF_IO_32BITS
#define HCF_DMA             1
#define HCF_DESC_STRCT_EXT  4

/* Switch for BusMaster DMA support. Note that the above define includes the DMA-specific HCF
   code in the build. This define sets the MSF to use DMA; if ENABLE_DMA is not defined, then
   port I/O will be used in the build */
#ifndef BUS_PCMCIA
#define ENABLE_DMA
#endif  // USE_PCMCIA

#endif  // HERMES25


/* Overrule standard WaveLAN Packet Size when in DMA mode */
#ifdef ENABLE_DMA
#define HCF_MAX_PACKET_SIZE 2304
#else
#define HCF_MAX_PACKET_SIZE 1514
#endif  // ENABLE_DMA

/* The following sets the component ID, as well as the versioning. See also wl_version.h */
#define	MSF_COMPONENT_ID	COMP_ID_LINUX

#define	MSF_COMPONENT_VAR			DRV_VARIANT
#define MSF_COMPONENT_MAJOR_VER     DRV_MAJOR_VERSION
#define MSF_COMPONENT_MINOR_VER     DRV_MINOR_VERSION

/* Define the following to turn on assertions in the HCF */
//#define HCF_ASSERT  0x8000
#define HCF_ASSERT			HCF_ASSERT_LNK_MSF_RTN	// statically binding of msf_assert routine

#ifdef USE_BIG_ENDIAN
#define HCF_BIG_ENDIAN  1
#else
#define HCF_BIG_ENDIAN  0
#endif  /* USE_BIG_ENDIAN */

/* Define the following if your system uses memory-mapped IO */
//#define HCF_MEM_IO

/* The following defines the standard macros required by the HCF to move data to/from the card */
#define IN_PORT_BYTE(port)			((hcf_8)inb( (hcf_io)(port) ))
#define IN_PORT_WORD(port)			((hcf_16)inw( (hcf_io)(port) ))
#define OUT_PORT_BYTE(port, value)	(outb( (hcf_8) (value), (hcf_io)(port) ))
#define OUT_PORT_WORD(port, value)	(outw((hcf_16) (value), (hcf_io)(port) ))

#define IN_PORT_STRING_16(port, dst, n)    insw((hcf_io)(port), dst, n)
#define OUT_PORT_STRING_16(port, src, n)   outsw((hcf_io)(port), src, n)
//#define IN_PORT_STRINGL(port, dst, n)   insl((port), (dst), (n))
//#define OUT_PORT_STRINGL(port, src, n)  outsl((port), (src), (n))
#define IN_PORT_STRING_32(port, dst, n)   insl((port), (dst), (n))
#define OUT_PORT_STRING_32(port, src, n)  outsl((port), (src), (n))
#define IN_PORT_HCF32(port)          inl( (hcf_io)(port) )
#define OUT_PORT_HCF32(port, value)  outl((hcf_32)(value), (hcf_io)(port) )

#define IN_PORT_DWORD(port)          IN_PORT_HCF32(port)
#define OUT_PORT_DWORD(port, value)  OUT_PORT_HCF32(port, value)

#define  IN_PORT_STRING_8_16(port, addr, len)	IN_PORT_STRING_16(port, addr, len)
#define  OUT_PORT_STRING_8_16(port, addr, len)	OUT_PORT_STRING_16(port, addr, len)


#ifndef OUTPUTDEBUGMSG
#define OUTPUTDEBUGMSG(dprintf_exp)
#endif


#ifndef ASSERTDEBUGMSG
#define ASSERTDEBUGMSG(cond, dprintf_exp)
#endif

#ifndef CFG_SCAN_CHANNELS_2GHZ
#define CFG_SCAN_CHANNELS_2GHZ 0xFCC2
#endif /* CFG_SCAN_CHANNELS_2GHZ */

#define HCF_MAX_MSG 1600 //get going ;?
#endif	// WVLAN_49



/************************************************************************************************/
/*********************************************  Q N X  ******************************************/
/************************************************************************************************/

#if defined  __QNX__ || defined WVLAN_50

#define MSF_COMPONENT_ID		0   //Although there is no DUI support, we need this to get ...
#define MSF_COMPONENT_VAR		0	//...compatibilty check to function
#define MSF_COMPONENT_MAJOR_VER	0	//...;?this is worth looking into to make this a more
#define MSF_COMPONENT_MINOR_VER	0	//..."defined" I/F so OEMers can figure out what to do

#include <conio.h>

#define IN_PORT_WORD(port)			((hcf_16)inpw( (hcf_io)(port) ))
#define OUT_PORT_WORD(port, value)	(outpw( (hcf_io)(port), (hcf_16) (value) ))
/*
#define IN_PORT_STRING_16( port, addr, n)	\
		while ( n-- ) { *(hcf_16*)addr = IN_PORT_WORD( port ); (cast)addr += 2; }
#define OUT_PORT_STRING_16( port, addr, n)	\
		while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16*)addr ) ; (cast)addr  += 2; }
*/

#endif	// QNX / WVLAN_50



/************************************************************************************************/
/*********************************************  B E O S  ****************************************/
/************************************************************************************************/

#if defined  __BEOS__

#define MSF_COMPONENT_ID		0   //Although there is no DUI support, we need this to get ...
#define MSF_COMPONENT_VAR		0	//...compatibilty check to function
#define MSF_COMPONENT_MAJOR_VER	0	//...;?this is worth looking into to make this a more
#define MSF_COMPONENT_MINOR_VER	0	//..."defined" I/F so OEMers can figure out what to do

#include <drivers/Drivers.h>
#include <drivers/KernelExport.h>

uint8 read_io_8 (int);
void write_io_8 (int, uint8);
uint16 read_io_16 (int);
void write_io_16 (int, uint16);

#define IN_PORT_WORD(port)			((hcf_16)read_io_16( (hcf_io)(port) ))
#define OUT_PORT_WORD(port, value)	(write_io_16( (hcf_io)(port), (hcf_16) (value) ))
/*
#define IN_PORT_STRING_16( port, addr, n)	\
		while ( n-- ) { *(hcf_16*)addr = IN_PORT_WORD( port ); (cast)addr += 2; }
#define OUT_PORT_STRING_16( port, addr, n)	\
		while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16*)addr ) ; (cast)addr  += 2; }
*/
#endif	// __BEOS__



/************************************************************************************************/
/********************************  U S B   D O N G L E  *****************************************/
/************************************************************************************************/

#if defined USB
#include "gpif.h"

#define	MSF_COMPONENT_MAJOR_VER		0
#define	MSF_COMPONENT_MINOR_VER		1

#define IN_PORT_WORD(port)			(Hermes_IO_Read( (hcf_8)(port)))
#define OUT_PORT_WORD(port, value)	(Hermes_IO_Write( (hcf_8)port, /*(hcf_16)*/(value) ) )
/* !!!! NOTE USB supports only 16-bits I/O and no 8-bits I/O
 * as a consequence the IN_/OUT_PORT_STRING_16 macros use hcf_16* rather than hcf_8 pointers
 * to get more optimal code
 * therefore the pointers are incremented by 1 (which means two "bytes") rather than by 2
 */
//#define IN_PORT_STRING_16( port, addr, n)	while ( n-- ) { *((hcf_16*)addr)++ = IN_PORT_WORD( port ); }
//#define OUT_PORT_STRING_16( port, addr, n)	while ( n-- ) { OUT_PORT_WORD( port, *((hcf_16*)addr)++ ); }
#define IN_PORT_STRING_16( port, dst, n)	while ( n-- ) { *dst++ = IN_PORT_WORD( port ); }
#define OUT_PORT_STRING_16( port, src, n)	while ( n-- ) { OUT_PORT_WORD( port, *src++ ); }

//#define HCF_TYPE	( HCF_TYPE_AP | HCF_TYPE_WPA )
#define HCF_TYPE	HCF_TYPE_WPA

#endif	// USB


/************************************************************************************************/
/******************************************  FreeBSD  *******************************************/
/************************************************************************************************/

#if defined __FREE_BSD__

#define	MSF_COMPONENT_ID			COMP_ID_FreeBSD
#define	MSF_COMPONENT_VAR			1
#define	MSF_COMPONENT_MAJOR_VER		1
#define	MSF_COMPONENT_MINOR_VER		0

#define HCF_IO 						HCF_IO_MEM		// overrule standard Port I/O with Memory mapped I/O

#include <machine/cpufunc.h>

#define IN_PORT_WORD(port)			((hcf_16)inw( (hcf_io)(port) ))
#define OUT_PORT_WORD(port, value)	(outw((hcf_io)(port), (hcf_16)(value)))

/*
#define IN_PORT_STRING_16( port, addr, n)	\
		while ( n-- ) { *(hcf_16*)addr = IN_PORT_WORD( port ); (cast)addr += 2; }
#define OUT_PORT_STRING_16( port, addr, n)	\
		while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16*)addr ) ; (cast)addr  += 2; }
*/
#endif	// __FREE_BSD__



/************************************************************************************************/
/*********************************  W A V E P O I N T  ******************************************/
/************************************************************************************************/

#if defined WVLAN_81	/* BORLANDC */

#define EXTERN_C  extern	// needed because DHF uses this instead of 'extern'

#define	MSF_COMPONENT_ID	COMP_ID_AP1
#define	MSF_COMPONENT_VAR			1
#define	MSF_COMPONENT_MAJOR_VER		4
#define	MSF_COMPONENT_MINOR_VER		0

#define HCF_PROT_TIME				49	//49*10240 microseconds H/W failure protection timer

//#define HCF_ASSERT	HCF_ASSERT_MB	// logging via Mailbox	/* debug build only */

#if !defined FAR
#define FAR  far						// segmented 16 bits mode
#endif // FAR

#define IN_PORT_WORD(port)					(inport( (hcf_io)(port) ))
#define OUT_PORT_WORD(port, value)			(outport( (hcf_io)(port), value ))

#define IN_PORT_STRING_16(port, addr, len)	\
	asm { push di; push es; mov cx,len; les di,addr; mov dx,port; rep insw; pop es; pop di }

#define OUT_PORT_STRING_16(port, addr, len)	\
	asm { push si; push ds; mov cx,len; lds si,addr; mov dx,port; rep outsw; pop ds; pop si }

#endif // WVLAN_81


/************************************************************************************************/
/********************************  W A V E L A U N C H  *****************************************/
/************************************************************************************************/

#if defined WVLAUNCH

#include "DriverX.h"
extern HWDEVICE*	g_pDevice;

//#define	MSF_COMPONENT_ID			0  //;? to get around browser problem

#define IN_PORT_WORD(port)	HwInpw( g_pDevice, port )
#define OUT_PORT_WORD(port, value)	HwOutpw( g_pDevice, port, value )


// C implementation which let the processor handle the word-at-byte-boundary problem
/*
#define IN_PORT_STRING_16( port, addr, n)	\
		while ( n-- ) { *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); (cast)addr += 2; }
#define OUT_PORT_STRING_16( port, addr, n)	\
		while ( n-- ) { OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ) ; (cast)addr  += 2; }
*/
#endif // WVLAUNCH



/************************************************************************************************/
/*************************************  W C I T S T *********************************************/
/************************************************************************************************/

#if defined WCITST
#define MSF_COMPONENT_ID		0   //Although there is no DUI support, we need this to get ...
#define MSF_COMPONENT_VAR		0	//...compatibilty check to function
#define MSF_COMPONENT_MAJOR_VER	0	//...;?this is worth looking into to make this a more
#define MSF_COMPONENT_MINOR_VER	0	//..."defined" I/F so OEMers can figure out what to do

//#define HCF_ENCAP				HCF_ENC_NONE	//to get going
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To ease testing the different options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define HCF_TYPE (HCF_TYPE_WPA | HCF_TYPE_PRELOADED) // Hermes-I for HCF6, II for HCF7
#define 		HCF_DMA				1
//#define LLB	//!!!!MIC Debug Only
#if defined LLB && !((HCF_TYPE) & HCF_TYPE_WPA)
err: no LLB unless SSN;
#endif // LLB / HCF_TYPE_WPA
//#define HCF_ALIGN 2
#define HCF_DLV		1			//just to change memory layout ????;?
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To ease testing the different options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#define HCF_ASSERT	HCF_ASSERT_SW_SUP	// logging via Hermes support registerr
//#define HCF_ASSERT		HCF_ASSERT_MB		// logging via Mailbox

#if defined __GNUC__
#include "stdio.h"
//#include "unistd.h"	//ioperm   libc5
#include "sys/io.h"	//ioperm   glibc
#define extern		//see IO Port Programming mini-HOWTO
//#include "asm/io.h"	//
#define IN_PORT_WORD(port)			inw( (hcf_io)(port) )
#define IN_PORT_DWORD(port)			inl( (hcf_io)(port) )
#define OUT_PORT_WORD(port, value)	outw( (hcf_io)(port), (hcf_16)(value) )
#define OUT_PORT_DWORD(port, value)	outl( (hcf_io)(port), (hcf_16)(value) )
#else
#pragma warning ( disable: 4001 )
#define FAR  __far					// segmented 16 bits mode

#include <stdio.h>
#include <conio.h>
#ifndef _DEBUG
#pragma intrinsic( _inp, _inpw, _outp, _outpw )
#endif // _DEBUG

#ifdef LOG
extern FILE* utm_logfile;
hcf_16	ipw( hcf_16 port );
hcf_8	ipb( hcf_16 port );
void	opw( hcf_16 port, hcf_16 value );
void	opb( hcf_16 port, hcf_8 value );

#define IN_PORT_WORD(port)			ipw( (hcf_io)(port) )
#define OUT_PORT_WORD(port, value)	opw( (hcf_io)(port), (hcf_16)(value) )
#else // LOG
#define IN_PORT_WORD(port)			((hcf_16)_inpw( (hcf_io)(port) ))
#define OUT_PORT_WORD(port, value)	((void)_outpw( (hcf_io)(port), value ))
#endif // LOG

#if 1 //ASM example
#define IN_PORT_STRING_16( port, addr, len) __asm		\
{														\
	__asm push di										\
	__asm push es										\
	__asm mov cx,len									\
	__asm les di,addr									\
	__asm mov dx,port									\
	__asm rep insw										\
	__asm pop es										\
	__asm pop di										\
}

#define OUT_PORT_STRING_16( port, addr, len) __asm		\
{														\
	__asm push si										\
	__asm push ds										\
	__asm mov cx,len									\
	__asm lds si,addr									\
	__asm mov dx,port									\
	__asm rep outsw										\
	__asm pop ds										\
	__asm pop si										\
}

#endif	// asm example

#endif // __GCC__

#if ! defined IN_PORT_STRING_16
#define IN_PORT_STRING_16( port, addr, n)  while (n--) \
	{ *(hcf_16 FAR*)addr = IN_PORT_WORD( port ); ((hcf_16 FAR*)addr)++; }
#define OUT_PORT_STRING_16( port, addr, n) while (n--) \
	{ OUT_PORT_WORD( port, *(hcf_16 FAR*)addr ); ((hcf_16 FAR*)addr)++; }
#endif // IN_PORT_STRING_16

#endif	// WCITST


/************************************************************************************************/
/*******************************  Motorola Power PC 800 family  *********************************/
/************************************************************************************************/
/* known users: LH@I
 */

#if defined I_MPC8XX

#define MSF_COMPONENT_VAR		0
#define MSF_COMPONENT_ID		0
#define MSF_COMPONENT_MAJOR_VER	1
#define MSF_COMPONENT_MINOR_VER	0

#define HCF_HSI_VAR				1

#define HCF_BIG_ENDIAN			1
#define HCF_IO 					HCF_IO_MEM		// overrule standard Port I/O with Memory mapped I/O

#include "o_portbl.h"
#include "ipcmcia.h"
typedef o_uint8_t  hcf_8;
typedef o_uint16_t hcf_16;
typedef o_uint32_t hcf_32;

/***************************************************************************/


#ifdef _lint
#else
asm hcf_16 IN_PORT_WORD(int port)
{
% reg port
    lhbrx r3,r0,port
    eieio
}
#endif // _lint


#ifdef _lint
#else
asm void OUT_PORT_WORD(int port, hcf_16 value)
{
% reg port, value
    sthbrx value,r0,port
    eieio
}
#endif // _lint

/***************************************************************************/

#define IN_PORT_STRING_16(port, addr, len)               \
   {                                                  \
      unsigned l = (len);                             \
      hcf_16 *d = (volatile hcf_16 *)(addr);          \
      while (l--)                                     \
      {                                               \
         *d++ = *(volatile hcf_16 *)(port);           \
         EIEIO();                                     \
      }                                               \
   }

#define OUT_PORT_STRING_16(port, addr, len)           \
   {                                                  \
      unsigned l = (len);                             \
      hcf_16 *s = (volatile hcf_16 *)(addr);          \
      while (l--)                                     \
      {                                               \
         *(volatile hcf_16 *)(port) = *s++;           \
         EIEIO();                                     \
      }                                               \
   }

#endif	// I_MPC8XX



/************************************************************************************************/
/**********************************   Diab or High C 29K   **************************************/
/************************************************************************************************/
/* known users: GK@C
 */

#if defined _AM29K

#define MSF_COMPONENT_VAR		0
#define MSF_COMPONENT_ID		COMP_ID_AP1
#define MSF_COMPONENT_MAJOR_VER	1
#define MSF_COMPONENT_MINOR_VER	0

#define HCF_BIG_ENDIAN			1
#define HCF_IO 					HCF_IO_MEM		// overrule standard Port I/O with Memory mapped I/O

#define SwapBytes(t)    /*lint -e572*/(((t) >> 8) + (((t) & 0xff) << 8))/*lint +e572*/

#if defined __ppc
    #ifndef __GNUC__
        #define __asm__     asm
    #endif

    #if ! defined _lint
        #define EIEIO()     __asm__(" eieio")
    #else
        #define EIEIO()
    #endif

    static hcf_16 IN_PORT_WORD(int port) {
        hcf_16 value = *(volatile hcf_16 *)(port); EIEIO();
        value = SwapBytes(value);
        return value;
    }

    #define OUT_PORT_WORD(port, value)      \
            { *(volatile hcf_16 *)(port) = SwapBytes(value); EIEIO(); }
#else
    #define IN_PORT_WORD(port) (*(volatile hcf_16 *)(port))
    #define OUT_PORT_WORD(port, value) (*(volatile hcf_16 *)(port) = (value))
#endif // __ppc

/***************************************************************************/

#define IN_PORT_STRING_16( port, addr, len)        {                       \
                        unsigned l = (len);                             \
                        hcf_16 t, *d = (volatile hcf_16 *)(addr);       \
                        while (l--) {                                   \
                            t = IN_PORT_WORD(port);                     \
                            *d++ = SwapBytes(t);                        \
                        }                                               \
                                                }

#define OUT_PORT_STRING_16( port, addr, len)        {                       \
                        unsigned l = (len);                             \
                        hcf_16 t, *s = (volatile hcf_16 *)(addr);        \
                        while (l--) {                                   \
                            t = *s++;                                   \
                            OUT_PORT_WORD(port, SwapBytes(t));          \
                        }                                               \
                                                }

#if PRODUCT == 9150
    #define HCF_ASSERT	HCF_ASSERT_MB	// logging via Mailbox
    #undef MSF_COMPONENT_ID
#endif // 9150

#endif	// _AM29K



/************************************************************************************************/
/*****************************************  MPC860 **********************************************/
/************************************************************************************************/
/* known users: RR
 */

#if defined CPU
#if CPU == PPC860

#define MSF_COMPONENT_VAR		0
#define MSF_COMPONENT_ID		0
#define MSF_COMPONENT_MAJOR_VER	1
#define MSF_COMPONENT_MINOR_VER	0

#define HCF_BIG_ENDIAN			1
#define HCF_IO 					HCF_IO_MEM		// overrule standard Port I/O with Memory mapped I/O

#define SwapBytes(t)    /*lint -e572*/(((t) >> 8) + (((t) & 0xff) << 8))/*lint +e572*/

#ifndef __GNUC__
    #define __asm__     asm
#endif

#if ! defined _lint
    #define EIEIO()     __asm__(" eieio")
#else
    #define EIEIO()
#endif

static hcf_16 IN_PORT_WORD(int port) {
    hcf_16 value = *(volatile hcf_16 *)(port); EIEIO();
    value = SwapBytes(value);
    return value;
    #ifdef __GNUC__
        /* the following serves to avoid the compiler warnings that
         * IN_PORT_WORD() is not used in some files */
        (void)IN_PORT_WORD;
    #endif
}

#define OUT_PORT_WORD(port, value)      \
        { *(volatile hcf_16 *)(port) = SwapBytes(value); EIEIO(); }

/***************************************************************************/

#define IN_PORT_STRING_16( port, addr, len)        {                       \
                        unsigned l = (len);                             \
                        hcf_16 t;                                       \
                        volatile hcf_16 *d = (volatile hcf_16 *)(addr); \
                        while (l--) {                                   \
                            t = IN_PORT_WORD(port);                     \
                            *d++ = SwapBytes(t);                        \
                        }                                               \
                                                }

#define OUT_PORT_STRING_16( port, addr, len)        {                       \
                        unsigned l = (len);                             \
                        hcf_16 t;                                       \
                        volatile hcf_16 *s = (volatile hcf_16 *)(addr);  \
                        while (l--) {                                   \
                            t = *s++;                                   \
                            OUT_PORT_WORD(port, SwapBytes(t));          \
                        }                                               \
                                                }

#if PRODUCT == 9150
    #define HCF_ASSERT	HCF_ASSERT_MB	// logging via Mailbox
    #undef MSF_COMPONENT_ID
#endif

#endif	/* PPC860 */
#endif	/* CPU */



/************************************************************************************************/
/****************************  Microtec Research 80X86 Compiler *********************************/
/************************************************************************************************/

#if 0

//#undef HCF_TYPE									// Hermes-I Station F/W without SSN support

#define MSF_COMPONENT_VAR       0
#define MSF_COMPONENT_ID        0
#define MSF_COMPONENT_MAJOR_VER 1
#define MSF_COMPONENT_MINOR_VER 0

extern int far inp( int );
extern void far outp( int, int );
extern int far inpw( int );
extern void far outpw( int, int );

#define IN_PORT_WORD(port)		((hcf_16)inpw( (hcf_io)(port) ))
#define OUT_PORT_WORD(port, value)	((void)outpw( (hcf_io)(port), value ))

#define IN_PORT_STRING_16( port, addr, len)        {                       \
                        unsigned l = (len);                             \
                        hcf_16 *d = (hcf_16 *)(addr);                   \
                        while (l--) *d++ =  IN_PORT_WORD(port);         \
                                                }

#define OUT_PORT_STRING_16( port, addr, len)        {                       \
                        unsigned l = (len);                             \
                        hcf_16 *s = (hcf_16 *)(addr);                    \
                        while (l--) OUT_PORT_WORD(port, *s++);          \
                                                }
#endif	/* Microtec 80X86 C Compiler */



/************************************************************************************************/
/******************************  W A V E L A N  E C  ********************************************/
/************************************************************************************************/
/* known users: KM
 */

#ifdef mc68302

#define	MSF_COMPONENT_ID			COMP_ID_EC

#include <version.h>

#define	MSF_COMPONENT_VAR			1
#define	MSF_COMPONENT_MAJOR_VER		MAJOR_VERSION
#define	MSF_COMPONENT_MINOR_VER		MINOR_VERSION

#define HCF_BIG_ENDIAN				1
#define HCF_IO 						HCF_IO_MEM		// overrule standard Port I/O with Memory mapped I/O

#define SwapBytes(t)	/*lint -e572*/(((t) >> 8) + (((t) & 0xff) << 8))/*lint +e572*/

#define PCMCIA_ADDRESS 0xc80000UL

#define IN_PORT_2BYTES(port)			 (*(hcf_16 *)(port))
#if 0
static hcf_16 IN_PORT_WORD(hcf_32 port) // should be hcf_io, not hcf_32
{
  hcf_16 word = IN_PORT_2BYTES(port);
  return SwapBytes(word);
}
#else
static hcf_16 swap_var;
#define IN_PORT_WORD(port) \
  (((swap_var = IN_PORT_2BYTES(port)) >> 8) + (((swap_var) & 0xff) << 8))
#endif
#define OUT_PORT_2BYTES(port, value)	 (*(hcf_16 *)(port) = (hcf_16)(value))
#define OUT_PORT_WORD(port, value)		 OUT_PORT_2BYTES(port, SwapBytes(value))

/*
#define IN_PORT_STRING_16(port, addr, len)	  \
	while ((len)--) {*(hcf_16 *)(addr) = IN_PORT_2BYTES(port); ((cast)addr) += 2; }
#define OUT_PORT_STRING_16(port, addr, len)	  \
	while ((len)--) {OUT_PORT_2BYTES((port), *(hcf_16 *)(addr)) ; ((cast)addr)  += 2; }
*/

#endif	/* mc68302 */



/************************************************************************************************/
/*********************************  NGAP   ***************************************/
/************************************************************************************************/

#if defined __VX_WORKS__	/* VxWorks */

#if defined WLC_STATION
//#undef HCF_TYPE 				/* Hermes-I Station F/W without SSN support */
#define MSF_COMPONENT_ID	COMP_ID_VX_WORKS_ENDSTA
#else
#define MSF_COMPONENT_ID	COMP_ID_VX_WORKS_ENDAP
#endif	// WLC_STATION

#define HCF_YIELD (taskDelay(0) == 0)

#define    MSF_COMPONENT_VAR              1
#define    MSF_COMPONENT_MAJOR_VER        1
#define    MSF_COMPONENT_MINOR_VER        0

// #define HCF_ASSERT	HCF_ASSERT_MB	// logging via Mailbox

#if defined PC486BSP

#define IN_PORT_WORD(port)            (sysInWord ((hcf_io)(port)))
#define OUT_PORT_WORD(port, value)        (sysOutWord ((hcf_io)(port), (hcf_16) (value)))
#define IN_PORT_STRING_16(port, addr, n)        (sysInWordString ((hcf_io)(port), addr, n))
#define OUT_PORT_STRING_16(port, addr, n)        (sysOutWordString ((hcf_io)(port), addr, n))

#elif defined AS2000BSP

#define HCF_IO 						HCF_IO_MEM		// overrule standard Port I/O with Memory mapped I/O

/* Define PCI stuff here. */
unsigned short sysRead16( unsigned short *port );
void sysWrite16( unsigned short *port, unsigned short value );

#define PCI_IN_BYTE( port ) \
	*(unsigned char *)( port )

#define PCI_IN_WORD( port ) \
	sysRead16( (unsigned short *)( port ) )

#define PCI_OUT_BYTE( port, value ) \
	*(unsigned char *)( port ) = (unsigned char)( value )

#define PCI_OUT_WORD( port, value ) \
	sysWrite16( (unsigned short *)( port ), (unsigned short)( value ) )

#define IN_PORT_WORD( port ) \
	PCI_IN_WORD( port )

#define OUT_PORT_WORD( port, value ) \
	PCI_OUT_WORD( port, value )

#define IN_PORT_STRING_16( port, buf, len ) \
	do { \
		hcf_16 *p; \
	 \
	 	for ( p = (hcf_16 *)(buf); p < &( (hcf_16 *)(buf) )[ (int)len ]; p++ ) { \
			*p = PCI_IN_WORD( port ); \
		} \
	} while ( 0 )

#define OUT_PORT_STRING_16( port, buf, len ) \
	do { \
		const hcf_16 *p; \
	 \
	 	for ( p = (const hcf_16 *)( buf ); p < &( (const hcf_16 *)(buf) )[ (int)len ]; p++ ) { \
			PCI_OUT_WORD( port, *p ); \
		} \
	} while ( 0 )

#elif defined FADS860BSP /* elif defined AS2000BSP */

#define HCF_BIG_ENDIAN 1

#define HCF_IO 						HCF_IO_MEM		// overrule standard Port I/O with Memory mapped I/O

#ifndef __GNUC__
    #define __asm__     asm
#endif

#if ! defined _lint
    #define EIEIO()     __asm__(" eieio")
#else
    #define EIEIO()
#endif

static hcf_16 IN_PORT_WORD(int port) {
    hcf_16 value = *(volatile hcf_16 *)(port); EIEIO();
    value = ((value & 0xff00) >> 8) + ((value & 0x00ff) << 8);
/*  value = CNV_LITTLE_TO_SHORT(value); */
    return value;
    #ifdef __GNUC__
        /* the following serves to avoid the compiler warnings that
         * IN_PORT_WORD() is not used in some files */
        (void)IN_PORT_WORD;
    #endif
}

#define OUT_PORT_WORD(port, value)                                      \
        { *(volatile hcf_16 *)(port) = CNV_SHORT_TO_LITTLE(value); EIEIO(); }

/***********************************************************************/

#define IN_PORT_STRING_16( port, addr, len)        {                       \
                        unsigned l = (len);                             \
                        volatile hcf_16 *d = (volatile hcf_16 *)(addr); \
                        while (l--) {                                   \
                            *d++ = *(volatile hcf_16 *)(port);          \
                            EIEIO();                                    \
                        }                                               \
                                                }

#define OUT_PORT_STRING_16( port, addr, len)        {                       \
                        unsigned l = (len);                             \
                        volatile hcf_16 *s = (volatile hcf_16 *)(addr);  \
                        while (l--) {                                   \
                            *(volatile hcf_16 *)(port) = *s++;          \
                            EIEIO();                                    \
                        }                                               \
                                                }

#elif defined DAYTONABSP

#define HCF_BIG_ENDIAN 1

#define HCF_IO 						HCF_IO_MEM		// overrule standard Port I/O with Memory mapped I/O

#ifndef __GNUC__
    #define __asm__     asm
#endif

#define IN_PORT_WORD(port)              (sysOrinocoInWord((unsigned long)(port)))
#define OUT_PORT_WORD(port,value)       (sysOrinocoOutWord((unsigned long)(port), (unsigned short)(value)))

#define IN_PORT_STRING_16(port,addr,len)   (sysOrinocoInString((port), (addr), (len)))
#define OUT_PORT_STRING_16(port,addr,len)   (sysOrinocoOutString((port), (addr), (len)))

extern unsigned char    sysOrinocoInByte    (unsigned long port);
extern unsigned short   sysOrinocoInWord    (unsigned long port);
extern void             sysOrinocoInString  (unsigned long port, void *addr, unsigned short len);

extern void             sysOrinocoOutByte   (unsigned long port, unsigned char value);
extern void             sysOrinocoOutWord   (unsigned long port, unsigned short value);
extern void             sysOrinocoOutString (unsigned long port, void *addr, unsigned short len);

#elif defined ALPHA_BSP

#define HCF_BIG_ENDIAN 1

#define HCF_IO 						HCF_IO_MEM		// overrule standard Port I/O with Memory mapped I/O

#ifndef __GNUC__
    #define __asm__     asm
#endif

#define IN_PORT_WORD(port)              (sysOrinocoInWord((unsigned long)(port)))
#define OUT_PORT_WORD(port,value)       (sysOrinocoOutWord((unsigned long)(port), (unsigned short)(value)))

#define IN_PORT_STRING_16(port,addr,len)   (sysOrinocoInString((port), (addr), (len)))
#define OUT_PORT_STRING_16(port,addr,len)   (sysOrinocoOutString((port), (addr), (len)))

extern unsigned char    sysOrinocoInByte    (unsigned long port);
extern unsigned short   sysOrinocoInWord    (unsigned long port);
extern void             sysOrinocoInString  (unsigned long port, void *addr, unsigned short len);

extern void             sysOrinocoOutByte   (unsigned long port, unsigned char value);
extern void             sysOrinocoOutWord   (unsigned long port, unsigned short value);
extern void             sysOrinocoOutString (unsigned long port, void *addr, unsigned short len);

#else

err: /* commented here */ /*	"BSP is not defined..." */

#endif	/* else PC486BSP */

#endif	// __VX_WORKS__



/************************************************************************************************/
/******************************  VXWORKS. Motorola Sandpoint PowerPC 824X ***********************/
/************************************************************************************************/
#ifdef __VX_WORKS_SANDPOINT_824X__

#include <vxWorks.h>
#include <sysLib.h>
#include <taskLib.h>

#ifdef WVLAN_53
#define	MSF_COMPONENT_ID            COMP_ID_VX_WORKS_ENDSTA
#endif /* WVLAN_53 */

#ifdef WVLAN_54
#define	MSF_COMPONENT_ID            COMP_ID_VX_WORKS_ENDAP
#endif /* WVLAN_54 */

#ifdef WVLAN_56
#define	MSF_COMPONENT_ID            COMP_ID_VX_WORKS_END
#endif /* WVLAN_56 */

#if !defined MSF_COMPONENT_ID
#error "you must define an MSF component ID: WVLAN_53, WVLAN_54, WVLAN_56"
#endif

#define	MSF_COMPONENT_VAR			1

#define HCF_EXT                         HCF_EXT_INFO_LOG
#define HCF_SLEEP                       ( HCF_CDS | HCF_DDS )
//#define HCF_SLEEP                       ( HCF_DDS )

#ifndef HCF_ACT_WAKEUP
#define HCF_ACT_WAKEUP                  0x1D
#endif // HCF_ACT_WAKEUP

#if defined FATNIC | defined BEAGLE_H253
#define T1__HCF_TYPE                    HCF_TYPE_STA
#else
#define T1__HCF_TYPE                    HCF_TYPE_AP | HCF_TYPE_STA
#endif

#ifdef HERMES_USB
#define T2__HCF_TYPE					(T1__HCF_TYPE | HCF_TYPE_USB)
#else // HERMES_USB
#define T2__HCF_TYPE					(T1__HCF_TYPE)
#endif // HERMES_USB

#ifdef _WARP
#define T3__HCF_TYPE					(T2__HCF_TYPE | HCF_TYPE_HII5)
#else // _WARP
#define T3__HCF_TYPE					(T2__HCF_TYPE | HCF_TYPE_WPA | HCF_TYPE_HII)
#endif // WARP

#ifdef _CCX
#define T4__HCF_TYPE					(T3__HCF_TYPE | HCF_TYPE_CCX)
#else // _WARP
#define T4__HCF_TYPE					(T3__HCF_TYPE)
#endif // _CCX

#define T5__HCF_TYPE					(T4__HCF_TYPE)

// Default to TYPE_AP + SSN!
#define HCF_TYPE						(T5__HCF_TYPE )



#define	MSF_COMPONENT_MAJOR_VER		2
#define	MSF_COMPONENT_MINOR_VER		0

#define HCF_IO                      HCF_IO_MEM
#define HCF_DMA                     0
#define HCF_MEM_IO                  1
#define HCF_BIG_ENDIAN              1

//#define support_32bits 1

#define IN_PORT_WORD(port)			        (sysInWord( (hcf_io)(port) ))
#define OUT_PORT_WORD(port, value)	        (sysOutWord( (hcf_io)(port), (hcf_16)(value) ))
#define IN_PORT_DWORD(port)			        (sysInLong( (hcf_io)(port) ))
#define OUT_PORT_DWORD(port, value)	        (sysOutLong( (hcf_io)(port), (hcf_16)(value) ))
#define IN_PORT_STRING_16(port, dst, n)	    (sysInWordString((hcf_io)(port), (hcf_16 *)dst, n))
#define OUT_PORT_STRING_16(port, src, n)    (sysOutWordString((hcf_io)(port), (hcf_16 *)src, n))

#ifdef WVLAN_DEBUG
#define DBG                         1
#define _DEBUG                      1
#endif

/* we'll need to add these prints someday */
#define OUTPUTDEBUGMSG(dprintf_exp)
#define ASSERTDEBUGMSG(cond, dprintf_exp)

#define HCF_INTERFACE_CONNECT(ifbp)
#define HCF_INTERFACE_DISCONNECT(ifbp)
#define HCF_ENTER_INTERFACE_FUNCT(ibfb)
#define HCF_LEAVE_INTERFACE_FUNCT(ifbp)

#define CNV_END_INT(w)    ( ((hcf_16)(w) & 0x00FF) << 8 | ((hcf_16)(w) & 0xFF00) >> 8 )
#define CNV_LITTLE_TO_INT(w)	CNV_END_INT(w)
#define CNV_INT_TO_LITTLE(w)	CNV_LITTLE_TO_INT(w)

#endif /* __VX_WORKS_SANDPOINT_824X__ */

/************************************************************************************************/
/*************************************  VXWORKS. ARM T8300 IPPhone  *****************************/
/************************************************************************************************/
#if defined( IPT_T8300 ) || defined( IPT_T8307 )

#include <vxWorks.h>
#include <sysLib.h>
#include <taskLib.h>

#define HCF_ALIGN                   4       /* default to 4 byte alignment */

#define BEAGLE_H253	/* Hermes 2.5.3 build, better to be in the project file */
#define OOR_DDS		/* Hermes 2.5.3 build, better to be in the project file */
#define FATNIC


#ifdef WVLAN_53
#define	MSF_COMPONENT_ID            COMP_ID_VX_WORKS_ENDSTA
#endif /* WVLAN_53 */

#ifdef WVLAN_54
#define	MSF_COMPONENT_ID            COMP_ID_VX_WORKS_ENDAP
#endif /* WVLAN_54 */

#ifdef WVLAN_56
#define	MSF_COMPONENT_ID            COMP_ID_VX_WORKS_END
#endif /* WVLAN_56 */

#if !defined MSF_COMPONENT_ID
#error "you must define an MSF component ID: WVLAN_53, WVLAN_54, WVLAN_56"
#endif

#define	MSF_COMPONENT_VAR			1

#define HCF_EXT                         HCF_EXT_INFO_LOG
//#define HCF_EXT                         HCF_EXT_INFO_LOG | HCF_EXT_MB
#define HCF_SLEEP                       ( HCF_CDS | HCF_DDS )
//#define HCF_SLEEP                       ( HCF_DDS )

#ifndef HCF_ACT_WAKEUP
#define HCF_ACT_WAKEUP                  0x1D
#endif // HCF_ACT_WAKEUP

#if defined FATNIC || defined BEAGLE_H253
#define T1__HCF_TYPE                    HCF_TYPE_STA
#else
//#define T1__HCF_TYPE                    HCF_TYPE_AP | HCF_TYPE_STA
#define T1__HCF_TYPE                    HCF_TYPE_STA		/* dz, Station code only */
#endif

#ifdef HERMES_USB
#define T2__HCF_TYPE					(T1__HCF_TYPE | HCF_TYPE_USB)
#else // HERMES_USB
#define T2__HCF_TYPE					(T1__HCF_TYPE)
#endif // HERMES_USB

#ifdef _WARP
#define T3__HCF_TYPE					(T2__HCF_TYPE | HCF_TYPE_HII5)
#else // _WARP
#define T3__HCF_TYPE					(T2__HCF_TYPE | HCF_TYPE_WPA | HCF_TYPE_HII)
//#define T3__HCF_TYPE					(T2__HCF_TYPE | HCF_TYPE_HII)	/* dz. no WPA support at this time, test code */
#endif // WARP

#ifdef _CCX
#define T4__HCF_TYPE					(T3__HCF_TYPE | HCF_TYPE_CCX)
#else // _WARP
#define T4__HCF_TYPE					(T3__HCF_TYPE)
#endif // _CCX

#define T5__HCF_TYPE					(T4__HCF_TYPE)

// Default to TYPE_AP + SSN!
#define HCF_TYPE						(T5__HCF_TYPE )


#define	MSF_COMPONENT_MAJOR_VER		2
#define	MSF_COMPONENT_MINOR_VER		0

#define HCF_IO                      HCF_IO_MEM
#define HCF_DMA                     0
#define HCF_MEM_IO                  1


/* Endian is determined by vxWorks project compile option */
#if (_BYTE_ORDER == _BIG_ENDIAN)
#undef  HCF_LITTLE_ENDIAN
#define HCF_BIG_ENDIAN              1
#endif


#define CNV_END(w)    ( ((hcf_16)(w) & 0x00FF) << 8 | ((hcf_16)(w) & 0xFF00) >> 8 )
#if defined HCF_BIG_ENDIAN
//******************************************** B I G   E N D I A N *******************************************
#define CNV_LITTLE_TO_INT(w)    CNV_END(w)	//    endianess conversion needed
#define CNV_BIG_TO_INT(w)		(w)			// no endianess conversion needed
#else
//****************************************** L I T T L E   E N D I A N ****************************************
#define CNV_LITTLE_TO_INT(w) 	(w)			// no endianess conversion needed
#define CNV_BIG_TO_INT(w)       CNV_END(w)	//    endianess conversion needed
#endif // HCF_BIG_ENDIAN

// conversion macros which can be expressed in other macros
#define CNV_INT_TO_LITTLE(w)	CNV_LITTLE_TO_INT(w)
#define CNV_INT_TO_BIG(w)		CNV_BIG_TO_INT(w)



#define IN_PORT_WORD( port )            *((volatile hcf_16 *)( port ))
#define OUT_PORT_WORD( port, value )    *((volatile hcf_16 *)( port )) = ((hcf_16)( value ))
//#define IN_PORT_BYTE( port )            *((volatile hcf_8 *)( port ))

#define IN_PORT_STRING( port, addr, len) {		\
	unsigned l = len;								\
	hcf_16  *d = (hcf_16 *)(addr);					\
	hcf_16   t;										\
	while (l--) {									\
		t = IN_PORT_WORD(port);						\
		*d++ = CNV_LITTLE_TO_INT(t);				\
	}												\
} // IN_PORT_STRING

#define OUT_PORT_STRING( port, addr, len) {		\
	unsigned l = (len);								\
	hcf_16  *s = (hcf_16 *)(addr);					\
	hcf_16   t;										\
	while (l--) {									\
		t = *s++;									\
		t = CNV_LITTLE_TO_INT(t);					\
		OUT_PORT_WORD(port, t);						\
	}												\
} // OUT_PORT_STRING

#define IN_PORT_STRING_16(port, dst, n)	    {	\
	unsigned l = (n);								\
	hcf_16  *d = (hcf_16 *)(dst);					\
	while (l--) {									\
		*d++ = IN_PORT_WORD(port);					\
	}												\
} // IN_PORT_STRING_16

#define OUT_PORT_STRING_16(port, src, n)	{	\
	hcf_16   t;										\
	int l = (n);									\
	hcf_16  *s = (hcf_16 *)(src);					\
	while (l--) {									\
		t = *s++;									\
		OUT_PORT_WORD(port, t);						\
	}												\
} // OUT_PORT_STRING_16

/* #define HCF_YIELD                       (taskDelay(0) == 0) */



#ifdef WVLAN_DEBUG
#define DBG                         1
#define _DEBUG                      1
#endif

/* we'll need to add these prints someday */
#define OUTPUTDEBUGMSG(dprintf_exp)
#define ASSERTDEBUGMSG(cond, dprintf_exp)

#define HCF_INTERFACE_CONNECT(ifbp)
#define HCF_INTERFACE_DISCONNECT(ifbp)
#define HCF_ENTER_INTERFACE_FUNCT(ibfb)
#define HCF_LEAVE_INTERFACE_FUNCT(ifbp)

#define sysInWord(offsetAddr)  IN_PORT_WORD(offsetAddr)
#define sysInByte(offsetAddr)  IN_PORT_BYTE(offsetAddr)
#define sysOutWord(addr, value) OUT_PORT_WORD(addr, value)

#endif /*IPT_T8300 */

/************************************************************************************************************/
/***********************************                                   **************************************/
/************************************************************************************************************/
#if ! defined 	HCF_ALIGN
#define 		HCF_ALIGN			1		//default to no alignment
#endif // 		HCF_ALIGN

#if ! defined 	HCF_ASSERT
#define 		HCF_ASSERT			0
#endif //		HCF_ASSERT

#if ! defined	HCF_BIG_ENDIAN
#define 		HCF_BIG_ENDIAN		0
#endif // 		HCF_BIG_ENDIAN

#if ! defined	HCF_DL_ONLY
#define 		HCF_DL_ONLY			0
#endif // 		HCF_DL_ONLY

#if ! defined	HCF_DMA
#define 		HCF_DMA				0
#endif // 		HCF_DMA

#if ! defined	HCF_ENCAP
#define			HCF_ENCAP			HCF_ENC
#endif //		HCF_ENCAP

#if ! defined	HCF_ENTRY
#define			HCF_ENTRY( ifbp )
#endif //		HCF_ENTRY

#if ! defined	HCF_EXIT
#define			HCF_EXIT( ifbp )
#endif //		HCF_EXIT

#if ! defined	HCF_EXT
#define			HCF_EXT				0
#endif //		HCF_EXT

#if ! defined	HCF_INT_ON
#define			HCF_INT_ON			1
#endif //		HCF_INT_ON

#if ! defined	HCF_IO
#define			HCF_IO				0		//default 16 bits support only, port I/O
#endif //		HCF_IO

#if ! defined	HCF_LEGACY
#define			HCF_LEGACY			0
#endif //		HCF_LEGACY

#if ! defined	HCF_MAX_LTV
#define 		HCF_MAX_LTV			1200	// sufficient for all known purposes
#endif //		HCF_MAX_LTV

#if ! defined	HCF_PROT_TIME
#define 		HCF_PROT_TIME		100		// number of 10K microsec protection timer against H/W malfunction
#endif // 		HCF_PROT_TIME

#if ! defined	HCF_SLEEP
#define			HCF_SLEEP			0
#endif //		HCF_SLEEP

#if ! defined	HCF_TALLIES
#define			HCF_TALLIES			( HCF_TALLIES_NIC | HCF_TALLIES_HCF )
#endif //		HCF_TALLIES

#if ! defined 	HCF_TYPE
#define 		HCF_TYPE 			0
#endif //		HCF_TYPE

#if				HCF_BIG_ENDIAN
#undef			HCF_BIG_ENDIAN
#define			HCF_BIG_ENDIAN		1		//just for convenience of generating cfg_hcf_opt
#endif //	 	HCF_BIG_ENDIAN

#if				HCF_DL_ONLY
#undef			HCF_DL_ONLY
#define			HCF_DL_ONLY			1		//just for convenience of generating cfg_hcf_opt
#endif //		HCF_DL_ONLY

#if				HCF_DMA
#undef			HCF_DMA
#define			HCF_DMA				1		//just for convenience of generating cfg_hcf_opt
#endif //		HCF_DMA

#if				HCF_INT_ON
#undef			HCF_INT_ON
#define			HCF_INT_ON			1		//just for convenience of generating cfg_hcf_opt
#endif //		HCF_INT_ON


#if ! defined IN_PORT_STRING_8_16
#define  IN_PORT_STRING_8_16(port, addr, len)	IN_PORT_STRING_16(port, addr, len)
#define  OUT_PORT_STRING_8_16(port, addr, len)	OUT_PORT_STRING_16(port, addr, len)
#endif // IN_PORT_STRING_8_16

/************************************************************************************************/
/**********                                                                         *************/
/************************************************************************************************/

#if ! defined	FAR
#define 		FAR						// default to flat 32-bits code
#endif // 		FAR

typedef hcf_8  FAR *wci_bufp;			// segmented 16-bits or flat 32-bits pointer to 8 bits unit
typedef hcf_16 FAR *wci_recordp;		// segmented 16-bits or flat 32-bits pointer to 16 bits unit

/*	I/O Address size
*	Platforms which use port mapped I/O will (in general) have a 64k I/O space, conveniently expressed in a
*	16-bits quantity
*	Platforms which use memory mapped I/O will (in general) have an I/O space much larger than 64k, and need a
*	32-bits quantity to express the I/O base
*/

#if HCF_IO & HCF_IO_MEM
typedef hcf_32 hcf_io;
#else
typedef hcf_16 hcf_io;
#endif //HCF_IO

#if 	HCF_PROT_TIME > 128
#define HCF_PROT_TIME_SHFT	3
#define HCF_PROT_TIME_DIV	8
#elif 	HCF_PROT_TIME > 64
#define HCF_PROT_TIME_SHFT	2
#define HCF_PROT_TIME_DIV	4
#elif 	HCF_PROT_TIME > 32
#define HCF_PROT_TIME_SHFT	1
#define HCF_PROT_TIME_DIV	2
#else //HCF_PROT_TIME >= 19
#define HCF_PROT_TIME_SHFT	0
#define HCF_PROT_TIME_DIV	1
#endif

#define HCF_PROT_TIME_CNT (HCF_PROT_TIME / HCF_PROT_TIME_DIV)


/************************************************************************************************************/
/******************************************* . . . . . . . . .  *********************************************/
/************************************************************************************************************/

/* MSF_COMPONENT_ID is used to define the CFG_IDENTITY_STRCT in HCF.C
* CFG_IDENTITY_STRCT is defined in HCF.C purely based on convenience arguments.
* The HCF can not have the knowledge to determine the ComponentId field of the Identity record (aka as
* Version Record), therefore the MSF part of the Drivers must supply this value via the System Constant
* MSF_COMPONENT_ID.
* There is a set of values predefined in MDD.H (format COMP_ID_.....)
*
* Note that taking MSF_COMPONENT_ID as a default value for DUI_COMPAT_VAR is purely an implementation
* convenience, the numerical values of these two quantities have none functional relationship whatsoever.
*/

#if defined	MSF_COMPONENT_ID

#if ! defined	DUI_COMPAT_VAR
#define			DUI_COMPAT_VAR		MSF_COMPONENT_ID
#endif //		DUI_COMPAT_VAR

#if ! defined	DUI_COMPAT_BOT		//;?this way utilities can lower as well raise the bottom
#define			DUI_COMPAT_BOT		8
#endif //		DUI_COMPAT_BOT

#if ! defined	DUI_COMPAT_TOP		//;?this way utilities can lower as well raise the top
#define			DUI_COMPAT_TOP       8
#endif //		DUI_COMPAT_TOP

#endif // MSF_COMPONENT_ID

#if (HCF_TYPE) & HCF_TYPE_HII5

#if ! defined	HCF_HSI_VAR_5
#define			HCF_HSI_VAR_5
#endif //		HCF_HSI_VAR_5

#if ! defined	HCF_APF_VAR_4
#define			HCF_APF_VAR_4
#endif //		HCF_APF_VAR_4

#if (HCF_TYPE) & HCF_TYPE_WARP
#if ! defined	HCF_STA_VAR_4
#define			HCF_STA_VAR_4
#endif //		HCF_STA_VAR_4
#else
#if ! defined	HCF_STA_VAR_2
#define			HCF_STA_VAR_2
#endif //		HCF_STA_VAR_2
#endif

#if defined HCF_HSI_VAR_4
err: HSI variants 4 correspond with HII;
#endif // HCF_HSI_VAR_4

#else

#if ! defined	HCF_HSI_VAR_4
#define			HCF_HSI_VAR_4		//Hermes-II all types (for the time being!)
#endif //		HCF_HSI_VAR_4

#if ! defined	HCF_APF_VAR_2
#define 		HCF_APF_VAR_2
#endif //		HCF_APF_VAR_2

#if ! defined	HCF_STA_VAR_2
#define			HCF_STA_VAR_2
#endif //		HCF_STA_VAR_2

#endif // HCF_TYPE_HII5

#if ! defined	HCF_PRI_VAR_3
#define		HCF_PRI_VAR_3
#endif //		HCF_PRI_VAR_3

#if defined HCF_HSI_VAR_1 || defined HCF_HSI_VAR_2 || defined HCF_HSI_VAR_3
err: HSI variants 1, 2 and 3 correspond with H-I only;
#endif // HCF_HSI_VAR_1, HCF_HSI_VAR_2, HCF_HSI_VAR_3

#if defined HCF_PRI_VAR_1 || defined HCF_PRI_VAR_2
err: primary variants 1 and 2 correspond with H-I only;
#endif // HCF_PRI_VAR_1 / HCF_PRI_VAR_2


/************************************************************************************************************/
/******************************************* . . . . . . . . .  *********************************************/
/************************************************************************************************************/


/* The BASED customization macro is used to resolves the SS!=DS conflict for the Interrupt Service logic in
 * DOS Drivers. Due to the cumbersomeness of mixing C and assembler local BASED variables still end up in the
 * wrong segment. The workaround is that the HCF uses only global BASED variables or IFB-based variables.
 * The "BASED" construction (supposedly) only amounts to something in the small memory model.
 *
 * Note that the whole BASED rigmarole is needlessly complicated because both the Microsoft Compiler and
 * Linker are unnecessary restrictive in what far pointer manipulation they allow
 */

#if ! defined	BASED
#define 		BASED
#endif //		BASED

#if ! defined	EXTERN_C
#ifdef __cplusplus
#define			EXTERN_C extern "C"
#else
#define			EXTERN_C
#endif // __cplusplus
#endif //		EXTERN_C

#if ! defined	NULL
#define			NULL	((void *) 0)
#endif //		NULL

#if ! defined	TEXT
#define			TEXT(x)	x
#endif //		TEXT

#if !defined	_TCHAR_DEFINED
#define 		TCHAR	char
#endif //		_TCHAR_DEFINED

/************************************************************************************************************/
/*********************** C O N F L I C T   D E T E C T I O N  &  R E S O L U T I O N ************************/
/************************************************************************************************************/
#if defined HCF_LITTLE_ENDIAN
err: HCF_LITTLE_ENDIAN is obsolete;
#endif // 	HCF_LITTLE_ENDIAN

#if defined HCF_INT_OFF
err: HCF_INT_OFF is obsolete;
#endif //HCF_INT_OFF

#if HCF_ALIGN != 1 && HCF_ALIGN != 2 && HCF_ALIGN != 4 && HCF_ALIGN != 8
err: invalid value for HCF_ALIGN;
#endif // HCF_ALIGN

#if (HCF_ASSERT) & ~( HCF_ASSERT_PRINTF | HCF_ASSERT_SW_SUP | HCF_ASSERT_MB | HCF_ASSERT_RT_MSF_RTN | \
					  HCF_ASSERT_LNK_MSF_RTN )
err: invalid value for HCF_ASSERT;
#endif // HCF_ASSERT

#if (HCF_ASSERT) & HCF_ASSERT_MB && ! ( (HCF_EXT) & HCF_EXT_MB )		//detect potential conflict
err: these macros are not used consistently;
#endif // HCF_ASSERT_MB / HCF_EXT_MB

#if HCF_BIG_ENDIAN != 0 && HCF_BIG_ENDIAN != 1
err: invalid value for HCF_BIG_ENDIAN;
#endif // HCF_BIG_ENDIAN

#if HCF_DL_ONLY != 0 && HCF_DL_ONLY != 1
err: invalid value for HCF_DL_ONLY;
#endif // HCF_DL_ONLY

#if HCF_DMA != 0 && HCF_DMA != 1
err: invalid value for HCF_DMA;
#endif // HCF_DMA

#if (HCF_ENCAP) & ~( HCF_ENC | HCF_ENC_SUP )
err: invalid value for HCF_ENCAP;
#endif // HCF_ENCAP

#if (HCF_EXT) & ~( HCF_EXT_INFO_LOG | HCF_EXT_INT_TX_EX | HCF_EXT_TALLIES_FW | HCF_EXT_TALLIES_HCF	| \
				   HCF_EXT_NIC_ACCESS | HCF_EXT_MB | HCF_EXT_INT_TICK | \
				   HCF_EXT_IFB_STRCT | HCF_EXT_DESC_STRCT | HCF_EXT_TX_CONT )
err: invalid value for HCF_EXT;
#endif // HCF_EXT

#if HCF_INT_ON != 0 && HCF_INT_ON != 1
err: invalid value for HCF_INT_ON;
#endif // HCF_INT_ON

#if (HCF_IO) & ~( HCF_IO_MEM | HCF_IO_32BITS )
err: invalid value for HCF_IO;
#endif // HCF_IO

#if HCF_LEGACY != 0 && HCF_LEGACY != 1
err: invalid value for HCF_LEGACY;
#endif // HCF_LEGACY

#if HCF_MAX_LTV < 16 || HCF_MAX_LTV > 2304
err: invalid value for HCF_MAX_LTV;
#endif // HCF_MAX_LTV

#if HCF_PROT_TIME != 0 && ( HCF_PROT_TIME < 19 || 256 < HCF_PROT_TIME )
err: below minimum .08 second required by Hermes or possibly above hcf_32 capacity;
#endif // HCF_PROT_TIME

#if (HCF_SLEEP) & ~( HCF_CDS | HCF_DDS )
err: invalid value for HCF_SLEEP;
#endif // HCF_SLEEP

#if (HCF_SLEEP) && ! (HCF_INT_ON)
err: these macros are not used consistently;
#endif // HCF_SLEEP / HCF_INT_ON

#if (HCF_SLEEP) && ! ( (HCF_EXT) & HCF_EXT_INT_TICK )
//;? err: these macros are not used consistently;
#endif // HCF_SLEEP / HCF_EXT_INT_TICK

#if (HCF_TALLIES) & ~( HCF_TALLIES_HCF | HCF_TALLIES_NIC | HCF_TALLIES_RESET ) || \
	(HCF_TALLIES) == HCF_TALLIES_RESET
err: invalid value for HCF_TALLIES;
#endif // HCF_TALLIES

#if (HCF_TYPE) & ~(HCF_TYPE_WPA | HCF_TYPE_USB | HCF_TYPE_PRELOADED | HCF_TYPE_HII5 | HCF_TYPE_WARP | \
		HCF_TYPE_CCX /* | HCF_TYPE_TX_DELAY */ )
err: invalid value for HCF_TYPE;
#endif //HCF_TYPE

#if (HCF_TYPE) & HCF_TYPE_WARP && (HCF_TYPE) & HCF_TYPE_WPA
err: at most 1 of these macros should be defined;
#endif //HCF_TYPE_WARP / HCF_TYPE_WPA

#endif //HCFCFG_H