aee.h 8.9 KB

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