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 

Loading a Kernl Mod. in Buffer from Kernel Module FAILS??!

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



Joined: 03 Jun 2007
Posts: 328

PostPosted: Fri Oct 03, 2008 11:07 am    Post subject: Loading a Kernl Mod. in Buffer from Kernel Module FAILS??! Reply with quote

sceKernelLoadModuleBuffer only works from Kernel mode module... That is why I'm trying to load Kernel Module in Buffer From a Kernel Module

This isn't working? Please help. :(

This is the buffer which is passed from User module.
Code:


static unsigned int size_KBUF = 2046;
static unsigned char KBUF[] __attribute__((aligned(64))) = {DATA here };

main()
{
loadMyBufModule(KBUF (also tried &KBUF),size_KBUF,PSP_MEMORY_PARTITION_KERNEL,0,NULL)
}



The following code is an export from a kernel module:
Code:

int loadMyBufModule(char **buf ([i]also tried *buf,*buf[][/i]), int size, int mpid, int argc, char * const argv[])
{
    u32 k1;

    k1 = pspSdkSetK1(0);

        SceKernelLMOption option;
        SceUID modid = 0;
        int retVal = 0, mresult;
        char args[5]; //unused
        int  argpos = 0;
        int  i;

//         memset(args, 0, MAX_ARGS);
//        strcpy(args, buf);
//        argpos += size + 1;
//        for(i = 0; (i < argc) && (argpos < MAX_ARGS); i++)
//        {
//                int len;
//
//                sprintf(&args[argpos], "%s", argv[i]);
//                len = strlen(&args[argpos]);
//                argpos += len + 1;
//        }
//

        option.size = sizeof(option);
        option.mpidtext = mpid;
        option.mpiddata = mpid;
        option.position = 0;
        option.access = 1;

        retVal = sceKernelLoadModuleBuffer(buf, size, 0, &option);
        if(retVal < 0){
                return retVal;
        }

        modid = retVal;

        retVal = sceKernelStartModule(modid, 0, NULL, &mresult, NULL);
        if(retVal < 0){
                return retVal;
        }

         pspSdkSetK1(k1);
        return modid;
}


When the Export is called:

Code:

host0:/flipxmbauth/> Exception - Address load/inst fetch
Thread ID - 0x00CCD21F
Th Name   - SceKernelModmgrWorker
Module ID - 0x00CC6F2B
Mod Name  - SystemControl
EPC       - 0x880668E8
Cause     - 0x10000010
BadVAddr  - 0x000007FE
Status    - 0x00088603
zr:0x00000000 at:0xDEADBEEF v0:0x00000001 v1:0x00000001
a0:0x000007FE a1:0x882FA690 a2:0x00000000 a3:0x00000000
t0:0x882FA750 t1:0x00000000 t2:0x882FA750 t3:0x00000000
t4:0x00000000 t5:0x00000000 t6:0x00000000 t7:0x00000000
s0:0x882FA690 s1:0x000007FE s2:0x882FA690 s3:0xDEADBEEF
s4:0x88224224 s5:0xDEADBEEF s6:0x882FA7E0 s7:0x00000000
t8:0x00000000 t9:0x88300000 k0:0x00000000 k1:0x00000000
gp:0x8806C6D0 sp:0x882FA420 fp:0x882FA760 ra:0x88067E24
0x880668E8: 0x8C830000 '....' - lw         $v1, 0($a0)
reset

_________________
Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Fri Oct 03, 2008 2:33 pm    Post subject: Reply with quote

under LMOption, int retVal = 0, mresult; // what is mresult //
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
KickinAezz



Joined: 03 Jun 2007
Posts: 328

PostPosted: Fri Oct 03, 2008 10:48 pm    Post subject: Reply with quote

dot_blank wrote:
under LMOption, int retVal = 0, mresult; // what is mresult //

it's the modded code from pspSdkLoadStartModule...
_________________
Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Sat Oct 04, 2008 12:19 am    Post subject: Reply with quote

read that line again and notice comma between two values that would get stored into ONE int ... look really hard
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
KickinAezz



Joined: 03 Jun 2007
Posts: 328

PostPosted: Sat Oct 04, 2008 8:05 am    Post subject: Reply with quote

dot_blank wrote:
read that line again and notice comma between two values that would get stored into ONE int ... look really hard


http://psp.jim.sh/svn/filedetails.php?repname=psp&path=%2Ftrunk%2Fpspsdk%2Fsrc%2Fsdk%2Floadmodule.c

The only use of mresult is to store the result....
_________________
Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.
Back to top
View user's profile Send private message
cory1492



Joined: 10 Dec 2004
Posts: 216

PostPosted: Sun Oct 05, 2008 4:56 am    Post subject: Reply with quote

