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 

Load ELF files with sceKernelLoadExec
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
pspkrazy



Joined: 04 Jul 2005
Posts: 49

PostPosted: Sun Jul 24, 2005 3:04 am    Post subject: thanks Reply with quote

Thanks shazz for your great explanation.

It seems that I missed some things!

I was sure that BOOT.BIN was an ELF file ?!

I will shut up next time ! :)
Back to top
View user's profile Send private message
Shazz



Joined: 31 Aug 2004
Posts: 244
Location: Somewhere over the rainbow

PostPosted: Sun Jul 24, 2005 6:12 am    Post subject: Reply with quote

no no !!!! Thanks to your idea, I leanrt plenty of things and as Tyranid told me, we never thought it could be possible to run an plain elf using Load/StartModule... either if it seems to be redirected to LoadExec...

By the way, with Placasoft, we played with it and we have a UMD game screenshot dumper which nearly works (the image is corrupted due to the 'slowness' of writing a file) for games (as BOOT.BIN is not a plain elf but a true PRX)

So the future is simple, stop creating ELF ! Time to learn how to create PRX !!!!

So PSPKrazy, don't shut up :D Continue to have such good ideas !
_________________
- TiTAN Art Division -
http://www.titandemo.org
Back to top
View user's profile Send private message Visit poster's website
CyberBill



Joined: 26 Jul 2005
Posts: 86
Location: Redmond, WA

PostPosted: Wed Jul 27, 2005 5:49 pm    Post subject: Reply with quote

I'm trying to figure out this stuff. Will this work:

Code:


PSP_MODULE_INFO("Blah", 0x1000, 1, 1);   // 0x1000 = Kernel MODE
PSP_MAIN_THREAD_ATTR(0); // 0 for kernel mode too

int main(void)

        //THIS??
   //sceKernelLoadExec("ms0:/PSP_GAME/SYSDIR/boot.elf",0);

        //Or this??
   int exec_p = sceKernelLoadModule("ms0:/PSP_GAME/SYSDIR/boot.elf", 0, 0);
   sceKernelStartModule(exec_p, 0, 0, 0, 0);

   return 0;
}



Well, no, it wont.. but I dont know why. hehe :)

-Bill
Back to top
View user's profile Send private message AIM Address MSN Messenger
reigel



Joined: 15 Jul 2005
Posts: 14

PostPosted: Wed Jul 27, 2005 7:57 pm    Post subject: Reply with quote

both will work!
Back to top
View user's profile Send private message
CyberBill



Joined: 26 Jul 2005
Posts: 86
Location: Redmond, WA

PostPosted: Sat Jul 30, 2005 2:31 pm    Post subject: Reply with quote

The first one *does* work... not sure what I was doing wrong the last time. The 2nd one doesnt... not sure why.

Oh, and it loads .elf files.

I didnt try to load any pbp files.... whats the point. :P

-Bill
Back to top
View user's profile Send private message AIM Address MSN Messenger
ooPo
Site Admin


Joined: 17 Jan 2004
Posts: 2032
Location: Canada

PostPosted: Sat Jul 30, 2005 4:28 pm    Post subject: Reply with quote

About this:

Code:
int exec_p = sceKernelLoadModule("ms0:/PSP_GAME/SYSDIR/boot.elf", 0, 0);

I know you're going to fool around with it anyway, but could you at least pretend you're not trying to run a game you've copied to the memory card? Maybe change the path a little when you're pasting code to these forums?

You know, attempt to follow the rules or something?

Unbelievable.
Back to top
View user's profile Send private message Visit poster's website
MiKA-



Joined: 04 Mar 2006
Posts: 6

PostPosted: Tue Mar 07, 2006 1:02 am    Post subject: Reply with quote

Hi, I have a little problem loading .elf's from Memory Stick, and I hope that somebody could help me.

