SceUsbstorVStorDriver

From Vita Development Wiki
Revision as of 03:43, 9 November 2016 by Devnoname120 (talk | contribs) (Swapped Module <-> Library, see revision 1.1 under "Revision History" of "Vita SDK specifications" (https://wiki.henkaku.xyz/vita/File:Vita_SDK_specifications.pdf))
Jump to navigation Jump to search

Module

Known NIDs

Version Name World Privilege NID
1.69 SceUsbstorVStorDriver Non-secure Kernel 0xC2C77BE3

Libraries

Known NIDs

Version Name World Visibility NID
1.69 SceUsbstorVStorForDriver Non-secure Kernel 0xFD5BA349
1.69 SceUsbstorVStor Non-secure User 0x17F294B9

SceUsbstorVStorForDriver

Set Device Name

Version NID
1.69 0x3F02417C

This name shows up in the USB descriptor.

int SceUsbstorVStorForDriver_0x3F02417C_set_name(const char *name);

Set Image Path

Version NID
1.69 0x78B42CC8

The filesystem image to use as USB storage. This is limited to the CMA installer ISO and a FAT image at ux0:/umass/fat.img. Other paths will return error.

int SceUsbstorVStorForDriver_0x78B42CC8_set_path(const char *path);

Activate USB storage device

Version NID
1.69 0x31F7BBAD

The user is responsible for making sure no other UDC driver is active. This activates UDC as a "PS Vita" Type A device.

int SceUsbstorVStorForDriver_0x31F7BBAD_activate(int unk);

Stop USB Storage

Version NID
1.69 0x99C2BC8A
int SceUsbstorVStorForDriver_0x99C2BC8A_stop(int unk);

SceUsbstorVStor

Set Device Name

Version NID
1.69 0x3F02417C

User wrapper for 0x14455C20. Must have correct permissions to call.

Set Image Path

Version NID
1.69 0x8C9F93AB

User wrapper for 0x78B42CC8. Must have correct permissions to call.

Activate USB storage device

Version NID
1.69 0xB606F1AF

User wrapper for 0x31F7BBAD. Must have correct permissions to call.

Stop USB Storage

Version NID
1.69 0x0FD67059

User wrapper for 0x99C2BC8A. Must have correct permissions to call.

Sample Usage

int start_usb_storage(void)
{
    int ret;

    ret = SceMtpIfForDriver_0xFDF8C3C0_stop(1); // stop MTP driver
    printf("Stop: 0x%08X\n", ret);
    ret = SceUsbstorVStorForDriver_0x3F02417C_set_name("\"PS Vita\" MC", "1.00");
    printf("SetName: 0x%08X\n", ret);
    ret = SceUsbstorVStorForDriver_0x78B42CC8_set_path("ux0:/umass/fat.img");
    printf("SetPath: 0x%08X\n", ret);
    ret = SceUsbstorVStorForDriver_0x31F7BBAD_activate(0);
    printf("Activate: 0x%08X\n", ret);

    return 0;
}

int start_usb_storage_unchecked(void)
{
    int ret;

    ret = SceMtpIfForDriver_0xFDF8C3C0_stop(1); // stop MTP driver
    printf("Stop: 0x%08X\n", ret);
    ret = SceUsbstorVStorForDriver_0x3F02417C_set_name("\"PS Vita\" MC", "1.00");
    printf("SetName: 0x%08X\n", ret);
    ret = SceUsbstorVStorForDriver_0x78B42CC8_set_path("ux0:/any/path/here.img");
    printf("SetPath: 0x%08X\n", ret);

    // activate without tests
    //*(int*)0x013F9054 = 0; // set 1 for RO access
    ret = SceUdcdForDriver_0x9FD733EA_start("USBDeviceControllerDriver", 0, 0);
    printf("StartUSB: 0x%08X\n", ret);
    ret = SceUdcdForDriver_0x9FD733EA_start("USBStor_Driver", 0, 0);
    printf("StartStor: 0x%08X\n", ret);
    ret = SceUdcdForDriver_0x4FDEA423_activate(1491);
    printf("Activate: 0x%08X\n", ret);

    return 0;
}

int stop_usb_storage(void)
{
    int ret;

    ret = SceUsbstorVStorForDriver_0x99C2BC8A_stop(1); // stop storage driver
    printf("Stop: 0x%08X\n", ret);

    return ret;
}