mirror of
https://github.com/CTCaer/hekate
synced 2024-12-22 19:31:12 +00:00
[sd] Correct ssr parsing + add write protect info
This commit is contained in:
parent
54187226c8
commit
e06d833cf8
3 changed files with 44 additions and 27 deletions
|
@ -574,9 +574,10 @@ void print_sdcard_info()
|
||||||
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\n",
|
App perf class: A%d\n\
|
||||||
|
Write Protect: %d\n\n",
|
||||||
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.ssr.video_class, sd_storage.ssr.app_class, sd_storage.csd.write_protect);
|
||||||
|
|
||||||
gfx_puts(&gfx_con, "Acquiring FAT volume info...\n\n");
|
gfx_puts(&gfx_con, "Acquiring FAT volume info...\n\n");
|
||||||
f_getfree("", &sd_fs.free_clst, NULL);
|
f_getfree("", &sd_fs.free_clst, NULL);
|
||||||
|
|
29
ipl/sdmmc.c
29
ipl/sdmmc.c
|
@ -824,9 +824,22 @@ int _sd_storage_enable_highspeed_high_volt(sdmmc_storage_t *storage, u8 *buf)
|
||||||
|
|
||||||
static void _sd_storage_parse_ssr(sdmmc_storage_t *storage)
|
static void _sd_storage_parse_ssr(sdmmc_storage_t *storage)
|
||||||
{
|
{
|
||||||
u32 *raw_ssr = (u32 *)&(storage->raw_ssr);
|
// unstuff_bits supports only 4 u32 so break into 2 x 16byte groups
|
||||||
storage->ssr.bus_width = unstuff_bits(raw_ssr, 510 - 384, 2) & SD_BUS_WIDTH_4 ? 4 : 1;
|
u32 raw_ssr1[4];
|
||||||
switch(unstuff_bits(raw_ssr, 440 - 384, 8))
|
u32 raw_ssr2[4];
|
||||||
|
|
||||||
|
raw_ssr1[3] = *(u32 *)&storage->raw_ssr[12];
|
||||||
|
raw_ssr1[2] = *(u32 *)&storage->raw_ssr[8];
|
||||||
|
raw_ssr1[1] = *(u32 *)&storage->raw_ssr[4];
|
||||||
|
raw_ssr1[0] = *(u32 *)&storage->raw_ssr[0];
|
||||||
|
|
||||||
|
raw_ssr2[3] = *(u32 *)&storage->raw_ssr[28];
|
||||||
|
raw_ssr2[2] = *(u32 *)&storage->raw_ssr[24];
|
||||||
|
raw_ssr2[1] = *(u32 *)&storage->raw_ssr[20];
|
||||||
|
raw_ssr2[0] = *(u32 *)&storage->raw_ssr[16];
|
||||||
|
|
||||||
|
storage->ssr.bus_width = unstuff_bits(raw_ssr1, 510 - 384, 2) & SD_BUS_WIDTH_4 ? 4 : 1;
|
||||||
|
switch(unstuff_bits(raw_ssr1, 440 - 384, 8))
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
storage->ssr.speed_class = 0;
|
storage->ssr.speed_class = 0;
|
||||||
|
@ -844,12 +857,13 @@ static void _sd_storage_parse_ssr(sdmmc_storage_t *storage)
|
||||||
storage->ssr.speed_class = 10;
|
storage->ssr.speed_class = 10;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
storage->ssr.speed_class = unstuff_bits(raw_ssr, 440 - 384, 8);
|
storage->ssr.speed_class = unstuff_bits(raw_ssr1, 440 - 384, 8);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
storage->ssr.uhs_grade = unstuff_bits(raw_ssr, 396 - 384, 4);
|
storage->ssr.uhs_grade = unstuff_bits(raw_ssr1, 396 - 384, 4);
|
||||||
storage->ssr.video_class = unstuff_bits(raw_ssr, 384 - 384, 8);
|
storage->ssr.video_class = unstuff_bits(raw_ssr1, 384 - 384, 8);
|
||||||
storage->ssr.app_class = unstuff_bits(raw_ssr + 16, 472 + 4 - 384, 4);
|
|
||||||
|
storage->ssr.app_class = unstuff_bits(raw_ssr2, 336 - 256, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _sd_storage_get_ssr(sdmmc_storage_t *storage, u8 *buf)
|
static int _sd_storage_get_ssr(sdmmc_storage_t *storage, u8 *buf)
|
||||||
|
@ -914,6 +928,7 @@ static void _sd_storage_parse_csd(sdmmc_storage_t *storage)
|
||||||
storage->csd.structure = unstuff_bits(raw_csd, 126, 2);
|
storage->csd.structure = unstuff_bits(raw_csd, 126, 2);
|
||||||
storage->csd.cmdclass = unstuff_bits(raw_csd, 84, 12);
|
storage->csd.cmdclass = unstuff_bits(raw_csd, 84, 12);
|
||||||
storage->csd.read_blkbits = unstuff_bits(raw_csd, 80, 4);
|
storage->csd.read_blkbits = unstuff_bits(raw_csd, 80, 4);
|
||||||
|
storage->csd.write_protect = unstuff_bits(raw_csd, 12, 2);
|
||||||
switch(storage->csd.structure)
|
switch(storage->csd.structure)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
|
|
@ -46,6 +46,7 @@ typedef struct _mmc_csd
|
||||||
u32 read_blkbits;
|
u32 read_blkbits;
|
||||||
u32 write_blkbits;
|
u32 write_blkbits;
|
||||||
u32 capacity;
|
u32 capacity;
|
||||||
|
u8 write_protect;
|
||||||
} mmc_csd_t;
|
} mmc_csd_t;
|
||||||
|
|
||||||
typedef struct _mmc_ext_csd
|
typedef struct _mmc_ext_csd
|
||||||
|
|
Loading…
Reference in a new issue