summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2014-08-08 01:39:29 -0400
committerMichael Sevakis <jethead71@rockbox.org>2014-08-08 01:59:59 -0400
commit981d028c09d10ed867f2f955f58d60b753c64f29 (patch)
tree0dab835a14c5cb3e740be4e46be93c42aec76bc5 /apps
parent53d9f2e6a7564e487bdac87f6e28c662e8407458 (diff)
downloadrockbox-981d028c09d10ed867f2f955f58d60b753c64f29.tar.gz
rockbox-981d028c09d10ed867f2f955f58d60b753c64f29.zip
Do some kernel cleanup
* Seal away private thread and kernel definitions and declarations into the internal headers in order to better hide internal structure. * Add a thread-common.c file that keeps shared functions together. List functions aren't messed with since that's about to be changed to different ones. * It is necessary to modify some ARM/PP stuff since GCC was complaining about constant pool distance and I would rather not force dump it. Just bl the cache calls in the startup and exit code and let it use veneers if it must. * Clean up redundant #includes in relevant areas and reorganize them. * Expunge useless and dangerous stuff like remove_thread(). Change-Id: I6e22932fad61a9fac30fd1363c071074ee7ab382
Diffstat (limited to 'apps')
-rw-r--r--apps/debug_menu.c68
-rw-r--r--apps/main.c3
2 files changed, 16 insertions, 55 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index bc2a73fc9c..a11cff9350 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -133,69 +133,44 @@
133 133
134#include "talk.h" 134#include "talk.h"
135 135
136/*---------------------------------------------------*/
137/* SPECIAL DEBUG STUFF */
138/*---------------------------------------------------*/
139extern struct thread_entry threads[MAXTHREADS];
140
141static char thread_status_char(unsigned status)
142{
143 static const char thread_status_chars[THREAD_NUM_STATES+1] =
144 {
145 [0 ... THREAD_NUM_STATES] = '?',
146 [STATE_RUNNING] = 'R',
147 [STATE_BLOCKED] = 'B',
148 [STATE_SLEEPING] = 'S',
149 [STATE_BLOCKED_W_TMO] = 'T',
150 [STATE_FROZEN] = 'F',
151 [STATE_KILLED] = 'K',
152 };
153
154 if (status > THREAD_NUM_STATES)
155 status = THREAD_NUM_STATES;
156
157 return thread_status_chars[status];
158}
159
160static const char* threads_getname(int selected_item, void *data, 136static const char* threads_getname(int selected_item, void *data,
161 char *buffer, size_t buffer_len) 137 char *buffer, size_t buffer_len)
162{ 138{
163 (void)data; 139 (void)data;
164 struct thread_entry *thread;
165 char name[32];
166 140
167#if NUM_CORES > 1 141#if NUM_CORES > 1
168 if (selected_item < (int)NUM_CORES) 142 if (selected_item < (int)NUM_CORES)
169 { 143 {
144 struct core_debug_info coreinfo;
145 core_get_debug_info(selected_item, &coreinfo);
170 snprintf(buffer, buffer_len, "Idle (%d): %2d%%", selected_item, 146 snprintf(buffer, buffer_len, "Idle (%d): %2d%%", selected_item,
171 idle_stack_usage(selected_item)); 147 coreinfo.idle_stack_usage);
172 return buffer; 148 return buffer;
173 } 149 }
174 150
175 selected_item -= NUM_CORES; 151 selected_item -= NUM_CORES;
176#endif 152#endif
177 153
178 thread = &threads[selected_item]; 154 struct thread_debug_info threadinfo;
179 155 if (thread_get_debug_info(selected_item, &threadinfo) <= 0)
180 if (thread->state == STATE_KILLED)
181 { 156 {
182 snprintf(buffer, buffer_len, "%2d: ---", selected_item); 157 snprintf(buffer, buffer_len, "%2d: ---", selected_item);
183 return buffer; 158 return buffer;
184 } 159 }
185 160
186 thread_get_name(name, 32, thread);
187
188 snprintf(buffer, buffer_len, 161 snprintf(buffer, buffer_len,
189 "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d %d ") "%2d%% %s", 162 "%2d: " IF_COP("(%d) ") "%s " IF_PRIO("%d %d ") "%2d%% %s",
190 selected_item, 163 selected_item,
191 IF_COP(thread->core,) 164#if NUM_CORES > 1
192#ifdef HAVE_SCHEDULER_BOOSTCTRL 165 threadinfo.core,
193 (thread->cpu_boost) ? '+' : 166#endif
167 threadinfo.statusstr,
168#ifdef HAVE_PRIORITY_SCHEDULING
169 threadinfo.base_priority,
170 threadinfo.current_priority,
194#endif 171#endif
195 ((thread->state == STATE_RUNNING) ? '*' : ' '), 172 threadinfo.stack_usage,
196 thread_status_char(thread->state), 173 threadinfo.name);
197 IF_PRIO(thread->base_priority, thread->priority, )
198 thread_stack_usage(thread), name);
199 174
200 return buffer; 175 return buffer;
201} 176}
@@ -203,19 +178,6 @@ static const char* threads_getname(int selected_item, void *data,
203static int dbg_threads_action_callback(int action, struct gui_synclist *lists) 178static int dbg_threads_action_callback(int action, struct gui_synclist *lists)
204{ 179{
205 (void)lists; 180 (void)lists;
206#ifdef ROCKBOX_HAS_LOGF
207 if (action == ACTION_STD_OK)
208 {
209 int selpos = gui_synclist_get_sel_pos(lists);
210#if NUM_CORES > 1
211 if (selpos >= NUM_CORES)
212 remove_thread(threads[selpos - NUM_CORES].id);
213#else
214 remove_thread(threads[selpos].id);
215#endif
216 return ACTION_REDRAW;
217 }
218#endif /* ROCKBOX_HAS_LOGF */
219 if (action == ACTION_NONE) 181 if (action == ACTION_NONE)
220 action = ACTION_REDRAW; 182 action = ACTION_REDRAW;
221 return action; 183 return action;
diff --git a/apps/main.c b/apps/main.c
index 7dc61754d3..6c6f0d6aba 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -28,7 +28,7 @@
28#include "rtc.h" 28#include "rtc.h"
29#include "debug.h" 29#include "debug.h"
30#include "led.h" 30#include "led.h"
31#include "kernel.h" 31#include "../kernel-internal.h"
32#include "button.h" 32#include "button.h"
33#include "tree.h" 33#include "tree.h"
34#include "filetypes.h" 34#include "filetypes.h"
@@ -44,7 +44,6 @@
44#endif 44#endif
45#include "audio.h" 45#include "audio.h"
46#include "mp3_playback.h" 46#include "mp3_playback.h"
47#include "thread.h"
48#include "settings.h" 47#include "settings.h"
49#include "backlight.h" 48#include "backlight.h"
50#include "status.h" 49#include "status.h"