diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-01-31 09:27:49 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-01-31 09:27:49 +0000 |
commit | 7f8dfe2fd3e770c2e0435e9c56f5db5fd11ed6f7 (patch) | |
tree | 7335786169736fb133adfdffbc4c60f2050dac0d /os/ports | |
parent | c73b66a3cc8d7808b9c06e031c782345d358b3e9 (diff) | |
download | ChibiOS-7f8dfe2fd3e770c2e0435e9c56f5db5fd11ed6f7.tar.gz ChibiOS-7f8dfe2fd3e770c2e0435e9c56f5db5fd11ed6f7.tar.bz2 ChibiOS-7f8dfe2fd3e770c2e0435e9c56f5db5fd11ed6f7.zip |
Implemented thread reference counters and related APIs.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1556 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/ports')
-rw-r--r-- | os/ports/GCC/ARMCM3/chtypes.h | 19 | ||||
-rw-r--r-- | os/ports/GCC/AVR/chcore.c | 16 |
2 files changed, 26 insertions, 9 deletions
diff --git a/os/ports/GCC/ARMCM3/chtypes.h b/os/ports/GCC/ARMCM3/chtypes.h index 4865002f3..1a854d209 100644 --- a/os/ports/GCC/ARMCM3/chtypes.h +++ b/os/ports/GCC/ARMCM3/chtypes.h @@ -36,15 +36,16 @@ #include <stdint.h>
#endif
-typedef int32_t bool_t; /**< Fast boolean type. */
-typedef uint8_t tmode_t; /**< Thread flags. */
-typedef uint8_t tstate_t; /**< Thread state. */
-typedef uint32_t tprio_t; /**< Thread priority. */
-typedef int32_t msg_t; /**< Inter-thread message. */
-typedef int32_t eventid_t; /**< Event Id. */
-typedef uint32_t eventmask_t; /**< Events mask. */
-typedef uint32_t systime_t; /**< System time. */
-typedef int32_t cnt_t; /**< Resources counter. */
+typedef int32_t bool_t; /**< Fast boolean type. */
+typedef uint8_t tmode_t; /**< Thread flags. */
+typedef uint8_t tstate_t; /**< Thread state. */
+typedef uint8_t trefs_t; /**< Thread references counter. */
+typedef uint32_t tprio_t; /**< Thread priority. */
+typedef int32_t msg_t; /**< Inter-thread message. */
+typedef int32_t eventid_t; /**< Event Id. */
+typedef uint32_t eventmask_t; /**< Events mask. */
+typedef uint32_t systime_t; /**< System time. */
+typedef int32_t cnt_t; /**< Resources counter. */
#define INLINE inline
#define PACK_STRUCT_STRUCT __attribute__((packed))
diff --git a/os/ports/GCC/AVR/chcore.c b/os/ports/GCC/AVR/chcore.c index e4f12b088..e99c2b970 100644 --- a/os/ports/GCC/AVR/chcore.c +++ b/os/ports/GCC/AVR/chcore.c @@ -59,6 +59,21 @@ void port_switch(Thread *otp, Thread *ntp) { asm volatile ("push r28");
asm volatile ("push r29");
+ /* This is required because the context offset changes if CH_USE_DYNAMIC
+ is activated.*/
+#if CH_USE_DYNAMIC
+ asm volatile ("movw r30, r24");
+ asm volatile ("in r0, 0x3d");
+ asm volatile ("std Z+8, r0");
+ asm volatile ("in r0, 0x3e");
+ asm volatile ("std Z+9, r0");
+
+ asm volatile ("movw r30, r22");
+ asm volatile ("ldd r0, Z+8");
+ asm volatile ("out 0x3d, r0");
+ asm volatile ("ldd r0, Z+9");
+ asm volatile ("out 0x3e, r0");
+#else /* !CH_USE_DYNAMIC */
asm volatile ("movw r30, r24");
asm volatile ("in r0, 0x3d");
asm volatile ("std Z+7, r0");
@@ -70,6 +85,7 @@ void port_switch(Thread *otp, Thread *ntp) { asm volatile ("out 0x3d, r0");
asm volatile ("ldd r0, Z+8");
asm volatile ("out 0x3e, r0");
+#endif /* !CH_USE_DYNAMIC */
asm volatile ("pop r29");
asm volatile ("pop r28");
|