Rtfiles.h
76.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* rtfiles.h
*
* Project:
* --------
* Maui
*
* Description:
* ------------
* Native api declarations
*
* Author:
* -------
*
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
* removed!
* removed!
*
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
/**************************************************************************/
/* */
/* File: RTFILES.H Copyright (c) 1998,2002 */
/* Version: 4.0 On Time Informatik GmbH */
/* */
/* */
/* On Time /////////////----- */
/* Informatik GmbH ///////////// */
/* --------------------------------------------------///////////// */
/* Real-Time and System Software */
/* */
/**************************************************************************/
/* RTFiles native API declarations */
#ifndef _RTFILES_H
#define _RTFILES_H
#if (!defined(CURR_MODULE) || (CURR_MODULE != MOD_FS)) && !defined(__FS_CARD_DOWNLOAD__)
#error "This header is for FS internal use only. Please include fs_gprot.h instead!"
#endif
#include "kal_general_types.h"
#include "kal_public_defs.h"
#include "fs_internal_def.h"
#include "fs_gprot.h"
#include "fs_iprot.h"
/***************** Compile Option definition ***************************/
#undef __FS_DEBUG__ // remove for DEBUG only!!
/************************************************************************/
#ifndef RTTDLL
#ifdef RTT32DLL
#if defined(_MSC_VER)
#define RTTDLL __declspec(dllimport)
#define RTTDDL __declspec(dllimport)
#elif defined(__BORLANDC__)
#define RTTDLL
#define RTTDDL extern __import
#else // importing needs no special declaration or is not supported
#define RTTDLL
#define RTTDDL extern
#endif
#else
#define RTTDLL
#define RTTDDL extern
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
//#define RTFILE_VER 404
#if defined(_WIN32) || defined (WIN32) || defined (__FLAT__)
#define RTF_32_BIT
#define RTFAPI __cdecl
#else
/* #define RTFAPI _cdecl */
#define RTFAPI
#endif
#if !defined(WIN32)
#undef _MSC_VER
#endif
#define SECTOR_SIZE 512
#define SECTOR_SHIFT 9
#define LSB(FileName, i) (FileName[2*i])
#define MSB(FileName, i) (FileName[2*i+1])
#define isASCII(FileName, i) ( !((BYTE) MSB(FileName, i)) && (LSB(FileName, i)<0x80) )
#define toASCII(FileName, i) ((BYTE) LSB(FileName, i))
#define isWASCII(wch) (wch < 0x80)
#define setASCII(FileName, i, ch) (LSB(FileName, i)=ch); (MSB(FileName,i)=0)
#define compASCII(FileName, i, c) (isASCII(FileName, i) && (toASCII(FileName, i) == c))
#define RTFRoundUp(N, Multiple) (((N)+(Multiple)-1) & ~((Multiple)-1))
#define RTFRoundDown(N, Multiple) ((N) & ~((Multiple)-1))
// General FAT related definitions
#define RTF_CHAIN_END_MARK 0x0FFFFFFFL
#define CLUSTER_TO_SECTOR(Drive, Cluster) ((Drive)->FirstDataSector + (((Cluster)-2L) << (Drive)->SPerCShift))
#define CLUSTER_TO_SECTOR_DIR(Drive, Cluster) (((Cluster) == RTF_ROOT_DIR) ? (Drive)->FirstDirSector : CLUSTER_TO_SECTOR(Drive, Cluster))
#define CLUSTER_TO_SECTOR_OFS(Drive, Cluster, Ofs) ((Drive)->FirstDataSector + (((Cluster)-2L) << (Drive)->SPerCShift) + ((Ofs) >> (Drive)->Dev->DevData.SectorShift))
#define CLUSTER_TO_SECTOR_DIR_OFS(Drive, Cluster, Ofs) ((((Cluster) == RTF_ROOT_DIR) ? (Drive)->FirstDirSector : CLUSTER_TO_SECTOR(Drive, Cluster)) + ((Ofs) >> (Drive)->Dev->DevData.SectorShift))
#define SECTOR_OFS(Drive, Ofs) ((Ofs) & ((Drive)->Dev->DevData.SectorSize-1))
#define SAME_DIR_ENTRY(D1, D2) (((D1).Cluster == (D2).Cluster) && ((D1).Index == (D2).Index))
#define DIRS_PER_SECTOR(Drive) (Drive->Dev->DevData.SectorSize/sizeof(RTFDOSDirEntry))
#define RTF_DELETED ((char) -27) // first char in file name of deleted file
#define RTF_LONGNAME_ATTR (RTF_ATTR_READ_ONLY | RTF_ATTR_HIDDEN | RTF_ATTR_SYSTEM | RTF_ATTR_VOLUME)
#define RTFATUnknown 0
#define RTFAT12 12
#define RTFAT16 16
#define RTFAT32 32
// for FAT12 cross-sector cluster mark
#define FS_FAT12_CLUSTER_CROSSING_SECTOR_OFFSET (512 * 8 / 12)
#define FS_FAT12_CLUSTER_CROSSING_SECTOR_GROUP (512 * 8 * 3 / 12)
// partition type flags
#define RTF_PARTITION_FIRST_PRIMARY 0x00000001
#define RTF_PARTITION_EXTENDED 0x00000002
#define RTF_PARTITION_OTHER_PRIMARY 0x00000004
#define RTF_PARTITION_ALL 0x00000007 // all of the above
// flag used in GenerateShortName, to specify the handling method for SFN
#define SKIP_MATCH_SFN 0x04000000 // used in SearchFile, to indicate if SFN matching can be skipped to improve search speed.
#define INC_SHORT_NAME 0x08000000 // used in CreateNewDirEntry, to indicate if IncShortName is required for the default filename.
#define FS_GET_CLUSTER_DEFAULT (0x0)
#define FS_GET_CLUSTER_RAW (0x1) // bypass checking input cluster and its value
//#define RTF_MAX_FILES 32
#define RTF_MIN_BUFFER_SIZE 512
#define RTF_MAX_BUFFER_SIZE 32768
#define RTF_MAX_PATH 520 // 260x2=520
// error codes
#define RTF_NO_ERROR 0
#define RTF_ERROR_RESERVED -1
#define RTF_PARAM_ERROR -2
#define RTF_INVALID_FILENAME -3
#define RTF_DRIVE_NOT_FOUND -4
#define RTF_TOO_MANY_FILES -5
#define RTF_NO_MORE_FILES -6
#define RTF_WRONG_MEDIA -7
#define RTF_INVALID_FILE_SYSTEM -8
#define RTF_FILE_NOT_FOUND -9
#define RTF_INVALID_FILE_HANDLE -10
#define RTF_UNSUPPORTED_DEVICE -11
#define RTF_UNSUPPORTED_DRIVER_FUNCTION -12
#define RTF_CORRUPTED_PARTITION_TABLE -13
#define RTF_TOO_MANY_DRIVES -14
#define RTF_INVALID_FILE_POS -15
#define RTF_ACCESS_DENIED -16
#define RTF_STRING_BUFFER_TOO_SMALL -17
#define RTF_GENERAL_FAILURE -18
#define RTF_PATH_NOT_FOUND -19
#define RTF_FAT_ALLOC_ERROR -20
#define RTF_ROOT_DIR_FULL -21
#define RTF_DISK_FULL -22
#define RTF_TIMEOUT -23
#define RTF_BAD_SECTOR -24
#define RTF_DATA_ERROR -25
#define RTF_MEDIA_CHANGED -26
#define RTF_SECTOR_NOT_FOUND -27
#define RTF_ADDRESS_MARK_NOT_FOUND -28
#define RTF_DRIVE_NOT_READY -29
#define RTF_WRITE_PROTECTION -30
#define RTF_DMA_OVERRUN -31
#define RTF_CRC_ERROR -32
#define RTF_DEVICE_RESOURCE_ERROR -33
#define RTF_INVALID_SECTOR_SIZE -34
#define RTF_OUT_OF_BUFFERS -35
#define RTF_FILE_EXISTS -36
#define RTF_LONG_FILE_POS -37
#define RTF_FILE_TOO_LARGE -38
#define RTF_BAD_DIR_ENTRY -39
#define RTF_ATTR_CONFLICT -40 // Recoverable support: Can't specify FS_PROTECTION_MODE and FS_NONBLOCK_MODE
#define RTF_CHECKDISK_RETRY -41 // Recoverable support: used for CROSSLINK
#define RTF_LACK_OF_PROTECTION_SPACE -42 // UN-USED
// add for non_blocking write and protection
typedef enum{
FS_BLOCK_ENUM,
FS_NON_BLOCK_ENUM,
FS_BLOCK_PROTECTION_ENUM
}fs_block_type_enum;// file attributes
typedef enum
{
RTF_SEARCH_RET_FILE,
RTF_SEARCH_RET_PATH,
RTF_SEARCH_RET_PARENT,
RTF_SEARCH_RET_NOT_FOUND
}rtf_search_ret_enum;
// file attributes
#define RTF_ATTR_READ_ONLY 0x01
#define RTF_ATTR_HIDDEN 0x02
#define RTF_ATTR_SYSTEM 0x04
#define RTF_ATTR_VOLUME 0x08
#define RTF_ATTR_DIR 0x10
#define RTF_ATTR_ARCHIVE 0x20
#define RTF_LONGNAME_ATTR (RTF_ATTR_READ_ONLY | RTF_ATTR_HIDDEN | RTF_ATTR_SYSTEM | RTF_ATTR_VOLUME)
#define RTF_ATTR_ANY 0x3F
// file open flags
// 0x000000XX - attributes
// 0x0000XX00 - sharing
// 0x000X0000 - creation
// 0xXX000000 - caching
// 0x00X00000 - RTFiles internal use
#define RTF_READ_WRITE 0x00000000L
#define RTF_READ_ONLY 0x00000100L
#define RTF_OPEN_SHARED 0x00000200L
#define RTF_OPEN_NO_DIR 0x00000400L
#define RTF_OPEN_DIR 0x00000800L
#define RTF_CREATE 0x00010000L // create if it does not exist
#define RTF_CREATE_ALWAYS 0x00020000L // always create
// defaults:
// DIR and FAT is written at file close
// buffers are written when file pointer leaves the sector
#define RTF_COMMITTED 0x01000000L // commit all buffers after every write
#define RTF_CACHE_DATA 0x02000000L // do not discard data buffers
#define RTF_LAZY_DATA 0x04000000L // do not commit buffer when file pointer leaves sector
// add a new flags for non_blocking write for flash driver
#define FS_NONBLOCK_MODE 0x10000000L // writing while encounter flash erase return immediately
#define FS_NOBUSY_CHECK_MODE 0x40000000L
/* add a new flags for write protection for flash driver.
* Note that, currently, we protect a write range of 2 or less sectors.
* Originally, only NVRAM files are meant to be protected.
*/
#define FS_PROTECTION_MODE 0x20000000L // Keep old versioned sectors for recovery on unexpected poweroff.
#define FS_FH_INTERNAL_HINT 0x80000000L // indicate if this file handle embeds a internal hint
// note that RTF_DEVICE_LAZY_WRITE is a drive option and applies to all files
// file seek options
#define RTF_FILE_BEGIN 0
#define RTF_FILE_CURRENT 1
#define RTF_FILE_END 2
// format flags, low 8 bits are reserved for media specification
// Use RTF_FPLY_DRIVE_360/1200/720/1440/2880 to force a particular medium
// Default is the highest supported medium
#define RTF_FMT_SINGLE_FAT 0x00000100L
#define RTF_FMT_FORCE_LOW_LEVEL 0x00000200L
#define RTF_FMT_NO_LOW_LEVEL 0x00000400L
#define RTF_FMT_GET_DATA_SECTOR 0x00000800L
#define RTF_FMT_FAT_12 0x00001000L
#define RTF_FMT_FAT_16 0x00002000L
#define RTF_FMT_FAT_32 0x00004000L
#define RTF_FMT_NO_FAT_32 0x00008000L
#define RTF_FMT_PGS_LOW_FMT 1
#define RTF_FMT_PGS_HIGH_FMT 2
#define RTF_FMT_PGS_CLEAR_MEDIUM 5
#define RTF_FMT_PGS_DONE -1
// check disk flags
#define RTF_CHK_FAT_MISMATCH 0x00000001L
#define RTF_CHK_FAT_MISMATCH_1 0x00000002L
#define RTF_CHK_FAT_MISMATCH_2 0x00000003L
#define RTF_CHK_FAT_MISMATCH_MASK 0x00000003L
#define RTF_CHK_INVALID_DIR 0x00000004L
#define RTF_CHK_INVALID_DIR_DELETE 0x00000008L
#define RTF_CHK_INVALID_DIR_MASK 0x0000000CL
#define RTF_CHK_INVALID_CLUSTER 0x00000010L
#define RTF_CHK_INVALID_CLUSTER_TRUNC 0x00000020L
#define RTF_CHK_INVALID_CLUSTER_DELETE 0x00000030L
#define RTF_CHK_INVALID_CLUSTER_MASK 0x00000030L
#define RTF_CHK_CROSSLINK 0x00000040L
#define RTF_CHK_CROSSLINK_TRUNC 0x00000080L
#define RTF_CHK_CROSSLINK_DELETE 0x000000C0L
#define RTF_CHK_CROSSLINK_MASK 0x000000C0L
#define RTF_CHK_FILESIZE_SMALL 0x00000100L // DIR.FileSize < FAT.FileSize
#define RTF_CHK_FILESIZE_SMALL_TRUNC 0x00000200L // truncate FAT chain
#define RTF_CHK_FILESIZE_SMALL_DELETE 0x00000300L
#define RTF_CHK_FILESIZE_SMALL_MASK 0x00000300L
#define RTF_CHK_FILESIZE_LARGE 0x00000400L // DIR.FileSize > FAT.FileSize
#define RTF_CHK_FILESIZE_LARGE_TRUNC 0x00000800L // truncate DIR.FileSize
#define RTF_CHK_FILESIZE_LARGE_DELETE 0x00000C00L
#define RTF_CHK_FILESIZE_LARGE_MASK 0x00000C00L
#define RTF_CHK_LOST_CLUSTER 0x00001000L
#define RTF_CHK_LOST_CLUSTER_FREE 0x00002000L
#define RTF_CHK_LOST_CLUSTER_MASK 0x00003000L
#define RTF_CHK_LONG_FILENAME 0x00004000L
#define RTF_CHK_LONG_FILENAME_REMOVE 0x00008000L
#define RTF_CHK_LONG_FILENAME_DELETE 0x0000C000L
#define RTF_CHK_LONG_FILENAME_MASK 0x0000C000L
#define RTF_CHK_VERBOSE 0x80000000L
// Flags for RTFCompactDir
#define RTF_CMPCT_READ_ONLY 0x00000001
#define RTF_CMPCT_RECURSIVE 0x00000002
// Flags for RTFDiskInfoEx
#define RTF_DI_BASIC_INFO 0x00000001L
#define RTF_DI_FREE_SPACE 0x00000002L // return FreeClusters
#define RTF_DI_FAT_STATISTICS 0x00000004L // return BadClusters, Files, FileChains, FreeChains, LargestFreeChain
#define RTF_DI_VOLUME_LABEL 0x00000008L // return Volume Label
#define RTF_DI_OPT_READ_PERMITTED 0x00000010L // return Volume Label
// Flags for RTFFileInfoEx
#define RTF_FI_BASIC_INFO 0x00000001L
#define RTF_FI_ALLOCATED_SIZE 0x00000002L
#define RTF_FI_ALL (RTF_FI_BASIC_INFO | RTF_FI_ALLOCATED_SIZE)
// device types
#define RTF_DEVICE_UNKNOWN 0
#define RTF_DEVICE_FLOPPY 1
#define RTF_DEVICE_FDISK 2
// device flags, use only lower 16 bits
#define RTF_DEVICE_SINGLE_FAT 0x0001
#define RTF_DEVICE_LAZY_WRITE 0x0002 // update FAT/DIR/data buffers at last file close of drive
#define RTF_DEVICE_MOUNT_CONTIGUOUS 0x0004
#define RTF_DEVICE_REMOVABLE 0x0008
// device driver flags, may only use upper 16 bits
#define RTF_DEVICE_NO_MEDIA 0x10000
#define RTF_DEVICE_NEW_LOCK 0x20000
#define RTF_DEVICE_BUSY_READ_ONLY 0x40000
// floppy driver flags
#define RTF_CUSTOM_TIMER 0x80000000L
#define RTF_MOTOR_TIMEOUT_1 0x40000000L
#define RTF_MOTOR_TIMEOUT_5 0x20000000L
#define RTF_MOTOR_TIMEOUT_10 0x10000000L
#define RTF_READ_AHEAD_0 0x01000000L
#define RTF_READ_AHEAD_2 0x02000000L
#define RTF_READ_AHEAD_8 0x03000000L
#define RTF_READ_AHEAD_16 0x04000000L
// IDE driver flags
#define RTF_NO_CMOS_RAM 0x80000000L
#define RTF_32_BIT_IO 0x40000000L
#define RTF_16_BIT_IO 0x20000000L
#define RTF_NO_MULTI_SECTOR 0x10000000L
#define RTF_NO_WRITE_CACHE 0x08000000L
#define RTF_CONTIGUOUS_IO 0x04000000L
// Flash driver flags
#define RTF_FLASH_NO_SECTOR_MAP 0x80000000L
#define RTF_FLASH_NO_LOW_FMT 0x40000000L
#define RTF_FLASH_NO_HIGH_FMT 0x20000000L
// Flags for RTFGetPartitionInfo
#define FS_PARTITION_INFO_BASIC (0x01)
#define FS_PARTITION_INFO_ADVANCED (0x02)
#define FS_PARTITION_INFO_ALL (FS_PARTITION_INFO_BASIC | FS_PARTITION_INFO_ADVANCED)
// a few data types
#if !defined(_WINDOWS_) && !defined(__AMNT__)
typedef unsigned int DWORD; // keep DWORD type definition inside RTFiles32 (Just in case for capatibility! Please use kal_uint32 instead in any future design)
#endif
typedef int RTFHANDLE;
typedef kal_uint32 RTFSector;
typedef kal_uint32 RTFCluster;
#if defined(WIN32)
#pragma pack(push,1)
#endif
typedef __fs_packed_prefix struct {
BYTE BootIndicator, // 0x80 for bootable, 0 otherwise
StartHead, // 0 based
StartSector, // 1 based, bits 0..5, bits 6,7 are bits 8,9 of StartTrack
StartTrack, // 0 based, bits 0..7
OSType, // FAT-12: 1, FAT-16: 4, 6, 14, FAT-32: 11, 12
EndHead, // see StartHead
EndSector, // see StartSector
EndTrack; // see StartTrack
RTFSector RelativeSector, // offset to first sector of partition data
// for primary partitions, this is the absolute
// LBA of the boot sector
// for logical drives, the boot sector is at ExtendedPartition.RelativeSector + Drive.RelativeSector
Sectors; // number of sectors in partition
} __fs_packed_postfix RTFPartitionRecord; /* ! Must SYNC ! */
typedef __fs_packed_prefix struct {
unsigned int Second2:5;
unsigned int Minute:6;
unsigned int Hour:5;
unsigned int Day:5;
unsigned int Month:4;
unsigned int Year1980:7;
} __fs_packed_postfix RTFDOSDateTime; /* ! Must SYNC ! */
typedef __fs_packed_prefix struct {
char FileName[8];
char Extension[3];
BYTE Attributes;
BYTE NTReserved;
BYTE CreateTimeTenthSecond; // range 0..199, not used
RTFDOSDateTime CreateDateTime;
WORD LastAccessDate; // not used
WORD FirstClusterHi; // FAT-32 only
RTFDOSDateTime DateTime; // last modification time
WORD FirstCluster;
kal_uint32 FileSize;
} __fs_packed_postfix RTFDOSDirEntry; /* ! Must SYNC ! */
// end of one byte alignment for structure definitions
#if defined(WIN32)
#pragma pack(pop)
#endif
typedef struct {
const RTFDOSDirEntry * DirEntry;
kal_uint32 FilePos;
kal_uint32 AllocatedSize;
kal_uint32 ClusterChains;
kal_uint32 VolumeSerialNumber;
const char * FullName;
} RTFFileInfo; /* ! Must SYNC ! */
typedef struct {
char Label[24];
char DriveLetter;
BYTE WriteProtect;
char Reserved[2];
kal_uint32 SerialNumber;
kal_uint32 FirstPhysicalSector;
UINT FATType; // 12 or 16
UINT FATCount;
UINT MaxDirEntries;
UINT BytesPerSector;
UINT SectorsPerCluster;
RTFCluster TotalClusters;
RTFCluster BadClusters;
RTFCluster FreeClusters;
kal_uint32 Files;
kal_uint32 FileChains;
kal_uint32 FreeChains;
RTFCluster LargestFreeChain;
} RTFDiskInfo; /* ! Must SYNC ! */
// for device CFI information query
typedef enum
{
MT_DEV_NO_BOOT = 0,
MT_DEV_DUAL_BOOT,
MT_DEV_TOP_BOOT,
MT_DEV_BOTTOM_BOOT
} MT_DEVICE_BOOT_LOCATION_ENUM; /* ! Must SYNC ! */
// FS_NANDDeviceInfo (RTFNANDDeviceInfo) related definition
#define MT_DEVICE_FLAG_VISIBLE (0x00000001)
#define MT_DEVICE_FLAG_PRESENT (0x00000010)
typedef struct
{
BYTE DeviceID[8];
UINT BlockSize;
UINT PageSize;
UINT DeviceSize;
UINT Flag;
} RTFNANDDeviceInfo; /* ! Must SYNC ! */
typedef struct
{
BYTE DeviceID[8];
UINT DeviceSize;
BYTE BootLocation;
} RTFNORDeviceInfo; /* ! Must SYNC ! */
typedef struct
{
UINT Flag;
UINT PSN;
kal_uint8 SerialMode;
kal_uint8 DeferredMount;
} RTFCardDeviceInfo; /* ! Must SYNC ! */
typedef struct
{
union
{
RTFNANDDeviceInfo NAND;
RTFNORDeviceInfo NOR;
RTFCardDeviceInfo Card;
} DeviceInfo;
} RTFDeviceInfo; /* ! Must SYNC ! */
typedef struct {
RTFPartitionRecord Partition;
RTFSector PartitionSector; // absolute sector containing the partition table (0 for primary partitions and floppies)
int PhysicalDiskIndex; // nth physical hard disk (0 based, -1 for floppies)
UINT BytesPerSector; // usually 512
BYTE MediaDescriptor; // F8 for hard disks, 0 for unknown
BYTE Reserved; // for alignment
short DeviceListIndex; // nth entry in the RTFiles device list (0 based)
} RTFPartitionInfo;
typedef struct {
kal_uint32 TotalBuffers, // number of installed sector buffers
ValidBuffers, // buffers currently holding valid data
DirtyBuffers, // buffers currently holding unflushed data
MaxDirtyBuffers, // max number of dirty buffers
PhysicalBufferReads, // number of physical buffer reads
CachedBufferReads, // number of times data was in the cache
BuffersDiscarded, // number of times a valid buffer was discared to make room for a new buffer
CacheHits, // 100 * CachedBufferReads / (PhysicalBufferReads+CachedBufferReads)
PhysicalBufferWrites, // buffer writes to disk
CachedBufferWrites, // updates of a dirty buffer
AsynchBufferFlushs, // buffers written in a differen RTFiles API call than the first update to that buffer
UnbufferedReads, // sectors read bypassing the buffer cache
UnbufferedWrites; // sectors written bypassing the buffer cache
} RTFBufferStatistic;
/*------------------------------
* FS Trace
*------------------------------*/
#define MTPrintSysTrace(x)
typedef void (RTFAPI * RTFFormatCallback)(const char * DeviceName, int Action, kal_uint32 Total, kal_uint32 Completed);
typedef kal_uint32 (RTFAPI * RTFCheckDiskCallback)(kal_uint32 Flag,
const char * Path,
const RTFDOSDirEntry * FileInfo,
kal_uint32 N1,
kal_uint32 N2);
#ifndef _WINDOWS_
typedef struct {
kal_uint32 Reserved[12];
} CRITICAL_SECTION;
#endif
typedef struct RTFMutex_t {
kal_semid rtf_sem;
kal_taskid rtf_sem_owner;
kal_uint32 rtf_sem_owner_lr;
kal_uint32 rtf_lock_count;
int DeviceNum_1;
int DeviceNum_2;
} RTFMutex; /* ! Must SYNC ! */
typedef RTFMutex RTFSemaphore;
typedef struct rtfdriver {
//UINT Version;
int (RTFAPI * MountDevice) (void * DriveData, int DeviceNumber, int DeviceType, kal_uint32 Flags);
int (RTFAPI * ShutDown) (void * DriveData);
int (RTFAPI * ReadSectors) (void * DriveData, RTFSector Sector, UINT Sectors, void * Buffer);
int (RTFAPI * WriteSectors) (void * DriveData, RTFSector Sector, UINT Sectors, void * Buffer);
int (RTFAPI * MediaChanged) (void * DriveData);
int (RTFAPI * DiscardSectors) (void * DriveData, RTFSector Sector, UINT Sectors);
int (RTFAPI * GetDiskGeometry)(void * DriveData, RTFPartitionRecord * DiskGeometry, BYTE * MediaDescriptor);
int (RTFAPI * LowLevelFormat) (void * DriveData, const char * DeviceName, RTFFormatCallback Progress, kal_uint32 Flags);
int (RTFAPI * NonBlockWriteSectors) (void * DriveData, RTFSector Sector, UINT Sectors, void * Buffer);
int (RTFAPI * RecoverableWriteSectors)(void * DriveData, RTFSector Sector, UINT Sectors, void * Buffer); // Recoverable support
int (RTFAPI * ResumeSectorStates) (void * DriveData); // Recoverable support
int (RTFAPI * HighLevelFormat)(void * DriveData, UINT BaseSector); /* for speed up format, WCP_SW , 2007/08/27 */
int (RTFAPI * RecoverDisk) (void * DriveData); /* Support advance disk recover operation, WCP_SW, 2007/08/30 */
int (RTFAPI * MessageAck) (void * DriveData, int type); /* Add for USB OTG Device, 2005/12/13 */
int (RTFAPI * CopySectors) (void * DriveData, RTFSector SrcSector, RTFSector DstSector, UINT Sectors); /* Add for XCOPY Speed up, 2006/06/15 */
int (RTFAPI * OTPAccess) (void * DriveData, int type, UINT Offset, void * BufferPtr, UINT Length); /* Add for OTP device IO, 2006/06/29 */
int (RTFAPI * OTPQueryLength) (void * DriveData, UINT *Length); /* Add for OTP device IO, 2006/06/29 */
int (RTFAPI * IOCtrl) (void * DriveData, UINT CtrlAction, void * CtrlData); // For device IO control (like CMMB CAS full card)
} RTFDriver; /* ! Must SYNC ! */
struct _rtfDrive;
struct _rtfBuffer;
#if defined(__FS_CACHE_SUPPORT__) && !defined(__FS_CARD_DOWNLOAD__)
typedef struct {
RTFMutex * Lock;
struct _rtfDrive * FirstDrive;
BYTE MediaPresent;
BYTE MediaRemovedReported; // set to zero when MediaPresent is set to zero
BYTE Reserved;
BYTE MountState;
int SectorSize;
RTFPartitionRecord Geometry; // size = 4 kal_uint32
UINT SectorShift;
UINT AccessCount;
int ErrorCondition; // keep returning this until it is remounted
int PhysicalDiskIndex;
char FriendlyName[7]; // "Disk X"
BYTE MediaDescriptor;
FS_CacheProfile CacheProfile;
struct _rtfBuffer *B; // temporary buffer
} RTFDeviceData; /* ! Must SYNC ! */
#else // defined(__FS_CACHE_SUPPORT__) && !defined(__FS_CARD_DOWNLOAD__)
typedef struct {
RTFMutex * Lock;
struct _rtfDrive * FirstDrive;
BYTE MediaPresent;
BYTE MediaRemovedReported; // set to zero when MediaPresent is set to zero
BYTE Reserved;
BYTE MountState;
int SectorSize;
RTFPartitionRecord Geometry; // size = 4 kal_uint32
UINT SectorShift;
UINT AccessCount;
struct _rtfBuffer *B; // temporary buffer
struct _rtfBuffer *AltBuffer; // temporary buffer for critical errors
int ErrorCondition; // keep returning this until it is remounted
int PhysicalDiskIndex;
char FriendlyName[7]; // "Disk X"
BYTE MediaDescriptor;
} RTFDeviceData; /* ! Must SYNC ! */
#endif // defined(__FS_CACHE_SUPPORT__) && !defined(__FS_CARD_DOWNLOAD__)
typedef struct _rtfDevice {
int DeviceType;
int DeviceNumber;
kal_uint32 DeviceFlags;
RTFDriver * Driver;
void * DriverData; // total size = 5 kal_uint32
RTFDeviceData DevData; // size = 16 kal_uint32
} RTFDevice; /* ! Must SYNC ! */
// driver specific data for well known drivers
// Windows NT driver, do not use for embedded systems
typedef struct {
int DeviceType;
kal_uint32 Flags;
HANDLE FileHandle;
CRITICAL_SECTION CS;
// just for diagnostics
kal_uint32 LastStatus;
kal_uint32 SectorSize;
kal_uint32 SectorsPerTrack;
kal_uint32 Heads;
} RTFDrvNTData;
// ATA-IDE driver
typedef struct {
void * ReadAheadBuffer;
UINT ReadAheadBufferSize;
UINT PortBase;
UINT InitTimeout;
UINT DiskTimeout;
UINT ControllerTimeout;
UINT IRQ;
UINT Cylinders;
UINT Heads;
UINT SectorsPerTrack;
UINT MaxSectors;
UINT DeviceNumber; // 0 or 1
UINT Controller; // 0 to 3
RTFSector TotalSector;
RTFSector InBufferSector;
RTFSector InBufferSectors;
kal_uint32 ExtraReads;
kal_uint32 SavedReads;
kal_uint32 SavedAccesses;
kal_uint32 Flags;
} RTFDrvIDEData;
// Floppy driver
// these are also used as media identifiers. 0 means unknown.
// drive types never change, but medias can
#define RTF_FPLY_DRIVE_UNKNOWN 0
#define RTF_FPLY_DRIVE_360 1
#define RTF_FPLY_DRIVE_1200 2
#define RTF_FPLY_DRIVE_720 3
#define RTF_FPLY_DRIVE_1440 4
#define RTF_FPLY_DRIVE_2880 5
typedef struct {
BYTE CommandByte2; // use 0xDF
BYTE CommandByte3; // HeadLoadTime, use 0x02
BYTE MotorTimeout; // 55ms timer ticks, use 0x25
BYTE SectorSize; // use 2 for 512 bytes
BYTE LastSector; // media dependent, don't use
BYTE GapLength; // media dependent, don't use
BYTE CommandByte8; // DataLength, use 0xFF
BYTE FormatGapLength; // media dependent, don't use
BYTE FormatFillByte; // use 0xF6
BYTE HeadSettleTime; // use 0x0F (milliseconds)
BYTE MotorStartupTime; // 8th of a second, use 8 (only used from write)
} RTF_FPLY_BIOS_Disk_Parameter;
typedef struct {
UINT DeviceType; // 0 to have the driver ask the BIOS CMOS RAM
RTF_FPLY_BIOS_Disk_Parameter * DPT; // NULL to use default
UINT DiskTimeout; // 0 for default of 2000 milliseconds
UINT ControllerTimeout; // 0 for default 500 milliseconds
UINT Retries; // 3 by default
UINT DeviceNumber;
UINT Media;
UINT CurrentTrack;
UINT RetryCount;
UINT ReadAheadSectors;
kal_uint32 ExtraReads;
kal_uint32 SavedReads;
kal_uint32 SavedAccesses;
kal_uint32 Flags;
BYTE CtrStatus[7];
} RTFDrvFLPYData;
// RAM Disk
typedef struct {
RTFSector Sectors;
kal_uint32 Reserved1, Reserved2;
UINT SectorsPerSegment;
void * * * MasterSegment;
} RTFDrvRAMData;
// BIOS Driver
typedef struct {
void * ReadAheadBuffer;
UINT ReadAheadBufferSize;
UINT LockIndex;
UINT Retries;
UINT DeviceNumber;
UINT DeviceType;
UINT SectorsPerTrack;
UINT Heads;
UINT RetryCount;
UINT InBufferSectors;
RTFSector InBufferSector;
kal_uint32 ExtraReads;
kal_uint32 SavedReads;
kal_uint32 SavedAccesses;
kal_uint32 Flags;
} RTFDrvBIOSData;
// DiskOnChip 2000
typedef struct {
unsigned DeviceNumber;
} RTFDrvDOCData;
// PCMCIA SRAM card driver
typedef struct {
RTFSector Sectors;
BYTE * WinAddrP; // physical address of window
BYTE * WinAddrV; // virtual address of window
RTFSector WinSize; // in sectors
RTFSector CurrSec;
int Socket;
kal_uint32 Flags;
} RTFDrvSRAMData;
// port i/o routines for the drivers
RTTDLL BYTE RTFAPI RTIn (UINT Port);
RTTDLL WORD RTFAPI RTInW (UINT Port);
RTTDLL kal_uint32 RTFAPI RTInD (UINT Port);
RTTDLL void RTFAPI RTOut (UINT Port, BYTE val);
RTTDLL void RTFAPI RTOutW (UINT Port, WORD val);
RTTDLL void RTFAPI RTOutD (UINT Port, kal_uint32 val);
RTTDLL void * RTFAPI RTInSW (UINT Port, void * Buffer, UINT Bytes);
RTTDLL void * RTFAPI RTInSD (UINT Port, void * Buffer, UINT Bytes);
RTTDLL void * RTFAPI RTOutSW(UINT Port, void * Buffer, UINT Bytes);
RTTDLL void * RTFAPI RTOutSD(UINT Port, void * Buffer, UINT Bytes);
// 32-bit disk drivers
RTTDDL RTFDriver RTFDrvNT; // Windows NT driver (not for embedded systems)
RTTDDL RTFDriver RTFDrvIDE; // ATA-IDE driver
RTTDDL RTFDriver RTFDrvFloppy; // floppy disk driver
RTTDDL RTFDriver RTFDrvRAM; // RAM disk driver
RTTDDL RTFDriver RTFDrvDOC; // M-Systems DiskOnChip 2000 driver
RTTDDL RTFDriver RTFDrvSRAM; // PCMCIA SRAM card driver
RTTDDL RTFDriver RTFDrvNULL; // Dummy driver to reserve driver letters
RTTDDL RTFDriver RTFDrvFlash; // linear flash driver
// 16-bit disk drivers
RTTDDL RTFDriver RTFDrvBIOS; // BIOS int 13h driver
RTTDDL RTFDriver RTFDrvRAM; // RAM disk driver
RTTDDL RTFDriver RTFDrvNULL; // dummy driver to reserve driver letters
// The device list
RTTDDL RTFDevice gFS_DeviceList[];
//RTTDDL RTFDevice RTFDeviceList[];
struct _rtfDevice;
struct _rtfDrive;
#define RTF_RECOVERABLE_WRITE 1
#define RTF_NORMAL_WRITE 0
#if defined(__FS_CACHE_SUPPORT__) && !defined(__FS_CARD_DOWNLOAD__)
typedef struct _rtfBuffer {
struct _rtfBuffer * Next;
struct _rtfBuffer * Prev;
struct _rtfDrive * Drive;
struct _rtfDevice * Dev;
kal_uint8 * Data;
kal_uint32 SectorAddress;
kal_uint32 SectorLength;
kal_uint32 Flags;
} RTFBuffer; /* ! Must SYNC ! */
#else // defined(__FS_CACHE_SUPPORT__) && !defined(__FS_CARD_DOWNLOAD__)
typedef struct _rtfBuffer {
struct _rtfBuffer * Next;
struct _rtfBuffer * Prev;
RTFDevice * Dev;
BYTE * Data;
RTFSector Sector;
struct _rtfDrive * FATSectorInfo;
UINT Flags;
UINT FirstDirtyTime,
LastDirtyTime;
int Num; // for debugging only
BYTE recoverable_flag; // 1 means the buffer needs recoverablewritesector, 0 means not
BYTE SectorCount;
BYTE SectorOffset; // may not be required
} RTFBuffer; /* ! Must SYNC ! */
#endif // defined(__FS_CACHE_SUPPORT__) && !defined(__FS_CARD_DOWNLOAD__)
typedef struct _fsBufferList {
struct _rtfBuffer * FirstBuffer;
struct _rtfBuffer * LastBuffer;
} FS_BufferList;
typedef struct {
RTFCluster Cluster; // zero if none
UINT Index; // undefined if none
} RTFDirLocation; /* ! Must SYNC ! */
// FS external open hint
typedef struct {
// RTFDirLocation
UINT Cluster;
UINT Index;
// Extension
UINT Stamp;
UINT Drive;
UINT SerialNumber;
} RTFFileOpenHint; /* ! Must SYNC ! */
typedef struct {
RTFCluster DirCluster; // start of dir containing this entry
RTFDirLocation LongPos;
RTFDirLocation ShortPos;
RTFDOSDirEntry Dir;
} RTFDirEntry; /* ! Must SYNC ! */
typedef struct _rtfDrive {
struct _rtfDevice * Dev;
struct _rtfDrive * NextDrive;
int MountState; // see type MountStates
RTFPartitionRecord Geometry;
RTFCluster Clusters; // 1 + last valid cluster value, actual value +2
UINT SectorsPerCluster;
kal_uint32 ClusterSize; // in bytes
UINT ClusterShift;
UINT SPerCShift; // sector per cluster shift
UINT FATType;
UINT FATCount;
kal_uint32 SectorsPerFAT;
kal_uint32 DataRangePerFATSector;
RTFCluster ClusterWatermark;
RTFCluster FreeClusterCount; // 0xFFFFFFFF if unknown
RTFSector InfoSector; // 0 if none
kal_uint32 SerialNumber;
RTFSector FirstSector;
RTFSector FirstFATSector;
RTFSector FirstDirSector; // this is the first root dir cluster on FAT-32
RTFSector FirstDataSector;
UINT RootDirEntries; // not used on FAT-32
RTFDirEntry CurrDirEntry;
BYTE Reserved1[5 * sizeof(UINT)]; // add 5 UINT members to synchronize the size of FS_Drive and _rtfDrive (FS_DOSDirEntry has additional 5 members for hint support in FS_DOSDirEntry than RTFDOSDirEntry)
char CurrDir[RTF_MAX_PATH]; // "X:\[Dir]"
#ifdef __FS_QM_SUPPORT__
BYTE QuotaMgt;
BYTE Reserved2[3];
#endif
} RTFDrive; /* ! Must SYNC ! */
typedef struct
{
unsigned short StaticHintCount;
unsigned short UsedStaticHintCount; // #static_hint + #classic_hint
unsigned int StaticHintRange;
} RTFSeekHintData;
typedef struct {
RTFDrive * Drive; // NULL for physical disk files
RTFDevice * Dev; // redundant for data and volume files
kal_uint16 SpecialKind;
kal_uint16 PrivateFlags;
UINT Unique;
kal_uint32 Flags;
RTFDirEntry DirEntry;
BYTE Reserved1[5 * sizeof(UINT)]; // add 5 UINT members to synchronize the size of FS_File and RTFile (FS_DOSDirEntry has additional 5 members for hint support in FS_DOSDirEntry than RTFDOSDirEntry)
kal_uint32 FilePointer;
RTFCluster LastCluster; // cluster preceeding Cluster (A1 and A2 for search handles)
RTFCluster Cluster; // cluster containing FilePointer (RTFDirLocation for search handles)
kal_uint32 Offset; // within Cluster (ditto)
char FullName[RTF_MAX_PATH + 2 * sizeof(WCHAR)];
void * Task; /* for garbage collection */
UINT HintNum;
RTFDirLocation * Seek_Hint;
fs_job_id Job;
fs_tbl_usr_ptr_type usr_ptr_type;
void *usr_ptr;
kal_uint32 OwnerLR; // Caller address of the file handle creator, ex. FS_Open().
BYTE Lock;
BYTE Valid; // The Valid flag MUST be put at the end of the structure to avoid race condition between _rtfLock() & memset().
} RTFile; /* ! Must SYNC ! with FS_File */
typedef struct {
RTFDrive * DriveTable;
RTFile * FileTable;
RTFBuffer * BufferTable;
BYTE * BufferData;
} RTFTables; /* ! Must SYNC ! */
#if defined(WIN32)
#pragma pack(push,1)
#endif
typedef __fs_packed_prefix struct {
kal_uint32 Signature1; // 0x41615252l
BYTE Reserved[480];
kal_uint32 Signature2; // 0x61417272l
RTFCluster FreeClusterCount; // 0xFFFFFFFF for unkown, not guaranteed to be correct
RTFCluster NextFreeCluster; // 0xFFFFFFFF for unkown, start free cluster search here, not guaranteed to be correct
BYTE Reserved2[12];
kal_uint32 Signature; // 0xAA550000l
} __fs_packed_postfix RTFFAT32InfoSector;
typedef __fs_packed_prefix struct {
BYTE PhysicalDiskNumber; // 0x80, 0x81, etc.
BYTE CurrentHead; // not used
BYTE Signature; // needed by NT
kal_uint32 SerialNumber;
BYTE Label[11]; // not used
char SystemID[8];
} __fs_packed_postfix RTFExtendedBIOSParameter; /* ! Must SYNC ! */
typedef __fs_packed_prefix struct {
char OEMName[8];
WORD BytesPerSector;
BYTE SectorsPerCluster;
WORD ReservedSectors; // relative to partition start
BYTE NumberOfFATs;
WORD DirEntries; // zero on FAT-32
WORD SectorsOnDisk;
BYTE MediaDescriptor;
WORD SectorsPerFAT; // zero on FAT-32
WORD SectorsPerTrack;
WORD NumberOfHeads;
RTFSector NumberOfHiddenSectors; // OS specific, unreliable
RTFSector TotalSectors;
__fs_packed_prefix union {
__fs_packed_prefix struct {
RTFExtendedBIOSParameter BPB;
} __fs_packed_postfix _16;
__fs_packed_prefix struct {
RTFCluster SectorsPerFAT;
WORD Flags; // if (Flags & 0x0080) { SingleFAT; ActiveFat = (Flags & 0x000F); }
WORD Version;
RTFCluster RootDirCluster;
WORD FSInfoSector; // relative to start of partition, usually 1, 0xFFFF for none.
WORD BackupBootSector; // usually 6
BYTE Reserved[12]; // should be all zero
RTFExtendedBIOSParameter BPB;
} __fs_packed_postfix _32;
} __fs_packed_postfix E;
} __fs_packed_postfix RTFBIOSParameter; /* ! Must SYNC ! */
typedef __fs_packed_prefix struct {
BYTE BootCode[512-4*sizeof(RTFPartitionRecord)-sizeof(WORD)];
RTFPartitionRecord PTable[4];
WORD Signature;
} __fs_packed_postfix RTFMasterBootRecord; /* ! Must SYNC ! */
typedef __fs_packed_prefix struct {
BYTE NearJump[3];
RTFBIOSParameter BP;
BYTE BootCode[512-3-sizeof(RTFBIOSParameter)-sizeof(WORD)];
WORD Signature;
} __fs_packed_postfix RTFBootRecord; /* ! Must SYNC ! */
#if defined(WIN32)
#pragma pack(pop)
#endif
/*------------------------------
* FS Internal Hint Management
*------------------------------*/
typedef enum {
MT_HINT_MATCH_NONE,
MT_HINT_MATCH_PERFECT,
MT_HINT_MATCH_TARGET_END,
MT_HINT_MATCH_HINT_END,
MT_HINT_MATCH_OTHER
} RTFOpenHintMatchTypeEnum;
typedef enum {
MT_HINT_ACTION_NONE = 0,
MT_HINT_ACTION_PAUSE,
MT_HINT_ACTION_RESUME,
MT_HINT_ACTION_OPEN,
MT_HINT_ACTION_FORCE_NEW,
MT_HINT_ACTION_FORCE_NO_NEW
} RTFOpenHintActionEnum;
#define MT_HINT_PATH_FREE_SLOT_UNAVAILABLE (0xFF)
/*
* Hint Stamp Normalization Base
* (M / N): M is the maximum hint stamp, and N is how many levels are there after normalization.
* (M / N) should be assigned to a 2^N value to minimize the normalization overhead.
*/
#define MT_HINT_STAMP_NORMALIZE_LEVEL (8)
#define MT_HINT_STAMP_NORMALIZE_BASE (256 / MT_HINT_STAMP_NORMALIZE_LEVEL)
#define MT_HINT_FLAG_FIND_FILE (0x01)
#define MT_HINT_FLAG_OBSOLETE (0x02)
#define MT_HINT_INTERNAL (0x80)
#define MT_HINT_NEW (0x40)
#define MT_HINT_DISABLE (0x80000000)
#define MTHintSetLevel(hint, level) (((FS_OpenHintInt*)(hint))->Level = (level))
#define MTHintGetLevel(hint) (((FS_OpenHintInt*)(hint))->Level)
#define MTHintGetMatchType(hint) (((FS_OpenHintInt*)(hint))->MatchType)
#define MTHintGetIndex(hint) (((FS_OpenHintInt*)(hint))->PathIndex)
#define MTHintGetDirCluster(hint) (((FS_OpenHintInt*)(hint))->DirCluster)
#define MTIsNewHint(hint) (((FS_OpenHintInt*)(hint))->Flag & MT_HINT_NEW)
#define MTIsInternalHint(hint) (((FS_OpenHintInt*)(hint))->Flag & MT_HINT_INTERNAL)
/*-------------------------------
* FS Smart File Seeker Support
* (Internal Use)
*-------------------------------*/
// hint types
#define FS_SEEKHINT_TYPE_STATIC (0)
#define FS_SEEKHINT_TYPE_CLASSIC (1)
// hint operations
#define FS_SEEKHINT_TYPE_MASK (0x1)
#define FS_SEEKHINT_IS_STATIC(F, I) (!(F->Seek_Hint[i].Index & FS_SEEKHINT_TYPE_MASK))
#define FS_SEEKHINT_IS_CLASSIC(F, I) (F->Seek_Hint[i].Index & FS_SEEKHINT_TYPE_MASK)
#define FS_SEEKHINT_SET_STATIC(F, I) (F->Seek_Hint[i].Index &= ~FS_SEEKHINT_TYPE_MASK)
#define FS_SEEKHINT_SET_CLASSIC(F, I) (F->Seek_Hint[i].Index |= FS_SEEKHINT_TYPE_MASK)
// for RTFCommit
#define FS_COMMIT_DEFAULT (0x00000000) // default: no ResumeSector
#define FS_COMMIT_RESUMESECTOR (0x00000001) // ResumeSector will be executed if it is supported.
// API functions
// General File I/O
RTTDLL RTFHANDLE RTFAPI RTFOpenFile(const WCHAR * FileName, kal_uint32 Flags, RTFDirLocation * DSR_Hint, kal_uint32 caller_address);
RTTDLL RTFHANDLE RTFAPI RTFOpen(const WCHAR * FileName, kal_uint32 Flags, kal_uint32 caller_address);
RTTDLL RTFHANDLE RTFAPI RTFReopen(const WCHAR * FileName, kal_uint32 Flags, RTFHANDLE handle);
RTTDLL RTFHANDLE RTFAPI RTFOpenHint(const WCHAR * FileName, kal_uint32 Flags, RTFDirLocation * DSR_Hint, kal_uint32 caller_address);
RTTDLL int RTFAPI RTFCloseFile(RTFHANDLE File, BYTE freeSlot);
#define RTFKEEPSLOT 0
#define RTFFREESLOT 1
RTTDLL int RTFAPI RTFClose(RTFHANDLE File);
#define RTFSoftClose(File) RTFCloseFile(File, RTFKEEPSLOT)
RTTDLL int RTFAPI RTFRead(RTFHANDLE File, void * DataPtr, UINT Length, UINT * Read);
RTTDLL int RTFAPI RTFWrite(RTFHANDLE File, void * DataPtr, UINT Length, UINT * Written);
RTTDLL kal_int64 RTFAPI RTFSeek(RTFHANDLE File, kal_int64 Offset, int Whence);
RTTDLL int RTFAPI RTFExtend(RTFHANDLE File, kal_uint32 Length);
RTTDLL int RTFAPI RTFCommit(RTFHANDLE File, kal_uint32 Flag);
RTTDLL int RTFAPI RTFTruncate(RTFHANDLE File);
// Information about Files
RTTDLL int RTFAPI RTFGetFileInfo(RTFHANDLE File, RTFFileInfo * FileInfo, UINT Flags);
RTTDLL int RTFAPI RTFGetFileSize(RTFHANDLE File, kal_uint32 * Size);
RTTDLL int RTFAPI RTFGetFilePosition(FS_HANDLE fh, kal_uint32 *position);
RTTDLL int RTFAPI RTFSetFileTime(RTFHANDLE File, const RTFDOSDateTime * Time);
RTTDLL int RTFAPI RTFSetFileCreatedTime(RTFHANDLE File, const RTFDOSDateTime * Time);
RTTDLL int MTCheckMSCard(RTFHANDLE File, RTFBootRecord *BR);
// File Attributes
RTTDLL int RTFAPI RTFGetAttributes(const WCHAR * FileName);
RTTDLL int RTFAPI RTFSetAttributes(const WCHAR * FileName, BYTE Attributes);
// Directories
RTTDLL int RTFAPI RTFGetCurrentDir(WCHAR * DirName, UINT MaxLength);
RTTDLL int RTFAPI RTFGetCurrentDirByDrive(WCHAR * DirName, UINT MaxLength);
RTTDLL int RTFAPI RTFSetCurrentDir(const WCHAR * DirName);
RTTDLL int RTFAPI RTFCreateDir(const WCHAR * DirName, kal_uint32 attributes);
RTTDLL int RTFAPI RTFRemoveDir(const WCHAR * DirName);
RTTDLL int RTFAPI RTFCompactDir(const WCHAR * DirName, kal_uint32 Flags);
// Finding Files
RTTDLL RTFHANDLE RTFAPI RTFFindFirstEx (const WCHAR * NamePattern, BYTE Attr, BYTE AttrMask, RTFDOSDirEntry * FileInfo, WCHAR * FileName, UINT MaxLength, RTFFileOpenHint *OpenHint, kal_uint32 caller_address);
RTTDLL int RTFAPI RTFFindNextEx (RTFHANDLE File, RTFDOSDirEntry * FileInfo, WCHAR * FileName, UINT MaxLength, RTFFileOpenHint *OpenHint);
RTTDLL int RTFAPI RTFFindClose(RTFHANDLE File);
RTTDLL int RTFAPI RTFGetDiskInfoEx(const WCHAR * DriveName, RTFDiskInfo * DiskInfo, int Flags);
// File Name Operations
RTTDLL int RTFAPI RTFRename(const WCHAR * FileName, const WCHAR * NewName);
RTTDLL int RTFAPI RTFDelete(const WCHAR * FileName);
RTTDLL int RTFAPI RTFMakeTempFileName(const WCHAR * DirName, WCHAR * FileName, UINT MaxLength);
RTTDLL int RTFAPI RTFMakeFileName(const RTFDOSDirEntry * FileInfo, WCHAR * FileName);
RTTDLL int RTFAPI RTFExpandName(WCHAR * FileName, UINT MaxLength);
// Disk and Volume Management
RTTDLL int RTFAPI RTFResetDisk(const WCHAR * DriveName);
RTTDLL int RTFAPI RTFGetDiskInfoEx(const WCHAR * DriveName, RTFDiskInfo * DiskInfo, int Flags);
RTTDLL int RTFAPI RTFGetPartitionInfo(const WCHAR * DriveName, RTFPartitionInfo * PartitionInfo, kal_uint32 Option);
RTTDLL int RTFAPI RTFSetVolumeLabel(const WCHAR * DriveName, const WCHAR * Label);
RTTDLL int RTFAPI RTFFormat(const WCHAR * DriveName, UINT MinSectorsPerCluster, RTFFormatCallback Progress, kal_uint32 Flags, kal_uint32 caller_address);
RTTDLL int RTFAPI RTFFormatGetFatType(RTFBootRecord *BR, kal_uint32 *_RootDirSectors, kal_uint32 *_FATSectors, kal_uint32 *_Written);
RTTDLL void RTFAPI RTFFormatInitFatSector(kal_uint8 MediaDescriptor, kal_int32 FATType, kal_uint8 *Sector);
RTTDLL int RTFAPI RTFCheckDiskBufferSize(const WCHAR * DriveName);
RTTDLL int RTFAPI RTFCheckDisk(const WCHAR * DriveName, void * Buffer, UINT BufferSize, RTFCheckDiskCallback ErrorHandler, kal_uint32 Flags);
RTTDLL int RTFAPI RTFSanityCheck(void);
RTTDLL int RTFAPI RTFCheckBootUpFlag(void);
RTTDLL int RTFAPI RTFSetBootUpFlag(kal_bool bSet);
typedef enum {
FS_BOOTFLAG_CHECK = 0x00,
FS_BOOTFLAG_SET = 0x01,
FS_BOOTFLAG_CLEAR = 0x02
} fs_bootflag_enum;
int RTFAPI RTFBootUpFlag(fs_bootflag_enum operation);
// Miscellaneous File Functions
RTTDLL int RTFAPI RTFCommitAll(const WCHAR * DriveName);
RTTDLL int RTFAPI RTFCloseAll(void);
RTTDLL int RTFAPI RTFUnlockAll(void);
RTTDLL void RTFAPI RTFShutDown(void);
RTTDLL int RTFAPI RTFCreateMasterBootRecord(void * SectorBuffer, const RTFPartitionRecord * DiskGeometry);
RTTDLL int RTFAPI RTFSplitPartition(void * MasterBootRecord, RTFSector Sectors);
RTTDLL int RTFAPI RTFCreateBootSector(void * BootSector, const RTFPartitionRecord * Partition, BYTE MediaDescriptor, UINT MinSectorsPerCluster, kal_uint32 Flags);
// Raw I/O functions
RTTDLL int RTFAPI RTFRawLowLevelFormat(int DeviceIndex, const WCHAR * DeviceName, RTFFormatCallback Progress, kal_uint32 Flags);
// MTP support
RTTDLL int RTFAPI RTFMakeFilePathByHint(WCHAR DriveLetter, UINT DirCluster, UINT DirIndex, WCHAR * FileName, UINT MaxLength);
RTFHANDLE RTFAPI RTFOpenFileByHint(WCHAR DriveLetter, UINT DirCluster, UINT DirIndex, kal_uint32 Flags, kal_uint32 caller_address);
RTTDLL int RTFAPI RTFDeleteByHint(WCHAR DriveLetter, UINT DirCluster, UINT DirIndex);
RTTDLL int RTFAPI RTFGetAttributesByHint(WCHAR DriveLetter, UINT DirCluster, UINT DirIndex);
RTTDLL int RTFAPI RTFSetAttributesByHint(WCHAR DriveLetter, UINT DirCluster, UINT DirIndex, BYTE Attributes);
RTTDLL int RTFAPI RTFHintGetParent(WCHAR DriveLetter, UINT DirCluster, UINT DirIndex, UINT *ParentCluster, UINT *ParentIndex);
// Functions for Debugging
RTTDLL void RTFAPI RTFBufferInfo(RTFBufferStatistic * BufferInfo);
// Obsolete functions
RTTDLL kal_int32 RTFAPI RTFFindFirst(fs_list_param_struct *param,
FS_DOSDirEntry * FileInfo, WCHAR * FileName, UINT MaxLength,
UINT Flag, FS_FileLocationHint *Pos, kal_uint32 caller_address);
RTTDLL kal_int32 RTFAPI RTFFindNext(FS_HANDLE handle,
FS_Pattern_Struct * PatternArray, UINT PatternNum,
BYTE ArrayMask,
FS_DOSDirEntry * FileInfo, WCHAR * FileName, UINT MaxLength,
UINT Flag);
RTTDLL int RTFAPI RTFGetDiskInfo(const WCHAR * DriveName, RTFDiskInfo * DiskInfo);
#ifdef RTF_32_BIT
#ifdef RTT32_VER
#if RTT32_VER >= 202
RTTDDL RTFileSystemHandlers RTFilesFileSystem;
#endif
#endif
#endif
/*------------- Internal EXTERN -------------*/
#define ParseFileName(FileName) ParseFileName0((const char *)FileName)
#define ParseFileNameWithFlag(FileName, Flags) ParseFileName1((const char *)FileName, Flags)
typedef enum { NotMounted, Initialized, Mounted, Accessible, SizeExceeded, HasFileSystem } MountStates;
typedef enum {NeverUsed, Available, Lfn, InUse} DirEntry;
typedef enum { NormalFile, FileMapFile, Volume, PhysicalDisk } FileKind;
#define SEARCH_FILES 0
#define SEARCH_LABEL 1
#define SEARCH_PARENT 2
#define SEARCH_RELEASE_LOCK 4 // allow release device/system locks while searching.
#define RTF_BAD_CLUSTER 0x0FFFFFF7L
#define RTF_INVALID_CLUSTER 0xFFFFFFFFL
#define RTF_CLUSTER_CHAIN_END 0x0FFFFFF8L // also 0x0FFFFFF9..0x0FFFFFFF, test for >=, write RTF_CHAIN_END_MARK
#define RTF_ROOT_DIR 0xFFFFFFFFL // pseudo cluster for the root directory (not for FAT-32)
#define FIRST_FILE_CLUSTER(Dir) (((RTFCluster)((Dir).FirstClusterHi) << 16) + (Dir).FirstCluster)
#define FIRST_FILE_CLUSTER_LOW_WORD_ONLY(Dir) (Dir).FirstCluster
#define SET_FIRST_FILE_CLUSTER(Dir, Cluster) (Dir).FirstCluster = (Cluster), (Dir).FirstClusterHi = (Cluster) >> 16
#define CLUSTER_BIT(ClusterMap, C) ((ClusterMap[C / 8] & (1 << (C % 8))) != 0)
#define SET_CLUSTER_BIT(ClusterMap, C) ClusterMap[C / 8] |= 1 << (C % 8)
#define CLEAR_CLUSTER_BIT(ClusterMap, C) ClusterMap[C / 8] &= ~(1 << (C % 8))
#if defined(WIN32)
#pragma pack(push,1)
#endif
typedef __fs_packed_prefix struct {
BYTE Ord; // sequency number (backwards, 0x40 set if last record)
WORD Name1[5]; // name chars 1..5
BYTE Attributes; // magic value
BYTE Type; // must be zero
BYTE CheckSum; // checksum of the short name
WORD Name2[6]; // name chars 6..11
WORD FirstCluster; // zero
WORD Name3[2]; // name chars 12..13
} __fs_packed_postfix LFNDirEntry;
#if defined(WIN32)
#pragma pack(pop)
#endif
RTTDDL RTFTables gFS_Data;
//RTTDDL RTFTables RTFData;
RTTDDL const WCHAR dchar_dot[]; /* . */
RTTDDL const WCHAR dchar_dot_dot[]; /* .. */
RTTDDL const WCHAR dchar_start_dot_star[];
RTTDDL const WCHAR dchar_star[];
RTTDDL RTFMutex *RTFLock;
RTTDDL RTFMutex *MTFMLock;
RTTDDL RTFMutex *MTXLock;
RTTDDL RTFMutex *MTMoveLock;
RTTDDL RTFMutex *MTXdelLock;
#ifdef __FS_SORT_SUPPORT__
RTTDDL RTFMutex *MTSortLock;
#endif
RTTDDL RTFMutex *MTDiskInfoLock;
RTTDDL int DrvMappingOld;
RTTDDL int DrvMappingNew;
RTTDLL int RTFAPI SearchFile(RTFile * f, UINT Flags, const char * FileName, RTFDirLocation * DSR_Hint);
RTTDLL RTFile * RTFAPI ParseFileName0(const char * FileName);
RTTDLL RTFile * RTFAPI ParseFileName1(const char * FileName, kal_uint32 Flags);
RTTDLL void RTFAPI RTFInit(void);
RTTDLL void RTFAPI DiscardAllBuffers(RTFDevice * Dev);
RTTDLL void RTFAPI MountLogicalDrive(RTFDrive * Drive, MountStates State);
RTTDLL void RTFAPI FlushAllBuffers(RTFDevice * Dev);
RTTDLL void RTFAPI FreeFTSlot(RTFile * f);
RTTDLL RTFile * RTFAPI ParseFileHandleEx(RTFHANDLE File, kal_uint32 Option);
RTTDLL int RTFAPI WFNamesMatch(const char * N1, const char * N2);
extern RTFDOSDirEntry *StartDirSearchPrefetch(RTFDrive * Drive, RTFCluster Cluster, UINT Index, RTFDirLocation * DSR, kal_int32 PrefetchSectors);
RTTDLL RTFDOSDirEntry * RTFAPI GetDirPrefetch(RTFDrive * Drive, const RTFDirLocation * Pos, kal_int32 PrefetchSectors);
RTTDLL RTFDOSDirEntry * RTFAPI NextDirPrefetch(RTFDrive * Drive, RTFDirLocation * DSR, kal_int32 PrefetchSectors);
extern int IncDirPrefetch(RTFDrive * Drive, RTFDirLocation * DSR, kal_int32 PrefetchSectors);
#define StartDirSearch(Drive, Cluster, Index, DSR) StartDirSearchPrefetch(Drive, Cluster, Index, DSR, 0)
#define GetDir(Drive, Pos) GetDirPrefetch(Drive, Pos, 0)
#define IncDir(Drive, DSR) IncDirPrefetch(Drive, DSR, 0)
#define NextDir(Drive, DSR) NextDirPrefetch(Drive, DSR, 0)
RTTDLL DirEntry RTFAPI EntryType(const RTFDOSDirEntry * D);
RTTDLL int RTFAPI LFNCharCount(const LFNDirEntry * LD);
RTTDLL void RTFAPI CopyLFN(char * Name, const LFNDirEntry * LD);
RTTDLL int RTFAPI MakeShortFileName(const RTFDOSDirEntry * FileInfo, char * FileName, UINT MaxLength);
RTTDLL void RTFAPI FileNameExtendToWCHAR(char *filename, kal_uint32 max_length);
RTTDLL void RTFAPI MakePseudoRootDirEntry(RTFDrive * Drive, RTFDirEntry * DirEntry);
RTTDLL void RTFAPI InitFilePointer(RTFile * f);
RTTDLL RTFHANDLE RTFAPI MakeNewFileHandle(RTFile * f);
RTTDLL void RTFAPI FreeFTSlotAndDevice(RTFile * f);
RTTDLL BYTE RTFAPI ShortNameCheckSum(const BYTE * Name);
RTTDLL int RTFAPI FileNamesMatch(const WCHAR * p, const WCHAR * n);
RTTDLL void RTFAPI DeleteDirEntry(RTFile * f);
RTTDLL void RTFAPI UpdateDirEntry(RTFile * f);
RTTDLL void RTFAPI ExtendFile(RTFile * f, kal_uint32 Bytes, kal_uint32 Options);
RTTDLL void RTFAPI CommitBuffer(RTFDevice * Dev);
RTTDLL void RTFAPI SetClusterValue(RTFDrive * Drive, RTFCluster Cluster, RTFCluster Value);
RTTDLL int RTFAPI SafeLock(kal_uint32 Lock, RTFDevice * Dev, UINT Timeout);
RTTDLL int RTFAPI SafeUnlock(kal_uint32 Lock);
RTTDLL void RTFAPI CheckNotOpen(RTFile * File);
RTTDLL int RTFAPI UpdateClusterWatermark(RTFDrive * Drive, RTFCluster Watermark, int DeltaFreeClusters);
RTTDLL int RTFAPI RTFCheckDiskFlag(void);
RTTDLL void RTFAPI CheckSharing(RTFile * File);
RTTDLL RTFCluster RTFAPI SafeGetClusterValue(RTFDrive * Drive, RTFCluster Cluster);
RTTDLL void RTFAPI DelDirEntry(RTFDrive * Drive, RTFDirLocation * LongPos, const RTFDirLocation * Pos);
RTTDLL int RTFAPI IsValidLongNameChar(WCHAR c);
RTTDLL RTFCluster RTFAPI FATDelete(RTFDrive * Drive, RTFCluster Cluster, RTFile * f);
RTTDLL int RTFAPI FileNameInvalid(const char * Name);
RTTDLL void RTFAPI UnmountDevice(RTFDevice * Dev, int CloseFiles);
RTTDLL WCHAR* RTFAPI CheckValidFileName2(const WCHAR * FileName, kal_bool bCheckLeading);
RTTDLL void RTFAPI CheckValidFileName(const WCHAR * FileName);
RTTDLL int RTFAPI CheckValidVolumeLabel(const WCHAR * Label);
#if defined(__FS_CACHE_SUPPORT__) && !defined(__FS_CARD_DOWNLOAD__)
RTFCluster fs_srv_get_cluster_value(RTFDrive * Drive, RTFCluster Cluster, kal_uint32 Option, kal_int32 PrefetchSectorLength);
#else // defined(__FS_CACHE_SUPPORT__) && !defined(__FS_CARD_DOWNLOAD__)
typedef void * (*fs_func_get_buffer) (RTFDevice * Dev, RTFSector Sector, UINT Flags);
RTFCluster fs_srv_get_cluster_value(RTFDrive * Drive, RTFCluster Cluster, kal_uint32 Option, fs_func_get_buffer GetBufferFunc);
#endif // defined(__FS_CACHE_SUPPORT__) && !defined(__FS_CARD_DOWNLOAD__)
/*------------- Internal Use -------------*/
typedef enum {
MT_ENUM_FH_INVALID,
MT_ENUM_FH_VALID,
MT_ENUM_FH_MEDIACHANGED,
MT_ENUM_FH_ABORTED,
MT_ENUM_FH_EXPORTED
}MT_FH_ENUM;
//Device Flag (lower 16 bit only; higher 16 bit for driver)
#define MT_DEVICE_NOR_FLASH 0x0040
#define MT_DEVICE_NAND_FLASH 0x0080
#define MT_DEVICE_WRITE_PROTECT 0x0100
#define MT_DEVICE_NO_EXPORT 0x0200
#define MT_DEVICE_EXPORTING 0x0400
#define MT_DEVICE_EXTERNAL 0x0800
#define MT_DEVICE_SIMPLUS 0x1000
#define MT_DEVICE_MEMORY_STICK 0x4000
#define MT_DEVICE_CHECK_PART 0x8000
//Special for function
#define MT_LOCK_RTF 0x00000002 //SafeUnlockDevice
#define MT_LOCK_DEV 0x00000004 //SafeUnlockDevice
#define MT_LOCK_FMT 0x00000008 //SafeUnlockDevice
#define MT_LOCK_EXT 0x00000010 //SafeUnlockDevice
#define MT_LOCK_MOVE 0x00000020 //SafeUnlockDevice
#define MT_LOCK_XDEL 0x00000040 //SafeUnlockDevice
#define MT_LOCK_SORT 0x00000080 //SafeUnlockDevice
#define MT_LOCK_TRACE 0x00000100 //SafeUnlockDevice
#define MT_LOCK_DISKIF 0x00000200 //SafeUnlockDevice
#define MT_LOCK_ALL 0x000001FF //MT_LOCK_DISKIF, Except MT_LOCK_DISKIF
//drive letter
#define MT_BASE_DRIVE_LETTER 'C'
#define MT_BASE_DRIVE_INDEX 0
//for sanity check
#define MT_CHECKDISK_MAX_DEPTH 10
//Error Code Number
#define MT_SYSTEM_CRASH -43 //for NAND Bad Block
#define MT_FAIL_GET_MEM -44 //for get system memory failure
#define MT_READ_ONLY_ERROR -45 //for access on read only error
#define MT_DEVICE_BUSY -46 //for look up device status
#define MT_ABORTED_ERROR -47 //for abort copy
#define MT_QUOTA_OVER_DISK_SPACE -48 //for quota management configure check
#define MT_PATH_OVER_LEN_ERROR -49 //for longh path over 260
#define MT_APP_QUOTA_FULL -50 //for quota management
#define MT_VF_MAP_ERROR -51 //for virtual file feature
#define MT_DEVICE_EXPORTED_ERROR -52 //for usb access in normal mode
#define MT_DISK_FRAGMENT -53 //for RTF_Extend() user
#define MT_DIRCACHE_EXPIRED -54 //for dir cache feature
#define MT_QUOTA_USAGE_WARNING -55 //for quota management run time usage check
#define MT_ERR_DIRDATA_LOCKED -56 //for dir cache feature
// Error codes that related to device driver feature or system/kernel adadption layer
#define MT_MSDC_MOUNT_ERROR -100 //for MSDC only
#define MT_MSDC_READ_SECTOR_ERROR -101 //for MSDC only
#define MT_MSDC_WRITE_SECTOR_ERROR -102 //for MSDC only
#define MT_MSDC_DISCARD_SECTOR_ERROR -103 //for MSDC only
#define MT_MSDC_PRESNET_NOT_READY -104 //for MSDC only
#define MT_MSDC_NOT_PRESENT -105 //for MSDC only
#define MT_EXTERNAL_DEVICE_NOT_PRESENT -106 //for USB OTG only
#define MT_FLASH_MOUNT_ERROR -120 //for flash driver
#define MT_FLASH_ERASE_BUSY -121 //for flash driver
#define MT_NAND_DEVICE_NOT_SUPPORTED -122 //for flash driver
#define MT_LOCK_MUTEX_FAIL -141
#define MT_NO_NONBLOCKMODE -142
#define MT_NO_PROTECTIONMODE -143
#define MT_DISK_SIZE_TOO_LARGE (MT_MSDC_MOUNT_ERROR)
//Trace Code Number
#define MT_TRACE_QM_OK -500 //for Quota Feature only
#define MT_TRACE_QM_ERR -501 //for Quota Feature only
//New API
RTTDLL int RTFAPI MTGetDrive(kal_uint32 Type, kal_uint32 Serial, kal_uint32 AltMask);
RTTDLL int RTFAPI MTMappingDrive(kal_uint32 UpperOldDrv, kal_uint32 UpperNewDrv);
RTTDLL void RTFAPI MTTraceFS(kal_uint32 TaskId, kal_uint32 FileCode, kal_uint32 Line, int Code, RTFile * f, BYTE * TraceStr);
RTTDLL void * RTFAPI MTProxyGetBuffer (RTFDevice * Dev, RTFSector Sector);
RTTDLL int RTFAPI MTCopyFileByClusterChain(RTFHANDLE FileDst, RTFCluster *ClustersArray, UINT ClusterNum);
RTTDLL UINT RTFAPI GetFirstSector(WCHAR * FileName, void * SectorContent, UINT *Sector1, UINT *Sector2);
RTTDLL int RTFAPI SetCopyrightEntry(RTFDirLocation *lFS_CopyrightLongPos, RTFDirLocation *lFS_CopyrightShortPos, RTFDOSDirEntry *lFS_CopyrightDir);
RTTDLL int RTFAPI BatchCountFreeClusters(RTFDrive * Drive);
RTTDLL kal_int32 RTFAPI MTGetDirCacheValue(RTFDrive * Drive, RTFCluster DirCluster, kal_uint32 * CurrValue);
RTTDLL kal_int32 RTFAPI MTSetDirCacheValue(RTFDrive * Drive, RTFCluster DirCluster, kal_uint32 NewValue);
RTTDLL kal_int32 RTFAPI MTExpireDirCacheValue(RTFDrive * Drive, RTFCluster DirCluster);
RTTDLL void RTFAPI MTExpireDirCacheByDrive(RTFDrive* Drive);
RTTDLL int RTFAPI CleanUpDataSectors(RTFDrive * Drive, RTFCluster *Start, int MaxClusters);
RTTDLL void RTFAPI MTCheckSharingWithSpecialKindFh(RTFile * File);
RTTDLL void RTFAPI MTToLowerString(WCHAR *FileName, UINT MaxLength);
RTTDLL void RTFAPI MTCheckFileNameCase(WCHAR *FileName, UINT MaxLength, BYTE NTReserved);
RTTDLL WCHAR * RTFAPI TruncateWideWhiteSpacesAndPeriods(const WCHAR *pSrcBuf);
RTTDLL WCHAR * RTFAPI TruncateWideBackSlash(WCHAR *path);
RTTDLL RTFDrive* RTFAPI MTGetRTFDriveByDriveFileName(const WCHAR *DriveName);
RTTDLL void RTFAPI MTClearFileTableByDrive(RTFDrive* drive);
#ifdef __FS_DEDICATED_BUFFER__
RTTDLL void RTFAPI MTBufInit(const kal_uint32 buf_addr, const kal_uint32 buf_size);
RTTDLL int RTFAPI MTBufAlloc(unsigned int size, unsigned char **buf, unsigned int flag);
RTTDLL void RTFAPI MTBufFree(unsigned int size, unsigned char **buf);
RTTDLL int RTFAPI MTBufCheckRange(unsigned int addr);
#endif /* __FS_DEDICATED_BUFFER__ */
#ifdef __FS_OPEN_HINT__
RTTDLL void RTFAPI MTHintAlloc(void);
RTTDLL int RTFAPI MTHintNew(kal_uint8 PathIndex, kal_uint8 Level, RTFDirLocation *Location, RTFile *f, WCHAR *FileName);
RTTDLL void RTFAPI MTHintNewManual(kal_int8 PathIndex, const WCHAR *Path, WCHAR *FileName, RTFDirLocation *Location, UINT DirCluster);
RTTDLL void RTFAPI MTHintExpireByDrive(RTFDrive *Drive);
RTTDLL RTFDirLocation* RTFAPI MTHintGet(const WCHAR *Path, RTFOpenHintActionEnum Action);
RTTDLL void RTFAPI MTHintFinish(FS_OpenHintInt *hint);
RTTDLL void RTFAPI MTHintPause(kal_uint8 PathIndex, RTFOpenHintActionEnum Action);
RTTDLL void RTFAPI MTHintDelete(kal_uint8 PathIndex);
RTTDLL void RTFAPI MTHintFindFirst(FS_OpenHintInt *hint, RTFDirLocation* location, RTFile *f, WCHAR* filename);
RTTDLL void RTFAPI MTHintFindNext(RTFDirLocation* location, RTFHANDLE fh, WCHAR* filename);
RTTDLL void RTFAPI MTHintFindClose(RTFHANDLE fh);
RTTDLL void RTFAPI MTHintDiscard(kal_uint8 path_idx);
#endif /* __FS_OPEN_HINT__ */
#ifdef __FS_SMART_FILE_SEEKER__
RTTDLL void RTFAPI MTSH_AddSeekHint(RTFile *f, RTFDirLocation *Hint, UINT Type);
RTTDLL void RTFAPI MTSH_ReCalHintData(RTFile *f);
RTTDLL void RTFAPI MTSH_DelHintByOffset(RTFile *f);
RTTDLL RTFCluster RTFAPI MTSH_GetNextStaticMilestone(RTFile *f, kal_uint32 CurrPos);
RTTDLL int RTFAPI MTSH_SearchHint(RTFile *f, UINT Pos);
#endif // __FS_SMART_FILE_SEEKER__
extern int RTFGetListEntry(FS_HANDLE handle, kal_wchar *path, kal_wchar *FileName, kal_uint32 MaxLength, FS_DOSDirEntry *FileInfo, kal_int32 index);
extern UINT MoveFilePointerSegment(RTFile * f, UINT Offset);
extern void MoveFilePointer(RTFile * f, UINT Offset);
extern int rtf_core_read_sectors(RTFDevice * Dev, void * Data, RTFSector Sector, UINT Sectors, DWORD Flags);
extern int rtf_core_write_sectors(RTFDevice * Dev, void * Data, RTFSector Sector, UINT Sectors, DWORD Flags, BYTE recoverable_flag);
extern void MTHintGen(RTFDirLocation *Hint, RTFDirLocation *DSR_SFN, RTFile *f);
extern int SearchFile(RTFile * f, UINT Flags, const char * FileName, RTFDirLocation * DSR_Hint);
extern void MountLogicalDrive(RTFDrive * Drive, MountStates State);
extern void FreeFTSlot(RTFile * f);
extern RTFHANDLE MakeNewFileHandle(RTFile * f);
extern void InitFilePointer(RTFile * f);
extern void CheckMedia(RTFDevice * Dev);
extern void CheckDirEntry(RTFile *f);
extern RTFDrive * AllocateDrive(char DriveLetter, RTFDevice * Dev);
extern int MountRemovableDevice(RTFDevice *Dev);
extern int rtf_core_mount_device(RTFDevice * Dev, DWORD Flags);
extern void ScanDevices(void);
extern int GenerateShortName(const char * LongName, char * ShortName);
extern int GenerateVolumeLable(const char * LongName, char * ShortName);
extern int RTFAPI fs_srv_findnext(FS_HANDLE handle,
FS_Pattern_Struct * PatternArray, UINT PatternNum,
BYTE ArrayMask,
FS_DOSDirEntry * FileInfo, WCHAR * FileName, UINT MaxLength,
UINT Flag,
FS_FileLocationHint * FilePos);
extern int FNamesMatch(const char * N1, const char * N2);
extern kal_int32 MTSearchDirData(RTFDrive * drive, RTFCluster dir_cluster);
extern kal_int32 GetFileHandle(RTFile *f);
extern void RTFileCheck_NormalFile_InvalidHandle(RTFile *f);
extern void RTFileCheck_NormalFile_InvalidFilename(RTFile *f);
extern void RTFileCheck_AttrDir_InvalidHandle(RTFile *f);
extern void RTFileCheck_WriteProtect(RTFile *f);
extern void RTFileCheck_Aborted(RTFile *f);
extern void RTFileCheck_Drive(RTFile *f);
extern void RTFileCheck_DirPath(RTFile *f);
extern void RTFHandle_MediaChange(RTFDevice *Dev);
//MTGetDrive Parameter
#define MT_NO_ALT_DRIVE 0x00000001
#define MT_ONLY_ALT_SERIAL 0x00000002
#define MT_DRIVE_I_SYSTEM 0x00000004
#define MT_DRIVE_V_NORMAL 0x00000008
#define MT_DRIVE_V_REMOVABLE 0x00000010
#define MT_DRIVE_V_EXTERNAL 0x00000020
#define MT_DRIVE_V_SIMPLUS 0x00000040
//NTReserved for Find series
typedef enum{
MT_ENUM_FIND_NONE,
MT_ENUM_FIND_LFN,
MT_ENUM_FIND_SFN,
MT_ENUM_LOWERCASE_MARK = 0x08,
MT_ENUM_EXT_LOWERCASE_MARK = 0x10
}MT_FIND_ENUM;
//MTSetTrace Parameter
#define MT_TRACE_API 0x00000001
#define MT_TRACE_ERROR 0x00000002
#define MT_TRACE_DISABLE 0x00000004
#define MT_TRACE_ALL_TASK 0x00000008
#ifdef __FS_QM_SUPPORT__
typedef FS_QuotaStruct QuotaStruct;
typedef struct __InternQuotaStruct
{
UINT Qmin;
UINT Qmax;
UINT Qnow;
}InternQuotaStruct;
typedef enum
{
MT_QP_HIG_ENUM,
MT_QP_MID_ENUM,
MT_QP_LOW_ENUM,
MT_QP_DEL_ENUM
}MT_QP_ENUM;
extern FS_QuotaStruct *gFS_IntQuotaSet;
extern UINT FS_MAX_QSET;
extern WCHAR NvramName[6];
#endif // __FS_QM_SUPPORT__
extern const UINT FS_MAX_DRIVES;
extern UINT FS_MAX_FILES;
extern const UINT FS_MAX_BUFFERS;
extern const UINT FS_MAX_THREAD;
extern kal_taskid gFS_TaskList[];
extern fs_tls_struct _gfs_tls[];
extern const int gFS_DeviceNumOfSYSDRV;
extern const UINT FS_MAX_CHECK_BUFFER;
extern BYTE gFS_SanityCheckBuffer[];
extern int SysLockFAT; // for USB mode
extern int SysBlockFAT; // for single bank
extern char gFS_Export; // for USB normal mode
extern kal_taskid gFS_ExportOwnerTaskID;
extern int CardBusyCheck;
extern kal_bool COPYRIGHT_USB_ON;
#ifdef __FS_OPEN_HINT__
extern FS_OpenHintPath gFS_OpenHintPath[];
extern FS_OpenHintInt gFS_OpenHint[];
extern BYTE gFS_OpenHintLocationData[];
extern const UINT FS_MAX_OPEN_HINT_PATH;
extern const UINT FS_MAX_OPEN_HINT_LOCATION_PER_HINT;
#endif /* __FS_OPEN_HINT_ */
#define FS_DIRDATA_MASK_TIME (0x3FFFFFFF)
#define FS_DIRDATA_MASK_LOCKED (0x80000000)
#define FS_DIRDATA_MASK_EXPIRED (0x40000000)
typedef struct _fsDirData {
RTFDrive * Drive;
RTFCluster Cluster;
kal_uint32 Value;
kal_uint32 Status;
} FS_DirDataStruct;
extern FS_DirDataStruct _gfs_dir_data[];
#ifdef __EMMC_BOOTING__
extern kal_uint32 _gfs_system_drive_size;
#endif // __EMMC_BOOTING__
/**
* Macro Definitions
*/
#if !defined(__FS_SLIM_RTFINIT__)
#define fs_init() do {if (RTFLock == NULL) RTFInit(); } while (0)
#else
#define fs_init()
#endif // __FS_SLIM_RTFINIT__
#if defined(__FS_CACHE_SUPPORT__) && !defined(__FS_CARD_DOWNLOAD__)
#define GetClusterValue(drive, cluster, fat_prefetch_size) fs_srv_get_cluster_value(drive, cluster, FS_GET_CLUSTER_DEFAULT, fat_prefetch_size)
#else // defined(__FS_CACHE_SUPPORT__) && !defined(__FS_CARD_DOWNLOAD__)
extern RTFCluster GetClusterValue(RTFDrive * Drive, RTFCluster Cluster, kal_int32 PrefetchSectorLength);
#endif // defined(__FS_CACHE_SUPPORT__) && !defined(__FS_CARD_DOWNLOAD__)
#define ParseFileHandle(a) ParseFileHandleEx(a, 0)
#ifdef __cplusplus
}
#endif
#endif