aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/exc.S
diff options
context:
space:
mode:
authorPerry Hung <iperry@gmail.com>2011-02-27 17:26:19 -0500
committerPerry Hung <iperry@gmail.com>2011-02-27 17:30:44 -0500
commit68c483e3c9c382779d2580598fb0f90a9f55d2ab (patch)
tree3adb27aeedaf18173a31732cf6e6d8fff7298871 /libmaple/exc.S
parent214941537f2211d5e2ef16e34440485d7e872d1a (diff)
downloadlibrambutan-68c483e3c9c382779d2580598fb0f90a9f55d2ab.tar.gz
librambutan-68c483e3c9c382779d2580598fb0f90a9f55d2ab.zip
Set NONEBASETHRDENA on exception.
Diffstat (limited to 'libmaple/exc.S')
-rw-r--r--libmaple/exc.S40
1 files changed, 25 insertions, 15 deletions
diff --git a/libmaple/exc.S b/libmaple/exc.S
index d01e3d5..823bbc5 100644
--- a/libmaple/exc.S
+++ b/libmaple/exc.S
@@ -48,40 +48,50 @@
.globl __exc_busfault
.globl __exc_usagefault
-/* TODO: Fix this up. */
+.code 16
.thumb_func
__exc_nmi:
mov r0, #1
+ b __default_exc
.thumb_func
__exc_hardfault:
mov r0, #2
+ b __default_exc
.thumb_func
__exc_memmanage:
mov r0, #3
+ b __default_exc
.thumb_func
__exc_busfault:
mov r0, #4
+ b __default_exc
.thumb_func
__exc_usagefault:
mov r0, #5
+ b __default_exc
-__default:
- ldr r1, CPSR_MASK @ Set default CPSR
- push {r1}
- ldr r1, TARGET_PC @ Set target pc
- push {r1}
- sub sp, sp, #24 @ Don't care
- ldr r1, EXC_RETURN @ Return to thread mode
- mov lr, r1
- bx lr @ Exception exit
-
- .align 4
- CPSR_MASK: .word 0x61000000
- EXC_RETURN: .word 0xFFFFFFF9
- TARGET_PC: .word throb
+.thumb_func
+__default_exc:
+ ldr r2, NVIC_CCR @ Enabling returning to thread mode from an
+ mov r1 ,#1 @ exception. See flag NONEBASETHRDENA.
+ str r1, [r2]
+ cpsid i @ Disable global interrupts
+ ldr r1, CPSR_MASK @ Set default CPSR
+ push {r1}
+ ldr r1, TARGET_PC @ Set target pc
+ push {r1}
+ sub sp, sp, #24 @ Don't care
+ ldr r1, EXC_RETURN @ Return to thread mode
+ mov lr, r1
+ bx lr @ Exception exit
+.align 4
+CPSR_MASK: .word 0x61000000
+EXC_RETURN: .word 0xFFFFFFF9
+TARGET_PC: .word __error
+NVIC_CCR: .word 0xE000ED14 @ NVIC configuration control register