11#include "eeelfloader.h"
12#include "irx_imports.h"
17IRX_ID(
"LoadModuleByEE", 2, 2);
21static void loadfile_rpc_service_thread(
void *param);
23int _start(
int argc,
char *argv[])
25 const int *BootMode_3;
33 BootMode_3 = QueryBootMode(3);
38 BootMode_3_1 = BootMode_3[1];
39 if ( (BootMode_3_1 & 1) != 0 )
41 printf(
" No SIF service(loadfile)\n");
42 return MODULE_NO_RESIDENT_END;
44 if ( (BootMode_3_1 & 2) != 0 )
46 printf(
" No LoadFile service\n");
47 return MODULE_NO_RESIDENT_END;
51 thparam.attr = 0x2000000;
52 thparam.thread = loadfile_rpc_service_thread;
53 thparam.priority = 88;
54 thparam.stacksize = 4096;
56 thid = CreateThread(&thparam);
59 return MODULE_NO_RESIDENT_END;
62 return MODULE_RESIDENT_END;
65static int *loadfile_modload(
const struct _lf_module_load_arg *in_packet,
int length,
int *outbuffer)
71 path = in_packet->path;
72 if ( IsIllegalBootDevice(path) )
74 outbuffer[0] = KE_ILLEGAL_OBJECT;
78 printf(
"loadmodule: fname %s args %d arg %s\n", path, in_packet->p.arg_len, in_packet->args);
79 outbuffer[0] = LoadStartModule(path, in_packet->p.arg_len, in_packet->args, &outbuffer[1]);
80 printf(
"loadmodule: id %d, ret %d\n", outbuffer[0], outbuffer[1]);
85static int *loadfile_elfload(
const struct _lf_elf_load_arg *in_packet,
int length,
int *outbuffer)
89 int result_module_out;
93 path = in_packet->path;
94 if ( IsIllegalBootDevice(path) )
96 outbuffer[0] = KE_FILEERR;
100 printf(
"loadelf: fname %s secname %s\n", path, in_packet->secname);
102 loadfile_elfload_innerproc(path, in_packet->epc, in_packet->secname, &result_out, &result_module_out);
103 if ( outbuffer[0] >= 0 )
106 outbuffer[0] = result_out;
107 outbuffer[1] = result_module_out;
111 outbuffer[3] = outbuffer[0];
118static int *loadfile_setaddr(
const struct _lf_iop_val_arg *in_packet,
int length,
int *outbuffer)
125 iop_addr = (
void *)in_packet->p.iop_addr;
126 type = in_packet->type;
130 *(u8 *)iop_addr = in_packet->val.b;
133 *(u16 *)iop_addr = in_packet->val.s;
136 *(u32 *)iop_addr = in_packet->val.l;
145static int *loadfile_getaddr(
const struct _lf_iop_val_arg *in_packet,
int length,
int *outbuffer)
152 iop_addr = (
void *)in_packet->p.iop_addr;
153 type = in_packet->type;
157 outbuffer[0] = *(u8 *)iop_addr;
160 outbuffer[0] = *(u16 *)iop_addr;
163 outbuffer[0] = *(u32 *)iop_addr;
171static int *loadfile_mg_modload(
const struct _lf_module_load_arg *in_packet,
int length,
int *outbuffer)
175 outbuffer[0] = LoadStartKelfModule(in_packet->path, in_packet->p.arg_len, in_packet->args, &outbuffer[1]);
179static int *loadfile_mg_elfload(
const struct _lf_elf_load_arg *in_packet,
int length,
int *outbuffer)
182 int result_module_out;
187 loadfile_mg_elfload_proc(in_packet->path, in_packet->epc, in_packet->secname, &result_out, &result_module_out);
188 if ( outbuffer[0] >= 0 )
191 outbuffer[0] = result_out;
192 outbuffer[1] = result_module_out;
208 ModuleBuffer = LoadModuleBuffer(in_packet->p.ptr);
209 if ( ModuleBuffer >= 0 )
211 outbuffer[0] = StartModule(ModuleBuffer,
"LBbyEE", in_packet->q.arg_len, in_packet->args, &outbuffer[1]);
215 outbuffer[0] = ModuleBuffer;
221static int *loadfile_stopmodule(
struct _lf_module_stop_arg *in_packet,
int length,
int *outbuffer)
225 outbuffer[0] = StopModule(in_packet->p.id, in_packet->q.arg_len, in_packet->args, &outbuffer[1]);
234 outbuffer[0] = UnloadModule(in_packet->id);
243 outbuffer[0] = SearchModuleByName(in_packet->name);
253 outbuffer[0] = SearchModuleByAddress(in_packet->p.ptr);
258static int *loadfile_get_version(
void *in_packet,
int length,
int *outbuffer)
263 ((u32 *)(outbuffer))[0] = 0x30303133;
269static int *loadfile_rpc_service_handler(
int fno,
void *buffer,
int length)
274 return loadfile_modload((
struct _lf_module_load_arg *)buffer, length, loadfile_rpc_outbuf);
276 return loadfile_elfload((
struct _lf_elf_load_arg *)buffer, length, loadfile_rpc_outbuf);
278 return loadfile_setaddr((
struct _lf_iop_val_arg *)buffer, length, loadfile_rpc_outbuf);
280 return loadfile_getaddr((
struct _lf_iop_val_arg *)buffer, length, loadfile_rpc_outbuf);
281 case LF_F_MG_MOD_LOAD:
282 return loadfile_mg_modload((
struct _lf_module_load_arg *)buffer, length, loadfile_rpc_outbuf);
283 case LF_F_MG_ELF_LOAD:
284 return loadfile_mg_elfload((
struct _lf_elf_load_arg *)buffer, length, loadfile_rpc_outbuf);
285 case LF_F_MOD_BUF_LOAD:
288 return loadfile_stopmodule((
struct _lf_module_stop_arg *)buffer, length, loadfile_rpc_outbuf);
289 case LF_F_MOD_UNLOAD:
291 case LF_F_SEARCH_MOD_BY_NAME:
293 case LF_F_SEARCH_MOD_BY_ADDRESS:
294 return loadfile_searchmodulebyaddress(
296 case LF_F_GET_VERSION:
297 return loadfile_get_version((
void *)buffer, length, loadfile_rpc_outbuf);
307static void loadfile_rpc_service_thread(
void *param)
311 printf(
"Load File service.(99/11/05)\n");
313 sceSifSetRpcQueue(&loadfile_rpc_service_queue, GetThreadId());
315 &loadfile_rpc_service_data,
317 (SifRpcFunc_t)loadfile_rpc_service_handler,
318 loadfile_rpc_service_in_buf,
321 &loadfile_rpc_service_queue);
322 sceSifRpcLoop(&loadfile_rpc_service_queue);