1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Profiling routines counts ticks and calls to each profiled function.
12 * Copyright (C) 2005 by Brandon Low
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 ****************************************************************************/
21 #ifndef _SYS_PROFILE_H
22 #define _SYS_PROFILE_H 1
24 #include <sys/types.h>
26 /* PFD is Profiled Function Data */
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 */
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
45 struct pfd_struct
*caller
;
48 /* Possible states of profiling */
50 #define PROF_BUSY 0x01
51 #define PROF_ERROR 0x02
53 /* Masks for thread switches */
54 #define PROF_OFF_THREAD 0x10
55 #define PROF_ON_THREAD 0x0F
57 /* Initialize and start profiling */
58 void profstart(int current_thread
)
61 /* Clean up and write profile data */
65 /* Called every time a thread stops, we check if it's our thread and store
66 * temporary timing data if it is */
67 void profile_thread_stopped(int current_thread
)
69 /* Called when a thread starts, we check if it's our thread and resume timing */
70 void profile_thread_started(int current_thread
)
73 void profile_func_exit(void *this_fn
, void *call_site
)
74 NO_PROF_ATTR ICODE_ATTR
;
75 void profile_func_enter(void *this_fn
, void *call_site
)
76 NO_PROF_ATTR ICODE_ATTR
;
78 #endif /*_SYS_PROFILE_H*/