mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-22 20:06:43 +00:00
Show EMMC/EMUMMC GPT
This commit is contained in:
parent
3307e975c9
commit
859ad2cc4c
7 changed files with 157 additions and 36 deletions
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
MenuEntry_t topEntries[] = {
|
MenuEntry_t topEntries[] = {
|
||||||
{.optionUnion = COLORTORGB(COLOR_GREEN) | SKIPBIT},
|
{.optionUnion = COLORTORGB(COLOR_GREEN) | SKIPBIT},
|
||||||
{.optionUnion = COLORTORGB(COLOR_ORANGE), .name = "Back"},
|
{.optionUnion = COLORTORGB(COLOR_ORANGE)},
|
||||||
{.optionUnion = COLORTORGB(COLOR_GREY) | SKIPBIT, .name = "Clipboard -> Current folder"},
|
{.optionUnion = COLORTORGB(COLOR_GREY) | SKIPBIT, .name = "Clipboard -> Current folder"},
|
||||||
{.optionUnion = COLORTORGB(COLOR_GREY) | SKIPBIT, .name = "Current folder options"}
|
{.optionUnion = COLORTORGB(COLOR_GREY) | SKIPBIT, .name = "Current folder options"}
|
||||||
};
|
};
|
||||||
|
@ -44,6 +44,7 @@ void FileExplorer(char *path){
|
||||||
|
|
||||||
while (1){
|
while (1){
|
||||||
topEntries[2].optionUnion = (TConf.explorerCopyMode != CMODE_None) ? (COLORTORGB(COLOR_ORANGE)) : (COLORTORGB(COLOR_GREY) | SKIPBIT);
|
topEntries[2].optionUnion = (TConf.explorerCopyMode != CMODE_None) ? (COLORTORGB(COLOR_ORANGE)) : (COLORTORGB(COLOR_GREY) | SKIPBIT);
|
||||||
|
topEntries[1].name = (!strcmp(storedPath, path)) ? "<- Exit explorer" : "<- Folder back";
|
||||||
|
|
||||||
gfx_clearscreen();
|
gfx_clearscreen();
|
||||||
gfx_printf("Loading...\r");
|
gfx_printf("Loading...\r");
|
||||||
|
|
|
@ -18,9 +18,9 @@ MenuEntry_t FileMenuEntries[] = {
|
||||||
{.optionUnion = COLORTORGB(COLOR_VIOLET) | SKIPBIT}, // For the file Attribs
|
{.optionUnion = COLORTORGB(COLOR_VIOLET) | SKIPBIT}, // For the file Attribs
|
||||||
{.optionUnion = HIDEBIT},
|
{.optionUnion = HIDEBIT},
|
||||||
{.optionUnion = COLORTORGB(COLOR_WHITE), .name = "<- Back"},
|
{.optionUnion = COLORTORGB(COLOR_WHITE), .name = "<- Back"},
|
||||||
{.optionUnion = COLORTORGB(COLOR_BLUE), .name = "Copy to clipboard"},
|
{.optionUnion = COLORTORGB(COLOR_BLUE), .name = "\nCopy to clipboard"},
|
||||||
{.optionUnion = COLORTORGB(COLOR_BLUE), .name = "Move to clipboard"},
|
{.optionUnion = COLORTORGB(COLOR_BLUE), .name = "Move to clipboard"},
|
||||||
{.optionUnion = COLORTORGB(COLOR_BLUE), .name = "Rename file"},
|
{.optionUnion = COLORTORGB(COLOR_BLUE), .name = "Rename file\n"},
|
||||||
{.optionUnion = COLORTORGB(COLOR_RED), .name = "Delete file"},
|
{.optionUnion = COLORTORGB(COLOR_RED), .name = "Delete file"},
|
||||||
{.optionUnion = COLORTORGB(COLOR_GREEN), .name = "View hex"},
|
{.optionUnion = COLORTORGB(COLOR_GREEN), .name = "View hex"},
|
||||||
{.optionUnion = COLORTORGB(COLOR_ORANGE), .name = "Launch Payload"},
|
{.optionUnion = COLORTORGB(COLOR_ORANGE), .name = "Launch Payload"},
|
||||||
|
@ -56,7 +56,7 @@ MenuEntry_t DeleteEntries[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
void DeleteFile(char *path, FSEntry_t entry){
|
void DeleteFile(char *path, FSEntry_t entry){
|
||||||
gfx_con_setpos(384 + 16, 200 + 16 + 8 * 16);
|
gfx_con_setpos(384 + 16, 200 + 16 + 10 * 16);
|
||||||
SETCOLOR(COLOR_RED, COLOR_DARKGREY);
|
SETCOLOR(COLOR_RED, COLOR_DARKGREY);
|
||||||
gfx_printf("Are you sure? ");
|
gfx_printf("Are you sure? ");
|
||||||
|
|
||||||
|
@ -82,10 +82,10 @@ menuPaths FileMenuPaths[] = {
|
||||||
|
|
||||||
void FileMenu(char *path, FSEntry_t entry){
|
void FileMenu(char *path, FSEntry_t entry){
|
||||||
FileMenuEntries[1].name = entry.name;
|
FileMenuEntries[1].name = entry.name;
|
||||||
FileMenuEntries[1].sizeUnion = entry.sizeUnion;
|
FileMenuEntries[0].sizeUnion = entry.sizeUnion;
|
||||||
char attribs[15];
|
char attribs[16];
|
||||||
char *attribList = GetFileAttribs(entry);
|
char *attribList = GetFileAttribs(entry);
|
||||||
sprintf(attribs, "Attribs:%s", attribList);
|
sprintf(attribs, "Attribs:%s\n", attribList);
|
||||||
free(attribList);
|
free(attribList);
|
||||||
FileMenuEntries[2].name = attribs;
|
FileMenuEntries[2].name = attribs;
|
||||||
|
|
||||||
|
|
95
source/storage/gptmenu.c
Normal file
95
source/storage/gptmenu.c
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
#include "gptmenu.h"
|
||||||
|
#include "../gfx/gfx.h"
|
||||||
|
#include "../gfx/menu.h"
|
||||||
|
#include "../gfx/gfxutils.h"
|
||||||
|
#include "../utils/vector.h"
|
||||||
|
#include "mountmanager.h"
|
||||||
|
#include <utils/list.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "nx_emmc.h"
|
||||||
|
#include <mem/heap.h>
|
||||||
|
#include "../fs/menus/explorer.h"
|
||||||
|
#include "../err.h"
|
||||||
|
#include "../tegraexplorer/tconf.h"
|
||||||
|
|
||||||
|
MenuEntry_t GptMenuHeader[] = {
|
||||||
|
{.optionUnion = COLORTORGB(COLOR_ORANGE), .name = "<- Back"},
|
||||||
|
{.optionUnion = COLORTORGB(COLOR_GREY) | SKIPBIT, .name = "Clipboard -> Partition"},
|
||||||
|
{.optionUnion = COLORTORGB(COLOR_GREY) | SKIPBIT, .name = "\nBoot0/1"} // Should be blue when implemented
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *GptFSEntries[] = {
|
||||||
|
"PRODINFOF",
|
||||||
|
"SAFE",
|
||||||
|
"SYSTEM",
|
||||||
|
"USER"
|
||||||
|
};
|
||||||
|
|
||||||
|
void GptMenu(u8 MMCType){
|
||||||
|
if (connectMMC(MMCType))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Vector_t GptMenu = newVec(sizeof(MenuEntry_t), 15);
|
||||||
|
GptMenu.count = 3;
|
||||||
|
memcpy(GptMenu.data, GptMenuHeader, sizeof(MenuEntry_t) * ARR_LEN(GptMenuHeader));
|
||||||
|
|
||||||
|
link_t *gpt = GetCurGPT();
|
||||||
|
|
||||||
|
LIST_FOREACH_ENTRY(emmc_part_t, part, gpt, link) {
|
||||||
|
MenuEntry_t entry = {.optionUnion = COLORTORGB(COLOR_VIOLET), .icon = 128, .name = part->name};
|
||||||
|
u64 total = (part->lba_end - part->lba_start) / 2 + 1;
|
||||||
|
u8 type = 1;
|
||||||
|
while (total > 1024){
|
||||||
|
total /= 1024;
|
||||||
|
type++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type > 3)
|
||||||
|
type = 3;
|
||||||
|
|
||||||
|
entry.showSize = 1;
|
||||||
|
entry.size = total;
|
||||||
|
entry.sizeDef = type;
|
||||||
|
|
||||||
|
for (int i = 0; i < ARR_LEN(GptFSEntries); i++){
|
||||||
|
if (!strcmp(part->name, GptFSEntries[i])){
|
||||||
|
entry.optionUnion = COLORTORGB(COLOR_WHITE);
|
||||||
|
entry.icon = 127;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vecAddElem(&GptMenu, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
vecDefArray(MenuEntry_t*, entries, GptMenu);
|
||||||
|
int res = 0;
|
||||||
|
while (1){
|
||||||
|
gfx_clearscreen();
|
||||||
|
gfx_printf((MMCType == MMC_CONN_EMMC) ? "-- Emmc --\n\n" : "-- Emummc --\n\n");
|
||||||
|
|
||||||
|
res = newMenu(&GptMenu, res, 40, 20, ALWAYSREDRAW | ENABLEB, GptMenu.count);
|
||||||
|
|
||||||
|
if (res < 3){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (entries[res].icon == 127){
|
||||||
|
unmountMMCPart();
|
||||||
|
ErrCode_t err = mountMMCPart(entries[res].name);
|
||||||
|
if (err.err){
|
||||||
|
DrawError(err);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (TConf.curExplorerLoc > LOC_SD)
|
||||||
|
ResetCopyParams();
|
||||||
|
TConf.curExplorerLoc = LOC_EMMC;
|
||||||
|
FileExplorer("bis:/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DrawError(newErrCode(TE_ERR_UNIMPLEMENTED));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(GptMenu.data);
|
||||||
|
}
|
5
source/storage/gptmenu.h
Normal file
5
source/storage/gptmenu.h
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <utils/types.h>
|
||||||
|
|
||||||
|
void GptMenu(u8 MMCType);
|
|
@ -6,6 +6,9 @@
|
||||||
#include <sec/se.h>
|
#include <sec/se.h>
|
||||||
#include <libs/fatfs/ff.h>
|
#include <libs/fatfs/ff.h>
|
||||||
#include "nx_emmc_bis.h"
|
#include "nx_emmc_bis.h"
|
||||||
|
#include "../config.h"
|
||||||
|
|
||||||
|
extern hekate_config h_cfg;
|
||||||
|
|
||||||
void SetKeySlots(){
|
void SetKeySlots(){
|
||||||
if (TConf.keysDumped){
|
if (TConf.keysDumped){
|
||||||
|
@ -39,31 +42,45 @@ int connectMMC(u8 mmcType){
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
disconnectMMC();
|
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);
|
int res = emummc_storage_init_mmc(&emmc_storage, &emmc_sdmmc);
|
||||||
if (!res)
|
if (!res){
|
||||||
TConf.currentMMCConnected = mmcType;
|
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
|
return res; // deal with the errors later lol
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrCode_t mountMMCPart(const char *partition){
|
ErrCode_t mountMMCPart(const char *partition){
|
||||||
if (TConf.connectedMMCMounted)
|
if (!TConf.connectedMMCMounted){
|
||||||
return newErrCode(0);
|
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);
|
int res = 0;
|
||||||
|
if ((res = f_mount(&emmc_fs, "bis:", 1)))
|
||||||
nx_emmc_gpt_parse(&curGpt, &emmc_storage);
|
return newErrCode(res);
|
||||||
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;
|
TConf.connectedMMCMounted = 1;
|
||||||
if ((res = f_mount(&emmc_fs, "bis:", 1)))
|
}
|
||||||
return newErrCode(res);
|
|
||||||
|
|
||||||
TConf.connectedMMCMounted = 1;
|
|
||||||
return newErrCode(0);
|
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;
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <utils/types.h>
|
#include <utils/types.h>
|
||||||
|
#include <utils/list.h>
|
||||||
#include "../err.h"
|
#include "../err.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -10,4 +11,6 @@ enum {
|
||||||
|
|
||||||
int connectMMC(u8 mmcType);
|
int connectMMC(u8 mmcType);
|
||||||
ErrCode_t mountMMCPart(const char *partition);
|
ErrCode_t mountMMCPart(const char *partition);
|
||||||
void SetKeySlots();
|
void SetKeySlots();
|
||||||
|
void unmountMMCPart();
|
||||||
|
link_t *GetCurGPT();
|
|
@ -10,11 +10,14 @@
|
||||||
#include "tconf.h"
|
#include "tconf.h"
|
||||||
#include "../keys/keys.h"
|
#include "../keys/keys.h"
|
||||||
#include "../storage/mountmanager.h"
|
#include "../storage/mountmanager.h"
|
||||||
|
#include "../storage/gptmenu.h"
|
||||||
|
#include "../storage/emummc.h"
|
||||||
|
|
||||||
MenuEntry_t mainMenuEntries[] = {
|
MenuEntry_t mainMenuEntries[] = {
|
||||||
{.R = 255, .G = 255, .B = 255, .skip = 1, .name = "-- Main Menu --"},
|
{.R = 255, .G = 255, .B = 255, .skip = 1, .name = "-- Main Menu --"},
|
||||||
{.G = 255, .name = "SD:/"},
|
{.G = 255, .name = "SD:/"},
|
||||||
{.optionUnion = COLORTORGB(COLOR_YELLOW), .name = "emmc:/SYSTEM"},
|
{.optionUnion = COLORTORGB(COLOR_YELLOW), .name = "Emmc"},
|
||||||
|
{.optionUnion = COLORTORGB(COLOR_YELLOW), .name = "Emummc"},
|
||||||
{.B = 255, .G = 255, .name = "Test Controllers"},
|
{.B = 255, .G = 255, .name = "Test Controllers"},
|
||||||
{.R = 255, .name = "Cause an exception"},
|
{.R = 255, .name = "Cause an exception"},
|
||||||
{.optionUnion = COLORTORGB(COLOR_ORANGE), .name = "View dumped keys"},
|
{.optionUnion = COLORTORGB(COLOR_ORANGE), .name = "View dumped keys"},
|
||||||
|
@ -33,16 +36,11 @@ void HandleSD(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleEMMC(){
|
void HandleEMMC(){
|
||||||
if (connectMMC(MMC_CONN_EMMC))
|
GptMenu(MMC_CONN_EMMC);
|
||||||
return;
|
}
|
||||||
|
|
||||||
ErrCode_t err = mountMMCPart("SYSTEM");
|
void HandleEMUMMC(){
|
||||||
if (err.err){
|
GptMenu(MMC_CONN_EMUMMC);
|
||||||
DrawError(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FileExplorer("bis:/");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrashTE(){
|
void CrashTE(){
|
||||||
|
@ -72,6 +70,7 @@ menuPaths mainMenuPaths[] = {
|
||||||
NULL,
|
NULL,
|
||||||
HandleSD,
|
HandleSD,
|
||||||
HandleEMMC,
|
HandleEMMC,
|
||||||
|
HandleEMUMMC,
|
||||||
TestControllers,
|
TestControllers,
|
||||||
CrashTE,
|
CrashTE,
|
||||||
ViewKeys,
|
ViewKeys,
|
||||||
|
@ -81,7 +80,8 @@ menuPaths mainMenuPaths[] = {
|
||||||
void EnterMainMenu(){
|
void EnterMainMenu(){
|
||||||
while (1){
|
while (1){
|
||||||
mainMenuEntries[2].hide = !TConf.keysDumped;
|
mainMenuEntries[2].hide = !TConf.keysDumped;
|
||||||
mainMenuEntries[5].hide = !TConf.keysDumped;
|
mainMenuEntries[3].hide = (!TConf.keysDumped || !emu_cfg.enabled);
|
||||||
|
mainMenuEntries[6].hide = !TConf.keysDumped;
|
||||||
FunctionMenuHandler(mainMenuEntries, ARR_LEN(mainMenuEntries), mainMenuPaths, ALWAYSREDRAW);
|
FunctionMenuHandler(mainMenuEntries, ARR_LEN(mainMenuEntries), mainMenuPaths, ALWAYSREDRAW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue