-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathcoredump.h
More file actions
171 lines (155 loc) · 5.02 KB
/
coredump.h
File metadata and controls
171 lines (155 loc) · 5.02 KB
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
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
/*
* Copyright 2024 Morse Micro
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <linux/types.h>
#define MORSE_COREDUMP_FILE_VERSION (1)
/* List of available methods to generate a coredump */
enum morse_coredump_method {
/* Method for coredump is to call out to an external userspace script */
COREDUMP_METHOD_USERSPACE_SCRIPT = 0,
/* Use the system bus (e.g. SDIO, SPI, etc) to read mem regions on chip */
COREDUMP_METHOD_BUS = 1,
};
/* Describe the type of a memory region */
enum morse_coredump_mem_region_type {
/* no specific distinction made on memory region */
MORSE_MEM_REGION_TYPE_GENERAL = 1,
/* Assertion information */
MORSE_MEM_REGION_TYPE_ASSERT_INFO = 2,
};
/* Describe an on-chip memory region */
struct morse_coredump_mem_region {
struct list_head list;
/* memory region type */
enum morse_coredump_mem_region_type type;
/* start address of memory region */
u32 start;
/* length of memory region */
u32 len;
};
enum morse_coredump_reason {
/* unknown reason / reset state */
MORSE_COREDUMP_REASON_UNKNOWN = 0,
/* the health-check command failed */
MORSE_COREDUMP_REASON_HEALTH_CHECK_FAILED = 1,
/* user requested a coredump (vendor command) */
MORSE_COREDUMP_REASON_USER_REQUEST = 2,
/* chip has notified host of stop */
MORSE_COREDUMP_REASON_CHIP_INDICATED_STOP = 3,
};
/* Describe note types when parsing notes in a morse coredump file
* Note; Note type enum starts at a high number to avoid overlap with
* standard/upstream elf note types.
*/
enum morse_coredump_note_type {
/* Intepret note data as a u32 */
MORSE_COREDUMP_NOTE_TYPE_U32 = 0x900,
/* Intepret note data as a u64 */
MORSE_COREDUMP_NOTE_TYPE_U64 = 0x901,
/* Intepret note data as an ascii str */
MORSE_COREDUMP_NOTE_TYPE_STR = 0x902,
/* Intepret note data as a u8 array */
MORSE_COREDUMP_NOTE_TYPE_BIN = 0x903,
};
/* Contains data to later create a coredump. It can contain
* memory descriptors (filled from metadata provided in fw binary)
* and data (upon coredump).
*/
struct morse_coredump_data {
/* Reason for coredump creation */
enum morse_coredump_reason reason;
/* Stop information string (may be NULL if not available) */
char *information;
/* system timestamp of when the data was filled */
struct timespec64 timestamp;
/* chip-memory regions of interest upon a coredump */
struct {
/* dynamically allocated to store memory region info / contents */
struct list_head regions;
} memory;
};
/**
* morse_coredump_destroy() - Destroy any dynamically allocated memory for
* coredump creation.
*
* @mors: Morse chip object
*/
void morse_coredump_destroy(struct morse *mors);
/**
* morse_coredump_new() - Initialise a new coredump with a reason code.
* The driver will typically schedule restart work
* after this is called, eventually invoking
* morse_coredump().
*
* @mors: Morse chip object
* @reason: Reason for coredump
*
* return 0 on success
*/
int morse_coredump_new(struct morse *mors, enum morse_coredump_reason reason);
/**
* morse_coredump() - Generate a morse coredump file.
*
* @mors: Morse chip object
*
* return 0 on success
*/
int morse_coredump(struct morse *mors);
/**
* morse_coredump_add_memory_region() - Add the provided memory region descriptor
* to the list of on-chip memory regions to
* read on a coredump.
*
* @mors: Morse chip object
* @desc: Memory region descriptor from the fw_info TLV
*
* return 0 on success
*/
int morse_coredump_add_memory_region(struct morse *mors,
const struct morse_fw_info_tlv_coredump_mem *desc);
/**
* morse_coredump_remove_memory_regions() - Remove all memory region descriptors
* for core-dumping.
*
* @mors: Morse chip object
*/
void morse_coredump_remove_memory_regions(struct morse *mors);
/**
* morse_coredump_set_fw_binary_str() - Store the name of fw binary used to
* initialise the chip.
*
* @mors: Morse chip object
* @str: The name of binary (or NULL to clear)
*/
void morse_coredump_set_fw_binary_str(struct morse *mors, const char *str);
/**
* morse_coredump_set_fw_version_str() - Store the name of fw version string
* stored int the chip.
*
* @mors: Morse chip object
* @str: The version string (or NULL to clear)
*/
void morse_coredump_set_fw_version_str(struct morse *mors, const char *str);
/**
* morse_coredump_reason_to_str() - Convert coredump reason to string
*
* @reason: Reason for failure
*
* return string representing failure
*/
static inline const char *morse_coredump_reason_to_str(enum morse_coredump_reason reason)
{
switch (reason) {
case MORSE_COREDUMP_REASON_HEALTH_CHECK_FAILED:
return "health check failure";
case MORSE_COREDUMP_REASON_USER_REQUEST:
return "user request";
case MORSE_COREDUMP_REASON_CHIP_INDICATED_STOP:
return "chip indicated stop";
default:
return "unknown";
}
}