diff options
author | Brandon Low <lostlogic@rockbox.org> | 2006-01-18 20:54:13 +0000 |
---|---|---|
committer | Brandon Low <lostlogic@rockbox.org> | 2006-01-18 20:54:13 +0000 |
commit | 05dccc355144dc717b3cb9ef0074a9ab38a520f4 (patch) | |
tree | 0a36425cf1321817480a82ed05564a2790e2fca9 /firmware/export/profile.h | |
parent | 1060e447f83128a78dfaa8d59ba0baa642d15a4d (diff) | |
download | rockbox-05dccc355144dc717b3cb9ef0074a9ab38a520f4.tar.gz rockbox-05dccc355144dc717b3cb9ef0074a9ab38a520f4.zip |
Profiling support, tools and documentation.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8375 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/export/profile.h')
-rw-r--r-- | firmware/export/profile.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/firmware/export/profile.h b/firmware/export/profile.h new file mode 100644 index 0000000000..cb751328ae --- /dev/null +++ b/firmware/export/profile.h | |||
@@ -0,0 +1,80 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Profiling routines counts ticks and calls to each profiled function. | ||
11 | * | ||
12 | * Copyright (C) 2005 by Brandon Low | ||
13 | * | ||
14 | * All files in this archive are subject to the GNU General Public License. | ||
15 | * See the file COPYING in the source tree root for full license agreement. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | ****************************************************************************/ | ||
20 | |||
21 | #ifndef _SYS_PROFILE_H | ||
22 | #define _SYS_PROFILE_H 1 | ||
23 | |||
24 | #include <sys/types.h> | ||
25 | |||
26 | /* PFD is Profiled Function Data */ | ||
27 | |||
28 | /* Indices are shorts which means that we use 4k of RAM */ | ||
29 | #define INDEX_BITS 11 /* What is a reasonable size for this? */ | ||
30 | #define INDEX_SIZE 2048 /* 2 ^ INDEX_BITS */ | ||
31 | #define INDEX_MASK 0x7FF /* lower INDEX_BITS 1 */ | ||
32 | |||
33 | /* | ||
34 | * In the current setup (pfd has 4 longs and 2 shorts) this uses 20k of RAM | ||
35 | * for profiling, and allows for profiling sections of code with up-to | ||
36 | * 1024 function caller->callee pairs | ||
37 | */ | ||
38 | #define NUMPFDS 1024 | ||
39 | |||
40 | struct pfd_struct { | ||
41 | void *self_pc; | ||
42 | unsigned long count; | ||
43 | unsigned long time; | ||
44 | unsigned short link; | ||
45 | struct pfd_struct *caller; | ||
46 | }; | ||
47 | |||
48 | /* Possible states of profiling */ | ||
49 | #define PROF_ON 0x00 | ||
50 | #define PROF_BUSY 0x01 | ||
51 | #define PROF_ERROR 0x02 | ||
52 | #define PROF_OFF 0x03 | ||
53 | /* Masks for thread switches */ | ||
54 | #define PROF_OFF_THREAD 0x10 | ||
55 | #define PROF_ON_THREAD 0x0F | ||
56 | |||
57 | extern int current_thread; | ||
58 | |||
59 | /* Initialize and start profiling */ | ||
60 | void profstart(int current_thread) | ||
61 | NO_PROF_ATTR; | ||
62 | |||
63 | /* Clean up and write profile data */ | ||
64 | void profstop (void) | ||
65 | NO_PROF_ATTR; | ||
66 | |||
67 | /* Called every time a thread stops, we check if it's our thread and store | ||
68 | * temporary timing data if it is */ | ||
69 | void profile_thread_stopped(int current_thread) | ||
70 | NO_PROF_ATTR; | ||
71 | /* Called when a thread starts, we check if it's our thread and resume timing */ | ||
72 | void profile_thread_started(int current_thread) | ||
73 | NO_PROF_ATTR; | ||
74 | |||
75 | void profile_func_exit(void *this_fn, void *call_site) | ||
76 | NO_PROF_ATTR ICODE_ATTR; | ||
77 | void profile_func_enter(void *this_fn, void *call_site) | ||
78 | NO_PROF_ATTR ICODE_ATTR; | ||
79 | |||
80 | #endif /*_SYS_PROFILE_H*/ | ||