📄 ff.lst
字号:
C51 COMPILER V7.06 FF 03/06/2010 17:37:27 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE FF
OBJECT MODULE PLACED IN ff.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\c51.exe ff.c DB OE BR LARGE
stmt level source
1 /*----------------------------------------------------------------------------/
2 / FatFs - FAT file system module R0.07c (C)ChaN, 2009
3 /-----------------------------------------------------------------------------/
4 / FatFs module is an open source software to implement FAT file system to
5 / small embedded systems. This is a free software and is opened for education,
6 / research and commercial use under license policy of following trems.
7 /
8 / Copyright (C) 2009, 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 products UNDER YOUR RESPONSIBILITY.
13 / * Redistributions of source code must retain the above copyright notice.
14 /
15 /-----------------------------------------------------------------------------/
16 / Feb 26,'06 R0.00 Prototype.
17 /
18 / Apr 29,'06 R0.01 First stable version.
19 /
20 / Jun 01,'06 R0.02 Added FAT12 support.
21 / Removed unbuffered mode.
22 / Fixed a problem on small (<32M) patition.
23 / Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM).
24 /
25 / Sep 22,'06 R0.03 Added f_rename().
26 / Changed option _FS_MINIMUM to _FS_MINIMIZE.
27 / Dec 11,'06 R0.03a Improved cluster scan algolithm to write files fast.
28 / Fixed f_mkdir() creates incorrect directory on FAT32.
29 /
30 / Feb 04,'07 R0.04 Supported multiple drive system.
31 / Changed some interfaces for multiple drive system.
32 / Changed f_mountdrv() to f_mount().
33 / Added f_mkfs().
34 / Apr 01,'07 R0.04a Supported multiple partitions on a plysical drive.
35 / Added a capability of extending file size to f_lseek().
36 / Added minimization level 3.
37 / Fixed an endian sensitive code in f_mkfs().
38 / May 05,'07 R0.04b Added a configuration option _USE_NTFLAG.
39 / Added FSInfo support.
40 / Fixed DBCS name can result FR_INVALID_NAME.
41 / Fixed short seek (<= csize) collapses the file object.
42 /
43 / Aug 25,'07 R0.05 Changed arguments of f_read(), f_write() and f_mkfs().
44 / Fixed f_mkfs() on FAT32 creates incorrect FSInfo.
45 / Fixed f_mkdir() on FAT32 creates incorrect directory.
46 / Feb 03,'08 R0.05a Added f_truncate() and f_utime().
47 / Fixed off by one error at FAT sub-type determination.
48 / Fixed btr in f_read() can be mistruncated.
49 / Fixed cached sector is not flushed when create and close
50 / without write.
51 /
52 / Apr 01,'08 R0.06 Added fputc(), fputs(), fprintf() and fgets().
53 / Improved performance of f_lseek() on moving to the same
54 / or following cluster.
55 /
C51 COMPILER V7.06 FF 03/06/2010 17:37:27 PAGE 2
56 / Apr 01,'09 R0.07 Merged Tiny-FatFs as a buffer configuration option.
57 / Added long file name support.
58 / Added multiple code page support.
59 / Added re-entrancy for multitask operation.
60 / Added auto cluster size selection to f_mkfs().
61 / Added rewind option to f_readdir().
62 / Changed result code of critical errors.
63 / Renamed string functions to avoid name collision.
64 / Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg.
65 / Added multiple sector size support.
66 / Jun 21,'09 R0.07c Fixed f_unlink() may return FR_OK on error.
67 / Fixed wrong cache control in f_lseek().
68 / Added relative path feature.
69 / Added f_chdir() and f_chdrive().
70 / Added proper case conversion to extended char.
71 /---------------------------------------------------------------------------*/
72
73 #include "ff.h" /* FatFs configurations and declarations */
*** WARNING C322 IN LINE 364 OF ff.h: unknown identifier
*** WARNING C322 IN LINE 419 OF ff.h: unknown identifier
74 #include "diskio.h" /* Declarations of low level disk I/O functions */
75
76 /*--------------------------------------------------------------------------
77
78 Module Private Definitions
79
80 ---------------------------------------------------------------------------*/
81
82 #if _FS_REENTRANT
#if _USE_LFN == 1
#error Static LFN work area must not be used in re-entrant configuration.
#endif
#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; }
#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; }
#else
90 #define ENTER_FF(fs)
91 #define LEAVE_FF(fs, res) return res
92
93 #endif
94
95 #define ABORT(fs, res) { fp->flag |= FA__ERROR; LEAVE_FF(fs, res); }
96
97 #ifndef NULL
98 #define NULL 0
99 #endif
100
101 /* Name status flags */
102 #define NS_LOSS 0x01 /* Lossy conversion */
103 #define NS_LFN 0x02 /* Force to create LFN entry */
104 #define NS_LAST 0x04 /* Last segment */
105 #define NS_BODY 0x08 /* Lower case flag (body) */
106 #define NS_EXT 0x10 /* Lower case flag (ext) */
107 #define NS_DOT 0x20 /* Dot entry */
108
109
110
111
112 /*--------------------------------------------------------------------------
113
114 Private Work Area
115
C51 COMPILER V7.06 FF 03/06/2010 17:37:27 PAGE 3
116 ---------------------------------------------------------------------------*/
117
118 static
119 FATFS *FatFs[_DRIVES]; /* Pointer to the file system objects (logical drives) */
120
121 static
122 WORD Fsid; /* File system mount ID */
123
124 #if _FS_RPATH
static
BYTE Drive; /* Current drive */
#endif
128
129
130 #if _USE_LFN == 1 /* LFN with static LFN working buffer */
static
WORD LfnBuf[_MAX_LFN + 1];
#define NAMEBUF(sp,lp) BYTE sp[12]; WCHAR *lp = LfnBuf
#define INITBUF(dj,sp,lp) dj.fn = sp; dj.lfn = lp
#elif _USE_LFN > 1 /* LFN with dynamic LFN working buffer */
#define NAMEBUF(sp,lp) BYTE sp[12]; WCHAR lbuf[_MAX_LFN + 1], *lp = lbuf
#define INITBUF(dj,sp,lp) dj.fn = sp; dj.lfn = lp
#else /* No LFN */
141 #define NAMEBUF(sp,lp) BYTE sp[12]
142 #define INITBUF(dj,sp,lp) dj.fn = sp
143
144 #endif
145
146
147
148
149 /*--------------------------------------------------------------------------
150
151 Private Functions
152
153 ---------------------------------------------------------------------------*/
154
155
156 /*-----------------------------------------------------------------------*/
157 /* String functions */
158 /*-----------------------------------------------------------------------*/
159
160 /* Copy memory to memory */
161 static
162 void mem_cpy (void* dst, const void* src, int cnt) {
163 1 char *d = (char*)dst;
164 1 const char *s = (const char *)src;
165 1 while (cnt--) *d++ = *s++;
166 1 }
167
168 /* Fill memory */
169 static
170 void mem_set (void* dst, int val, int cnt) {
171 1 char *d = (char*)dst;
172 1 while (cnt--) *d++ = (char)val;
173 1 }
174
175 /* Compare memory to memory */
176 static
177 int mem_cmp (const void* dst, const void* src, int cnt) {
C51 COMPILER V7.06 FF 03/06/2010 17:37:27 PAGE 4
178 1 const char *d = (const char *)dst, *s = (const char *)src;
179 1 int r = 0;
180 1 while (cnt-- && (r = *d++ - *s++) == 0) ;
181 1 return r;
182 1 }
183
184 /* Check if chr is contained in the string */
185 static
186 int chk_chr (const char* str, int chr) {
187 1 while (*str && *str != chr) str++;
188 1 return *str;
189 1 }
190
191
192
193 /*-----------------------------------------------------------------------*/
194 /* Request/Release grant to access the volume */
195 /*-----------------------------------------------------------------------*/
196 #if _FS_REENTRANT
static
BOOL lock_fs (
FATFS *fs /* File system object */
)
{
return ff_req_grant(fs->sobj);
}
static
void unlock_fs (
FATFS *fs, /* File system object */
FRESULT res /* Result code to be returned */
)
{
if (res != FR_NOT_ENABLED &&
res != FR_INVALID_DRIVE &&
res != FR_INVALID_OBJECT &&
res != FR_TIMEOUT) {
ff_rel_grant(fs->sobj);
}
}
#endif
221
222
223
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -