diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/ata.c | 38 | ||||
-rw-r--r-- | firmware/drivers/fat.c | 44 | ||||
-rw-r--r-- | firmware/drivers/lcd-scroll.c | 8 | ||||
-rw-r--r-- | firmware/drivers/ramdisk.c | 6 | ||||
-rw-r--r-- | firmware/drivers/sd.c | 12 |
5 files changed, 63 insertions, 45 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index d82fb173cc..b4d8a388ec 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c | |||
@@ -109,15 +109,15 @@ static long last_disk_activity = -1; | |||
109 | static long power_off_tick = 0; | 109 | static long power_off_tick = 0; |
110 | #endif | 110 | #endif |
111 | 111 | ||
112 | static unsigned long total_sectors; | 112 | static sector_t total_sectors; |
113 | static int multisectors; /* number of supported multisectors */ | 113 | static int multisectors; /* number of supported multisectors */ |
114 | static unsigned short identify_info[SECTOR_SIZE/2]; | 114 | static unsigned short identify_info[ATA_IDENTIFY_WORDS]; |
115 | 115 | ||
116 | #ifdef MAX_PHYS_SECTOR_SIZE | 116 | #ifdef MAX_PHYS_SECTOR_SIZE |
117 | 117 | ||
118 | struct sector_cache_entry { | 118 | struct sector_cache_entry { |
119 | bool inuse; | 119 | bool inuse; |
120 | unsigned long sectornum; /* logical sector */ | 120 | sector_t sectornum; /* logical sector */ |
121 | unsigned char data[MAX_PHYS_SECTOR_SIZE]; | 121 | unsigned char data[MAX_PHYS_SECTOR_SIZE]; |
122 | }; | 122 | }; |
123 | /* buffer for reading and writing large physical sectors */ | 123 | /* buffer for reading and writing large physical sectors */ |
@@ -381,7 +381,7 @@ static ICODE_ATTR void copy_write_sectors(const unsigned char* buf, | |||
381 | } | 381 | } |
382 | #endif /* !ATA_OPTIMIZED_WRITING */ | 382 | #endif /* !ATA_OPTIMIZED_WRITING */ |
383 | 383 | ||
384 | static int ata_transfer_sectors(unsigned long start, | 384 | static int ata_transfer_sectors(uint64_t start, |
385 | int incount, | 385 | int incount, |
386 | void* inbuf, | 386 | void* inbuf, |
387 | int write) | 387 | int write) |
@@ -443,9 +443,9 @@ static int ata_transfer_sectors(unsigned long start, | |||
443 | ATA_OUT8(ATA_NSECTOR, count & 0xff); | 443 | ATA_OUT8(ATA_NSECTOR, count & 0xff); |
444 | ATA_OUT8(ATA_SECTOR, (start >> 24) & 0xff); /* 31:24 */ | 444 | ATA_OUT8(ATA_SECTOR, (start >> 24) & 0xff); /* 31:24 */ |
445 | ATA_OUT8(ATA_SECTOR, start & 0xff); /* 7:0 */ | 445 | ATA_OUT8(ATA_SECTOR, start & 0xff); /* 7:0 */ |
446 | ATA_OUT8(ATA_LCYL, 0); /* 39:32 */ | 446 | ATA_OUT8(ATA_LCYL, (start >> 32) & 0xff); /* 39:32 */ |
447 | ATA_OUT8(ATA_LCYL, (start >> 8) & 0xff); /* 15:8 */ | 447 | ATA_OUT8(ATA_LCYL, (start >> 8) & 0xff); /* 15:8 */ |
448 | ATA_OUT8(ATA_HCYL, 0); /* 47:40 */ | 448 | ATA_OUT8(ATA_HCYL, (start >> 40) & 0xff); /* 47:40 */ |
449 | ATA_OUT8(ATA_HCYL, (start >> 16) & 0xff); /* 23:16 */ | 449 | ATA_OUT8(ATA_HCYL, (start >> 16) & 0xff); /* 23:16 */ |
450 | ATA_OUT8(ATA_SELECT, SELECT_LBA | ata_device); | 450 | ATA_OUT8(ATA_SELECT, SELECT_LBA | ata_device); |
451 | #ifdef HAVE_ATA_DMA | 451 | #ifdef HAVE_ATA_DMA |
@@ -592,7 +592,7 @@ static int ata_transfer_sectors(unsigned long start, | |||
592 | 592 | ||
593 | #ifndef MAX_PHYS_SECTOR_SIZE | 593 | #ifndef MAX_PHYS_SECTOR_SIZE |
594 | int ata_read_sectors(IF_MD(int drive,) | 594 | int ata_read_sectors(IF_MD(int drive,) |
595 | unsigned long start, | 595 | sector_t start, |
596 | int incount, | 596 | int incount, |
597 | void* inbuf) | 597 | void* inbuf) |
598 | { | 598 | { |
@@ -607,7 +607,7 @@ int ata_read_sectors(IF_MD(int drive,) | |||
607 | } | 607 | } |
608 | 608 | ||
609 | int ata_write_sectors(IF_MD(int drive,) | 609 | int ata_write_sectors(IF_MD(int drive,) |
610 | unsigned long start, | 610 | sector_t start, |
611 | int count, | 611 | int count, |
612 | const void* buf) | 612 | const void* buf) |
613 | { | 613 | { |
@@ -623,7 +623,7 @@ int ata_write_sectors(IF_MD(int drive,) | |||
623 | #endif /* ndef MAX_PHYS_SECTOR_SIZE */ | 623 | #endif /* ndef MAX_PHYS_SECTOR_SIZE */ |
624 | 624 | ||
625 | #ifdef MAX_PHYS_SECTOR_SIZE | 625 | #ifdef MAX_PHYS_SECTOR_SIZE |
626 | static int cache_sector(unsigned long sector) | 626 | static int cache_sector(sector_t sector) |
627 | { | 627 | { |
628 | int rc; | 628 | int rc; |
629 | 629 | ||
@@ -652,7 +652,7 @@ static inline int flush_current_sector(void) | |||
652 | } | 652 | } |
653 | 653 | ||
654 | int ata_read_sectors(IF_MD(int drive,) | 654 | int ata_read_sectors(IF_MD(int drive,) |
655 | unsigned long start, | 655 | sector_t start, |
656 | int incount, | 656 | int incount, |
657 | void* inbuf) | 657 | void* inbuf) |
658 | { | 658 | { |
@@ -718,7 +718,7 @@ int ata_read_sectors(IF_MD(int drive,) | |||
718 | } | 718 | } |
719 | 719 | ||
720 | int ata_write_sectors(IF_MD(int drive,) | 720 | int ata_write_sectors(IF_MD(int drive,) |
721 | unsigned long start, | 721 | sector_t start, |
722 | int count, | 722 | int count, |
723 | const void* buf) | 723 | const void* buf) |
724 | { | 724 | { |
@@ -845,7 +845,7 @@ void ata_spindown(int seconds) | |||
845 | 845 | ||
846 | bool ata_disk_is_active(void) | 846 | bool ata_disk_is_active(void) |
847 | { | 847 | { |
848 | return ata_state >= ATA_SPINUP; | 848 | return ata_disk_can_poweroff() ? (ata_state >= ATA_SPINUP) : 0; |
849 | } | 849 | } |
850 | 850 | ||
851 | void ata_sleepnow(void) | 851 | void ata_sleepnow(void) |
@@ -916,7 +916,7 @@ static int identify(void) | |||
916 | return -2; | 916 | return -2; |
917 | } | 917 | } |
918 | 918 | ||
919 | for (i=0; i<SECTOR_SIZE/2; i++) { | 919 | for (i=0; i<ATA_IDENTIFY_WORDS; i++) { |
920 | /* the IDENTIFY words are already swapped, so we need to treat | 920 | /* the IDENTIFY words are already swapped, so we need to treat |
921 | this info differently that normal sector data */ | 921 | this info differently that normal sector data */ |
922 | identify_info[i] = ATA_SWAP_IDENTIFY(ATA_IN16(ATA_DATA)); | 922 | identify_info[i] = ATA_SWAP_IDENTIFY(ATA_IN16(ATA_DATA)); |
@@ -1269,10 +1269,8 @@ int STORAGE_INIT_ATTR ata_init(void) | |||
1269 | if (identify_info[83] & 0x0400 /* 48 bit address support */ | 1269 | if (identify_info[83] & 0x0400 /* 48 bit address support */ |
1270 | && total_sectors == 0x0FFFFFFF) /* and disk size >= 128 GiB */ | 1270 | && total_sectors == 0x0FFFFFFF) /* and disk size >= 128 GiB */ |
1271 | { /* (needs BigLBA addressing) */ | 1271 | { /* (needs BigLBA addressing) */ |
1272 | if (identify_info[102] || identify_info[103]) | 1272 | total_sectors = identify_info[100] | (identify_info[101] << 16) | ((uint64_t)identify_info[102] << 32) | ((uint64_t)identify_info[103] << 48); |
1273 | panicf("Unsupported disk size: >= 2^32 sectors"); | ||
1274 | 1273 | ||
1275 | total_sectors = identify_info[100] | (identify_info[101] << 16); | ||
1276 | lba48 = true; /* use BigLBA */ | 1274 | lba48 = true; /* use BigLBA */ |
1277 | } | 1275 | } |
1278 | #endif /* HAVE_LBA48 */ | 1276 | #endif /* HAVE_LBA48 */ |
@@ -1360,7 +1358,13 @@ void ata_get_info(IF_MD(int drive,)struct storage_info *info) | |||
1360 | (void)drive; /* unused for now */ | 1358 | (void)drive; /* unused for now */ |
1361 | #endif | 1359 | #endif |
1362 | int i; | 1360 | int i; |
1363 | info->sector_size = SECTOR_SIZE; | 1361 | |
1362 | /* Logical sector size */ | ||
1363 | if ((identify_info[106] & 0xd000) == 0x5000) | ||
1364 | info->sector_size = identify_info[117] | (identify_info[118] << 16); | ||
1365 | else | ||
1366 | info->sector_size = SECTOR_SIZE; | ||
1367 | |||
1364 | info->num_sectors = total_sectors; | 1368 | info->num_sectors = total_sectors; |
1365 | 1369 | ||
1366 | src = (unsigned short*)&identify_info[27]; | 1370 | src = (unsigned short*)&identify_info[27]; |
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) |
diff --git a/firmware/drivers/lcd-scroll.c b/firmware/drivers/lcd-scroll.c index 895cf98cba..2a58d6ff21 100644 --- a/firmware/drivers/lcd-scroll.c +++ b/firmware/drivers/lcd-scroll.c | |||
@@ -195,8 +195,14 @@ static void LCDFN(scroll_worker)(void) | |||
195 | s = &si->scroll[index]; | 195 | s = &si->scroll[index]; |
196 | 196 | ||
197 | /* check pause */ | 197 | /* check pause */ |
198 | if (TIME_BEFORE(current_tick, s->start_tick)) | 198 | if (TIME_BEFORE(current_tick, s->start_tick)) { |
199 | continue; | 199 | continue; |
200 | } | ||
201 | |||
202 | if (global_settings.disable_mainmenu_scrolling && get_current_activity() == ACTIVITY_MAINMENU) { | ||
203 | // No scrolling on the main menu if disabled (to not break themes with lockscreens) | ||
204 | continue; | ||
205 | } | ||
200 | 206 | ||
201 | s->start_tick = current_tick; | 207 | s->start_tick = current_tick; |
202 | 208 | ||
diff --git a/firmware/drivers/ramdisk.c b/firmware/drivers/ramdisk.c index 9f73b6b5c3..cecc943352 100644 --- a/firmware/drivers/ramdisk.c +++ b/firmware/drivers/ramdisk.c | |||
@@ -32,7 +32,7 @@ static unsigned char ramdisk[SECTOR_SIZE * NUM_SECTORS]; | |||
32 | static long last_disk_activity = -1; | 32 | static long last_disk_activity = -1; |
33 | 33 | ||
34 | int ramdisk_read_sectors(IF_MD(int drive,) | 34 | int ramdisk_read_sectors(IF_MD(int drive,) |
35 | unsigned long start, | 35 | sector_t start, |
36 | int count, | 36 | int count, |
37 | void* buf) | 37 | void* buf) |
38 | { | 38 | { |
@@ -48,7 +48,7 @@ int ramdisk_read_sectors(IF_MD(int drive,) | |||
48 | } | 48 | } |
49 | 49 | ||
50 | int ramdisk_write_sectors(IF_MD(int drive,) | 50 | int ramdisk_write_sectors(IF_MD(int drive,) |
51 | unsigned long start, | 51 | sector_t start, |
52 | int count, | 52 | int count, |
53 | const void* buf) | 53 | const void* buf) |
54 | { | 54 | { |
@@ -134,7 +134,7 @@ int ramdisk_num_drives(int first_drive) | |||
134 | { | 134 | { |
135 | /* We don't care which logical drive number(s) we have been assigned */ | 135 | /* We don't care which logical drive number(s) we have been assigned */ |
136 | (void)first_drive; | 136 | (void)first_drive; |
137 | 137 | ||
138 | return 1; | 138 | return 1; |
139 | } | 139 | } |
140 | #endif | 140 | #endif |
diff --git a/firmware/drivers/sd.c b/firmware/drivers/sd.c index 6185d5382d..ca83498087 100644 --- a/firmware/drivers/sd.c +++ b/firmware/drivers/sd.c | |||
@@ -49,6 +49,13 @@ void sd_parse_csd(tCardInfo *card) | |||
49 | c_size = card_extract_bits(card->csd, 69, 22) + 1; | 49 | c_size = card_extract_bits(card->csd, 69, 22) + 1; |
50 | card->numblocks = c_size << 10; | 50 | card->numblocks = c_size << 10; |
51 | } | 51 | } |
52 | else if(csd_version == 2) | ||
53 | { | ||
54 | /* CSD version 3.0 */ | ||
55 | c_size = card_extract_bits(card->csd, 75, 28) + 1; | ||
56 | card->numblocks = c_size << 10; | ||
57 | } | ||
58 | card->sd2plus = csd_version >= 1; | ||
52 | 59 | ||
53 | card->blocksize = 512; /* Always use 512 byte blocks */ | 60 | card->blocksize = 512; /* Always use 512 byte blocks */ |
54 | 61 | ||
@@ -62,7 +69,9 @@ void sd_parse_csd(tCardInfo *card) | |||
62 | 69 | ||
63 | card->r2w_factor = card_extract_bits(card->csd, 28, 3); | 70 | card->r2w_factor = card_extract_bits(card->csd, 28, 3); |
64 | 71 | ||
65 | logf("CSD%d.0 numblocks:%ld speed:%ld", csd_version+1, card->numblocks, card->speed); | 72 | |
73 | |||
74 | logf("CSD%d.0 numblocks:%lld speed:%ld", csd_version+1, card->numblocks, card->speed); | ||
66 | logf("nsac: %d taac: %ld r2w: %d", card->nsac, card->taac, card->r2w_factor); | 75 | logf("nsac: %d taac: %ld r2w: %d", card->nsac, card->taac, card->r2w_factor); |
67 | } | 76 | } |
68 | 77 | ||
@@ -99,4 +108,3 @@ void sd_get_info(IF_MD(int drive,) struct storage_info *info) | |||
99 | info->revision="0.00"; | 108 | info->revision="0.00"; |
100 | } | 109 | } |
101 | #endif | 110 | #endif |
102 | |||