diff options
-rw-r--r-- | apps/codecs.c | 3 | ||||
-rw-r--r-- | apps/codecs.h | 7 | ||||
-rw-r--r-- | apps/codecs/spc.c | 9 | ||||
-rw-r--r-- | apps/plugin.c | 6 | ||||
-rw-r--r-- | apps/plugin.h | 9 | ||||
-rw-r--r-- | apps/plugins/test_codec.c | 3 | ||||
-rw-r--r-- | apps/voice_thread.c | 12 | ||||
-rw-r--r-- | firmware/export/config.h | 1 | ||||
-rw-r--r-- | firmware/export/kernel.h | 18 | ||||
-rw-r--r-- | firmware/kernel.c | 117 |
10 files changed, 15 insertions, 170 deletions
diff --git a/apps/codecs.c b/apps/codecs.c index 8e9e55a5d4..53fa6755a8 100644 --- a/apps/codecs.c +++ b/apps/codecs.c | |||
@@ -105,9 +105,6 @@ struct codec_api ci = { | |||
105 | semaphore_init, | 105 | semaphore_init, |
106 | semaphore_wait, | 106 | semaphore_wait, |
107 | semaphore_release, | 107 | semaphore_release, |
108 | event_init, | ||
109 | event_wait, | ||
110 | event_set_state, | ||
111 | #endif | 108 | #endif |
112 | 109 | ||
113 | #ifdef CACHE_FUNCTIONS_AS_CALL | 110 | #ifdef CACHE_FUNCTIONS_AS_CALL |
diff --git a/apps/codecs.h b/apps/codecs.h index 6d8c1016a8..4194524e6d 100644 --- a/apps/codecs.h +++ b/apps/codecs.h | |||
@@ -82,12 +82,12 @@ | |||
82 | #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ | 82 | #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ |
83 | 83 | ||
84 | /* increase this every time the api struct changes */ | 84 | /* increase this every time the api struct changes */ |
85 | #define CODEC_API_VERSION 26 | 85 | #define CODEC_API_VERSION 27 |
86 | 86 | ||
87 | /* update this to latest version if a change to the api struct breaks | 87 | /* update this to latest version if a change to the api struct breaks |
88 | backwards compatibility (and please take the opportunity to sort in any | 88 | backwards compatibility (and please take the opportunity to sort in any |
89 | new function which are "waiting" at the end of the function table) */ | 89 | new function which are "waiting" at the end of the function table) */ |
90 | #define CODEC_MIN_API_VERSION 26 | 90 | #define CODEC_MIN_API_VERSION 27 |
91 | 91 | ||
92 | /* codec return codes */ | 92 | /* codec return codes */ |
93 | enum codec_status { | 93 | enum codec_status { |
@@ -175,9 +175,6 @@ struct codec_api { | |||
175 | void (*semaphore_init)(struct semaphore *s, int max, int start); | 175 | void (*semaphore_init)(struct semaphore *s, int max, int start); |
176 | void (*semaphore_wait)(struct semaphore *s); | 176 | void (*semaphore_wait)(struct semaphore *s); |
177 | void (*semaphore_release)(struct semaphore *s); | 177 | void (*semaphore_release)(struct semaphore *s); |
178 | void (*event_init)(struct event *e, unsigned int flags); | ||
179 | void (*event_wait)(struct event *e, unsigned int for_state); | ||
180 | void (*event_set_state)(struct event *e, unsigned int state); | ||
181 | #endif /* NUM_CORES */ | 178 | #endif /* NUM_CORES */ |
182 | 179 | ||
183 | #ifdef CACHE_FUNCTIONS_AS_CALL | 180 | #ifdef CACHE_FUNCTIONS_AS_CALL |
diff --git a/apps/codecs/spc.c b/apps/codecs/spc.c index da91eb0391..a2b6fabf99 100644 --- a/apps/codecs/spc.c +++ b/apps/codecs/spc.c | |||
@@ -230,7 +230,7 @@ static struct | |||
230 | int head, tail; | 230 | int head, tail; |
231 | struct semaphore emu_sem_head; | 231 | struct semaphore emu_sem_head; |
232 | struct semaphore emu_sem_tail; | 232 | struct semaphore emu_sem_tail; |
233 | struct event emu_evt_reply; | 233 | struct semaphore emu_evt_reply; |
234 | intptr_t retval; | 234 | intptr_t retval; |
235 | struct sample_queue_chunk wav_chunk[WAV_NUM_CHUNKS]; | 235 | struct sample_queue_chunk wav_chunk[WAV_NUM_CHUNKS]; |
236 | } sample_queue SHAREDBSS_ATTR; | 236 | } sample_queue SHAREDBSS_ATTR; |
@@ -284,7 +284,7 @@ static intptr_t emu_thread_send_msg(long id, intptr_t data) | |||
284 | 284 | ||
285 | if (id != SPC_EMU_QUIT) { | 285 | if (id != SPC_EMU_QUIT) { |
286 | /* Wait for a response */ | 286 | /* Wait for a response */ |
287 | ci->event_wait(&sample_queue.emu_evt_reply, STATE_SIGNALED); | 287 | ci->semaphore_wait(&sample_queue.emu_evt_reply); |
288 | } | 288 | } |
289 | 289 | ||
290 | return sample_queue.retval; | 290 | return sample_queue.retval; |
@@ -316,7 +316,7 @@ static bool emu_thread_process_msg(struct sample_queue_chunk *chunk) | |||
316 | } | 316 | } |
317 | 317 | ||
318 | if (id != SPC_EMU_QUIT) { | 318 | if (id != SPC_EMU_QUIT) { |
319 | ci->event_set_state(&sample_queue.emu_evt_reply, STATE_SIGNALED); | 319 | ci->semaphore_release(&sample_queue.emu_evt_reply); |
320 | } | 320 | } |
321 | 321 | ||
322 | return ret; | 322 | return ret; |
@@ -361,8 +361,7 @@ static bool spc_emu_start(void) | |||
361 | 361 | ||
362 | /* Initialize audio queue as full to prevent emu thread from trying to run the | 362 | /* Initialize audio queue as full to prevent emu thread from trying to run the |
363 | emulator before loading something */ | 363 | emulator before loading something */ |
364 | ci->event_init(&sample_queue.emu_evt_reply, | 364 | ci->semaphore_init(&sample_queue.emu_evt_reply, 1, 0); |
365 | EVENT_AUTOMATIC | STATE_NONSIGNALED); | ||
366 | ci->semaphore_init(&sample_queue.emu_sem_tail, 2, 0); | 365 | ci->semaphore_init(&sample_queue.emu_sem_tail, 2, 0); |
367 | ci->semaphore_init(&sample_queue.emu_sem_head, 2, 2); | 366 | ci->semaphore_init(&sample_queue.emu_sem_head, 2, 2); |
368 | sample_queue.head = 0; | 367 | sample_queue.head = 0; |
diff --git a/apps/plugin.c b/apps/plugin.c index 4ba1396085..a9c9a6c3f8 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -614,11 +614,7 @@ static const struct plugin_api rockbox_api = { | |||
614 | semaphore_wait, | 614 | semaphore_wait, |
615 | semaphore_release, | 615 | semaphore_release, |
616 | #endif | 616 | #endif |
617 | #ifdef HAVE_EVENT_OBJECTS | 617 | |
618 | event_init, | ||
619 | event_wait, | ||
620 | event_set_state, | ||
621 | #endif | ||
622 | appsversion, | 618 | appsversion, |
623 | /* new stuff at the end, sort into place next time | 619 | /* new stuff at the end, sort into place next time |
624 | the API gets incompatible */ | 620 | the API gets incompatible */ |
diff --git a/apps/plugin.h b/apps/plugin.h index 1029431cd1..9544b3851c 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -130,12 +130,12 @@ void* plugin_get_buffer(size_t *buffer_size); | |||
130 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 130 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
131 | 131 | ||
132 | /* increase this every time the api struct changes */ | 132 | /* increase this every time the api struct changes */ |
133 | #define PLUGIN_API_VERSION 124 | 133 | #define PLUGIN_API_VERSION 125 |
134 | 134 | ||
135 | /* update this to latest version if a change to the api struct breaks | 135 | /* update this to latest version if a change to the api struct breaks |
136 | backwards compatibility (and please take the opportunity to sort in any | 136 | backwards compatibility (and please take the opportunity to sort in any |
137 | new function which are "waiting" at the end of the function table) */ | 137 | new function which are "waiting" at the end of the function table) */ |
138 | #define PLUGIN_MIN_API_VERSION 123 | 138 | #define PLUGIN_MIN_API_VERSION 125 |
139 | 139 | ||
140 | /* plugin return codes */ | 140 | /* plugin return codes */ |
141 | enum plugin_status { | 141 | enum plugin_status { |
@@ -770,11 +770,6 @@ struct plugin_api { | |||
770 | void (*semaphore_wait)(struct semaphore *s); | 770 | void (*semaphore_wait)(struct semaphore *s); |
771 | void (*semaphore_release)(struct semaphore *s); | 771 | void (*semaphore_release)(struct semaphore *s); |
772 | #endif | 772 | #endif |
773 | #ifdef HAVE_EVENT_OBJECTS | ||
774 | void (*event_init)(struct event *e, unsigned int flags); | ||
775 | void (*event_wait)(struct event *e, unsigned int for_state); | ||
776 | void (*event_set_state)(struct event *e, unsigned int state); | ||
777 | #endif | ||
778 | 773 | ||
779 | const char *appsversion; | 774 | const char *appsversion; |
780 | /* new stuff at the end, sort into place next time | 775 | /* new stuff at the end, sort into place next time |
diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index 448b512c83..3c54610a94 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c | |||
@@ -493,9 +493,6 @@ static void init_ci(void) | |||
493 | ci.semaphore_init = rb->semaphore_init; | 493 | ci.semaphore_init = rb->semaphore_init; |
494 | ci.semaphore_wait = rb->semaphore_wait; | 494 | ci.semaphore_wait = rb->semaphore_wait; |
495 | ci.semaphore_release = rb->semaphore_release; | 495 | ci.semaphore_release = rb->semaphore_release; |
496 | ci.event_init = rb->event_init; | ||
497 | ci.event_wait = rb->event_wait; | ||
498 | ci.event_set_state = rb->event_set_state; | ||
499 | #endif | 496 | #endif |
500 | 497 | ||
501 | } | 498 | } |
diff --git a/apps/voice_thread.c b/apps/voice_thread.c index aeffa5bd7c..084c3872c6 100644 --- a/apps/voice_thread.c +++ b/apps/voice_thread.c | |||
@@ -61,8 +61,8 @@ static const char voice_thread_name[] = "voice"; | |||
61 | /* Voice thread synchronization objects */ | 61 | /* Voice thread synchronization objects */ |
62 | static struct event_queue voice_queue SHAREDBSS_ATTR; | 62 | static struct event_queue voice_queue SHAREDBSS_ATTR; |
63 | static struct mutex voice_mutex SHAREDBSS_ATTR; | 63 | static struct mutex voice_mutex SHAREDBSS_ATTR; |
64 | static struct event voice_event SHAREDBSS_ATTR; | ||
65 | static struct queue_sender_list voice_queue_sender_list SHAREDBSS_ATTR; | 64 | static struct queue_sender_list voice_queue_sender_list SHAREDBSS_ATTR; |
65 | static bool voice_done SHAREDDATA_ATTR = true; | ||
66 | 66 | ||
67 | /* Buffer for decoded samples */ | 67 | /* Buffer for decoded samples */ |
68 | static spx_int16_t voice_output_buf[VOICE_FRAME_SIZE] CACHEALIGN_ATTR; | 68 | static spx_int16_t voice_output_buf[VOICE_FRAME_SIZE] CACHEALIGN_ATTR; |
@@ -189,9 +189,9 @@ void voice_wait(void) | |||
189 | /* NOTE: One problem here is that we can't tell if another thread started a | 189 | /* NOTE: One problem here is that we can't tell if another thread started a |
190 | * new clip by the time we wait. This should be resolvable if conditions | 190 | * new clip by the time we wait. This should be resolvable if conditions |
191 | * ever require knowing the very clip you requested has finished. */ | 191 | * ever require knowing the very clip you requested has finished. */ |
192 | event_wait(&voice_event, STATE_SIGNALED); | 192 | |
193 | /* Wait for PCM buffer to be exhausted. Works only if not playing. */ | 193 | /* Wait for PCM buffer to be exhausted. Works only if not playing. */ |
194 | while(!playback_is_playing() && pcm_is_playing()) | 194 | while(!voice_done || (!playback_is_playing() && pcm_is_playing())) |
195 | sleep(1); | 195 | sleep(1); |
196 | } | 196 | } |
197 | 197 | ||
@@ -219,7 +219,7 @@ static void voice_message(struct voice_thread_data *td) | |||
219 | case Q_VOICE_PLAY: | 219 | case Q_VOICE_PLAY: |
220 | LOGFQUEUE("voice < Q_VOICE_PLAY"); | 220 | LOGFQUEUE("voice < Q_VOICE_PLAY"); |
221 | /* Put up a block for completion signal */ | 221 | /* Put up a block for completion signal */ |
222 | event_set_state(&voice_event, STATE_NONSIGNALED); | 222 | voice_done = false; |
223 | 223 | ||
224 | /* Copy the clip info */ | 224 | /* Copy the clip info */ |
225 | td->vi = *(struct voice_info *)td->ev.data; | 225 | td->vi = *(struct voice_info *)td->ev.data; |
@@ -264,7 +264,7 @@ static void voice_message(struct voice_thread_data *td) | |||
264 | cancel_cpu_boost(); | 264 | cancel_cpu_boost(); |
265 | 265 | ||
266 | td->state = TSTATE_STOPPED; | 266 | td->state = TSTATE_STOPPED; |
267 | event_set_state(&voice_event, STATE_SIGNALED); | 267 | voice_done = true; |
268 | break; | 268 | break; |
269 | 269 | ||
270 | case Q_VOICE_STATE: | 270 | case Q_VOICE_STATE: |
@@ -433,7 +433,7 @@ void voice_thread_init(void) | |||
433 | logf("Starting voice thread"); | 433 | logf("Starting voice thread"); |
434 | queue_init(&voice_queue, false); | 434 | queue_init(&voice_queue, false); |
435 | mutex_init(&voice_mutex); | 435 | mutex_init(&voice_mutex); |
436 | event_init(&voice_event, STATE_SIGNALED | EVENT_MANUAL); | 436 | |
437 | voice_thread_p = create_thread(voice_thread, voice_stack, | 437 | voice_thread_p = create_thread(voice_thread, voice_stack, |
438 | sizeof(voice_stack), CREATE_THREAD_FROZEN, | 438 | sizeof(voice_stack), CREATE_THREAD_FROZEN, |
439 | voice_thread_name IF_PRIO(, PRIORITY_PLAYBACK) IF_COP(, CPU)); | 439 | voice_thread_name IF_PRIO(, PRIORITY_PLAYBACK) IF_COP(, CPU)); |
diff --git a/firmware/export/config.h b/firmware/export/config.h index 73ecca1495..e425bf98e5 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h | |||
@@ -409,7 +409,6 @@ | |||
409 | #endif /* SIMULATOR */ | 409 | #endif /* SIMULATOR */ |
410 | 410 | ||
411 | #define HAVE_SEMAPHORE_OBJECTS | 411 | #define HAVE_SEMAPHORE_OBJECTS |
412 | #define HAVE_EVENT_OBJECTS | ||
413 | 412 | ||
414 | #ifdef TOSHIBA_GIGABEAT_F | 413 | #ifdef TOSHIBA_GIGABEAT_F |
415 | #define HAVE_WAKEUP_OBJECTS | 414 | #define HAVE_WAKEUP_OBJECTS |
diff --git a/firmware/export/kernel.h b/firmware/export/kernel.h index 1824962dfd..51eb635004 100644 --- a/firmware/export/kernel.h +++ b/firmware/export/kernel.h | |||
@@ -176,17 +176,6 @@ struct semaphore | |||
176 | }; | 176 | }; |
177 | #endif | 177 | #endif |
178 | 178 | ||
179 | #ifdef HAVE_EVENT_OBJECTS | ||
180 | struct event | ||
181 | { | ||
182 | struct thread_entry *queues[2]; /* waiters for each state */ | ||
183 | unsigned char automatic; /* event performs auto-reset */ | ||
184 | unsigned char state; /* state: 1 = signaled */ | ||
185 | IF_COP( struct corelock cl; ) /* multiprocessor sync */ | ||
186 | }; | ||
187 | #endif | ||
188 | |||
189 | |||
190 | #ifdef HAVE_WAKEUP_OBJECTS | 179 | #ifdef HAVE_WAKEUP_OBJECTS |
191 | struct wakeup | 180 | struct wakeup |
192 | { | 181 | { |
@@ -286,13 +275,6 @@ extern void semaphore_init(struct semaphore *s, int max, int start); | |||
286 | extern void semaphore_wait(struct semaphore *s); | 275 | extern void semaphore_wait(struct semaphore *s); |
287 | extern void semaphore_release(struct semaphore *s); | 276 | extern void semaphore_release(struct semaphore *s); |
288 | #endif /* HAVE_SEMAPHORE_OBJECTS */ | 277 | #endif /* HAVE_SEMAPHORE_OBJECTS */ |
289 | #ifdef HAVE_EVENT_OBJECTS | ||
290 | #define EVENT_AUTOMATIC 0x10 | ||
291 | #define EVENT_MANUAL 0x00 | ||
292 | extern void event_init(struct event *e, unsigned int flags); | ||
293 | extern void event_wait(struct event *e, unsigned int for_state); | ||
294 | extern void event_set_state(struct event *e, unsigned int state); | ||
295 | #endif /* HAVE_EVENT_OBJECTS */ | ||
296 | 278 | ||
297 | #ifdef HAVE_WAKEUP_OBJECTS | 279 | #ifdef HAVE_WAKEUP_OBJECTS |
298 | extern void wakeup_init(struct wakeup *w); | 280 | extern void wakeup_init(struct wakeup *w); |
diff --git a/firmware/kernel.c b/firmware/kernel.c index 10efb87cf4..fb9c5e2449 100644 --- a/firmware/kernel.c +++ b/firmware/kernel.c | |||
@@ -1264,122 +1264,6 @@ void semaphore_release(struct semaphore *s) | |||
1264 | } | 1264 | } |
1265 | #endif /* HAVE_SEMAPHORE_OBJECTS */ | 1265 | #endif /* HAVE_SEMAPHORE_OBJECTS */ |
1266 | 1266 | ||
1267 | /**************************************************************************** | ||
1268 | * Simple event functions ;) | ||
1269 | ****************************************************************************/ | ||
1270 | #ifdef HAVE_EVENT_OBJECTS | ||
1271 | void event_init(struct event *e, unsigned int flags) | ||
1272 | { | ||
1273 | e->queues[STATE_NONSIGNALED] = NULL; | ||
1274 | e->queues[STATE_SIGNALED] = NULL; | ||
1275 | e->state = flags & STATE_SIGNALED; | ||
1276 | e->automatic = (flags & EVENT_AUTOMATIC) ? 1 : 0; | ||
1277 | corelock_init(&e->cl); | ||
1278 | } | ||
1279 | |||
1280 | void event_wait(struct event *e, unsigned int for_state) | ||
1281 | { | ||
1282 | struct thread_entry *current; | ||
1283 | |||
1284 | corelock_lock(&e->cl); | ||
1285 | |||
1286 | if(e->automatic != 0) | ||
1287 | { | ||
1288 | /* wait for false always satisfied by definition | ||
1289 | or if it just changed to false */ | ||
1290 | if(e->state == STATE_SIGNALED || for_state == STATE_NONSIGNALED) | ||
1291 | { | ||
1292 | /* automatic - unsignal */ | ||
1293 | e->state = STATE_NONSIGNALED; | ||
1294 | corelock_unlock(&e->cl); | ||
1295 | return; | ||
1296 | } | ||
1297 | /* block until state matches */ | ||
1298 | } | ||
1299 | else if(for_state == e->state) | ||
1300 | { | ||
1301 | /* the state being waited for is the current state */ | ||
1302 | corelock_unlock(&e->cl); | ||
1303 | return; | ||
1304 | } | ||
1305 | |||
1306 | /* block until state matches what callers requests */ | ||
1307 | current = cores[CURRENT_CORE].running; | ||
1308 | |||
1309 | IF_COP( current->obj_cl = &e->cl; ) | ||
1310 | current->bqp = &e->queues[for_state]; | ||
1311 | |||
1312 | disable_irq(); | ||
1313 | block_thread(current); | ||
1314 | |||
1315 | corelock_unlock(&e->cl); | ||
1316 | |||
1317 | /* turn control over to next thread */ | ||
1318 | switch_thread(); | ||
1319 | } | ||
1320 | |||
1321 | void event_set_state(struct event *e, unsigned int state) | ||
1322 | { | ||
1323 | unsigned int result; | ||
1324 | int oldlevel; | ||
1325 | |||
1326 | corelock_lock(&e->cl); | ||
1327 | |||
1328 | if(e->state == state) | ||
1329 | { | ||
1330 | /* no change */ | ||
1331 | corelock_unlock(&e->cl); | ||
1332 | return; | ||
1333 | } | ||
1334 | |||
1335 | IF_PRIO( result = THREAD_OK; ) | ||
1336 | |||
1337 | oldlevel = disable_irq_save(); | ||
1338 | |||
1339 | if(state == STATE_SIGNALED) | ||
1340 | { | ||
1341 | if(e->automatic != 0) | ||
1342 | { | ||
1343 | /* no thread should have ever blocked for nonsignaled */ | ||
1344 | KERNEL_ASSERT(e->queues[STATE_NONSIGNALED] == NULL, | ||
1345 | "set_event_state->queue[NS]:S\n"); | ||
1346 | /* pass to next thread and keep unsignaled - "pulse" */ | ||
1347 | result = wakeup_thread(&e->queues[STATE_SIGNALED]); | ||
1348 | e->state = (result & THREAD_OK) ? STATE_NONSIGNALED : STATE_SIGNALED; | ||
1349 | } | ||
1350 | else | ||
1351 | { | ||
1352 | /* release all threads waiting for signaled */ | ||
1353 | e->state = STATE_SIGNALED; | ||
1354 | IF_PRIO( result = ) | ||
1355 | thread_queue_wake(&e->queues[STATE_SIGNALED]); | ||
1356 | } | ||
1357 | } | ||
1358 | else | ||
1359 | { | ||
1360 | /* release all threads waiting for nonsignaled */ | ||
1361 | |||
1362 | /* no thread should have ever blocked if automatic */ | ||
1363 | KERNEL_ASSERT(e->queues[STATE_NONSIGNALED] == NULL || | ||
1364 | e->automatic == 0, "set_event_state->queue[NS]:NS\n"); | ||
1365 | |||
1366 | e->state = STATE_NONSIGNALED; | ||
1367 | IF_PRIO( result = ) | ||
1368 | thread_queue_wake(&e->queues[STATE_NONSIGNALED]); | ||
1369 | } | ||
1370 | |||
1371 | restore_irq(oldlevel); | ||
1372 | |||
1373 | corelock_unlock(&e->cl); | ||
1374 | |||
1375 | #ifdef HAVE_PRIORITY_SCHEDULING | ||
1376 | if(result & THREAD_SWITCH) | ||
1377 | switch_thread(); | ||
1378 | #endif | ||
1379 | } | ||
1380 | #endif /* HAVE_EVENT_OBJECTS */ | ||
1381 | |||
1382 | |||
1383 | #ifdef HAVE_WAKEUP_OBJECTS | 1267 | #ifdef HAVE_WAKEUP_OBJECTS |
1384 | /**************************************************************************** | 1268 | /**************************************************************************** |
1385 | * Lightweight IRQ-compatible wakeup object | 1269 | * Lightweight IRQ-compatible wakeup object |
@@ -1456,4 +1340,3 @@ int wakeup_signal(struct wakeup *w) | |||
1456 | return ret; | 1340 | return ret; |
1457 | } | 1341 | } |
1458 | #endif /* HAVE_WAKEUP_OBJECTS */ | 1342 | #endif /* HAVE_WAKEUP_OBJECTS */ |
1459 | |||