Ok, so I was going to make myself a little sample program which would load an emulator from Memory Stick. I extracted the DATA.PSP from the EBOOT.PBP of the emulator, and renamed that to EMU.ELF (Isn't this right?). Now, my code looks like this:

Code:
// Kernel Mode
PSP_MODULE_INFO("EMULATOR", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(0);

.
.
.

and in main it's just like this:

sceKernelLoadExec("ms0:/EMULATORS/EMU.ELF",0);


The program compiles OK, no errors or anything, but it doesn't work on my 1.5 PSP. All I have is a black screen, memstick light flashes couple of times, then it gets back to XMB. For some emus it doesn't give any error, but with some it gives "80020001". Does somebody know what's wrong and how I could succesfully load that .ELF -file?


EDIT:
It would help if I'd get a sample code somewhere which would just load an .ELF/.PBP from memory stick, so if somebody knows where to get that kind of source, please post it here :)
Back to top
View user's profile Send private message
MiKA-



Joined: 04 Mar 2006
Posts: 6

PostPosted: Tue Mar 14, 2006 7:18 am    Post subject: Reply with quote

Could anybody help me and tell me an answer to the question above this post, how could I load my emulators from memory stick with my own program?.
Back to top
View user's profile Send private message
MiKA-



Joined: 04 Mar 2006
Posts: 6

PostPosted: Fri Mar 31, 2006 7:17 am    Post subject: Reply with quote

Sorry for double posting, but what should I put into my code so it would print "File doesn't exist" or something like that if the file doesn't actually exist? In my code, I'm loading ms0:/EBOOT.PBP with SceKernelLoadExec when pressing X.
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Fri Mar 31, 2006 5:11 pm    Post subject: Reply with quote

MiKA- wrote:
Sorry for double posting, but what should I put into my code so it would print "File doesn't exist" or something like that if the file doesn't actually exist? In my code, I'm loading ms0:/EBOOT.PBP with SceKernelLoadExec when pressing X.



Code:

int FileExists(char *path)
{
    SceIoStat stat;

    return (sceIoGetstat(path, &stat) >= 0)
   
}

void yourfunction(char *yourfile)
{
    struct SceKernelLoadExecParam param;

    if (!FileExists(yourfile))
    {
        printf("File doesn't exist");
        return;
    }

    memset(&param, 0, sizeof(param));
    param.size = sizeof(param);
    param.args = strlen(yourfile) + 1;
    param.argp = yourfile;

    sceKernelLoadExec(yourfile, &param);
}


Well, more or less.
Back to top
View user's profile Send private message
MiKA-



Joined: 04 Mar 2006
Posts: 6

PostPosted: Fri Mar 31, 2006 7:34 pm    Post subject: Reply with quote

moonlight wrote:

Code:

Some code
.
.
.


Well, more or less.


As I'm just a beginner, I don't actually know how to use this code :( I've read all the Yeldarb tutorials and just borrowed a C-programming book from the library, so I don't know much about coding, yet. And because of that, I don't understand how do I define the path "ms0:/EBOOT.PBP" to this piece of code? If somebody can still teach me little more, I'll be happy.
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Sat Apr 01, 2006 9:36 am    Post subject: Reply with quote

in your C book look up how pointers are
used in a functions argument list and why

but example lets use first function moonlight posted
Code:
int FileExists(char *path)
{
    SceIoStat stat;

    return (sceIoGetstat(path, &stat) >= 0)
   
}

the function argument char *path is a string pointer
to path of your file to check if it exists
and anytime the pointer path is used your string
array is replaced ... using ms0:/EBOOT.PBP for example
the above function works like this
Code:
int FileExists("ms0:/EBOOT.PBP")
{
    SceIoStat stat;

    return (sceIoGetstat("ms0:/EBOOT.PBP", &stat) >= 0)
   
}

so if you add above function before main()
then you will be able to use it like so in your program
using pseudo code below
Code:

int main(int argc, char* argv[]) {
....
//check if file exists at root of psp
FileExists("ms0:/EBOOT.PBP");
...
//if it does run the file
yourfunction("ms0:/EBOOT.PBP");
...


you must take into affect the return status of one of the
sceIoGetstat() status return codes and if file exist from
returned success code then making a simple check against
this number is simple and and yourfunction() can run only
if FileExists() returned positive return ...that i leave to you
and keep reading on with C book and dont just read one
and go by it religiously ...read as many articles and books
on the language as time should allow ...any language takes
practice and so does C
_________________
10011011 00101010 11010111 10001001 10111010
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 -> PSP Development All times are GMT + 10 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
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