Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
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/* Query ID */
12 /*
13 * Returns error code from backend.
14 */
16
17 /*
18 * Check if there is a stored coredump from backend.
19 *
20 * Returns 1 if there is a stored coredump.
21 * 0 if none.
22 * -ENOTSUP if this query is not supported.
23 * Otherwise, error code from backend.
24 */
26
28};
29
30/* Command ID */
32 /*
33 * Clear error code from backend.
34 *
35 * Returns 0 if successful, failed otherwise.
36 */
38
39 /*
40 * Verify that the stored coredump is valid.
41 *
42 * Returns 1 if valid.
43 * 0 if not valid or no stored coredump.
44 * -ENOTSUP if this command is not supported.
45 * Otherwise, error code from backend.
46 */
48
49 /*
50 * Erase the stored coredump.
51 *
52 * Returns 0 if successful.
53 * -ENOTSUP if this command is not supported.
54 * Otherwise, error code from backend.
55 */
57
59};
60
61#ifdef CONFIG_DEBUG_COREDUMP
62
63#include <toolchain.h>
64#include <arch/cpu.h>
65#include <sys/byteorder.h>
66
67#define COREDUMP_HDR_VER 1
68
69#define COREDUMP_ARCH_HDR_ID 'A'
70
71#define COREDUMP_MEM_HDR_ID 'M'
72#define COREDUMP_MEM_HDR_VER 1
73
74/* Target code */
75enum coredump_tgt_code {
76 COREDUMP_TGT_UNKNOWN = 0,
77 COREDUMP_TGT_X86,
78 COREDUMP_TGT_X86_64,
79 COREDUMP_TGT_ARM_CORTEX_M,
80};
81
82/* Coredump header */
83struct coredump_hdr_t {
84 /* 'Z', 'E' */
85 char id[2];
86
87 /* Header version */
88 uint16_t hdr_version;
89
90 /* Target code */
91 uint16_t tgt_code;
92
93 /* Pointer size in Log2 */
94 uint8_t ptr_size_bits;
95
97
98 /* Coredump Reason given */
99 unsigned int reason;
100} __packed;
101
102/* Architecture-specific block header */
103struct coredump_arch_hdr_t {
104 /* COREDUMP_ARCH_HDR_ID */
105 char id;
106
107 /* Header version */
108 uint16_t hdr_version;
109
110 /* Number of bytes in this block (excluding header) */
111 uint16_t num_bytes;
112} __packed;
113
114/* Memory block header */
115struct coredump_mem_hdr_t {
116 /* COREDUMP_MEM_HDR_ID */
117 char id;
118
119 /* Header version */
120 uint16_t hdr_version;
121
122 /* Address of start of memory region */
123 uintptr_t start;
124
125 /* Address of end of memory region */
126 uintptr_t end;
127} __packed;
128
129void coredump(unsigned int reason, const z_arch_esf_t *esf,
130 struct k_thread *thread);
131void coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr);
132void coredump_buffer_output(uint8_t *buf, size_t buflen);
133
134int coredump_query(enum coredump_query_id query_id, void *arg);
135int coredump_cmd(enum coredump_cmd_id cmd_id, void *arg);
136
137#else
138
139void coredump(unsigned int reason, const z_arch_esf_t *esf,
140 struct k_thread *thread)
141{
142}
143
144void coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr)
145{
146}
147
148void coredump_buffer_output(uint8_t *buf, size_t buflen)
149{
150}
151
152int coredump_query(enum coredump_query_id query_id, void *arg)
153{
154 return -ENOTSUP;
155}
156
157int coredump_cmd(enum coredump_cmd_id query_id, void *arg)
158{
159 return -ENOTSUP;
160}
161
162#endif /* CONFIG_DEBUG_COREDUMP */
163
231#endif /* ZEPHYR_INCLUDE_DEBUG_COREDUMP_H_ */
static struct k_thread thread[2]
Definition: atomic.c:22
Byte order helpers.
coredump_query_id
Definition: coredump.h:11
@ COREDUMP_QUERY_HAS_STORED_DUMP
Definition: coredump.h:25
@ COREDUMP_QUERY_MAX
Definition: coredump.h:27
@ COREDUMP_QUERY_GET_ERROR
Definition: coredump.h:15
coredump_cmd_id
Definition: coredump.h:31
@ COREDUMP_CMD_MAX
Definition: coredump.h:58
@ COREDUMP_CMD_ERASE_STORED_DUMP
Definition: coredump.h:56
@ COREDUMP_CMD_VERIFY_STORED_DUMP
Definition: coredump.h:47
@ COREDUMP_CMD_CLEAR_ERROR
Definition: coredump.h:37
void coredump_buffer_output(uint8_t *buf, size_t buflen)
Output the buffer via coredump.
Definition: coredump.h:148
void coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr)
Dump memory region.
Definition: coredump.h:144
int coredump_cmd(enum coredump_cmd_id query_id, void *arg)
Perform command on coredump subsystem.
Definition: coredump.h:157
void coredump(unsigned int reason, const z_arch_esf_t *esf, struct k_thread *thread)
Perform coredump.
Definition: coredump.h:139
int coredump_query(enum coredump_query_id query_id, void *arg)
Perform query on coredump subsystem.
Definition: coredump.h:152
#define ENOTSUP
Definition: errno.h:115
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
__UINTPTR_TYPE__ uintptr_t
Definition: stdint.h:75
__UINT16_TYPE__ uint16_t
Definition: stdint.h:59
Definition: thread.h:201
static uint32_t flag[3]
Definition: thread_competition.c:23
Macros to abstract toolchain specific capabilities.