-
Notifications
You must be signed in to change notification settings - Fork 0
/
usb.c
96 lines (82 loc) · 1.93 KB
/
usb.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//Thanks neur0n!!
#include <pspkernel.h>
#include <pspusb.h>
#include <pspusbstor.h>
#include <pspusbdevice.h>
#include <pspmodulemgr.h>
#include <pspsdk.h>
#include "common.h"
typedef struct
{
char *path;
int uid;
}UsbModuleList;
int StopUnloadModule(SceUID id)
{
SceUID r = sceKernelStopModule(id ,0 ,NULL , NULL, NULL);
if(r < 0) return r;
return sceKernelUnloadModule(id);
}
static UsbModuleList usb_list[] = {
{"flash0:/kd/semawm.prx" , -1 },
{"flash0:/kd/usbstor.prx" , -1 },
{"flash0:/kd/usbstormgr.prx" , -1 },
{"flash0:/kd/usbstorms.prx" , -1 },
{"flash0:/kd/usbstoreflash.prx" , -1 },
{"flash0:/kd/usbstorboot.prx" , -1 },
};
#define USB_MODULE_CNT (sizeof(usb_list)/sizeof(UsbModuleList))
void LoadUsbModules()
{
int i;
for(i=0;i<USB_MODULE_CNT;i++)
{
usb_list[i].uid = LoadStartModule( usb_list[i].path );
}
}
void UnoadUsbModules()
{
int i;
for(i= (USB_MODULE_CNT - 1); i< 0 ;i--)
{
if( usb_list[i].uid >= 0)
{
StopUnloadModule(usb_list[i].uid);
usb_list[i].uid = -1;
}
}
}
int connect_usb()
{
static int connect_flag = 0;
if( connect_flag )
{
sceUsbDeactivate(0);
//Flush MS and SS to avoid corrupted files
sceIoDevctl("mscmhc0:", 0x0240D81E, NULL, 0, NULL, 0 );
if (model == 4 ) { sceIoDevctl("mscmhcemu0:", 0x0240D81E, NULL, 0, NULL, 0 ); }
sceUsbStop(PSP_USBSTOR_DRIVERNAME, 0, 0);
sceUsbStop(PSP_USBBUS_DRIVERNAME, 0, 0);
UnoadUsbModules();
}
else
{
LoadUsbModules();
sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0);
// sceUsbstorBootSetCapacity(0x800000);
switch (model){
case 0: //PSP 1000
sceUsbActivate(0x1c8);
break;
case 4: //PSP Go
sceUsbActivate(0x381);
break;
default: //PSP Slim; Brite and Street unknown
sceUsbActivate(0x2D2);
}
}
// select new
connect_flag = 1- connect_flag;
return connect_flag;
}