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 

Kernel Module Can't be Started

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



Joined: 23 Nov 2006
Posts: 22

PostPosted: Fri Oct 26, 2007 1:37 pm    Post subject: Kernel Module Can't be Started Reply with quote

Code:

#include <pspkernel.h>
#include <pspdebug.h>
#include "MyModule.h"

PSP_MODULE_INFO("MyModule", 0x1000, 0, 1);
PSP_NO_CREATE_MAIN_THREAD();

int mymoduleGetVersionNumber(void)
{
   return 123;
}

int dummyFixupImport()
{
//   sceKernelDelayThread(1000000);
}

int module_start(int argc, char* argv[])
{
   return 0;
}

int module_stop(int argc, char* argv[])
{
   return 0;
}



if i comment out the sceKernelDelayThread line, the module can't be started, returning error code 0x8002013c.

client code:

Code:

   ret = kuKernelLoadModule(prx_path, 0, 0);
   if(ret >= 0) {
      ret = sceKernelStartModule(ret, 0, 0, &status, 0);
      if(ret >= 0) {
         printf("Start Module Successfully.\n");
      }
      else {
         printf("Start Module Fail[%08X]\n", ret);
      }
   }
   else {
      printf("Load Module Fail[%08x]\n", ret);
   }


Look like kuKernelLoadModule successully load the module, but i can't start it.
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Fri Oct 26, 2007 4:49 pm    Post subject: Reply with quote

Make sure you have in the makefile USE_KERNEL_LIBS = 1
Back to top
View user's profile Send private message
hrimfaxi



Joined: 23 Nov 2006
Posts: 22

PostPosted: Sat Oct 27, 2007 1:06 am    Post subject: Reply with quote

that's fixed, thx.
And then, i tried to make a wrapper to let user library to use the kernel only function...:

Code:

int mymoduleKernelModuleCount(void)
{
   return sceKernelModuleCount();
}


And the user client:

Code:

printf("mymoduleGetVersion returns %08X\n", mymoduleGetVersion());
printf("mymoduleKernelModuleCount returns %08X\n", mymoduleKernelModuleCount());


This time, mymoduleGetVersion is OK now, and the library seems to be loaded OK, but mymoduleKernelModuleCount returns 0x8002013A(SCE_KERNEL_ERROR_LIBRARY_NOT_YET_LINKED). What happend?
Back to top
View user's profile Send private message
jas0nuk



Joined: 27 Apr 2006
Posts: 137

PostPosted: Sat Oct 27, 2007 5:45 am    Post subject: Reply with quote

Do it like this (in the kernel PRX)

int sceKernelBlahBlah_(u8 *foo) {
int k1 = pspSdkSetK1(0);
int blah = sceKernelBlahBlah(foo);
pspSdkSetK1(k1);

return 0;
}

In other words, set k1 to 0, call kernel functions, then set it to the original value which was stored in k1.
Back to top
View user's profile Send private message
hrimfaxi



Joined: 23 Nov 2006
Posts: 22

PostPosted: Sat Oct 27, 2007 12:31 pm    Post subject: Reply with quote

Code:

int mymoduleKernelModuleCount(void)
{
   int k1 = pspSdkSetK1(0);
   int ret = sceKernelModuleCount();
   pspSdkSetK1(k1);
   return ret;
}


The problem remains, and here is my export.exp for the module:

Code:

# Define the exports for the prx
PSP_BEGIN_EXPORTS

# These four lines are mandatory (although you can add other functions like module_stop)
# syslib is a psynonym for the single mandatory export.
PSP_EXPORT_START(syslib, 0, 0x8000)
PSP_EXPORT_FUNC_HASH(module_start)
PSP_EXPORT_VAR_HASH(module_info)
PSP_EXPORT_END

PSP_EXPORT_START(MyModule, 0, 0x4001)
PSP_EXPORT_FUNC_HASH(mymoduleGetVersionNumber)
PSP_EXPORT_FUNC_HASH(mymoduleKernelModuleCount)
PSP_EXPORT_END

PSP_END_EXPORTS


I am on a PSP Slim 3.71M-2 version
Back to top
View user's profile Send private message
cooleyes



Joined: 18 May 2006
Posts: 125

