TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Mon Jun 20, 2005 12:42 am Post subject: Kprintf |
|
|
Oki been awhile since I posted anything of worth so here is some code to enable your own Kprintf handler. Most of the kernel code calls Kprintf when it errors, or for status information, but installing your own handler you can write to the screen etc anything interesting, could help with debugging kernel functions.
Big NOTE: The handler must be installed in kernel mode (using the previous trick that has already been discussed). It also relies on direct calls as you cannot link kmode and user mode libs in one app, therefore it is dependant on the version of the psp you are running. You have been warned :P
Have fun.
| Code: |
#ifdef VERSION_10
void (*sceKernelRegisterKprintfHandler)(void *fn, void *arg) = (void*) 0x88007598;
void (*Kprintf)(const char *str, ...) = (void *)0x88007D4C;
#else
void (*sceKernelRegisterKprintfHandler)(void *fn, void *arg) = (void*) 0x8800B5F8;
void (*Kprintf)(const char *str, ...) = (void *)0x8800B550;
#endif
int kprintf_handler(void *arg, const char *str, u32 *args)
{
printf(str, args[0], args[1], args[2], args[3]);
return 0;
}
// Main function in kernel mode
int kmain(void)
{
u32 addr;
addr = (u32) kprintf_handler;
addr |= 0x80000000;
sceKernelRegisterKprintfHandler((void *) addr, NULL);
return 0;
}
|
|
|