ff.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. /*---------------------------------------------------------------------------/
  2. / FatFs - FAT file system module include file R0.08a (C)ChaN, 2010
  3. /----------------------------------------------------------------------------/
  4. / FatFs module is a generic FAT file system module for small embedded systems.
  5. / This is a free software that opened for education, research and commercial
  6. / developments under license policy of following trems.
  7. /
  8. / Copyright (C) 2010, ChaN, all right reserved.
  9. /
  10. / * The FatFs module is a free software and there is NO WARRANTY.
  11. / * No restriction on use. You can use, modify and redistribute it for
  12. / personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
  13. / * Redistributions of source code must retain the above copyright notice.
  14. /
  15. /----------------------------------------------------------------------------*/
  16. #ifndef _FATFS
  17. #define _FATFS 8255 /* Revision ID */
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #include "integer.h" /* Basic integer types */
  22. #include "ffconf.h" /* FatFs configuration options */
  23. #if _FATFS != _FFCONF
  24. #error Wrong configuration file (ffconf.h).
  25. #endif
  26. /* DBCS code ranges and SBCS extend char conversion table */
  27. #if _CODE_PAGE == 932 /* Japanese Shift-JIS */
  28. #define _DF1S 0x81 /* DBC 1st byte range 1 start */
  29. #define _DF1E 0x9F /* DBC 1st byte range 1 end */
  30. #define _DF2S 0xE0 /* DBC 1st byte range 2 start */
  31. #define _DF2E 0xFC /* DBC 1st byte range 2 end */
  32. #define _DS1S 0x40 /* DBC 2nd byte range 1 start */
  33. #define _DS1E 0x7E /* DBC 2nd byte range 1 end */
  34. #define _DS2S 0x80 /* DBC 2nd byte range 2 start */
  35. #define _DS2E 0xFC /* DBC 2nd byte range 2 end */
  36. #elif _CODE_PAGE == 936 /* Simplified Chinese GBK */
  37. #define _DF1S 0x81
  38. #define _DF1E 0xFE
  39. #define _DS1S 0x40
  40. #define _DS1E 0x7E
  41. #define _DS2S 0x80
  42. #define _DS2E 0xFE
  43. #elif _CODE_PAGE == 949 /* Korean */
  44. #define _DF1S 0x81
  45. #define _DF1E 0xFE
  46. #define _DS1S 0x41
  47. #define _DS1E 0x5A
  48. #define _DS2S 0x61
  49. #define _DS2E 0x7A
  50. #define _DS3S 0x81
  51. #define _DS3E 0xFE
  52. #elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */
  53. #define _DF1S 0x81
  54. #define _DF1E 0xFE
  55. #define _DS1S 0x40
  56. #define _DS1E 0x7E
  57. #define _DS2S 0xA1
  58. #define _DS2E 0xFE
  59. #elif _CODE_PAGE == 437 /* U.S. (OEM) */
  60. #define _DF1S 0
  61. #define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
  62. 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,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xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
  71. #elif _CODE_PAGE == 737 /* Greek (OEM) */
  72. #define _DF1S 0
  73. #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \
  74. 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
  75. 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
  76. 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
  77. #elif _CODE_PAGE == 775 /* Baltic (OEM) */
  78. #define _DF1S 0
  79. #define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \
  80. 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB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0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
  89. #elif _CODE_PAGE == 852 /* Latin 2 (OEM) */
  90. #define _DF1S 0
  91. #define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \
  92. 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \
  93. 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
  94. 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF}
  95. #elif _CODE_PAGE == 855 /* Cyrillic (OEM) */
  96. #define _DF1S 0
  97. #define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \
  98. 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5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xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
  107. #elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */
  108. #define _DF1S 0
  109. #define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \
  110. 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
  111. 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
  112. 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
  113. #elif _CODE_PAGE == 862 /* Hebrew (OEM) */
  114. #define _DF1S 0
  115. #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0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,0xDC,0xDD,0xDE,0xDF, \
  124. 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
  125. #elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */
  126. #define _DF1S 0
  127. #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
  128. 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
  129. 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
  130. 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
  131. #elif _CODE_PAGE == 1250 /* Central Europe (Windows) */
  132. #define _DF1S 0
  133. #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x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xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
  142. 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF}
  143. #elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */
  144. #define _DF1S 0
  145. #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \
  146. 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
  147. 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
  148. 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F}
  149. #elif _CODE_PAGE == 1253 /* Greek (Windows) */
  150. #define _DF1S 0
  151. #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8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,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
  160. 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F}
  161. #elif _CODE_PAGE == 1255 /* Hebrew (Windows) */
  162. #define _DF1S 0
  163. #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
  164. 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
  165. 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
  166. 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
  167. #elif _CODE_PAGE == 1256 /* Arabic (Windows) */
  168. #define _DF1S 0
  169. #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \
  170. 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
  171. 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
  172. 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF}
  173. #elif _CODE_PAGE == 1257 /* Baltic (Windows) */
  174. #define _DF1S 0
  175. #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
  176. 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \
  177. 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,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for only non-LFN cfg) */
  186. #define _DF1S 0
  187. #else
  188. #error Unknown code page
  189. #endif
  190. /* Definitions of volume management */
  191. #if _MULTI_PARTITION /* Multiple partition configuration */
  192. #define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive# */
  193. #define LD2PT(vol) (VolToPart[vol].pt) /* Get partition# */
  194. typedef struct
  195. {
  196. BYTE pd; /* Physical drive# */
  197. BYTE pt; /* Partition # (0-3) */
  198. } PARTITION;
  199. extern const PARTITION VolToPart[]; /* Volume - Physical location resolution table */
  200. #else /* Single partition configuration */
  201. #define LD2PD(vol) (vol) /* Logical drive# is bound to the same physical drive# */
  202. #define LD2PT(vol) 0 /* Always mounts the 1st partition */
  203. #endif
  204. /* Type of path name strings on FatFs API */
  205. #if _LFN_UNICODE /* Unicode string */
  206. #if !_USE_LFN
  207. #error _LFN_UNICODE must be 0 in non-LFN cfg.
  208. #endif
  209. #ifndef _INC_TCHAR
  210. typedef WCHAR TCHAR;
  211. #define _T(x) L ## x
  212. #define _TEXT(x) L ## x
  213. #endif
  214. #else /* ANSI/OEM string */
  215. #ifndef _INC_TCHAR
  216. typedef char TCHAR;
  217. #define _T(x) x
  218. #define _TEXT(x) x
  219. #endif
  220. #endif
  221. /* File system object structure (FATFS) */
  222. typedef struct
  223. {
  224. BYTE fs_type; /* FAT sub-type (0:Not mounted) */
  225. BYTE drv; /* Physical drive number */
  226. BYTE csize; /* Sectors per cluster (1,2,4...128) */
  227. BYTE n_fats; /* Number of FAT copies (1,2) */
  228. BYTE wflag; /* win[] dirty flag (1:must be written back) */
  229. BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
  230. WORD id; /* File system mount ID */
  231. WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
  232. #if _MAX_SS != 512
  233. WORD ssize; /* Bytes per sector (512,1024,2048,4096) */
  234. #endif
  235. #if _FS_REENTRANT
  236. _SYNC_t sobj; /* Identifier of sync object */
  237. #endif
  238. #if !_FS_READONLY
  239. DWORD last_clust; /* Last allocated cluster */
  240. DWORD free_clust; /* Number of free clusters */
  241. DWORD fsi_sector; /* fsinfo sector (FAT32) */
  242. #endif
  243. #if _FS_RPATH
  244. DWORD cdir; /* Current directory start cluster (0:root) */
  245. #endif
  246. DWORD n_fatent; /* Number of FAT entries (= number of clusters + 2) */
  247. DWORD fsize; /* Sectors per FAT */
  248. DWORD fatbase; /* FAT start sector */
  249. DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */
  250. DWORD database; /* Data start sector */
  251. DWORD winsect; /* Current sector appearing in the win[] */
  252. BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and Data on tiny cfg) */
  253. } FATFS;
  254. /* File object structure (FIL) */
  255. typedef struct
  256. {
  257. FATFS *fs; /* Pointer to the owner file system object */
  258. WORD id; /* Owner file system mount ID */
  259. BYTE flag; /* File status flags */
  260. BYTE pad1;
  261. DWORD fptr; /* File read/write pointer (0 on file open) */
  262. DWORD fsize; /* File size */
  263. DWORD org_clust; /* File start cluster (0 when fsize==0) */
  264. DWORD curr_clust; /* Current cluster */
  265. DWORD dsect; /* Current data sector */
  266. #if !_FS_READONLY
  267. DWORD dir_sect; /* Sector containing the directory entry */
  268. BYTE *dir_ptr; /* Ponter to the directory entry in the window */
  269. #endif
  270. #if _USE_FASTSEEK
  271. DWORD *cltbl; /* Pointer to the cluster link map table (null on file open) */
  272. #endif
  273. #if _FS_SHARE
  274. UINT lockid; /* File lock ID (index of file semaphore table) */
  275. #endif
  276. #if !_FS_TINY
  277. BYTE buf[_MAX_SS]; /* File data read/write buffer */
  278. #endif
  279. } FIL;
  280. /* Directory object structure (DIR) */
  281. typedef struct
  282. {
  283. FATFS *fs; /* Pointer to the owner file system object */
  284. WORD id; /* Owner file system mount ID */
  285. WORD index; /* Current read/write index number */
  286. DWORD sclust; /* Table start cluster (0:Root dir) */
  287. DWORD clust; /* Current cluster */
  288. DWORD sect; /* Current sector */
  289. BYTE *dir; /* Pointer to the current SFN entry in the win[] */
  290. BYTE *fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
  291. #if _USE_LFN
  292. WCHAR *lfn; /* Pointer to the LFN working buffer */
  293. WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
  294. #endif
  295. } DIR;
  296. /* File status structure (FILINFO) */
  297. typedef struct
  298. {
  299. DWORD fsize; /* File size */
  300. WORD fdate; /* Last modified date */
  301. WORD ftime; /* Last modified time */
  302. BYTE fattrib; /* Attribute */
  303. TCHAR fname[13]; /* Short file name (8.3 format) */
  304. DWORD clust; /* start cluster */
  305. #if _USE_LFN
  306. TCHAR *lfname; /* Pointer to the LFN buffer */
  307. UINT lfsize; /* Size of LFN buffer in TCHAR */
  308. #endif
  309. } FILINFO;
  310. /* File function return code (FRESULT) */
  311. typedef enum
  312. {
  313. FR_OK = 0, /* (0) Succeeded */
  314. FR_DISK_ERR, /* (1) A hard error occured in the low level disk I/O layer */
  315. FR_INT_ERR, /* (2) Assertion failed */
  316. FR_NOT_READY, /* (3) The physical drive cannot work */
  317. FR_NO_FILE, /* (4) Could not find the file */
  318. FR_NO_PATH, /* (5) Could not find the path */
  319. FR_INVALID_NAME, /* (6) The path name format is invalid */
  320. FR_DENIED, /* (7) Acces denied due to prohibited access or directory full */
  321. FR_EXIST, /* (8) Acces denied due to prohibited access */
  322. FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
  323. FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
  324. FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
  325. FR_NOT_ENABLED, /* (12) The volume has no work area */
  326. FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume on the physical drive */
  327. FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
  328. FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
  329. FR_LOCKED, /* (16) The operation is rejected according to the file shareing policy */
  330. FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
  331. FR_TOO_MANY_OPEN_FILES /* (18) Number of open files > _FS_SHARE */
  332. } FRESULT;
  333. /*--------------------------------------------------------------*/
  334. /* FatFs module application interface */
  335. /* Low Level functions */
  336. FRESULT l_openfilebycluster( FATFS *fs, FIL *fp, const TCHAR *path, DWORD clust,
  337. DWORD fsize ); /* Open a file by its start cluster using supplied file size */
  338. FRESULT l_opendirbycluster ( FATFS *fs, DIR *dj, const TCHAR *path, DWORD clust );
  339. /* application level functions */
  340. FRESULT f_mount ( BYTE, FATFS * ); /* Mount/Unmount a logical drive */
  341. FRESULT f_open ( FIL *, const TCHAR *, BYTE ); /* Open or create a file */
  342. FRESULT f_read ( FIL *, void *, UINT, UINT * ); /* Read data from a file */
  343. FRESULT f_lseek ( FIL *, DWORD ); /* Move file pointer of a file object */
  344. FRESULT f_close ( FIL * ); /* Close an open file object */
  345. FRESULT f_opendir ( DIR *, const TCHAR * ); /* Open an existing directory */
  346. FRESULT f_readdir ( DIR *, FILINFO * ); /* Read a directory item */
  347. FRESULT f_stat ( const TCHAR *, FILINFO * ); /* Get file status */
  348. #if !_FS_READONLY
  349. FRESULT f_write ( FIL *, const void *, UINT, UINT * ); /* Write data to a file */
  350. FRESULT f_getfree ( const TCHAR *, DWORD *, FATFS ** ); /* Get number of free clusters on the drive */
  351. FRESULT f_truncate ( FIL * ); /* Truncate file */
  352. FRESULT f_sync ( FIL * ); /* Flush cached data of a writing file */
  353. FRESULT f_unlink ( const TCHAR * ); /* Delete an existing file or directory */
  354. FRESULT f_mkdir ( const TCHAR * ); /* Create a new directory */
  355. FRESULT f_chmod ( const TCHAR *, BYTE, BYTE ); /* Change attriburte of the file/dir */
  356. FRESULT f_utime ( const TCHAR *, const FILINFO * ); /* Change timestamp of the file/dir */
  357. FRESULT f_rename ( const TCHAR *, const TCHAR * ); /* Rename/Move a file or directory */
  358. #endif
  359. #if _USE_FORWARD
  360. FRESULT f_forward ( FIL *, UINT( * )( const BYTE *, UINT ), UINT, UINT * ); /* Forward data to the stream */
  361. #endif
  362. #if _USE_MKFS
  363. FRESULT f_mkfs ( BYTE, BYTE, UINT ); /* Create a file system on the drive */
  364. #endif
  365. #if _FS_RPATH
  366. FRESULT f_chdrive ( BYTE ); /* Change current drive */
  367. FRESULT f_chdir ( const TCHAR * ); /* Change current directory */
  368. FRESULT f_getcwd ( TCHAR *, UINT ); /* Get current directory */
  369. #endif
  370. #if _USE_STRFUNC
  371. int f_putc ( TCHAR, FIL * ); /* Put a character to the file */
  372. int f_puts ( const TCHAR *, FIL * ); /* Put a string to the file */
  373. int f_printf ( FIL *, const TCHAR *, ... ); /* Put a formatted string to the file */
  374. TCHAR *f_gets ( TCHAR *, int, FIL * ); /* Get a string from the file */
  375. #ifndef EOF
  376. #define EOF (-1)
  377. #endif
  378. #endif
  379. #define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
  380. #define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
  381. #define f_tell(fp) ((fp)->fptr)
  382. #define f_size(fp) ((fp)->fsize)
  383. /*--------------------------------------------------------------*/
  384. /* Additional user defined functions */
  385. /* RTC function */
  386. #if !_FS_READONLY
  387. DWORD get_fattime ( void );
  388. #endif
  389. /* Unicode support functions */
  390. #if _USE_LFN /* Unicode - OEM code conversion */
  391. WCHAR ff_convert ( WCHAR, UINT ); /* OEM-Unicode bidirectional conversion */
  392. WCHAR ff_wtoupper ( WCHAR ); /* Unicode upper-case conversion */
  393. #if _USE_LFN == 3 /* Memory functions */
  394. void *ff_memalloc ( UINT ); /* Allocate memory block */
  395. void ff_memfree ( void * ); /* Free memory block */
  396. #endif
  397. #endif
  398. /* Sync functions */
  399. #if _FS_REENTRANT
  400. int ff_cre_syncobj ( BYTE, _SYNC_t * ); /* Create a sync object */
  401. int ff_del_syncobj ( _SYNC_t ); /* Delete a sync object */
  402. int ff_req_grant ( _SYNC_t ); /* Lock sync object */
  403. void ff_rel_grant ( _SYNC_t ); /* Unlock sync object */
  404. #endif
  405. /*--------------------------------------------------------------*/
  406. /* Flags and offset address */
  407. /* File access control and file status flags (FIL.flag) */
  408. #define FA_READ 0x01
  409. #define FA_OPEN_EXISTING 0x00
  410. #define FA__ERROR 0x80
  411. #if !_FS_READONLY
  412. #define FA_WRITE 0x02
  413. #define FA_CREATE_NEW 0x04
  414. #define FA_CREATE_ALWAYS 0x08
  415. #define FA_OPEN_ALWAYS 0x10
  416. #define FA__WRITTEN 0x20
  417. #define FA__DIRTY 0x40
  418. #endif
  419. /* FAT sub type (FATFS.fs_type) */
  420. #define FS_FAT12 1
  421. #define FS_FAT16 2
  422. #define FS_FAT32 3
  423. /* File attribute bits for directory entry */
  424. #define AM_RDO 0x01 /* Read only */
  425. #define AM_HID 0x02 /* Hidden */
  426. #define AM_SYS 0x04 /* System */
  427. #define AM_VOL 0x08 /* Volume label */
  428. #define AM_LFN 0x0F /* LFN entry */
  429. #define AM_DIR 0x10 /* Directory */
  430. #define AM_ARC 0x20 /* Archive */
  431. #define AM_MASK 0x3F /* Mask of defined bits */
  432. /* Fast seek function */
  433. #define CREATE_LINKMAP 0xFFFFFFFF
  434. /*--------------------------------*/
  435. /* Multi-byte word access macros */
  436. #if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
  437. #define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
  438. #define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
  439. #define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
  440. #define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
  441. #else /* Use byte-by-byte access to the FAT structure */
  442. #define LD_WORD(ptr) (WORD)(((WORD)*(BYTE*)((ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
  443. #define LD_DWORD(ptr) (DWORD)(((DWORD)*(BYTE*)((ptr)+3)<<24)|((DWORD)*(BYTE*)((ptr)+2)<<16)|((WORD)*(BYTE*)((ptr)+1)<<8)|*(BYTE*)(ptr))
  444. #define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *(BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8)
  445. #define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *(BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8); *(BYTE*)((ptr)+2)=(BYTE)((DWORD)(val)>>16); *(BYTE*)((ptr)+3)=(BYTE)((DWORD)(val)>>24)
  446. #endif
  447. #ifdef __cplusplus
  448. }
  449. #endif
  450. #endif /* _FATFS */