SifLoadElf problem

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
vegito-93
Posts: 12
Joined: Sat Feb 18, 2006 10:36 am

SifLoadElf problem

Post by vegito-93 »

k i tried a simple:

Code: Select all

t_ExecData elfdata;
.............................//all the other code
SifLoadElf(path,&elfdata);
and it returned -1.
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 &#40;ret < 0&#41;
        &#123;
                
                LoadExecPS2&#40;"", 0, NULL&#41;;
                &#125;
     SleepThread;

	return 0;
&#125;
Everything goes fine until StartThread(); is called. HELP!!!
vegito-93
Posts: 12
Joined: Sat Feb 18, 2006 10:36 am

Post by vegito-93 »

I really need to get this right. Anyone know what i am doing wrong.
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

You may want to start with error checking the sifloadelf call...

It looks like you ripped this code straight out of ps2link, except you removed all the error checking code... why?
Shoot Pixels Not People!
Makeshift Development
vegito-93
Posts: 12
Joined: Sat Feb 18, 2006 10:36 am

Post by vegito-93 »

i had some error checks before but for some reason i removed them. I will put them on again.
*EDIT*
Well i just put all the checks back and for some reason it worked. Now if u don't mind i got a random. Might be crazy.

When an elf is runing, are all the comands, calls and everything else runing from the ee not the iop?
Post Reply