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 PRX from Eboot

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



Joined: 24 Mar 2008
Posts: 25

PostPosted: Tue Jul 22, 2008 9:43 pm    Post subject: Load PRX from Eboot Reply with quote

Hi all,
I am trying to include prx files into my eboot using bin/o and then load them into kernel memory when they are needed.

i use this function to store the prx file in the eboot.

syslib.o : syslib.prx
bin2o -i syslib.prx syslib.o syslib

But how do i load if from the memory?
Regards
Homemister
Back to top
View user's profile Send private message
sakya



Joined: 28 Apr 2006
Posts: 190

PostPosted: Tue Jul 22, 2008 9:53 pm    Post subject: Reply with quote

Hi! :)

I never used bin2o, but if it works like bin2c it should declare a variable named as the label parameter:
Code:
static unsigned char label[] __attribute__((aligned(16)))


Ciaooo
Sakya
Back to top
View user's profile Send private message Visit poster's website
homemister



Joined: 24 Mar 2008
Posts: 25

PostPosted: Tue Jul 22, 2008 9:59 pm    Post subject: Reply with quote

how do you do bin2c?
Back to top
View user's profile Send private message
sakya



Joined: 28 Apr 2006
Posts: 190

PostPosted: Tue Jul 22, 2008 10:04 pm    Post subject: Reply with quote

Hi! :)

homemister wrote:
how do you do bin2c?

Almost the same way you used bin2o: :)
Code:
bin2c syslib.prx syslib.h syslib


And you get a header file with the declaration of
Code:
static unsigned char syslib[] __attribute__((aligned(16))) = {
....
};


Ciaooo
Sakya
Back to top
View user's profile Send private message Visit poster's website
homemister



Joined: 24 Mar 2008
Posts: 25

PostPosted: Wed Jul 23, 2008 7:35 pm    Post subject: Reply with quote

how do i then load it into the kernal memory?
Sorry for all of the trouble, but i have never done this before.
Back to top
View user's profile Send private message
sakya



Joined: 28 Apr 2006
Posts: 190

PostPosted: Wed Jul 23, 2008 9:11 pm    Post subject: Reply with quote

Hi! :)

homemister wrote:
how do i then load it into the kernal memory?
Sorry for all of the trouble, but i have never done this before.

Sorry, I don't know if it is possible to load a prx from memory and not from ms/flash.
If there's no way to do this I think you can at last save the data to a file and then load it. ;)

EDIT: Try to have a look to this function:
Code:
/**
 * Load a module from a buffer using the USB/WLAN API.
 *
 * Can only be called from kernel mode, or from a thread that has attributes of 0xa0000000.
 *
 * @param bufsize - Size (in bytes) of the buffer pointed to by buf.
 * @param buf - Pointer to a buffer containing the module to load.  The buffer must reside at an
 *              address that is a multiple to 64 bytes.
 * @param flags - Unused, always 0.
 * @param option - Pointer to an optional ::SceKernelLMOption structure.
 *
 * @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes.
 */
SceUID sceKernelLoadModuleBufferUsbWlan(SceSize bufsize, void *buf, int flags, SceKernelLMOption *option);


But if this function works only in kernel mode you'll need a kernel prx to use it...so the problem isn't solved. :)

Ciaooo
Sakya
Back to top
View user's profile Send private message Visit poster's website
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Thu Jul 31, 2008 12:06 pm    Post subject: Reply with quote

You can write the bin2o variable to a temporary file in ms0:/ and load it normally, then delete it.
Thats what IRShell does to continue running in the background after launching a game.
Back to top
View user's profile Send private message
homemister



Joined: 24 Mar 2008
Posts: 25

PostPosted: Thu Jul 31, 2008 6:38 pm    Post subject: Reply with quote

sorry for this question. But i am still learing about bin2c and bin2o.

How would i write the bin2o file to the memory stick?
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Fri Aug 01, 2008 12:22 am    Post subject: Reply with quote

In your program, in the global area, declare the following

extern unsigned char syslib_start[];
extern u32 syslib_size[];

Then you can write it to a file using sceIoWrite(fp, syslib_start, syslib_size);
Back to top
View user's profile Send private message
homemister



Joined: 24 Mar 2008
Posts: 25

PostPosted: Sat Aug 02, 2008 11:02 am    Post subject: Reply with quote

Thx verry much Torch.
Back to top
View user's profile Send private message
Mashphealh



Joined: 28 Nov 2007
Posts: 18

PostPosted: Thu Aug 07, 2008 2:44 am    Post subject: Reply with quote

You also can use this :

Code:

int LoadStartModuleBuffer(void *buffer, int size, int a2)
{
    SceUID v0 = vshKernelLoadModuleBufferVSH(size, buffer, 0, 0) < 0) return -1;
    if(v0 < 0)
           return -1;
           
    if(a2 == 0)
          return sceKernelStartModule(v0, 0, 0, 0, 0);
         
    return 0;
}


In my SDK, the function vshKernelLoad... hasn't been defined, so you can use a paralel function found at pspmodulemgr_kernel.h , his name is sceKernelLoadModuleBuffer.

Personally, I didn't test it function, and I don't know if that function will work in vsh mode.

The usage of LoadStartModuleBuffer is easy, just write LoadStartModuleBuffer(buffer, sizeof(buffer), 0);
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
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