diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2006-10-15 11:57:52 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2006-10-15 11:57:52 +0000 |
commit | 70587527898345fdb7245be7c8723b338323fceb (patch) | |
tree | 2cd1f4570c34db202f2a4b4cc9fa867e1f7582f1 /firmware | |
parent | 450f619dcf4904e5aee00b89c417a5ba8a1bf23f (diff) | |
download | rockbox-70587527898345fdb7245be7c8723b338323fceb.tar.gz rockbox-70587527898345fdb7245be7c8723b338323fceb.zip |
Removed ugly boosting solutions from playback code and let scheduler
handle unboosting instead.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11226 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/export/config.h | 1 | ||||
-rw-r--r-- | firmware/export/thread.h | 8 | ||||
-rw-r--r-- | firmware/thread.c | 32 |
3 files changed, 39 insertions, 2 deletions
diff --git a/firmware/export/config.h b/firmware/export/config.h index 1b756cc6bd..6a3091de30 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h | |||
@@ -222,6 +222,7 @@ | |||
222 | 222 | ||
223 | #if (CONFIG_CODEC == SWCODEC) && !defined(SIMULATOR) && !defined(BOOTLOADER) | 223 | #if (CONFIG_CODEC == SWCODEC) && !defined(SIMULATOR) && !defined(BOOTLOADER) |
224 | #define HAVE_PRIORITY_SCHEDULING | 224 | #define HAVE_PRIORITY_SCHEDULING |
225 | #define HAVE_SCHEDULER_BOOSTCTRL | ||
225 | #endif | 226 | #endif |
226 | 227 | ||
227 | /* define for all cpus from coldfire family */ | 228 | /* define for all cpus from coldfire family */ |
diff --git a/firmware/export/thread.h b/firmware/export/thread.h index cd532c8968..17e6e3aa88 100644 --- a/firmware/export/thread.h +++ b/firmware/export/thread.h | |||
@@ -131,12 +131,18 @@ struct thread_entry* | |||
131 | const char *name | 131 | const char *name |
132 | IF_PRIO(, int priority)); | 132 | IF_PRIO(, int priority)); |
133 | 133 | ||
134 | #ifdef HAVE_SCHEDULER_BOOSTCTRL | ||
135 | void trigger_cpu_boost(void); | ||
136 | #else | ||
137 | #define trigger_cpu_boost() | ||
138 | #endif | ||
139 | |||
134 | void remove_thread(struct thread_entry *thread); | 140 | void remove_thread(struct thread_entry *thread); |
135 | void switch_thread(bool save_context, struct thread_entry **blocked_list); | 141 | void switch_thread(bool save_context, struct thread_entry **blocked_list); |
136 | void sleep_thread(int ticks); | 142 | void sleep_thread(int ticks); |
137 | void block_thread(struct thread_entry **thread, int timeout); | 143 | void block_thread(struct thread_entry **thread, int timeout); |
138 | void wakeup_thread(struct thread_entry **thread); | 144 | void wakeup_thread(struct thread_entry **thread); |
139 | void thread_set_priority(struct thread_entry *thread, int priority); | 145 | int thread_set_priority(struct thread_entry *thread, int priority); |
140 | void init_threads(void); | 146 | void init_threads(void); |
141 | int thread_stack_usage(const struct thread_entry *thread); | 147 | int thread_stack_usage(const struct thread_entry *thread); |
142 | int thread_get_status(const struct thread_entry *thread); | 148 | int thread_get_status(const struct thread_entry *thread); |
diff --git a/firmware/thread.c b/firmware/thread.c index 205375a44d..6a94a52333 100644 --- a/firmware/thread.c +++ b/firmware/thread.c | |||
@@ -35,6 +35,9 @@ struct core_entry cores[NUM_CORES] IBSS_ATTR; | |||
35 | #ifdef HAVE_PRIORITY_SCHEDULING | 35 | #ifdef HAVE_PRIORITY_SCHEDULING |
36 | static unsigned short highest_priority IBSS_ATTR; | 36 | static unsigned short highest_priority IBSS_ATTR; |
37 | #endif | 37 | #endif |
38 | #ifdef HAVE_SCHEDULER_BOOSTCTRL | ||
39 | static bool cpu_boosted IBSS_ATTR; | ||
40 | #endif | ||
38 | 41 | ||
39 | /* Define to enable additional checks for blocking violations etc. */ | 42 | /* Define to enable additional checks for blocking violations etc. */ |
40 | // #define THREAD_EXTRA_CHECKS | 43 | // #define THREAD_EXTRA_CHECKS |
@@ -332,6 +335,14 @@ static inline void sleep_core(void) | |||
332 | if (cores[CURRENT_CORE].running != NULL) | 335 | if (cores[CURRENT_CORE].running != NULL) |
333 | break; | 336 | break; |
334 | 337 | ||
338 | #ifdef HAVE_SCHEDULER_BOOSTCTRL | ||
339 | if (cpu_boosted) | ||
340 | { | ||
341 | cpu_boost(false); | ||
342 | cpu_boosted = false; | ||
343 | } | ||
344 | #endif | ||
345 | |||
335 | /* Enter sleep mode to reduce power usage, woken up on interrupt */ | 346 | /* Enter sleep mode to reduce power usage, woken up on interrupt */ |
336 | #ifdef CPU_COLDFIRE | 347 | #ifdef CPU_COLDFIRE |
337 | asm volatile ("stop #0x2000"); | 348 | asm volatile ("stop #0x2000"); |
@@ -646,6 +657,17 @@ struct thread_entry* | |||
646 | return thread; | 657 | return thread; |
647 | } | 658 | } |
648 | 659 | ||
660 | #ifdef HAVE_SCHEDULER_BOOSTCTRL | ||
661 | void trigger_cpu_boost(void) | ||
662 | { | ||
663 | if (!cpu_boosted) | ||
664 | { | ||
665 | cpu_boost(true); | ||
666 | cpu_boosted = true; | ||
667 | } | ||
668 | } | ||
669 | #endif | ||
670 | |||
649 | /*--------------------------------------------------------------------------- | 671 | /*--------------------------------------------------------------------------- |
650 | * Remove a thread on the current core from the scheduler. | 672 | * Remove a thread on the current core from the scheduler. |
651 | * Parameter is the ID as returned from create_thread(). | 673 | * Parameter is the ID as returned from create_thread(). |
@@ -676,13 +698,18 @@ void remove_thread(struct thread_entry *thread) | |||
676 | } | 698 | } |
677 | 699 | ||
678 | #ifdef HAVE_PRIORITY_SCHEDULING | 700 | #ifdef HAVE_PRIORITY_SCHEDULING |
679 | void thread_set_priority(struct thread_entry *thread, int priority) | 701 | int thread_set_priority(struct thread_entry *thread, int priority) |
680 | { | 702 | { |
703 | int old_priority; | ||
704 | |||
681 | if (thread == NULL) | 705 | if (thread == NULL) |
682 | thread = cores[CURRENT_CORE].running; | 706 | thread = cores[CURRENT_CORE].running; |
683 | 707 | ||
708 | old_priority = thread->priority; | ||
684 | thread->priority = priority; | 709 | thread->priority = priority; |
685 | highest_priority = 100; | 710 | highest_priority = 100; |
711 | |||
712 | return old_priority; | ||
686 | } | 713 | } |
687 | #endif | 714 | #endif |
688 | 715 | ||
@@ -699,6 +726,9 @@ void init_threads(void) | |||
699 | cores[core].threads[0].priority = PRIORITY_USER_INTERFACE; | 726 | cores[core].threads[0].priority = PRIORITY_USER_INTERFACE; |
700 | highest_priority = 100; | 727 | highest_priority = 100; |
701 | #endif | 728 | #endif |
729 | #ifdef HAVE_SCHEDULER_BOOSTCTRL | ||
730 | cpu_boosted = false; | ||
731 | #endif | ||
702 | add_to_list(&cores[core].running, &cores[core].threads[0]); | 732 | add_to_list(&cores[core].running, &cores[core].threads[0]); |
703 | 733 | ||
704 | /* In multiple core setups, each core has a different stack. There is probably | 734 | /* In multiple core setups, each core has a different stack. There is probably |