? tools/mkboot Index: apps/plugin.c =================================================================== RCS file: /cvsroot/rockbox/apps/plugin.c,v retrieving revision 1.77 diff -u -r1.77 plugin.c --- apps/plugin.c 3 Mar 2005 14:10:17 -0000 1.77 +++ apps/plugin.c 5 Mar 2005 10:50:30 -0000 @@ -268,7 +268,9 @@ #if CONFIG_KEYPAD == IRIVER_H100_PAD button_hold, #endif - +#if CONFIG_CPU == MCF5249 + &profile_tick, +#endif }; int plugin_load(const char* plugin, void* parameter) Index: apps/plugin.h =================================================================== RCS file: /cvsroot/rockbox/apps/plugin.h,v retrieving revision 1.88 diff -u -r1.88 plugin.h --- apps/plugin.h 3 Mar 2005 14:10:17 -0000 1.88 +++ apps/plugin.h 5 Mar 2005 10:50:30 -0000 @@ -317,6 +317,9 @@ #if CONFIG_KEYPAD == IRIVER_H100_PAD bool (*button_hold)(void); #endif +#if CONFIG_CPU == MCF5249 + unsigned long* profile_tick; +#endif }; /* defined by the plugin loader (plugin.c) */ Index: apps/plugins/mpa2wav.c =================================================================== RCS file: /cvsroot/rockbox/apps/plugins/mpa2wav.c,v retrieving revision 1.7 diff -u -r1.7 mpa2wav.c --- apps/plugins/mpa2wav.c 4 Mar 2005 10:37:15 -0000 1.7 +++ apps/plugins/mpa2wav.c 5 Mar 2005 10:50:32 -0000 @@ -69,6 +69,8 @@ static __inline signed int dither(mad_fixed_t sample, struct dither *dither) { + PROFILING_START("dither"); + unsigned int scalebits; mad_fixed_t output, mask, random; @@ -115,6 +117,8 @@ /* error feedback */ dither->error[0] = sample - output; + PROFILING_STOP("dither"); + /* scale */ return output >> scalebits; } @@ -161,6 +165,8 @@ return PLUGIN_ERROR; } + PROFILING_INIT(); + /* Create a decoder instance */ mad_stream_init(&Stream); @@ -280,11 +286,13 @@ display_status(&file_info); if (rb->button_get(false)!=BUTTON_NONE) { + PROFILING_WRITE("/profiling.txt"); close_wav(&file_info); return PLUGIN_OK; } } + PROFILING_WRITE("/profiling.txt"); close_wav(&file_info); rb->splash(HZ*2, true, "FINISHED!"); Index: apps/plugins/lib/xxx2wav.c =================================================================== RCS file: /cvsroot/rockbox/apps/plugins/lib/xxx2wav.c,v retrieving revision 1.6 diff -u -r1.6 xxx2wav.c --- apps/plugins/lib/xxx2wav.c 28 Feb 2005 20:55:30 -0000 1.6 +++ apps/plugins/lib/xxx2wav.c 5 Mar 2005 10:50:33 -0000 @@ -245,4 +245,92 @@ local_rb->write(file_info->outfile,wav_header,sizeof(wav_header)); local_rb->close(file_info->outfile); } + +#ifdef PROFILING + +struct profiling_entry profiling_information[MAX_PROFILING_ENTRIES]; +unsigned long start_tick = 0; +char *current_symbol = NULL; + +void profiling_init(void) { + memset(profiling_information, 0, + sizeof(profiling_information)); +} + +struct profiling_entry *profiling_start(char *symbol_name) { + struct profiling_entry *curr = profiling_get_entry(symbol_name); + start_tick = *(local_rb->profile_tick); + return curr; +} + +void profiling_stop(struct profiling_entry * entry) { + unsigned long stop_tick = *(local_rb->profile_tick); + + if(entry==NULL) + return; + + entry->calls++; + entry->duration += stop_tick - start_tick; +} + +void profiling_write(char *filename) { + int fd = 0; + unsigned long duration_all = 0; + int x=0; + struct profiling_entry *curr = &profiling_information[0]; + + /* calculate used time */ + while(x < MAX_PROFILING_ENTRIES + && curr->symbol_name != NULL) { + duration_all += curr->duration; + x++; + curr = &profiling_information[x]; + } + + /* prevent division by zero */ + if(duration_all == 0) + duration_all = 1; + + fd = local_rb->open(filename, O_WRONLY|O_CREAT|O_TRUNC); + local_rb->fdprintf(fd, "symbol_name\tcall_count\tduration_sum\t%%\n"); + + /* write profiling information */ + x=0; + curr = &profiling_information[0]; + while(x < MAX_PROFILING_ENTRIES + && curr->symbol_name != NULL) { + local_rb->fdprintf(fd, "%s\t%d\t%d\t%d\n", + curr->symbol_name, curr->calls, curr->duration, + curr->duration * 100 / duration_all); + x++; + curr = &profiling_information[x]; + } + + if(x==MAX_PROFILING_ENTRIES) + local_rb->fdprintf(fd, "profiling information overflow: increase \ + MAX_PROFILING_ENTRIES"); + local_rb->close(fd); +} + +struct profiling_entry *profiling_get_entry(char *symbol_name) { + int x = 0; + struct profiling_entry *curr = &profiling_information[0]; + + while(x < MAX_PROFILING_ENTRIES + && curr->symbol_name != NULL + && local_rb->strcmp(curr->symbol_name, symbol_name) != 0) { + x++; + curr = &profiling_information[x]; + } + + if(x==MAX_PROFILING_ENTRIES) + return NULL; + + curr->symbol_name = symbol_name; + + return curr; +} + +#endif /* PROFILING */ + #endif /* CONFIG_HWCODEC == MASNONE */ Index: apps/plugins/lib/xxx2wav.h =================================================================== RCS file: /cvsroot/rockbox/apps/plugins/lib/xxx2wav.h,v retrieving revision 1.5 diff -u -r1.5 xxx2wav.h --- apps/plugins/lib/xxx2wav.h 28 Feb 2005 20:55:30 -0000 1.5 +++ apps/plugins/lib/xxx2wav.h 5 Mar 2005 10:50:33 -0000 @@ -16,7 +16,9 @@ * KIND, either express or implied. * ****************************************************************************/ - +#ifndef _XXX2WAV_H_ +#define _XXX2WAV_H_ + /* Various "helper functions" common to all the xxx2wav decoder plugins */ /* the main data structure of the program */ @@ -55,3 +57,41 @@ void display_status(file_info_struct* file_info); int local_init(char* infilename, char* outfilename, file_info_struct* file_info, struct plugin_api* rb); void close_wav(file_info_struct* file_info); + +#define PROFILING + +#ifdef PROFILING + +#define MAX_PROFILING_ENTRIES 255 + +struct profiling_entry { + char *symbol_name; + unsigned long duration; + unsigned long calls; +}; + +void profiling_init(void); +struct profiling_entry *profiling_start(char *symbol_name); +void profiling_stop(struct profiling_entry * entry); +void profiling_write(char *filename); +struct profiling_entry *profiling_get_entry(char *symbol_name); + +#define PROFILING_INIT() \ + profiling_init() +#define PROFILING_START(symbol_name) \ + struct profiling_entry *curr_entry = profiling_start(symbol_name) +#define PROFILING_STOP(symbol_name) \ + profiling_stop(curr_entry) +#define PROFILING_WRITE(filename) \ + profiling_write(filename) + +#else + +#define PROFILING_INIT() +#define PROFILING_START(symbol_name) +#define PROFILING_STOP(symbol_name) +#define PROFILING_WRITE(filename) + +#endif /* PROFILING */ + +#endif Index: firmware/kernel.c =================================================================== RCS file: /cvsroot/rockbox/firmware/kernel.c,v retrieving revision 1.37 diff -u -r1.37 kernel.c --- firmware/kernel.c 1 Mar 2005 14:33:45 -0000 1.37 +++ firmware/kernel.c 5 Mar 2005 10:50:34 -0000 @@ -29,6 +29,11 @@ static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void); +#if CONFIG_CPU == MCF5249 +unsigned long profile_tick = 0; +static void profile_tick_start(void); +#endif + /* This array holds all queues that are initiated. It is used for broadcast. */ static struct event_queue *all_queues[32]; static int num_queues; @@ -48,7 +53,11 @@ num_queues = 0; memset(all_queues, 0, sizeof(all_queues)); - + +#if CONFIG_CPU == MCF5249 + profile_tick_start(); +#endif + tick_start(1000/HZ); } @@ -251,6 +260,32 @@ TER0 = 0xff; /* Clear all events */ } +static void profile_tick_start(void) +{ + unsigned int count; + + /* reference count for 1 ms */ + count = FREQ/2 / 10000 / 16; + + /* we are using timer 1 */ + TRR1 = count; /* the reference count */ + TCN1 = 0; /* reset the timer */ + TMR1 = 0x001d; /* no prescaler, restart, CLK/16, enabled */ + + TER1 = 0xff; /* clear all events */ + + /* auto vector interrupt on level 2.0 */ + ICR0 = (ICR0 & 0xffff00ff) | 0x00008800; + IMR &= ~0x400; /* unmask interrupt */ +} + +void TIMER1(void) __attribute__ ((interrupt_handler)); +void TIMER1(void) +{ + profile_tick++; + TER1 = 0xff; +} + #elif CONFIG_CPU == TCC730 void TIMER0(void) Index: firmware/system.c =================================================================== RCS file: /cvsroot/rockbox/firmware/system.c,v retrieving revision 1.45 diff -u -r1.45 system.c --- firmware/system.c 3 Mar 2005 21:48:02 -0000 1.45 +++ firmware/system.c 5 Mar 2005 10:50:48 -0000 @@ -432,12 +432,12 @@ UIE,UIE,UIE,UIE,UIE,UIE, UIE,UIE,UIE,UIE,UIE,UIE,UIE,UIE, UIE,UIE,UIE,UIE,UIE,UIE,UIE,UIE, - UIE,UIE,UIE,TIMER0,UIE,UIE,UIE,UIE, + UIE,UIE,TIMER1,TIMER0,UIE,UIE,UIE,UIE, TRAP0,TRAP1,TRAP2,TRAP3,TRAP4,TRAP5,TRAP6,TRAP7, TRAP8,TRAP9,TRAP10,TRAP11,TRAP12,TRAP13,TRAP14,TRAP15, - SWT,UIE,TIMER1,I2C,UART1,UART2,DMA0,DMA1, + SWT,UIE,UIE,I2C,UART1,UART2,DMA0,DMA1, DMA2,DMA3,QSPI,UIE,UIE,UIE,UIE,UIE, PDIR1FULL,PDIR2FULL,EBUTXEMPTY,IIS2TXEMPTY, IIS1TXEMPTY,PDIR3FULL,PDIR3RESYN,UQ2CHANERR, Index: firmware/export/kernel.h =================================================================== RCS file: /cvsroot/rockbox/firmware/export/kernel.h,v retrieving revision 1.13 diff -u -r1.13 kernel.h --- firmware/export/kernel.h 1 Mar 2005 14:33:45 -0000 1.13 +++ firmware/export/kernel.h 5 Mar 2005 10:50:48 -0000 @@ -65,6 +65,11 @@ /* global tick variable */ extern long current_tick; +#if CONFIG_CPU == MCF5249 +/* profile tick variable */ +extern unsigned long profile_tick; +#endif + #ifdef SIMULATOR #define sleep(x) sim_sleep(x) #endif