mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-22 11:56:42 +00:00
Get a basic gpt menu
This commit is contained in:
parent
ee145ca9aa
commit
f93cc0ff44
10 changed files with 209 additions and 41 deletions
|
@ -104,4 +104,8 @@ enum fs_menu_startdir_return {
|
|||
FILEMENU_CURFOLDER
|
||||
};
|
||||
|
||||
extern menu_entry fs_menu_startdir[];
|
||||
extern menu_entry fs_menu_startdir[];
|
||||
|
||||
extern gpt_entry_rule gpt_fs_rules[];
|
||||
|
||||
extern menu_entry mmcmenu_start[];
|
|
@ -2,13 +2,9 @@
|
|||
#include "types.h"
|
||||
|
||||
menu_entry mainmenu_main[] = {
|
||||
{"[SD:/] SD CARD\n", COLOR_GREEN, ISMENU},
|
||||
{"[SAFE:/] EMMC", COLOR_ORANGE, ISMENU},
|
||||
{"[SYSTEM:/] EMMC", COLOR_ORANGE, ISMENU},
|
||||
{"[USER:/] EMMC", COLOR_ORANGE, ISMENU},
|
||||
{"\n[SAFE:/] EMUMMC", COLOR_BLUE, ISMENU},
|
||||
{"[SYSTEM:/] EMUMMC", COLOR_BLUE, ISMENU},
|
||||
{"[USER:/] EMUMMC", COLOR_BLUE, ISMENU},
|
||||
{"[SD:/] SD CARD", COLOR_GREEN, ISMENU},
|
||||
{"[EMMC:/] EMMC", COLOR_ORANGE, ISMENU},
|
||||
{"[EMMC:/] EMUMMC", COLOR_BLUE, ISMENU},
|
||||
{"\nMount/Unmount SD", COLOR_WHITE, ISMENU},
|
||||
{"Tools", COLOR_VIOLET, ISMENU},
|
||||
{"SD format", COLOR_VIOLET, ISMENU},
|
||||
|
@ -73,4 +69,17 @@ menu_entry fs_menu_startdir[] = {
|
|||
{"Folder -> previous folder ", COLOR_ORANGE, ISMENU},
|
||||
{"Clipboard -> Current folder ", COLOR_ORANGE, ISMENU},
|
||||
{"Current folder menu ", COLOR_ORANGE, ISMENU}
|
||||
};
|
||||
|
||||
gpt_entry_rule gpt_fs_rules[] = {
|
||||
{"PRODINFOF", 0 | isFS},
|
||||
{"SAFE", 1 | isFS },
|
||||
{"SYSTEM", 2 | isFS},
|
||||
{"USER", 3 | isFS},
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
menu_entry mmcmenu_start[] = {
|
||||
{"Back", COLOR_ORANGE, ISMENU},
|
||||
{"RESERVED\n", COLOR_ORANGE, ISMENU}
|
||||
};
|
|
@ -43,4 +43,11 @@ typedef struct {
|
|||
char *name;
|
||||
u32 storage;
|
||||
u16 property;
|
||||
} menu_entry;
|
||||
} menu_entry;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
u8 property;
|
||||
} gpt_entry_rule;
|
||||
|
||||
#define isFS 0x80
|
|
@ -22,13 +22,16 @@
|
|||
#include "../../config/config.h"
|
||||
#include "../common/common.h"
|
||||
#include "../gfx/gfxutils.h"
|
||||
#include "../../utils/list.h"
|
||||
#include "../../mem/heap.h"
|
||||
|
||||
sdmmc_storage_t storage;
|
||||
emmc_part_t *system_part;
|
||||
sdmmc_t sdmmc;
|
||||
extern hekate_config h_cfg;
|
||||
__attribute__ ((aligned (16))) FATFS emmc;
|
||||
LIST_INIT(gpt);
|
||||
LIST_INIT(sys_gpt);
|
||||
LIST_INIT(emu_gpt);
|
||||
|
||||
u8 bis_key[4][32];
|
||||
pkg1_info pkg1inf = {-1, ""};
|
||||
|
@ -64,7 +67,7 @@ pkg1_info returnpkg1info(){
|
|||
int connect_part(const char *partition){
|
||||
sdmmc_storage_set_mmc_partition(&storage, 0);
|
||||
|
||||
system_part = nx_emmc_part_find(&gpt, partition);
|
||||
system_part = nx_emmc_part_find(selectGpt(currentlyMounted), partition);
|
||||
if (!system_part) {
|
||||
gfx_errDisplay("connect_mmc_part", ERR_PART_NOT_FOUND, 0);
|
||||
return 1;
|
||||
|
@ -213,8 +216,7 @@ int dump_biskeys(){
|
|||
}
|
||||
|
||||
sdmmc_storage_set_mmc_partition(&storage, 0);
|
||||
// Parse eMMC GPT.
|
||||
nx_emmc_gpt_parse(&gpt, &storage);
|
||||
nx_emmc_gpt_parse(&sys_gpt, &storage);
|
||||
|
||||
se_aes_key_set(8, bis_key[2] + 0x00, 0x10);
|
||||
se_aes_key_set(9, bis_key[2] + 0x10, 0x10);
|
||||
|
@ -222,4 +224,20 @@ int dump_biskeys(){
|
|||
pkg1inf.ver = pkg1_id->kb;
|
||||
strcpy(pkg1inf.id, pkg1_id->id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dumpEmuGpt(){
|
||||
connect_mmc(EMUMMC);
|
||||
sdmmc_storage_set_mmc_partition(&storage, 0);
|
||||
nx_emmc_gpt_parse(&emu_gpt, &storage);
|
||||
}
|
||||
|
||||
link_t *selectGpt(short mmcType){
|
||||
switch(mmcType){
|
||||
case SYSMMC:
|
||||
return &sys_gpt;
|
||||
case EMUMMC:
|
||||
return &emu_gpt;
|
||||
}
|
||||
return NULL;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include "../../utils/types.h"
|
||||
#include "../../utils/list.h"
|
||||
|
||||
typedef struct _pkg1_info {
|
||||
short ver;
|
||||
|
@ -15,6 +16,8 @@ int mount_mmc(const char *partition, const int biskeynumb);
|
|||
void connect_mmc(short mmctype);
|
||||
void disconnect_mmc();
|
||||
int connect_part(const char *partition);
|
||||
void dumpEmuGpt();
|
||||
link_t *selectGpt(short mmcType);
|
||||
|
||||
static const u8 zeros[0x10] = {0};
|
||||
|
||||
|
|
118
source/tegraexplorer/emmc/emmcmenu.c
Normal file
118
source/tegraexplorer/emmc/emmcmenu.c
Normal file
|
@ -0,0 +1,118 @@
|
|||
#include <string.h>
|
||||
#include "emmc.h"
|
||||
#include "../../mem/heap.h"
|
||||
#include "../../utils/types.h"
|
||||
#include "../../libs/fatfs/ff.h"
|
||||
#include "../../utils/sprintf.h"
|
||||
#include "../../utils/btn.h"
|
||||
#include "../../gfx/gfx.h"
|
||||
#include "../../utils/util.h"
|
||||
#include "../../hos/pkg1.h"
|
||||
#include "../../storage/sdmmc.h"
|
||||
#include "../../storage/nx_emmc.h"
|
||||
#include "../../sec/tsec.h"
|
||||
#include "../../soc/t210.h"
|
||||
#include "../../soc/fuse.h"
|
||||
#include "../../mem/mc.h"
|
||||
#include "../../sec/se.h"
|
||||
#include "../../soc/hw_init.h"
|
||||
#include "../../mem/emc.h"
|
||||
#include "../../mem/sdram.h"
|
||||
#include "../../storage/emummc.h"
|
||||
#include "../../config/config.h"
|
||||
#include "../common/common.h"
|
||||
#include "../gfx/gfxutils.h"
|
||||
#include "../../utils/list.h"
|
||||
#include "../../mem/heap.h"
|
||||
#include "emmcmenu.h"
|
||||
#include "../fs/fsreader.h"
|
||||
#include "../utils/utils.h"
|
||||
#include "../gfx/menu.h"
|
||||
#include "../fs/fsmenu.h"
|
||||
|
||||
menu_entry *mmcMenuEntries = NULL;
|
||||
|
||||
int checkGptRules(char *in){
|
||||
for (int i = 0; gpt_fs_rules[i].name != NULL; i++){
|
||||
if (!strcmp(in, gpt_fs_rules[i].name))
|
||||
return gpt_fs_rules[i].property;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void addEntry(emmc_part_t *part, u8 property, int spot){
|
||||
if (mmcMenuEntries[spot].name != NULL){
|
||||
free(mmcMenuEntries[spot].name);
|
||||
}
|
||||
|
||||
utils_copystring(part->name, &mmcMenuEntries[spot].name);
|
||||
|
||||
if (property & isFS){
|
||||
mmcMenuEntries[spot].storage = (u32)(property & 0x7F);
|
||||
mmcMenuEntries[spot].property = ISDIR;
|
||||
}
|
||||
else {
|
||||
u64 size = 0;
|
||||
int sizes = 0;
|
||||
mmcMenuEntries[spot].property = 0;
|
||||
size = (part->lba_end + 1 - part->lba_start) * NX_EMMC_BLOCKSIZE;
|
||||
|
||||
while (size > 1024){
|
||||
size /= 1024;
|
||||
sizes++;
|
||||
}
|
||||
|
||||
if (sizes > 3)
|
||||
sizes = 0;
|
||||
|
||||
mmcMenuEntries[spot].property |= (1 << (4 + sizes));
|
||||
mmcMenuEntries[spot].storage = (u32)size;
|
||||
}
|
||||
}
|
||||
|
||||
int fillMmcMenu(short mmcType){
|
||||
int count = 2, i;
|
||||
|
||||
if (mmcMenuEntries != NULL)
|
||||
clearfileobjects(&mmcMenuEntries);
|
||||
|
||||
link_t *gpt = selectGpt(mmcType);
|
||||
|
||||
LIST_FOREACH_ENTRY(emmc_part_t, part, gpt, link)
|
||||
count++;
|
||||
|
||||
createfileobjects(count, &mmcMenuEntries);
|
||||
|
||||
for (i = 0; i < 2; i++){
|
||||
utils_copystring(mmcmenu_start[i].name, &mmcMenuEntries[i].name);
|
||||
mmcMenuEntries[i].property = mmcmenu_start[i].property;
|
||||
mmcMenuEntries[i].storage = mmcmenu_start[i].storage;
|
||||
}
|
||||
|
||||
LIST_FOREACH_ENTRY(emmc_part_t, part, gpt, link){
|
||||
addEntry(part, checkGptRules(part->name), i++);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int makeMmcMenu(short mmcType){
|
||||
int count, selection;
|
||||
count = fillMmcMenu(mmcType);
|
||||
connect_mmc(mmcType);
|
||||
while (1){
|
||||
selection = menu_make(mmcMenuEntries, count, (mmcType == SYSMMC) ? "-- SYSMMC --" : "-- EMUMMC --");
|
||||
|
||||
switch(selection){
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
break; //stubbed
|
||||
default:
|
||||
if (mmcMenuEntries[selection].property & ISDIR){
|
||||
if (!mount_mmc(mmcMenuEntries[selection].name, mmcMenuEntries[selection].storage))
|
||||
fileexplorer("emmc:/", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3
source/tegraexplorer/emmc/emmcmenu.h
Normal file
3
source/tegraexplorer/emmc/emmcmenu.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
int makeMmcMenu(short mmcType);
|
|
@ -29,20 +29,20 @@ void fsreader_writeclipboard(const char *in, u8 args){
|
|||
utils_copystring(in, &clipboard);
|
||||
}
|
||||
|
||||
void clearfileobjects(){
|
||||
if (fsreader_files != NULL){
|
||||
for (int i = 0; fsreader_files[i].name != NULL; i++){
|
||||
free(fsreader_files[i].name);
|
||||
fsreader_files[i].name = NULL;
|
||||
void clearfileobjects(menu_entry **menu){
|
||||
if ((*menu) != NULL){
|
||||
for (int i = 0; (*menu)[i].name != NULL; i++){
|
||||
free((*menu)[i].name);
|
||||
(*menu)[i].name = NULL;
|
||||
}
|
||||
free(fsreader_files);
|
||||
fsreader_files = NULL;
|
||||
free((*menu));
|
||||
(*menu) = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void createfileobjects(int size){
|
||||
fsreader_files = calloc (size + 1, sizeof(menu_entry));
|
||||
fsreader_files[size].name = NULL;
|
||||
void createfileobjects(int size, menu_entry **menu){
|
||||
(*menu) = calloc (size + 1, sizeof(menu_entry));
|
||||
(*menu)[size].name = NULL;
|
||||
}
|
||||
|
||||
void addobject(char* name, int spot, u8 attribs){
|
||||
|
@ -83,8 +83,8 @@ int fsreader_readfolder(const char *path){
|
|||
FILINFO fno;
|
||||
int folderamount, res;
|
||||
|
||||
clearfileobjects();
|
||||
createfileobjects(fsutil_getfolderentryamount(path) + 3);
|
||||
clearfileobjects(&fsreader_files);
|
||||
createfileobjects(fsutil_getfolderentryamount(path) + 3, &fsreader_files);
|
||||
|
||||
for (folderamount = 0; folderamount < 3; folderamount++){
|
||||
utils_copystring(fs_menu_startdir[folderamount].name, &(fsreader_files[folderamount].name));
|
||||
|
|
|
@ -4,4 +4,7 @@
|
|||
extern menu_entry *fsreader_files;
|
||||
void fsreader_writecurpath(const char *in);
|
||||
void fsreader_writeclipboard(const char *in, u8 args);
|
||||
int fsreader_readfolder(const char *path);
|
||||
int fsreader_readfolder(const char *path);
|
||||
|
||||
void createfileobjects(int size, menu_entry **menu);
|
||||
void clearfileobjects(menu_entry **menu);
|
|
@ -16,6 +16,7 @@
|
|||
#include "fs/fsutils.h"
|
||||
#include "fs/fsmenu.h"
|
||||
#include "emmc/emmcoperations.h"
|
||||
#include "emmc/emmcmenu.h"
|
||||
|
||||
extern bool sd_mount();
|
||||
extern void sd_unmount();
|
||||
|
@ -33,18 +34,24 @@ void MainMenu_EMMC(){
|
|||
gfx_clearscreen();
|
||||
gfx_printf("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");
|
||||
if (gfx_makewaitmenu("Press Power to enter", 4)){
|
||||
/*
|
||||
connect_mmc(SYSMMC);
|
||||
|
||||
if (!mount_mmc(emmc_fs_entries[res - 2], res - 1))
|
||||
fileexplorer("emmc:/", 1);
|
||||
*/
|
||||
makeMmcMenu(SYSMMC);
|
||||
}
|
||||
}
|
||||
|
||||
void MainMenu_EMUMMC(){
|
||||
/*
|
||||
connect_mmc(EMUMMC);
|
||||
|
||||
if (!mount_mmc(emmc_fs_entries[res - 5], res - 4))
|
||||
fileexplorer("emmc:/", 1);
|
||||
fileexplorer("emmc:/", 1);
|
||||
*/
|
||||
makeMmcMenu(EMUMMC);
|
||||
}
|
||||
|
||||
void MainMenu_MountSD(){
|
||||
|
@ -61,6 +68,7 @@ void MainMenu_Tools(){
|
|||
break;
|
||||
case TOOLS_DISPLAY_GPIO:
|
||||
displaygpio();
|
||||
//makeMmcMenu(SYSMMC);
|
||||
break;
|
||||
case TOOLS_DUMPFIRMWARE:
|
||||
dumpfirmware(SYSMMC);
|
||||
|
@ -130,10 +138,6 @@ void MainMenu_Exit(){
|
|||
func_void_ptr mainmenu_functions[] = {
|
||||
MainMenu_SDCard,
|
||||
MainMenu_EMMC,
|
||||
MainMenu_EMMC,
|
||||
MainMenu_EMMC,
|
||||
MainMenu_EMUMMC,
|
||||
MainMenu_EMUMMC,
|
||||
MainMenu_EMUMMC,
|
||||
MainMenu_MountSD,
|
||||
MainMenu_Tools,
|
||||
|
@ -143,7 +147,7 @@ func_void_ptr mainmenu_functions[] = {
|
|||
};
|
||||
|
||||
void RunMenuOption(int option){
|
||||
if (option != 11)
|
||||
if (option != 7)
|
||||
meter = 0;
|
||||
if (option > 0)
|
||||
mainmenu_functions[option - 1]();
|
||||
|
@ -153,14 +157,14 @@ void te_main(){
|
|||
|
||||
if (dump_biskeys() == -1){
|
||||
gfx_errDisplay("dump_biskey", ERR_BISKEY_DUMP_FAILED, 0);
|
||||
for (int i = 1; i <= 3; i++)
|
||||
mainmenu_main[i].property |= ISHIDE;
|
||||
mainmenu_main[1].property |= ISHIDE;
|
||||
}
|
||||
|
||||
if (emummc_load_cfg()){
|
||||
for (int i = 4; i <= 6; i++)
|
||||
mainmenu_main[i].property |= ISHIDE;
|
||||
mainmenu_main[2].property |= ISHIDE;
|
||||
}
|
||||
else
|
||||
dumpEmuGpt();
|
||||
|
||||
disconnect_mmc();
|
||||
|
||||
|
@ -170,17 +174,16 @@ void te_main(){
|
|||
setter = sd_mounted;
|
||||
|
||||
if (emu_cfg.enabled){
|
||||
for (int i = 4; i <= 6; i++)
|
||||
SETBIT(mainmenu_main[i].property, ISHIDE, !setter);
|
||||
SETBIT(mainmenu_main[2].property, ISHIDE, !setter);
|
||||
}
|
||||
|
||||
SETBIT(mainmenu_main[0].property, ISHIDE, !setter);
|
||||
mainmenu_main[7].name = (menu_sd_states[!setter]);
|
||||
mainmenu_main[3].name = (menu_sd_states[!setter]);
|
||||
|
||||
setter = sd_inited;
|
||||
SETBIT(mainmenu_main[9].property, ISHIDE, !setter);
|
||||
SETBIT(mainmenu_main[5].property, ISHIDE, !setter);
|
||||
|
||||
res = menu_make(mainmenu_main, 12, "-- Main Menu --") + 1;
|
||||
res = menu_make(mainmenu_main, 8, "-- Main Menu --") + 1;
|
||||
RunMenuOption(res);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue