[Scummvm-cvs-logs] CVS: scummvm/backends/psp psp_main.cpp,1.1,1.2
Joost Peters
joostp at users.sourceforge.net
Wed Sep 28 16:11:29 CEST 2005
Update of /cvsroot/scummvm/scummvm/backends/psp
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23275
Modified Files:
psp_main.cpp
Log Message:
Make ScummVM run in usermode, install exception handler in kernelmode.
Index: psp_main.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/psp/psp_main.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- psp_main.cpp 16 Aug 2005 17:15:36 -0000 1.1
+++ psp_main.cpp 28 Sep 2005 23:10:18 -0000 1.2
@@ -37,10 +37,21 @@
#include <pspgu.h>
#include "./trace.h"
+
+/**
+ * Define the module info section
+ *
+ * 2nd arg must 0x1000 so __init is executed in
+ * kernelmode for our loaderInit function
+ */
PSP_MODULE_INFO("SCUMMVM-PSP", 0x1000, 1, 1);
-/* Define the main thread's attribute value (optional) */
-PSP_MAIN_THREAD_ATTR(/*THREAD_ATTR_USER | THREAD_ATTR_VFPU*/ 0);
+/**
+ * THREAD_ATTR_USER causes the thread that the startup
+ * code (crt0.c) starts this program in to be in usermode
+ * even though the module was started in kernelmode
+ */
+PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
/* global quit flag, this is used to let the VM engine shutdown properly */
bool g_quit = false;
@@ -60,6 +71,16 @@
while (1) ;
}
+/**
+ * Function that is called from _init in kernelmode before the
+ * main thread is started in usermode.
+ */
+__attribute__ ((constructor))
+void loaderInit() {
+ pspKernelSetKernelPC();
+ pspDebugInstallErrorHandler(MyExceptionHandler);
+}
+
/* Exit callback */
SceKernelCallbackFunction exit_callback(int /*arg1*/, int /*arg2*/, void * /*common*/) {
@@ -104,9 +125,6 @@
//PSPDebugTrace("Setup callbacks\n");
SetupCallbacks();
- //install exception handler
- pspDebugInstallErrorHandler(MyExceptionHandler);
-
//check if the save directory exists
SceUID fd = sceIoDopen(SCUMMVM_SAVEPATH);
if (fd < 0) {
More information about the Scummvm-git-logs
mailing list