2009-04-10 18:15:10 +02:00
|
|
|
/*
|
|
|
|
mini - a Free Software replacement for the Nintendo/BroadOn IOS.
|
|
|
|
|
|
|
|
exception handling
|
|
|
|
|
|
|
|
Copyright (C) 2008, 2009 Hector Martin "marcan" <marcan@marcansoft.com>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, version 2.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
*/
|
2009-01-16 08:53:57 +01:00
|
|
|
.globl v_undf
|
|
|
|
.globl v_swi
|
|
|
|
.globl v_instr_abrt
|
|
|
|
.globl v_data_abrt
|
|
|
|
.globl v_reserved
|
|
|
|
.globl v_fiq
|
|
|
|
|
|
|
|
.globl exc_setup_stack
|
|
|
|
.extern __excstack_addr
|
|
|
|
.extern exc_handler
|
|
|
|
|
|
|
|
exc_setup_stack:
|
|
|
|
mrs r0, cpsr
|
|
|
|
|
|
|
|
@ Switch to FIQ mode
|
|
|
|
msr cpsr_c, #0xd1
|
|
|
|
@ Setup exception stack
|
|
|
|
ldr sp, =__excstack_addr
|
|
|
|
|
|
|
|
@ Switch to SVC mode
|
|
|
|
msr cpsr_c, #0xd3
|
|
|
|
@ Setup exception stack
|
|
|
|
ldr sp, =__excstack_addr
|
|
|
|
|
|
|
|
@ Switch to ABORT mode
|
|
|
|
msr cpsr_c, #0xd7
|
|
|
|
@ Setup exception stack
|
|
|
|
ldr sp, =__excstack_addr
|
|
|
|
|
|
|
|
@ Switch to UNDF mode
|
|
|
|
msr cpsr_c, #0xdb
|
|
|
|
@ Setup exception stack
|
|
|
|
ldr sp, =__excstack_addr
|
|
|
|
|
|
|
|
@ Restore mode
|
|
|
|
msr cpsr_c, r0
|
|
|
|
bx lr
|
|
|
|
|
|
|
|
.pool
|
|
|
|
|
|
|
|
v_undf:
|
|
|
|
stmfd sp!, {lr}
|
|
|
|
stmfd sp, {r0-lr}^
|
|
|
|
sub sp, sp, #0x3c
|
|
|
|
mov r2, sp
|
|
|
|
mrs r1, spsr
|
|
|
|
mov r0, #1
|
|
|
|
|
|
|
|
blx exc_handler
|
|
|
|
|
|
|
|
ldmfd sp!, {r0-r12}
|
|
|
|
add sp, sp, #8
|
2009-03-06 05:15:43 +01:00
|
|
|
ldmfd sp!, {lr}
|
2009-01-16 08:53:57 +01:00
|
|
|
movs pc, lr
|
|
|
|
|
|
|
|
v_swi:
|
|
|
|
stmfd sp!, {lr}
|
|
|
|
stmfd sp, {r0-lr}^
|
|
|
|
sub sp, sp, #0x3c
|
|
|
|
mov r2, sp
|
|
|
|
mrs r1, spsr
|
|
|
|
mov r0, #2
|
|
|
|
|
|
|
|
blx exc_handler
|
|
|
|
|
|
|
|
ldmfd sp!, {r0-r12}
|
|
|
|
add sp, sp, #8
|
2009-03-06 05:15:43 +01:00
|
|
|
ldmfd sp!, {lr}
|
2009-01-16 08:53:57 +01:00
|
|
|
movs pc, lr
|
|
|
|
|
|
|
|
v_instr_abrt:
|
|
|
|
stmfd sp!, {lr}
|
|
|
|
stmfd sp, {r0-lr}^
|
|
|
|
sub sp, sp, #0x3c
|
|
|
|
mov r2, sp
|
|
|
|
mrs r1, spsr
|
|
|
|
mov r0, #3
|
|
|
|
|
|
|
|
blx exc_handler
|
|
|
|
|
|
|
|
ldmfd sp!, {r0-r12}
|
|
|
|
add sp, sp, #8
|
2009-03-06 05:15:43 +01:00
|
|
|
ldmfd sp!, {lr}
|
2009-01-16 08:53:57 +01:00
|
|
|
subs pc, lr, #4
|
|
|
|
|
|
|
|
v_data_abrt:
|
|
|
|
stmfd sp!, {lr}
|
|
|
|
stmfd sp, {r0-lr}^
|
|
|
|
sub sp, sp, #0x3c
|
|
|
|
mov r2, sp
|
|
|
|
mrs r1, spsr
|
|
|
|
mov r0, #4
|
|
|
|
|
|
|
|
blx exc_handler
|
|
|
|
|
|
|
|
ldmfd sp!, {r0-r12}
|
|
|
|
add sp, sp, #8
|
2009-03-06 05:15:43 +01:00
|
|
|
ldmfd sp!, {lr}
|
2009-01-16 08:53:57 +01:00
|
|
|
subs pc, lr, #8
|
|
|
|
|
|
|
|
v_reserved:
|
|
|
|
stmfd sp!, {lr}
|
|
|
|
stmfd sp, {r0-lr}^
|
|
|
|
sub sp, sp, #0x3c
|
|
|
|
mov r2, sp
|
|
|
|
mrs r1, spsr
|
|
|
|
mov r0, #5
|
|
|
|
|
|
|
|
blx exc_handler
|
|
|
|
|
|
|
|
ldmfd sp!, {r0-r12}
|
|
|
|
add sp, sp, #8
|
2009-03-06 05:15:43 +01:00
|
|
|
ldmfd sp!, {lr}
|
2009-01-16 08:53:57 +01:00
|
|
|
movs pc, lr
|
|
|
|
|
|
|
|
v_fiq:
|
|
|
|
stmfd sp!, {lr}
|
|
|
|
stmfd sp, {r0-lr}^
|
|
|
|
sub sp, sp, #0x3c
|
|
|
|
mov r2, sp
|
|
|
|
mrs r1, spsr
|
|
|
|
mov r0, #7
|
|
|
|
|
|
|
|
blx exc_handler
|
|
|
|
|
|
|
|
ldmfd sp!, {r0-r12}
|
|
|
|
add sp, sp, #8
|
2009-03-06 05:15:43 +01:00
|
|
|
ldmfd sp!, {lr}
|
2009-01-16 08:53:57 +01:00
|
|
|
subs pc, lr, #4
|
|
|
|
|