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

master
gdisirio 2009-01-05 15:07:55 +00:00
parent bbabbf4ac2
commit e55a45c9e8
4 changed files with 85 additions and 28 deletions

View File

@ -24,6 +24,24 @@
#include <ch.h>
static WORKING_AREA(idle_thread_wa, IDLE_THREAD_STACK_SIZE);
/**
* This function implements the idle thread infinite loop. The function should
* put the processor in the lowest power mode capable to serve interrupts.
* The priority is internally set to the minimum system value so that this
* thread is executed only if there are no other ready threads in the system.
* @param p the thread parameter, unused in this scenario
* @note Implementation should declare this function as a weak symbol in order
* to allow applications to re-implement it.
*/
static void idle_thread(void *p) {
while (TRUE) {
sys_wait_for_interrupt();
}
}
/**
* ChibiOS/RT initialization. After executing this function the current
* instructions stream becomes the main thread.
@ -33,7 +51,6 @@
*/
void chSysInit(void) {
static Thread mainthread;
static WORKING_AREA(idle_wa, IDLE_THREAD_STACK_SIZE);
chSchInit();
chDbgInit();
@ -54,7 +71,8 @@ void chSysInit(void) {
* serve interrupts in its context while keeping the lowest energy saving
* mode compatible with the system status.
*/
chThdCreateStatic(idle_wa, sizeof(idle_wa), IDLEPRIO, (tfunc_t)_idle, NULL);
chThdCreateStatic(idle_wa, sizeof(idle_thread_wa), IDLEPRIO,
(tfunc_t)idle_thread, NULL);
}
/**
@ -76,6 +94,16 @@ void chSysTimerHandlerI(void) {
chVTDoTickI();
}
/**
* Abonormal system termination handler. Invoked by the ChibiOS/RT when an
* abnormal unrecoverable condition is met.
*/
void chSysHalt(void) {
chSysDisable();
sys_halt();
}
#if !defined(CH_OPTIMIZE_SPEED)
/**
* Enters the ChibiOS/RT system mutual exclusion zone.
@ -107,14 +135,4 @@ void chSysUnlock(void) {
}
#endif /* !CH_OPTIMIZE_SPEED */
/**
* Abonormal system termination handler. Invoked by the ChibiOS/RT when an
* abnormal unrecoverable condition is met.
*/
void chSysHalt(void) {
chSysDisable();
sys_halt();
}
/** @} */

View File

@ -86,7 +86,7 @@
* syscall from an interrupt handler.
* @note This API must be invoked exclusively from interrupt handlers.
*/
#define chSysUnlockI() sys_disable_from_isr()
#define chSysUnlockI() sys_enable_from_isr()
#if defined(CH_USE_NESTED_LOCKS) || defined(_DOXYGEN_)
/**
@ -133,7 +133,7 @@
* @note Usually IRQ handlers functions are also declared naked.
* @note On some architectures this macro can be empty.
*/
#define chSysIRQEnterI() sys_irq_prologue()
#define chSysIRQEnterI() SYS_IRQ_PROLOGUE()
/**
* IRQ handler exit code.
@ -141,7 +141,7 @@
* @note This macro usually performs the final reschedulation by using
* \p chSchRescRequiredI() and \p chSchDoRescheduleI().
*/
#define chSysIRQExitI() sys_irq_epilogue()
#define chSysIRQExitI() SYS_IRQ_EPILOGUE()
/**
* Standard modifier for IRQ handler functions.

View File

@ -26,21 +26,36 @@
/*
* This file is a template of the system driver functions provided by a port.
* Some of the following functions may be implemented as macros in chcore.h if
* the implementer decides there is an advantage in doing so, as example
* because performance concerns.
*/
/**
* This function implements the idle thread infinite loop. The function should
* put the processor in the lowest power mode capable to serve interrupts.
* The priority is internally set to the minimum system value so that this
* thread is executed only if there are no other ready threads in the system.
* @param p the thread parameter, unused in this scenario
* @note Implementation should declare this function as a weak symbol in order
* to allow applications to re-implement it.
*/
void _idle(void *p) {
void sys_puts(char *msg) {
}
while (TRUE)
;
void sys_switch(Thread *otp, Thread *ntp) {
}
void sys_enable(void) {
}
void sys_disable(void) {
}
void sys_disable_from_isr(void) {
}
void sys_enable_from_isr(void) {
}
void sys_wait_for_interrupt(void) {
}
void sys_halt(void) {
while(TRUE) {
}
}
/** @} */

View File

@ -106,10 +106,34 @@ typedef struct {
*/
#define WORKING_AREA(s, n) stkalign_t s[THD_WA_SIZE(n) / sizeof(stkalign_t)];
/**
* IRQ prologue code, inserted at the start of all IRQ handlers enabled to
* invoke system APIs.
*/
#define SYS_IRQ_PROLOGUE()
/**
* IRQ epilogue code, inserted at the start of all IRQ handlers enabled to
* invoke system APIs.
*/
#define SYS_IRQ_EPILOGUE()
/**
* IRQ handler function modifier.
*/
#define SYS_IRQ_HANDLER
#ifdef __cplusplus
extern "C" {
#endif
void _idle(void *p);
void sys_puts(char *msg);
void sys_switch(Thread *otp, Thread *ntp);
void sys_enable(void);
void sys_disable(void);
void sys_disable_from_isr(void);
void sys_enable_from_isr(void);
void sys_wait_for_interrupt(void);
void sys_halt(void);
#ifdef __cplusplus
}
#endif