aboutsummaryrefslogtreecommitdiffstats
path: root/os/ports/GCC/PPC/chcore.h
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-02-13 11:43:14 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-02-13 11:43:14 +0000
commit24469eee457801a9fe66f6dc77a74c05c50fdbaf (patch)
treeb1859792f95f763dde1cc321739cfed02f05c8e4 /os/ports/GCC/PPC/chcore.h
parent1b8cc3f865d5780ff37d92b2d7fb18df1ef99626 (diff)
downloadChibiOS-24469eee457801a9fe66f6dc77a74c05c50fdbaf.tar.gz
ChibiOS-24469eee457801a9fe66f6dc77a74c05c50fdbaf.tar.bz2
ChibiOS-24469eee457801a9fe66f6dc77a74c05c50fdbaf.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5176 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/ports/GCC/PPC/chcore.h')
-rw-r--r--os/ports/GCC/PPC/chcore.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/os/ports/GCC/PPC/chcore.h b/os/ports/GCC/PPC/chcore.h
index c64737c67..0f78b3b9b 100644
--- a/os/ports/GCC/PPC/chcore.h
+++ b/os/ports/GCC/PPC/chcore.h
@@ -342,6 +342,27 @@ struct context {
#define port_enable() asm volatile ("wrteei 1" : : : "memory")
/**
+ * @brief Performs a context switch between two threads.
+ * @details This is the most critical code in any port, this function
+ * is responsible for the context switch between 2 threads.
+ * @note The implementation of this code affects <b>directly</b> the context
+ * switch performance so optimize here as much as you can.
+ *
+ * @param[in] ntp the thread to be switched in
+ * @param[in] otp the thread to be switched out
+ */
+#if !CH_DBG_ENABLE_STACK_CHECK || defined(__DOXYGEN__)
+#define port_switch(ntp, otp) _port_switch(ntp, otp)
+#else
+#define port_switch(ntp, otp) { \
+ register struct intctx *sp asm ("%r1"); \
+ if ((stkalign_t *)(sp - 1) < otp->p_stklimit) \
+ chDbgPanic("stack overflow"); \
+ _port_switch(ntp, otp); \
+}
+#endif
+
+/**
* @brief Writes to a special register.
*
* @param[in] spr special register number
@@ -369,7 +390,7 @@ extern "C" {
#endif
void port_init(void);
void port_halt(void);
- void port_switch(Thread *ntp, Thread *otp);
+ void _port_switch(Thread *ntp, Thread *otp);
void _port_thread_start(void);
#ifdef __cplusplus
}