summaryrefslogtreecommitdiff
path: root/firmware/profile.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/profile.c')
-rw-r--r--firmware/profile.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/firmware/profile.c b/firmware/profile.c
index f84eebe3f1..cb68f18d8e 100644
--- a/firmware/profile.c
+++ b/firmware/profile.c
@@ -62,7 +62,6 @@
62#include <sys/types.h> 62#include <sys/types.h>
63#include "profile.h" 63#include "profile.h"
64 64
65
66/* PFD is Profiled Function Data */ 65/* PFD is Profiled Function Data */
67 66
68/* Indices are shorts which means that we use 4k of RAM */ 67/* Indices are shorts which means that we use 4k of RAM */
@@ -75,7 +74,7 @@
75 * for profiling, and allows for profiling sections of code with up-to 74 * for profiling, and allows for profiling sections of code with up-to
76 * 1024 function caller->callee pairs 75 * 1024 function caller->callee pairs
77 */ 76 */
78#define NUMPFDS 1024 77#define NUMPFDS 512
79 78
80struct pfd_struct { 79struct pfd_struct {
81 void *self_pc; 80 void *self_pc;
@@ -141,7 +140,7 @@ void profile_thread_started(int current_thread) {
141 if (profiling < PROF_ERROR) { 140 if (profiling < PROF_ERROR) {
142 /* After we de-mask, if profiling is active, reactivate the timer */ 141 /* After we de-mask, if profiling is active, reactivate the timer */
143 timer_register(0, profile_timer_unregister, 142 timer_register(0, profile_timer_unregister,
144 TIMER_FREQ/10000, 0, profile_timer_tick); 143 TIMER_FREQ/10000, 0, profile_timer_tick IF_COP(, 0 ) );
145 } 144 }
146 } 145 }
147} 146}
@@ -168,9 +167,9 @@ void profstart(int current_thread) {
168 last_pfd = (struct pfd_struct*)0; 167 last_pfd = (struct pfd_struct*)0;
169 pfds[0].link = 0; 168 pfds[0].link = 0;
170 pfds[0].self_pc = 0; 169 pfds[0].self_pc = 0;
171 memset(&indices,0,INDEX_SIZE * sizeof(unsigned short)); 170 memset(indices,0,INDEX_SIZE * sizeof(unsigned short));
172 timer_register( 171 timer_register(
173 0, profile_timer_unregister, TIMER_FREQ/10000, 0, profile_timer_tick); 172 0, profile_timer_unregister, TIMER_FREQ/10000, 0, profile_timer_tick IF_COP(, 0 ) );
174 profiling = PROF_ON; 173 profiling = PROF_ON;
175} 174}
176 175
@@ -179,7 +178,7 @@ static void write_function_recursive(int fd, struct pfd_struct *pfd, int depth){
179 fdprintf(fd,"0x%08lX\t%08ld\t%08ld\t%04d\n", (size_t)pfd->self_pc, 178 fdprintf(fd,"0x%08lX\t%08ld\t%08ld\t%04d\n", (size_t)pfd->self_pc,
180 pfd->count, pfd->time, depth); 179 pfd->count, pfd->time, depth);
181 if (link > 0 && link < NUMPFDS) { 180 if (link > 0 && link < NUMPFDS) {
182 write_function_recursive(fd, &pfds[link], depth++); 181 write_function_recursive(fd, &pfds[link], ++depth);
183 } 182 }
184} 183}
185 184
@@ -206,7 +205,7 @@ void profstop() {
206 } 205 }
207 } 206 }
208 fdprintf(fd,"DEBUG PROFILE DATA FOLLOWS\n"); 207 fdprintf(fd,"DEBUG PROFILE DATA FOLLOWS\n");
209 fdprintf(fd,"INDEX\tLOCATION\tSELF_PC\t\tCOUNT\t\tTIME\t\tLINK\tCALLER\n"); 208 fdprintf(fd,"INDEX\tLOCATION\tSELF_PC\t\tCOUNT\t\tTIME\t\tLINK\tCALLER_IDX\n");
210 for (i = 0; i < NUMPFDS; i++) { 209 for (i = 0; i < NUMPFDS; i++) {
211 struct pfd_struct *my_last_pfd = &pfds[i]; 210 struct pfd_struct *my_last_pfd = &pfds[i];
212 if (my_last_pfd->self_pc != 0) { 211 if (my_last_pfd->self_pc != 0) {
@@ -214,7 +213,7 @@ void profstop() {
214 "%04d\t0x%08lX\t0x%08lX\t0x%08lX\t0x%08lX\t%04d\t0x%08lX\n", 213 "%04d\t0x%08lX\t0x%08lX\t0x%08lX\t0x%08lX\t%04d\t0x%08lX\n",
215 i, (size_t)my_last_pfd, (size_t)my_last_pfd->self_pc, 214 i, (size_t)my_last_pfd, (size_t)my_last_pfd->self_pc,
216 my_last_pfd->count, my_last_pfd->time, my_last_pfd->link, 215 my_last_pfd->count, my_last_pfd->time, my_last_pfd->link,
217 (size_t)my_last_pfd->caller); 216 (size_t)my_last_pfd->caller );
218 } 217 }
219 } 218 }
220 fdprintf(fd,"INDEX_ADDRESS=INDEX\n"); 219 fdprintf(fd,"INDEX_ADDRESS=INDEX\n");
@@ -224,7 +223,7 @@ void profstop() {
224 close(fd); 223 close(fd);
225} 224}
226 225
227void profile_func_exit(void *self_pc, void *call_site) { 226void __cyg_profile_func_exit(void *self_pc, void *call_site) {
228 (void)call_site; 227 (void)call_site;
229 (void)self_pc; 228 (void)self_pc;
230 /* When we started timing, we set the time to the tick at that time 229 /* When we started timing, we set the time to the tick at that time
@@ -255,7 +254,7 @@ void profile_func_exit(void *self_pc, void *call_site) {
255 pfd = &pfds[temp];\ 254 pfd = &pfds[temp];\
256 pfd->self_pc = self_pc; pfd->count = 1; pfd->time = 0 255 pfd->self_pc = self_pc; pfd->count = 1; pfd->time = 0
257 256
258void profile_func_enter(void *self_pc, void *from_pc) { 257void __cyg_profile_func_enter(void *self_pc, void *from_pc) {
259 struct pfd_struct *pfd; 258 struct pfd_struct *pfd;
260 struct pfd_struct *prev_pfd; 259 struct pfd_struct *prev_pfd;
261 unsigned short *pfd_index_pointer; 260 unsigned short *pfd_index_pointer;
@@ -339,3 +338,7 @@ overflow:
339 profiling = PROF_ERROR; 338 profiling = PROF_ERROR;
340 return; 339 return;
341} 340}
341
342
343
344