summaryrefstree
path: root/kernel/include/linux/debug-snapshot.h
blob: 227371b68d20555a663480cee084a7a55846206f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
/*
 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
 *		http://www.samsung.com
 *
 * Exynos-SnapShot debugging framework for Exynos SoC
 *
 * Author: Hosung Kim <Hosung0.kim@samsung.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef DEBUG_SNAPSHOT_H
#define DEBUG_SNAPSHOT_H

#ifdef CONFIG_DEBUG_SNAPSHOT
#include <asm/ptrace.h>
#include <linux/bug.h>
#include "debug-snapshot-binder.h"

/* mandatory */
extern void dbg_snapshot_task(int cpu, void *v_task);
extern void dbg_snapshot_work(void *worker, void *v_task, void *fn, int en);
extern void dbg_snapshot_cpuidle(char *modes, unsigned state, int diff, int en);
extern void dbg_snapshot_suspend(char *log, void *fn, void *dev, int state, int en);
extern void dbg_snapshot_irq(int irq, void *fn, void *val, unsigned long long time, int en);
extern void dbg_snapshot_print_notifier_call(void **nl, unsigned long func, int en);
extern int dbg_snapshot_try_enable(const char *name, unsigned long long duration);
extern int dbg_snapshot_set_enable(const char *name, int en);
extern int dbg_snapshot_get_enable(const char *name);
extern int dbg_snapshot_save_context(void *regs);
extern int dbg_snapshot_save_reg(void *regs);
extern void dbg_snapshot_save_system(void *unused);
extern int dbg_snapshot_dump_panic(char *str, size_t len);
extern int dbg_snapshot_early_panic(void);
extern int dbg_snapshot_prepare_panic(void);
extern int dbg_snapshot_post_panic(void);
extern int dbg_snapshot_post_reboot(char *cmd);
extern int dbg_snapshot_set_hardlockup(int);
extern int dbg_snapshot_get_hardlockup(void);
extern void dbg_snapshot_set_sjtag_status(void);
extern int dbg_snapshot_get_sjtag_status(void);
extern int dbg_snapshot_get_debug_level(void);
extern int dbg_snapshot_get_debug_level_reg(void);
extern unsigned int dbg_snapshot_get_item_size(char *);
extern unsigned int dbg_snapshot_get_item_paddr(char *);
extern unsigned long dbg_snapshot_get_item_vaddr(char *);
extern unsigned long dbg_snapshot_get_item_curr_ptr(char *);
extern bool dbg_snapshot_dumper_one(void *, char *, size_t, size_t *);
extern void dbg_snapshot_panic_handler_safe(void);
extern unsigned long dbg_snapshot_get_spare_vaddr(unsigned int offset);
extern unsigned long dbg_snapshot_get_spare_paddr(unsigned int offset);
extern unsigned long dbg_snapshot_get_last_pc(unsigned int cpu);
extern unsigned long dbg_snapshot_get_last_pc_paddr(void);
extern void dbg_snapshot_hook_hardlockup_entry(void *v_regs);
extern void dbg_snapshot_hook_hardlockup_exit(void);
extern void dbg_snapshot_dump_sfr(void);
extern int dbg_snapshot_hook_pmsg(char *buffer, size_t count);
extern void dbg_snapshot_save_log(int cpu, unsigned long where);
extern int dbg_snapshot_add_bl_item_info(const char *name,
		unsigned int paddr, unsigned int size);

#define dbg_snapshot_irq_var(v)   do {    v = cpu_clock(raw_smp_processor_id());  \
				  } while(0)
/* option */
#ifdef CONFIG_DEBUG_SNAPSHOT_ACPM
extern void dbg_snapshot_acpm(unsigned long long timestamp, const char *log, unsigned int data);
#else
#define dbg_snapshot_acpm(a,b,c)         do { } while(0)
#endif

#ifdef CONFIG_DEBUG_SNAPSHOT_REGULATOR
extern void dbg_snapshot_regulator(unsigned long long timestamp, char* f_name, unsigned int addr, unsigned int volt, unsigned int rvolt, int en);
#else
#define dbg_snapshot_regulator(a,b,c,d,e,f)         do { } while(0)
#endif

