summaryrefslogtreecommitdiff
path: root/firmware/export
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-03-21 22:58:53 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-03-21 22:58:53 +0000
commit0caf3b8caec97dd14345565977d040c8b7350ad9 (patch)
tree88d0987645099d3903631bbf41b9efc726caacb2 /firmware/export
parenta83a94ea9c8ca260ed8422d08df0c61f93e7ecf6 (diff)
Update sync queues to use a statically allocated return value in order to facilitate upcoming COP updates.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12881 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/export')
-rw-r--r--firmware/export/kernel.h11
-rw-r--r--firmware/export/thread.h42
2 files changed, 45 insertions, 8 deletions
diff --git a/firmware/export/kernel.h b/firmware/export/kernel.h
index 13e353d736..1d27fedd2a 100644
--- a/firmware/export/kernel.h
+++ b/firmware/export/kernel.h
@@ -57,18 +57,13 @@ struct event
};
#ifdef HAVE_EXTENDED_MESSAGING_AND_NAME
-struct queue_sender
-{
- struct thread_entry *thread;
- intptr_t retval;
-};
-
struct queue_sender_list
{
/* If non-NULL, there is a thread waiting for the corresponding event */
- struct queue_sender *senders[QUEUE_LENGTH];
+ /* Must be statically allocated to put in non-cached ram. */
+ struct thread_entry *senders[QUEUE_LENGTH];
/* Send info for last message dequeued or NULL if replied or not sent */
- struct queue_sender *curr_sender;
+ struct thread_entry *curr_sender;
};
#endif /* HAVE_EXTENDED_MESSAGING_AND_NAME */
diff --git a/firmware/export/thread.h b/firmware/export/thread.h
index 1b685066e3..c9132af524 100644
--- a/firmware/export/thread.h
+++ b/firmware/export/thread.h
@@ -20,6 +20,7 @@
#define THREAD_H
#include "config.h"
+#include <inttypes.h>
#include <stdbool.h>
/* Priority scheduling (when enabled with HAVE_PRIORITY_SCHEDULING) works
@@ -109,6 +110,9 @@ struct thread_entry {
long last_run;
#endif
struct thread_entry *next, *prev;
+#ifdef HAVE_EXTENDED_MESSAGING_AND_NAME
+ intptr_t retval;
+#endif
};
struct core_entry {
@@ -127,6 +131,44 @@ struct core_entry {
#define IF_PRIO(empty, type)
#endif
+/* PortalPlayer chips have 2 cores, therefore need atomic mutexes
+ * Just use it for ARM, Coldfire and whatever else well...why not?
+ */
+
+/* Macros generate better code than an inline function is this case */
+#if defined (CPU_PP) || defined (CPU_ARM)
+#define test_and_set(x_, v_) \
+({ \
+ uint32_t old; \
+ asm volatile ( \
+ "swpb %[old], %[v], [%[x]] \r\n" \
+ : [old]"=r"(old) \
+ : [v]"r"((uint32_t)v_), [x]"r"((uint32_t *)x_) \
+ ); \
+ old; \
+ })
+#elif defined (CPU_COLDFIRE)
+#define test_and_set(x_, v_) \
+({ \
+ uint8_t old; \
+ asm volatile ( \
+ "bset.l %[v], (%[x]) \r\n" \
+ "sne.b %[old] \r\n" \
+ : [old]"=d,d"(old) \
+ : [v]"i,d"((uint32_t)v_), [x]"a,a"((uint32_t *)x_) \
+ ); \
+ old; \
+ })
+#else
+/* default for no asm version */
+#define test_and_set(x_, v_) \
+({ \
+ uint32_t old = *(uint32_t *)x_; \
+ *(uint32_t *)x_ = v_; \
+ old; \
+ })
+#endif
+
struct thread_entry*
create_thread(void (*function)(void), void* stack, int stack_size,
const char *name IF_PRIO(, int priority)