From 5442547a595c759262cb100c25a842ae95d7fd3b Mon Sep 17 00:00:00 2001 From: CTCaer Date: Wed, 29 Apr 2020 22:06:33 +0300 Subject: [PATCH] sdmmc v2: Name eMMC physical partitions --- bootloader/frontend/fe_emmc_tools.c | 4 ++-- bootloader/frontend/fe_info.c | 4 ++-- bootloader/frontend/fe_tools.c | 8 ++++---- bootloader/hos/hos.c | 4 ++-- bootloader/hos/secmon_exo.c | 2 +- bootloader/hos/sept.c | 2 +- bootloader/main.c | 2 +- nyx/nyx_gui/frontend/fe_emmc_tools.c | 4 ++-- nyx/nyx_gui/frontend/fe_emummc_tools.c | 4 ++-- nyx/nyx_gui/frontend/gui_info.c | 4 ++-- nyx/nyx_gui/frontend/gui_tools.c | 6 +++--- nyx/nyx_gui/hos/sept.c | 2 +- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/bootloader/frontend/fe_emmc_tools.c b/bootloader/frontend/fe_emmc_tools.c index 4af9a57..26a2c7e 100644 --- a/bootloader/frontend/fe_emmc_tools.c +++ b/bootloader/frontend/fe_emmc_tools.c @@ -525,7 +525,7 @@ static void _dump_emmc_selected(emmcPartType_t dumpType) if ((dumpType & PART_SYSTEM) || (dumpType & PART_USER) || (dumpType & PART_RAW)) { - sdmmc_storage_set_mmc_partition(&storage, 0); + sdmmc_storage_set_mmc_partition(&storage, EMMC_GPP); if ((dumpType & PART_SYSTEM) || (dumpType & PART_USER)) { @@ -873,7 +873,7 @@ static void _restore_emmc_selected(emmcPartType_t restoreType) if (restoreType & PART_GP_ALL) { - sdmmc_storage_set_mmc_partition(&storage, 0); + sdmmc_storage_set_mmc_partition(&storage, EMMC_GPP); LIST_INIT(gpt); nx_emmc_gpt_parse(&gpt, &storage); diff --git a/bootloader/frontend/fe_info.c b/bootloader/frontend/fe_info.c index 2832f1b..faa64f2 100644 --- a/bootloader/frontend/fe_info.c +++ b/bootloader/frontend/fe_info.c @@ -263,7 +263,7 @@ void print_mmc_info() gfx_put_small_sep(); gfx_printf("%kGPP (eMMC USER) partition table:%k\n", 0xFF00DDFF, 0xFFCCCCCC); - sdmmc_storage_set_mmc_partition(&storage, 0); + sdmmc_storage_set_mmc_partition(&storage, EMMC_GPP); LIST_INIT(gpt); nx_emmc_gpt_parse(&gpt, &storage); int gpp_idx = 0; @@ -350,7 +350,7 @@ void print_tsec_key() // Read package1. u8 *pkg1 = (u8 *)malloc(0x40000); - sdmmc_storage_set_mmc_partition(&storage, 1); + sdmmc_storage_set_mmc_partition(&storage, EMMC_BOOT0); sdmmc_storage_read(&storage, 0x100000 / NX_EMMC_BLOCKSIZE, 0x40000 / NX_EMMC_BLOCKSIZE, pkg1); sdmmc_storage_end(&storage); const pkg1_id_t *pkg1_id = pkg1_identify(pkg1); diff --git a/bootloader/frontend/fe_tools.c b/bootloader/frontend/fe_tools.c index c4c5e8c..ed87eb8 100644 --- a/bootloader/frontend/fe_tools.c +++ b/bootloader/frontend/fe_tools.c @@ -74,7 +74,7 @@ void dump_packages12() EPRINTF("Failed to init eMMC."); goto out_free; } - sdmmc_storage_set_mmc_partition(&storage, 1); + sdmmc_storage_set_mmc_partition(&storage, EMMC_BOOT0); // Read package1. sdmmc_storage_read(&storage, 0x100000 / NX_EMMC_BLOCKSIZE, 0x40000 / NX_EMMC_BLOCKSIZE, pkg1); @@ -169,7 +169,7 @@ void dump_packages12() } // Dump package2.1. - sdmmc_storage_set_mmc_partition(&storage, 0); + sdmmc_storage_set_mmc_partition(&storage, EMMC_GPP); // Parse eMMC GPT. LIST_INIT(gpt); nx_emmc_gpt_parse(&gpt, &storage); @@ -271,7 +271,7 @@ void _toggle_autorcm(bool enable) } u8 *tempbuf = (u8 *)malloc(0x200); - sdmmc_storage_set_mmc_partition(&storage, 1); + sdmmc_storage_set_mmc_partition(&storage, EMMC_BOOT0); int i, sect = 0; u8 corr_mod_byte0; @@ -344,7 +344,7 @@ void menu_autorcm() } u8 *tempbuf = (u8 *)malloc(0x200); - sdmmc_storage_set_mmc_partition(&storage, 1); + sdmmc_storage_set_mmc_partition(&storage, EMMC_BOOT0); sdmmc_storage_read(&storage, 0x200 / NX_EMMC_BLOCKSIZE, 1, tempbuf); if ((fuse_read_odm(4) & 3) != 3) diff --git a/bootloader/hos/hos.c b/bootloader/hos/hos.c index e615b96..827e9e2 100644 --- a/bootloader/hos/hos.c +++ b/bootloader/hos/hos.c @@ -346,7 +346,7 @@ static int _read_emmc_pkg1(launch_ctxt_t *ctxt) // Read package1. ctxt->pkg1 = (void *)malloc(0x40000); - emummc_storage_set_mmc_partition(&storage, 1); + emummc_storage_set_mmc_partition(&storage, EMMC_BOOT0); emummc_storage_read(&storage, 0x100000 / NX_EMMC_BLOCKSIZE, 0x40000 / NX_EMMC_BLOCKSIZE, ctxt->pkg1); ctxt->pkg1_id = pkg1_identify(ctxt->pkg1); if (!ctxt->pkg1_id) @@ -387,7 +387,7 @@ static u8 *_read_emmc_pkg2(launch_ctxt_t *ctxt) return NULL; } - emummc_storage_set_mmc_partition(&storage, 0); + emummc_storage_set_mmc_partition(&storage, EMMC_GPP); // Parse eMMC GPT. LIST_INIT(gpt); diff --git a/bootloader/hos/secmon_exo.c b/bootloader/hos/secmon_exo.c index 158a277..382e716 100644 --- a/bootloader/hos/secmon_exo.c +++ b/bootloader/hos/secmon_exo.c @@ -201,7 +201,7 @@ void config_exosphere(launch_ctxt_t *ctxt) u8 *rsa_mod = (u8 *)malloc(512); sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_BUS_WIDTH_8, SDHCI_TIMING_MMC_HS400); - sdmmc_storage_set_mmc_partition(&storage, 1); + sdmmc_storage_set_mmc_partition(&storage, EMMC_BOOT0); sdmmc_storage_read(&storage, 1, 1, rsa_mod); sdmmc_storage_end(&storage); diff --git a/bootloader/hos/sept.c b/bootloader/hos/sept.c index 5f2e33e..32dba0e 100644 --- a/bootloader/hos/sept.c +++ b/bootloader/hos/sept.c @@ -103,7 +103,7 @@ void check_sept(ini_sec_t *cfg_sec) goto out_free; } - emummc_storage_set_mmc_partition(&storage, 1); + emummc_storage_set_mmc_partition(&storage, EMMC_BOOT0); // Read package1. emummc_storage_read(&storage, 0x100000 / NX_EMMC_BLOCKSIZE, 0x40000 / NX_EMMC_BLOCKSIZE, pkg1); diff --git a/bootloader/main.c b/bootloader/main.c index fdc7674..94e21c4 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -1155,7 +1155,7 @@ static void _patched_rcm_protection() return; u8 *tempbuf = (u8 *)malloc(0x200); - sdmmc_storage_set_mmc_partition(&storage, 1); + sdmmc_storage_set_mmc_partition(&storage, EMMC_BOOT0); u8 corr_mod_byte0; int i, sect = 0; diff --git a/nyx/nyx_gui/frontend/fe_emmc_tools.c b/nyx/nyx_gui/frontend/fe_emmc_tools.c index c781b12..b8420d1 100644 --- a/nyx/nyx_gui/frontend/fe_emmc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emmc_tools.c @@ -791,7 +791,7 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui) if ((dumpType & PART_SYSTEM) || (dumpType & PART_USER) || (dumpType & PART_RAW)) { - sdmmc_storage_set_mmc_partition(&storage, 0); + sdmmc_storage_set_mmc_partition(&storage, EMMC_GPP); if ((dumpType & PART_SYSTEM) || (dumpType & PART_USER)) { @@ -1374,7 +1374,7 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui) gui->base_path = (char *)malloc(strlen(sdPath) + 1); strcpy(gui->base_path, sdPath); - sdmmc_storage_set_mmc_partition(&storage, 0); + sdmmc_storage_set_mmc_partition(&storage, EMMC_GPP); LIST_INIT(gpt); nx_emmc_gpt_parse(&gpt, &storage); diff --git a/nyx/nyx_gui/frontend/fe_emummc_tools.c b/nyx/nyx_gui/frontend/fe_emummc_tools.c index f50d83c..59c2bfe 100644 --- a/nyx/nyx_gui/frontend/fe_emummc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emummc_tools.c @@ -443,7 +443,7 @@ void dump_emummc_file(emmc_tool_gui_t *gui) } // Get GP partition size dynamically. - sdmmc_storage_set_mmc_partition(&storage, 0); + sdmmc_storage_set_mmc_partition(&storage, EMMC_GPP); // Get GP partition size dynamically. const u32 RAW_AREA_NUM_SECTORS = storage.sec_cnt; @@ -713,7 +713,7 @@ void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start) strcpy(sdPath, gui->base_path); } - sdmmc_storage_set_mmc_partition(&storage, 0); + sdmmc_storage_set_mmc_partition(&storage, EMMC_GPP); // Get GP partition size dynamically. const u32 RAW_AREA_NUM_SECTORS = storage.sec_cnt; diff --git a/nyx/nyx_gui/frontend/gui_info.c b/nyx/nyx_gui/frontend/gui_info.c index 8a94ccc..4e5ad02 100644 --- a/nyx/nyx_gui/frontend/gui_info.c +++ b/nyx/nyx_gui/frontend/gui_info.c @@ -436,7 +436,7 @@ static lv_res_t _create_window_tsec_keys_status(lv_obj_t *btn) char *build_date = malloc(32); u8 *pkg1 = (u8 *)malloc(0x40000); sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_BUS_WIDTH_8, SDHCI_TIMING_MMC_HS400); - sdmmc_storage_set_mmc_partition(&storage, 1); + sdmmc_storage_set_mmc_partition(&storage, EMMC_BOOT0); sdmmc_storage_read(&storage, 0x100000 / NX_EMMC_BLOCKSIZE, 0x40000 / NX_EMMC_BLOCKSIZE, pkg1); sdmmc_storage_end(&storage); const pkg1_id_t *pkg1_id = pkg1_identify(pkg1, build_date); @@ -653,7 +653,7 @@ static lv_res_t _create_window_emmc_info_status(lv_obj_t *btn) s_printf(txt_buf + strlen(txt_buf), "0: #96FF00 GPP# Size: %5d MiB (Sect: 0x%08X)\n\n", storage.sec_cnt >> SECTORS_TO_MIB_COEFF, storage.sec_cnt); s_printf(txt_buf + strlen(txt_buf), "#00DDFF GPP (eMMC USER) Partition Table:#\n"); - sdmmc_storage_set_mmc_partition(&storage, 0); + sdmmc_storage_set_mmc_partition(&storage, EMMC_GPP); LIST_INIT(gpt); nx_emmc_gpt_parse(&gpt, &storage); int gpp_idx = 0; diff --git a/nyx/nyx_gui/frontend/gui_tools.c b/nyx/nyx_gui/frontend/gui_tools.c index 0da1039..34c9aeb 100644 --- a/nyx/nyx_gui/frontend/gui_tools.c +++ b/nyx/nyx_gui/frontend/gui_tools.c @@ -51,7 +51,7 @@ bool get_autorcm_status(bool change) sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_BUS_WIDTH_8, SDHCI_TIMING_MMC_HS400); u8 *tempbuf = (u8 *)malloc(0x200); - sdmmc_storage_set_mmc_partition(&storage, 1); + sdmmc_storage_set_mmc_partition(&storage, EMMC_BOOT0); sdmmc_storage_read(&storage, 0x200 / NX_EMMC_BLOCKSIZE, 1, tempbuf); if ((fuse_read_odm(4) & 3) != 3) @@ -359,7 +359,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn) goto out_free; } - sdmmc_storage_set_mmc_partition(&storage, 1); + sdmmc_storage_set_mmc_partition(&storage, EMMC_BOOT0); // Read package1. char *build_date = malloc(32); @@ -477,7 +477,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn) } // Dump package2.1. - sdmmc_storage_set_mmc_partition(&storage, 0); + sdmmc_storage_set_mmc_partition(&storage, EMMC_GPP); // Parse eMMC GPT. LIST_INIT(gpt); nx_emmc_gpt_parse(&gpt, &storage); diff --git a/nyx/nyx_gui/hos/sept.c b/nyx/nyx_gui/hos/sept.c index 38feafb..175df11 100644 --- a/nyx/nyx_gui/hos/sept.c +++ b/nyx/nyx_gui/hos/sept.c @@ -93,7 +93,7 @@ void check_sept() EPRINTF("Failed to init eMMC."); goto out_free; } - sdmmc_storage_set_mmc_partition(&storage, 1); + sdmmc_storage_set_mmc_partition(&storage, EMMC_BOOT0); // Read package1. char *build_date = malloc(32);