#ifdef CONFIG_DEBUG_SNAPSHOT_THERMAL
extern void dbg_snapshot_thermal(void *data, unsigned int temp, char *name, unsigned int max_cooling);
#else
#define dbg_snapshot_thermal(a,b,c,d)	do { } while(0)
#endif

#ifndef CONFIG_DEBUG_SNAPSHOT_MINIMIZED_MODE
extern void dbg_snapshot_clockevent(unsigned long long clc, int64_t delta, void *next_event);
extern void dbg_snapshot_printk(const char *fmt, ...);
extern void dbg_snapshot_printkl(size_t msg, size_t val);
#else
#define dbg_snapshot_clockevent(a,b,c)	do { } while(0)
#define dbg_snapshot_printk(...)		do { } while(0)
#define dbg_snapshot_printkl(a,b)		do { } while(0)
#endif

#ifdef CONFIG_DEBUG_SNAPSHOT_IRQ_DISABLED
extern void dbg_snapshot_irqs_disabled(unsigned long flags);
#else
#define dbg_snapshot_irqs_disabled(a)	do { } while(0)
#endif

#ifdef CONFIG_DEBUG_SNAPSHOT_HRTIMER
extern void dbg_snapshot_hrtimer(void *timer, s64 *now, void *fn, int en);
#else
#define dbg_snapshot_hrtimer(a,b,c,d)	do { } while(0)
#endif

#ifdef CONFIG_DEBUG_SNAPSHOT_I2C
struct i2c_adapter;
struct i2c_msg;
extern void dbg_snapshot_i2c(struct i2c_adapter *adap, struct i2c_msg *msgs, int num, int en);
#else
#define dbg_snapshot_i2c(a,b,c,d)		do { } while(0)
#endif

#ifdef CONFIG_DEBUG_SNAPSHOT_SPI
struct spi_controller;
struct spi_message;
extern void dbg_snapshot_spi(struct spi_controller *ctlr, struct spi_message *cur_msg, int en);
#else
#define dbg_snapshot_spi(a,b,c)		do { } while(0)
#endif

#ifdef CONFIG_DEBUG_SNAPSHOT_REG
extern void dbg_snapshot_reg(unsigned int read, size_t val, size_t reg, int en);
#else
#define dbg_snapshot_reg(a,b,c,d)		do { } while(0)
#endif

#ifdef CONFIG_DEBUG_SNAPSHOT_SPINLOCK
extern void dbg_snapshot_spinlock(void *lock, int en);
#else
#define dbg_snapshot_spinlock(a,b)		do { } while(0)
#endif

#ifdef CONFIG_DEBUG_SNAPSHOT_CLK
struct clk;
extern void dbg_snapshot_clk(void *clock, const char *func_name, unsigned long arg, int mode);
#else
#define dbg_snapshot_clk(a,b,c,d)		do { } while(0)
#endif

#ifdef CONFIG_DEBUG_SNAPSHOT_PMU
extern void dbg_snapshot_pmu(int id, const char *func_name, int mode);
#else
#define dbg_snapshot_pmu(a,b,c)		do { } while(0)
#endif

#ifdef CONFIG_DEBUG_SNAPSHOT_FREQ
void dbg_snapshot_freq(int type, unsigned long old_freq, unsigned long target_freq, int en);
void dbg_snapshot_freq_misc(int type, unsigned long old_freq, unsigned long target_freq, int en);
#else
#define dbg_snapshot_freq(a,b,c,d)		do { } while(0)
#define dbg_snapshot_freq_misc(a,b,c,d)		do { } while(0)
#endif

#ifdef CONFIG_DEBUG_SNAPSHOT_DM
void dbg_snapshot_dm(int type, unsigned long min, unsigned long max, s32 wait_t, s32 t);
#else
#define dbg_snapshot_dm(a,b,c,d,e)		do { } while(0)
#endif

