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/ARMCM3/chcore.c | 15 +++++++++------ ports/ARMCM3/chcore.h | 7 +++++++ ports/ARMCM3/crt0.s | 4 ++-- 3 files changed, 18 insertions(+), 8 deletions(-) (limited to 'ports/ARMCM3') 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. -- cgit v1.2.3