mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2025-02-19 23:15:36 +00:00
Make emmc writable + merge hekate fixes
This commit is contained in:
parent
ef76834ef4
commit
02504c8a36
5 changed files with 57 additions and 23 deletions
|
@ -188,7 +188,7 @@ void gfx_putc(char c)
|
||||||
|
|
||||||
for (u32 i = 0; i < 16; i+=2)
|
for (u32 i = 0; i < 16; i+=2)
|
||||||
{
|
{
|
||||||
u8 v = *cbuf++;
|
u8 v = *cbuf;
|
||||||
for (u32 k = 0; k < 2; k++)
|
for (u32 k = 0; k < 2; k++)
|
||||||
{
|
{
|
||||||
for (u32 j = 0; j < 8; j++)
|
for (u32 j = 0; j < 8; j++)
|
||||||
|
@ -213,6 +213,7 @@ void gfx_putc(char c)
|
||||||
fb += gfx_ctxt.stride - 16;
|
fb += gfx_ctxt.stride - 16;
|
||||||
v = *cbuf;
|
v = *cbuf;
|
||||||
}
|
}
|
||||||
|
cbuf++;
|
||||||
}
|
}
|
||||||
gfx_con.x += 16;
|
gfx_con.x += 16;
|
||||||
if (gfx_con.x >= gfx_ctxt.width - 16) {
|
if (gfx_con.x >= gfx_ctxt.width - 16) {
|
||||||
|
|
|
@ -150,7 +150,7 @@ DRESULT disk_read (
|
||||||
__attribute__ ((aligned (16))) static u8 tweak[0x10];
|
__attribute__ ((aligned (16))) static u8 tweak[0x10];
|
||||||
__attribute__ ((aligned (16))) static u64 prev_cluster = -1;
|
__attribute__ ((aligned (16))) static u64 prev_cluster = -1;
|
||||||
__attribute__ ((aligned (16))) static u32 prev_sector = 0;
|
__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 (secindex == 0 || clear_sector_cache) {
|
||||||
if (!sector_cache)
|
if (!sector_cache)
|
||||||
|
@ -212,20 +212,46 @@ DRESULT disk_read (
|
||||||
|
|
||||||
DRESULT disk_write (
|
DRESULT disk_write (
|
||||||
BYTE pdrv, /* Physical drive number to identify the drive */
|
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 */
|
DWORD sector, /* Start sector in LBA */
|
||||||
UINT count /* Number of sectors to write */
|
UINT count /* Number of sectors to write */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (pdrv == 1)
|
switch (pdrv){
|
||||||
return RES_WRPRT;
|
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.
|
||||||
|
memcpy(buf, buff, 512 * count);
|
||||||
|
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 (((u32)buff >= DRAM_START) && !((u32)buff % 8))
|
if (prev_cluster != sector / 0x20) { // sector in different cluster than last read
|
||||||
return sdmmc_storage_write(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR;
|
prev_cluster = sector / 0x20;
|
||||||
u8 *buf = (u8 *)SDMMC_UPPER_BUFFER; //TODO: define this somewhere.
|
tweak_exp = sector % 0x20;
|
||||||
memcpy(buf, buff, 512 * count);
|
} else if (sector > prev_sector) { // sector in same cluster and past last sector
|
||||||
if (sdmmc_storage_write(&sd_storage, sector, count, buf))
|
tweak_exp = sector - prev_sector - 1;
|
||||||
return RES_OK;
|
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;
|
return RES_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ typedef enum {
|
||||||
DSTATUS disk_initialize (BYTE pdrv);
|
DSTATUS disk_initialize (BYTE pdrv);
|
||||||
DSTATUS disk_status (BYTE pdrv);
|
DSTATUS disk_status (BYTE pdrv);
|
||||||
DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
|
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);
|
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ u32 minerva_init()
|
||||||
{
|
{
|
||||||
u32 curr_ram_idx = 0;
|
u32 curr_ram_idx = 0;
|
||||||
|
|
||||||
|
minerva_cfg = NULL;
|
||||||
mtc_config_t *mtc_cfg = (mtc_config_t *)&nyx_str->mtc_cfg;
|
mtc_config_t *mtc_cfg = (mtc_config_t *)&nyx_str->mtc_cfg;
|
||||||
|
|
||||||
// Set table to nyx storage.
|
// Set table to nyx storage.
|
||||||
|
|
|
@ -174,22 +174,23 @@ int copy(const char *locin, const char *locout, bool print, bool canCancel){
|
||||||
UINT temp1, temp2;
|
UINT temp1, temp2;
|
||||||
u8 *buff;
|
u8 *buff;
|
||||||
unsigned int x, y, i = 0;
|
unsigned int x, y, i = 0;
|
||||||
|
int res;
|
||||||
|
|
||||||
gfx_con_getpos(&x, &y);
|
gfx_con_getpos(&x, &y);
|
||||||
|
|
||||||
if (!strcmp(locin, locout)){
|
if (!strcmp(locin, locout)){
|
||||||
return 3;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f_open(&in, locin, FA_READ | FA_OPEN_EXISTING)){
|
if (f_open(&in, locin, FA_READ | FA_OPEN_EXISTING)){
|
||||||
return 1;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f_stat(locin, &in_info))
|
if (f_stat(locin, &in_info))
|
||||||
return 1;
|
return -2;
|
||||||
|
|
||||||
if (f_open(&out, locout, FA_CREATE_ALWAYS | FA_WRITE)){
|
if (f_open(&out, locout, FA_CREATE_ALWAYS | FA_WRITE)){
|
||||||
return 2;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
buff = malloc (BUFSIZE);
|
buff = malloc (BUFSIZE);
|
||||||
|
@ -197,13 +198,13 @@ int copy(const char *locin, const char *locout, bool print, bool canCancel){
|
||||||
totalsize = sizeoffile;
|
totalsize = sizeoffile;
|
||||||
|
|
||||||
while (sizeoffile > 0){
|
while (sizeoffile > 0){
|
||||||
if (f_read(&in, buff, (sizeoffile > BUFSIZE) ? BUFSIZE : sizeoffile, &temp1))
|
if ((res = f_read(&in, buff, (sizeoffile > BUFSIZE) ? BUFSIZE : sizeoffile, &temp1)))
|
||||||
return 3;
|
return res;
|
||||||
if (f_write(&out, buff, (sizeoffile > BUFSIZE) ? BUFSIZE : sizeoffile, &temp2))
|
if ((res = f_write(&out, buff, (sizeoffile > BUFSIZE) ? BUFSIZE : sizeoffile, &temp2)))
|
||||||
return 4;
|
return res;
|
||||||
|
|
||||||
if (temp1 != temp2)
|
if (temp1 != temp2)
|
||||||
return 5;
|
return -4;
|
||||||
|
|
||||||
sizeoffile -= temp1;
|
sizeoffile -= temp1;
|
||||||
sizecopied += temp1;
|
sizecopied += temp1;
|
||||||
|
@ -487,12 +488,17 @@ void copyfolder(char *in, char *out){
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (!strcmp(in, rootpath)){
|
if (!strcmp(in, rootpath)){
|
||||||
message(COLOR_RED, "In is root\nAborting!");
|
message(COLOR_RED, "\nIn is root\nAborting!");
|
||||||
fatalerror = true;
|
fatalerror = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(out, in) != NULL && !fatalerror){
|
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;
|
fatalerror = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue