Difference between kuKernelLoadModule and sceKernelLoadModul

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Difference between kuKernelLoadModule and sceKernelLoadModul

Post by sauron_le_noir »

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.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

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).
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Post by sauron_le_noir »

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: Select all

#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&#40;"info", 0, 1, 0&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_USER&#41;;
PSP_HEAP_SIZE_KB&#40;-64&#41;;



extern   int ReadKey&#40;int key, char *buffer&#41;;
extern        int WriteKey&#40;int key, char *buffer&#41;;
extern        void GetMoboInfo&#40;int* baryon, int* tachyon&#41;;
extern        u64 GetFuseId&#40;&#41;;

int main&#40;int argc, char *argv&#91;&#93;&#41;
&#123;
  int i;
   pspDebugScreenInit&#40;&#41;;
   
   int r = kuKernelLoadModule&#40;"kinfo.prx",0,NULL&#41;;
   if &#40;r < 0&#41;
   &#123;
      printf&#40; "Error 0x%08X loading/starting kinfo.prx.\n", r&#41;;
      sceKernelDelayThread&#40;7000000&#41;;
   &#125;
   sceKernelStartModule&#40;r, 0, NULL, 0, NULL&#41;;

   
   int bar,tac;
   GetMoboInfo&#40;&bar,&tac&#41;;
   printf&#40;"baryon %x - Tachyon %x\n",bar,tac&#41;;

   
   printf&#40;"Fuseid %#llx\n",GetFuseId&#40;&#41;&#41;;
   
   char wifi_module_mac&#91;512&#93;;
   ReadKey&#40;0x44, wifi_module_mac&#41;;
   printf&#40;"Mac &#58; "&#41;;
   for&#40;i=0;i<12;i++&#41;
      printf&#40;"%02X&#58;",wifi_module_mac&#91;i&#93;&#41;;

   
   sceKernelDelayThread&#40;10000000&#41;;


   return 0;
&#125; 
it works with kukernelloadmodule but is this the good way to archive this ?
or must i use sceKernelLoadModule. ? avoiding using the 4.01M33 SDK
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

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).
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Post by sauron_le_noir »

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

Code: Select all

release&#58; 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 = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

BUILD_PRX = 1
PRX_EXPORTS = exports.exp

USE_KERNEL_LIBC = 1
USE_KERNEL_LIBS = 1
PSP_FW_VERSION = 500

LIBDIR = 
LIBS = 

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build_prx.mak
so kinfo.S contains

Code: Select all

	.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
Post Reply