import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / aee / ipanic / ipanic.h
CommitLineData
6fa3eb70
S
1#if !defined(__AEE_IPANIC_H__)
2#define __AEE_IPANIC_H__
3
4#include <generated/autoconf.h>
5#include <linux/kallsyms.h>
6#include <linux/kmsg_dump.h>
7/* #include "staging/android/logger.h" */
8#include <linux/aee.h>
9#include "ipanic_version.h"
10
11#define AEE_IPANIC_PLABEL "expdb"
12
13#define IPANIC_MODULE_TAG "KERNEL-PANIC"
14
15#define AEE_IPANIC_MAGIC 0xaee0dead
16#define AEE_IPANIC_PHDR_VERSION 0x10
17#define IPANIC_NR_SECTIONS 32
18#if (AEE_IPANIC_PHDR_VERSION >= 0x10)
19#define IPANIC_USERSPACE_READ 1
20#endif
21
22#define AEE_LOG_LEVEL 8
23#define LOG_DEBUG(fmt, ...) \
24 if (aee_in_nested_panic()) \
25 aee_nested_printf(fmt, ##__VA_ARGS__); \
26 else \
27 pr_debug(fmt, ##__VA_ARGS__)
28
29#define LOG_ERROR(fmt, ...) \
30 if (aee_in_nested_panic()) \
31 aee_nested_printf(fmt, ##__VA_ARGS__); \
32 else \
33 pr_err(fmt, ##__VA_ARGS__)
34
35#define LOGV(fmt, msg...)
36#define LOGD LOG_DEBUG
37#define LOGI LOG_DEBUG
38#define LOGW LOG_ERROR
39#define LOGE LOG_ERROR
40
41struct ipanic_data_header {
42 u32 type; /* data type(0-31) */
43 u32 valid; /* set to 1 when dump succeded */
44 u32 offset; /* offset in EXPDB partition */
45 u32 used; /* valid data size */
46 u32 total; /* allocated partition size */
47 u32 encrypt; /* data encrypted */
48 u32 raw; /* raw data or plain text */
49 u32 compact; /* data and header in same block, to save space */
50 u8 name[32];
51};
52
53struct ipanic_header {
54 /* The magic/version field cannot be moved or resize */
55 u32 magic;
56 u32 version; /* ipanic version */
57 u32 size; /* ipanic_header size */
58 u32 datas; /* bitmap of data sections dumped */
59 u32 dhblk; /* data header blk size, 0 if no dup data headers */
60 u32 blksize;
61 u32 partsize; /* expdb partition totoal size */
62 u32 bufsize;
63 u64 buf;
64 struct ipanic_data_header data_hdr[IPANIC_NR_SECTIONS];
65};
66
67#define IPANIC_MMPROFILE_LIMIT 0x220000
68
69struct ipanic_ops {
70
71 struct aee_oops *(*oops_copy) (void);
72
73 void (*oops_free) (struct aee_oops *oops, int erase);
74};
75
76void register_ipanic_ops(struct ipanic_ops *op);
77struct aee_oops *ipanic_oops_copy(void);
78void ipanic_oops_free(struct aee_oops *oops, int erase);
79void ipanic_block_scramble(u8 *buf, int buflen);
80/* for WDT timeout case : dump timer/schedule/irq/softirq etc... debug information */
81extern void aee_wdt_dump_info(void);
82extern int mt_dump_wq_debugger(void);
83void aee_disable_api(void);
84int panic_dump_android_log(char *buf, size_t size, int type);
85
86/* User space process support functions */
87#define MAX_NATIVEINFO 32*1024
88#define MAX_NATIVEHEAP 2048
89extern char NativeInfo[MAX_NATIVEINFO]; /* check that 32k is enought?? */
90extern unsigned long User_Stack[MAX_NATIVEHEAP]; /* 8K Heap */
91int DumpNativeInfo(void);
92/*
93* Since ipanic_detail and usersapce info size is not known
94* until run time, we do a guess here
95*/
96#define IPANIC_DETAIL_USERSPACE_SIZE (100 * 1024)
97
98#if 1
99#ifdef CONFIG_MTK_AEE_IPANIC_TYPES
100#define IPANIC_DT_DUMP CONFIG_MTK_AEE_IPANIC_TYPES
101#else
102#define IPANIC_DT_DUMP 0x0fffffff
103#endif
104#define IPANIC_DT_ENCRYPT 0xfffffffe
105
106typedef enum {
107 IPANIC_DT_HEADER = 0,
108 IPANIC_DT_KERNEL_LOG = 1,
109 IPANIC_DT_WDT_LOG,
110 IPANIC_DT_WQ_LOG,
111 IPANIC_DT_CURRENT_TSK = 6,
112 IPANIC_DT_OOPS_LOG,
113 IPANIC_DT_MINI_RDUMP = 8,
114 IPANIC_DT_MMPROFILE,
115 IPANIC_DT_MAIN_LOG,
116 IPANIC_DT_SYSTEM_LOG,
117 IPANIC_DT_EVENTS_LOG,
118 IPANIC_DT_RADIO_LOG,
119 IPANIC_DT_LAST_LOG,
120 IPANIC_DT_ATF_LOG,
121 IPANIC_DT_RAM_DUMP = 28,
122 IPANIC_DT_SHUTDOWN_LOG = 30,
123 IPANIC_DT_RESERVED31 = 31,
124} IPANIC_DT;
125
126struct ipanic_memory_block {
127 unsigned long kstart; /* start kernel addr of memory dump */
128 unsigned long kend; /* end kernel addr of memory dump */
129 unsigned long pos; /* next pos to dump */
130 unsigned long reserved; /* reserved */
131};
132
133typedef struct ipanic_dt_op {
134 char string[32];
135 int size;
136 int (*next) (void *data, unsigned char *buffer, size_t sz_buf);
137} ipanic_dt_op_t;
138
139typedef struct ipanic_atf_log_rec {
140 size_t total_size;
141 size_t has_read;
142 unsigned long start_idx;
143} ipanic_atf_log_rec_t;
144
145#define ipanic_dt_encrypt(x) ((IPANIC_DT_ENCRYPT >> x) & 1)
146#define ipanic_dt_active(x) ((IPANIC_DT_DUMP >> x) & 1)
147
148/* copy from kernel/drivers/staging/android/logger.h */
149/*
150 SMP porting, we double the android buffer
151* and kernel buffer size for dual core
152*/
153#ifdef CONFIG_SMP
154#ifndef __MAIN_BUF_SIZE
155#define __MAIN_BUF_SIZE 256*1024
156#endif
157
158#ifndef __EVENTS_BUF_SIZE
159#define __EVENTS_BUF_SIZE 256*1024
160#endif
161
162#ifndef __RADIO_BUF_SIZE
163#define __RADIO_BUF_SIZE 256*1024
164#endif
165
166#ifndef __SYSTEM_BUF_SIZE
167#define __SYSTEM_BUF_SIZE 256*1024
168#endif
169#else
170#ifndef __MAIN_BUF_SIZE
171#define __MAIN_BUF_SIZE 256*1024
172#endif
173
174#ifndef __EVENTS_BUF_SIZE
175#define __EVENTS_BUF_SIZE 256*1024
176#endif
177
178#ifndef __RADIO_BUF_SIZE
179#define __RADIO_BUF_SIZE 64*1024
180#endif
181
182#ifndef __SYSTEM_BUF_SIZE
183#define __SYSTEM_BUF_SIZE 64*1024
184#endif
185#endif
186
187#ifndef __LOG_BUF_LEN
188#define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)
189#endif
190
191#define OOPS_LOG_LEN __LOG_BUF_LEN
192#define WDT_LOG_LEN __LOG_BUF_LEN
193#define WQ_LOG_LEN 32*1024
194#define LAST_LOG_LEN (AEE_LOG_LEVEL == 8 ? __LOG_BUF_LEN : 32*1024)
195
196#define ATF_LOG_SIZE (32*1024)
197
198char *ipanic_read_size(int off, int len);
199int ipanic_write_size(void *buf, int off, int len);
200void ipanic_erase(void);
201struct ipanic_header *ipanic_header(void);
202void ipanic_msdc_init(void);
203int ipanic_msdc_info(struct ipanic_header *iheader);
204void ipanic_log_temp_init(void);
205void ipanic_klog_region(struct kmsg_dumper *dumper);
206int ipanic_klog_buffer(void *data, unsigned char *buffer, size_t sz_buf);
207extern int ipanic_atflog_buffer(void *data, unsigned char *buffer, size_t sz_buf);
208#endif
209#endif