[PATCH 2/5] SPARC: add BSP specific error handler

Daniel Hellstrom daniel at gaisler.com
Wed Jun 4 09:23:35 UTC 2014


Instead of calling the system call TA instruction directly it
is better paractise to isolate the trap implementation to the
system call functions.

The BSP_fatal_return() should always exist, regardless of SPARC
CPU.
---
 c/src/lib/libbsp/sparc/erc32/Makefile.am           |    1 +
 c/src/lib/libbsp/sparc/leon2/Makefile.am           |    1 +
 c/src/lib/libbsp/sparc/leon3/Makefile.am           |    1 +
 c/src/lib/libbsp/sparc/shared/start/start.S        |   12 +++++++-----
 .../libbsp/sparc/shared/startup/bsp_fatal_exit.c   |   19 +++++++++++++++++++
 5 files changed, 29 insertions(+), 5 deletions(-)
 create mode 100644 c/src/lib/libbsp/sparc/shared/startup/bsp_fatal_exit.c

diff --git a/c/src/lib/libbsp/sparc/erc32/Makefile.am b/c/src/lib/libbsp/sparc/erc32/Makefile.am
index abf8eca..d3abba6 100644
--- a/c/src/lib/libbsp/sparc/erc32/Makefile.am
+++ b/c/src/lib/libbsp/sparc/erc32/Makefile.am
@@ -45,6 +45,7 @@ libbsp_a_SOURCES += startup/boardinit.S
 libbsp_a_SOURCES += startup/bspidle.c
 libbsp_a_SOURCES += startup/bspdelay.c
 libbsp_a_SOURCES += ../../sparc/shared/startup/early_malloc.c
+libbsp_a_SOURCES += ../../sparc/shared/startup/bsp_fatal_exit.c
 # ISR Handler
 libbsp_a_SOURCES += ../../sparc/shared/irq_asm.S
 # gnatsupp
diff --git a/c/src/lib/libbsp/sparc/leon2/Makefile.am b/c/src/lib/libbsp/sparc/leon2/Makefile.am
index f913462..1490391 100644
--- a/c/src/lib/libbsp/sparc/leon2/Makefile.am
+++ b/c/src/lib/libbsp/sparc/leon2/Makefile.am
@@ -60,6 +60,7 @@ libbsp_a_SOURCES += startup/bspidle.c
 libbsp_a_SOURCES += ../../shared/bspinit.c
 libbsp_a_SOURCES += startup/bspdelay.c
 libbsp_a_SOURCES += ../../sparc/shared/startup/early_malloc.c
+libbsp_a_SOURCES += ../../sparc/shared/startup/bsp_fatal_exit.c
 
 # ISR Handler
 libbsp_a_SOURCES += ../../sparc/shared/irq_asm.S
diff --git a/c/src/lib/libbsp/sparc/leon3/Makefile.am b/c/src/lib/libbsp/sparc/leon3/Makefile.am
index 789c3d0..b942824 100644
--- a/c/src/lib/libbsp/sparc/leon3/Makefile.am
+++ b/c/src/lib/libbsp/sparc/leon3/Makefile.am
@@ -41,6 +41,7 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \
     ../../shared/bspinit.c ../../sparc/shared/startup/early_malloc.c
 libbsp_a_SOURCES += startup/bspreset.c
 libbsp_a_SOURCES += startup/cpucounter.c
+libbsp_a_SOURCES += ../../sparc/shared/startup/bsp_fatal_exit.c
 
 # ISR Handler
 libbsp_a_SOURCES += ../../sparc/shared/irq_asm.S
diff --git a/c/src/lib/libbsp/sparc/shared/start/start.S b/c/src/lib/libbsp/sparc/shared/start/start.S
index 070387f..d54c5a0 100644
--- a/c/src/lib/libbsp/sparc/shared/start/start.S
+++ b/c/src/lib/libbsp/sparc/shared/start/start.S
@@ -368,14 +368,16 @@ zerobss:
         sub     %sp, 0x60, %sp          ! room for boot_card to save args
         nop
 
+        PUBLIC(BSP_fatal_return)	! Symbol look good in back trace
+SYM(BSP_fatal_return):
+        call    SYM(BSP_fatal_exit)     ! Halt if _main returns ...
+         or     %g0, 1, %o0             ! boot_card leaves no return value
+
 #if !defined(START_LEON3_ENABLE_SMP)
-        PUBLIC(BSP_fatal_return)
         PUBLIC(bsp_reset)
-SYM(BSP_fatal_return):
 SYM(bsp_reset):
-	mov	1, %g1
-        ta      0                       ! Halt if _main returns ...
-        nop
+        call    SYM(BSP_fatal_exit)
+         clr     %o0
 #endif
 
 /* end of file */
diff --git a/c/src/lib/libbsp/sparc/shared/startup/bsp_fatal_exit.c b/c/src/lib/libbsp/sparc/shared/startup/bsp_fatal_exit.c
new file mode 100644
index 0000000..c7ba6c2
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/shared/startup/bsp_fatal_exit.c
@@ -0,0 +1,19 @@
+/**
+ * @file
+ * @ingroup sparc_bsp
+ * @brief ERC32/LEON2/LEON3 BSP specific exit handler.
+ *
+ *  COPYRIGHT (c) 2014.
+ *  Aeroflex Gaisler AB.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.org/license/LICENSE.
+ */
+
+#include <rtems.h>
+
+void BSP_fatal_exit(uint32_t error)
+{
+  sparc_syscall_exit(RTEMS_FATAL_SOURCE_BSP, error);
+}
-- 
1.7.0.4




More information about the devel mailing list