mirror of
https://github.com/CTCaer/hekate.git
synced 2024-11-22 18:06:40 +00:00
Refactor emmcsn_path_impl and return serial number if needed
The refactoring also makes consecutive requests instantaneous.
This commit is contained in:
parent
8ce5d55eb8
commit
53b44a525d
6 changed files with 48 additions and 29 deletions
|
@ -45,7 +45,7 @@
|
|||
|
||||
extern nyx_config n_cfg;
|
||||
|
||||
extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
|
||||
extern char *emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
|
||||
|
||||
static void _get_valid_partition(u32 *sector_start, u32 *sector_size, u32 *part_idx, bool backup)
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
extern boot_cfg_t b_cfg;
|
||||
extern hekate_config h_cfg;
|
||||
|
||||
extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
|
||||
extern char *emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
|
||||
|
||||
lv_obj_t *ums_mbox;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <utils/sprintf.h>
|
||||
#include <utils/types.h>
|
||||
|
||||
extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
|
||||
extern char *emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
|
||||
|
||||
typedef struct _mbr_ctxt_t
|
||||
{
|
||||
|
|
|
@ -51,7 +51,7 @@ extern hekate_config h_cfg;
|
|||
extern volatile boot_cfg_t *b_cfg;
|
||||
extern volatile nyx_storage_t *nyx_str;
|
||||
|
||||
extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
|
||||
extern char *emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
|
||||
|
||||
static u8 *cal0_buf = NULL;
|
||||
|
||||
|
@ -71,7 +71,10 @@ static lv_res_t _create_window_dump_done(int error, char *dump_filenames)
|
|||
if (error)
|
||||
s_printf(txt_buf, "#FFDD00 Failed to dump to# %s#FFDD00 !#\nError: %d", dump_filenames, error);
|
||||
else
|
||||
s_printf(txt_buf, "Dumping to SD card finished!\nFiles: #C7EA46 backup/{emmc_sn}/dumps/#%s", dump_filenames);
|
||||
{
|
||||
char *sn = emmcsn_path_impl(NULL, NULL, NULL, NULL);
|
||||
s_printf(txt_buf, "Dumping to SD card finished!\nFiles: #C7EA46 backup/%s/dumps/#\n%s", sn, dump_filenames);
|
||||
}
|
||||
lv_mbox_set_text(mbox, txt_buf);
|
||||
|
||||
lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); // Important. After set_text.
|
||||
|
@ -223,7 +226,11 @@ static lv_res_t _fuse_dump_window_action(lv_obj_t * btn)
|
|||
|
||||
sd_unmount();
|
||||
}
|
||||
_create_window_dump_done(error, "fuse_cached.bin, fuse_array_raw.bin");
|
||||
|
||||
if (!h_cfg.t210b01)
|
||||
_create_window_dump_done(error, "fuse_cached_t210.bin, fuse_array_raw_t210.bin");
|
||||
else
|
||||
_create_window_dump_done(error, "fuse_cached_t210b01_partX.bin, fuse_array_raw_t210b01.bin");
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ extern volatile boot_cfg_t *b_cfg;
|
|||
extern hekate_config h_cfg;
|
||||
extern nyx_config n_cfg;
|
||||
|
||||
extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
|
||||
extern char *emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
|
||||
|
||||
static lv_obj_t *_create_container(lv_obj_t *parent)
|
||||
{
|
||||
|
|
|
@ -69,43 +69,55 @@ const volatile ipl_ver_meta_t __attribute__((section ("._ipl_version"))) ipl_ver
|
|||
volatile nyx_storage_t *nyx_str = (nyx_storage_t *)NYX_STORAGE_ADDR;
|
||||
volatile boot_cfg_t *b_cfg;
|
||||
|
||||
void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage)
|
||||
char *emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage)
|
||||
{
|
||||
sdmmc_storage_t storage2;
|
||||
sdmmc_t sdmmc;
|
||||
char emmcSN[9];
|
||||
bool init_done = false;
|
||||
static char emmc_sn[9] = {0};
|
||||
|
||||
memcpy(path, "backup", 7);
|
||||
f_mkdir(path);
|
||||
// Check if eMMC S/N storage has valid data and skip parsing in that case.
|
||||
if (emmc_sn[0] && strcmp(emmc_sn, "00000000"))
|
||||
goto create_dir;
|
||||
|
||||
// Get actual eMMC S/N.
|
||||
if (!storage)
|
||||
{
|
||||
sdmmc_t sdmmc;
|
||||
sdmmc_storage_t storage2;
|
||||
|
||||
if (!sdmmc_storage_init_mmc(&storage2, &sdmmc, SDMMC_BUS_WIDTH_8, SDHCI_TIMING_MMC_HS400))
|
||||
memcpy(emmcSN, "00000000", 9);
|
||||
strcpy(emmc_sn, "00000000");
|
||||
else
|
||||
{
|
||||
init_done = true;
|
||||
itoa(storage2.cid.serial, emmcSN, 16);
|
||||
itoa(storage2.cid.serial, emmc_sn, 16);
|
||||
sdmmc_storage_end(&storage2);
|
||||
}
|
||||
}
|
||||
else
|
||||
itoa(storage->cid.serial, emmcSN, 16);
|
||||
itoa(storage->cid.serial, emmc_sn, 16);
|
||||
|
||||
u32 sub_dir_len = strlen(sub_dir); // Can be a null-terminator.
|
||||
u32 filename_len = strlen(filename); // Can be a null-terminator.
|
||||
create_dir:
|
||||
// Check if only eMMC S/N was requested.
|
||||
if (!path)
|
||||
return emmc_sn;
|
||||
|
||||
memcpy(path + strlen(path), "/", 2);
|
||||
memcpy(path + strlen(path), emmcSN, 9);
|
||||
// Create main folder.
|
||||
strcpy(path, "backup");
|
||||
f_mkdir(path);
|
||||
memcpy(path + strlen(path), sub_dir, sub_dir_len + 1);
|
||||
if (sub_dir_len)
|
||||
f_mkdir(path);
|
||||
memcpy(path + strlen(path), "/", 2);
|
||||
memcpy(path + strlen(path), filename, filename_len + 1);
|
||||
|
||||
if (init_done)
|
||||
sdmmc_storage_end(&storage2);
|
||||
// Create eMMC S/N folder.
|
||||
strcat(path, "/");
|
||||
strcat(path, emmc_sn);
|
||||
f_mkdir(path);
|
||||
|
||||
// Create sub folder if defined. Dir slash must be included.
|
||||
strcat(path, sub_dir); // Can be a null-terminator.
|
||||
if (strlen(sub_dir))
|
||||
f_mkdir(path);
|
||||
|
||||
// Add filename.
|
||||
strcat(path, "/");
|
||||
strcat(path, filename); // Can be a null-terminator.
|
||||
|
||||
return emmc_sn;
|
||||
}
|
||||
|
||||
// This is a safe and unused DRAM region for our payloads.
|
||||
|
|
Loading…
Reference in a new issue