54 #define GET_CH_KERNEL_MAJOR(coded_version) ((coded_version >> 11) & 0x1f)
55 #define GET_CH_KERNEL_MINOR(coded_version) ((coded_version >> 6) & 0x1f)
56 #define GET_CH_KERNEL_PATCH(coded_version) ((coded_version >> 0) & 0x3f)
62 "WTSTART",
"SUSPENDED",
"QUEUED",
"WTSEM",
"WTMTX",
"WTCOND",
"SLEEPING",
63 "WTEXIT",
"WTOREVT",
"WTANDEVT",
"SNDMSGQ",
"SNDMSG",
"WTMSG",
"FINAL"
66 #define CHIBIOS_NUM_STATES ARRAY_SIZE(chibios_thread_states)
71 #define CHIBIOS_THREAD_NAME_STR_SIZE (64)
97 struct rtos_reg **reg_list,
int *num_regs);
125 {
"ch_debug", 0,
false},
130 #define CH_RLIST_OFFSET 0x00
141 free(
param->signature);
146 LOG_ERROR(
"Could not allocate space for ChibiOS/RT memory signature");
155 LOG_ERROR(
"Could not read ChibiOS/RT memory signature from target");
160 LOG_ERROR(
"Memory signature identifier does not contain magic bytes.");
165 LOG_ERROR(
"ChibiOS/RT memory signature claims to be smaller "
171 LOG_WARNING(
"ChibiOS/RT memory signature claims to be bigger than"
172 " expected. Assuming compatibility...");
176 const uint8_t *versiontarget = (
const uint8_t *)
182 LOG_INFO(
"Successfully loaded memory map of ChibiOS/RT target "
189 LOG_ERROR(
"ChibiOS/RT target memory signature claims an address "
190 "width unequal to 32 bits!");
201 param->signature = 0;
236 if (armv7m_target->fp_feature !=
FP_NONE) {
242 LOG_ERROR(
"Could not read CPACR register to check FPU state");
248 if (cpacr & 0x00F00000) {
280 if (!
param->signature) {
283 LOG_ERROR(
"Reading the memory signature of ChibiOS/RT failed");
308 LOG_ERROR(
"Could not read next ChibiOS thread");
314 LOG_ERROR(
"ChibiOS registry integrity check failed, NULL pointer");
322 if ((retval !=
ERROR_OK) || (older == 0) || (older != previous)) {
323 LOG_ERROR(
"ChibiOS registry integrity check failed, "
324 "double linked list violation");
329 if (current == rlist)
336 LOG_INFO(
"Only showing current execution because of a broken "
337 "ChibiOS thread registry.");
339 const char tmp_thread_name[] =
"Current Execution";
340 const char tmp_thread_extra_info[] =
"No RTOS thread";
348 sizeof(tmp_thread_extra_info));
352 sizeof(tmp_thread_name));
364 LOG_ERROR(
"Could not allocate space for thread details");
371 while (curr_thrd_details < rtos->thread_details + tasks_found) {
372 uint32_t name_ptr = 0;
378 LOG_ERROR(
"Could not read next ChibiOS thread");
383 if (current == rlist)
387 curr_thrd_details->
threadid = current;
393 LOG_ERROR(
"Could not read ChibiOS thread name pointer from target");
400 (uint8_t *)&tmp_str);
402 LOG_ERROR(
"Error reading thread name from ChibiOS target");
407 if (tmp_str[0] ==
'\x00')
408 strcpy(tmp_str,
"No Name");
411 strlen(tmp_str) + 1);
415 uint8_t thread_state;
416 const char *state_desc;
421 LOG_ERROR(
"Error reading thread state from ChibiOS target");
429 state_desc =
"Unknown";
433 sprintf(curr_thrd_details->
extra_info_str,
"State: %s", state_desc);
435 curr_thrd_details->
exists =
true;
440 uint32_t current_thrd;
446 LOG_ERROR(
"Could not read current Thread from ChibiOS target");
455 struct rtos_reg **reg_list,
int *num_regs)
459 uint32_t stack_ptr = 0;
461 if ((!
rtos) || (thread_id == 0) ||
467 if (!
param->signature)
471 if ((
param->stacking_info == 0) &&
479 thread_id +
param->signature->cf_off_ctx, &stack_ptr);
481 LOG_ERROR(
"Error reading stack frame from ChibiOS thread");
506 LOG_INFO(
"It looks like the target may be running ChibiOS "
507 "without ch_debug.");
526 LOG_WARNING(
"Could not find target \"%s\" in ChibiOS compatibility "
static struct aice_port_param_s param
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)
struct rtos_type chibios_rtos
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)
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.
uint16_t ch_version
Encoded ChibiOS/RT version.
uint8_t ch_size
Size of this structure.
uint8_t cf_off_older
Offset of p_older field.
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.
const char * name
Name of this type of target.
enum target_endianness endianness
struct target_type * type
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)
static const char * target_name(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.
static uint32_t be_to_h_u32(const uint8_t *buf)
static uint32_t le_to_h_u32(const uint8_t *buf)