summaryrefslogtreecommitdiff
path: root/firmware/system.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-10-16 01:25:17 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-10-16 01:25:17 +0000
commita9b2fb5ee3114fe835f6515b6aeae7454f66d821 (patch)
treefc4e96d0c1f215565918406c8827b16b806c1345 /firmware/system.c
parenta3fbbc9fa7e12fd3fce122bbd235dc362050e024 (diff)
downloadrockbox-a9b2fb5ee3114fe835f6515b6aeae7454f66d821.tar.gz
rockbox-a9b2fb5ee3114fe835f6515b6aeae7454f66d821.zip
Finally full multicore support for PortalPlayer 502x targets with an eye towards the possibility of other types. All SVN targets the low-lag code to speed up blocking operations. Most files are modified here simple due to a name change to actually support a real event object and a param change to create_thread. Add some use of new features but just sit on things for a bit and leave full integration for later. Work will continue on to address size on sensitive targets and simplify things if possible. Any PP target having problems with SWP can easily be changed to sw corelocks with one #define change in config.h though only PP5020 has shown an issue and seems to work without any difficulties.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15134 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/system.c')
-rw-r--r--firmware/system.c74
1 files changed, 63 insertions, 11 deletions
diff --git a/firmware/system.c b/firmware/system.c
index 6ff0dbb5d1..0b5ae1719e 100644
--- a/firmware/system.c
+++ b/firmware/system.c
@@ -35,6 +35,13 @@ long cpu_frequency NOCACHEBSS_ATTR = CPU_FREQ;
35#ifdef HAVE_ADJUSTABLE_CPU_FREQ 35#ifdef HAVE_ADJUSTABLE_CPU_FREQ
36static int boost_counter NOCACHEBSS_ATTR = 0; 36static int boost_counter NOCACHEBSS_ATTR = 0;
37static bool cpu_idle NOCACHEBSS_ATTR = false; 37static bool cpu_idle NOCACHEBSS_ATTR = false;
38#if NUM_CORES > 1
39struct spinlock boostctrl_spin NOCACHEBSS_ATTR;
40void cpu_boost_init(void)
41{
42 spinlock_init(&boostctrl_spin, SPINLOCK_NO_TASK_SWITCH);
43}
44#endif
38 45
39int get_cpu_boost_counter(void) 46int get_cpu_boost_counter(void)
40{ 47{
@@ -52,25 +59,51 @@ int cpu_boost_log_getcount(void)
52} 59}
53char * cpu_boost_log_getlog_first(void) 60char * cpu_boost_log_getlog_first(void)
54{ 61{
62 char *first;
63#if NUM_CORES > 1
64 spinlock_lock(&boostctrl_spin);
65#endif
66
67 first = NULL;
68
55 if (cpu_boost_calls_count) 69 if (cpu_boost_calls_count)
56 { 70 {
57 cpu_boost_track_message = 1; 71 cpu_boost_track_message = 1;
58 return cpu_boost_calls[cpu_boost_first]; 72 first = cpu_boost_calls[cpu_boost_first];
59 } 73 }
60 else return NULL; 74
75#if NUM_CORES > 1
76 spinlock_unlock(&boostctrl_spin);
77#endif
61} 78}
62char * cpu_boost_log_getlog_next(void) 79char * cpu_boost_log_getlog_next(void)
63{ 80{
64 int message = (cpu_boost_track_message+cpu_boost_first)%MAX_BOOST_LOG; 81 int message;
82 char *next;
83
84#if NUM_CORES > 1
85 spinlock_lock(&boostctrl_spin);
86#endif
87
88 message = (cpu_boost_track_message+cpu_boost_first)%MAX_BOOST_LOG;
89 next = NULL;
90
65 if (cpu_boost_track_message < cpu_boost_calls_count) 91 if (cpu_boost_track_message < cpu_boost_calls_count)
66 { 92 {
67 cpu_boost_track_message++; 93 cpu_boost_track_message++;
68 return cpu_boost_calls[message]; 94 next = cpu_boost_calls[message];
69 } 95 }
70 else return NULL; 96
97#if NUM_CORES > 1
98 spinlock_unlock(&boostctrl_spin);
99#endif
71} 100}
72void cpu_boost_(bool on_off, char* location, int line) 101void cpu_boost_(bool on_off, char* location, int line)
73{ 102{
103#if NUM_CORES > 1
104 spinlock_lock(&boostctrl_spin);
105#endif
106
74 if (cpu_boost_calls_count == MAX_BOOST_LOG) 107 if (cpu_boost_calls_count == MAX_BOOST_LOG)
75 { 108 {
76 cpu_boost_first = (cpu_boost_first+1)%MAX_BOOST_LOG; 109 cpu_boost_first = (cpu_boost_first+1)%MAX_BOOST_LOG;
@@ -88,32 +121,46 @@ void cpu_boost_(bool on_off, char* location, int line)
88#else 121#else
89void cpu_boost(bool on_off) 122void cpu_boost(bool on_off)
90{ 123{
124#if NUM_CORES > 1
125 spinlock_lock(&boostctrl_spin);
91#endif 126#endif
127
128#endif /* CPU_BOOST_LOGGING */
92 if(on_off) 129 if(on_off)
93 { 130 {
94 /* Boost the frequency if not already boosted */ 131 /* Boost the frequency if not already boosted */
95 if(boost_counter++ == 0) 132 if(++boost_counter == 1)
96 set_cpu_frequency(CPUFREQ_MAX); 133 set_cpu_frequency(CPUFREQ_MAX);
97 } 134 }
98 else 135 else
99 { 136 {
100 /* Lower the frequency if the counter reaches 0 */ 137 /* Lower the frequency if the counter reaches 0 */
101 if(--boost_counter == 0) 138 if(--boost_counter <= 0)
102 { 139 {
103 if(cpu_idle) 140 if(cpu_idle)
104 set_cpu_frequency(CPUFREQ_DEFAULT); 141 set_cpu_frequency(CPUFREQ_DEFAULT);
105 else 142 else
106 set_cpu_frequency(CPUFREQ_NORMAL); 143 set_cpu_frequency(CPUFREQ_NORMAL);
107 }
108 144
109 /* Safety measure */ 145 /* Safety measure */
110 if(boost_counter < 0) 146 if (boost_counter < 0)
111 boost_counter = 0; 147 {
148 boost_counter = 0;
149 }
150 }
112 } 151 }
152
153#if NUM_CORES > 1
154 spinlock_unlock(&boostctrl_spin);
155#endif
113} 156}
114 157
115void cpu_idle_mode(bool on_off) 158void cpu_idle_mode(bool on_off)
116{ 159{
160#if NUM_CORES > 1
161 spinlock_lock(&boostctrl_spin);
162#endif
163
117 cpu_idle = on_off; 164 cpu_idle = on_off;
118 165
119 /* We need to adjust the frequency immediately if the CPU 166 /* We need to adjust the frequency immediately if the CPU
@@ -125,6 +172,10 @@ void cpu_idle_mode(bool on_off)
125 else 172 else
126 set_cpu_frequency(CPUFREQ_NORMAL); 173 set_cpu_frequency(CPUFREQ_NORMAL);
127 } 174 }
175
176#if NUM_CORES > 1
177 spinlock_unlock(&boostctrl_spin);
178#endif
128} 179}
129#endif /* HAVE_ADJUSTABLE_CPU_FREQ */ 180#endif /* HAVE_ADJUSTABLE_CPU_FREQ */
130 181
@@ -199,6 +250,7 @@ void UIE(unsigned int pc, unsigned int num)
199 /* TODO: perhaps add button handling in here when we get a polling 250 /* TODO: perhaps add button handling in here when we get a polling
200 driver some day. 251 driver some day.
201 */ 252 */
253 core_idle();
202 } 254 }
203} 255}
204 256