dot_blank wrote:
read that line again and notice comma between two values that would get stored into ONE int ... look really hard

Code:
int var1 =2, var3, var4 = 0, var5, var6, var7 = 1;

though it's generally bad programming practice to declare uninitialized variables along with initialized ones, it works just fine to declare multiple int variables in such a fashion. Doesn't require hard looking at all...

KickinAezz:
It helps to use the search here and try your exception cause (0x10000010) as the search parameter.
http://forums.ps2dev.org/viewtopic.php?t=10328&highlight=0x10000010
See tyranid's reply towards the bottom of that thread, might help you out (along with the info on using partition alloc.)

On that note, is there any documentation/notes that apply to the exception info that would help decipher the info it gives? More specifically cause and status?
Back to top
View user's profile Send private message
KickinAezz



Joined: 03 Jun 2007
Posts: 328

PostPosted: Sun Oct 05, 2008 7:18 am    Post subject: Reply with quote

cory1492 wrote:
dot_blank wrote:
read that line again and notice comma between two values that would get stored into ONE int ... look really hard

Code:
int var1 =2, var3, var4 = 0, var5, var6, var7 = 1;

though it's generally bad programming practice to declare uninitialized variables along with initialized ones, it works just fine to declare multiple int variables in such a fashion. Doesn't require hard looking at all...

KickinAezz:
It helps to use the search here and try your exception cause (0x10000010) as the search parameter.
http://forums.ps2dev.org/viewtopic.php?t=10328&highlight=0x10000010
See tyranid's reply towards the bottom of that thread, might help you out (along with the info on using partition alloc.)

On that note, is there any documentation/notes that apply to the exception info that would help decipher the info it gives? More specifically cause and status?


Will try that at my earliest convenience (size first, then *buf)

--

Why doesn't tyranid upgrade PSPLINK to show CAUSE's Descriptive text? :(
_________________
Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sun Oct 05, 2008 8:53 am    Post subject: Reply with quote

"Exception - Address load/inst fetch" wasn't clear enough for you, for fucks sake.

The error says it is a load exception, i.e. you gave a garbage address to something. The faulting instruction is a load word from $a0 and $a0 is set to 0x7FE and obvious garbage address. No doubt you could have then looked at your code and probably found your module was that length and you could have worked this out yourself. Damn if people can't read an exception dump they shouldn't be coding in kernel mode at all....

Find yourself a MIPS manual which should tell you about all the exception stuff you need (they are mostly the same in all MIPS revisions).
Back to top
View user's profile Send private message
KickinAezz



Joined: 03 Jun 2007
Posts: 328

PostPosted: Sun Oct 05, 2008 12:32 pm    Post subject: Reply with quote

TyRaNiD wrote:
"Exception - Address load/inst fetch" wasn't clear enough for you, for fucks sake.

The error says it is a load exception, i.e. you gave a garbage address to something. The faulting instruction is a load word from $a0 and $a0 is set to 0x7FE and obvious garbage address. No doubt you could have then looked at your code and probably found your module was that length and you could have worked this out yourself. Damn if people can't read an exception dump they shouldn't be coding in kernel mode at all....

Find yourself a MIPS manual which should tell you about all the exception stuff you need (they are mostly the same in all MIPS revisions).
You got too serious. I never thought CAUSE's description was the one shown during an exception, my mistake!

Quote:
Damn if people can't read an exception dump they shouldn't be coding in kernel mode at all....


I never had to interpret Crash dumps because I code that good. And, they only occur during years that end with a 8 and very Rarely too.

Creating creative applications doesn't need that we have to write bad code (using trial and error) and end up with crashes like most people.

===

And WHY Why is the wrong prototype
Code:
sceKernelLoadExecBufferPlain(SceSize bufsize, void *buf, struct SceKernelLoadExecParam *param);
still in latest PSPSDK?
_________________
Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.
Back to top
View user's profile Send private message
cory1492



Joined: 10 Dec 2004
Posts: 216

PostPosted: Mon Oct 06, 2008 5:55 am    Post subject: Reply with quote

The 'wrong' prototype isn't in the SDK - if you are using a different firmware than the one you are using. As far as I can tell, it's still mainly geared towards 1.50 with a bit of 2.71 stuff in there.
TyRaNiD wrote:
Find yourself a MIPS manual which should tell you about all the exception stuff you need (they are mostly the same in all MIPS revisions).

Thanks for that TyRaNiD - I was mainly curious as to where you 'enumerated' it from yourself as any such document may well have further background info beyond a 1 liner ("MIPS32 Architecture For Programmers Volume III" - login required - has some great info on exceptions and interrupts.) Aiming for understanding, myself - though my search method mentioned above has gotten me out of a few binds (thanks to ps2dev gurus.)
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