summaryrefslogtreecommitdiff
path: root/firmware/drivers/fat.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/fat.c')
-rw-r--r--firmware/drivers/fat.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index 9dd27cf72a..f3374fc4c4 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -172,6 +172,7 @@ struct bpb
172}; 172};
173 173
174static struct bpb fat_bpbs[NUM_VOLUMES]; /* mounted partition info */ 174static struct bpb fat_bpbs[NUM_VOLUMES]; /* mounted partition info */
175static bool initialized = false;
175 176
176static int update_fsinfo(IF_MV_NONVOID(struct bpb* fat_bpb)); 177static int update_fsinfo(IF_MV_NONVOID(struct bpb* fat_bpb));
177static int flush_fat(IF_MV_NONVOID(struct bpb* fat_bpb)); 178static int flush_fat(IF_MV_NONVOID(struct bpb* fat_bpb));
@@ -202,6 +203,18 @@ static char fat_cache_sectors[FAT_CACHE_SIZE][SECTOR_SIZE];
202static struct fat_cache_entry fat_cache[FAT_CACHE_SIZE]; 203static struct fat_cache_entry fat_cache[FAT_CACHE_SIZE];
203static struct mutex cache_mutex NOCACHEBSS_ATTR; 204static struct mutex cache_mutex NOCACHEBSS_ATTR;
204 205
206#ifdef HAVE_HOTSWAP
207void fat_lock(void)
208{
209 mutex_lock(&cache_mutex);
210}
211
212void fat_unlock(void)
213{
214 mutex_unlock(&cache_mutex);
215}
216#endif
217
205static long cluster2sec(IF_MV2(struct bpb* fat_bpb,) long cluster) 218static long cluster2sec(IF_MV2(struct bpb* fat_bpb,) long cluster)
206{ 219{
207#ifndef HAVE_MULTIVOLUME 220#ifndef HAVE_MULTIVOLUME
@@ -240,7 +253,11 @@ void fat_init(void)
240{ 253{
241 unsigned int i; 254 unsigned int i;
242 255
243 mutex_init(&cache_mutex); 256 if (!initialized)
257 {
258 initialized = true;
259 mutex_init(&cache_mutex);
260 }
244 261
245 /* mark the FAT cache as unused */ 262 /* mark the FAT cache as unused */
246 for(i = 0;i < FAT_CACHE_SIZE;i++) 263 for(i = 0;i < FAT_CACHE_SIZE;i++)