Skip to content

Commit

Permalink
v4.0 stable
Browse files Browse the repository at this point in the history
- fixed the PSVSD driver
- added ability to disable post-yamt mounts
  • Loading branch information
SKGleba committed Aug 9, 2020
1 parent d175afa commit 2eb966b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 65 deletions.
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -13,7 +13,7 @@ Requires enso, compatible ONLY with firmware 3.60 and 3.65.
1) Remove the previous driver, if you had yamt - remove it with the NEW installer.
2) Install the vpk
3) Open the app, choose the option that suits you.
- Lite version is intended for normal users, it provides basic mounting options.
- Lite version is intended for normal users, it provides basic mounting and format options.
- Full version is recommended for advanced users, it packs all the important storage managing tools.
4) Reboot, you should be able to access a new menu under the "Devices" tab in the System Settings app.

Expand All @@ -24,7 +24,7 @@ Requires enso, compatible ONLY with firmware 3.60 and 3.65.
- You can remount every partition with yamt.
- Developer options in driver settings provide some useful storage functions like formatting.
- In the 'Custom partitions" tab you have all the partitions listed excluding pseudo partitions like lma0.
- You can edit the assignements of the listed partitions, please take a look at https://wiki.henkaku.xyz/vita/SceIofilemgr#Mount_Points.
- You can edit the assignements of the listed partitions, take a look at https://wiki.henkaku.xyz/vita/SceIofilemgr#Mount_Points.
- i.e if you set sa0 to [ext; act; entire] it will bind sa0 to the sd2vita's main partition at boot.

# Uninstallation
Expand All @@ -33,14 +33,14 @@ Requires enso, compatible ONLY with firmware 3.60 and 3.65.
# Manual Installation
1) Add yamt.skprx to enso's boot_config.txt
2) Add yamt.suprx to tai config.txt under \*NPXS10015
3) Add yamt_helper.skprx to tai config under \*KERNEL
3) Add yamt_helper.skprx to tai config.txt under \*KERNEL

# Notes
- To compile simply run ". create_vpk.sh".
- The project is still WIP, report all bugs.
- Before updating from a beta release, use enso's "fix boot configuration".
- You can format the SD/USB to TexFAT from the developer options menu in the driver settings tab.
- If the USB-as-ux0 mounting fails, setting legacy mode in driver settings may help.
- If the USB/PSVSD mount fails, setting legacy mode in driver settings may help.
- Before updating from a beta release, use enso's "fix boot configuration".
- The project is still WIP, report all bugs.

# Credits
- TheOfficialFlow, xyz for their work on vitashell/gamesd
Expand Down
63 changes: 21 additions & 42 deletions plugin/helper/main.c
Expand Up @@ -7,7 +7,6 @@
#define LOGGING_ENABLED 0
#include "logging.h"
#include <taihen.h>
static SceIoDevice uma_ux0_dev = { "ux0:", "exfatux0", "sdstor0:uma-pp-act-a", "sdstor0:uma-lp-act-entire", 0x800 };

static int umaid = 0;
static uint8_t mids[16];
Expand All @@ -28,7 +27,7 @@ int yamtUserCmdHandler(int cmd, void *cmdbuf) {
case 0: // read SD to buf
opret = ksceSdifReadSectorSd(ksceSdifGetSdContextPartValidateSd(1), buf.arg0, (void *)&buf.data, 1);
break;
case 1: // write SD to buf
case 1: // write buf to SD
opret = ksceSdifWriteSectorSd(ksceSdifGetSdContextPartValidateSd(1), buf.arg0, &buf.data, 1);
break;
case 2: // remount everything
Expand Down Expand Up @@ -62,36 +61,6 @@ void patch_appmgr() {
}
}

int legacyUsbRedir(void) {
tai_module_info_t sceiofilemgr_modinfo;
sceiofilemgr_modinfo.size = sizeof(tai_module_info_t);
SceIoMountPoint *(* sceIoFindMountPoint)(int id) = NULL;
if (taiGetModuleInfoForKernel(KERNEL_PID, "SceIofilemgr", &sceiofilemgr_modinfo) < 0)
return -1;

switch (sceiofilemgr_modinfo.module_nid) {
case 0x9642948C: // 3.60
module_get_offset(KERNEL_PID, sceiofilemgr_modinfo.modid, 0, 0x138C1, (uintptr_t *)&sceIoFindMountPoint);
break;
case 0xA96ACE9D: // 3.65
module_get_offset(KERNEL_PID, sceiofilemgr_modinfo.modid, 0, 0x182F5, (uintptr_t *)&sceIoFindMountPoint);
break;
default:
return -1;
}

if (sceIoFindMountPoint == NULL)
return -1;

SceIoMountPoint *mount1 = sceIoFindMountPoint(0x800);
mount1->dev = &uma_ux0_dev;
mount1->dev2 = &uma_ux0_dev;

ksceIoUmount(0x800, 0, 0, 0);
ksceIoUmount(0x800, 1, 0, 0);
return ksceIoMount(0x800, NULL, 0, 0, 0, 0);
}