PostPosted: Sat Oct 27, 2007 1:31 pm    Post subject: Re: Kernel Module Can't be Started Reply with quote

hrimfaxi wrote:
Code:

#include <pspkernel.h>
#include <pspdebug.h>
#include "MyModule.h"

PSP_MODULE_INFO("MyModule", 0x1000, 0, 1);
PSP_NO_CREATE_MAIN_THREAD();

int mymoduleGetVersionNumber(void)
{
   return 123;
}

int dummyFixupImport()
{
//   sceKernelDelayThread(1000000);
}

int module_start(int argc, char* argv[])
{
   return 0;
}

int module_stop(int argc, char* argv[])
{
   return 0;
}



if i comment out the sceKernelDelayThread line, the module can't be started, returning error code 0x8002013c.

client code:

Code:

   ret = kuKernelLoadModule(prx_path, 0, 0);
   if(ret >= 0) {
      ret = sceKernelStartModule(ret, 0, 0, &status, 0);
      if(ret >= 0) {
         printf("Start Module Successfully.\n");
      }
      else {
         printf("Start Module Fail[%08X]\n", ret);
      }
   }
   else {
      printf("Load Module Fail[%08x]\n", ret);
   }


Look like kuKernelLoadModule successully load the module, but i can't start it.



PSP_NO_CREATE_MAIN_THREAD();

?????????
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Sat Oct 27, 2007 5:13 pm    Post subject: Reply with quote

That function doesn't exist... since 1.50!

http://moonlight.lan.st/1.00/kd/loadcore.html
http://moonlight.lan.st/1.5x/kd/loadcore.html

No surprise it returns that error.

The reason of Sony deleting this function is probably the introducion of sceKernelGetModuleListWithAlloc in 1.50. Maybe before the "user" of the function used sceKernelModuleCount to allocate a buffer with enough size, and then sceKernelGetModuleList to get the module list. Then they just make a function to do all at same time, making sceKernelModuleCount useless for them.
Back to top
View user's profile Send private message
hrimfaxi



Joined: 23 Nov 2006
Posts: 22

PostPosted: Sat Oct 27, 2007 10:23 pm    Post subject: Reply with quote

Thanks a lot, it works now
Back to top
View user's profile Send private message
Aura



Joined: 24 Jul 2007
Posts: 37

PostPosted: Mon Nov 05, 2007 9:21 am    Post subject: Reply with quote

I've been having this problem also, but I've not been able to find my error, I'm not sure whats causing it, but I'm 99% sure its the actual kmode plugin and not the loader.

KMode main:

Code:
#include <pspkernel.h>
#include <pspmodulemgr_kernel.h>
#include <pspsdk.h>
#include <pspdebug.h>

PSP_MODULE_INFO("KMode", 0x1006, 1, 1);
//PSP_HEAP_SIZE_KB(3000);
PSP_MAIN_THREAD_ATTR(0);

int unloadmod(const char *module)
{
    u32 k1;
   
    k1 = pspSdkSetK1(0);
    SceModule *mod;
   
    while((mod = sceKernelFindModuleByName(module)))
    {
               sceKernelStopModule(mod->modid, 0, NULL, NULL, NULL);
               sceKernelUnloadModule(mod->modid);
    }
    pspSdkSetK1(k1);
    return 1;   
}

int module_start(SceSize args, void *argp)
{
   return 0;
}

int module_stop()
{
   return 0;
}



KMode exports:

Code:
# Define the exports for the prx
PSP_BEGIN_EXPORTS

# These four lines are mandatory (although you can add other functions like module_stop)
# syslib is a psynonym for the single mandatory export.
PSP_EXPORT_START(syslib, 0, 0x8000)
PSP_EXPORT_FUNC_HASH(module_start)
PSP_EXPORT_VAR_HASH(module_info)
PSP_EXPORT_END

PSP_EXPORT_START(KMode, 0, 0x4001)
PSP_EXPORT_FUNC(unloadmod)
PSP_EXPORT_END

PSP_END_EXPORTS


This, too, returns the 0x8002013A, and I'm not sure why.

Any help is greatly apprechiated.

-Aura

_________________
Live. Love. Be. Believe.

Free downgrading/unbricking service list!
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Mon Nov 05, 2007 9:37 pm    Post subject: Reply with quote

Post your makefile, just in case.
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