From 81e97fa8208bf5ca3a4a69ae659dc7223e03c575 Mon Sep 17 00:00:00 2001 From: "Such Meme, Many Skill" Date: Sun, 22 Dec 2019 12:10:59 +0100 Subject: [PATCH] Mount other emmc parts --- source/libs/fatfs/diskio.c | 5 ++++- source/main.c | 2 +- source/tegraexplorer/fs.c | 4 ++++ source/tegraexplorer/te.c | 42 +++++++++++++++++++++++------------- source/tegraexplorer/te.h | 3 ++- source/tegraexplorer/tools.c | 1 + 6 files changed, 39 insertions(+), 18 deletions(-) diff --git a/source/libs/fatfs/diskio.c b/source/libs/fatfs/diskio.c index 46c7c09..c0e70c9 100644 --- a/source/libs/fatfs/diskio.c +++ b/source/libs/fatfs/diskio.c @@ -151,7 +151,7 @@ DRESULT disk_read ( __attribute__ ((aligned (16))) static u64 prev_cluster = -1; __attribute__ ((aligned (16))) static u32 prev_sector = 0; bool needs_cache_sector = false; - + /* if (secindex == 0 || clear_sector_cache) { if (!sector_cache) sector_cache = (sector_cache_t *)malloc(sizeof(sector_cache_t) * MAX_SEC_CACHE_ENTRIES); @@ -179,6 +179,7 @@ DRESULT disk_read ( secindex++; } } + */ //system_part (pdrv == 1) ? system_part_sys : system_part_usr if (nx_emmc_part_read(&storage, system_part, sector, count, buff)) { u32 tweak_exp = 0; @@ -195,10 +196,12 @@ DRESULT disk_read ( // fatfs will never pull more than a cluster _emmc_xts(9, 8, 0, tweak, regen_tweak, tweak_exp, prev_cluster, buff, buff, count * 0x200); + /* if (needs_cache_sector) { memcpy(sector_cache[s].cached_sector, buff, 0x200); memcpy(sector_cache[s].tweak, tweak, 0x10); } + */ prev_sector = sector + count - 1; return RES_OK; } diff --git a/source/main.c b/source/main.c index 7f46e84..298f18a 100644 --- a/source/main.c +++ b/source/main.c @@ -54,7 +54,7 @@ bool return_sd_mounted(int value){ switch(value){ case 1: return sd_mounted; - case 5: + case 7: return sd_inited; } } diff --git a/source/tegraexplorer/fs.c b/source/tegraexplorer/fs.c index cf17197..119c3b5 100644 --- a/source/tegraexplorer/fs.c +++ b/source/tegraexplorer/fs.c @@ -320,6 +320,10 @@ int delfile(const char *path, const char *filename){ void filemenu(const char *startpath){ int amount, res, tempint; char temp[100]; + + if (!strcmp(rootpath, "emmc:/") && !strcmp(startpath, "emmc:/")) + clipboardhelper = 0; + strcpy(rootpath, startpath); writecurpath(startpath); amount = readfolder(currentpath); diff --git a/source/tegraexplorer/te.c b/source/tegraexplorer/te.c index 9628411..6275943 100644 --- a/source/tegraexplorer/te.c +++ b/source/tegraexplorer/te.c @@ -14,8 +14,10 @@ extern bool return_sd_mounted(int value); extern int launch_payload(char *path); menu_item mainmenu[MAINMENU_AMOUNT] = { - {"[SD:/] SD CARD", COLOR_GREEN, SD_CARD, 1}, - {"[SYSTEM:/] EMMC", COLOR_GREEN, EMMC_SYS, 1}, + {"[SD:/] SD CARD\n", COLOR_GREEN, SD_CARD, 1}, + {"[SYSTEM:/] EMMC", COLOR_ORANGE, EMMC_SYS, 1}, + {"[USER:/] EMMC", COLOR_ORANGE, EMMC_USR, 1}, + {"[SAFE:/] EMMC", COLOR_ORANGE, EMMC_SAF, 1}, {"\nMount/Unmount SD", COLOR_WHITE, MOUNT_SD, 1}, {"Tools", COLOR_VIOLET, TOOLS, 1}, {"SD format", COLOR_VIOLET, SD_FORMAT, 1}, @@ -48,19 +50,25 @@ menu_item formatmenu[4] = { {"Format for EmuMMC setup (FAT32/RAW)", COLOR_RED, FORMAT_EMUMMC, 1} }; +const char emmc_entries[3][8] = { + "SAFE", + "SYSTEM", + "USER" +}; + void fillmainmenu(){ int i; for (i = 0; i < MAINMENU_AMOUNT; i++){ switch (i + 1) { case 1: - case 5: + case 7: if (return_sd_mounted(i + 1)) mainmenu[i].property = 1; else mainmenu[i].property = -1; break; - case 3: + case 5: if (return_sd_mounted(1)){ mainmenu[i].property = 2; strcpy(mainmenu[i].name, "\nUnmount SD"); @@ -80,9 +88,8 @@ void te_main(){ if (dump_biskeys() == -1){ message("Biskeys failed to dump!\nEmmc will not be mounted!", COLOR_RED); mainmenu[1].property = -1; - } - else { - mount_emmc("SYSTEM", 2); + mainmenu[2].property = -1; + mainmenu[3].property = -1; } while (1){ @@ -93,16 +100,21 @@ void te_main(){ case SD_CARD: filemenu("SD:/"); break; + + case EMMC_SAF: case EMMC_SYS: - if (makewaitmenu("You're about to enter EMMC\nModifying anything here\n can result in a BRICK!\n\nPlease only continue\n if you know what you're doing\n\nPress Vol+/- to return\n", "Press Power to enter", 4)) - filemenu("emmc:/"); - break; - /* case EMMC_USR: - mount_emmc("USER", 2); - filemenu("emmc:/"); - break; - */ + + if (makewaitmenu("You're about to enter EMMC\nModifying anything here\n can result in a BRICK!\n\nPlease only continue\n if you know what you're doing\n\nPress Vol+/- to return\n", "Press Power to enter", 4)){ + if (!mount_emmc(emmc_entries[res - 2], res - 1)){ + filemenu("emmc:/"); + } + else + message("EMMC failed to mount!", COLOR_RED); + } + + break; + case MOUNT_SD: if (return_sd_mounted(1)) sd_unmount(); diff --git a/source/tegraexplorer/te.h b/source/tegraexplorer/te.h index e107de6..39fc92b 100644 --- a/source/tegraexplorer/te.h +++ b/source/tegraexplorer/te.h @@ -1,7 +1,7 @@ #pragma once #include "../utils/types.h" -#define MAINMENU_AMOUNT 7 +#define MAINMENU_AMOUNT 9 #define CREDITS_MESSAGE "\nTegraexplorer, made by:\nSuch Meme, Many Skill\n\nProject based on:\nLockpick_RCM\nHekate\n\nCool people:\nshchmue\ndennthecafebabe\nDax" typedef struct _menu_item { @@ -13,6 +13,7 @@ typedef struct _menu_item { enum mainmenu_return { SD_CARD = 1, + EMMC_SAF, EMMC_SYS, EMMC_USR, MOUNT_SD, diff --git a/source/tegraexplorer/tools.c b/source/tegraexplorer/tools.c index e9679a3..bda3463 100644 --- a/source/tegraexplorer/tools.c +++ b/source/tegraexplorer/tools.c @@ -97,6 +97,7 @@ int dumpfirmware(){ u32 timer = get_tmr_s(); clearscreen(); + mount_emmc("SYSTEM", 2); gfx_printf("PKG1 version: %d\n", pkg1ver);