aed.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #ifndef __aed_h
  2. #define __aed_h
  3. #include <generated/autoconf.h>
  4. #include <linux/types.h>
  5. #include <linux/bug.h>
  6. #include <mt-plat/aee.h>
  7. #include <linux/kallsyms.h>
  8. #include <linux/ptrace.h>
  9. #define LOGD(fmt, msg...) pr_notice(fmt, ##msg)
  10. #define LOGV(fmt, msg...)
  11. #define LOGI LOGD
  12. #define LOGE(fmt, msg...) pr_err(fmt, ##msg)
  13. #define LOGW LOGE
  14. #define IPANIC_MODULE_TAG "KERNEL-PANIC"
  15. #define AE_INVALID 0xAEEFF000
  16. #define AE_NOT_AVAILABLE 0xAEE00000
  17. #define AE_DEFAULT 0xAEE00001
  18. enum AEE_MODE {
  19. AEE_MODE_MTK_ENG = 1,
  20. AEE_MODE_MTK_USER,
  21. AEE_MODE_CUSTOMER_ENG,
  22. AEE_MODE_CUSTOMER_USER,
  23. AEE_MODE_NOT_INIT
  24. };
  25. enum AEE_FORCE_RED_SCREEN_VALUE {
  26. AEE_FORCE_DISABLE_RED_SCREEN = 0,
  27. AEE_FORCE_RED_SCREEN,
  28. AEE_FORCE_NOT_SET
  29. };
  30. enum AE_ERR {
  31. AE_SUCC,
  32. AE_FAIL
  33. };
  34. enum AE_PASS_METHOD {
  35. AE_PASS_BY_MEM,
  36. AE_PASS_BY_FILE,
  37. AE_PASS_METHOD_END
  38. };
  39. enum AE_CMD_TYPE { AE_REQ, AE_RSP, AE_IND, AE_CMD_TYPE_END };
  40. enum AE_CMD_ID {
  41. AE_REQ_IDX,
  42. AE_REQ_CLASS,
  43. AE_REQ_TYPE,
  44. AE_REQ_PROCESS,
  45. AE_REQ_MODULE,
  46. AE_REQ_BACKTRACE,
  47. AE_REQ_DETAIL, /* Content of response message rule:
  48. * if msg.arg1==AE_PASS_BY_FILE => msg->data=file path
  49. */
  50. AE_REQ_ROOT_LOG_DIR,
  51. AE_REQ_CURR_LOG_DIR,
  52. AE_REQ_DFLT_LOG_DIR,
  53. AE_REQ_MAIN_LOG_FILE_PATH,
  54. AE_IND_FATAL_RAISED, /* fatal event raised, indicate AED to notify users */
  55. AE_IND_EXP_RAISED, /* exception event raised, indicate AED to notify users */
  56. AE_IND_WRN_RAISED, /* warning event raised, indicate AED to notify users */
  57. AE_IND_REM_RAISED, /* reminding event raised, indicate AED to notify users */
  58. AE_IND_LOG_STATUS, /* arg = AE_ERR */
  59. AE_IND_LOG_CLOSE, /* arg = AE_ERR */
  60. AE_REQ_SWITCH_DAL_BEEP, /* arg: dal on|off, seq: beep on|off */
  61. AE_REQ_DB_COUNT, /* arg: db count */
  62. AE_REQ_DB_FORCE_PATH, /* arg: force db path yes\no */
  63. AE_REQ_SWITCH_EXP_LEVEL,
  64. AE_REQ_IS_AED_READY, /* query if AED is ready for service */
  65. AE_REQ_COREDUMP, /* msg->data=file path */
  66. AE_REQ_SET_READFLAG, /* set read flag msg */
  67. AE_REQ_E2S_INIT, /* Init notification of client side(application layer) of Exp2Server */
  68. AE_REQ_USERSPACEBACKTRACE = 40,
  69. AE_REQ_USER_REG,
  70. AE_REQ_USER_MAPS,
  71. AE_CMD_ID_END
  72. };
  73. struct AE_Msg {
  74. enum AE_CMD_TYPE cmdType; /* command type */
  75. enum AE_CMD_ID cmdId; /* command Id */
  76. union {
  77. unsigned int seq; /* sequence number for error checking */
  78. int pid; /* process id */
  79. };
  80. union {
  81. unsigned int arg; /* simple argument */
  82. AE_EXP_CLASS cls; /* exception/error/defect class */
  83. };
  84. union {
  85. unsigned int len; /* dynamic length argument */
  86. int id; /* desired id */
  87. };
  88. unsigned int dbOption; /* DB dump option */
  89. };
  90. /* Kernel IOCTL interface */
  91. struct aee_dal_show {
  92. char msg[1024];
  93. };
  94. struct aee_dal_setcolor {
  95. unsigned int foreground;
  96. unsigned int background;
  97. unsigned int screencolor;
  98. };
  99. #define MAX_AEE_KERNEL_BT 16 /* we use MAX_NR_FRAME to control max unwind layer */
  100. #define AEE_NR_FRAME 32
  101. struct aee_ioctl {
  102. __u32 pid;
  103. __u32 detail;
  104. __u32 size;
  105. __u32 pad;
  106. __u64 in;
  107. __u64 out;
  108. };
  109. struct aee_thread_user_stack {
  110. pid_t tid;
  111. int StackLength;
  112. unsigned char Userspace_Stack[8192]; /* 8k stack ,define to char only for match 64bit/32bit */
  113. };
  114. #define AEEIOCTL_DAL_SHOW _IOW('p', 0x01, struct aee_dal_show) /* Show string on DAL layer */
  115. #define AEEIOCTL_DAL_CLEAN _IO('p', 0x02) /* Clear DAL layer */
  116. #define AEEIOCTL_SETCOLOR _IOW('p', 0x03, struct aee_dal_setcolor) /* RGB color 0x00RRGGBB */
  117. /*#define AEEIOCTL_GET_PROCESS_BT _IOW('p', 0x04, struct aee_process_bt) *//*change new ID for KK */
  118. #define AEEIOCTL_GET_PROCESS_BT _IOW('p', 0x04, struct aee_ioctl)
  119. #define AEEIOCTL_GET_SMP_INFO _IOR('p', 0x05, int)
  120. #define AEEIOCTL_SET_AEE_MODE _IOR('p', 0x06, int)
  121. #define AEEIOCTL_GET_THREAD_REG _IOW('p', 0x07, struct aee_thread_reg)
  122. #define AEEIOCTL_CHECK_SUID_DUMPABLE _IOR('p', 0x08, int)
  123. /* AED debug support */
  124. #define AEEIOCTL_WDT_KICK_POWERKEY _IOR('p', 0x09, int)
  125. #define AEEIOCTL_RT_MON_Kick _IOR('p', 0x0A, int)
  126. #define AEEIOCTL_SET_FORECE_RED_SCREEN _IOR('p', 0x0B, int)
  127. #define AEEIOCTL_SET_SF_STATE _IOR('p', 0x0C, long long)
  128. #define AEEIOCTL_GET_SF_STATE _IOW('p', 0x0D, long long)
  129. #define AEEIOCTL_USER_IOCTL_TO_KERNEL_WANING _IOR('p', 0x0E, int)
  130. #define AED_FILE_OPS(entry) \
  131. static const struct file_operations proc_##entry##_fops = { \
  132. .read = proc_##entry##_read, \
  133. .write = proc_##entry##_write, \
  134. }
  135. #define AED_FILE_OPS_RO(entry) \
  136. static const struct file_operations proc_##entry##_fops = { \
  137. .read = proc_##entry##_read, \
  138. }
  139. #define AED_PROC_ENTRY(name, entry, mode)\
  140. ({if (!proc_create(#name, S_IFREG | mode, aed_proc_dir, &proc_##entry##_fops)) \
  141. LOGE("proc_create %s failed\n", #name); })
  142. struct proc_dir_entry;
  143. int aed_proc_debug_init(struct proc_dir_entry *aed_proc_dir);
  144. int aed_proc_debug_done(struct proc_dir_entry *aed_proc_dir);
  145. int aed_get_process_bt(struct aee_process_bt *bt);
  146. void aee_rr_proc_init(struct proc_dir_entry *aed_proc_dir);
  147. void aee_rr_proc_done(struct proc_dir_entry *aed_proc_dir);
  148. void dram_console_init(struct proc_dir_entry *aed_proc_dir);
  149. void dram_console_done(struct proc_dir_entry *aed_proc_dir);
  150. struct aee_oops *ipanic_oops_copy(void);
  151. void ipanic_oops_free(struct aee_oops *oops, int erase);
  152. extern struct atomic_notifier_head panic_notifier_list;
  153. extern int ksysfs_bootinfo_init(void);
  154. extern void ksysfs_bootinfo_exit(void);
  155. extern int aee_dump_ccci_debug_info(int md_id, void **addr, int *size);
  156. extern void show_stack(struct task_struct *tsk, unsigned long *sp);
  157. extern int aee_mode;
  158. extern void aee_kernel_RT_Monitor_api(int lParam);
  159. #endif