ARM: tegra: Add Tegra Profiler
[linux-2.6.git] / drivers / misc / tegra-profiler / debug.h
1 /*
2  * drivers/misc/tegra-profiler/debug.h
3  *
4  * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  */
16
17 #ifndef __QUADD_DEBUG_H
18 #define __QUADD_DEBUG_H
19
20 #include <linux/tegra_profiler.h>
21
22 /* #define QM_DEBUG_SAMPLES_ENABLE 1 */
23
24 #ifdef QM_DEBUG_SAMPLES_ENABLE
25 void qm_debug_handler_sample(struct pt_regs *regs);
26 void qm_debug_timer_forward(struct pt_regs *regs, u64 period);
27 void qm_debug_timer_start(struct pt_regs *regs, u64 period);
28 void qm_debug_timer_cancel(void);
29 void qm_debug_task_sched_in(pid_t prev_pid, pid_t current_pid,
30                             int prev_nr_active);
31 void qm_debug_read_counter(int event_id, u32 prev_val, u32 val);
32 void qm_debug_start_source(int source_type);
33 void qm_debug_stop_source(int source_type);
34 #else
35 static inline void qm_debug_handler_sample(struct pt_regs *regs)
36 {
37 }
38 static inline void qm_debug_timer_forward(struct pt_regs *regs, u64 period)
39 {
40 }
41 static inline void qm_debug_timer_start(struct pt_regs *regs, u64 period)
42 {
43 }
44 static inline void qm_debug_timer_cancel(void)
45 {
46 }
47 static inline void
48 qm_debug_task_sched_in(pid_t prev_pid, pid_t current_pid, int prev_nr_active)
49 {
50 }
51 static inline void qm_debug_read_counter(int event_id, u32 prev_val, u32 val)
52 {
53 }
54 static inline void qm_debug_start_source(int source_type)
55 {
56 }
57 static inline void qm_debug_stop_source(int source_type)
58 {
59 }
60 #endif
61
62 void quadd_test_delay(void);
63
64 #define QM_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
65 static inline char *
66 quadd_get_event_str(int event)
67 {
68         static char *str[] = {
69                 [QUADD_EVENT_TYPE_CPU_CYCLES]           = "cpu-cycles",
70
71                 [QUADD_EVENT_TYPE_INSTRUCTIONS]         = "instructions",
72                 [QUADD_EVENT_TYPE_BRANCH_INSTRUCTIONS]  = "branch_instruction",
73                 [QUADD_EVENT_TYPE_BRANCH_MISSES]        = "branch_misses",
74                 [QUADD_EVENT_TYPE_BUS_CYCLES]           = "bus-cycles",
75
76                 [QUADD_EVENT_TYPE_L1_DCACHE_READ_MISSES]        = "l1_d_read",
77                 [QUADD_EVENT_TYPE_L1_DCACHE_WRITE_MISSES]       = "l1_d_write",
78                 [QUADD_EVENT_TYPE_L1_ICACHE_MISSES]             = "l1_i",
79
80                 [QUADD_EVENT_TYPE_L2_DCACHE_READ_MISSES]        = "l2_d_read",
81                 [QUADD_EVENT_TYPE_L2_DCACHE_WRITE_MISSES]       = "l2_d_write",
82                 [QUADD_EVENT_TYPE_L2_ICACHE_MISSES]             = "l2_i",
83         };
84         return (event < QM_ARRAY_SIZE(str)) ? str[event] : "invalid event";
85 }
86
87 #endif  /* __QUADD_DEBUG_H */