#172241 - fincs - Tue Jan 26, 2010 9:43 pm
Hi,
I hate that my first post is something as obscure as this, but I'm having trouble trying to install a custom SWI handler on the DS. I'm using devkitARM r27 and libnds 1.4.0.
The problem is that the custom handler never gets executed. This is how I install it:
I then used the no$gba debugger (with the appropiate BIOS ROMs) to see what was wrong with my program. The SWI instruction jumps to 0xFFFF0008 (BIOS) instead of 0x00000008 (libnds vectors) although I cleared the V bit in the CP15. Real hardware (DSi) exposes the same problem, whilst other emulators run my code fine. I've tried everything: hacking the linker script, ds_arm9_crt0.s, vectorbase.s, mpusetup.s, searching this forum, re-reading gbatek, reading the official ARM documentation, nothing. I've been struggling my head for like a week for something that might just be a one-byte problem.
PD: vectorbase.s is wrong although it doesn't affect program execution (FIQs are never fired), here's a fix:
I hate that my first post is something as obscure as this, but I'm having trouble trying to install a custom SWI handler on the DS. I'm using devkitARM r27 and libnds 1.4.0.
The problem is that the custom handler never gets executed. This is how I install it:
Code: |
SystemVectors.swi = (u32) __SWIHandler;
setVectorBase(0); // clear the high vector bit in the CP15 control register |
I then used the no$gba debugger (with the appropiate BIOS ROMs) to see what was wrong with my program. The SWI instruction jumps to 0xFFFF0008 (BIOS) instead of 0x00000008 (libnds vectors) although I cleared the V bit in the CP15. Real hardware (DSi) exposes the same problem, whilst other emulators run my code fine. I've tried everything: hacking the linker script, ds_arm9_crt0.s, vectorbase.s, mpusetup.s, searching this forum, re-reading gbatek, reading the official ARM documentation, nothing. I've been struggling my head for like a week for something that might just be a one-byte problem.
PD: vectorbase.s is wrong although it doesn't affect program execution (FIQs are never fired), here's a fix:
Code: |
(..snip..)
.global SystemVectors ldr r15,vec_reset ldr r15,vec_undefined ldr r15,vec_swi ldr r15,vec_prefetch_abort ldr r15,vec_data_abort .word 0 @ <<-- added line ldr r15,vec_irq ldr r15,vec_fiq SystemVectors: vec_reset: .word 0xFFFF0000 vec_undefined: .word 0xFFFF0004 vec_swi: .word 0xFFFF0008 vec_prefetch_abort: .word 0xFFFF000C vec_data_abort: .word 0xFFFF0010 vec_irq: .word 0xFFFF0018 @ <<--changed address vec_fiq: .word 0xFFFF001C @ <<--changed address (..snip..) |