#ifdef CONFIG_DEBUG_SNAPSHOT_CRASH_KEY
void dbg_snapshot_check_crash_key(unsigned int code, int value);
#else
#define dbg_snapshot_check_crash_key(a,b)	do { } while(0)
#endif

#ifdef CONFIG_DEBUG_SNAPSHOT_BINDER
extern void dbg_snapshot_binder(struct trace_binder_transaction_base *base,
				struct trace_binder_transaction *transaction,
				struct trace_binder_transaction_error *error);
#else
#define dbg_snapshot_binder(a,b,c)	do { } while(0)
#endif

#ifdef CONFIG_SEC_DEBUG
extern void dbg_snapshot_get_hardlockup_info(unsigned int cpu, void *info);
extern void dbg_snapshot_get_softlockup_info(unsigned int cpu, void *info);
#else
#define dbg_snapshot_get_hardlockup_info(a, b)	do { } while (0)
#define dbg_snapshot_get_softlockup_info(a, b)	do { } while (0)
#endif

#else
#define dbg_snapshot_acpm(a,b,c)		do { } while(0)
#define dbg_snapshot_task(a,b)		do { } while(0)
#define dbg_snapshot_work(a,b,c,d)		do { } while(0)
#define dbg_snapshot_clockevent(a,b,c)	do { } while(0)
#define dbg_snapshot_cpuidle(a,b,c,d)	do { } while(0)
#define dbg_snapshot_suspend(a,b,c,d,e)	do { } while(0)
#define dbg_snapshot_regulator(a,b,c,d,e,f)	do { } while(0)
#define dbg_snapshot_thermal(a,b,c,d)	do { } while(0)
#define dbg_snapshot_irq(a,b,c,d,e)		do { } while(0)
#define dbg_snapshot_irqs_disabled(a)	do { } while(0)
#define dbg_snapshot_spinlock(a,b)		do { } while(0)
#define dbg_snapshot_clk(a,b,c,d)		do { } while(0)
#define dbg_snapshot_pmu(a,b,c)		do { } while(0)
#define dbg_snapshot_freq(a,b,c,d)		do { } while(0)
#define dbg_snapshot_freq_misc(a,b,c,d)		do { } while(0)
#define dbg_snapshot_irq_var(v)		do { v = 0; } while(0)
#define dbg_snapshot_reg(a,b,c,d)		do { } while(0)
#define dbg_snapshot_hrtimer(a,b,c,d)	do { } while(0)
#define dbg_snapshot_i2c(a,b,c,d)		do { } while(0)
#define dbg_snapshot_spi(a,b,c)		do { } while(0)
#define dbg_snapshot_hook_pmsg(a,b)	do { } while(0)
#define dbg_snapshot_printk(...)		do { } while(0)
#define dbg_snapshot_printkl(a,b)		do { } while(0)
#define dbg_snapshot_save_context(a)	do { } while(0)
#define dbg_snapshot_try_enable(a,b)	do { } while(0)
#define dbg_snapshot_set_enable(a,b)	do { } while(0)
#define dbg_snapshot_get_enable(a)		do { } while(0)
#define dbg_snapshot_save_reg(a)		do { } while(0)
#define dbg_snapshot_save_system(a)	do { } while(0)
#define dbg_snapshot_dump_panic(a,b)	do { } while(0)
#define dbg_snapshot_dump_sfr()		do { } while(0)
#define dbg_snapshot_early_panic(a)	do { } while(0)
#define dbg_snapshot_prepare_panic()	do { } while(0)
#define dbg_snapshot_post_panic()		do { } while(0)
#define dbg_snapshot_post_reboot(a)	do { } while(0)
#define dbg_snapshot_set_hardlockup(a)	do { } while(0)
#define dbg_snapshot_get_hardlockup()	do { } while(0)
#define dbg_snapshot_set_sjtag_status() do { } while (0)
#define dbg_snasshot_get_sjtag_status() do { } while (0)
#define dbg_snapshot_get_debug_level()	do { } while(0)
#define dbg_snapshot_get_debug_level_reg()     do { } while (0)
#define dbg_snapshot_check_crash_key(a,b)	do { } while(0)
#define dbg_snapshot_dm(a,b,c,d,e)		do { } while(0)
#define dbg_snapshot_panic_handler_safe()	do { } while(0)
#define dbg_snapshot_get_last_pc(a)	do { } while(0)
#define dbg_snapshot_get_last_pc_paddr()	do { } while(0)
#define dbg_snapshot_hook_hardlockup_entry(a) do { } while(0)
#define dbg_snapshot_hook_hardlockup_exit() do { } while(0)
#define dbg_snapshot_binder(a,b,c)	do { } while(0)
#define dbg_snapshot_get_hardlockup_info(a, b)	do { } while (0)
#define dbg_snapshot_get_softlockup_info(a, b)	do { } while (0)

