diff options
author | Joost Peters | 2005-09-28 23:10:18 +0000 |
---|---|---|
committer | Joost Peters | 2005-09-28 23:10:18 +0000 |
commit | 1c2fdf5af82ef4dcb2444433e0b8cbc2d837bae5 (patch) | |
tree | 3d0fb0b56eb73a20ffa8b4af5a60a87a2158fe90 /backends/psp | |
parent | fab72eed17a60cce4a738b3ed1b06cb3b08e801d (diff) | |
download | scummvm-rg350-1c2fdf5af82ef4dcb2444433e0b8cbc2d837bae5.tar.gz scummvm-rg350-1c2fdf5af82ef4dcb2444433e0b8cbc2d837bae5.tar.bz2 scummvm-rg350-1c2fdf5af82ef4dcb2444433e0b8cbc2d837bae5.zip |
Make ScummVM run in usermode, install exception handler in kernelmode.
svn-id: r18897
Diffstat (limited to 'backends/psp')
-rw-r--r-- | backends/psp/psp_main.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/backends/psp/psp_main.cpp b/backends/psp/psp_main.cpp index 0a4b8fa05d..89ad768941 100644 --- a/backends/psp/psp_main.cpp +++ b/backends/psp/psp_main.cpp @@ -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 @@ void MyExceptionHandler(PspDebugRegBlock *regs) { 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 @@ int main(void) //PSPDebugTrace("Setup callbacks\n"); SetupCallbacks(); - //install exception handler - pspDebugInstallErrorHandler(MyExceptionHandler); - //check if the save directory exists SceUID fd = sceIoDopen(SCUMMVM_SAVEPATH); if (fd < 0) { |