Show EMMC/EMUMMC GPT

This commit is contained in:
suchmememanyskill
2020-12-27 23:33:23 +01:00
parent 3307e975c9
commit 859ad2cc4c
7 changed files with 157 additions and 36 deletions

View File

@@ -6,6 +6,9 @@
#include <sec/se.h>
#include <libs/fatfs/ff.h>
#include "nx_emmc_bis.h"
#include "../config.h"
extern hekate_config h_cfg;
void SetKeySlots(){
if (TConf.keysDumped){
@@ -39,31 +42,45 @@ int connectMMC(u8 mmcType){
return 0;
disconnectMMC();
emu_cfg.enabled = (mmcType == MMC_CONN_EMMC) ? 0 : 1;
h_cfg.emummc_force_disable = (mmcType == MMC_CONN_EMMC) ? 1 : 0;
int res = emummc_storage_init_mmc(&emmc_storage, &emmc_sdmmc);
if (!res)
if (!res){
TConf.currentMMCConnected = mmcType;
emummc_storage_set_mmc_partition(&emmc_storage, 0);
nx_emmc_gpt_parse(&curGpt, &emmc_storage);
}
return res; // deal with the errors later lol
}
ErrCode_t mountMMCPart(const char *partition){
if (TConf.connectedMMCMounted)
return newErrCode(0);
if (!TConf.connectedMMCMounted){
emummc_storage_set_mmc_partition(&emmc_storage, 0); // why i have to do this twice beats me
emmc_part_t *system_part = nx_emmc_part_find(&curGpt, partition);
if (!system_part)
return newErrCode(TE_ERR_PARTITION_NOT_FOUND);
nx_emmc_bis_init(system_part);
emummc_storage_set_mmc_partition(&emmc_storage, 0);
nx_emmc_gpt_parse(&curGpt, &emmc_storage);
emmc_part_t *system_part = nx_emmc_part_find(&curGpt, partition);
if (!system_part)
return newErrCode(TE_ERR_PARTITION_NOT_FOUND);
nx_emmc_bis_init(system_part);
int res = 0;
if ((res = f_mount(&emmc_fs, "bis:", 1)))
return newErrCode(res);
int res = 0;
if ((res = f_mount(&emmc_fs, "bis:", 1)))
return newErrCode(res);
TConf.connectedMMCMounted = 1;
}
TConf.connectedMMCMounted = 1;
return newErrCode(0);
}
link_t *GetCurGPT(){
if (TConf.currentMMCConnected != MMC_CONN_None)
return &curGpt;
return NULL;
}
void unmountMMCPart(){
if (TConf.connectedMMCMounted)
f_unmount("bis:");
TConf.connectedMMCMounted = 0;
}