static inline unsigned int dbg_snapshot_get_item_size(char *name)
{
	return 0;
}
static inline unsigned int dbg_snapshot_get_item_paddr(char *name)
{
	return 0;
}
static inline unsigned long dbg_snapshot_get_item_vaddr(char *name)
{
	return 0;
}
static inline unsigned long dbg_snapshot_get_item_curr_ptr(char *name)
{
	return 0;
}
static inline bool dbg_snapshot_dumper_one(void *v_dumper,
				char *line, size_t size, size_t *len)
{
	return false;
}
static int dbg_snapshot_add_bl_item_info(const char *name,
				unsigned int paddr, unsigned int size)
{
	return 0;
}

#endif /* CONFIG_DEBUG_SNAPSHOT */

extern void dbg_snapshot_soc_helper_init(void);
static inline void dbg_snapshot_bug_func(void) {BUG();}
static inline void dbg_snapshot_spin_func(void) {do {wfi();} while(1);}

extern struct atomic_notifier_head restart_handler_list;
extern struct blocking_notifier_head reboot_notifier_list;
extern struct blocking_notifier_head pm_chain_head;

#ifdef CONFIG_EXYNOS_ITMON
extern struct atomic_notifier_head itmon_notifier_list;
#endif

/**
 * dsslog_flag - added log information supported.
 * @DSS_FLAG_REQ: Generally, marking starting request something
 * @DSS_FLAG_IN: Generally, marking into the function
 * @DSS_FLAG_ON: Generally, marking the status not in, not out
 * @DSS_FLAG_OUT: Generally, marking come out the function
 * @DSS_FLAG_SOFTIRQ: Marking to pass the softirq function
 * @DSS_FLAG_SOFTIRQ_HI_TASKLET: Marking to pass the tasklet function
 * @DSS_FLAG_SOFTIRQ_TASKLET: Marking to pass the tasklet function
 */
enum dsslog_flag {
	DSS_FLAG_REQ			= 0,
	DSS_FLAG_IN			= 1,
	DSS_FLAG_ON			= 2,
	DSS_FLAG_OUT			= 3,
	DSS_FLAG_SOFTIRQ		= 10000,
	DSS_FLAG_SOFTIRQ_HI_TASKLET	= 10100,
	DSS_FLAG_SOFTIRQ_TASKLET	= 10200,
	DSS_FLAG_CALL_TIMER_FN		= 20000,
	DSS_FLAG_SMP_CALL_FN		= 30000,
};

enum dsslog_freq_flag {
	DSS_FLAG_LIT = 0,
	DSS_FLAG_MID,
	DSS_FLAG_BIG,
	DSS_FLAG_INT,
	DSS_FLAG_MIF,
	DSS_FLAG_ISP,
	DSS_FLAG_DISP,
	DSS_FLAG_INTCAM,
	DSS_FLAG_AUD,
	DSS_FLAG_IVA,
	DSS_FLAG_SCORE,
	DSS_FLAG_FSYS0,
	DSS_FLAG_MFC,
	DSS_FLAG_NPU,
	DSS_FLAG_G3D,
	DSS_FLAG_END
};

#define DSS_DEBUG_LEVEL_PREFIX	(0xDB9 << 16)
#define DSS_DEBUG_LEVEL_LOW	(0)
#define DSS_DEBUG_LEVEL_MID	(1)

#endif