summaryrefslogtreecommitdiff
path: root/firmware/profile.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/profile.c')
-rw-r--r--firmware/profile.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/firmware/profile.c b/firmware/profile.c
index 71fe343879..0f445f42de 100644
--- a/firmware/profile.c
+++ b/firmware/profile.c
@@ -57,8 +57,41 @@
57#include <system.h> 57#include <system.h>
58#include <string.h> 58#include <string.h>
59#include <timer.h> 59#include <timer.h>
60#include <sys/types.h>
60#include "profile.h" 61#include "profile.h"
61 62
63
64/* PFD is Profiled Function Data */
65
66/* Indices are shorts which means that we use 4k of RAM */
67#define INDEX_BITS 11 /* What is a reasonable size for this? */
68#define INDEX_SIZE 2048 /* 2 ^ INDEX_BITS */
69#define INDEX_MASK 0x7FF /* lower INDEX_BITS 1 */
70
71/*
72 * In the current setup (pfd has 4 longs and 2 shorts) this uses 20k of RAM
73 * for profiling, and allows for profiling sections of code with up-to
74 * 1024 function caller->callee pairs
75 */
76#define NUMPFDS 1024
77
78struct pfd_struct {
79 void *self_pc;
80 unsigned long count;
81 unsigned long time;
82 unsigned short link;
83 struct pfd_struct *caller;
84};
85
86/* Possible states of profiling */
87#define PROF_ON 0x00
88#define PROF_BUSY 0x01
89#define PROF_ERROR 0x02
90#define PROF_OFF 0x03
91/* Masks for thread switches */
92#define PROF_OFF_THREAD 0x10
93#define PROF_ON_THREAD 0x0F
94
62static unsigned short profiling = PROF_OFF; 95static unsigned short profiling = PROF_OFF;
63static size_t recursion_level; 96static size_t recursion_level;
64static unsigned short indices[INDEX_SIZE]; 97static unsigned short indices[INDEX_SIZE];