From b7eba42be8e04a6a9cbade60d5ae0190fd34efae Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 10 Jan 2009 15:36:16 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@611 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- ports/ARM7-LPC214x/chcore.c | 4 +--- ports/ARMCM3/chcore.c | 15 +++++++++------ ports/ARMCM3/chcore.h | 7 +++++++ ports/ARMCM3/crt0.s | 4 ++-- src/include/sys.h | 5 +++-- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/ports/ARM7-LPC214x/chcore.c b/ports/ARM7-LPC214x/chcore.c index 858214ea3..dd65e87eb 100644 --- a/ports/ARM7-LPC214x/chcore.c +++ b/ports/ARM7-LPC214x/chcore.c @@ -54,9 +54,7 @@ void sys_wait_for_interrupt(void) { } /** - * Halts the system. This function is invoked by the operating system when an - * unrecoverable error is detected (as example because a programming error in - * the application code that triggers an assertion while in debug mode). + * Halts the system. */ __attribute__((weak)) void sys_halt(void) { diff --git a/ports/ARMCM3/chcore.c b/ports/ARMCM3/chcore.c index 6b4811904..a6871d701 100644 --- a/ports/ARMCM3/chcore.c +++ b/ports/ARMCM3/chcore.c @@ -36,25 +36,28 @@ __attribute__((weak)) void sys_puts(char *msg) { } +/** + * Halts the system. + * @note The function is declared as a weak symbol, it is possible to redefine + * it in your application code. + */ +__attribute__((weak)) void sys_halt(void) { - asm volatile ("cpsid i"); + sys_disable_all(); while (TRUE) { } } /** * Start a thread by invoking its work function. - * If the work function returns @p chThdExit() is automatically invoked. A call - * to @p chSysHalt() is added as failure check in the "impossible" case - * @p chThdExit() returns. + * If the work function returns @p chThdExit() is automatically invoked. */ __attribute__((naked, weak)) void threadstart(void) { asm volatile ("blx r1 \n\t" \ - "bl chThdExit \n\t" \ - "bl chSysHalt "); + "bl chThdExit"); } /** diff --git a/ports/ARMCM3/chcore.h b/ports/ARMCM3/chcore.h index c213b9ffd..a0f0c4f4e 100644 --- a/ports/ARMCM3/chcore.h +++ b/ports/ARMCM3/chcore.h @@ -186,6 +186,13 @@ typedef struct { */ #define sys_enable_from_isr() sys_enable() +/** + * Disables all the interrupt sources, even those having a priority higher + * to the kernel. + * In the Cortex-M3 it raises the priority mask to level 0. + */ +#define sys_disable_all() asm volatile ("cpsid i") + #if ENABLE_WFI_IDLE != 0 /** * This port function is implemented as inlined code for performance reasons. diff --git a/ports/ARMCM3/crt0.s b/ports/ARMCM3/crt0.s index b59f0993b..06bbb49c6 100644 --- a/ports/ARMCM3/crt0.s +++ b/ports/ARMCM3/crt0.s @@ -95,7 +95,7 @@ bloop: movs r0, #0 mov r1, r0 bl main - bl chSysHalt + bl sys_halt /* * Default early initialization code. It is declared weak in order to be @@ -108,7 +108,7 @@ bloop: .weak hwinit0 hwinit0: bx lr - + /* * Default late initialization code. It is declared weak in order to be * replaced by the real initialization code. diff --git a/src/include/sys.h b/src/include/sys.h index cf7cf78a4..25cdbed6a 100644 --- a/src/include/sys.h +++ b/src/include/sys.h @@ -32,8 +32,9 @@ #define chSysPuts(msg) sys_puts(msg) /** - * Abonormal system termination handler. Invoked by the ChibiOS/RT when an - * abnormal unrecoverable condition is met. + * Halts the system. This function is invoked by the operating system when an + * unrecoverable error is detected (as example because a programming error in + * the application code that triggers an assertion while in debug mode). */ #define chSysHalt() sys_halt() -- cgit v1.2.3