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 

Difference between kuKernelLoadModule and sceKernelLoadModul

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



Joined: 05 Jul 2008
Posts: 229

PostPosted: Tue Jun 09, 2009 3:08 am    Post subject: Difference between kuKernelLoadModule and sceKernelLoadModul Reply with quote

I have a prx 3.x that must load a kernel prx that export some functions that must
run in kernel mode.
In the samples that i have see some use kukernelloadmodule some use
scekernelloadmodule.
What is the difference between the two ? can scekernelloadmodule be use in a
prx 3.X (non kernel) to load a prx that must run in kernel mode or must i use the
kukernelloadmodule from the sdk oif Dark Alex.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Tue Jun 09, 2009 4:33 am    Post subject: Reply with quote

kuKernelLoadModule (which must be called from a user PRX) is the same as calling sceKernelLoadModule from a kernel PRX. It will be as if your user mode PRX loaded the module using the kernel mode version of sceKernelLoadModule.

This is only needed for special modules that cannot be loaded from user mode (such as vshmain.prx and some other Sony modules). If you make a kernel mode PRX and need to load it from another user mode PRX then it is enough to call sceKernelLoadModule (which will call the user mode one, but it can load your kernel module).
Back to top
View user's profile Send private message
sauron_le_noir



Joined: 05 Jul 2008
Posts: 229

PostPosted: Tue Jun 09, 2009 4:43 am    Post subject: Reply with quote

torch i have made a kinfo.prx
PSP_MODULE_INFO("kinfo", 0x1006, 2, 0);

i have made a user program that load this kinfo.prx

Code:

#include <pspsdk.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspmoduleinfo.h>
#include <kubridge.h>
#include "kinfo.h"

// #include "kernel.h"

#define printf pspDebugScreenPrintf

/* Define the module info section */
PSP_MODULE_INFO("info", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
PSP_HEAP_SIZE_KB(-64);



extern   int ReadKey(int key, char *buffer);
extern        int WriteKey(int key, char *buffer);
extern        void GetMoboInfo(int* baryon, int* tachyon);
extern        u64 GetFuseId();

int main(int argc, char *argv[])
{
  int i;
   pspDebugScreenInit();
   
   int r = kuKernelLoadModule("kinfo.prx",0,NULL);
   if (r < 0)
   {
      printf( "Error 0x%08X loading/starting kinfo.prx.\n", r);
      sceKernelDelayThread(7000000);
   }
   sceKernelStartModule(r, 0, NULL, 0, NULL);

   
   int bar,tac;
   GetMoboInfo(&bar,&tac);
   printf("baryon %x - Tachyon %x\n",bar,tac);

   
   printf("Fuseid %#llx\n",GetFuseId());
   
   char wifi_module_mac[512];
   ReadKey(0x44, wifi_module_mac);
   printf("Mac : ");
   for(i=0;i<12;i++)
      printf("%02X:",wifi_module_mac[i]);

   
   sceKernelDelayThread(10000000);


   return 0;
}

it works with kukernelloadmodule but is this the good way to archive this ?
or must i use sceKernelLoadModule. ? avoiding using the 4.01M33 SDK
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Tue Jun 09, 2009 4:46 am    Post subject: Reply with quote

sceKernelLoadModule is enough. Also, you are loading the kinfo module and using its exports from the same user module. Thus your stubs file for the user module must be changed for late binding (0x40090000 instead of 0x40000000).
Back to top
View user's profile Send private message
sauron_le_noir



Joined: 05 Jul 2008
Posts: 229

PostPosted: Tue Jun 09, 2009 4:59 am    Post subject: Reply with quote

was already the case because i use psp-build-export to generate it
Code:

release: all
   psp-build-exports -s exports.exp

TARGET = kinfo
OBJS = main.o exports.o

INCDIR =
CFLAGS = -O2 -Os -G0 -Wall -fshort-wchar -fno-pic -mno-check-zero-division
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

BUILD_PRX = 1
PRX_EXPORTS = exports.exp

USE_KERNEL_LIBC = 1
USE_KERNEL_LIBS = 1
PSP_FW_VERSION = 500

LIBDIR =
LIBS =

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build_prx.mak


so kinfo.S contains

Code:

   .set noreorder

#include "pspstub.s"

   STUB_START "kinfo",0x40090000,0x00040005
   STUB_FUNC  0x4EB98A32,GetFuseId
   STUB_FUNC  0x708AF9F6,GetMoboInfo
   STUB_FUNC  0xBE861F44,ReadKey
   STUB_FUNC  0x5E4510CC,WriteKey
   STUB_END
Back to top
View user's profile Send private message Send e-mail MSN Messenger
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