[rtems commit] arm: Add and use _ARMV7M_Exception_default()

Sebastian Huber sebh at rtems.org
Mon Jan 7 14:05:04 UTC 2013


Module:    rtems
Branch:    master
Commit:    04f399dc0b11248eeb19453f28248862432e9d1b
Changeset: http://git.rtems.org/rtems/commit/?id=04f399dc0b11248eeb19453f28248862432e9d1b

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Jan  7 10:19:23 2013 +0100

arm: Add and use _ARMV7M_Exception_default()

---

 c/src/lib/libbsp/arm/shared/start/start.S       |   31 +++++++------
 cpukit/score/cpu/arm/Makefile.am                |    1 +
 cpukit/score/cpu/arm/armv7m-exception-default.c |   53 +++++++++++++++++++++++
 cpukit/score/cpu/arm/rtems/score/armv7m.h       |    2 +
 4 files changed, 72 insertions(+), 15 deletions(-)

diff --git a/c/src/lib/libbsp/arm/shared/start/start.S b/c/src/lib/libbsp/arm/shared/start/start.S
index 33783cb..9954a87 100644
--- a/c/src/lib/libbsp/arm/shared/start/start.S
+++ b/c/src/lib/libbsp/arm/shared/start/start.S
@@ -38,6 +38,7 @@
 	.extern	_ARMV4_Exception_reserved_default
 	.extern	_ARMV4_Exception_irq_default
 	.extern	_ARMV4_Exception_fiq_default
+	.extern	_ARMV7M_Exception_default
 
 	/* Global symbols */
 	.globl	_start
@@ -218,22 +219,22 @@ bsp_start_vector_table_begin:
 
 	.word	bsp_stack_main_end
 	.word	_start /* Reset */
-	.word	bsp_reset /* NMI */
-	.word	bsp_reset /* Hard Fault */
-	.word	bsp_reset /* MPU Fault */
-	.word	bsp_reset /* Bus Fault */
-	.word	bsp_reset /* Usage Fault */
-	.word	bsp_reset /* Reserved */
-	.word	bsp_reset /* Reserved */
-	.word	bsp_reset /* Reserved */
-	.word	bsp_reset /* Reserved */
-	.word	bsp_reset /* SVC */
-	.word	bsp_reset /* Debug Monitor */
-	.word	bsp_reset /* Reserved */
-	.word	bsp_reset /* PendSV */
-	.word	bsp_reset /* SysTick */
+	.word	_ARMV7M_Exception_default /* NMI */
+	.word	_ARMV7M_Exception_default /* Hard Fault */
+	.word	_ARMV7M_Exception_default /* MPU Fault */
+	.word	_ARMV7M_Exception_default /* Bus Fault */
+	.word	_ARMV7M_Exception_default /* Usage Fault */
+	.word	_ARMV7M_Exception_default /* Reserved */
+	.word	_ARMV7M_Exception_default /* Reserved */
+	.word	_ARMV7M_Exception_default /* Reserved */
+	.word	_ARMV7M_Exception_default /* Reserved */
+	.word	_ARMV7M_Exception_default /* SVC */
+	.word	_ARMV7M_Exception_default /* Debug Monitor */
+	.word	_ARMV7M_Exception_default /* Reserved */
+	.word	_ARMV7M_Exception_default /* PendSV */
+	.word	_ARMV7M_Exception_default /* SysTick */
 	.rept	BSP_INTERRUPT_VECTOR_MAX + 1
-	.word	bsp_reset /* IRQ */
+	.word	_ARMV7M_Exception_default /* IRQ */
 	.endr
 
 bsp_start_vector_table_end:
diff --git a/cpukit/score/cpu/arm/Makefile.am b/cpukit/score/cpu/arm/Makefile.am
index 85f9c7d..dedbb04 100644
--- a/cpukit/score/cpu/arm/Makefile.am
+++ b/cpukit/score/cpu/arm/Makefile.am
@@ -25,6 +25,7 @@ libscorecpu_a_SOURCES += armv4-exception-default.S
 libscorecpu_a_SOURCES += armv7m-context-initialize.c
 libscorecpu_a_SOURCES += armv7m-context-restore.c
 libscorecpu_a_SOURCES += armv7m-context-switch.c
+libscorecpu_a_SOURCES += armv7m-exception-default.c
 libscorecpu_a_SOURCES += armv7m-exception-frame-print.c
 libscorecpu_a_SOURCES += armv7m-exception-handler-get.c
 libscorecpu_a_SOURCES += armv7m-exception-handler-set.c
diff --git a/cpukit/score/cpu/arm/armv7m-exception-default.c b/cpukit/score/cpu/arm/armv7m-exception-default.c
new file mode 100644
index 0000000..fbd1039
--- /dev/null
+++ b/cpukit/score/cpu/arm/armv7m-exception-default.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Obere Lagerstr. 30
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems at embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include <rtems/score/armv7m.h>
+
+#ifdef ARM_MULTILIB_ARCH_V7M
+
+void __attribute__((naked)) _ARMV7M_Exception_default( void )
+{
+  __asm__ volatile (
+    "sub sp, %[cpufsz]\n"
+    "stm sp, {r0-r12}\n"
+    "mov r2, lr\n"
+    "mrs r1, msp\n"
+    "mrs r0, psp\n"
+    "cmn r2, #3\n"
+    "itt ne\n"
+    "movne r0, r1\n"
+    "addne r0, %[cpufsz]\n"
+    "add r2, r0, %[v7mlroff]\n"
+    "add r1, sp, %[cpulroff]\n"
+    "ldm r2, {r3-r5}\n"
+    "stm r1, {r3-r5}\n"
+    "mrs r1, ipsr\n"
+    "str r1, [sp, %[cpuvecoff]]\n"
+    "mov r0, sp\n"
+    "b _ARM_Exception_default\n"
+    :
+    : [cpufsz] "i" (sizeof(CPU_Exception_frame)),
+      [v7mfsz] "i" (sizeof(ARMV7M_Exception_frame)),
+      [cpuspoff] "J" (offsetof(CPU_Exception_frame, register_sp)),
+      [cpulroff] "i" (offsetof(CPU_Exception_frame, register_lr)),
+      [v7mlroff] "i" (offsetof(ARMV7M_Exception_frame, register_lr)),
+      [cpuvecoff] "J" (offsetof(CPU_Exception_frame, vector))
+  );
+}
+
+#endif /* ARM_MULTILIB_ARCH_V7M */
diff --git a/cpukit/score/cpu/arm/rtems/score/armv7m.h b/cpukit/score/cpu/arm/rtems/score/armv7m.h
index c8b55c1..f029b69 100644
--- a/cpukit/score/cpu/arm/rtems/score/armv7m.h
+++ b/cpukit/score/cpu/arm/rtems/score/armv7m.h
@@ -468,6 +468,8 @@ void _ARMV7M_Set_exception_priority_and_handler(
   ARMV7M_Exception_handler handler
 );
 
+void _ARMV7M_Exception_default( void );
+
 void _ARMV7M_Interrupt_service_enter( void );
 
 void _ARMV7M_Interrupt_service_leave( void );




More information about the vc mailing list