git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@611 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2009-01-10 15:36:16 +00:00
parent 23626829b9
commit b7eba42be8
5 changed files with 22 additions and 13 deletions

View File

@ -54,9 +54,7 @@ void sys_wait_for_interrupt(void) {
} }
/** /**
* Halts the system. This function is invoked by the operating system when an * Halts the system.
* unrecoverable error is detected (as example because a programming error in
* the application code that triggers an assertion while in debug mode).
*/ */
__attribute__((weak)) __attribute__((weak))
void sys_halt(void) { void sys_halt(void) {

View File

@ -36,25 +36,28 @@ __attribute__((weak))
void sys_puts(char *msg) { 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) { void sys_halt(void) {
asm volatile ("cpsid i"); sys_disable_all();
while (TRUE) { while (TRUE) {
} }
} }
/** /**
* Start a thread by invoking its work function. * Start a thread by invoking its work function.
* If the work function returns @p chThdExit() is automatically invoked. A call * If the work function returns @p chThdExit() is automatically invoked.
* to @p chSysHalt() is added as failure check in the "impossible" case
* @p chThdExit() returns.
*/ */
__attribute__((naked, weak)) __attribute__((naked, weak))
void threadstart(void) { void threadstart(void) {
asm volatile ("blx r1 \n\t" \ asm volatile ("blx r1 \n\t" \
"bl chThdExit \n\t" \ "bl chThdExit");
"bl chSysHalt ");
} }
/** /**

View File

@ -186,6 +186,13 @@ typedef struct {
*/ */
#define sys_enable_from_isr() sys_enable() #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 #if ENABLE_WFI_IDLE != 0
/** /**
* This port function is implemented as inlined code for performance reasons. * This port function is implemented as inlined code for performance reasons.

View File

@ -95,7 +95,7 @@ bloop:
movs r0, #0 movs r0, #0
mov r1, r0 mov r1, r0
bl main bl main
bl chSysHalt bl sys_halt
/* /*
* Default early initialization code. It is declared weak in order to be * Default early initialization code. It is declared weak in order to be

View File

@ -32,8 +32,9 @@
#define chSysPuts(msg) sys_puts(msg) #define chSysPuts(msg) sys_puts(msg)
/** /**
* Abonormal system termination handler. Invoked by the ChibiOS/RT when an * Halts the system. This function is invoked by the operating system when an
* abnormal unrecoverable condition is met. * 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() #define chSysHalt() sys_halt()