From 3c2d86ef7b970d7a6942819c7ea8ae9ecf419afe Mon Sep 17 00:00:00 2001 From: CTCaer Date: Fri, 17 Jul 2020 17:01:40 +0300 Subject: [PATCH] sdmmc: Add protected area info (Content Protection) --- bdk/storage/sdmmc.c | 2 ++ bdk/storage/sdmmc.h | 1 + nyx/nyx_gui/frontend/gui_info.c | 8 +++++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bdk/storage/sdmmc.c b/bdk/storage/sdmmc.c index fc41458..e252a94 100644 --- a/bdk/storage/sdmmc.c +++ b/bdk/storage/sdmmc.c @@ -1030,6 +1030,8 @@ static void _sd_storage_parse_ssr(sdmmc_storage_t *storage) 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; + storage->ssr.protected_size = unstuff_bits(raw_ssr1, 448 - 384, 32); + switch(unstuff_bits(raw_ssr1, 440 - 384, 8)) { case 0: diff --git a/bdk/storage/sdmmc.h b/bdk/storage/sdmmc.h index 6bfad77..28b1c09 100644 --- a/bdk/storage/sdmmc.h +++ b/bdk/storage/sdmmc.h @@ -92,6 +92,7 @@ typedef struct _sd_ssr u8 uhs_grade; u8 video_class; u8 app_class; + u32 protected_size; } sd_ssr_t; /*! SDMMC storage context. */ diff --git a/nyx/nyx_gui/frontend/gui_info.c b/nyx/nyx_gui/frontend/gui_info.c index 61a67d8..0768b00 100644 --- a/nyx/nyx_gui/frontend/gui_info.c +++ b/nyx/nyx_gui/frontend/gui_info.c @@ -1327,12 +1327,14 @@ static lv_res_t _create_window_sdcard_info_status(lv_obj_t *btn) lv_obj_t * lb_val2 = lv_label_create(val2, lb_desc); s_printf(txt_buf, - "#00DDFF v%d.0#\n%02X\n%d MiB\n%X\n%d\n%d MB/s (%d MHz)\n%d\nU%d\nV%d\nA%d\n%d", - sd_storage.csd.structure + 1, sd_storage.csd.cmdclass, sd_storage.sec_cnt >> 11, sd_storage.sec_cnt, + "#00DDFF v%d.0#\n%02X\n%d MiB\n%X (CP %X)\n%d\n%d MB/s (%d MHz)\n%d\nU%d\nV%d\nA%d\n%d", + sd_storage.csd.structure + 1, sd_storage.csd.cmdclass, + sd_storage.sec_cnt >> 11, sd_storage.sec_cnt, sd_storage.ssr.protected_size >> 9, sd_storage.ssr.bus_width, sd_storage.csd.busspeed, (sd_storage.csd.busspeed > 10) ? (sd_storage.csd.busspeed * 2) : 50, 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.app_class, + sd_storage.csd.write_protect); lv_label_set_text(lb_val2, txt_buf);