Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 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 | /*
* Copyright (c) 2020 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_DEBUG_COREDUMP_H_
#define ZEPHYR_INCLUDE_DEBUG_COREDUMP_H_
#ifdef CONFIG_DEBUG_COREDUMP
#include <toolchain.h>
#include <arch/cpu.h>
#include <sys/byteorder.h>
#define Z_COREDUMP_HDR_VER 1
#define Z_COREDUMP_ARCH_HDR_ID 'A'
#define Z_COREDUMP_MEM_HDR_ID 'M'
#define Z_COREDUMP_MEM_HDR_VER 1
/* Target code */
enum z_coredump_tgt_code {
COREDUMP_TGT_UNKNOWN = 0,
COREDUMP_TGT_X86,
COREDUMP_TGT_X86_64,
COREDUMP_TGT_ARM_CORTEX_M,
};
/* Coredump header */
struct z_coredump_hdr_t {
/* 'Z', 'E' */
char id[2];
/* Header version */
uint16_t hdr_version;
/* Target code */
uint16_t tgt_code;
/* Pointer size in Log2 */
uint8_t ptr_size_bits;
uint8_t flag;
/* Coredump Reason given */
unsigned int reason;
} __packed;
/* Architecture-specific block header */
struct z_coredump_arch_hdr_t {
/* Z_COREDUMP_ARCH_HDR_ID */
char id;
/* Header version */
uint16_t hdr_version;
/* Number of bytes in this block (excluding header) */
uint16_t num_bytes;
} __packed;
/* Memory block header */
struct z_coredump_mem_hdr_t {
/* Z_COREDUMP_MEM_HDR_ID */
char id;
/* Header version */
uint16_t hdr_version;
/* Address of start of memory region */
uintptr_t start;
/* Address of end of memory region */
uintptr_t end;
} __packed;
void z_coredump(unsigned int reason, const z_arch_esf_t *esf,
struct k_thread *thread);
void z_coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr);
int z_coredump_buffer_output(uint8_t *buf, size_t buflen);
#else
void z_coredump(unsigned int reason, const z_arch_esf_t *esf,
struct k_thread *thread)
{
}
void z_coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr)
{
}
int z_coredump_buffer_output(uint8_t *buf, size_t buflen)
{
return 0;
}
#endif /* CONFIG_DEBUG_COREDUMP */
/**
* @defgroup coredump_apis Coredump APIs
* @brief Coredump APIs
* @{
*/
/**
* @fn void z_coredump(unsigned int reason, const z_arch_esf_t *esf, struct k_thread *thread);
* @brief Perform coredump.
*
* Normally, this is called inside z_fatal_error() to generate coredump
* when a fatal error is encountered. This can also be called on demand
* whenever a coredump is desired.
*
* @param reason Reason for the fatal error
* @param esf Exception context
* @param thread Thread information to dump
*/
/**
* @fn void z_coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr);
* @brief Dump memory region
*
* @param start_addr Start address of memory region to be dumped
* @param emd_addr End address of memory region to be dumped
*/
/**
* @fn int z_coredump_buffer_output(uint8_t *buf, size_t buflen);
* @brief Output the buffer via coredump
*
* This outputs the buffer of byte array to the coredump backend.
* For example, this can be called to output the coredump section
* containing registers, or a section for memory dump.
*
* @param buf Buffer to be send to coredump output
* @param buflen Buffer length
*/
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_DEBUG_COREDUMP_H_ */
|