void addUsbPatches(void) {
int (* _ksceKernelMountBootfs)(const char *bootImagePath);
int (* _ksceKernelUmountBootfs)(void);
Expand All @@ -107,12 +76,13 @@ void addUsbPatches(void) {
module_get_export_func(KERNEL_PID, "SceKernelModulemgr", 0x92C9FFC2, 0xBD61AD4D, (uintptr_t *)&_ksceKernelUmountBootfs);

SceUID sceusbmass_modid;
LOG("Loading SceUsbMass from os0:.\nMounting bootfs:...\n");
LOG("Mounting bootfs for umass... ");
if (_ksceKernelMountBootfs("os0:kd/bootimage.skprx") >= 0) {
ret = yamtPatchUsbDrv("os0:kd/umass.skprx");
LOG("patch_usb: : 0x%X\n", ret);
LOG("ok\npatch_usb: 0x%X\n", ret);
_ksceKernelUmountBootfs();
}
} else
LOG("failed\n");
}

static int yusb_sysevent_handler(int resume, int eventid, void *args, void *opt) {
Expand Down Expand Up @@ -152,7 +122,8 @@ int module_start(SceSize argc, const void *args)
}

while(yamtGPIO(0, 2, 0) == 2) {
ksceKernelDelayThread(5000);
LOG("yamt_usb busy, waiting 0.05s\n");
ksceKernelDelayThread(50000);
}

