12#define MODNAME "secrsif"
16#define DPRINTF(x...) printf("SECRSIF: " x)
39static int SifSecrDownloadHeaderThreadID;
40static int SifSecrDownloadBlockThreadID;
41static int SifSecrDownloadGetKbitThreadID;
42static int SifSecrDownloadGetKcThreadID;
43static int SifSecrDownloadGetICVPS2ThreadID;
44static int SifSecrDiskBootHeaderThreadID;
45static int SifSecrDiskBootBlockThreadID;
47static unsigned char SifServerBuffer[0x1000];
49static void *SifSecrDownloadHeader(
int function,
void *buffer,
int nbytes)
58static void *SifSecrDownloadBlockHandler(
int function,
void *buffer,
int nbytes)
67static void *SifSecrDownloadGetKbitHandler(
int function,
void *buffer,
int nbytes)
76static void *SifSecrDownloadGetKcHandler(
int function,
void *buffer,
int nbytes)
84static void *SifSecrDownloadGetICVPS2Handler(
int function,
void *buffer,
int nbytes)
93static void *SifSecrDiskBootHeaderHandler(
int function,
void *buffer,
int nbytes)
102static void *SifSecrDiskBootBlockHandler(
int function,
void *buffer,
int nbytes)
113static void SifSecrDownloadHeaderThread(
void *parameters)
117 if (!sceSifCheckInit()) {
118 DPRINTF(
"yet sif hasn't been init\n");
123 sceSifSetRpcQueue(&SifSecrDownloadHeaderQD, GetThreadId());
124 sceSifRegisterRpc(&SifSecrDownloadHeaderData, SECRSIF_DOWNLOAD_HEADER, &SifSecrDownloadHeader, SifServerBuffer, NULL, NULL, &SifSecrDownloadHeaderQD);
125 sceSifRpcLoop(&SifSecrDownloadHeaderQD);
128static void SifSecrDownloadBlockThread(
void *parameters)
132 if (!sceSifCheckInit()) {
133 DPRINTF(
"yet sif hasn't been init\n");
138 sceSifSetRpcQueue(&SifSecrDownloadBlockQD, GetThreadId());
139 sceSifRegisterRpc(&SifSecrDownloadBlockData, SECRSIF_DOWNLOAD_BLOCK, &SifSecrDownloadBlockHandler, SifServerBuffer, NULL, NULL, &SifSecrDownloadBlockQD);
140 sceSifRpcLoop(&SifSecrDownloadBlockQD);
143static void SifSecrDownloadGetKbitThread(
void *parameters)
147 if (!sceSifCheckInit()) {
148 DPRINTF(
"yet sif hasn't been init\n");
153 sceSifSetRpcQueue(&SifSecrDownloadGetKbitQD, GetThreadId());
154 sceSifRegisterRpc(&SifSecrDownloadGetKbitData, SECRSIF_DOWNLOAD_GET_KBIT, &SifSecrDownloadGetKbitHandler, SifServerBuffer, NULL, NULL, &SifSecrDownloadGetKbitQD);
155 sceSifRpcLoop(&SifSecrDownloadGetKbitQD);
158static void SifSecrDownloadGetKcThread(
void *parameters)
162 if (!sceSifCheckInit()) {
163 DPRINTF(
"yet sif hasn't been init\n");
168 sceSifSetRpcQueue(&SifSecrDownloadGetKcQD, GetThreadId());
169 sceSifRegisterRpc(&SifSecrDownloadGetKcData, SECRSIF_DOWNLOAD_GET_KC, &SifSecrDownloadGetKcHandler, SifServerBuffer, NULL, NULL, &SifSecrDownloadGetKcQD);
170 sceSifRpcLoop(&SifSecrDownloadGetKcQD);
173static void SifSecrDownloadGetICVPS2Thread(
void *parameters)
177 if (!sceSifCheckInit()) {
178 DPRINTF(
"yet sif hasn't been init\n");
183 sceSifSetRpcQueue(&SifSecrDownloadGetICVPS2QD, GetThreadId());
184 sceSifRegisterRpc(&SifSecrDownloadGetICVPS2Data, SECRSIF_DOWNLOAD_GET_ICVPS2, &SifSecrDownloadGetICVPS2Handler, SifServerBuffer, NULL, NULL, &SifSecrDownloadGetICVPS2QD);
185 sceSifRpcLoop(&SifSecrDownloadGetICVPS2QD);
188static void SifSecrDiskBootHeaderThread(
void *parameters)
192 if (!sceSifCheckInit()) {
193 DPRINTF(
"yet sif hasn't been init\n");
198 sceSifSetRpcQueue(&SifSecrDiskBootHeaderQD, GetThreadId());
199 sceSifRegisterRpc(&SifSecrDiskBootHeaderData, SECRSIF_DISK_BOOT_HEADER, &SifSecrDiskBootHeaderHandler, SifServerBuffer, NULL, NULL, &SifSecrDiskBootHeaderQD);
200 sceSifRpcLoop(&SifSecrDiskBootHeaderQD);
203static void SifSecrDiskBootBlockThread(
void *parameters)
207 if (!sceSifCheckInit()) {
208 DPRINTF(
"yet sif hasn't been init\n");
213 sceSifSetRpcQueue(&SifSecrDiskBootBlockQD, GetThreadId());
214 sceSifRegisterRpc(&SifSecrDiskBootBlockData, SECRSIF_DISK_BOOT_BLOCK, &SifSecrDiskBootBlockHandler, SifServerBuffer, NULL, NULL, &SifSecrDiskBootBlockQD);
215 sceSifRpcLoop(&SifSecrDiskBootBlockQD);
218int _start(
int argc,
char *argv[])
225 if (RegisterLibraryEntries(&_exp_secrsif) != 0) {
226 return MODULE_NO_RESIDENT_END;
233 thread.thread = &SifSecrDownloadHeaderThread;
234 if ((SifSecrDownloadHeaderThreadID = CreateThread(&
thread)) == 0) {
235 return MODULE_NO_RESIDENT_END;
238 StartThread(SifSecrDownloadHeaderThreadID, NULL);
240 thread.thread = &SifSecrDownloadBlockThread;
241 if ((SifSecrDownloadBlockThreadID = CreateThread(&
thread)) == 0) {
242 return MODULE_NO_RESIDENT_END;
245 StartThread(SifSecrDownloadBlockThreadID, NULL);
247 thread.thread = &SifSecrDownloadGetKbitThread;
248 if ((SifSecrDownloadGetKbitThreadID = CreateThread(&
thread)) == 0) {
249 return MODULE_NO_RESIDENT_END;
252 StartThread(SifSecrDownloadGetKbitThreadID, NULL);
254 thread.thread = &SifSecrDownloadGetKcThread;
255 if ((SifSecrDownloadGetKcThreadID = CreateThread(&
thread)) == 0) {
256 return MODULE_NO_RESIDENT_END;
259 StartThread(SifSecrDownloadGetKcThreadID, NULL);
261 thread.thread = &SifSecrDownloadGetICVPS2Thread;
262 if ((SifSecrDownloadGetICVPS2ThreadID = CreateThread(&
thread)) == 0) {
263 return MODULE_NO_RESIDENT_END;
266 StartThread(SifSecrDownloadGetICVPS2ThreadID, NULL);
268 thread.thread = &SifSecrDiskBootHeaderThread;
269 if ((SifSecrDiskBootHeaderThreadID = CreateThread(&
thread)) == 0) {
270 return MODULE_NO_RESIDENT_END;
273 StartThread(SifSecrDiskBootHeaderThreadID, NULL);
275 thread.thread = &SifSecrDiskBootBlockThread;
276 if ((SifSecrDiskBootBlockThreadID = CreateThread(&
thread)) == 0) {
277 return MODULE_NO_RESIDENT_END;
280 StartThread(SifSecrDiskBootBlockThreadID, NULL);
282 return MODULE_RESIDENT_END;