29extern int _iop_reboot_count;
33int _SifLoadElfPart(
const char *path,
const char *secname,
t_ExecData *data,
int fno);
34int _SifLoadModuleBuffer(
void *ptr,
int arg_len,
const char *args,
int *modres);
36#if defined(F_SifLoadFileInit)
43 static int _rb_count = 0;
44 if (_rb_count != _iop_reboot_count) {
45 _rb_count = _iop_reboot_count;
46 memset(&_lf_cd, 0,
sizeof _lf_cd);
55 while ((res = SifBindRpc(&_lf_cd, 0x80000006, 0)) >= 0 && !_lf_cd.server)
66#if defined(F_SifLoadFileExit)
70 memset(&_lf_cd, 0,
sizeof _lf_cd);
74#ifdef F__SifLoadModule
75int _SifLoadModule(
const char *path,
int arg_len,
const char *args,
int *modres,
76 int fno,
int dontwait)
83 memset(&arg, 0,
sizeof arg);
85 strncpy(arg.path, path, LF_PATH_MAX - 1);
86 arg.path[LF_PATH_MAX - 1] = 0;
88 if (args && arg_len) {
89 arg.p.arg_len = arg_len > LF_ARG_MAX ? LF_ARG_MAX : arg_len;
90 memcpy(arg.args, args, arg.p.arg_len);
95 if (SifCallRpc(&_lf_cd, fno, dontwait, &arg,
sizeof arg, &arg, 8, NULL, NULL) < 0)
105#if defined(F_SifLoadModule)
106int SifLoadModule(
const char *path,
int arg_len,
const char *args)
108 return _SifLoadModule(path, arg_len, args, NULL, LF_F_MOD_LOAD, 0);
112#if defined(F_SifLoadStartModule)
115 return _SifLoadModule(path, arg_len, args, mod_res, LF_F_MOD_LOAD, 0);
119#if defined(F_SifLoadModuleEncrypted)
122 return _SifLoadModule(path, arg_len, args, NULL, LF_F_MG_MOD_LOAD, 0);
126#ifdef F_SifStopModule
127int SifStopModule(
int id,
int arg_len,
const char *args,
int *mod_res)
136 if (args && arg_len) {
137 arg.q.arg_len = arg_len > LF_ARG_MAX ? LF_ARG_MAX : arg_len;
138 memcpy(arg.args, args, arg.q.arg_len);
143 if (SifCallRpc(&_lf_cd, LF_F_MOD_STOP, 0, &arg,
sizeof arg, &arg, 8, NULL, NULL) < 0)
147 *mod_res = arg.q.modres;
153#ifdef F_SifUnloadModule
154int SifUnloadModule(
int id)
163 if (SifCallRpc(&_lf_cd, LF_F_MOD_UNLOAD, 0, &arg,
sizeof arg, &arg, 4, NULL, NULL) < 0)
170#ifdef F_SifSearchModuleByName
171int SifSearchModuleByName(
const char *name)
177 strncpy(arg.name, name, LF_PATH_MAX - 1);
178 arg.name[LF_PATH_MAX - 1] = 0;
180 if (SifCallRpc(&_lf_cd, LF_F_SEARCH_MOD_BY_NAME, 0, &arg,
sizeof arg, &arg, 4, NULL, NULL) < 0)
187#ifdef F_SifSearchModuleByAddress
188int SifSearchModuleByAddress(
const void *ptr)
196 if (SifCallRpc(&_lf_cd, LF_F_SEARCH_MOD_BY_ADDRESS, 0, &arg,
sizeof arg, &arg, 4, NULL, NULL) < 0)
203#ifdef F__SifLoadElfPart
204int _SifLoadElfPart(
const char *path,
const char *secname,
t_ExecData *data,
int fno)
211 strncpy(arg.path, path, LF_PATH_MAX - 1);
212 strncpy(arg.secname, secname, LF_ARG_MAX - 1);
213 arg.path[LF_PATH_MAX - 1] = 0;
214 arg.secname[LF_ARG_MAX - 1] = 0;
216 if (SifCallRpc(&_lf_cd, fno, 0, &arg,
sizeof arg, &arg,
230#if defined(F_SifLoadElfPart)
233 return _SifLoadElfPart(path, secname, data, LF_F_ELF_LOAD);
237#if defined(F_SifLoadElf)
240 u32 secname = 0x6c6c61;
241 return _SifLoadElfPart(path, (
char *)&secname, data, LF_F_ELF_LOAD);
245#if defined(F_SifLoadElfEncrypted)
248 u32 secname = 0x6c6c61;
249 return _SifLoadElfPart(path, (
char *)&secname, data, LF_F_MG_ELF_LOAD);
253#if defined(F_SifIopSetVal)
263 arg.val.b = (u8)(val & 0xff);
266 arg.val.s = (u16)(val & 0xffff);
275 arg.p.iop_addr = iop_addr;
278 if (SifCallRpc(&_lf_cd, LF_F_SET_ADDR, 0, &arg,
sizeof arg, &arg, 4,
286#if defined(F_SifIopGetVal)
294 arg.p.iop_addr = iop_addr;
297 if (SifCallRpc(&_lf_cd, LF_F_GET_ADDR, 0, &arg,
sizeof arg, &arg, 4,
304 *(u8 *)val = (u8)arg.p.result & 0xff;
307 *(u16 *)val = (u16)arg.p.result & 0xffff;
310 *(u32 *)val = arg.p.result;
319#ifdef F__SifLoadModuleBuffer
320int _SifLoadModuleBuffer(
void *ptr,
int arg_len,
const char *args,
int *modres)
327 memset(&arg, 0,
sizeof arg);
330 if (args && arg_len) {
331 arg.q.arg_len = arg_len > LF_ARG_MAX ? LF_ARG_MAX : arg_len;
332 memcpy(arg.args, args, arg.q.arg_len);
337 if (SifCallRpc(&_lf_cd, LF_F_MOD_BUF_LOAD, 0, &arg,
sizeof arg, &arg, 8,
342 *modres = arg.q.modres;
348#if defined(F_SifLoadModuleBuffer)
351 return _SifLoadModuleBuffer(ptr, arg_len, args, NULL);
355#if defined(F_SifLoadStartModuleBuffer)
358 return _SifLoadModuleBuffer(ptr, arg_len, args, mod_res);
362#if defined(F_SifExecModuleBuffer)
371 size = (size + 15) & -16;
373 if (!(iop_addr = SifAllocIopHeap(size)))
377 dmat.dest = iop_addr;
380 SifWriteBackDCache(ptr, size);
381 qid = SifSetDma(&dmat, 1);
386 while (SifDmaStat(qid) >= 0)
389 res = _SifLoadModuleBuffer(iop_addr, arg_len, args, mod_res);
390 SifFreeIopHeap(iop_addr);
396#if defined(F_SifExecModuleFile)
397int SifExecModuleFile(
const char *path, u32 arg_len,
const char *args,
int *mod_res)
402 if ((fd = open(path, O_RDONLY)) < 0)
405 if ((size = lseek(fd, 0, SEEK_END)) < 0)
410 if (!(iop_addr = SifAllocIopHeap(size)))
413 if ((res = SifLoadIopHeap(path, iop_addr)) < 0) {
414 SifFreeIopHeap(iop_addr);
418 res = _SifLoadModuleBuffer(iop_addr, arg_len, args, mod_res);
419 SifFreeIopHeap(iop_addr);
int SifLoadModuleEncrypted(const char *path, int arg_len, const char *args)
int SifLoadModule(const char *path, int arg_len, const char *args)
int SifLoadStartModuleBuffer(void *ptr, int arg_len, const char *args, int *mod_res)
void SifLoadFileExit(void)
int SifLoadElf(const char *path, t_ExecData *data)
int SifLoadElfPart(const char *path, const char *secname, t_ExecData *data)
int SifLoadElfEncrypted(const char *path, t_ExecData *data)
int SifExecModuleBuffer(void *ptr, u32 size, u32 arg_len, const char *args, int *mod_res)
int SifLoadFileInit(void)
int SifIopSetVal(u32 iop_addr, int val, int type)
int SifExecModuleFile(const char *path, u32 arg_len, const char *args, int *mod_res)
int _SifLoadModule(const char *path, int arg_len, const char *args, int *modres, int fno, int dontwait)
int SifIopGetVal(u32 iop_addr, void *val, int type)
int SifLoadModuleBuffer(void *ptr, int arg_len, const char *args)
int SifLoadStartModule(const char *path, int arg_len, const char *args, int *mod_res)