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
324
325
326
|
/*
* 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 EXYNOS_SNAPSHOT_H
#define EXYNOS_SNAPSHOT_H
#ifdef CONFIG_EXYNOS_SNAPSHOT
#include <linux/kernel.h>
#include <asm/ptrace.h>
#include "exynos-ss-soc.h"
#include <linux/bug.h>
extern unsigned int *exynos_ss_base_enabled;
/* mandatory */
extern void __exynos_ss_task(int cpu, void *v_task);
extern void __exynos_ss_work(void *worker, void *work, void *fn, int en);
extern void __exynos_ss_cpuidle(char *modes, unsigned state, int diff, int en);
extern void __exynos_ss_suspend(void *fn, void *dev, int en);
extern void __exynos_ss_irq(int irq, void *fn, unsigned long val, int en);
extern int exynos_ss_try_enable(const char *name, unsigned long long duration);
extern int exynos_ss_set_enable(const char *name, int en);
extern int exynos_ss_get_enable(const char *name, bool init);
extern int exynos_ss_save_context(void *regs);
extern int exynos_ss_save_reg(void *regs);
extern int exynos_ss_dump_panic(char *str, size_t len);
extern int exynos_ss_prepare_panic(void);
extern int exynos_ss_post_panic(void);
extern int exynos_ss_post_reboot(void);
extern int exynos_ss_set_hardlockup(int);
extern int exynos_ss_get_hardlockup(void);
extern unsigned int exynos_ss_get_item_size(char *);
extern unsigned int exynos_ss_get_item_paddr(char *);
extern void exynos_ss_panic_handler_safe(struct pt_regs *regs);
extern unsigned long exynos_ss_get_last_pc(unsigned int cpu);
extern unsigned long exynos_ss_get_last_pc_paddr(void);
extern void exynos_ss_hook_hardlockup_entry(void *v_regs);
extern void exynos_ss_hook_hardlockup_exit(void);
#ifdef CONFIG_EXYNOS_DRAMTEST
extern int disable_mc_powerdn(void);
#endif
/* option */
#ifdef CONFIG_EXYNOS_SNAPSHOT_REGULATOR
extern void __exynos_ss_regulator(char *f_name, unsigned int addr, unsigned int volt, int en);
static inline void exynos_ss_regulator(char *f_name, unsigned int addr, unsigned int volt, int en)
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_regulator(f_name, addr, volt, en);
}
#else
#define exynos_ss_regulator(a,b,c,d) do { } while(0)
#endif
#ifdef CONFIG_EXYNOS_SNAPSHOT_THERMAL
extern void __exynos_ss_thermal(void *data, unsigned int temp, char *name, unsigned int max_cooling);
static inline void exynos_ss_thermal(void *data, unsigned int temp, char *name, unsigned int max_cooling)
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_thermal(data, temp, name, max_cooling);
}
#else
#define exynos_ss_thermal(a,b,c,d) do { } while(0)
#endif
#ifdef CONFIG_EXYNOS_SNAPSHOT_MBOX
extern void __exynos_ss_mailbox(void *msg, int mode, char *f_name, void *volt);
static inline void exynos_ss_mailbox(void *msg, int mode, char *f_name, void *volt)
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_mailbox(msg, mode, f_name, volt);
}
#else
#define exynos_ss_mailbox(a,b,c,d) do { } while(0)
#endif
#ifndef CONFIG_EXYNOS_SNAPSHOT_MINIMIZED_MODE
extern void __exynos_ss_clockevent(void* dev, unsigned long long clc, int64_t delta, void *next_event);
extern void __exynos_ss_printk(const char *fmt, ...);
extern void __exynos_ss_printkl(size_t msg, size_t val);
static inline void exynos_ss_clockevent(void* dev, unsigned long long clc, int64_t delta, void *next_event)
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_clockevent(dev, clc, delta, next_event);
}
#define exynos_ss_printk(fmt, ...) \
({ \
if (unlikely(*exynos_ss_base_enabled)) \
__exynos_ss_printk(fmt, ##__VA_ARGS__); \
})
static inline void exynos_ss_printkl(size_t msg, size_t val)
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_printkl(msg, val);
}
#else
#define exynos_ss_clockevent(a,b,c,d) do { } while(0)
#define exynos_ss_printk(...) do { } while(0)
#define exynos_ss_printkl(a,b) do { } while(0)
#endif
#ifdef CONFIG_EXYNOS_SNAPSHOT_IRQ_DISABLED
extern void __exynos_ss_irqs_disabled(unsigned long flags);
static inline void exynos_ss_irqs_disabled(unsigned long flags);
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_irqs_disabled(flags);
}
#else
#define exynos_ss_irqs_disabled(a) do { } while(0);
#endif
#ifdef CONFIG_EXYNOS_SNAPSHOT_HRTIMER
extern void __exynos_ss_hrtimer(void *timer, s64 *now, void *fn, int en);
static inline void exynos_ss_hrtimer(void *timer, s64 *now, void *fn, int en)
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_hrtimer(timer, now, fn, en);
}
#else
#define exynos_ss_hrtimer(a,b,c,d) do { } while(0);
#endif
#ifdef CONFIG_EXYNOS_SNAPSHOT_REG
extern void __exynos_ss_reg(unsigned int read, size_t val, size_t reg, int en);
static inline void exynos_ss_reg(unsigned int read, size_t val, size_t reg, int en)
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_reg(read, val, reg, en);
}
#else
#define exynos_ss_reg(a,b,c,d) do { } while(0);
#endif
#ifdef CONFIG_EXYNOS_SNAPSHOT_SPINLOCK
extern void __exynos_ss_spinlock(void *lock, int en);
static inline void exynos_ss_spinlock(void *lock, int en)
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_spinlock(lock, en);
}
#else
#define exynos_ss_spinlock(a,b) do { } while(0);
#endif
#ifdef CONFIG_EXYNOS_SNAPSHOT_CLK
struct clk;
extern void __exynos_ss_clk(void *clock, const char *func_name, int mode);
static inline void exynos_ss_clk(void *clock, const char *func_name, int mode)
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_clk(clock, func_name, mode);
}
#else
#define exynos_ss_clk(a,b,c) do { } while(0);
#endif
#ifdef CONFIG_EXYNOS_SNAPSHOT_FREQ
extern void __exynos_ss_freq(int type, unsigned long old_freq, unsigned long target_freq, int en);
static inline void exynos_ss_freq(int type, unsigned long old_freq, unsigned long target_freq, int en)
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_freq(type, old_freq, target_freq, en);
}
#else
#define exynos_ss_freq(a,b,c,d) do { } while(0);
#endif
#ifdef CONFIG_EXYNOS_SNAPSHOT_IRQ_EXIT
extern void __exynos_ss_irq_exit(unsigned int irq, unsigned long long start_time);
static inline void exynos_ss_irq_exit(unsigned int irq, unsigned long long start_time)
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_irq_exit(irq, start_time);
}
#define exynos_ss_irq_exit_var(v) do { v = cpu_clock(raw_smp_processor_id()); \
} while(0)
#else
#define exynos_ss_irq_exit(a,b) do { } while(0);
#define exynos_ss_irq_exit_var(v) do { v = 0; } while(0);
#endif
#ifdef CONFIG_EXYNOS_SNAPSHOT_PSTORE
extern int exynos_ss_hook_pmsg(char *buffer, size_t count);
#else
#define exynos_ss_hook_pmsg(a,b) do { } while(0);
#endif
#ifdef CONFIG_EXYNOS_SNAPSHOT_CRASH_KEY
void exynos_ss_check_crash_key(unsigned int code, int value);
#else
#define exynos_ss_check_crash_key(a,b) do { } while(0);
#endif
#ifdef CONFIG_EXYNOS_SNAPSHOT_SFRDUMP
void exynos_ss_dump_sfr(void);
#else
#define exynos_ss_dump_sfr() do { } while(0)
#endif
/* inline functions */
static inline void exynos_ss_task(int cpu, void *v_task)
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_task(cpu, v_task);
}
static inline void exynos_ss_work(void *worker, void *work, void *fn, int en)
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_work(worker, work, fn, en);
}
static inline void exynos_ss_cpuidle(char *modes, unsigned state, int diff, int en)
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_cpuidle(modes, state, diff, en);
}
static inline void exynos_ss_suspend(void *fn, void *dev, int en)
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_suspend(fn, dev, en);
}
static inline void exynos_ss_irq(int irq, void *fn, unsigned long val, int en)
{
if (unlikely(*exynos_ss_base_enabled))
__exynos_ss_irq(irq, fn, val, en);
}
#else
#define exynos_ss_task(a,b) do { } while(0)
#define exynos_ss_work(a,b,c,d) do { } while(0)
#define exynos_ss_clockevent(a,b,c) do { } while(0)
#define exynos_ss_cpuidle(a,b,c,d) do { } while(0)
#define exynos_ss_suspend(a,b,c) do { } while(0)
#define exynos_ss_regulator(a,b,c,d) do { } while(0)
#define exynos_ss_thermal(a,b,c,d) do { } while(0)
#define exynos_ss_mailbox(a,b,c,d) do { } while(0)
#define exynos_ss_irq(a,b,c,d) do { } while(0)
#define exynos_ss_irq_exit(a,b) do { } while(0)
#define exynos_ss_irqs_disabled(a) do { } while(0)
#define exynos_ss_spinlock(a,b) do { } while(0)
#define exynos_ss_clk(a,b,c) do { } while(0)
#define exynos_ss_freq(a,b,c,d) do { } while(0)
#define exynos_ss_irq_exit_var(v) do { v = 0; } while(0)
#define exynos_ss_reg(a,b,c,d) do { } while(0)
#define exynos_ss_hrtimer(a,b,c,d) do { } while(0)
#define exynos_ss_hook_pmsg(a,b) do { } while(0)
#define exynos_ss_printk(...) do { } while(0)
#define exynos_ss_printkl(a,b) do { } while(0)
#define exynos_ss_save_context(a) do { } while(0)
#define exynos_ss_try_enable(a,b) do { } while(0)
#define exynos_ss_set_enable(a,b) do { } while(0)
#define exynos_ss_get_enable(a) do { } while(0)
#define exynos_ss_dump_panic(a,b) do { } while(0)
#define exynos_ss_dump_sfr() do { } while(0)
#define exynos_ss_prepare_panic() do { } while(0)
#define exynos_ss_post_panic() do { } while(0)
#define exynos_ss_post_reboot() do { } while(0)
#define exynos_ss_set_hardlockup(a) do { } while(0)
#define exynos_ss_get_hardlockup() do { } while(0)
#define exynos_ss_get_item_size(a) do { } while(0)
#define exynos_ss_get_item_paddr(a) do { } while(0)
#define exynos_ss_check_crash_key(a,b) do { } while(0)
#define exynos_ss_panic_handler_safe() do { } while(0)
#define exynos_ss_get_last_pc(a) do { } while(0)
#define exynos_ss_get_last_pc_paddr() do { } while(0)
#define exynos_ss_hook_hardlockup_entry(a) do { } while(0)
#define exynos_ss_hook_hardlockup_exit() do { } while(0)
#endif /* CONFIG_EXYNOS_SNAPSHOT */
static inline void exynos_ss_bug(void) {BUG();}
/**
* esslog_flag - added log information supported.
* @ESS_FLAG_IN: Generally, marking into the function
* @ESS_FLAG_ON: Generally, marking the status not in, not out
* @ESS_FLAG_OUT: Generally, marking come out the function
* @ESS_FLAG_SOFTIRQ: Marking to pass the softirq function
* @ESS_FLAG_SOFTIRQ_HI_TASKLET: Marking to pass the tasklet function
* @ESS_FLAG_SOFTIRQ_TASKLET: Marking to pass the tasklet function
*/
enum esslog_flag {
ESS_FLAG_IN = 1,
ESS_FLAG_ON = 2,
ESS_FLAG_OUT = 3,
ESS_FLAG_SOFTIRQ = 10000,
ESS_FLAG_SOFTIRQ_HI_TASKLET = 10100,
ESS_FLAG_SOFTIRQ_TASKLET = 10200,
ESS_FLAG_CALL_TIMER_FN = 20000
};
enum esslog_freq_flag {
ESS_FLAG_APL = 0,
ESS_FLAG_ATL,
ESS_FLAG_INT,
ESS_FLAG_MIF,
ESS_FLAG_ISP,
ESS_FLAG_DISP,
};
#endif
|