65 #define GET_CH_KERNEL_MAJOR(codedVersion) ((codedVersion >> 11) & 0x1f) 66 #define GET_CH_KERNEL_MINOR(codedVersion) ((codedVersion >> 6) & 0x1f) 67 #define GET_CH_KERNEL_PATCH(codedVersion) ((codedVersion >> 0) & 0x3f) 73 "READY",
"CURRENT",
"SUSPENDED",
"WTSEM",
"WTMTX",
"WTCOND",
"SLEEPING",
74 "WTEXIT",
"WTOREVT",
"WTANDEVT",
"SNDMSGQ",
"SNDMSG",
"WTMSG",
"WTQUEUE",
78 #define CHIBIOS_NUM_STATES (sizeof(ChibiOS_thread_states)/sizeof(char *)) 83 #define CHIBIOS_THREAD_NAME_STR_SIZE (64) 104 #define CHIBIOS_NUM_PARAMS ((int)(sizeof(ChibiOS_params_list)/sizeof(struct ChibiOS_params))) 137 {
"ch_debug", 0,
false},
142 #define CH_RLIST_OFFSET 0x00 158 signature = malloc(
sizeof(*signature));
160 LOG_ERROR(
"Could not allocate space for ChibiOS/RT memory signature");
167 (uint8_t *) signature);
169 LOG_ERROR(
"Could not read ChibiOS/RT memory signature from target");
174 LOG_ERROR(
"Memory signature identifier does not contain magic bytes.");
178 if (signature->
ch_size <
sizeof(*signature)) {
179 LOG_ERROR(
"ChibiOS/RT memory signature claims to be smaller " 184 if (signature->
ch_size >
sizeof(*signature)) {
185 LOG_WARNING(
"ChibiOS/RT memory signature claims to be bigger than" 186 " expected. Assuming compatibility...");
190 const uint8_t *versionTarget = (
const uint8_t *)
196 LOG_INFO(
"Successfully loaded memory map of ChibiOS/RT target " 202 if (signature->
ch_ptrsize !=
sizeof(uint32_t)) {
203 LOG_ERROR(
"ChibiOS/RT target memory signature claims an address" 204 "width unequal to 32 bits!");
250 if (armv7m_target->fp_feature ==
FPv4_SP) {
256 LOG_ERROR(
"Could not read CPACR register to check FPU state");
262 if (cpacr & 0x00F00000) {
297 LOG_ERROR(
"Reading the memory signature of ChibiOS/RT failed");
322 LOG_ERROR(
"Could not read next ChibiOS thread");
328 LOG_ERROR(
"ChibiOS registry integrity check failed, NULL pointer");
336 if ((retval !=
ERROR_OK) || (older == 0) || (older != previous)) {
337 LOG_ERROR(
"ChibiOS registry integrity check failed, " 338 "double linked list violation");
343 if (current == rlist)
350 LOG_INFO(
"Only showing current execution because of a broken " 351 "ChibiOS thread registry.");
353 const char tmp_thread_name[] =
"Current Execution";
354 const char tmp_thread_extra_info[] =
"No RTOS thread";
362 sizeof(tmp_thread_extra_info));
366 sizeof(tmp_thread_name));
378 LOG_ERROR(
"Could not allocate space for thread details");
385 while (curr_thrd_details < rtos->thread_details + tasks_found) {
386 uint32_t name_ptr = 0;
392 LOG_ERROR(
"Could not read next ChibiOS thread");
397 if (current == rlist)
401 curr_thrd_details->
threadid = current;
407 LOG_ERROR(
"Could not read ChibiOS thread name pointer from target");
414 (uint8_t *)&tmp_str);
416 LOG_ERROR(
"Error reading thread name from ChibiOS target");
421 if (tmp_str[0] ==
'\x00')
422 strcpy(tmp_str,
"No Name");
425 strlen(tmp_str) + 1);
430 const char *state_desc;
435 LOG_ERROR(
"Error reading thread state from ChibiOS target");
443 state_desc =
"Unknown";
447 sprintf(curr_thrd_details->
extra_info_str,
"State: %s", state_desc);
449 curr_thrd_details->
exists =
true;
454 uint32_t current_thrd;
460 LOG_ERROR(
"Could not read current Thread from ChibiOS target");
472 uint32_t stack_ptr = 0;
474 *hex_reg_list =
NULL;
475 if ((rtos ==
NULL) || (thread_id == 0) ||
495 LOG_ERROR(
"Error reading stack frame from ChibiOS thread");
504 *symbol_list = malloc(
sizeof(ChibiOS_symbol_list));
506 if (*symbol_list ==
NULL)
509 memcpy(*symbol_list, ChibiOS_symbol_list,
sizeof(ChibiOS_symbol_list));
520 LOG_INFO(
"It looks like the target may be running ChibiOS " 521 "without ch_debug.");
540 LOG_WARNING(
"Could not find target \"%s\" in ChibiOS compatibility "
static struct armv7m_common * target_to_armv7m(struct target *target)
uint8_t cf_off_name
Offset of p_name field.
int target_read_buffer(struct target *target, uint32_t address, uint32_t size, uint8_t *buffer)
#define LOG_DEBUG(expr...)
uint8_t cf_off_refs
Offset of p_refs field.
uint8_t cf_off_prio
Offset of p_prio field.
#define CHIBIOS_NUM_PARAMS
const char * name
Name of this type of target.
static int ChibiOS_update_memory_signature(struct rtos *rtos)
#define LOG_INFO(expr...)
static uint32_t le_to_h_u32(const uint8_t *buf)
uint8_t ch_size
Size of this structure.
static uint32_t be_to_h_u32(const uint8_t *buf)
static int ChibiOS_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, char **hex_reg_list)
static int ChibiOS_update_stacking(struct rtos *rtos)
static int ChibiOS_update_threads(struct rtos *rtos)
const struct rtos_register_stacking * stacking_info
uint8_t cf_off_time
Offset of p_time field.
uint8_t ch_timesize
Size of a systime_t.
char ch_identifier[4]
Always set to "main".
void rtos_free_threadlist(struct rtos *rtos)
uint8_t cf_off_newer
Offset of p_newer field.
static bool is_armv7m(struct armv7m_common *armv7m)
#define GET_CH_KERNEL_MAJOR(codedVersion)
enum target_endianness endianness
static symbol_table_elem_t ChibiOS_symbol_list[]
int target_read_u32(struct target *target, uint32_t address, uint32_t *value)
Table should be terminated by an element with NULL in symbol_name.
threadid_t current_thread
#define LOG_ERROR(expr...)
static const char * target_name(struct target *target)
Returns the instance-specific name of the specified target.
uint16_t ch_version
Encoded ChibiOS/RT version.
int target_read_u8(struct target *target, uint32_t address, uint8_t *value)
static int ChibiOS_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[])
symbol_table_elem_t * symbols
static struct ChibiOS_params ChibiOS_params_list[]
int rtos_generic_stack_read(struct target *target, const struct rtos_register_stacking *stacking, int64_t stack_ptr, char **hex_reg_list)
static int ChibiOS_detect_rtos(struct target *target)
#define GET_CH_KERNEL_PATCH(codedVersion)
ChibiOS/RT memory signature record.
uint8_t cf_off_stklimit
Offset of p_stklimit field.
struct ChibiOS_chdebug * signature
uint8_t cf_off_ctx
Offset of p_ctx field.
#define CHIBIOS_THREAD_NAME_STR_SIZE
static const char *const ChibiOS_thread_states[]
ChibiOS thread states.
struct target_type * type
void * rtos_specific_params
#define GET_CH_KERNEL_MINOR(codedVersion)
uint8_t cf_off_preempt
Offset of p_preempt field.
const struct rtos_register_stacking rtos_chibios_arm_v7m_stacking_w_fpu
static struct aice_port_param_s param
uint8_t ch_zero
Must be zero.
The JTAG interface can be implemented with a software or hardware fifo.
static int ChibiOS_create(struct target *target)
struct thread_detail * thread_details
const struct rtos_register_stacking rtos_chibios_arm_v7m_stacking
uint8_t ch_ptrsize
Size of a pointer.
uint8_t cf_off_state
Offset of p_state field.
uint8_t cf_off_flags
Offset of p_flags field.
uint8_t ch_threadsize
Size of a Thread struct.
#define CHIBIOS_NUM_STATES
uint8_t cf_off_older
Offset of p_older field.
#define LOG_WARNING(expr...)
struct rtos_type ChibiOS_rtos