summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-01-22 10:41:25 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-01-22 10:41:25 +0000
commitf8c68c7912da50451167fe4bcfd69717f2a30c98 (patch)
treeb0d03c2488adabfda26823d9bcd3eeaa422b3ce2
parenta3a303e440d751fbbb8c2532640098bfc969b75f (diff)
downloadrockbox-f8c68c7912da50451167fe4bcfd69717f2a30c98.tar.gz
rockbox-f8c68c7912da50451167fe4bcfd69717f2a30c98.zip
Simple cpu boost tracker for LOGF builds. Shows the last 64 cpu_boost() calls from the debug menu
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12087 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs.c4
-rw-r--r--apps/codecs.h4
-rw-r--r--apps/debug_menu.c53
-rw-r--r--apps/plugin.c5
-rw-r--r--apps/plugin.h4
-rw-r--r--firmware/export/system.h18
-rw-r--r--firmware/system.c48
7 files changed, 133 insertions, 3 deletions
diff --git a/apps/codecs.c b/apps/codecs.c
index a093c2b601..3af5158fbb 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -131,9 +131,13 @@ struct codec_api ci = {
131 system_memory_guard, 131 system_memory_guard,
132 &cpu_frequency, 132 &cpu_frequency,
133#ifdef HAVE_ADJUSTABLE_CPU_FREQ 133#ifdef HAVE_ADJUSTABLE_CPU_FREQ
134#ifdef CPU_BOOST_LOGGING
135 cpu_boost_,
136#else
134 cpu_boost, 137 cpu_boost,
135#endif 138#endif
136#endif 139#endif
140#endif
137 141
138 /* strings and memory */ 142 /* strings and memory */
139 snprintf, 143 snprintf,
diff --git a/apps/codecs.h b/apps/codecs.h
index dff219c058..cef14c3971 100644
--- a/apps/codecs.h
+++ b/apps/codecs.h
@@ -209,9 +209,13 @@ struct codec_api {
209 int (*system_memory_guard)(int newmode); 209 int (*system_memory_guard)(int newmode);
210 long *cpu_frequency; 210 long *cpu_frequency;
211#ifdef HAVE_ADJUSTABLE_CPU_FREQ 211#ifdef HAVE_ADJUSTABLE_CPU_FREQ
212#ifdef CPU_BOOST_LOGGING
213 void (*cpu_boost_)(bool on_off,char*location,int line);
214#else
212 void (*cpu_boost)(bool on_off); 215 void (*cpu_boost)(bool on_off);
213#endif 216#endif
214#endif 217#endif
218#endif
215 219
216 /* strings and memory */ 220 /* strings and memory */
217 int (*snprintf)(char *buf, size_t size, const char *fmt, ...); 221 int (*snprintf)(char *buf, size_t size, const char *fmt, ...);
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 081bf2f63e..22db43d272 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -2237,7 +2237,55 @@ static bool dbg_write_eeprom(void)
2237 return false; 2237 return false;
2238} 2238}
2239#endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */ 2239#endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
2240 2240#ifdef CPU_BOOST_LOGGING
2241static bool cpu_boost_log(void)
2242{
2243 int i = 0,j=0;
2244 int count = cpu_boost_log_getcount();
2245 int lines = LCD_HEIGHT/SYSFONT_HEIGHT;
2246 char *str;
2247 bool done;
2248 lcd_setmargins(0, 0);
2249 lcd_setfont(FONT_SYSFIXED);
2250 str = cpu_boost_log_getlog_first();
2251 while (i < count)
2252 {
2253 lcd_clear_display();
2254 for(j=0; j<lines; j++,i++)
2255 {
2256 if (!str)
2257 str = cpu_boost_log_getlog_next();
2258 if (str)
2259 {
2260 lcd_puts(0, j,str);
2261 }
2262 str = NULL;
2263 }
2264 lcd_update();
2265 done = false;
2266 action_signalscreenchange();
2267 while (!done)
2268 {
2269 switch(get_action(CONTEXT_STD,TIMEOUT_BLOCK))
2270 {
2271 case ACTION_STD_OK:
2272 case ACTION_STD_PREV:
2273 case ACTION_STD_NEXT:
2274 done = true;
2275 break;
2276 case ACTION_STD_CANCEL:
2277 i = count;
2278 done = true;
2279 break;
2280 }
2281 }
2282 }
2283 get_action(CONTEXT_STD,TIMEOUT_BLOCK);
2284 lcd_setfont(FONT_UI);
2285 action_signalscreenchange();
2286 return false;
2287}
2288#endif
2241bool debug_menu(void) 2289bool debug_menu(void)
2242{ 2290{
2243 int m; 2291 int m;
@@ -2312,6 +2360,9 @@ bool debug_menu(void)
2312 {"logf", logfdisplay }, 2360 {"logf", logfdisplay },
2313 {"logfdump", logfdump }, 2361 {"logfdump", logfdump },
2314#endif 2362#endif
2363#ifdef CPU_BOOST_LOGGING
2364 {"cpu_boost log",cpu_boost_log},
2365#endif
2315 }; 2366 };
2316 2367
2317 m=menu_init( items, sizeof items / sizeof(struct menu_item), NULL, 2368 m=menu_init( items, sizeof items / sizeof(struct menu_item), NULL,
diff --git a/apps/plugin.c b/apps/plugin.c
index 250b4cc545..e11fd5cffe 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -250,9 +250,14 @@ static const struct plugin_api rockbox_api = {
250#ifndef SIMULATOR 250#ifndef SIMULATOR
251 system_memory_guard, 251 system_memory_guard,
252 &cpu_frequency, 252 &cpu_frequency,
253
253#ifdef HAVE_ADJUSTABLE_CPU_FREQ 254#ifdef HAVE_ADJUSTABLE_CPU_FREQ
255#ifdef CPU_BOOST_LOGGING
256 cpu_boost_,
257#else
254 cpu_boost, 258 cpu_boost,
255#endif 259#endif
260#endif
256 timer_register, 261 timer_register,
257 timer_unregister, 262 timer_unregister,
258 timer_set_period, 263 timer_set_period,
diff --git a/apps/plugin.h b/apps/plugin.h
index b2d894f0ee..64cc208aae 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -344,8 +344,12 @@ struct plugin_api {
344 int (*system_memory_guard)(int newmode); 344 int (*system_memory_guard)(int newmode);
345 long *cpu_frequency; 345 long *cpu_frequency;
346#ifdef HAVE_ADJUSTABLE_CPU_FREQ 346#ifdef HAVE_ADJUSTABLE_CPU_FREQ
347#ifdef CPU_BOOST_LOGGING
348 void (*cpu_boost_)(bool on_off,char*location,int line);
349#else
347 void (*cpu_boost)(bool on_off); 350 void (*cpu_boost)(bool on_off);
348#endif 351#endif
352#endif
349 bool (*timer_register)(int reg_prio, void (*unregister_callback)(void), 353 bool (*timer_register)(int reg_prio, void (*unregister_callback)(void),
350 long cycles, int int_prio, 354 long cycles, int int_prio,
351 void (*timer_callback)(void)); 355 void (*timer_callback)(void));
diff --git a/firmware/export/system.h b/firmware/export/system.h
index 688cf9bc15..6b53b88639 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -56,22 +56,38 @@ bool detect_flashed_romimage(void);
56bool detect_flashed_ramimage(void); 56bool detect_flashed_ramimage(void);
57bool detect_original_firmware(void); 57bool detect_original_firmware(void);
58 58
59#if defined(HAVE_ADJUSTABLE_CPU_FREQ) \
60 && defined(ROCKBOX_HAS_LOGF)
61#define CPU_BOOST_LOGGING
62#endif
63
59#ifdef HAVE_ADJUSTABLE_CPU_FREQ 64#ifdef HAVE_ADJUSTABLE_CPU_FREQ
60#define FREQ cpu_frequency 65#define FREQ cpu_frequency
61void set_cpu_frequency(long frequency); 66void set_cpu_frequency(long frequency);
67#ifdef CPU_BOOST_LOGGING
68char * cpu_boost_log_getlog_first(void);
69char * cpu_boost_log_getlog_next(void);
70int cpu_boost_log_getcount(void);
71void cpu_boost_(bool on_off, char* location, int line);
72#else
62void cpu_boost(bool on_off); 73void cpu_boost(bool on_off);
74#endif
63void cpu_idle_mode(bool on_off); 75void cpu_idle_mode(bool on_off);
64int get_cpu_boost_counter(void); 76int get_cpu_boost_counter(void);
65#else 77#else
66#define FREQ CPU_FREQ 78#define FREQ CPU_FREQ
67#define set_cpu_frequency(frequency) 79#define set_cpu_frequency(frequency)
68#define cpu_boost(on_off) 80#define cpu_boost(on_off,location)
69#define cpu_boost_id(on_off, id) 81#define cpu_boost_id(on_off, id)
70#define cpu_idle_mode(on_off) 82#define cpu_idle_mode(on_off)
71#define get_cpu_boost_counter() 83#define get_cpu_boost_counter()
72#define get_cpu_boost_tracker() 84#define get_cpu_boost_tracker()
73#endif 85#endif
74 86
87#ifdef CPU_BOOST_LOGGING
88#define cpu_boost(on_off) cpu_boost_(on_off,__FILE__, __LINE__)
89#endif
90
75#define BAUDRATE 9600 91#define BAUDRATE 9600
76 92
77#ifndef NULL 93#ifndef NULL
diff --git a/firmware/system.c b/firmware/system.c
index c9ce086f0a..49f01df0cd 100644
--- a/firmware/system.c
+++ b/firmware/system.c
@@ -39,9 +39,55 @@ int get_cpu_boost_counter(void)
39{ 39{
40 return boost_counter; 40 return boost_counter;
41} 41}
42 42#ifdef CPU_BOOST_LOGGING
43#define MAX_BOOST_LOG 64
44static char cpu_boost_calls[MAX_BOOST_LOG][MAX_PATH];
45static int cpu_boost_first = 0;
46static int cpu_boost_calls_count = 0;
47static int cpu_boost_track_message = 0;
48int cpu_boost_log_getcount(void)
49{
50 return cpu_boost_calls_count;
51}
52char * cpu_boost_log_getlog_first(void)
53{
54 if (cpu_boost_calls_count)
55 {
56 cpu_boost_track_message = 1;
57 return cpu_boost_calls[cpu_boost_first];
58 }
59 else return NULL;
60}
61char * cpu_boost_log_getlog_next(void)
62{
63 int message = (cpu_boost_track_message+cpu_boost_first)%MAX_BOOST_LOG;
64 if (cpu_boost_track_message < cpu_boost_calls_count)
65 {
66 cpu_boost_track_message++;
67 return cpu_boost_calls[message];
68 }
69 else return NULL;
70}
71void cpu_boost_(bool on_off, char* location, int line)
72{
73 if (cpu_boost_calls_count == MAX_BOOST_LOG)
74 {
75 cpu_boost_first = (cpu_boost_first+1)%MAX_BOOST_LOG;
76 cpu_boost_calls_count--;
77 if (cpu_boost_calls_count < 0)
78 cpu_boost_calls_count = 0;
79 }
80 if (cpu_boost_calls_count < MAX_BOOST_LOG)
81 {
82 int message = (cpu_boost_first+cpu_boost_calls_count)%MAX_BOOST_LOG;
83 snprintf(cpu_boost_calls[message], MAX_PATH,
84 "%c %s:%d",on_off==true?'B':'U',location,line);
85 cpu_boost_calls_count++;
86 }
87#else
43void cpu_boost(bool on_off) 88void cpu_boost(bool on_off)
44{ 89{
90#endif
45 if(on_off) 91 if(on_off)
46 { 92 {
47 /* Boost the frequency if not already boosted */ 93 /* Boost the frequency if not already boosted */