Prusa MINI Firmware overview
ff.h
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------/
2 / FatFs - Generic FAT file system module R0.12c /
3 /-----------------------------------------------------------------------------/
4 /
5 / Copyright (C) 2017, ChaN, all right reserved.
6 /
7 / FatFs module is an open source software. Redistribution and use of FatFs in
8 / source and binary forms, with or without modification, are permitted provided
9 / that the following condition is met:
10 
11 / 1. Redistributions of source code must retain the above copyright notice,
12 / this condition and the following disclaimer.
13 /
14 / This software is provided by the copyright holder and contributors "AS IS"
15 / and any warranties related to this software are DISCLAIMED.
16 / The copyright owner or contributors be NOT LIABLE for any damages caused
17 / by use of this software.
18 /----------------------------------------------------------------------------*/
19 
20 
21 #ifndef _FATFS
22 #define _FATFS 68300 /* Revision ID */
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #include "integer.h" /* Basic integer types */
29 #include "ffconf.h" /* FatFs configuration options */
30 
31 #if _FATFS != _FFCONF
32 #error Wrong configuration file (ffconf.h).
33 #endif
34 
35 
36 
37 /* Definitions of volume management */
38 
39 #if _MULTI_PARTITION /* Multiple partition configuration */
40 typedef struct {
41  BYTE pd; /* Physical drive number */
42  BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
43 } PARTITION;
44 extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
45 #endif
46 
47 
48 
49 /* Type of path name strings on FatFs API */
50 
51 #if _LFN_UNICODE /* Unicode (UTF-16) string */
52 #if _USE_LFN == 0
53 #error _LFN_UNICODE must be 0 at non-LFN cfg.
54 #endif
55 #ifndef _INC_TCHAR
56 typedef WCHAR TCHAR;
57 #define _T(x) L ## x
58 #define _TEXT(x) L ## x
59 #endif
60 #else /* ANSI/OEM string */
61 #ifndef _INC_TCHAR
62 typedef char TCHAR;
63 #define _T(x) x
64 #define _TEXT(x) x
65 #endif
66 #endif
67 
68 
69 
70 /* Type of file size variables */
71 
72 #if _FS_EXFAT
73 #if _USE_LFN == 0
74 #error LFN must be enabled when enable exFAT
75 #endif
76 typedef QWORD FSIZE_t;
77 #else
78 typedef DWORD FSIZE_t;
79 #endif
80 
81 
82 
83 /* File system object structure (FATFS) */
84 
85 typedef struct {
86  BYTE fs_type; /* File system type (0:N/A) */
87  BYTE drv; /* Physical drive number */
88  BYTE n_fats; /* Number of FATs (1 or 2) */
89  BYTE wflag; /* win[] flag (b0:dirty) */
90  BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */
91  WORD id; /* File system mount ID */
92  WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
93  WORD csize; /* Cluster size [sectors] */
94 #if _MAX_SS != _MIN_SS
95  WORD ssize; /* Sector size (512, 1024, 2048 or 4096) */
96 #endif
97 #if _USE_LFN != 0
98  WCHAR* lfnbuf; /* LFN working buffer */
99 #endif
100 #if _FS_EXFAT
101  BYTE* dirbuf; /* Directory entry block scratchpad buffer */
102 #endif
103 #if _FS_REENTRANT
104  _SYNC_t sobj; /* Identifier of sync object */
105 #endif
106 #if !_FS_READONLY
107  DWORD last_clst; /* Last allocated cluster */
108  DWORD free_clst; /* Number of free clusters */
109 #endif
110 #if _FS_RPATH != 0
111  DWORD cdir; /* Current directory start cluster (0:root) */
112 #if _FS_EXFAT
113  DWORD cdc_scl; /* Containing directory start cluster (invalid when cdir is 0) */
114  DWORD cdc_size; /* b31-b8:Size of containing directory, b7-b0: Chain status */
115  DWORD cdc_ofs; /* Offset in the containing directory (invalid when cdir is 0) */
116 #endif
117 #endif
118  DWORD n_fatent; /* Number of FAT entries (number of clusters + 2) */
119  DWORD fsize; /* Size of an FAT [sectors] */
120  DWORD volbase; /* Volume base sector */
121  DWORD fatbase; /* FAT base sector */
122  DWORD dirbase; /* Root directory base sector/cluster */
123  DWORD database; /* Data base sector */
124  DWORD winsect; /* Current sector appearing in the win[] */
125  BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */
126 } FATFS;
127 
128 
129 
130 /* Object ID and allocation information (_FDID) */
131 
132 typedef struct {
133  FATFS* fs; /* Pointer to the owner file system object */
134  WORD id; /* Owner file system mount ID */
135  BYTE attr; /* Object attribute */
136  BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous (no data on FAT), =3:flagmented in this session, b2:sub-directory stretched) */
137  DWORD sclust; /* Object start cluster (0:no cluster or root directory) */
138  FSIZE_t objsize; /* Object size (valid when sclust != 0) */
139 #if _FS_EXFAT
140  DWORD n_cont; /* Size of first fragment, clusters - 1 (valid when stat == 3) */
141  DWORD n_frag; /* Size of last fragment needs to be written (valid when not zero) */
142  DWORD c_scl; /* Containing directory start cluster (valid when sclust != 0) */
143  DWORD c_size; /* b31-b8:Size of containing directory, b7-b0: Chain status (valid when c_scl != 0) */
144  DWORD c_ofs; /* Offset in the containing directory (valid when sclust != 0 and non-directory object) */
145 #endif
146 #if _FS_LOCK != 0
147  UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */
148 #endif
149 } _FDID;
150 
151 
152 
153 /* File object structure (FIL) */
154 
155 typedef struct {
156  _FDID obj; /* Object identifier (must be the 1st member to detect invalid object pointer) */
157  BYTE flag; /* File status flags */
158  BYTE err; /* Abort flag (error code) */
159  FSIZE_t fptr; /* File read/write pointer (Zeroed on file open) */
160  DWORD clust; /* Current cluster of fpter (invalid when fptr is 0) */
161  DWORD sect; /* Sector number appearing in buf[] (0:invalid) */
162 #if !_FS_READONLY
163  DWORD dir_sect; /* Sector number containing the directory entry */
164  BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */
165 #endif
166 #if _USE_FASTSEEK
167  DWORD* cltbl; /* Pointer to the cluster link map table (nulled on open, set by application) */
168 #endif
169 #if !_FS_TINY
170  BYTE buf[_MAX_SS]; /* File private data read/write window */
171 #endif
172 } FIL;
173 
174 
175 
176 /* Directory object structure (DIR) */
177 
178 typedef struct {
179  _FDID obj; /* Object identifier */
180  DWORD dptr; /* Current read/write offset */
181  DWORD clust; /* Current cluster */
182  DWORD sect; /* Current sector (0:Read operation has terminated) */
183  BYTE* dir; /* Pointer to the directory item in the win[] */
184  BYTE fn[12]; /* SFN (in/out) {body[8],ext[3],status[1]} */
185 #if _USE_LFN != 0
186  DWORD blk_ofs; /* Offset of current entry block being processed (0xFFFFFFFF:Invalid) */
187 #endif
188 #if _USE_FIND
189  const TCHAR* pat; /* Pointer to the name matching pattern */
190 #endif
191 } DIR;
192 
193 
194 
195 /* File information structure (FILINFO) */
196 
197 typedef struct {
198  FSIZE_t fsize; /* File size */
199  WORD fdate; /* Modified date */
200  WORD ftime; /* Modified time */
201  BYTE fattrib; /* File attribute */
202 #if _USE_LFN != 0
203  TCHAR altname[13]; /* Alternative file name */
204  TCHAR fname[_MAX_LFN + 1]; /* Primary file name */
205 #else
206  TCHAR fname[13]; /* File name */
207 #endif
208 } FILINFO;
209 
210 
211 
212 /* File function return code (FRESULT) */
213 
214 typedef enum {
215  FR_OK = 0, /* (0) Succeeded */
216  FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
217  FR_INT_ERR, /* (2) Assertion failed */
218  FR_NOT_READY, /* (3) The physical drive cannot work */
219  FR_NO_FILE, /* (4) Could not find the file */
220  FR_NO_PATH, /* (5) Could not find the path */
221  FR_INVALID_NAME, /* (6) The path name format is invalid */
222  FR_DENIED, /* (7) Access denied due to prohibited access or directory full */
223  FR_EXIST, /* (8) Access denied due to prohibited access */
224  FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
225  FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
226  FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
227  FR_NOT_ENABLED, /* (12) The volume has no work area */
228  FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
229  FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any problem */
230  FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
231  FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
232  FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
233  FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_LOCK */
234  FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
235 } FRESULT;
236 
237 
238 
239 /*--------------------------------------------------------------*/
240 /* FatFs module application interface */
241 
242 FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
243 FRESULT f_close (FIL* fp); /* Close an open file object */
244 FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from the file */
245 FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to the file */
246 FRESULT f_lseek (FIL* fp, FSIZE_t ofs); /* Move file pointer of the file object */
247 FRESULT f_truncate (FIL* fp); /* Truncate the file */
248 FRESULT f_sync (FIL* fp); /* Flush cached data of the writing file */
249 FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */
250 FRESULT f_closedir (DIR* dp); /* Close an open directory */
251 FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */
252 FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */
253 FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */
254 FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */
255 FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */
256 FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
257 FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */
258 FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of a file/dir */
259 FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change timestamp of a file/dir */
260 FRESULT f_chdir (const TCHAR* path); /* Change current directory */
261 FRESULT f_chdrive (const TCHAR* path); /* Change current drive */
262 FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */
263 FRESULT f_getdirpath (DIR* pd, TCHAR* buff, UINT len);
264 FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
265 FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */
266 FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
267 FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
268 FRESULT f_expand (FIL* fp, FSIZE_t szf, BYTE opt); /* Allocate a contiguous block to the file */
269 FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
270 FRESULT f_mkfs (const TCHAR* path, BYTE opt, DWORD au, void* work, UINT len); /* Create a FAT volume */
271 FRESULT f_fdisk (BYTE pdrv, const DWORD* szt, void* work); /* Divide a physical drive into some partitions */
272 int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
273 int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
274 int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
275 TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
276 
277 #define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize))
278 #define f_error(fp) ((fp)->err)
279 #define f_tell(fp) ((fp)->fptr)
280 #define f_size(fp) ((fp)->obj.objsize)
281 #define f_rewind(fp) f_lseek((fp), 0)
282 #define f_rewinddir(dp) f_readdir((dp), 0)
283 #define f_rmdir(path) f_unlink(path)
284 
285 #ifndef EOF
286 #define EOF (-1)
287 #endif
288 
289 
290 
291 
292 /*--------------------------------------------------------------*/
293 /* Additional user defined functions */
294 
295 /* RTC function */
296 #if !_FS_READONLY && !_FS_NORTC
297 DWORD get_fattime (void);
298 #endif
299 
300 /* Unicode support functions */
301 #if _USE_LFN != 0 /* Unicode - OEM code conversion */
302 WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */
303 WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */
304 #if _USE_LFN == 3 /* Memory functions */
305 void* ff_memalloc (UINT msize); /* Allocate memory block */
306 void ff_memfree (void* mblock); /* Free memory block */
307 #endif
308 #endif
309 
310 /* Sync functions */
311 #if _FS_REENTRANT
312 int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */
313 int ff_req_grant (_SYNC_t sobj); /* Lock sync object */
314 void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */
315 int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */
316 #endif
317 
318 
319 
320 
321 /*--------------------------------------------------------------*/
322 /* Flags and offset address */
323 
324 
325 /* File access mode and open method flags (3rd argument of f_open) */
326 #define FA_READ 0x01
327 #define FA_WRITE 0x02
328 #define FA_OPEN_EXISTING 0x00
329 #define FA_CREATE_NEW 0x04
330 #define FA_CREATE_ALWAYS 0x08
331 #define FA_OPEN_ALWAYS 0x10
332 #define FA_OPEN_APPEND 0x30
333 
334 /* Fast seek controls (2nd argument of f_lseek) */
335 #define CREATE_LINKMAP ((FSIZE_t)0 - 1)
336 
337 /* Format options (2nd argument of f_mkfs) */
338 #define FM_FAT 0x01
339 #define FM_FAT32 0x02
340 #define FM_EXFAT 0x04
341 #define FM_ANY 0x07
342 #define FM_SFD 0x08
343 
344 /* Filesystem type (FATFS.fs_type) */
345 #define FS_FAT12 1
346 #define FS_FAT16 2
347 #define FS_FAT32 3
348 #define FS_EXFAT 4
349 
350 /* File attribute bits for directory entry (FILINFO.fattrib) */
351 #define AM_RDO 0x01 /* Read only */
352 #define AM_HID 0x02 /* Hidden */
353 #define AM_SYS 0x04 /* System */
354 #define AM_DIR 0x10 /* Directory */
355 #define AM_ARC 0x20 /* Archive */
356 
357 
358 #ifdef __cplusplus
359 }
360 #endif
361 
362 #endif /* _FATFS */
dir_read
static FRESULT dir_read(DIR *dp, int vol)
Definition: ff.c:2131
f_lseek
FRESULT f_lseek(FIL *fp, FSIZE_t ofs)
Definition: ff.c:4060
ff_wtoupper
WCHAR ff_wtoupper(WCHAR chr)
Definition: ccsbcs.c:303
STA_NOINIT
#define STA_NOINIT
Definition: onboard_sd.h:55
FR_NOT_ENOUGH_CORE
Definition: ff.h:232
FIL
Definition: ff.h:155
FA_OPEN_ALWAYS
#define FA_OPEN_ALWAYS
Definition: ff.h:331
GET_SECTOR_COUNT
#define GET_SECTOR_COUNT
Definition: onboard_sd.h:63
check_fs
static BYTE check_fs(FATFS *fs, DWORD sect)
Definition: ff.c:2964
XDIR_FstClus
#define XDIR_FstClus
Definition: ff.c:427
BS_BootSig32
#define BS_BootSig32
Definition: ff.c:367
BPB_ZeroedEx
#define BPB_ZeroedEx
Definition: ff.c:373
PTE_Boot
#define PTE_Boot
Definition: ff.c:442
TCHAR
char TCHAR
Definition: ff.h:62
BPB_FSVerEx
#define BPB_FSVerEx
Definition: ff.c:382
f_expand
FRESULT f_expand(FIL *fp, FSIZE_t szf, BYTE opt)
FSI_Free_Count
#define FSI_Free_Count
Definition: ff.c:437
XDIR_FileSize
#define XDIR_FileSize
Definition: ff.c:428
NS_LOSS
#define NS_LOSS
Definition: ff.c:314
dir_next
static FRESULT dir_next(DIR *dp, int stretch)
Definition: ff.c:1519
f_getlabel
FRESULT f_getlabel(const TCHAR *path, TCHAR *label, DWORD *vsn)
f_chdir
FRESULT f_chdir(const TCHAR *path)
XDIR_ValidFileSize
#define XDIR_ValidFileSize
Definition: ff.c:426
FR_DISK_ERR
Definition: ff.h:216
f_mkfs
FRESULT f_mkfs(const TCHAR *path, BYTE opt, DWORD au, void *work, UINT len)
FR_INVALID_OBJECT
Definition: ff.h:224
f_unlink
FRESULT f_unlink(const TCHAR *path)
Definition: ff.c:4584
XDIR_NumLabel
#define XDIR_NumLabel
Definition: ff.c:409
DIR_CrtTime
#define DIR_CrtTime
Definition: ff.c:397
FR_EXIST
Definition: ff.h:223
f_write
FRESULT f_write(FIL *fp, const void *buff, UINT btw, UINT *bw)
Definition: ff.c:3599
FATFS::last_clst
DWORD last_clst
Definition: ff.h:107
FATFS::fatbase
DWORD fatbase
Definition: ff.h:121
AM_HID
#define AM_HID
Definition: ff.h:352
f_stat
FRESULT f_stat(const TCHAR *path, FILINFO *fno)
Definition: ff.c:4412
dir_sdi
static FRESULT dir_sdi(DIR *dp, DWORD ofs)
Definition: ff.c:1470
_FDID::stat
BYTE stat
Definition: ff.h:136
NS_EXT
#define NS_EXT
Definition: ff.c:318
f_rename
FRESULT f_rename(const TCHAR *path_old, const TCHAR *path_new)
Definition: ff.c:4776
LDIR_Attr
#define LDIR_Attr
Definition: ff.c:404
LLEF
#define LLEF
Definition: ff.c:433
MAX_DIR
#define MAX_DIR
Definition: ff.c:325
DIR_FstClusHI
#define DIR_FstClusHI
Definition: ff.c:399
FR_NO_FILE
Definition: ff.h:219
BPB_FSVer32
#define BPB_FSVer32
Definition: ff.c:361
BS_FilSysType32
#define BS_FilSysType32
Definition: ff.c:370
f_chmod
FRESULT f_chmod(const TCHAR *path, BYTE attr, BYTE mask)
FA_WRITE
#define FA_WRITE
Definition: ff.h:327
LDIR_FstClusLO
#define LDIR_FstClusLO
Definition: ff.c:407
st_dword
static void st_dword(BYTE *ptr, DWORD val)
Definition: ff.c:661
DIR_FileSize
#define DIR_FileSize
Definition: ff.c:402
XDIR_AccTime
#define XDIR_AccTime
Definition: ff.c:417
FATFS::csize
WORD csize
Definition: ff.h:93
DIR_NTres
#define DIR_NTres
Definition: ff.c:395
NS_LFN
#define NS_LFN
Definition: ff.c:315
disk_initialize
DSTATUS disk_initialize(BYTE pdrv)
Initializes a Drive.
Definition: diskio.c:91
FILINFO::fattrib
BYTE fattrib
Definition: ff.h:201
LDIR_Chksum
#define LDIR_Chksum
Definition: ff.c:406
BPB_SecPerTrk
#define BPB_SecPerTrk
Definition: ff.c:346
FIL::fptr
FSIZE_t fptr
Definition: ff.h:159
FATFS::winsect
DWORD winsect
Definition: ff.h:124
dir_find
static FRESULT dir_find(DIR *dp)
Definition: ff.c:2210
CREATE_LINKMAP
#define CREATE_LINKMAP
Definition: ff.h:335
f_chdrive
FRESULT f_chdrive(const TCHAR *path)
INIT_NAMBUF
#define INIT_NAMBUF(fs)
Definition: ff.c:546
f_close
FRESULT f_close(FIL *fp)
Definition: ff.c:3801
FR_NO_PATH
Definition: ff.h:220
FA_OPEN_APPEND
#define FA_OPEN_APPEND
Definition: ff.h:332
pd
#define pd
Definition: screen_filebrowser.cpp:39
LDIR_Ord
#define LDIR_Ord
Definition: ff.c:403
BS_BootSig
#define BS_BootSig
Definition: ff.c:352
BPB_NumClusEx
#define BPB_NumClusEx
Definition: ff.c:379
f_open
FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode)
Definition: ff.c:3296
FIL::clust
DWORD clust
Definition: ff.h:160
LD2PD
#define LD2PD(vol)
Definition: ff.c:476
dir_remove
static FRESULT dir_remove(DIR *dp)
Definition: ff.c:2396
XDIR_SetSum
#define XDIR_SetSum
Definition: ff.c:413
validate
static FRESULT validate(_FDID *obj, FATFS **fs)
Definition: ff.c:3215
BPB_FATSz16
#define BPB_FATSz16
Definition: ff.c:345
FA_CREATE_ALWAYS
#define FA_CREATE_ALWAYS
Definition: ff.h:330
FATFS::n_fatent
DWORD n_fatent
Definition: ff.h:118
MBR_Table
#define MBR_Table
Definition: ff.c:440
WORD
unsigned short WORD
Definition: onboard_sd.h:14
FILINFO::fdate
WORD fdate
Definition: ff.h:199
BS_JmpBoot
#define BS_JmpBoot
Definition: ff.c:336
FIL::obj
_FDID obj
Definition: ff.h:156
f_puts
int f_puts(const TCHAR *str, FIL *cp)
disk_read
DRESULT disk_read(BYTE pdrv, BYTE *buff, DWORD sector, UINT count)
Reads Sector(s)
Definition: diskio.c:113
BPB_SecPerClus
#define BPB_SecPerClus
Definition: ff.c:339
XDIR_Label
#define XDIR_Label
Definition: ff.c:410
i
uint8_t i
Definition: screen_test_graph.c:72
get_fileinfo
static void get_fileinfo(DIR *dp, FILINFO *fno)
Definition: ff.c:2444
FS_EXFAT
#define FS_EXFAT
Definition: ff.h:348
BS_55AA
#define BS_55AA
Definition: ff.c:357
f_getdirpath
FRESULT f_getdirpath(DIR *pd, TCHAR *buff, UINT len)
_FDID::sclust
DWORD sclust
Definition: ff.h:137
f_closedir
FRESULT f_closedir(DIR *dp)
Definition: ff.c:4291
DIR::clust
DWORD clust
Definition: ff.h:181
FSIZE_t
DWORD FSIZE_t
Definition: ff.h:78
ld_clust
static DWORD ld_clust(FATFS *fs, const BYTE *dir)
Definition: ff.c:1632
BPB_RootClusEx
#define BPB_RootClusEx
Definition: ff.c:380
NS_NONAME
#define NS_NONAME
Definition: ff.c:321
FR_WRITE_PROTECTED
Definition: ff.h:225
BS_DrvNum
#define BS_DrvNum
Definition: ff.c:350
PTE_EdHead
#define PTE_EdHead
Definition: ff.c:447
clust2sect
static DWORD clust2sect(FATFS *fs, DWORD clst)
Definition: ff.c:983
IsLower
#define IsLower(c)
Definition: ff.c:275
f_unlink
FRESULT f_unlink(const TCHAR *path)
Definition: ff.c:4584
FSI_LeadSig
#define FSI_LeadSig
Definition: ff.c:435
remove_chain
static FRESULT remove_chain(_FDID *obj, DWORD clst, DWORD pclst)
Definition: ff.c:1271
BPB_NumFATsEx
#define BPB_NumFATsEx
Definition: ff.c:387
FS_FAT16
#define FS_FAT16
Definition: ff.h:346
put_fat
static FRESULT put_fat(FATFS *fs, DWORD clst, DWORD val)
Definition: ff.c:1081
_VOLUMES
#define _VOLUMES
Definition: ffconf.h:194
f_stat
FRESULT f_stat(const TCHAR *path, FILINFO *fno)
Definition: ff.c:4412
DIR_ModTime
#define DIR_ModTime
Definition: ff.c:400
BS_BootCodeEx
#define BS_BootCodeEx
Definition: ff.c:391
DIR::fn
BYTE fn[12]
Definition: ff.h:184
dir_register
static FRESULT dir_register(DIR *dp)
Definition: ff.c:2292
BPB_VolOfsEx
#define BPB_VolOfsEx
Definition: ff.c:374
f_mount
FRESULT f_mount(FATFS *fs, const TCHAR *path, BYTE opt)
Definition: ff.c:3248
DIR::dptr
DWORD dptr
Definition: ff.h:180
FIL::flag
BYTE flag
Definition: ff.h:157
sync_window
static FRESULT sync_window(FATFS *fs)
Definition: ff.c:883
FSI_StrucSig
#define FSI_StrucSig
Definition: ff.c:436
STA_PROTECT
#define STA_PROTECT
Definition: onboard_sd.h:57
NSFLAG
#define NSFLAG
Definition: ff.c:313
DIR_Name
#define DIR_Name
Definition: ff.c:393
DIR_FstClusLO
#define DIR_FstClusLO
Definition: ff.c:401
ld_word
static WORD ld_word(const BYTE *ptr)
Definition: ff.c:613
DIR::dir
BYTE * dir
Definition: ff.h:183
BYTE
#define BYTE
Definition: MarlinSerial.h:142
FATFS::n_rootdir
WORD n_rootdir
Definition: ff.h:92
BPB_BytsPerSec
#define BPB_BytsPerSec
Definition: ff.c:338
st_clust
static void st_clust(FATFS *fs, BYTE *dir, DWORD cl)
Definition: ff.c:1650
FA_MODIFIED
#define FA_MODIFIED
Definition: ff.c:308
_FS_RPATH
#define _FS_RPATH
Definition: ffconf.h:182
NS_NOLFN
#define NS_NOLFN
Definition: ff.c:320
BPB_FATSz32
#define BPB_FATSz32
Definition: ff.c:359
FR_LOCKED
Definition: ff.h:231
mem_cpy
static void mem_cpy(void *dst, const void *src, UINT cnt)
Definition: ff.c:693
BS_FilSysType
#define BS_FilSysType
Definition: ff.c:355
XDIR_CrtTime
#define XDIR_CrtTime
Definition: ff.c:415
ld_dword
static DWORD ld_dword(const BYTE *ptr)
Definition: ff.c:623
FR_NOT_ENABLED
Definition: ff.h:227
get_fattime
DWORD get_fattime(void)
Gets Time from RTC.
Definition: diskio.c:175
FATFS::fsi_flag
BYTE fsi_flag
Definition: ff.h:90
XDIR_NameHash
#define XDIR_NameHash
Definition: ff.c:425
FATFS::n_fats
BYTE n_fats
Definition: ff.h:88
MAX_FAT12
#define MAX_FAT12
Definition: ff.c:327
_FDID::objsize
FSIZE_t objsize
Definition: ff.h:138
_SYNC_t
#define _SYNC_t
Definition: ffconf.h:280
FATFS
Definition: ff.h:85
BPB_NumHeads
#define BPB_NumHeads
Definition: ff.c:347
XDIR_ModTime
#define XDIR_ModTime
Definition: ff.c:416
FA_READ
#define FA_READ
Definition: ff.h:326
FS_FAT32
#define FS_FAT32
Definition: ff.h:347
follow_path
static FRESULT follow_path(DIR *dp, const TCHAR *path)
Definition: ff.c:2812
XDIR_Attr
#define XDIR_Attr
Definition: ff.c:414
PTE_StCyl
#define PTE_StCyl
Definition: ff.c:445
BPB_TotSecEx
#define BPB_TotSecEx
Definition: ff.c:375
st_word
static void st_word(BYTE *ptr, WORD val)
Definition: ff.c:654
f_setlabel
FRESULT f_setlabel(const TCHAR *label)
find_volume
static FRESULT find_volume(const TCHAR **path, FATFS **rfs, BYTE mode)
Definition: ff.c:2992
GET_FATTIME
#define GET_FATTIME()
Definition: ff.c:499
NS_BODY
#define NS_BODY
Definition: ff.c:317
BPB_TotSec32
#define BPB_TotSec32
Definition: ff.c:349
create_chain
static DWORD create_chain(_FDID *obj, DWORD clst)
Definition: ff.c:1351
SZ_PTE
#define SZ_PTE
Definition: ff.c:441
MAX_FAT16
#define MAX_FAT16
Definition: ff.c:328
FILINFO::ftime
WORD ftime
Definition: ff.h:200
f_opendir
FRESULT f_opendir(DIR *dp, const TCHAR *path)
Definition: ff.c:4221
f_mkdir
FRESULT f_mkdir(const TCHAR *path)
Definition: ff.c:4679
mem_set
static void mem_set(void *dst, int val, UINT cnt)
Definition: ff.c:706
f_readdir
FRESULT f_readdir(DIR *dp, FILINFO *fno)
Definition: ff.c:4324
f_read
FRESULT f_read(FIL *fp, void *buff, UINT btr, UINT *br)
Definition: ff.c:3499
PTE_EdCyl
#define PTE_EdCyl
Definition: ff.c:449
AM_VOL
#define AM_VOL
Definition: ff.c:301
FIL::dir_ptr
BYTE * dir_ptr
Definition: ff.h:164
FA_SEEKEND
#define FA_SEEKEND
Definition: ff.c:307
f_getfree
FRESULT f_getfree(const TCHAR *path, DWORD *nclst, FATFS **fatfs)
Definition: ff.c:4447
_FDID::id
WORD id
Definition: ff.h:134
NS_DOT
#define NS_DOT
Definition: ff.c:319
ffconf.h
BPB_BytsPerSecEx
#define BPB_BytsPerSecEx
Definition: ff.c:385
RES_OK
Definition: onboard_sd.h:23
FR_DENIED
Definition: ff.h:222
f_truncate
FRESULT f_truncate(FIL *fp)
Definition: ff.c:4534
DIR_Attr
#define DIR_Attr
Definition: ff.c:394
BPB_DataOfsEx
#define BPB_DataOfsEx
Definition: ff.c:378
disk_status
DSTATUS disk_status(BYTE pdrv)
Gets Disk Status.
Definition: diskio.c:76
BPB_FSInfo32
#define BPB_FSInfo32
Definition: ff.c:363
DIR::sect
DWORD sect
Definition: ff.h:182
f_utime
FRESULT f_utime(const TCHAR *path, const FILINFO *fno)
Fsid
static WORD Fsid
Definition: ff.c:534
FR_MKFS_ABORTED
Definition: ff.h:229
mem_cmp
static int mem_cmp(const void *dst, const void *src, UINT cnt)
Definition: ff.c:716
_MAX_LFN
#define _MAX_LFN
Definition: ffconf.h:150
diskio.h
MAX_FAT32
#define MAX_FAT32
Definition: ff.c:329
ff.h
FR_NOT_READY
Definition: ff.h:218
if
if(size<=((png_alloc_size_t) -1) - ob)
Definition: pngwrite.c:2176
f_lseek
FRESULT f_lseek(FIL *fp, FSIZE_t ofs)
Definition: ff.c:4060
DSTATUS
BYTE DSTATUS
Definition: onboard_sd.h:19
createSpeedLookupTable.a
list a
Definition: createSpeedLookupTable.py:29
BPB_RootClus32
#define BPB_RootClus32
Definition: ff.c:362
f_printf
int f_printf(FIL *fp, const TCHAR *str,...)
FATFS::id
WORD id
Definition: ff.h:91
FSI_Nxt_Free
#define FSI_Nxt_Free
Definition: ff.c:438
BPB_FatSzEx
#define BPB_FatSzEx
Definition: ff.c:377
FIL::err
BYTE err
Definition: ff.h:158
_VOLUME_STRS
#define _VOLUME_STRS
Definition: ffconf.h:199
FATFS::fs_type
BYTE fs_type
Definition: ff.h:86
_FS_LOCK
#define _FS_LOCK
Definition: ffconf.h:267
disk_write
DRESULT disk_write(BYTE pdrv, const BYTE *buff, DWORD sector, UINT count)
Writes Sector(s)
Definition: diskio.c:135
FATFS::wflag
BYTE wflag
Definition: ff.h:89
_FDID
Definition: ff.h:132
FR_NO_FILESYSTEM
Definition: ff.h:228
FATFS::win
BYTE win[_MAX_SS]
Definition: ff.h:125
FILINFO::fname
TCHAR fname[13]
Definition: ff.h:206
f_gets
TCHAR * f_gets(TCHAR *buff, int len, FIL *fp)
AM_SYS
#define AM_SYS
Definition: ff.h:353
f_forward
FRESULT f_forward(FIL *fp, UINT(*func)(const BYTE *, UINT), UINT btf, UINT *bf)
IsDBCS1
#define IsDBCS1(c)
Definition: ff.c:294
BPB_FatOfsEx
#define BPB_FatOfsEx
Definition: ff.c:376
BPB_Media
#define BPB_Media
Definition: ff.c:344
FIL::dir_sect
DWORD dir_sect
Definition: ff.h:163
XDIR_GenFlags
#define XDIR_GenFlags
Definition: ff.c:423
FM_ANY
#define FM_ANY
Definition: ff.h:341
XDIR_NumName
#define XDIR_NumName
Definition: ff.c:424
disk_ioctl
DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff)
I/O control operation.
Definition: diskio.c:157
LEAVE_FF
#define LEAVE_FF(fs, res)
Definition: ff.c:467
SS
#define SS(fs)
Definition: ff.c:486
GET_SECTOR_SIZE
#define GET_SECTOR_SIZE
Definition: onboard_sd.h:64
FATFS::free_clst
DWORD free_clst
Definition: ff.h:108
DWORD
unsigned long DWORD
Definition: onboard_sd.h:15
f_write
FRESULT f_write(FIL *fp, const void *buff, UINT btw, UINT *bw)
Definition: ff.c:3599
BPB_BkBootSec32
#define BPB_BkBootSec32
Definition: ff.c:364
get_fat
static DWORD get_fat(_FDID *obj, DWORD clst)
Definition: ff.c:1001
FR_INT_ERR
Definition: ff.h:217
BPB_DrvNumEx
#define BPB_DrvNumEx
Definition: ff.c:388
_USE_LFN
#define _USE_LFN
Definition: ffconf.h:148
FRESULT
FRESULT
Definition: ff.h:214
AM_DIR
#define AM_DIR
Definition: ff.h:354
FATFS::volbase
DWORD volbase
Definition: ff.h:120
f_findnext
FRESULT f_findnext(DIR *dp, FILINFO *fno)
_FS_READONLY
#define _FS_READONLY
Definition: ffconf.h:69
f_rename
FRESULT f_rename(const TCHAR *path_old, const TCHAR *path_new)
Definition: ff.c:4776
f_sync
FRESULT f_sync(FIL *fp)
Definition: ff.c:3720
_MIN_SS
#define _MIN_SS
Definition: ffconf.h:214
rbuff
uint8_t rbuff[10]
Definition: HardwareSerial.cpp:19
XDIR_NumSec
#define XDIR_NumSec
Definition: ff.c:412
_FS_EXFAT
#define _FS_EXFAT
Definition: ffconf.h:249
FR_OK
Definition: ff.h:215
FATFS::fsize
DWORD fsize
Definition: ff.h:119
IsUpper
#define IsUpper(c)
Definition: ff.c:274
FIL::buf
BYTE buf[_MAX_SS]
Definition: ff.h:170
BS_VolLab32
#define BS_VolLab32
Definition: ff.c:369
f_getcwd
FRESULT f_getcwd(TCHAR *buff, UINT len)
FREE_NAMBUF
#define FREE_NAMBUF()
Definition: ff.c:547
_USE_STRFUNC
#define _USE_STRFUNC
Definition: ffconf.h:84
MAX_EXFAT
#define MAX_EXFAT
Definition: ff.c:330
IsDBCS2
#define IsDBCS2(c)
Definition: ff.c:295
PTE_StLba
#define PTE_StLba
Definition: ff.c:450
FS_FAT12
#define FS_FAT12
Definition: ff.h:345
f_opendir
FRESULT f_opendir(DIR *dp, const TCHAR *path)
Definition: ff.c:4221
IsDigit
#define IsDigit(c)
Definition: ff.c:276
ENTER_FF
#define ENTER_FF(fs)
Definition: ff.c:466
ABORT
#define ABORT(fs, res)
Definition: ff.c:455
get_ldnumber
static int get_ldnumber(const TCHAR **path)
Definition: ff.c:2903
FIL::sect
DWORD sect
Definition: ff.h:161
PTE_SizLba
#define PTE_SizLba
Definition: ff.c:451
DIR
Definition: ff.h:178
BPB_RsvdSecCnt
#define BPB_RsvdSecCnt
Definition: ff.c:340
AM_LFN
#define AM_LFN
Definition: ff.c:302
f_mount
FRESULT f_mount(FATFS *fs, const TCHAR *path, BYTE opt)
Definition: ff.c:3248
FR_INVALID_PARAMETER
Definition: ff.h:234
sync_fs
static FRESULT sync_fs(FATFS *fs)
Definition: ff.c:944
DDEM
#define DDEM
Definition: ff.c:431
f_open
FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode)
Definition: ff.c:3296
FR_TOO_MANY_OPEN_FILES
Definition: ff.h:233
XDIR_CrtTime10
#define XDIR_CrtTime10
Definition: ff.c:418
pattern_matching
int pattern_matching(const TCHAR *pat, const TCHAR *nam, int skip, int inf)
GET_BLOCK_SIZE
#define GET_BLOCK_SIZE
Definition: onboard_sd.h:65
BS_DrvNum32
#define BS_DrvNum32
Definition: ff.c:365
BS_VolLab
#define BS_VolLab
Definition: ff.c:354
BYTE
unsigned char BYTE
Definition: onboard_sd.h:13
f_truncate
FRESULT f_truncate(FIL *fp)
Definition: ff.c:4534
FM_EXFAT
#define FM_EXFAT
Definition: ff.h:340
FATFS::dirbase
DWORD dirbase
Definition: ff.h:122
_FDID::fs
FATFS * fs
Definition: ff.h:133
BPB_HiddSec
#define BPB_HiddSec
Definition: ff.c:348
ff_convert
WCHAR ff_convert(WCHAR chr, UINT dir)
Definition: ccsbcs.c:275
FATFS::drv
BYTE drv
Definition: ff.h:87
createSpeedLookupTable.int
int
Definition: createSpeedLookupTable.py:15
BPB_VolIDEx
#define BPB_VolIDEx
Definition: ff.c:381
XDIR_ModTime10
#define XDIR_ModTime10
Definition: ff.c:419
QWORD
unsigned long long QWORD
Definition: integer.h:34
FM_FAT
#define FM_FAT
Definition: ff.h:338
FR_INVALID_NAME
Definition: ff.h:221
BPB_SecPerClusEx
#define BPB_SecPerClusEx
Definition: ff.c:386
RDDEM
#define RDDEM
Definition: ff.c:432
MAX_DIR_EX
#define MAX_DIR_EX
Definition: ff.c:326
DEF_NAMBUF
#define DEF_NAMBUF
Definition: ff.c:545
dir_alloc
static FRESULT dir_alloc(DIR *dp, UINT nent)
Definition: ff.c:1589
FA_DIRTY
#define FA_DIRTY
Definition: ff.c:309
_MULTI_PARTITION
#define _MULTI_PARTITION
Definition: ffconf.h:207
f_closedir
FRESULT f_closedir(DIR *dp)
Definition: ff.c:4291
BS_VolID
#define BS_VolID
Definition: ff.c:353
CTRL_TRIM
#define CTRL_TRIM
Definition: onboard_sd.h:66
BPB_PercInUseEx
#define BPB_PercInUseEx
Definition: ff.c:389
EOF
#define EOF
Definition: ff.h:286
BPB_VolFlagEx
#define BPB_VolFlagEx
Definition: ff.c:383
WCHAR
unsigned short WCHAR
Definition: integer.h:27
SZDIRE
#define SZDIRE
Definition: ff.c:430
BPB_TotSec16
#define BPB_TotSec16
Definition: ff.c:343
create_name
static FRESULT create_name(DIR *dp, const TCHAR **path)
Definition: ff.c:2617
PTE_StSec
#define PTE_StSec
Definition: ff.c:444
LD2PT
#define LD2PT(vol)
Definition: ff.c:477
PTE_EdSec
#define PTE_EdSec
Definition: ff.c:448
mode
png_structrp int mode
Definition: png.h:1139
PTE_StHead
#define PTE_StHead
Definition: ff.c:443
f_putc
int f_putc(TCHAR c, FIL *fp)
LDIR_Type
#define LDIR_Type
Definition: ff.c:405
f_findfirst
FRESULT f_findfirst(DIR *dp, FILINFO *fno, const TCHAR *path, const TCHAR *pattern)
createSpeedLookupTable.b
list b
Definition: createSpeedLookupTable.py:30
FM_FAT32
#define FM_FAT32
Definition: ff.h:339
AM_RDO
#define AM_RDO
Definition: ff.h:351
FILINFO
Definition: ff.h:197
UINT
unsigned int UINT
Definition: onboard_sd.h:16
FR_TIMEOUT
Definition: ff.h:230
AM_ARC
#define AM_ARC
Definition: ff.h:355
FR_INVALID_DRIVE
Definition: ff.h:226
PTE_System
#define PTE_System
Definition: ff.c:446
f_mkdir
FRESULT f_mkdir(const TCHAR *path)
Definition: ff.c:4679
_USE_LABEL
#define _USE_LABEL
Definition: ffconf.h:109
AM_MASK
#define AM_MASK
Definition: ff.c:303
f_readdir
FRESULT f_readdir(DIR *dp, FILINFO *fno)
Definition: ff.c:4324
f_fdisk
FRESULT f_fdisk(BYTE pdrv, const DWORD *szt, void *work)
f_read
FRESULT f_read(FIL *fp, void *buff, UINT btr, UINT *br)
Definition: ff.c:3499
f_sync
FRESULT f_sync(FIL *fp)
Definition: ff.c:3720
f_close
FRESULT f_close(FIL *fp)
Definition: ff.c:3801
integer.h
FATFS::database
DWORD database
Definition: ff.h:123
BPB_NumFATs
#define BPB_NumFATs
Definition: ff.c:341
XDIR_Type
#define XDIR_Type
Definition: ff.c:408
DIR::obj
_FDID obj
Definition: ff.h:179
f_getfree
FRESULT f_getfree(const TCHAR *path, DWORD *nclst, FATFS **fatfs)
Definition: ff.c:4447
move_window
static FRESULT move_window(FATFS *fs, DWORD sector)
Definition: ff.c:912
CTRL_SYNC
#define CTRL_SYNC
Definition: onboard_sd.h:62
FM_SFD
#define FM_SFD
Definition: ff.h:342
FA_CREATE_NEW
#define FA_CREATE_NEW
Definition: ff.h:329
chk_chr
static int chk_chr(const char *str, int chr)
Definition: ff.c:729
FatFs
static FATFS * FatFs[_VOLUMES]
Definition: ff.c:533
_FDID::attr
BYTE attr
Definition: ff.h:135
FILINFO::fsize
FSIZE_t fsize
Definition: ff.h:198
_MAX_SS
#define _MAX_SS
Definition: ffconf.h:215
NS_LAST
#define NS_LAST
Definition: ff.c:316
DIR_LstAccDate
#define DIR_LstAccDate
Definition: ff.c:398
BPB_RootEntCnt
#define BPB_RootEntCnt
Definition: ff.c:342
BS_VolID32
#define BS_VolID32
Definition: ff.c:368