53 #define GET_CH_KERNEL_MAJOR(coded_version) ((coded_version >> 11) & 0x1f)
54 #define GET_CH_KERNEL_MINOR(coded_version) ((coded_version >> 6) & 0x1f)
55 #define GET_CH_KERNEL_PATCH(coded_version) ((coded_version >> 0) & 0x3f)
61 "WTSTART",
"SUSPENDED",
"QUEUED",
"WTSEM",
"WTMTX",
"WTCOND",
"SLEEPING",
62 "WTEXIT",
"WTOREVT",
"WTANDEVT",
"SNDMSGQ",
"SNDMSG",
"WTMSG",
"FINAL"
65 #define CHIBIOS_NUM_STATES ARRAY_SIZE(chibios_thread_states)
70 #define CHIBIOS_THREAD_NAME_STR_SIZE (64)
96 struct rtos_reg **reg_list,
int *num_regs);
124 {
"ch_debug", 0,
false},
129 #define CH_RLIST_OFFSET 0x00
145 LOG_ERROR(
"Could not allocate space for ChibiOS/RT memory signature");
154 LOG_ERROR(
"Could not read ChibiOS/RT memory signature from target");
159 LOG_ERROR(
"Memory signature identifier does not contain magic bytes.");
164 LOG_ERROR(
"ChibiOS/RT memory signature claims to be smaller "
170 LOG_WARNING(
"ChibiOS/RT memory signature claims to be bigger than"
171 " expected. Assuming compatibility...");
175 LOG_INFO(
"Successfully loaded memory map of ChibiOS/RT target "
182 LOG_ERROR(
"ChibiOS/RT target memory signature claims an address "
183 "width unequal to 32 bits!");
229 if (armv7m_target->fp_feature !=
FP_NONE) {
235 LOG_ERROR(
"Could not read CPACR register to check FPU state");
241 if (cpacr & 0x00F00000) {
276 LOG_ERROR(
"Reading the memory signature of ChibiOS/RT failed");
301 LOG_ERROR(
"Could not read next ChibiOS thread");
307 LOG_ERROR(
"ChibiOS registry integrity check failed, NULL pointer");
315 if ((retval !=
ERROR_OK) || (older == 0) || (older != previous)) {
316 LOG_ERROR(
"ChibiOS registry integrity check failed, "
317 "double linked list violation");
322 if (current == rlist)
329 LOG_INFO(
"Only showing current execution because of a broken "
330 "ChibiOS thread registry.");
332 const char tmp_thread_name[] =
"Current Execution";
333 const char tmp_thread_extra_info[] =
"No RTOS thread";
341 sizeof(tmp_thread_extra_info));
345 sizeof(tmp_thread_name));
357 LOG_ERROR(
"Could not allocate space for thread details");
364 while (curr_thrd_details < rtos->thread_details + tasks_found) {
365 uint32_t name_ptr = 0;
371 LOG_ERROR(
"Could not read next ChibiOS thread");
376 if (current == rlist)
380 curr_thrd_details->
threadid = current;
386 LOG_ERROR(
"Could not read ChibiOS thread name pointer from target");
393 (uint8_t *)&tmp_str);
395 LOG_ERROR(
"Error reading thread name from ChibiOS target");
400 if (tmp_str[0] ==
'\x00')
401 strcpy(tmp_str,
"No Name");
404 strlen(tmp_str) + 1);
408 uint8_t thread_state;
409 const char *state_desc;
414 LOG_ERROR(
"Error reading thread state from ChibiOS target");
422 state_desc =
"Unknown";
426 sprintf(curr_thrd_details->
extra_info_str,
"State: %s", state_desc);
428 curr_thrd_details->
exists =
true;
433 uint32_t current_thrd;
439 LOG_ERROR(
"Could not read current Thread from ChibiOS target");
448 struct rtos_reg **reg_list,
int *num_regs)
452 uint32_t stack_ptr = 0;
454 if ((!
rtos) || (thread_id == 0) ||
474 LOG_ERROR(
"Error reading stack frame from ChibiOS thread");
499 LOG_INFO(
"It looks like the target may be running ChibiOS "
500 "without ch_debug.");
519 LOG_WARNING(
"Could not find target \"%s\" in ChibiOS compatibility "
static struct armv7m_common * target_to_armv7m(struct target *target)
static bool is_armv7m(const struct armv7m_common *armv7m)
#define GET_CH_KERNEL_MINOR(coded_version)
#define CHIBIOS_NUM_STATES
static int chibios_update_stacking(struct rtos *rtos)
static int chibios_create(struct target *target)
static int chibios_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[])
#define GET_CH_KERNEL_MAJOR(coded_version)
#define CHIBIOS_THREAD_NAME_STR_SIZE
static struct chibios_params chibios_params_list[]
static int chibios_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, struct rtos_reg **reg_list, int *num_regs)
static int chibios_update_threads(struct rtos *rtos)
static bool chibios_detect_rtos(struct target *target)
static const char *const chibios_thread_states[]
ChibiOS thread states.
#define GET_CH_KERNEL_PATCH(coded_version)
const struct rtos_type chibios_rtos
static int chibios_update_memory_signature(struct rtos *rtos)
static struct symbol_table_elem chibios_symbol_list[]
The JTAG interface can be implemented with a software or hardware fifo.
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
int rtos_generic_stack_read(struct target *target, const struct rtos_register_stacking *stacking, int64_t stack_ptr, struct rtos_reg **reg_list, int *num_regs)
void rtos_free_threadlist(struct rtos *rtos)
const struct rtos_register_stacking rtos_chibios_arm_v7m_stacking_w_fpu
const struct rtos_register_stacking rtos_chibios_arm_v7m_stacking
ChibiOS/RT memory signature record.
uint8_t cf_off_refs
Offset of p_refs field.
uint8_t ch_size
Size of this structure.
uint8_t cf_off_older
Offset of p_older field.
uint8_t ch_version[2]
Encoded ChibiOS/RT version.
uint8_t cf_off_flags
Offset of p_flags field.
uint8_t ch_threadsize
Size of a Thread struct.
uint8_t cf_off_name
Offset of p_name field.
uint8_t cf_off_prio
Offset of p_prio field.
uint8_t cf_off_ctx
Offset of p_ctx field.
uint8_t cf_off_stklimit
Offset of p_stklimit field.
uint8_t ch_zero
Must be zero.
uint8_t cf_off_time
Offset of p_time field.
char ch_identifier[4]
Always set to "main".
uint8_t cf_off_newer
Offset of p_newer field.
uint8_t cf_off_preempt
Offset of p_preempt field.
uint8_t ch_ptrsize
Size of a pointer.
uint8_t ch_timesize
Size of a systime_t.
uint8_t cf_off_state
Offset of p_state field.
struct chibios_chdebug * signature
const struct rtos_register_stacking * stacking_info
struct thread_detail * thread_details
struct symbol_table_elem * symbols
void * rtos_specific_params
threadid_t current_thread
Table should be terminated by an element with NULL in symbol_name.
int target_read_buffer(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
int target_read_u8(struct target *target, target_addr_t address, uint8_t *value)
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
uint16_t target_buffer_get_u16(struct target *target, const uint8_t *buffer)
const char * target_type_name(const struct target *target)
Get the target type name.
static const char * target_name(const struct target *target)
Returns the instance-specific name of the specified target.
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.