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

Daniel Hellstrom daniel at gaisler.com
Fri Jul 4 08:49:51 UTC 2014


On 07/03/2014 04:48 PM, Joel Sherrill wrote:
> I don't have a problem with this in principle but reviewing
> the earlier patches and seeing similar names in other
> BSPs makes me wonder if we can't get a better name.
>
> Isn't this really just bsp_reset?
Yes it is, on LEON2 and ERC32, but not on LEON3. LEON3 must handle SMP too.

> I don't see needing the symbol BSP_fatal_exit().

True, after updating this patch there is only one caller at the moment. Perhaps I should remove bsp_reset() from LEON2 and ERC32 instead and rely on CPU_Fatal_halt() on all BSPs?

> On 7/3/2014 2:29 AM, Daniel Hellstrom wrote:
>> PATCHv2: BSP_fatal_exit defined in header
>>
>> Instead of calling the system call TA instruction directly it
>> is better paractise to isolate the trap implementation to the
>> system call functions.
>>
>> BSP_fatal_exit() is added.
>> ---
>>   c/src/lib/libbsp/sparc/erc32/Makefile.am           |    1 +
>>   c/src/lib/libbsp/sparc/erc32/include/bsp.h         |    2 ++
>>   c/src/lib/libbsp/sparc/leon2/Makefile.am           |    1 +
>>   c/src/lib/libbsp/sparc/leon2/include/bsp.h         |    2 ++
>>   c/src/lib/libbsp/sparc/leon3/Makefile.am           |    1 +
>>   c/src/lib/libbsp/sparc/leon3/include/bsp.h         |    2 ++
>>   c/src/lib/libbsp/sparc/shared/start/start.S        |    5 ++---
>>   .../libbsp/sparc/shared/startup/bsp_fatal_exit.c   |   19 +++++++++++++++++++
>>   8 files changed, 30 insertions(+), 3 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 d5de377..b9f1c53 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/cpu.c
>>   libbsp_a_SOURCES += ../../sparc/shared/irq_asm.S
>> diff --git a/c/src/lib/libbsp/sparc/erc32/include/bsp.h b/c/src/lib/libbsp/sparc/erc32/include/bsp.h
>> index fbe8988..b1cc83e 100644
>> --- a/c/src/lib/libbsp/sparc/erc32/include/bsp.h
>> +++ b/c/src/lib/libbsp/sparc/erc32/include/bsp.h
>> @@ -92,6 +92,8 @@ rtems_isr_entry set_vector(                     /* returns old vector */
>>       int                 type                    /* RTEMS or RAW intr  */
>>   );
>>   
>> +void BSP_fatal_exit(uint32_t error);
>> +
>>   void bsp_spurious_initialize( void );
>>   
>>   /* Allocate 8-byte aligned non-freeable pre-malloc() memory. The function
>> diff --git a/c/src/lib/libbsp/sparc/leon2/Makefile.am b/c/src/lib/libbsp/sparc/leon2/Makefile.am
>> index e808b33..3f8edf4 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/cpu.c
>> diff --git a/c/src/lib/libbsp/sparc/leon2/include/bsp.h b/c/src/lib/libbsp/sparc/leon2/include/bsp.h
>> index 63af19e..1943baf 100644
>> --- a/c/src/lib/libbsp/sparc/leon2/include/bsp.h
>> +++ b/c/src/lib/libbsp/sparc/leon2/include/bsp.h
>> @@ -113,6 +113,8 @@ rtems_isr_entry set_vector(                     /* returns old vector */
>>       int                 type                    /* RTEMS or RAW intr  */
>>   );
>>   
>> +void BSP_fatal_exit(uint32_t error);
>> +
>>   void bsp_spurious_initialize( void );
>>   
>>   /* Allocate 8-byte aligned non-freeable pre-malloc() memory. The function
>> diff --git a/c/src/lib/libbsp/sparc/leon3/Makefile.am b/c/src/lib/libbsp/sparc/leon3/Makefile.am
>> index 5dd43c3..54c9f22 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/cpu.c
>> diff --git a/c/src/lib/libbsp/sparc/leon3/include/bsp.h b/c/src/lib/libbsp/sparc/leon3/include/bsp.h
>> index ce4fe09..5f6f0a0 100644
>> --- a/c/src/lib/libbsp/sparc/leon3/include/bsp.h
>> +++ b/c/src/lib/libbsp/sparc/leon3/include/bsp.h
>> @@ -131,6 +131,8 @@ rtems_isr_entry set_vector(                     /* returns old vector */
>>       int                 type                    /* RTEMS or RAW intr  */
>>   );
>>   
>> +void BSP_fatal_exit(uint32_t error);
>> +
>>   void bsp_spurious_initialize( void );
>>   
>>   /* Allocate 8-byte aligned non-freeable pre-malloc() memory. The function
>> diff --git a/c/src/lib/libbsp/sparc/shared/start/start.S b/c/src/lib/libbsp/sparc/shared/start/start.S
>> index e621c39..8f10000 100644
>> --- a/c/src/lib/libbsp/sparc/shared/start/start.S
>> +++ b/c/src/lib/libbsp/sparc/shared/start/start.S
>> @@ -368,9 +368,8 @@ zerobss:
>>   #if !defined(START_LEON3_ENABLE_SMP)
>>           PUBLIC(bsp_reset)
>>   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);
>> +}



More information about the devel mailing list