Merge tag 'v3.10.72' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / linux / aee.h
1 #if !defined(__AEE_H__)
2 #define __AEE_H__
3
4 #include <linux/kernel.h>
5 #include <linux/sched.h>
6 #include <linux/mtk_ram_console.h>
7
8 #define AEE_MODULE_NAME_LENGTH 64
9 #define AEE_PROCESS_NAME_LENGTH 256
10 #define AEE_BACKTRACE_LENGTH 3072
11
12 typedef enum {
13 AE_DEFECT_FATAL,
14 AE_DEFECT_EXCEPTION,
15 AE_DEFECT_WARNING,
16 AE_DEFECT_REMINDING,
17 AE_DEFECT_ATTR_END
18 } AE_DEFECT_ATTR;
19
20 typedef enum {
21 AE_KE = 0, /* Fatal Exception */
22 AE_NE,
23 AE_JE,
24 AE_SWT,
25 AE_EE,
26 AE_EXP_ERR_END,
27 AE_ANR, /* Error or Warning or Defect */
28 AE_RESMON,
29 AE_MODEM_WARNING,
30 AE_WRN_ERR_END,
31 AE_MANUAL, /* Manual Raise */
32 AE_EXP_CLASS_END,
33
34 AE_KERNEL_PROBLEM_REPORT = 1000,
35 AE_SYSTEM_JAVA_DEFECT,
36 AE_SYSTEM_NATIVE_DEFECT,
37 } AE_EXP_CLASS; /* General Program Exception Class */
38
39 typedef enum {
40 AEE_REBOOT_MODE_NORMAL = 0,
41 AEE_REBOOT_MODE_KERNEL_OOPS,
42 AEE_REBOOT_MODE_KERNEL_PANIC,
43 AEE_REBOOT_MODE_NESTED_EXCEPTION,
44 AEE_REBOOT_MODE_WDT,
45 AEE_REBOOT_MODE_MANUAL_KDUMP,
46 } AEE_REBOOT_MODE;
47
48 #define AEE_SZ_SYMBOL_L 140
49 #define AEE_SZ_SYMBOL_S 80
50 struct aee_bt_frame {
51 __u64 pc;
52 __u64 lr;
53 __u32 pad[5];
54 char pc_symbol[AEE_SZ_SYMBOL_S]; /* Now we use different symbol length for PC &LR */
55 char lr_symbol[AEE_SZ_SYMBOL_L];
56 };
57
58 /* aee_process_info struct should strictly small than ipanic_buffer, now 4KB */
59 struct aee_process_info {
60 char process_path[AEE_PROCESS_NAME_LENGTH];
61 char backtrace[AEE_BACKTRACE_LENGTH];
62 struct aee_bt_frame ke_frame;
63 };
64
65 struct aee_process_bt {
66 __u32 pid;
67 __u32 nr_entries;
68 struct aee_bt_frame *entries;
69 };
70
71
72 struct aee_thread_reg {
73 pid_t tid;
74 struct pt_regs regs;
75 };
76
77 struct aee_user_thread_stack {
78 pid_t tid;
79 int StackLength;
80 unsigned char *Userthread_Stack; //8k stack ,define to char only for match 64bit/32bit
81 };
82
83 struct aee_user_thread_maps {
84 pid_t tid;
85 int Userthread_mapsLength;
86 unsigned char *Userthread_maps; //8k stack ,define to char only for match 64bit/32bit
87 };
88
89
90
91 struct aee_oops {
92 struct list_head list;
93 AE_DEFECT_ATTR attr;
94 AE_EXP_CLASS clazz;
95
96 char module[AEE_MODULE_NAME_LENGTH];
97 /* consist with struct aee_process_info */
98 char process_path[AEE_PROCESS_NAME_LENGTH];
99 char backtrace[AEE_BACKTRACE_LENGTH];
100 struct aee_bt_frame ke_frame;
101
102 char *detail;
103 int detail_len;
104
105 char *console;
106 int console_len;
107
108 char *android_main;
109 int android_main_len;
110 char *android_radio;
111 int android_radio_len;
112 char *android_system;
113 int android_system_len;
114
115 char *userspace_info;
116 int userspace_info_len;
117
118 char *mmprofile;
119 int mmprofile_len;
120
121 char *mini_rdump;
122 int mini_rdump_len;
123
124
125 struct aee_user_thread_stack userthread_stack;
126 struct aee_thread_reg userthread_reg;
127 struct aee_user_thread_maps userthread_maps;
128
129 int dump_option;
130 };
131
132 struct aee_kernel_api {
133 void (*kernel_reportAPI) (const AE_DEFECT_ATTR attr, const int db_opt, const char *module,
134 const char *msg);
135 void (*md_exception) (const char *assert_type, const int *log, int log_size, const int *phy,
136 int phy_size, const char *detail, const int db_opt);
137 void (*md32_exception) (const char *assert_type, const int *log, int log_size,
138 const int *phy, int phy_size, const char *detail, const int db_opt);
139 void (*combo_exception) (const char *assert_type, const int *log, int log_size,
140 const int *phy, int phy_size, const char *detail,
141 const int db_opt);
142 };
143
144 void aee_sram_printk(const char *fmt, ...);
145 int aee_nested_printf(const char *fmt, ...);
146 void aee_wdt_irq_info(void);
147 void aee_wdt_fiq_info(void *arg, void *regs, void *svc_sp);
148 void aee_trigger_kdb(void);
149 struct aee_oops *aee_oops_create(AE_DEFECT_ATTR attr, AE_EXP_CLASS clazz, const char *module);
150 void aee_oops_set_backtrace(struct aee_oops *oops, const char *backtrace);
151 void aee_oops_set_process_path(struct aee_oops *oops, const char *process_path);
152 void aee_oops_free(struct aee_oops *oops);
153 /* powerkey press,modules use bits */
154 #define AE_WDT_Powerkey_DEVICE_PATH "/dev/kick_powerkey"
155 #define WDT_SETBY_DEFAULT (0)
156 #define WDT_SETBY_Backlight (1<<0)
157 #define WDT_SETBY_Display (1<<1)
158 #define WDT_SETBY_SF (1<<2)
159 #define WDT_SETBY_PM (1<<3)
160 #define WDT_SETBY_WMS_DISABLE_PWK_MONITOR (0xAEEAEE00)
161 #define WDT_SETBY_WMS_ENABLE_PWK_MONITOR (0xAEEAEE01)
162 #define WDT_PWK_HANG_FORCE_HWT (0xAEE0FFFF)
163
164 /* QHQ RT Monitor */
165 #define AEEIOCTL_RT_MON_Kick _IOR('p', 0x0A, int)
166 #define AE_WDT_DEVICE_PATH "/dev/RT_Monitor"
167 /* QHQ RT Monitor end */
168
169 /* DB dump option bits, set relative bit to 1 to include related file in db */
170 #define DB_OPT_DEFAULT (0)
171 #define DB_OPT_FTRACE (1<<0)
172 #define DB_OPT_STORAGE_LOG (1<<1)
173 #define DB_OPT_NE_JBT_TRACES (1<<2)
174 #define DB_OPT_SWT_JBT_TRACES (1<<3)
175 #define DB_OPT_VM_TRACES (1<<4)
176 #define DB_OPT_DUMPSYS_ACTIVITY (1<<5)
177 #define DB_OPT_DUMPSYS_WINDOW (1<<6)
178 #define DB_OPT_DUMPSYS_GFXINFO (1<<7)
179 #define DB_OPT_DUMPSYS_SURFACEFLINGER (1<<8)
180 #define DB_OPT_DISPLAY_HANG_DUMP (1<<9)
181 #define DB_OPT_LOW_MEMORY_KILLER (1<<10)
182 #define DB_OPT_PROC_MEM (1<<11)
183 #define DB_OPT_FS_IO_LOG (1<<12)
184 #define DB_OPT_PROCESS_COREDUMP (1<<13)
185 #define DB_OPT_VM_HPROF (1<<14)
186 #define DB_OPT_PROCMEM (1<<15)
187 #define DB_OPT_DUMPSYS_INPUT (1<<16)
188 #define DB_OPT_MMPROFILE_BUFFER (1<<17)
189 #define DB_OPT_BINDER_INFO (1<<18)
190 #define DB_OPT_WCN_ISSUE_INFO (1<<19)
191 #define DB_OPT_DUMMY_DUMP (1<<20)
192 #define DB_OPT_PID_MEMORY_INFO (1<<21)
193 #define DB_OPT_VM_OOME_HPROF (1<<22)
194 #define DB_OPT_PID_SMAPS (1<<23)
195 #define DB_OPT_PROC_CMDQ_INFO (1<<24)
196 #define DB_OPT_PROC_USKTRK (1<<25)
197 #define DB_OPT_SF_RTT_DUMP (1<<26)
198 #define DB_OPT_PAGETYPE_INFO (1<<27)
199 #define DB_OPT_DUMPSYS_PROCSTATS (1<<28)
200 #define DB_OPT_DUMP_DISPLAY (1<<29)
201 #define DB_OPT_NATIVE_BACKTRACE (1<<30)
202 #define DB_OPT_AARCH64 (1<<31)
203
204 #define aee_kernel_exception(module, msg...) \
205 aee_kernel_exception_api(__FILE__, __LINE__, DB_OPT_DEFAULT, module, msg)
206 #define aee_kernel_warning(module, msg...) \
207 aee_kernel_warning_api(__FILE__, __LINE__, DB_OPT_DEFAULT, module, msg)
208 #define aee_kernel_reminding(module, msg...) \
209 aee_kernel_reminding_api(__FILE__, __LINE__, DB_OPT_DEFAULT, module, msg)
210 #define aee_kernel_dal_show(msg) \
211 aee_kernel_dal_api(__FILE__, __LINE__, msg)
212
213 #define aed_md_exception(log, log_size, phy, phy_size, detail) \
214 aed_md_exception_api(log, log_size, phy, phy_size, detail, DB_OPT_DEFAULT)
215 #define aed_md32_exception(log, log_size, phy, phy_size, detail) \
216 aed_md32_exception_api(log, log_size, phy, phy_size, detail, DB_OPT_DEFAULT)
217 #define aed_combo_exception(log, log_size, phy, phy_size, detail) \
218 aed_combo_exception_api(log, log_size, phy, phy_size, detail, DB_OPT_DEFAULT)
219
220 void aee_kernel_exception_api(const char *file, const int line, const int db_opt,
221 const char *module, const char *msg, ...);
222 void aee_kernel_warning_api(const char *file, const int line, const int db_opt, const char *module,
223 const char *msg, ...);
224 void aee_kernel_reminding_api(const char *file, const int line, const int db_opt,
225 const char *module, const char *msg, ...);
226 void aee_kernel_dal_api(const char *file, const int line, const char *msg);
227
228 void aed_md_exception_api(const int *log, int log_size, const int *phy, int phy_size,
229 const char *detail, const int db_opt);
230 void aed_md32_exception_api(const int *log, int log_size, const int *phy, int phy_size,
231 const char *detail, const int db_opt);
232 void aed_combo_exception_api(const int *log, int log_size, const int *phy, int phy_size,
233 const char *detail, const int db_opt);
234
235 void aee_kernel_wdt_kick_Powkey_api(const char *module, int msg);
236 int aee_kernel_wdt_kick_api(int kinterval);
237 void aee_powerkey_notify_press(unsigned long pressed);
238 int aee_kernel_Powerkey_is_press(void);
239
240 void ipanic_recursive_ke(struct pt_regs *regs, struct pt_regs *excp_regs, int cpu);
241
242 /* QHQ RT Monitor */
243 void aee_kernel_RT_Monitor_api(int lParam);
244 /* QHQ RT Monitor end */
245 void mt_fiq_printf(const char *fmt, ...);
246 void aee_register_api(struct aee_kernel_api *aee_api);
247 int aee_in_nested_panic(void);
248 void aee_stop_nested_panic(struct pt_regs *regs);
249 void aee_wdt_dump_info(void);
250 void aee_wdt_printf(const char *fmt, ...);
251
252 #if defined(CONFIG_MTK_AEE_DRAM_CONSOLE)
253 void aee_dram_console_reserve_memory(void);
254 #else
255 static inline void aee_dram_console_reserve_memory(void)
256 {
257 }
258 #endif
259
260 extern void *aee_excp_regs; /* To store latest exception, in case of stack corruption */
261 #endif /* __AEE_H__ */