diff options
author | Thomas Martitz <kugel@rockbox.org> | 2011-02-19 00:09:08 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2011-02-19 00:09:08 +0000 |
commit | 70bb128ae9b92c23480cd40fa90805eedd0db4bc (patch) | |
tree | 411f39311c375fb5c071cafee3db783dca32c42c | |
parent | 8bc2801e7cb78be60967fefa96a71d4e91761630 (diff) | |
download | rockbox-70bb128ae9b92c23480cd40fa90805eedd0db4bc.tar.gz rockbox-70bb128ae9b92c23480cd40fa90805eedd0db4bc.zip |
Cleanup preprocessor around corelock usage and move its definition outside #ifdef ASSEMBLER_THREADS
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29330 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/export/thread.h | 39 | ||||
-rw-r--r-- | firmware/kernel.c | 4 | ||||
-rw-r--r-- | firmware/thread.c | 4 |
3 files changed, 25 insertions, 22 deletions
diff --git a/firmware/export/thread.h b/firmware/export/thread.h index ba49951af6..179979a98a 100644 --- a/firmware/export/thread.h +++ b/firmware/export/thread.h | |||
@@ -125,22 +125,6 @@ struct regs | |||
125 | uint32_t start; /* 40 - Thread start address, or NULL when started */ | 125 | uint32_t start; /* 40 - Thread start address, or NULL when started */ |
126 | }; | 126 | }; |
127 | 127 | ||
128 | #ifdef CPU_PP | ||
129 | #ifdef HAVE_CORELOCK_OBJECT | ||
130 | /* No reliable atomic instruction available - use Peterson's algorithm */ | ||
131 | struct corelock | ||
132 | { | ||
133 | volatile unsigned char myl[NUM_CORES]; | ||
134 | volatile unsigned char turn; | ||
135 | } __attribute__((packed)); | ||
136 | |||
137 | /* Too big to inline everywhere */ | ||
138 | void corelock_init(struct corelock *cl); | ||
139 | void corelock_lock(struct corelock *cl); | ||
140 | int corelock_try_lock(struct corelock *cl); | ||
141 | void corelock_unlock(struct corelock *cl); | ||
142 | #endif /* HAVE_CORELOCK_OBJECT */ | ||
143 | #endif /* CPU_PP */ | ||
144 | #elif defined(CPU_MIPS) | 128 | #elif defined(CPU_MIPS) |
145 | struct regs | 129 | struct regs |
146 | { | 130 | { |
@@ -171,6 +155,23 @@ struct regs | |||
171 | #endif | 155 | #endif |
172 | #endif /* PLATFORM_NATIVE */ | 156 | #endif /* PLATFORM_NATIVE */ |
173 | 157 | ||
158 | #ifdef CPU_PP | ||
159 | #ifdef HAVE_CORELOCK_OBJECT | ||
160 | /* No reliable atomic instruction available - use Peterson's algorithm */ | ||
161 | struct corelock | ||
162 | { | ||
163 | volatile unsigned char myl[NUM_CORES]; | ||
164 | volatile unsigned char turn; | ||
165 | } __attribute__((packed)); | ||
166 | |||
167 | /* Too big to inline everywhere */ | ||
168 | void corelock_init(struct corelock *cl); | ||
169 | void corelock_lock(struct corelock *cl); | ||
170 | int corelock_try_lock(struct corelock *cl); | ||
171 | void corelock_unlock(struct corelock *cl); | ||
172 | #endif /* HAVE_CORELOCK_OBJECT */ | ||
173 | #endif /* CPU_PP */ | ||
174 | |||
174 | /* NOTE: The use of the word "queue" may also refer to a linked list of | 175 | /* NOTE: The use of the word "queue" may also refer to a linked list of |
175 | threads being maintained that are normally dealt with in FIFO order | 176 | threads being maintained that are normally dealt with in FIFO order |
176 | and not necessarily kernel event_queue */ | 177 | and not necessarily kernel event_queue */ |
@@ -266,7 +267,7 @@ struct thread_entry | |||
266 | object where thread is blocked - used | 267 | object where thread is blocked - used |
267 | for implicit unblock and explicit wake | 268 | for implicit unblock and explicit wake |
268 | states: STATE_BLOCKED/STATE_BLOCKED_W_TMO */ | 269 | states: STATE_BLOCKED/STATE_BLOCKED_W_TMO */ |
269 | #if NUM_CORES > 1 | 270 | #ifdef HAVE_CORELOCK_OBJECT |
270 | struct corelock *obj_cl; /* Object corelock where thead is blocked - | 271 | struct corelock *obj_cl; /* Object corelock where thead is blocked - |
271 | states: STATE_BLOCKED/STATE_BLOCKED_W_TMO */ | 272 | states: STATE_BLOCKED/STATE_BLOCKED_W_TMO */ |
272 | struct corelock waiter_cl; /* Corelock for thread_wait */ | 273 | struct corelock waiter_cl; /* Corelock for thread_wait */ |
@@ -323,7 +324,7 @@ struct thread_entry | |||
323 | /* Specify current thread in a function taking an ID. */ | 324 | /* Specify current thread in a function taking an ID. */ |
324 | #define THREAD_ID_CURRENT ((unsigned int)-1) | 325 | #define THREAD_ID_CURRENT ((unsigned int)-1) |
325 | 326 | ||
326 | #if NUM_CORES > 1 | 327 | #ifdef HAVE_CORELOCK_OBJECT |
327 | /* Operations to be performed just before stopping a thread and starting | 328 | /* Operations to be performed just before stopping a thread and starting |
328 | a new one if specified before calling switch_thread */ | 329 | a new one if specified before calling switch_thread */ |
329 | enum | 330 | enum |
@@ -356,7 +357,7 @@ struct core_entry | |||
356 | threads */ | 357 | threads */ |
357 | #endif | 358 | #endif |
358 | long next_tmo_check; /* soonest time to check tmo threads */ | 359 | long next_tmo_check; /* soonest time to check tmo threads */ |
359 | #if NUM_CORES > 1 | 360 | #ifdef HAVE_CORELOCK_OBJECT |
360 | struct thread_blk_ops blk_ops; /* operations to perform when | 361 | struct thread_blk_ops blk_ops; /* operations to perform when |
361 | blocking a thread */ | 362 | blocking a thread */ |
362 | struct corelock rtr_cl; /* Lock for rtr list */ | 363 | struct corelock rtr_cl; /* Lock for rtr list */ |
diff --git a/firmware/kernel.c b/firmware/kernel.c index ee42574055..588bbd2a75 100644 --- a/firmware/kernel.c +++ b/firmware/kernel.c | |||
@@ -68,7 +68,9 @@ void (*tick_funcs[MAX_NUM_TICK_TASKS+1])(void); | |||
68 | static struct | 68 | static struct |
69 | { | 69 | { |
70 | struct event_queue *queues[MAX_NUM_QUEUES+1]; | 70 | struct event_queue *queues[MAX_NUM_QUEUES+1]; |
71 | IF_COP( struct corelock cl; ) | 71 | #ifdef HAVE_CORELOCK_OBJECT |
72 | struct corelock cl; | ||
73 | #endif | ||
72 | } all_queues SHAREDBSS_ATTR; | 74 | } all_queues SHAREDBSS_ATTR; |
73 | 75 | ||
74 | /**************************************************************************** | 76 | /**************************************************************************** |
diff --git a/firmware/thread.c b/firmware/thread.c index bfbaf462a6..ea73150853 100644 --- a/firmware/thread.c +++ b/firmware/thread.c | |||
@@ -967,7 +967,7 @@ void check_tmo_threads(void) | |||
967 | * life again. */ | 967 | * life again. */ |
968 | if (state == STATE_BLOCKED_W_TMO) | 968 | if (state == STATE_BLOCKED_W_TMO) |
969 | { | 969 | { |
970 | #if NUM_CORES > 1 | 970 | #ifdef HAVE_CORELOCK_OBJECT |
971 | /* Lock the waiting thread's kernel object */ | 971 | /* Lock the waiting thread's kernel object */ |
972 | struct corelock *ocl = curr->obj_cl; | 972 | struct corelock *ocl = curr->obj_cl; |
973 | 973 | ||
@@ -1782,7 +1782,7 @@ void thread_exit(void) | |||
1782 | */ | 1782 | */ |
1783 | void remove_thread(unsigned int thread_id) | 1783 | void remove_thread(unsigned int thread_id) |
1784 | { | 1784 | { |
1785 | #if NUM_CORES > 1 | 1785 | #ifdef HAVE_CORELOCK_OBJECT |
1786 | /* core is not constant here because of core switching */ | 1786 | /* core is not constant here because of core switching */ |
1787 | unsigned int core = CURRENT_CORE; | 1787 | unsigned int core = CURRENT_CORE; |
1788 | unsigned int old_core = NUM_CORES; | 1788 | unsigned int old_core = NUM_CORES; |