This source file includes following definitions.
- pstore_ftrace_encode_cpu
- pstore_ftrace_decode_cpu
- pstore_ftrace_read_timestamp
- pstore_ftrace_write_timestamp
- pstore_ftrace_encode_cpu
- pstore_ftrace_decode_cpu
- pstore_ftrace_read_timestamp
- pstore_ftrace_write_timestamp
1
2
3
4
5
6
7
8
9
10 #ifndef _LINUX_PSTORE_H
11 #define _LINUX_PSTORE_H
12
13 #include <linux/compiler.h>
14 #include <linux/errno.h>
15 #include <linux/kmsg_dump.h>
16 #include <linux/mutex.h>
17 #include <linux/semaphore.h>
18 #include <linux/time.h>
19 #include <linux/types.h>
20
21 struct module;
22
23
24
25
26
27
28 enum pstore_type_id {
29
30 PSTORE_TYPE_DMESG = 0,
31 PSTORE_TYPE_MCE = 1,
32 PSTORE_TYPE_CONSOLE = 2,
33 PSTORE_TYPE_FTRACE = 3,
34
35
36 PSTORE_TYPE_PPC_RTAS = 4,
37 PSTORE_TYPE_PPC_OF = 5,
38 PSTORE_TYPE_PPC_COMMON = 6,
39 PSTORE_TYPE_PMSG = 7,
40 PSTORE_TYPE_PPC_OPAL = 8,
41
42
43 PSTORE_TYPE_MAX
44 };
45
46 const char *pstore_type_to_name(enum pstore_type_id type);
47 enum pstore_type_id pstore_name_to_type(const char *name);
48
49 struct pstore_info;
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 struct pstore_record {
70 struct pstore_info *psi;
71 enum pstore_type_id type;
72 u64 id;
73 struct timespec64 time;
74 char *buf;
75 ssize_t size;
76 ssize_t ecc_notice_size;
77
78 int count;
79 enum kmsg_dump_reason reason;
80 unsigned int part;
81 bool compressed;
82 };
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171 struct pstore_info {
172 struct module *owner;
173 char *name;
174
175 struct semaphore buf_lock;
176 char *buf;
177 size_t bufsize;
178
179 struct mutex read_mutex;
180
181 int flags;
182 void *data;
183
184 int (*open)(struct pstore_info *psi);
185 int (*close)(struct pstore_info *psi);
186 ssize_t (*read)(struct pstore_record *record);
187 int (*write)(struct pstore_record *record);
188 int (*write_user)(struct pstore_record *record,
189 const char __user *buf);
190 int (*erase)(struct pstore_record *record);
191 };
192
193
194 #define PSTORE_FLAGS_DMESG BIT(0)
195 #define PSTORE_FLAGS_CONSOLE BIT(1)
196 #define PSTORE_FLAGS_FTRACE BIT(2)
197 #define PSTORE_FLAGS_PMSG BIT(3)
198
199 extern int pstore_register(struct pstore_info *);
200 extern void pstore_unregister(struct pstore_info *);
201
202 struct pstore_ftrace_record {
203 unsigned long ip;
204 unsigned long parent_ip;
205 u64 ts;
206 };
207
208
209
210
211
212
213 #if NR_CPUS <= 2 && defined(CONFIG_ARM_THUMB)
214 #define PSTORE_CPU_IN_IP 0x1
215 #elif NR_CPUS <= 4 && defined(CONFIG_ARM)
216 #define PSTORE_CPU_IN_IP 0x3
217 #endif
218
219 #define TS_CPU_SHIFT 8
220 #define TS_CPU_MASK (BIT(TS_CPU_SHIFT) - 1)
221
222
223
224
225
226
227 #ifdef PSTORE_CPU_IN_IP
228 static inline void
229 pstore_ftrace_encode_cpu(struct pstore_ftrace_record *rec, unsigned int cpu)
230 {
231 rec->ip |= cpu;
232 }
233
234 static inline unsigned int
235 pstore_ftrace_decode_cpu(struct pstore_ftrace_record *rec)
236 {
237 return rec->ip & PSTORE_CPU_IN_IP;
238 }
239
240 static inline u64
241 pstore_ftrace_read_timestamp(struct pstore_ftrace_record *rec)
242 {
243 return rec->ts;
244 }
245
246 static inline void
247 pstore_ftrace_write_timestamp(struct pstore_ftrace_record *rec, u64 val)
248 {
249 rec->ts = val;
250 }
251 #else
252 static inline void
253 pstore_ftrace_encode_cpu(struct pstore_ftrace_record *rec, unsigned int cpu)
254 {
255 rec->ts &= ~(TS_CPU_MASK);
256 rec->ts |= cpu;
257 }
258
259 static inline unsigned int
260 pstore_ftrace_decode_cpu(struct pstore_ftrace_record *rec)
261 {
262 return rec->ts & TS_CPU_MASK;
263 }
264
265 static inline u64
266 pstore_ftrace_read_timestamp(struct pstore_ftrace_record *rec)
267 {
268 return rec->ts >> TS_CPU_SHIFT;
269 }
270
271 static inline void
272 pstore_ftrace_write_timestamp(struct pstore_ftrace_record *rec, u64 val)
273 {
274 rec->ts = (rec->ts & TS_CPU_MASK) | (val << TS_CPU_SHIFT);
275 }
276 #endif
277
278 #endif