1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-26 13:52:06 +00:00

Make emmc writable + merge hekate fixes

This commit is contained in:
Such Meme, Many Skill 2020-01-06 14:24:29 +01:00
parent ef76834ef4
commit 02504c8a36
5 changed files with 57 additions and 23 deletions

View file

@ -188,7 +188,7 @@ void gfx_putc(char c)
for (u32 i = 0; i < 16; i+=2)
{
u8 v = *cbuf++;
u8 v = *cbuf;
for (u32 k = 0; k < 2; k++)
{
for (u32 j = 0; j < 8; j++)
@ -213,6 +213,7 @@ void gfx_putc(char c)
fb += gfx_ctxt.stride - 16;
v = *cbuf;
}
cbuf++;
}
gfx_con.x += 16;
if (gfx_con.x >= gfx_ctxt.width - 16) {

View file

@ -150,7 +150,7 @@ DRESULT disk_read (
__attribute__ ((aligned (16))) static u8 tweak[0x10];
__attribute__ ((aligned (16))) static u64 prev_cluster = -1;
__attribute__ ((aligned (16))) static u32 prev_sector = 0;
bool needs_cache_sector = false;
//bool needs_cache_sector = false;
/*
if (secindex == 0 || clear_sector_cache) {
if (!sector_cache)
@ -212,14 +212,13 @@ DRESULT disk_read (
DRESULT disk_write (
BYTE pdrv, /* Physical drive number to identify the drive */
const BYTE *buff, /* Data to be written */
BYTE *buff, /* Data to be written */
DWORD sector, /* Start sector in LBA */
UINT count /* Number of sectors to write */
)
{
if (pdrv == 1)
return RES_WRPRT;
switch (pdrv){
case 0:
if (((u32)buff >= DRAM_START) && !((u32)buff % 8))
return sdmmc_storage_write(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR;
u8 *buf = (u8 *)SDMMC_UPPER_BUFFER; //TODO: define this somewhere.
@ -227,6 +226,33 @@ DRESULT disk_write (
if (sdmmc_storage_write(&sd_storage, sector, count, buf))
return RES_OK;
return RES_ERROR;
case 1:;
__attribute__ ((aligned (16))) static u8 tweak[0x10];
__attribute__ ((aligned (16))) static u64 prev_cluster = -1;
__attribute__ ((aligned (16))) static u32 prev_sector = 0;
u32 tweak_exp = 0;
bool regen_tweak = true;
if (prev_cluster != sector / 0x20) { // sector in different cluster than last read
prev_cluster = sector / 0x20;
tweak_exp = sector % 0x20;
} else if (sector > prev_sector) { // sector in same cluster and past last sector
tweak_exp = sector - prev_sector - 1;
regen_tweak = false;
} else { // sector in same cluster and before or same as last sector
tweak_exp = sector % 0x20;
}
if (_emmc_xts(9, 8, 1, tweak, regen_tweak, tweak_exp, prev_cluster, buff, buff, count * 0x200)){
if (nx_emmc_part_write(&storage, system_part, sector, count, buff)){
prev_sector = sector + count - 1;
return RES_OK;
}
}
return RES_ERROR;
}
return RES_ERROR;
}
DRESULT disk_ioctl (

View file

@ -31,7 +31,7 @@ typedef enum {
DSTATUS disk_initialize (BYTE pdrv);
DSTATUS disk_status (BYTE pdrv);
DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
DRESULT disk_write (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);

View file

@ -32,6 +32,7 @@ u32 minerva_init()
{
u32 curr_ram_idx = 0;
minerva_cfg = NULL;
mtc_config_t *mtc_cfg = (mtc_config_t *)&nyx_str->mtc_cfg;
// Set table to nyx storage.

View file

@ -174,22 +174,23 @@ int copy(const char *locin, const char *locout, bool print, bool canCancel){
UINT temp1, temp2;
u8 *buff;
unsigned int x, y, i = 0;
int res;
gfx_con_getpos(&x, &y);
if (!strcmp(locin, locout)){
return 3;
return -1;
}
if (f_open(&in, locin, FA_READ | FA_OPEN_EXISTING)){
return 1;
return -2;
}
if (f_stat(locin, &in_info))
return 1;
return -2;
if (f_open(&out, locout, FA_CREATE_ALWAYS | FA_WRITE)){
return 2;
return -3;
}
buff = malloc (BUFSIZE);
@ -197,13 +198,13 @@ int copy(const char *locin, const char *locout, bool print, bool canCancel){
totalsize = sizeoffile;
while (sizeoffile > 0){
if (f_read(&in, buff, (sizeoffile > BUFSIZE) ? BUFSIZE : sizeoffile, &temp1))
return 3;
if (f_write(&out, buff, (sizeoffile > BUFSIZE) ? BUFSIZE : sizeoffile, &temp2))
return 4;
if ((res = f_read(&in, buff, (sizeoffile > BUFSIZE) ? BUFSIZE : sizeoffile, &temp1)))
return res;
if ((res = f_write(&out, buff, (sizeoffile > BUFSIZE) ? BUFSIZE : sizeoffile, &temp2)))
return res;
if (temp1 != temp2)
return 5;
return -4;
sizeoffile -= temp1;
sizecopied += temp1;
@ -487,12 +488,17 @@ void copyfolder(char *in, char *out){
int res;
if (!strcmp(in, rootpath)){
message(COLOR_RED, "In is root\nAborting!");
message(COLOR_RED, "\nIn is root\nAborting!");
fatalerror = true;
}
if (strstr(out, in) != NULL && !fatalerror){
message(COLOR_RED, "\nOut is a part of in!\nAborting");
message(COLOR_RED, "\nOut is a part of in!\nAborting!");
fatalerror = true;
}
if (!strcmp(in, out) && !fatalerror){
message(COLOR_RED, "\nIn is the same as out!\nAborting!");
fatalerror = true;
}