Code: Select all
t_ExecData elfdata;
.............................//all the other code
SifLoadElf(path,&elfdata);
Whats wrong
*EDIT*
ok i got around that but ran into another problem.
The complete code:
Code: Select all
int userThreadID = 0;
static char userThreadStack[16*1024] __attribute__((aligned(16)));
#define MAX_ARGS 16
#define MAX_ARGLEN 256
struct argData
{
int flag; // Contains thread id atm
int argc;
char *argv[MAX_ARGS];
} __attribute__((packed)) userArgs;
const char *testmode = "rom0:TESTMODE";
t_ExecData elfdata;
static int
pkoLoadElf(char *path)
{
ee_thread_t th_attr;
int ret=0;
int pid;
SifLoadElf(path, &elfdata);
FlushCache(0);
FlushCache(2);
th_attr.func = (void *)elfdata.epc;
th_attr.stack = userThreadStack;
th_attr.stack_size = sizeof(userThreadStack);
th_attr.gp_reg = (void *)elfdata.gp;
th_attr.initial_priority = 64;
pid = CreateThread(&th_attr);
return pid;
}
int main(int argc, char **argv)
{
int pid=-1,ret;
pkoLoadElf(testmode);
FlushCache(0);
FlushCache(2);
userThreadID = pid;
userArgs.argc=1;
userArgs.argv[0]=testmode;
userArgs.flag = (int)&userThreadID;
ret = StartThread(userThreadID, &userArgs); //Returns -1
if (ret < 0)
{
LoadExecPS2("", 0, NULL);
}
SleepThread;
return 0;
}