aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-01-05 15:07:55 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-01-05 15:07:55 +0000
commite55a45c9e8eb2d89878ae935dbf4892566374c86 (patch)
tree1abfa1bd16adc4bafc042b72f9cea09d29094761 /src
parentbbabbf4ac29fc00d38a767cf07db01cf642e937d (diff)
downloadChibiOS-e55a45c9e8eb2d89878ae935dbf4892566374c86.tar.gz
ChibiOS-e55a45c9e8eb2d89878ae935dbf4892566374c86.tar.bz2
ChibiOS-e55a45c9e8eb2d89878ae935dbf4892566374c86.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@583 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src')
-rw-r--r--src/chsys.c42
-rw-r--r--src/include/sys.h6
-rw-r--r--src/templates/chcore.c39
-rw-r--r--src/templates/chcore.h26
4 files changed, 85 insertions, 28 deletions
diff --git a/src/chsys.c b/src/chsys.c
index f57180dd7..0f5f7fa39 100644
--- a/src/chsys.c
+++ b/src/chsys.c
@@ -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();
-}
-
/** @} */
diff --git a/src/include/sys.h b/src/include/sys.h
index 6c905fe63..7cc94ce82 100644
--- a/src/include/sys.h
+++ b/src/include/sys.h
@@ -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.
diff --git a/src/templates/chcore.c b/src/templates/chcore.c
index dbcf26ced..496ffc8fa 100644
--- a/src/templates/chcore.c
+++ b/src/templates/chcore.c
@@ -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) {
+}
+
+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)
- ;
+ while(TRUE) {
+ }
}
/** @} */
diff --git a/src/templates/chcore.h b/src/templates/chcore.h
index a1bc48db1..46d30a3aa 100644
--- a/src/templates/chcore.h
+++ b/src/templates/chcore.h
@@ -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