blob: b61f8e52602f33a84b7d04ac3619349848dd50bc [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * Copyright (c) 2018 MediaTek Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files
6 * (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge,
8 * publish, distribute, sublicense, and/or sell copies of the Software,
9 * and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24#include <sys/types.h>
25
26#define AEE_IPANIC_PLABLE "expdb"
27
28
29#define AEE_IPANIC_MAGIC 0xaee0dead
30#define AEE_IPANIC_PHDR_VERSION 0x10
31#define IPANIC_NR_SECTIONS 64
32#if (AEE_IPANIC_PHDR_VERSION >= 0x10)
33#define IPANIC_USERSPACE_READ 1
34#endif
35
36/***************************************************************/
37/* #define MRDUMP_MINI_NR_SECTION 40 */
38/* #define MRDUMP_MINI_SECTION_SIZE (32 * 1024) */
39/* #define MRDUMP_MINI_NR_MISC 20 */
40/***************************************************************/
41
42struct mrdump_mini_misc_data32 {
43 unsigned int vaddr;
44 unsigned int paddr;
45 unsigned int start;
46 unsigned int size;
47};
48
49struct mrdump_mini_misc_data64 {
50 unsigned long long vaddr;
51 unsigned long long paddr;
52 unsigned long long start;
53 unsigned long long size;
54};
55
56/**********************************************/
57/* struct mrdump_mini_elf_misc { */
58/* struct elf_note note; */
59/* char name[16]; */
60/* struct mrdump_mini_misc_data data; */
61/* }; */
62/**********************************************/
63
64/**********************************************************/
65/* struct mrdump_mini_elf_header { */
66/* struct elfhdr ehdr; */
67/* struct elf_phdr phdrs[MRDUMP_MINI_NR_SECTION]; */
68/* struct { */
69/* struct elf_note note; */
70/* char name[12]; */
71/* struct elf_prpsinfo data; */
72/* } psinfo; */
73/* struct { */
74/* struct elf_note note; */
75/* char name[12]; */
76/* struct elf_prstatus data; */
77/* } prstatus[3]; */
78/* struct { */
79/* struct elf_note note; */
80/* char name[20]; */
81/* struct mrdump_mini_misc_data data; */
82/* } misc[MRDUMP_MINI_NR_MISC]; */
83/* }; */
84/**********************************************************/
85
86//#define PAGE_SIZE 4096
87/***********************************************************************************************************/
88/* #define MRDUMP_MINI_HEADER_SIZE ALIGN(sizeof(struct mrdump_mini_elf_header), PAGE_SIZE) */
89/* #define MRDUMP_MINI_DATA_SIZE (MRDUMP_MINI_NR_SECTION * MRDUMP_MINI_SECTION_SIZE) */
90/* #define MRDUMP_MINI_BUF_SIZE (MRDUMP_MINI_HEADER_SIZE + MRDUMP_MINI_DATA_SIZE) */
91/***********************************************************************************************************/
92
93// ipanic partation
94struct ipanic_data_header {
95 u32 type; /* data type(0-31) */
96 u32 valid; /* set to 1 when dump succeded */
97 u32 offset; /* offset in EXPDB partition */
98 u32 used; /* valid data size */
99 u32 total; /* allocated partition size */
100 u32 encrypt; /* data encrypted */
101 u32 raw; /* raw data or plain text */
102 u32 compact; /* data and header in same block, to save space */
103 u8 name[32];
104};
105
106struct ipanic_header {
107 u32 magic;
108 u32 version; /* ipanic version */
109 u32 size; /* ipanic_header size */
110 u32 datas; /* bitmap of data sections dumped */
111 u32 dhblk; /* data header blk size, 0 if no dup data headers */
112 u32 blksize;
113 u32 partsize; /* expdb partition totoal size */
114 u32 bufsize;
115 u64 buf;
116 struct ipanic_data_header data_hdr[IPANIC_NR_SECTIONS];
117};
118
119#define IPANIC_MMPROFILE_LIMIT 0x220000
120
121typedef enum {
122 IPANIC_DT_HEADER = 0 ,
123 IPANIC_DT_KERNEL_LOG = 1 ,
124 IPANIC_DT_WDT_LOG ,
125 IPANIC_DT_WQ_LOG ,
126 IPANIC_DT_CURRENT_TSK = 6 ,
127 IPANIC_DT_OOPS_LOG ,
128 IPANIC_DT_MINI_RDUMP = 8 ,
129 IPANIC_DT_MMPROFILE ,
130 IPANIC_DT_MAIN_LOG ,
131 IPANIC_DT_SYSTEM_LOG ,
132 IPANIC_DT_EVENTS_LOG ,
133 IPANIC_DT_RADIO_LOG ,
134 IPANIC_DT_LAST_LOG ,
135 IPANIC_DT_RAM_DUMP = 28 ,
136 IPANIC_DT_SHUTDOWN_LOG = 30 ,
137 IPANIC_DT_RESERVED31 = 31 ,
138} IPANIC_DT;
139
140int kedump_get_data_info(int index, char **name, u32 *offset, u32 *size);