Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
coredump.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_DEBUG_COREDUMP_H_
8#define ZEPHYR_INCLUDE_DEBUG_COREDUMP_H_
9
10#include <stddef.h>
11#include <stdint.h>
12#include <sys/types.h>
13
14
31
41
49
54};
55
64
75
85
96
107
113
118
121
123 size_t length;
124};
125
126#ifdef CONFIG_DEBUG_COREDUMP
127
128#include <zephyr/toolchain.h>
129#include <zephyr/arch/cpu.h>
130#include <zephyr/sys/byteorder.h>
131
132#define COREDUMP_HDR_VER 1
133
134#define COREDUMP_ARCH_HDR_ID 'A'
135
136#define COREDUMP_MEM_HDR_ID 'M'
137#define COREDUMP_MEM_HDR_VER 1
138
139/* Target code */
140enum coredump_tgt_code {
141 COREDUMP_TGT_UNKNOWN = 0,
142 COREDUMP_TGT_X86,
143 COREDUMP_TGT_X86_64,
144 COREDUMP_TGT_ARM_CORTEX_M,
145 COREDUMP_TGT_RISC_V,
146 COREDUMP_TGT_XTENSA,
147 COREDUMP_TGT_ARM64,
148};
149
150/* Coredump header */
151struct coredump_hdr_t {
152 /* 'Z', 'E' */
153 char id[2];
154
155 /* Header version */
156 uint16_t hdr_version;
157
158 /* Target code */
159 uint16_t tgt_code;
160
161 /* Pointer size in Log2 */
162 uint8_t ptr_size_bits;
163
164 uint8_t flag;
165
166 /* Coredump Reason given */
167 unsigned int reason;
168} __packed;
169
170/* Architecture-specific block header */
171struct coredump_arch_hdr_t {
172 /* COREDUMP_ARCH_HDR_ID */
173 char id;
174
175 /* Header version */
176 uint16_t hdr_version;
177
178 /* Number of bytes in this block (excluding header) */
179 uint16_t num_bytes;
180} __packed;
181
182/* Memory block header */
183struct coredump_mem_hdr_t {
184 /* COREDUMP_MEM_HDR_ID */
185 char id;
186
187 /* Header version */
188 uint16_t hdr_version;
189
190 /* Address of start of memory region */
191 uintptr_t start;
192
193 /* Address of end of memory region */
194 uintptr_t end;
195} __packed;
196
197typedef void (*coredump_backend_start_t)(void);
198typedef void (*coredump_backend_end_t)(void);
199typedef void (*coredump_backend_buffer_output_t)(uint8_t *buf, size_t buflen);
200typedef int (*coredump_backend_query_t)(enum coredump_query_id query_id,
201 void *arg);
202typedef int (*coredump_backend_cmd_t)(enum coredump_cmd_id cmd_id,
203 void *arg);
204
205struct coredump_backend_api {
206 /* Signal to backend of the start of coredump. */
207 coredump_backend_start_t start;
208
209 /* Signal to backend of the end of coredump. */
210 coredump_backend_end_t end;
211
212 /* Raw buffer output */
213 coredump_backend_buffer_output_t buffer_output;
214
215 /* Perform query on backend */
216 coredump_backend_query_t query;
217
218 /* Perform command on backend */
219 coredump_backend_cmd_t cmd;
220};
221
222void coredump(unsigned int reason, const z_arch_esf_t *esf,
223 struct k_thread *thread);
224void coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr);
225void coredump_buffer_output(uint8_t *buf, size_t buflen);
226
227int coredump_query(enum coredump_query_id query_id, void *arg);
228int coredump_cmd(enum coredump_cmd_id cmd_id, void *arg);
229
230#else
231
232void coredump(unsigned int reason, const z_arch_esf_t *esf,
233 struct k_thread *thread)
234{
235 ARG_UNUSED(reason);
236 ARG_UNUSED(esf);
237 ARG_UNUSED(thread);
238}
239
240void coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr)
241{
242 ARG_UNUSED(start_addr);
243 ARG_UNUSED(end_addr);
244}
245
246void coredump_buffer_output(uint8_t *buf, size_t buflen)
247{
248 ARG_UNUSED(buf);
249 ARG_UNUSED(buflen);
250}
251
252int coredump_query(enum coredump_query_id query_id, void *arg)
253{
254 ARG_UNUSED(query_id);
255 ARG_UNUSED(arg);
256 return -ENOTSUP;
257}
258
259int coredump_cmd(enum coredump_cmd_id query_id, void *arg)
260{
261 ARG_UNUSED(query_id);
262 ARG_UNUSED(arg);
263 return -ENOTSUP;
264}
265
266#endif /* CONFIG_DEBUG_COREDUMP */
267
329#endif /* ZEPHYR_INCLUDE_DEBUG_COREDUMP_H_ */
void coredump_buffer_output(uint8_t *buf, size_t buflen)
Output the buffer via coredump.
Definition: coredump.h:246
coredump_query_id
Query ID.
Definition: coredump.h:26
coredump_cmd_id
Command ID.
Definition: coredump.h:57
void coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr)
Dump memory region.
Definition: coredump.h:240
int coredump_cmd(enum coredump_cmd_id query_id, void *arg)
Perform command on coredump subsystem.
Definition: coredump.h:259
void coredump(unsigned int reason, const z_arch_esf_t *esf, struct k_thread *thread)
Perform coredump.
Definition: coredump.h:232
int coredump_query(enum coredump_query_id query_id, void *arg)
Perform query on coredump subsystem.
Definition: coredump.h:252
@ COREDUMP_QUERY_HAS_STORED_DUMP
Check if there is a stored coredump from backend.
Definition: coredump.h:40
@ COREDUMP_QUERY_GET_STORED_DUMP_SIZE
Returns:
Definition: coredump.h:48
@ COREDUMP_QUERY_MAX
Max value for query ID.
Definition: coredump.h:53
@ COREDUMP_QUERY_GET_ERROR
Returns error code from backend.
Definition: coredump.h:30
@ COREDUMP_CMD_COPY_STORED_DUMP
Copy the raw stored coredump.
Definition: coredump.h:95
@ COREDUMP_CMD_MAX
Max value for command ID.
Definition: coredump.h:111
@ COREDUMP_CMD_INVALIDATE_STORED_DUMP
Invalidate the stored coredump.
Definition: coredump.h:106
@ COREDUMP_CMD_ERASE_STORED_DUMP
Erase the stored coredump.
Definition: coredump.h:84
@ COREDUMP_CMD_VERIFY_STORED_DUMP
Verify that the stored coredump is valid.
Definition: coredump.h:74
@ COREDUMP_CMD_CLEAR_ERROR
Clear error code from backend.
Definition: coredump.h:63
static void cmd(uint32_t command)
Execute a display list command by co-processor engine.
Definition: ft8xx_reference_api.h:153
#define ENOTSUP
Unsupported value.
Definition: errno.h:115
__INTPTR_TYPE__ off_t
Definition: types.h:36
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINTPTR_TYPE__ uintptr_t
Definition: stdint.h:105
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Coredump copy command (COREDUMP_CMD_COPY_STORED_DUMP) argument definition.
Definition: coredump.h:115
off_t offset
Copy offset.
Definition: coredump.h:117
uint8_t * buffer
Copy destination buffer.
Definition: coredump.h:120
size_t length
Copy length.
Definition: coredump.h:123
Thread Structure.
Definition: thread.h:259
Byte order helpers.
Macros to abstract toolchain specific capabilities.