diff options
-rw-r--r-- | apps/codec_thread.c | 2 | ||||
-rw-r--r-- | apps/plugin.c | 1 | ||||
-rw-r--r-- | apps/plugin.h | 3 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/audio_thread.c | 4 | ||||
-rw-r--r-- | apps/recorder/pcm_record.c | 6 | ||||
-rw-r--r-- | firmware/drivers/ata.c | 3 | ||||
-rw-r--r-- | firmware/export/thread.h | 11 | ||||
-rw-r--r-- | firmware/kernel.c | 18 | ||||
-rw-r--r-- | firmware/storage.c | 4 | ||||
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c | 2 | ||||
-rw-r--r-- | firmware/target/hosted/sdl/thread-sdl.c | 22 | ||||
-rw-r--r-- | firmware/thread.c | 42 | ||||
-rw-r--r-- | firmware/usb.c | 4 |
13 files changed, 67 insertions, 55 deletions
diff --git a/apps/codec_thread.c b/apps/codec_thread.c index f166f2ba18..6f15ba1fb3 100644 --- a/apps/codec_thread.c +++ b/apps/codec_thread.c | |||
@@ -567,7 +567,7 @@ void codec_thread_resume(void) | |||
567 | 567 | ||
568 | bool is_codec_thread(void) | 568 | bool is_codec_thread(void) |
569 | { | 569 | { |
570 | return thread_get_current() == codec_thread_id; | 570 | return thread_self() == codec_thread_id; |
571 | } | 571 | } |
572 | 572 | ||
573 | #ifdef HAVE_PRIORITY_SCHEDULING | 573 | #ifdef HAVE_PRIORITY_SCHEDULING |
diff --git a/apps/plugin.c b/apps/plugin.c index 192488ef81..3807ad5d76 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -779,6 +779,7 @@ static const struct plugin_api rockbox_api = { | |||
779 | 779 | ||
780 | /* new stuff at the end, sort into place next time | 780 | /* new stuff at the end, sort into place next time |
781 | the API gets incompatible */ | 781 | the API gets incompatible */ |
782 | thread_self, | ||
782 | }; | 783 | }; |
783 | 784 | ||
784 | int plugin_load(const char* plugin, const void* parameter) | 785 | int plugin_load(const char* plugin, const void* parameter) |
diff --git a/apps/plugin.h b/apps/plugin.h index 2275b309d7..43b9818ffd 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -145,7 +145,7 @@ void* plugin_get_buffer(size_t *buffer_size); | |||
145 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 145 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
146 | 146 | ||
147 | /* increase this every time the api struct changes */ | 147 | /* increase this every time the api struct changes */ |
148 | #define PLUGIN_API_VERSION 200 | 148 | #define PLUGIN_API_VERSION 201 |
149 | 149 | ||
150 | /* update this to latest version if a change to the api struct breaks | 150 | /* update this to latest version if a change to the api struct breaks |
151 | backwards compatibility (and please take the opportunity to sort in any | 151 | backwards compatibility (and please take the opportunity to sort in any |
@@ -909,6 +909,7 @@ struct plugin_api { | |||
909 | 909 | ||
910 | /* new stuff at the end, sort into place next time | 910 | /* new stuff at the end, sort into place next time |
911 | the API gets incompatible */ | 911 | the API gets incompatible */ |
912 | unsigned int (*thread_self)(void); | ||
912 | }; | 913 | }; |
913 | 914 | ||
914 | /* plugin header */ | 915 | /* plugin header */ |
diff --git a/apps/plugins/mpegplayer/audio_thread.c b/apps/plugins/mpegplayer/audio_thread.c index 45fa7257ef..f976fd6007 100644 --- a/apps/plugins/mpegplayer/audio_thread.c +++ b/apps/plugins/mpegplayer/audio_thread.c | |||
@@ -468,7 +468,7 @@ static void audio_thread(void) | |||
468 | struct audio_thread_data td; | 468 | struct audio_thread_data td; |
469 | #ifdef HAVE_PRIORITY_SCHEDULING | 469 | #ifdef HAVE_PRIORITY_SCHEDULING |
470 | /* Up the priority since the core DSP over-yields internally */ | 470 | /* Up the priority since the core DSP over-yields internally */ |
471 | int old_priority = rb->thread_set_priority(THREAD_ID_CURRENT, | 471 | int old_priority = rb->thread_set_priority(rb->thread_self(), |
472 | PRIORITY_PLAYBACK-4); | 472 | PRIORITY_PLAYBACK-4); |
473 | #endif | 473 | #endif |
474 | 474 | ||
@@ -514,7 +514,7 @@ static void audio_thread(void) | |||
514 | default: | 514 | default: |
515 | { | 515 | { |
516 | #ifdef HAVE_PRIORITY_SCHEDULING | 516 | #ifdef HAVE_PRIORITY_SCHEDULING |
517 | rb->thread_set_priority(THREAD_ID_CURRENT, old_priority); | 517 | rb->thread_set_priority(rb->thread_self(), old_priority); |
518 | #endif | 518 | #endif |
519 | return; | 519 | return; |
520 | } | 520 | } |
diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c index 8c9207f232..8a832e409c 100644 --- a/apps/recorder/pcm_record.c +++ b/apps/recorder/pcm_record.c | |||
@@ -897,8 +897,8 @@ static void pcmrec_flush(unsigned flush_num) | |||
897 | priority until finished */ | 897 | priority until finished */ |
898 | logf("pcmrec: boost (%s)", | 898 | logf("pcmrec: boost (%s)", |
899 | num >= flood_watermark ? "num" : "time"); | 899 | num >= flood_watermark ? "num" : "time"); |
900 | prio_pcmrec = thread_set_priority(THREAD_ID_CURRENT, | 900 | prio_pcmrec = thread_set_priority(thread_self(), |
901 | thread_get_priority(THREAD_ID_CURRENT) - 4); | 901 | thread_get_priority(thread_self()) - 4); |
902 | prio_codec = codec_thread_set_priority( | 902 | prio_codec = codec_thread_set_priority( |
903 | codec_thread_get_priority() - 4); | 903 | codec_thread_get_priority() - 4); |
904 | } | 904 | } |
@@ -950,7 +950,7 @@ static void pcmrec_flush(unsigned flush_num) | |||
950 | { | 950 | { |
951 | /* return to original priorities */ | 951 | /* return to original priorities */ |
952 | logf("pcmrec: unboost priority"); | 952 | logf("pcmrec: unboost priority"); |
953 | thread_set_priority(THREAD_ID_CURRENT, prio_pcmrec); | 953 | thread_set_priority(thread_self(), prio_pcmrec); |
954 | codec_thread_set_priority(prio_codec); | 954 | codec_thread_set_priority(prio_codec); |
955 | } | 955 | } |
956 | 956 | ||
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index a16a6cc15e..baef6691d4 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c | |||
@@ -99,8 +99,7 @@ static void ata_lock_init(struct ata_lock *l) | |||
99 | 99 | ||
100 | static void ata_lock_lock(struct ata_lock *l) | 100 | static void ata_lock_lock(struct ata_lock *l) |
101 | { | 101 | { |
102 | struct thread_entry * const current = | 102 | struct thread_entry * const current = thread_self_entry(); |
103 | thread_id_entry(THREAD_ID_CURRENT); | ||
104 | 103 | ||
105 | if (current == l->thread) | 104 | if (current == l->thread) |
106 | { | 105 | { |
diff --git a/firmware/export/thread.h b/firmware/export/thread.h index 0db849ab0a..d0f61f9d85 100644 --- a/firmware/export/thread.h +++ b/firmware/export/thread.h | |||
@@ -323,9 +323,6 @@ struct thread_entry | |||
323 | #define THREAD_ID_SLOT_MASK 0x00ff | 323 | #define THREAD_ID_SLOT_MASK 0x00ff |
324 | #define THREAD_ID_INIT(n) ((1u << THREAD_ID_VERSION_SHIFT) | (n)) | 324 | #define THREAD_ID_INIT(n) ((1u << THREAD_ID_VERSION_SHIFT) | (n)) |
325 | 325 | ||
326 | /* Specify current thread in a function taking an ID. */ | ||
327 | #define THREAD_ID_CURRENT ((unsigned int)-1) | ||
328 | |||
329 | #ifdef HAVE_CORELOCK_OBJECT | 326 | #ifdef HAVE_CORELOCK_OBJECT |
330 | /* Operations to be performed just before stopping a thread and starting | 327 | /* Operations to be performed just before stopping a thread and starting |
331 | a new one if specified before calling switch_thread */ | 328 | a new one if specified before calling switch_thread */ |
@@ -445,7 +442,13 @@ int thread_get_io_priority(unsigned int thread_id); | |||
445 | #if NUM_CORES > 1 | 442 | #if NUM_CORES > 1 |
446 | unsigned int switch_core(unsigned int new_core); | 443 | unsigned int switch_core(unsigned int new_core); |
447 | #endif | 444 | #endif |
448 | unsigned int thread_get_current(void); | 445 | |
446 | /* Return the id of the calling thread. */ | ||
447 | unsigned int thread_self(void); | ||
448 | |||
449 | /* Return the thread_entry for the calling thread. | ||
450 | * INTERNAL: Intended for use by kernel and not for programs. */ | ||
451 | struct thread_entry* thread_self_entry(void); | ||
449 | 452 | ||
450 | /* Debugging info - only! */ | 453 | /* Debugging info - only! */ |
451 | int thread_stack_usage(const struct thread_entry *thread); | 454 | int thread_stack_usage(const struct thread_entry *thread); |
diff --git a/firmware/kernel.c b/firmware/kernel.c index a8718ebf34..e0879a3c59 100644 --- a/firmware/kernel.c +++ b/firmware/kernel.c | |||
@@ -509,7 +509,7 @@ void queue_wait(struct event_queue *q, struct queue_event *ev) | |||
509 | 509 | ||
510 | #ifdef HAVE_PRIORITY_SCHEDULING | 510 | #ifdef HAVE_PRIORITY_SCHEDULING |
511 | KERNEL_ASSERT(QUEUE_GET_THREAD(q) == NULL || | 511 | KERNEL_ASSERT(QUEUE_GET_THREAD(q) == NULL || |
512 | QUEUE_GET_THREAD(q) == thread_id_entry(THREAD_ID_CURRENT), | 512 | QUEUE_GET_THREAD(q) == thread_self_entry(), |
513 | "queue_wait->wrong thread\n"); | 513 | "queue_wait->wrong thread\n"); |
514 | #endif | 514 | #endif |
515 | 515 | ||
@@ -527,7 +527,7 @@ void queue_wait(struct event_queue *q, struct queue_event *ev) | |||
527 | if (rd != q->write) /* A waking message could disappear */ | 527 | if (rd != q->write) /* A waking message could disappear */ |
528 | break; | 528 | break; |
529 | 529 | ||
530 | current = thread_id_entry(THREAD_ID_CURRENT); | 530 | current = thread_self_entry(); |
531 | 531 | ||
532 | IF_COP( current->obj_cl = &q->cl; ) | 532 | IF_COP( current->obj_cl = &q->cl; ) |
533 | current->bqp = &q->queue; | 533 | current->bqp = &q->queue; |
@@ -559,7 +559,7 @@ void queue_wait_w_tmo(struct event_queue *q, struct queue_event *ev, int ticks) | |||
559 | 559 | ||
560 | #ifdef HAVE_EXTENDED_MESSAGING_AND_NAME | 560 | #ifdef HAVE_EXTENDED_MESSAGING_AND_NAME |
561 | KERNEL_ASSERT(QUEUE_GET_THREAD(q) == NULL || | 561 | KERNEL_ASSERT(QUEUE_GET_THREAD(q) == NULL || |
562 | QUEUE_GET_THREAD(q) == thread_id_entry(THREAD_ID_CURRENT), | 562 | QUEUE_GET_THREAD(q) == thread_self_entry(), |
563 | "queue_wait_w_tmo->wrong thread\n"); | 563 | "queue_wait_w_tmo->wrong thread\n"); |
564 | #endif | 564 | #endif |
565 | 565 | ||
@@ -573,7 +573,7 @@ void queue_wait_w_tmo(struct event_queue *q, struct queue_event *ev, int ticks) | |||
573 | wr = q->write; | 573 | wr = q->write; |
574 | if (rd == wr && ticks > 0) | 574 | if (rd == wr && ticks > 0) |
575 | { | 575 | { |
576 | struct thread_entry *current = thread_id_entry(THREAD_ID_CURRENT); | 576 | struct thread_entry *current = thread_self_entry(); |
577 | 577 | ||
578 | IF_COP( current->obj_cl = &q->cl; ) | 578 | IF_COP( current->obj_cl = &q->cl; ) |
579 | current->bqp = &q->queue; | 579 | current->bqp = &q->queue; |
@@ -658,7 +658,7 @@ intptr_t queue_send(struct event_queue *q, long id, intptr_t data) | |||
658 | { | 658 | { |
659 | struct queue_sender_list *send = q->send; | 659 | struct queue_sender_list *send = q->send; |
660 | struct thread_entry **spp = &send->senders[wr]; | 660 | struct thread_entry **spp = &send->senders[wr]; |
661 | struct thread_entry *current = thread_id_entry(THREAD_ID_CURRENT); | 661 | struct thread_entry *current = thread_self_entry(); |
662 | 662 | ||
663 | if(UNLIKELY(*spp)) | 663 | if(UNLIKELY(*spp)) |
664 | { | 664 | { |
@@ -893,7 +893,7 @@ void mutex_init(struct mutex *m) | |||
893 | /* Gain ownership of a mutex object or block until it becomes free */ | 893 | /* Gain ownership of a mutex object or block until it becomes free */ |
894 | void mutex_lock(struct mutex *m) | 894 | void mutex_lock(struct mutex *m) |
895 | { | 895 | { |
896 | struct thread_entry *current = thread_id_entry(THREAD_ID_CURRENT); | 896 | struct thread_entry *current = thread_self_entry(); |
897 | 897 | ||
898 | if(current == mutex_get_thread(m)) | 898 | if(current == mutex_get_thread(m)) |
899 | { | 899 | { |
@@ -932,10 +932,10 @@ void mutex_lock(struct mutex *m) | |||
932 | void mutex_unlock(struct mutex *m) | 932 | void mutex_unlock(struct mutex *m) |
933 | { | 933 | { |
934 | /* unlocker not being the owner is an unlocking violation */ | 934 | /* unlocker not being the owner is an unlocking violation */ |
935 | KERNEL_ASSERT(mutex_get_thread(m) == thread_id_entry(THREAD_ID_CURRENT), | 935 | KERNEL_ASSERT(mutex_get_thread(m) == thread_self_entry(), |
936 | "mutex_unlock->wrong thread (%s != %s)\n", | 936 | "mutex_unlock->wrong thread (%s != %s)\n", |
937 | mutex_get_thread(m)->name, | 937 | mutex_get_thread(m)->name, |
938 | thread_id_entry(THREAD_ID_CURRENT)->name); | 938 | thread_self_entry()->name); |
939 | 939 | ||
940 | if(m->recursion > 0) | 940 | if(m->recursion > 0) |
941 | { | 941 | { |
@@ -1019,7 +1019,7 @@ int semaphore_wait(struct semaphore *s, int timeout) | |||
1019 | else | 1019 | else |
1020 | { | 1020 | { |
1021 | /* too many waits - block until count is upped... */ | 1021 | /* too many waits - block until count is upped... */ |
1022 | struct thread_entry * current = thread_id_entry(THREAD_ID_CURRENT); | 1022 | struct thread_entry * current = thread_self_entry(); |
1023 | IF_COP( current->obj_cl = &s->cl; ) | 1023 | IF_COP( current->obj_cl = &s->cl; ) |
1024 | current->bqp = &s->queue; | 1024 | current->bqp = &s->queue; |
1025 | /* return value will be OBJ_WAIT_SUCCEEDED after wait if wake was | 1025 | /* return value will be OBJ_WAIT_SUCCEEDED after wait if wake was |
diff --git a/firmware/storage.c b/firmware/storage.c index 867c68cf6b..69f28d94a8 100644 --- a/firmware/storage.c +++ b/firmware/storage.c | |||
@@ -71,14 +71,14 @@ static void storage_wait_turn(IF_MD_NONVOID(int drive)) | |||
71 | #ifndef HAVE_MULTIDRIVE | 71 | #ifndef HAVE_MULTIDRIVE |
72 | int drive=0; | 72 | int drive=0; |
73 | #endif | 73 | #endif |
74 | int my_prio = thread_get_io_priority(THREAD_ID_CURRENT); | 74 | int my_prio = thread_get_io_priority(thread_self()); |
75 | int loops=my_prio; | 75 | int loops=my_prio; |
76 | while(storage_should_wait(drive, my_prio) && (loops--)>=0) | 76 | while(storage_should_wait(drive, my_prio) && (loops--)>=0) |
77 | { | 77 | { |
78 | sleep(STORAGE_DELAY_UNIT); | 78 | sleep(STORAGE_DELAY_UNIT); |
79 | } | 79 | } |
80 | 80 | ||
81 | storage_last_thread[drive] = thread_get_current(); | 81 | storage_last_thread[drive] = thread_self(); |
82 | storage_last_activity[drive] = current_tick; | 82 | storage_last_activity[drive] = current_tick; |
83 | } | 83 | } |
84 | #endif | 84 | #endif |
diff --git a/firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c index 283c1a2c73..2df461015e 100644 --- a/firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c +++ b/firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c | |||
@@ -197,7 +197,7 @@ static enum | |||
197 | static inline void charging_set_thread_priority(bool charging) | 197 | static inline void charging_set_thread_priority(bool charging) |
198 | { | 198 | { |
199 | #ifdef HAVE_PRIORITY_SCHEDULING | 199 | #ifdef HAVE_PRIORITY_SCHEDULING |
200 | thread_set_priority(THREAD_ID_CURRENT, | 200 | thread_set_priority(thread_self(), |
201 | charging ? PRIORITY_REALTIME : PRIORITY_SYSTEM); | 201 | charging ? PRIORITY_REALTIME : PRIORITY_SYSTEM); |
202 | #endif | 202 | #endif |
203 | (void)charging; | 203 | (void)charging; |
diff --git a/firmware/target/hosted/sdl/thread-sdl.c b/firmware/target/hosted/sdl/thread-sdl.c index 08f20367cc..eaffa86aee 100644 --- a/firmware/target/hosted/sdl/thread-sdl.c +++ b/firmware/target/hosted/sdl/thread-sdl.c | |||
@@ -253,9 +253,7 @@ void * sim_thread_unlock(void) | |||
253 | 253 | ||
254 | struct thread_entry * thread_id_entry(unsigned int thread_id) | 254 | struct thread_entry * thread_id_entry(unsigned int thread_id) |
255 | { | 255 | { |
256 | return (thread_id == THREAD_ID_CURRENT) ? | 256 | return &threads[thread_id & THREAD_ID_SLOT_MASK]; |
257 | cores[CURRENT_CORE].running : | ||
258 | &threads[thread_id & THREAD_ID_SLOT_MASK]; | ||
259 | } | 257 | } |
260 | 258 | ||
261 | static void add_to_list_l(struct thread_entry **list, | 259 | static void add_to_list_l(struct thread_entry **list, |
@@ -299,11 +297,16 @@ static void remove_from_list_l(struct thread_entry **list, | |||
299 | thread->l.next->l.prev = thread->l.prev; | 297 | thread->l.next->l.prev = thread->l.prev; |
300 | } | 298 | } |
301 | 299 | ||
302 | unsigned int thread_get_current(void) | 300 | unsigned int thread_self(void) |
303 | { | 301 | { |
304 | return cores[CURRENT_CORE].running->id; | 302 | return cores[CURRENT_CORE].running->id; |
305 | } | 303 | } |
306 | 304 | ||
305 | struct thread_entry* thread_self_entry(void) | ||
306 | { | ||
307 | return cores[CURRENT_CORE].running; | ||
308 | } | ||
309 | |||
307 | void switch_thread(void) | 310 | void switch_thread(void) |
308 | { | 311 | { |
309 | struct thread_entry *current = cores[CURRENT_CORE].running; | 312 | struct thread_entry *current = cores[CURRENT_CORE].running; |
@@ -562,7 +565,7 @@ void remove_thread(unsigned int thread_id) | |||
562 | SDL_Thread *t; | 565 | SDL_Thread *t; |
563 | SDL_sem *s; | 566 | SDL_sem *s; |
564 | 567 | ||
565 | if (thread_id != THREAD_ID_CURRENT && thread->id != thread_id) | 568 | if (thread->id != thread_id) |
566 | return; | 569 | return; |
567 | 570 | ||
568 | int oldlevel = disable_irq_save(); | 571 | int oldlevel = disable_irq_save(); |
@@ -629,11 +632,11 @@ void remove_thread(unsigned int thread_id) | |||
629 | 632 | ||
630 | void thread_exit(void) | 633 | void thread_exit(void) |
631 | { | 634 | { |
632 | remove_thread(THREAD_ID_CURRENT); | 635 | unsigned int id = thread_self(); |
636 | remove_thread(id); | ||
633 | /* This should never and must never be reached - if it is, the | 637 | /* This should never and must never be reached - if it is, the |
634 | * state is corrupted */ | 638 | * state is corrupted */ |
635 | THREAD_PANICF("thread_exit->K:*R (ID: %d)", | 639 | THREAD_PANICF("thread_exit->K:*R (ID: %d)", id); |
636 | thread_id_entry(THREAD_ID_CURRENT)->id); | ||
637 | while (1); | 640 | while (1); |
638 | } | 641 | } |
639 | 642 | ||
@@ -642,8 +645,7 @@ void thread_wait(unsigned int thread_id) | |||
642 | struct thread_entry *current = cores[CURRENT_CORE].running; | 645 | struct thread_entry *current = cores[CURRENT_CORE].running; |
643 | struct thread_entry *thread = thread_id_entry(thread_id); | 646 | struct thread_entry *thread = thread_id_entry(thread_id); |
644 | 647 | ||
645 | if (thread_id == THREAD_ID_CURRENT || | 648 | if (thread->id == thread_id && thread->state != STATE_KILLED) |
646 | (thread->id == thread_id && thread->state != STATE_KILLED)) | ||
647 | { | 649 | { |
648 | current->bqp = &thread->queue; | 650 | current->bqp = &thread->queue; |
649 | block_thread(current); | 651 | block_thread(current); |
diff --git a/firmware/thread.c b/firmware/thread.c index ea73150853..cfedbbedba 100644 --- a/firmware/thread.c +++ b/firmware/thread.c | |||
@@ -1517,9 +1517,27 @@ static struct thread_entry * find_empty_thread_slot(void) | |||
1517 | */ | 1517 | */ |
1518 | struct thread_entry * thread_id_entry(unsigned int thread_id) | 1518 | struct thread_entry * thread_id_entry(unsigned int thread_id) |
1519 | { | 1519 | { |
1520 | return (thread_id == THREAD_ID_CURRENT) ? | 1520 | return &threads[thread_id & THREAD_ID_SLOT_MASK]; |
1521 | cores[CURRENT_CORE].running : | 1521 | } |
1522 | &threads[thread_id & THREAD_ID_SLOT_MASK]; | 1522 | |
1523 | /*--------------------------------------------------------------------------- | ||
1524 | * Return the thread id of the calling thread | ||
1525 | * -------------------------------------------------------------------------- | ||
1526 | */ | ||
1527 | unsigned int thread_self(void) | ||
1528 | { | ||
1529 | return cores[CURRENT_CORE].running->id; | ||
1530 | } | ||
1531 | |||
1532 | /*--------------------------------------------------------------------------- | ||
1533 | * Return the thread entry of the calling thread. | ||
1534 | * | ||
1535 | * INTERNAL: Intended for use by kernel and not for programs. | ||
1536 | *--------------------------------------------------------------------------- | ||
1537 | */ | ||
1538 | struct thread_entry* thread_self_entry(void) | ||
1539 | { | ||
1540 | return cores[CURRENT_CORE].running; | ||
1523 | } | 1541 | } |
1524 | 1542 | ||
1525 | /*--------------------------------------------------------------------------- | 1543 | /*--------------------------------------------------------------------------- |
@@ -1675,8 +1693,7 @@ void thread_wait(unsigned int thread_id) | |||
1675 | corelock_lock(&thread->waiter_cl); | 1693 | corelock_lock(&thread->waiter_cl); |
1676 | 1694 | ||
1677 | /* Be sure it hasn't been killed yet */ | 1695 | /* Be sure it hasn't been killed yet */ |
1678 | if (thread_id == THREAD_ID_CURRENT || | 1696 | if (thread->id == thread_id && thread->state != STATE_KILLED) |
1679 | (thread->id == thread_id && thread->state != STATE_KILLED)) | ||
1680 | { | 1697 | { |
1681 | IF_COP( current->obj_cl = &thread->waiter_cl; ) | 1698 | IF_COP( current->obj_cl = &thread->waiter_cl; ) |
1682 | current->bqp = &thread->queue; | 1699 | current->bqp = &thread->queue; |
@@ -1973,8 +1990,7 @@ int thread_set_priority(unsigned int thread_id, int priority) | |||
1973 | LOCK_THREAD(thread); | 1990 | LOCK_THREAD(thread); |
1974 | 1991 | ||
1975 | /* Make sure it's not killed */ | 1992 | /* Make sure it's not killed */ |
1976 | if (thread_id == THREAD_ID_CURRENT || | 1993 | if (thread->id == thread_id && thread->state != STATE_KILLED) |
1977 | (thread->id == thread_id && thread->state != STATE_KILLED)) | ||
1978 | { | 1994 | { |
1979 | int old_priority = thread->priority; | 1995 | int old_priority = thread->priority; |
1980 | 1996 | ||
@@ -2099,8 +2115,7 @@ int thread_get_priority(unsigned int thread_id) | |||
2099 | /* Simply check without locking slot. It may or may not be valid by the | 2115 | /* Simply check without locking slot. It may or may not be valid by the |
2100 | * time the function returns anyway. If all tests pass, it is the | 2116 | * time the function returns anyway. If all tests pass, it is the |
2101 | * correct value for when it was valid. */ | 2117 | * correct value for when it was valid. */ |
2102 | if (thread_id != THREAD_ID_CURRENT && | 2118 | if (thread->id != thread_id || thread->state == STATE_KILLED) |
2103 | (thread->id != thread_id || thread->state == STATE_KILLED)) | ||
2104 | base_priority = -1; | 2119 | base_priority = -1; |
2105 | 2120 | ||
2106 | return base_priority; | 2121 | return base_priority; |
@@ -2143,15 +2158,6 @@ void thread_thaw(unsigned int thread_id) | |||
2143 | restore_irq(oldlevel); | 2158 | restore_irq(oldlevel); |
2144 | } | 2159 | } |
2145 | 2160 | ||
2146 | /*--------------------------------------------------------------------------- | ||
2147 | * Return the ID of the currently executing thread. | ||
2148 | *--------------------------------------------------------------------------- | ||
2149 | */ | ||
2150 | unsigned int thread_get_current(void) | ||
2151 | { | ||
2152 | return cores[CURRENT_CORE].running->id; | ||
2153 | } | ||
2154 | |||
2155 | #if NUM_CORES > 1 | 2161 | #if NUM_CORES > 1 |
2156 | /*--------------------------------------------------------------------------- | 2162 | /*--------------------------------------------------------------------------- |
2157 | * Switch the processor that the currently executing thread runs on. | 2163 | * Switch the processor that the currently executing thread runs on. |
diff --git a/firmware/usb.c b/firmware/usb.c index a794e2ac8a..aada27dfd9 100644 --- a/firmware/usb.c +++ b/firmware/usb.c | |||
@@ -220,7 +220,7 @@ static inline void usb_slave_mode(bool on) | |||
220 | { | 220 | { |
221 | trigger_cpu_boost(); | 221 | trigger_cpu_boost(); |
222 | #ifdef HAVE_PRIORITY_SCHEDULING | 222 | #ifdef HAVE_PRIORITY_SCHEDULING |
223 | thread_set_priority(THREAD_ID_CURRENT, PRIORITY_REALTIME); | 223 | thread_set_priority(thread_self(), PRIORITY_REALTIME); |
224 | #endif | 224 | #endif |
225 | disk_unmount_all(); | 225 | disk_unmount_all(); |
226 | usb_attach(); | 226 | usb_attach(); |
@@ -229,7 +229,7 @@ static inline void usb_slave_mode(bool on) | |||
229 | { | 229 | { |
230 | usb_enable(false); | 230 | usb_enable(false); |
231 | #ifdef HAVE_PRIORITY_SCHEDULING | 231 | #ifdef HAVE_PRIORITY_SCHEDULING |
232 | thread_set_priority(THREAD_ID_CURRENT, PRIORITY_SYSTEM); | 232 | thread_set_priority(thread_self(), PRIORITY_SYSTEM); |
233 | #endif | 233 | #endif |
234 | /* Entered exclusive mode */ | 234 | /* Entered exclusive mode */ |
235 | rc = disk_mount_all(); | 235 | rc = disk_mount_all(); |