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 

using stdout

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



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Tue Jul 19, 2005 7:34 pm    Post subject: using stdout Reply with quote

With the latest version in svn repository (currently 694) you can register a handler for stdout and stderr, without starting the application in a kernel mode thread. The 2 step howto:

1. the module must be a kernel module, so use 0x1000 instead of 0 for the modattribute:

PSP_MODULE_INFO("APPNAME", 0x1000, 1, 1);

2. add a constructor function, which is automaticly called before starting the main function:

Code:

__attribute__((constructor)) void stdoutInit()
{
   pspKernelSetKernelPC();
   pspDebugInstallStdoutHandler(pspDebugScreenPrintData);
}


and you are done. Now you can write 'fprintf(stdout, "Hello\n")' and every third party library, which wants to write to stdout, for example when you use 'io.write("Hello")' from within a Lua script, uses the pspDebugScreenPrintData function to write to the display of the PSP. Instead of pspDebugScreenPrintData you can use your own custom function, for example to write to the IrDA port or something else.

The technical details: mrbrown moved the _init call from the _main function in ctr0.c to the _start entry point, so when your program is in kernel mode, you can call kernel mode functions from contructor functions, like registering the tty-kernel-driver for the stdout file routing like explained. After this, the user thread is started, which needs not to be in kernel mode, so your application can run in user mode like a normal application.

This change should be backward compatible, so you don't need to change your existing programs, if you don't need this feature.
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