diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2017-01-11 09:52:53 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2017-01-11 09:52:53 +0000 |
commit | 163b3562c0074af606b95d608ac4b56ccbab054c (patch) | |
tree | 287e0b8710e4960da0bbfdc85063b08ef8acf90e /os | |
parent | ffea5d743b8cf81452d78b4c70e31cb0fd1336da (diff) | |
download | ChibiOS-163b3562c0074af606b95d608ac4b56ccbab054c.tar.gz ChibiOS-163b3562c0074af606b95d608ac4b56ccbab054c.tar.bz2 ChibiOS-163b3562c0074af606b95d608ac4b56ccbab054c.zip |
Worked around GCC-AVR strange behavior in AVR port.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10023 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r-- | os/common/ports/AVR/chcore.c | 2 | ||||
-rw-r--r-- | os/common/ports/AVR/chcore.h | 18 |
2 files changed, 18 insertions, 2 deletions
diff --git a/os/common/ports/AVR/chcore.c b/os/common/ports/AVR/chcore.c index 36fa01bf0..8ecb47b00 100644 --- a/os/common/ports/AVR/chcore.c +++ b/os/common/ports/AVR/chcore.c @@ -69,7 +69,7 @@ bool __avr_in_isr; #if !defined(__DOXYGEN__)
__attribute__((naked, weak))
#endif
-void port_switch(thread_t *ntp, thread_t *otp) {
+void _port_switch(thread_t *ntp, thread_t *otp) {
asm volatile ("push r2");
asm volatile ("push r3");
diff --git a/os/common/ports/AVR/chcore.h b/os/common/ports/AVR/chcore.h index 87ada538b..039002c4f 100644 --- a/os/common/ports/AVR/chcore.h +++ b/os/common/ports/AVR/chcore.h @@ -341,6 +341,22 @@ struct port_context { #define PORT_FAST_IRQ_HANDLER(id) ISR(id)
/**
+ * @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
+ */
+#define port_switch(ntp, otp) { \
+ _port_switch(ntp, otp); \
+ asm volatile ("" : : : "memory"); \
+}
+
+
+/**
* @brief Port-related initialization code.
* @note This function is empty in this port.
*/
@@ -359,7 +375,7 @@ struct port_context { #ifdef __cplusplus
extern "C" {
#endif
- void port_switch(thread_t *ntp, thread_t *otp);
+ void _port_switch(thread_t *ntp, thread_t *otp);
void _port_thread_start(void);
#ifdef __cplusplus
}
|