diff options
Diffstat (limited to 'firmware/drivers/fat.c')
-rw-r--r-- | firmware/drivers/fat.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index ebf0f92798..f3c273cc05 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c | |||
@@ -173,9 +173,9 @@ union raw_dirent | |||
173 | 173 | ||
174 | struct fsinfo | 174 | struct fsinfo |
175 | { | 175 | { |
176 | unsigned long freecount; /* last known free cluster count */ | 176 | sector_t freecount; /* last known free cluster count */ |
177 | unsigned long nextfree; /* first cluster to start looking for free | 177 | sector_t nextfree; /* first cluster to start looking for free |
178 | clusters, or 0xffffffff for no hint */ | 178 | clusters, or 0xffffffff for no hint */ |
179 | }; | 179 | }; |
180 | /* fsinfo offsets */ | 180 | /* fsinfo offsets */ |
181 | #define FSINFO_SIGNATURE 0 | 181 | #define FSINFO_SIGNATURE 0 |
@@ -233,7 +233,7 @@ static struct bpb | |||
233 | unsigned long totalsectors; | 233 | unsigned long totalsectors; |
234 | unsigned long rootdirsector; | 234 | unsigned long rootdirsector; |
235 | unsigned long firstdatasector; | 235 | unsigned long firstdatasector; |
236 | unsigned long startsector; | 236 | sector_t startsector; |
237 | unsigned long dataclusters; | 237 | unsigned long dataclusters; |
238 | unsigned long fatrgnstart; | 238 | unsigned long fatrgnstart; |
239 | unsigned long fatrgnend; | 239 | unsigned long fatrgnend; |
@@ -241,8 +241,8 @@ static struct bpb | |||
241 | #ifdef HAVE_FAT16SUPPORT | 241 | #ifdef HAVE_FAT16SUPPORT |
242 | unsigned int bpb_rootentcnt; /* Number of dir entries in the root */ | 242 | unsigned int bpb_rootentcnt; /* Number of dir entries in the root */ |
243 | /* internals for FAT16 support */ | 243 | /* internals for FAT16 support */ |
244 | unsigned long rootdirsectornum; /* sector offset of root dir relative to start | 244 | sector_t rootdirsectornum; /* sector offset of root dir relative to start |
245 | * of first pseudo cluster */ | 245 | * of first pseudo cluster */ |
246 | #endif /* HAVE_FAT16SUPPORT */ | 246 | #endif /* HAVE_FAT16SUPPORT */ |
247 | 247 | ||
248 | /** Additional information kept for each volume **/ | 248 | /** Additional information kept for each volume **/ |
@@ -329,7 +329,7 @@ static void cache_discard(IF_MV_NONVOID(struct bpb *fat_bpb)) | |||
329 | } | 329 | } |
330 | 330 | ||
331 | /* caches a FAT or data area sector */ | 331 | /* caches a FAT or data area sector */ |
332 | static void * cache_sector(struct bpb *fat_bpb, unsigned long secnum) | 332 | static void * cache_sector(struct bpb *fat_bpb, sector_t secnum) |
333 | { | 333 | { |
334 | unsigned int flags; | 334 | unsigned int flags; |
335 | void *buf = dc_cache_probe(IF_MV(fat_bpb->volume,) secnum, &flags); | 335 | void *buf = dc_cache_probe(IF_MV(fat_bpb->volume,) secnum, &flags); |
@@ -340,8 +340,8 @@ static void * cache_sector(struct bpb *fat_bpb, unsigned long secnum) | |||
340 | secnum + fat_bpb->startsector, 1, buf); | 340 | secnum + fat_bpb->startsector, 1, buf); |
341 | if (UNLIKELY(rc < 0)) | 341 | if (UNLIKELY(rc < 0)) |
342 | { | 342 | { |
343 | DEBUGF("%s() - Could not read sector %ld" | 343 | DEBUGF("%s() - Could not read sector %llu" |
344 | " (error %d)\n", __func__, secnum, rc); | 344 | " (error %d)\n", __func__, (uint64_t)secnum, rc); |
345 | dc_discard_buf(buf); | 345 | dc_discard_buf(buf); |
346 | return NULL; | 346 | return NULL; |
347 | } | 347 | } |
@@ -354,14 +354,14 @@ static void * cache_sector(struct bpb *fat_bpb, unsigned long secnum) | |||
354 | * contents are NOT loaded before returning - use when completely overwriting | 354 | * contents are NOT loaded before returning - use when completely overwriting |
355 | * a sector's contents in order to avoid a fill */ | 355 | * a sector's contents in order to avoid a fill */ |
356 | static void * cache_sector_buffer(IF_MV(struct bpb *fat_bpb,) | 356 | static void * cache_sector_buffer(IF_MV(struct bpb *fat_bpb,) |
357 | unsigned long secnum) | 357 | sector_t secnum) |
358 | { | 358 | { |
359 | unsigned int flags; | 359 | unsigned int flags; |
360 | return dc_cache_probe(IF_MV(fat_bpb->volume,) secnum, &flags); | 360 | return dc_cache_probe(IF_MV(fat_bpb->volume,) secnum, &flags); |
361 | } | 361 | } |
362 | 362 | ||
363 | /* flush a cache buffer to storage */ | 363 | /* flush a cache buffer to storage */ |
364 | void dc_writeback_callback(IF_MV(int volume,) unsigned long sector, void *buf) | 364 | void dc_writeback_callback(IF_MV(int volume,) sector_t sector, void *buf) |
365 | { | 365 | { |
366 | struct bpb * const fat_bpb = &fat_bpbs[IF_MV_VOL(volume)]; | 366 | struct bpb * const fat_bpb = &fat_bpbs[IF_MV_VOL(volume)]; |
367 | unsigned int copies = !IS_FAT_SECTOR(fat_bpb, sector) ? | 367 | unsigned int copies = !IS_FAT_SECTOR(fat_bpb, sector) ? |
@@ -374,8 +374,8 @@ void dc_writeback_callback(IF_MV(int volume,) unsigned long sector, void *buf) | |||
374 | int rc = storage_write_sectors(IF_MD(fat_bpb->drive,) sector, 1, buf); | 374 | int rc = storage_write_sectors(IF_MD(fat_bpb->drive,) sector, 1, buf); |
375 | if (rc < 0) | 375 | if (rc < 0) |
376 | { | 376 | { |
377 | panicf("%s() - Could not write sector %ld" | 377 | panicf("%s() - Could not write sector %llu" |
378 | " (error %d)\n", __func__, sector, rc); | 378 | " (error %d)\n", __func__, (uint64_t)sector, rc); |
379 | } | 379 | } |
380 | 380 | ||
381 | if (--copies == 0) | 381 | if (--copies == 0) |
@@ -2397,12 +2397,12 @@ unsigned long fat_query_sectornum(const struct fat_filestr *filestr) | |||
2397 | } | 2397 | } |
2398 | 2398 | ||
2399 | /* helper for fat_readwrite */ | 2399 | /* helper for fat_readwrite */ |
2400 | static long transfer(struct bpb *fat_bpb, unsigned long start, long count, | 2400 | static long transfer(struct bpb *fat_bpb, sector_t start, long count, |
2401 | char *buf, bool write) | 2401 | char *buf, bool write) |
2402 | { | 2402 | { |
2403 | long rc = 0; | 2403 | long rc = 0; |
2404 | 2404 | ||
2405 | DEBUGF("%s(s=%lx, c=%lx, wr=%u)\n", __func__, | 2405 | DEBUGF("%s(s=%llx, c=%lx, wr=%u)\n", __func__, |
2406 | start + fat_bpb->startsector, count, write ? 1 : 0); | 2406 | start + fat_bpb->startsector, count, write ? 1 : 0); |
2407 | 2407 | ||
2408 | if (write) | 2408 | if (write) |
@@ -2416,12 +2416,12 @@ static long transfer(struct bpb *fat_bpb, unsigned long start, long count, | |||
2416 | firstallowed = fat_bpb->firstdatasector; | 2416 | firstallowed = fat_bpb->firstdatasector; |
2417 | 2417 | ||
2418 | if (start < firstallowed) | 2418 | if (start < firstallowed) |
2419 | panicf("Write %ld before data\n", firstallowed - start); | 2419 | panicf("Write %llu before data\n", (uint64_t)(firstallowed - start)); |
2420 | 2420 | ||
2421 | if (start + count > fat_bpb->totalsectors) | 2421 | if (start + count > fat_bpb->totalsectors) |
2422 | { | 2422 | { |
2423 | panicf("Write %ld after data\n", | 2423 | panicf("Write %llu after data\n", |
2424 | start + count - fat_bpb->totalsectors); | 2424 | (uint64_t)(start + count - fat_bpb->totalsectors)); |
2425 | } | 2425 | } |
2426 | } | 2426 | } |
2427 | 2427 | ||
@@ -2487,14 +2487,14 @@ long fat_readwrite(struct fat_filestr *filestr, unsigned long sectorcount, | |||
2487 | long rc; | 2487 | long rc; |
2488 | 2488 | ||
2489 | long cluster = filestr->lastcluster; | 2489 | long cluster = filestr->lastcluster; |
2490 | unsigned long sector = filestr->lastsector; | 2490 | sector_t sector = filestr->lastsector; |
2491 | long clusternum = filestr->clusternum; | 2491 | long clusternum = filestr->clusternum; |
2492 | unsigned long sectornum = filestr->sectornum; | 2492 | unsigned long sectornum = filestr->sectornum; |
2493 | 2493 | ||
2494 | DEBUGF("%s(file:%lx,count:0x%lx,buf:%lx,%s)\n", __func__, | 2494 | DEBUGF("%s(file:%lx,count:0x%lx,buf:%lx,%s)\n", __func__, |
2495 | file->firstcluster, sectorcount, (long)buf, | 2495 | file->firstcluster, sectorcount, (long)buf, |
2496 | write ? "write":"read"); | 2496 | write ? "write":"read"); |
2497 | DEBUGF("%s: sec:%lx numsec:%ld eof:%d\n", __func__, | 2497 | DEBUGF("%s: sec:%llx numsec:%ld eof:%d\n", __func__, |
2498 | sector, (long)sectornum, eof ? 1 : 0); | 2498 | sector, (long)sectornum, eof ? 1 : 0); |
2499 | 2499 | ||
2500 | eof = false; | 2500 | eof = false; |
@@ -2534,7 +2534,7 @@ long fat_readwrite(struct fat_filestr *filestr, unsigned long sectorcount, | |||
2534 | 2534 | ||
2535 | unsigned long transferred = 0; | 2535 | unsigned long transferred = 0; |
2536 | unsigned long count = 0; | 2536 | unsigned long count = 0; |
2537 | unsigned long last = sector; | 2537 | sector_t last = sector; |
2538 | 2538 | ||
2539 | while (transferred + count < sectorcount) | 2539 | while (transferred + count < sectorcount) |
2540 | { | 2540 | { |
@@ -2961,7 +2961,7 @@ void fat_recalc_free(IF_MV_NONVOID(int volume)) | |||
2961 | dc_unlock_cache(); | 2961 | dc_unlock_cache(); |
2962 | } | 2962 | } |
2963 | 2963 | ||
2964 | bool fat_size(IF_MV(int volume,) unsigned long *size, unsigned long *free) | 2964 | bool fat_size(IF_MV(int volume,) sector_t *size, sector_t *free) |
2965 | { | 2965 | { |
2966 | struct bpb * const fat_bpb = FAT_BPB(volume); | 2966 | struct bpb * const fat_bpb = FAT_BPB(volume); |
2967 | if (!fat_bpb) | 2967 | if (!fat_bpb) |