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 

SDL patch for optional kernel mode

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



Joined: 18 Mar 2007
Posts: 38

PostPosted: Mon Nov 19, 2007 12:48 pm    Post subject: SDL patch for optional kernel mode Reply with quote

As it is, SDL on the PSP is compiled to use kernel mode. So here's a patch to optionally compile it with or without. This is based on a patch by Dark_AleX, just replacing the commented out code with ifdefs.

Code:
--- src/main/psp/SDL_psp_main.c 2007-11-15 23:57:58.000000000 -0500
+++ src/main/psp/SDL_psp_main.c 2007-11-15 13:12:27.000000000 -0500
@@ -47,7 +47,11 @@
 
 static void cleanup_output(void);
 
+#ifdef PSPKMODE
 PSP_MODULE_INFO("SDL App", 0x1000, 1, 1);
+#else
+PSP_MODULE_INFO("SDL App", 0, 1, 1);
+#endif
 PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
 
 int sdl_psp_exit_callback(int arg1, int arg2, void *common)
@@ -76,6 +80,7 @@
        return thid;
 }
 
+#ifdef PSPKMODE
 void sdl_psp_exception_handler(PspDebugRegBlock *regs)
 {
        pspDebugScreenInit();
@@ -91,11 +96,13 @@
                "\tpsp-addr2line -e target.elf -f -C 0x%x 0x%x 0x%x\n",
                regs->epc, regs->badvaddr, regs->r[31]);
 }
+#endif
 
 /* If this flag is set to 1, the _init() function was called and all
    global/static constructors have been called. */
 static int init_was_called = 0;
 
+#ifdef PSPKMODE
 __attribute__ ((constructor))
 void loaderInit()
 {
@@ -109,6 +116,7 @@
 
        init_was_called = 1;
 }
+#endif
 
 /* Remove the output files if there was no output written */
 static void cleanup_output(void)
@@ -148,6 +156,7 @@
 
 int main(int argc, char *argv[])
 {
+       #ifdef PSPKMODE
        /* Fanjita's EBOOT loader can be configured to skip the call to _init().
           Since we need _init() for C++, we check to see if _init() has been
           called.  If it hasn't we call it manually, after determining whether or
@@ -155,6 +164,7 @@
        if (!init_was_called) {
                _init();
        }
+       #endif
 
        pspDebugScreenInit();
        sdl_psp_setup_callbacks();


and

Code:
--- configure.in        2007-11-18 21:32:07.000000000 -0500
+++ configure.in        2007-11-18 21:29:35.000000000 -0500
@@ -1914,6 +1914,13 @@
        CFLAGS="$CFLAGS -DPSPIRKEYB"
        SYSTEM_LIBS="$SYSTEM_LIBS -lpspirkeyb -lpsppower"
     fi
+
+    AC_ARG_ENABLE(pspkmode,
+                 [  --enable-pspkmode       enable PSP kernel mode functions [default=yes]],
+                  , enable_pspkmode=yes)
+    if test x$enable_pspkmode = xyes ; then
+       CFLAGS="$CFLAGS -DPSPKMODE"
+    fi
 }
 
 case "$target" in


E] You know, I'm not sure what _init and _fini are, so if there's a good reason for _init not to be ifdef'd out, by all means keep them, but that's how they were in the original patch I saw.
Back to top
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Mon Nov 19, 2007 4:44 pm    Post subject: Reply with quote

Why make it optional?
I think we should do away with it entirely.
Are there compelling reasons to keep it?
Back to top
View user's profile Send private message
Viper8896



Joined: 26 Jan 2006
Posts: 110

PostPosted: Mon Nov 19, 2007 4:57 pm    Post subject: Reply with quote

I think SDL should be user only. Especially with the way new firmwares operate. Anyway I don't like SDL and would like to encourage alternatives in every aspect that SDL provides.
Back to top
View user's profile Send private message
fungos



Joined: 31 Oct 2007
Posts: 41
Location: cwb br

PostPosted: Tue Nov 20, 2007 12:09 pm    Post subject: Reply with quote

Yes, I agree with jimparis.

I read somewhere somebody saying that It was hard to find homebrew for new firmwares and that developers only dev for 1.50 and that was crap. After that I saw that I was developing for 1.50 only and I haven't saw anywhere how to not develop for 1.50. Well, my problem was that I was using SDL and developing based on old samples. Now, that I'm trying to develop for 3.xx I'm getting too much trouble :D

Updating SDL to be 3.xx is a huge help for newbies as me do not develop for 1.50 :)
Back to top
View user's profile Send private message Visit poster's website
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Tue Nov 20, 2007 12:45 pm    Post subject: Reply with quote

Well, I'm looking for technical arguments, not just "yeah that sounds good".
Removing kernel mode means we remove functionality, so I want to know if anyone relies on it. Will anyone miss the exception handler? Does anyone need the stdio redirection or the no-device-check patches? Of course, those people can always choose to just implement main() themselves and not link libSDL_main, but some input from people using the library would be useful before we go and break stuff.
Back to top
View user's profile Send private message
danzel



Joined: 04 Nov 2005
Posts: 182

PostPosted: Tue Nov 20, 2007 2:33 pm    Post subject: Reply with quote

I use SDL for all my apps/games, and I support removing the Kernel mode dependency.

The things that patch will remove are un-needed as far as I'm concerned.
Add a note to the README.PSP that they are gone. Not that anyone reads it :-(
Back to top
View user's profile Send private message
Chrighton



Joined: 15 Jun 2005
Posts: 58

PostPosted: Tue Nov 20, 2007 2:42 pm    Post subject: Reply with quote

It's not worth bothering with (IMO). The exception handling is useful under 1.5, and if you're developing under 3.x/cfw, simply don't link SDL_main. If you want the app to work under both 1.5/3.x, simply don't link SDL_main. Updating the readme to merely emphasize this would probably be enough, I would think.
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Tue Nov 20, 2007 4:52 pm    Post subject: Reply with quote

Well as I pointed in the other thread kernel mode really isn't necessary anymore (*cough* psplink *cough* ;P) but that said breaking the code cause you are lazy is hardly the best option. If anything kmode should be the default to maintain legacy and people are encouraged to enabled a user mode only version or it should build both a user and kernel SDL_main.

Unfortunate but there we go, not that I expect masses of people to come here bitching about the change the fact but then just being the most vocal doesn't induce me to change it.

Still, why should I care :)
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