Add emummc support
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "../soc/hw_init.h"
|
||||
#include "../mem/emc.h"
|
||||
#include "../mem/sdram.h"
|
||||
#include "../storage/emummc.h"
|
||||
|
||||
sdmmc_storage_t storage;
|
||||
emmc_part_t *system_part;
|
||||
@@ -29,6 +30,8 @@ LIST_INIT(gpt);
|
||||
|
||||
u8 bis_key[4][32];
|
||||
short pkg1ver = -1;
|
||||
short currentlyMounted = -1;
|
||||
|
||||
|
||||
static bool _key_exists(const void *data) { return memcmp(data, zeros, 0x10); };
|
||||
|
||||
@@ -52,7 +55,11 @@ void print_biskeys(){
|
||||
gfx_hexdump(0, bis_key[2], 32);
|
||||
}
|
||||
|
||||
int mount_emmc(char *partition, int biskeynumb){
|
||||
short returnpkg1ver(){
|
||||
return pkg1ver;
|
||||
}
|
||||
|
||||
int mount_mmc(char *partition, int biskeynumb){
|
||||
f_unmount("emmc:");
|
||||
|
||||
se_aes_key_set(8, bis_key[biskeynumb] + 0x00, 0x10);
|
||||
@@ -72,13 +79,36 @@ int mount_emmc(char *partition, int biskeynumb){
|
||||
return 0;
|
||||
}
|
||||
|
||||
short returnpkg1ver(){
|
||||
return pkg1ver;
|
||||
void connect_mmc(short mmctype){
|
||||
if (mmctype != currentlyMounted){
|
||||
disconnect_mmc();
|
||||
switch (mmctype){
|
||||
case SYSMMC:
|
||||
sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4);
|
||||
emu_cfg.enabled = 0;
|
||||
currentlyMounted = SYSMMC;
|
||||
break;
|
||||
case EMUMMC:
|
||||
emummc_storage_init_mmc(&storage, &sdmmc);
|
||||
emu_cfg.enabled = 1;
|
||||
currentlyMounted = EMUMMC;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void disconnect_emmc(){
|
||||
void disconnect_mmc(){
|
||||
f_unmount("emmc:");
|
||||
sdmmc_storage_end(&storage);
|
||||
switch (currentlyMounted){
|
||||
case SYSMMC:
|
||||
sdmmc_storage_end(&storage);
|
||||
currentlyMounted = -1;
|
||||
break;
|
||||
case EMUMMC:
|
||||
emummc_storage_end(&storage);
|
||||
currentlyMounted = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int dump_biskeys(){
|
||||
@@ -87,7 +117,7 @@ int dump_biskeys(){
|
||||
|
||||
int retries = 0;
|
||||
|
||||
sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4);
|
||||
connect_mmc(SYSMMC);
|
||||
|
||||
// Read package1.
|
||||
u8 *pkg1 = (u8 *)malloc(0x40000);
|
||||
@@ -172,41 +202,10 @@ int dump_biskeys(){
|
||||
sdmmc_storage_set_mmc_partition(&storage, 0);
|
||||
// Parse eMMC GPT.
|
||||
nx_emmc_gpt_parse(&gpt, &storage);
|
||||
/*
|
||||
char part_name[37] = "SYSTEM";
|
||||
|
||||
// todo: menu selection for this
|
||||
|
||||
u32 bis_key_index = 0;
|
||||
if (strcmp(part_name, "PRODINFOF") == 0)
|
||||
bis_key_index = 0;
|
||||
else if (strcmp(part_name, "SAFE") == 0)
|
||||
bis_key_index = 1;
|
||||
else if (strcmp(part_name, "SYSTEM") == 0)
|
||||
bis_key_index = 2;
|
||||
else if (strcmp(part_name, "USER") == 0)
|
||||
bis_key_index = 3;
|
||||
else {
|
||||
gfx_printf("Partition name %s unrecognized.", part_name);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
se_aes_key_set(8, bis_key[2] + 0x00, 0x10);
|
||||
se_aes_key_set(9, bis_key[2] + 0x10, 0x10);
|
||||
|
||||
/*
|
||||
system_part = nx_emmc_part_find(&gpt, "SYSTEM");
|
||||
if (!system_part) {
|
||||
gfx_printf("Failed to locate SYSTEM partition.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (f_mount(&emmc_sys, "system:", 1)) {
|
||||
gfx_printf("Mount failed of SYSTEM.");
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
|
||||
pkg1ver = pkg1_id->kb;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user