1 /* include/mach/sec-debug.h
3 * Copyright (C) 2014 Samsung Electronics Co, Ltd.
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
19 #include <linux/sched.h>
20 #include <linux/semaphore.h>
21 #include <soc/sprd/hardware.h>
23 #ifdef CONFIG_SEC_DEBUG
25 struct sec_log_buffer {
34 union sec_debug_level_t {
42 #ifdef CONFIG_ARCH_SCX15
44 #define SEC_DEBUG_MAGIC_VA (SEC_DEBUG_MAGIC_BASE_VA)
45 #define SPRD_INFORM0 (SEC_DEBUG_MAGIC_VA + 0x00000004)
46 #define SPRD_INFORM1 (SPRD_INFORM0 + 0x00000004)
47 #define SPRD_INFORM2 (SPRD_INFORM1 + 0x00000004)
48 #define SPRD_INFORM3 (SPRD_INFORM2 + 0x00000004)
49 #define SPRD_INFORM4 (SPRD_INFORM3 + 0x00000004)
50 #define SPRD_INFORM5 (SPRD_INFORM4 + 0x00000004)
51 #define SPRD_INFORM6 (SPRD_INFORM5 + 0x00000004)
55 #define SEC_DEBUG_MAGIC_VA (SPRD_IRAM0_BASE + 0x00000f80)
56 #define SPRD_INFORM0 (SEC_DEBUG_MAGIC_VA + 0x00000004)
57 #define SPRD_INFORM1 (SPRD_INFORM0 + 0x00000004)
58 #define SPRD_INFORM2 (SPRD_INFORM1 + 0x00000004)
59 #define SPRD_INFORM3 (SPRD_INFORM2 + 0x00000004)
60 #define SPRD_INFORM4 (SPRD_INFORM3 + 0x00000004)
61 #define SPRD_INFORM5 (SPRD_INFORM4 + 0x00000004)
62 #define SPRD_INFORM6 (SPRD_INFORM5 + 0x00000004)
66 extern union sec_debug_level_t sec_debug_level;
68 extern int sec_debug_init(void);
70 extern int sec_debug_magic_init(void);
72 extern void sec_debug_check_crash_key(unsigned int code, int value);
74 extern void sec_getlog_supply_fbinfo(void *p_fb, u32 res_x, u32 res_y, u32 bpp,
76 extern void sec_getlog_supply_loggerinfo(void *p_main, void *p_radio,
77 void *p_events, void *p_system);
79 extern void sec_getlog_supply_kloginfo(void *klog_buf);
81 extern void sec_gaf_supply_rqinfo(unsigned short curr_offset,
82 unsigned short rq_offset);
84 extern void sec_debug_save_pte(void *pte, int task_addr);
86 int sec_debug_dump_stack(void);
88 extern int get_sec_debug_level(void);
90 static inline int sec_debug_init(void)
95 static inline int sec_debug_magic_init(void)
100 static inline void sec_debug_check_crash_key(unsigned int code, int value)
104 static inline void sec_getlog_supply_fbinfo(void *p_fb, u32 res_x, u32 res_y,
109 static inline void sec_getlog_supply_meminfo(u32 size0, u32 addr0, u32 size1,
114 static inline void sec_getlog_supply_loggerinfo(void *p_main,
115 void *p_radio, void *p_events,
120 static inline void sec_getlog_supply_kloginfo(void *klog_buf)
124 static inline void sec_gaf_supply_rqinfo(unsigned short curr_offset,
125 unsigned short rq_offset)
129 void sec_debug_save_pte(void *pte, unsigned int faulttype);
133 static inline int get_sec_debug_level(void)
141 #ifdef CONFIG_SEC_DEBUG_SCHED_LOG
142 extern void __sec_debug_task_log(int cpu, struct task_struct *task);
143 extern void __sec_debug_irq_log(unsigned int irq, void *fn, int en);
144 extern void __sec_debug_work_log(struct worker *worker,
145 struct work_struct *work, work_func_t f, int en);
146 #ifdef CONFIG_SEC_DEBUG_TIMER_LOG
147 extern void __sec_debug_timer_log(unsigned int type, void *fn);
150 static inline void sec_debug_task_log(int cpu, struct task_struct *task)
152 if (unlikely(sec_debug_level.en.kernel_fault))
153 __sec_debug_task_log(cpu, task);
156 static inline void sec_debug_irq_log(unsigned int irq, void *fn, int en)
158 if (unlikely(sec_debug_level.en.kernel_fault))
159 __sec_debug_irq_log(irq, fn, en);
162 static inline void sec_debug_work_log(struct worker *worker,
163 struct work_struct *work, work_func_t f, int en)
165 if (unlikely(sec_debug_level.en.kernel_fault))
166 __sec_debug_work_log(worker, work, f, en);
169 #ifdef CONFIG_SEC_DEBUG_TIMER_LOG
170 static inline void sec_debug_timer_log(unsigned int type, void *fn)
172 if (unlikely(sec_debug_level.en.kernel_fault))
173 __sec_debug_timer_log(type, fn);
176 static inline void sec_debug_timer_log(unsigned int type, void *fn)
181 #ifdef CONFIG_SEC_DEBUG_SOFTIRQ_LOG
182 static inline void sec_debug_softirq_log(unsigned int irq, void *fn, int en)
184 if (unlikely(sec_debug_level.en.kernel_fault))
186 static inline void sec_debug_softirq_log(unsigned int irq, void *fn, int en)
192 static inline void sec_debug_task_log(int cpu, struct task_struct *task)
196 static inline void sec_debug_irq_log(unsigned int irq, void *fn, int en)
200 static inline void sec_debug_work_log(struct worker *worker,
201 struct work_struct *work, work_func_t f, int en)
205 static inline void sec_debug_timer_log(unsigned int type, void *fn)
209 static inline void sec_debug_softirq_log(unsigned int irq, void *fn, int en)
213 #ifdef CONFIG_SEC_DEBUG_IRQ_EXIT_LOG
214 extern void sec_debug_irq_last_exit_log(void);
216 static inline void sec_debug_irq_last_exit_log(void)
221 #ifdef CONFIG_SEC_DEBUG_SEMAPHORE_LOG
222 extern void debug_semaphore_init(void);
223 extern void debug_semaphore_down_log(struct semaphore *sem);
224 extern void debug_semaphore_up_log(struct semaphore *sem);
225 extern void debug_rwsemaphore_init(void);
226 extern void debug_rwsemaphore_down_log(struct rw_semaphore *sem, int dir);
227 extern void debug_rwsemaphore_up_log(struct rw_semaphore *sem);
228 #define debug_rwsemaphore_down_read_log(x) \
229 debug_rwsemaphore_down_log(x, READ_SEM)
230 #define debug_rwsemaphore_down_write_log(x) \
231 debug_rwsemaphore_down_log(x, WRITE_SEM)
233 static inline void debug_semaphore_init(void)
237 static inline void debug_semaphore_down_log(struct semaphore *sem)
241 static inline void debug_semaphore_up_log(struct semaphore *sem)
245 static inline void debug_rwsemaphore_init(void)
249 static inline void debug_rwsemaphore_down_read_log(struct rw_semaphore *sem)
253 static inline void debug_rwsemaphore_down_write_log(struct rw_semaphore *sem)
257 static inline void debug_rwsemaphore_up_log(struct rw_semaphore *sem)
262 enum sec_debug_aux_log_idx {
263 SEC_DEBUG_AUXLOG_CPU_BUS_CLOCK_CHANGE,
264 SEC_DEBUG_AUXLOG_LOGBUF_LOCK_CHANGE,
265 SEC_DEBUG_AUXLOG_ITEM_MAX,
268 #ifdef CONFIG_SEC_DEBUG_AUXILIARY_LOG
269 extern void sec_debug_aux_log(int idx, char *fmt, ...);
271 #define sec_debug_aux_log(idx, ...) do { } while (0)
274 #endif /* SEC_DEBUG_H */