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)
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 = {
system_memory_guard,
&cpu_frequency,
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
+#ifdef CPU_BOOST_LOGGING
+ cpu_boost_,
+#else
cpu_boost,
#endif
#endif
+#endif
/* strings and memory */
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 {
int (*system_memory_guard)(int newmode);
long *cpu_frequency;
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
+#ifdef CPU_BOOST_LOGGING
+ void (*cpu_boost_)(bool on_off,char*location,int line);
+#else
void (*cpu_boost)(bool on_off);
#endif
#endif
+#endif
/* strings and memory */
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)
return false;
}
#endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
-
+#ifdef CPU_BOOST_LOGGING
+static bool cpu_boost_log(void)
+{
+ int i = 0,j=0;
+ int count = cpu_boost_log_getcount();
+ int lines = LCD_HEIGHT/SYSFONT_HEIGHT;
+ char *str;
+ bool done;
+ lcd_setmargins(0, 0);
+ lcd_setfont(FONT_SYSFIXED);
+ str = cpu_boost_log_getlog_first();
+ while (i < count)
+ {
+ lcd_clear_display();
+ for(j=0; j<lines; j++,i++)
+ {
+ if (!str)
+ str = cpu_boost_log_getlog_next();
+ if (str)
+ {
+ lcd_puts(0, j,str);
+ }
+ str = NULL;
+ }
+ lcd_update();
+ done = false;
+ action_signalscreenchange();
+ while (!done)
+ {
+ switch(get_action(CONTEXT_STD,TIMEOUT_BLOCK))
+ {
+ case ACTION_STD_OK:
+ case ACTION_STD_PREV:
+ case ACTION_STD_NEXT:
+ done = true;
+ break;
+ case ACTION_STD_CANCEL:
+ i = count;
+ done = true;
+ break;
+ }
+ }
+ }
+ get_action(CONTEXT_STD,TIMEOUT_BLOCK);
+ lcd_setfont(FONT_UI);
+ action_signalscreenchange();
+ return false;
+}
+#endif
bool debug_menu(void)
{
int m;
@@ -2312,6 +2360,9 @@ bool debug_menu(void)
{"logf", logfdisplay },
{"logfdump", logfdump },
#endif
+#ifdef CPU_BOOST_LOGGING
+ {"cpu_boost log",cpu_boost_log},
+#endif
};
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 = {
#ifndef SIMULATOR
system_memory_guard,
&cpu_frequency,
+
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
+#ifdef CPU_BOOST_LOGGING
+ cpu_boost_,
+#else
cpu_boost,
#endif
+#endif
timer_register,
timer_unregister,
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 {
int (*system_memory_guard)(int newmode);
long *cpu_frequency;
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
+#ifdef CPU_BOOST_LOGGING
+ void (*cpu_boost_)(bool on_off,char*location,int line);
+#else
void (*cpu_boost)(bool on_off);
#endif
+#endif
bool (*timer_register)(int reg_prio, void (*unregister_callback)(void),
long cycles, int int_prio,
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);
bool detect_flashed_ramimage(void);
bool detect_original_firmware(void);
+#if defined(HAVE_ADJUSTABLE_CPU_FREQ) \
+ && defined(ROCKBOX_HAS_LOGF)
+#define CPU_BOOST_LOGGING
+#endif
+
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
#define FREQ cpu_frequency
void set_cpu_frequency(long frequency);
+#ifdef CPU_BOOST_LOGGING
+char * cpu_boost_log_getlog_first(void);
+char * cpu_boost_log_getlog_next(void);
+int cpu_boost_log_getcount(void);
+void cpu_boost_(bool on_off, char* location, int line);
+#else
void cpu_boost(bool on_off);
+#endif
void cpu_idle_mode(bool on_off);
int get_cpu_boost_counter(void);
#else
#define FREQ CPU_FREQ
#define set_cpu_frequency(frequency)
-#define cpu_boost(on_off)
+#define cpu_boost(on_off,location)
#define cpu_boost_id(on_off, id)
#define cpu_idle_mode(on_off)
#define get_cpu_boost_counter()
#define get_cpu_boost_tracker()
#endif
+#ifdef CPU_BOOST_LOGGING
+#define cpu_boost(on_off) cpu_boost_(on_off,__FILE__, __LINE__)
+#endif
+
#define BAUDRATE 9600
#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)
{
return boost_counter;
}
-
+#ifdef CPU_BOOST_LOGGING
+#define MAX_BOOST_LOG 64
+static char cpu_boost_calls[MAX_BOOST_LOG][MAX_PATH];
+static int cpu_boost_first = 0;
+static int cpu_boost_calls_count = 0;
+static int cpu_boost_track_message = 0;
+int cpu_boost_log_getcount(void)
+{
+ return cpu_boost_calls_count;
+}
+char * cpu_boost_log_getlog_first(void)
+{
+ if (cpu_boost_calls_count)
+ {
+ cpu_boost_track_message = 1;
+ return cpu_boost_calls[cpu_boost_first];
+ }
+ else return NULL;
+}
+char * cpu_boost_log_getlog_next(void)
+{
+ int message = (cpu_boost_track_message+cpu_boost_first)%MAX_BOOST_LOG;
+ if (cpu_boost_track_message < cpu_boost_calls_count)
+ {
+ cpu_boost_track_message++;
+ return cpu_boost_calls[message];
+ }
+ else return NULL;
+}
+void cpu_boost_(bool on_off, char* location, int line)
+{
+ if (cpu_boost_calls_count == MAX_BOOST_LOG)
+ {
+ cpu_boost_first = (cpu_boost_first+1)%MAX_BOOST_LOG;
+ cpu_boost_calls_count--;
+ if (cpu_boost_calls_count < 0)
+ cpu_boost_calls_count = 0;
+ }
+ if (cpu_boost_calls_count < MAX_BOOST_LOG)
+ {
+ int message = (cpu_boost_first+cpu_boost_calls_count)%MAX_BOOST_LOG;
+ snprintf(cpu_boost_calls[message], MAX_PATH,
+ "%c %s:%d",on_off==true?'B':'U',location,line);
+ cpu_boost_calls_count++;
+ }
+#else
void cpu_boost(bool on_off)
{
+#endif
if(on_off)
{
/* Boost the frequency if not already boosted */