[Main] Remove redundant

And change some divisions into bitshifting
This commit is contained in:
Kostas Missos 2018-05-21 11:35:55 +03:00 committed by nwert
parent 8fdfb55f74
commit f0d88f61ca
2 changed files with 20 additions and 33 deletions

View file

@ -407,7 +407,7 @@ void print_mmc_info()
gfx_clear(&gfx_ctxt, 0xFF000000); gfx_clear(&gfx_ctxt, 0xFF000000);
gfx_con_setpos(&gfx_con, 0, 0); gfx_con_setpos(&gfx_con, 0, 0);
static const u32 SECTORS_TO_MIB_COEFF = 0x800; static const u32 SECTORS_TO_MIB_COEFF = 11;
sdmmc_storage_t storage; sdmmc_storage_t storage;
sdmmc_t sdmmc; sdmmc_t sdmmc;
@ -523,7 +523,7 @@ void print_mmc_info()
gfx_printf(&gfx_con, " 3: %kRPMB %kSize: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF00FF96, 0xFFFFFFFF, gfx_printf(&gfx_con, " 3: %kRPMB %kSize: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF00FF96, 0xFFFFFFFF,
rpmb_size / 1024, rpmb_size / 1024 / 512); rpmb_size / 1024, rpmb_size / 1024 / 512);
gfx_printf(&gfx_con, " 0: %kGPP (USER) %kSize: %05d MiB (LBA Sectors: 0x%07X)\n\n", 0xFF00FF96, 0xFFFFFFFF, gfx_printf(&gfx_con, " 0: %kGPP (USER) %kSize: %05d MiB (LBA Sectors: 0x%07X)\n\n", 0xFF00FF96, 0xFFFFFFFF,
storage.sec_cnt / SECTORS_TO_MIB_COEFF, storage.sec_cnt); storage.sec_cnt >> SECTORS_TO_MIB_COEFF, storage.sec_cnt);
gfx_printf(&gfx_con, "%kGPP (eMMC USER) partition table:%k\n", 0xFFFFDD00, 0xFFFFFFFF); gfx_printf(&gfx_con, "%kGPP (eMMC USER) partition table:%k\n", 0xFFFFDD00, 0xFFFFFFFF);
sdmmc_storage_set_mmc_partition(&storage, 0); sdmmc_storage_set_mmc_partition(&storage, 0);
@ -533,7 +533,7 @@ void print_mmc_info()
LIST_FOREACH_ENTRY(emmc_part_t, part, &gpt, link) LIST_FOREACH_ENTRY(emmc_part_t, part, &gpt, link)
{ {
gfx_printf(&gfx_con, " %02d: %k%s%k\n Size: % 5d MiB (LBA Sectors 0x%07X, LBA Range: %08X-%08X)%k\n", gfx_printf(&gfx_con, " %02d: %k%s%k\n Size: % 5d MiB (LBA Sectors 0x%07X, LBA Range: %08X-%08X)%k\n",
gpp_idx++, 0xFF14FDAE, part->name, 0xFFFFFFFF, (part->lba_end - part->lba_start + 1) / SECTORS_TO_MIB_COEFF, gpp_idx++, 0xFF14FDAE, part->name, 0xFFFFFFFF, (part->lba_end - part->lba_start + 1) >> SECTORS_TO_MIB_COEFF,
part->lba_end - part->lba_start + 1, part->lba_start, part->lba_end, 0xFFFFFFFF); part->lba_end - part->lba_start + 1, part->lba_start, part->lba_end, 0xFFFFFFFF);
} }
} }
@ -550,7 +550,7 @@ void print_sdcard_info()
gfx_clear(&gfx_ctxt, 0xFF000000); gfx_clear(&gfx_ctxt, 0xFF000000);
gfx_con_setpos(&gfx_con, 0, 0); gfx_con_setpos(&gfx_con, 0, 0);
static const u32 SECTORS_TO_MIB_COEFF = 0x800; static const u32 SECTORS_TO_MIB_COEFF = 11;
if (sd_mount()) if (sd_mount())
{ {
@ -572,30 +572,17 @@ void print_sdcard_info()
sd_storage.cid.month, sd_storage.cid.year); sd_storage.cid.month, sd_storage.cid.year);
gfx_printf(&gfx_con, "%kCard-Specific Data V%d.0:%k\n", 0xFFFFDD00, sd_storage.csd.structure + 1, 0xFFFFFFFF); gfx_printf(&gfx_con, "%kCard-Specific Data V%d.0:%k\n", 0xFFFFDD00, sd_storage.csd.structure + 1, 0xFFFFFFFF);
switch(sd_storage.csd.structure) capacity = sd_storage.csd.capacity >> (20 - sd_storage.csd.read_blkbits);
{
case 0:
capacity = (sd_storage.csd.capacity << sd_storage.csd.read_blkbits) / 1024 / 1024;
gfx_printf(&gfx_con, gfx_printf(&gfx_con,
" Cmd Classes: %02X\n\ " Cmd Classes: %02X\n\
Capacity: %d MiB\n", Capacity: %d MiB\n\
sd_storage.csd.cmdclass, capacity); Bus Width: %d\n\
break;
case 1:
capacity = (sd_storage.csd.c_size << sd_storage.csd.read_blkbits) / 1024;
gfx_printf(&gfx_con,
" Cmd Classes: %02X\n\
Capacity: %d MiB\n",
sd_storage.csd.cmdclass, capacity);
break;
}
gfx_printf(&gfx_con,
" Bus Width: %d\n\
Speed Class: %d\n\ Speed Class: %d\n\
UHS Grade: U%d\n\ UHS Grade: U%d\n\
Video Class: V%d\n\ Video Class: V%d\n\
App perf class: A%d\n\ App perf class: A%d\n\
Write Protect: %d\n\n", Write Protect: %d\n\n",
sd_storage.csd.cmdclass, capacity,
sd_storage.ssr.bus_width, sd_storage.ssr.speed_class, sd_storage.ssr.uhs_grade, sd_storage.ssr.bus_width, sd_storage.ssr.speed_class, sd_storage.ssr.uhs_grade,
sd_storage.ssr.video_class, sd_storage.ssr.app_class, sd_storage.csd.write_protect); sd_storage.ssr.video_class, sd_storage.ssr.app_class, sd_storage.csd.write_protect);
@ -603,7 +590,7 @@ void print_sdcard_info()
f_getfree("", &sd_fs.free_clst, NULL); f_getfree("", &sd_fs.free_clst, NULL);
gfx_printf(&gfx_con, "%kFound %s volume:%k\n Free: %d MiB\n Cluster: %d B\n", gfx_printf(&gfx_con, "%kFound %s volume:%k\n Free: %d MiB\n Cluster: %d B\n",
0xFFFFDD00, sd_fs.fs_type == FS_EXFAT ? "exFAT" : "FAT32", 0xFFFFFFFF, 0xFFFFDD00, sd_fs.fs_type == FS_EXFAT ? "exFAT" : "FAT32", 0xFFFFFFFF,
sd_fs.free_clst * sd_fs.csize / SECTORS_TO_MIB_COEFF, sd_fs.csize * 512); sd_fs.free_clst * sd_fs.csize >> SECTORS_TO_MIB_COEFF, sd_fs.csize * 512);
} }
sleep(1000000); sleep(1000000);
@ -939,7 +926,7 @@ static void dump_emmc_selected(dumpType_t dumpType)
if (!sd_mount()) if (!sd_mount())
goto out; goto out;
gfx_puts(&gfx_con, "Checking for available free space...\n"); gfx_puts(&gfx_con, "Checking for available free space...\n\n");
// Get SD Card free space for partial dumping // Get SD Card free space for partial dumping
f_getfree("", &sd_fs.free_clst, NULL); f_getfree("", &sd_fs.free_clst, NULL);