// init log sys
Expand All @@ -168,6 +139,8 @@ int module_start(SceSize argc, const void *args)
int fd;
mounted:
fd = ksceIoOpen("sdstor0:uma-lp-act-entire", SCE_O_RDONLY, 0);
if (fd < 0)
fd = ksceIoOpen("sdstor0:uma-pp-act-a", SCE_O_RDONLY, 0);
if (flags[2]) {
LOG("forcing legacy usb mode\n");
for (int i = 0; i <= 25; i++) {
Expand All @@ -184,15 +157,19 @@ int module_start(SceSize argc, const void *args)
}
if (fd >= 0) {
ksceIoClose(fd);
patch_appmgr();
LOG("found uma, legacy redir 0x%X\n", legacyUsbRedir());
if (umaid == 0x800)
patch_appmgr();
ksceIoUmount(umaid, 0, 0, 0);
ksceIoUmount(umaid, 1, 0, 0);
LOG("found uma, legacy redir 0x%X\n", ksceIoMount(umaid, NULL, 0, 0, 0, 0));
}
} else {
if (fd >= 0) {
ksceIoClose(fd);
if (umaid == 0x800)
patch_appmgr();
}
LOG("found uma, redir 0x%X\n", ksceIoMount(umaid, NULL, 0, 0, 0, 0));
}
}
LOG("umass module loaded, uma fd = 0x%X, umaid = 0x%X\n", fd, umaid);
if (fd >= 0 && (!flags[3]))
Expand All @@ -206,9 +183,11 @@ int module_start(SceSize argc, const void *args)
// mount if yamt didnt make it
yamtGPIO(1, 1, 0);
yamtGetValidMids(&mids);
for (int i = 0; i < 16; ++i) {
if (mids[i] > 0)
LOG("mounting 0x%X = 0x%X\n", mids[i] * 0x100, ksceIoMount(mids[i] * 0x100, NULL, 0, 0, 0, 0));
if (!flags[3]) {
for (int i = 0; i < 16; ++i) {
if (mids[i] > 0)
LOG("mounting 0x%X = 0x%X\n", mids[i] * 0x100, ksceIoMount(mids[i] * 0x100, NULL, 0, 0, 0, 0));
}
}

return SCE_KERNEL_START_SUCCESS;
Expand Down
20 changes: 11 additions & 9 deletions plugin/kernel/main.c
Expand Up @@ -14,6 +14,7 @@ static SceIoDevice custom[16];
static uint32_t gpio[4];
const char umass_skipb[] = {0x0d, 0xe0, 0x00, 0xbf};
const char stub_ret_one[] = {0x01, 0x00, 0xa0, 0xe3, 0x1e, 0xff, 0x2f, 0xe1};
static const char *psvsdpdev = "sdstor0:uma-pp-act-a";

int yamtPatchUsbDrv(const char *drvpath) {
gpio[2] = 2;
Expand Down Expand Up @@ -42,10 +43,10 @@ static int mthr(SceSize args, void *argp) {
curid-=-1;
}
gpio[1] = 0;
if (cfg.drv[0]) {
if (cfg.drv[0] && !cfg.drv[3]) {
gpio[2] = 1;
ksceKernelDelayThread(50000);
if (gpio[2] == 1)
ksceKernelDelayThread(500000);
if (gpio[2] == 1 && ksceKernelSearchModuleByName("SceUsbServ") >= 0)
yamtPatchUsbDrv("os0:kd/umass.skprx");
gpio[2] = 0;
}
Expand Down Expand Up @@ -87,7 +88,8 @@ static void patch_redirect(void) {
mount1 = sceIoFindMountPoint(cfg.entry[loopos].mid * 0x100);
custom[vetr].dev = mount1->dev->dev;
custom[vetr].dev2 = mount1->dev->dev2;
custom[vetr].blkdev = custom[vetr].blkdev2 = convc[vetr];
custom[vetr].blkdev = (umaid == cfg.entry[loopos].mid * 0x100) ? psvsdpdev : convc[vetr]; // add physdev support for psvsd compat
custom[vetr].blkdev2 = convc[vetr];
custom[vetr].id = (cfg.entry[loopos].mid * 0x100);
mount1->dev = &custom[vetr];
mount1->dev2 = &custom[vetr];
Expand Down Expand Up @@ -159,17 +161,17 @@ int module_start(SceSize argc, const void *args)

gpio[0] = *(uint32_t *)cfg.drv;

umaid = yamtGetCDevID(5, 16); // uma---entire
if (umaid == 0)
umaid = yamtGetCDevID(5, 0); // uma---a

// "Big" redirect loop
patch_redirect();

// ksceIoMount threaded to save time
ksceKernelStartThread(ksceKernelCreateThread("x", mthr, 0x00, 0x1000, 0, 0, 0), 0, NULL);

umaid = yamtGetCDevID(5, 16); // uma---entire
if (umaid == 0)
umaid = yamtGetCDevID(5, 0); // uma---a

gpio[3] = (cfg.drv[2]) ? 0x800 : umaid;
gpio[3] = umaid;

return SCE_KERNEL_START_SUCCESS;
}
Expand Down
12 changes: 6 additions & 6 deletions plugin/user/peripherals_settings.xml
Expand Up @@ -62,15 +62,15 @@
key="/CONFIG/YAMT/gpo_0"
title="Enable experimental USB patches"
icon="tex_spanner"/>
<toggle_switch id="set_gpo2"
key="/CONFIG/YAMT/gpo_2"
title="Force legacy USB/PSVSD mode"/>
<toggle_switch id="set_gpo3"
key="/CONFIG/YAMT/gpo_3"
title="Disable extra USB/PSVSD patches"/>
<toggle_switch id="set_gpo1"
key="/CONFIG/YAMT/gpo_1"
title="Enable helper logging to file"/>
<toggle_switch id="set_gpo2"
key="/CONFIG/YAMT/gpo_2"
title="Force USB legacy ux0 mode"/>
<toggle_switch id="set_gpo3"
key="/CONFIG/YAMT/gpo_3"
title="Disable USB wakeup patch"/>
</setting_list>
<setting_list id="id_adv_yamt"
title="★Custom partitions"
Expand Down
5 changes: 3 additions & 2 deletions src/main.c
Expand Up @@ -124,7 +124,8 @@ void installYamtC() {

FILE *pFile = fopen("ur0:tai/config.txt", "wb");
char *pkx = strstr(pbf, "# YAMT\n");
if (!pkx) {
char *pzx = strstr(pbf, "ur0:tai/yamt_helper.skprx\n");
if (!pkx || !pzx) {
const char *patch1 =
"# YAMT\n*NPXS10015\nur0:tai/yamt.suprx\n*KERNEL\nur0:tai/yamt_helper.skprx\n\n";
fwrite(patch1, 1, strlen(patch1), pFile);
Expand Down Expand Up @@ -197,7 +198,7 @@ int optct = 4;
void smenu(){
psvDebugScreenClear(COLOR_BLACK);
psvDebugScreenSetFgColor(COLOR_CYAN);
printf(" YAMT installer v4.0-b4 \n");
printf(" YAMT installer v4.0 \n");
printf(" By SKGleba \n");
psvDebugScreenSetFgColor(COLOR_RED);
for(int i = 0; i < optct; i++){
Expand Down

0 comments on commit 2eb966b

Please sign in to comment.