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 

Kprintf

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



Joined: 18 Jan 2004
Posts: 918

PostPosted: Mon Jun 20, 2005 12:42 am    Post subject: Kprintf Reply with quote

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;
}
Back to top
View user's profile Send private message
adresd



Joined: 17 Jan 2004
Posts: 43

PostPosted: Mon Jun 20, 2005 12:47 am    Post subject: Reply with quote

Nice find Tyranid.

Could see that being very useful :)
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