forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SifLoadElf problem

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
vegito-93



Joined: 18 Feb 2006
Posts: 12

PostPosted: Mon Apr 03, 2006 10:30 am    Post subject: SifLoadElf problem Reply with quote

k i tried a simple:
Code:

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:
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;
}

Everything goes fine until StartThread(); is called. HELP!!!
Back to top
View user's profile Send private message
vegito-93



Joined: 18 Feb 2006
Posts: 12

PostPosted: Sat Apr 08, 2006 8:39 am    Post subject: Reply with quote

I really need to get this right. Anyone know what i am doing wrong.
Back to top
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Sat Apr 08, 2006 11:56 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
vegito-93



Joined: 18 Feb 2006
Posts: 12

PostPosted: Sat Apr 08, 2006 12:22 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group