23 #define FREERTOS_MAX_PRIORITIES 63
94 struct rtos_reg **reg_list,
int *num_regs);
128 {
"pxCurrentTCB",
false },
129 {
"pxReadyTasksLists",
false },
130 {
"xDelayedTaskList1",
false },
131 {
"xDelayedTaskList2",
false },
132 {
"pxDelayedTaskList",
false },
133 {
"pxOverflowDelayedTaskList",
false },
134 {
"xPendingReadyList",
false },
135 {
"xTasksWaitingTermination",
true },
136 {
"xSuspendedTaskList",
true },
137 {
"uxCurrentNumberOfTasks",
false },
138 {
"uxTopUsedPriority",
true },
139 {
"xSchedulerRunning",
false },
151 unsigned int tasks_found = 0;
165 LOG_ERROR(
"Don't have the number of threads in FreeRTOS");
169 uint32_t thread_list_size = 0;
173 LOG_DEBUG(
"FreeRTOS: Read uxCurrentNumberOfTasks at 0x%" PRIx64
", value %" PRIu32,
178 LOG_ERROR(
"Could not read FreeRTOS thread count from target");
186 uint32_t pointer_casts_are_bad;
189 &pointer_casts_are_bad);
191 LOG_ERROR(
"Error reading current thread in FreeRTOS thread list");
195 LOG_DEBUG(
"FreeRTOS: Read pxCurrentTCB at 0x%" PRIx64
", value 0x%" PRIx64,
200 uint32_t scheduler_running;
205 LOG_ERROR(
"Error reading FreeRTOS scheduler state");
208 LOG_DEBUG(
"FreeRTOS: Read xSchedulerRunning at 0x%" PRIx64
", value 0x%" PRIx32,
212 if ((thread_list_size == 0) || (
rtos->
current_thread == 0) || (scheduler_running != 1)) {
216 char tmp_str[] =
"Current Execution";
222 LOG_ERROR(
"Error allocating memory for %d threads", thread_list_size);
232 if (thread_list_size == 1) {
241 LOG_ERROR(
"Error allocating memory for %d threads", thread_list_size);
248 LOG_ERROR(
"FreeRTOS: uxTopUsedPriority is not defined, consult the OpenOCD manual for a work-around");
251 uint32_t top_used_priority = 0;
257 LOG_DEBUG(
"FreeRTOS: Read uxTopUsedPriority at 0x%" PRIx64
", value %" PRIu32,
261 LOG_ERROR(
"FreeRTOS top used priority is unreasonably big, not proceeding: %" PRIu32,
271 unsigned int config_max_priorities = top_used_priority + 1;
275 if (!list_of_lists) {
276 LOG_ERROR(
"Error allocating memory for %u priorities", config_max_priorities);
280 unsigned int num_lists;
281 for (num_lists = 0; num_lists < config_max_priorities; num_lists++)
283 num_lists *
param->list_width;
291 for (
unsigned int i = 0; i < num_lists; i++) {
292 if (list_of_lists[i] == 0)
296 uint32_t list_thread_count = 0;
301 LOG_ERROR(
"Error reading number of threads in FreeRTOS thread list");
305 LOG_DEBUG(
"FreeRTOS: Read thread count for list %u at 0x%" PRIx64
", value %" PRIu32,
306 i, list_of_lists[i], list_thread_count);
308 if (list_thread_count == 0)
312 uint32_t prev_list_elem_ptr = -1;
313 uint32_t list_elem_ptr = 0;
315 list_of_lists[i] +
param->list_next_offset,
318 LOG_ERROR(
"Error reading first thread item location in FreeRTOS thread list");
322 LOG_DEBUG(
"FreeRTOS: Read first item for list %u at 0x%" PRIx64
", value 0x%" PRIx32,
323 i, list_of_lists[i] +
param->list_next_offset, list_elem_ptr);
325 while ((list_thread_count > 0) && (list_elem_ptr != 0) &&
326 (list_elem_ptr != prev_list_elem_ptr) &&
327 (tasks_found < thread_list_size)) {
331 list_elem_ptr +
param->list_elem_content_offset,
332 &pointer_casts_are_bad);
334 LOG_ERROR(
"Error reading thread list item object in FreeRTOS thread list");
339 LOG_DEBUG(
"FreeRTOS: Read Thread ID at 0x%" PRIx32
", value 0x%" PRIx64,
340 list_elem_ptr +
param->list_elem_content_offset,
345 #define FREERTOS_THREAD_NAME_STR_SIZE (200)
352 (uint8_t *)&tmp_str);
354 LOG_ERROR(
"Error reading first thread item location in FreeRTOS thread list");
359 LOG_DEBUG(
"FreeRTOS: Read Thread Name at 0x%" PRIx64
", value '%s'",
363 if (tmp_str[0] ==
'\x00')
364 strcpy(tmp_str,
"No Name");
367 malloc(strlen(tmp_str)+1);
372 char running_str[] =
"State: Running";
374 sizeof(running_str));
383 prev_list_elem_ptr = list_elem_ptr;
386 prev_list_elem_ptr +
param->list_elem_next_offset,
389 LOG_ERROR(
"Error reading next thread item location in FreeRTOS thread list");
393 LOG_DEBUG(
"FreeRTOS: Read next thread location at 0x%" PRIx32
", value 0x%" PRIx32,
394 prev_list_elem_ptr +
param->list_elem_next_offset,
405 struct rtos_reg **reg_list,
int *num_regs)
409 int64_t stack_ptr = 0;
423 uint32_t pointer_casts_are_bad;
425 thread_id +
param->thread_stack_offset,
426 &pointer_casts_are_bad);
428 LOG_ERROR(
"Error reading stack frame from FreeRTOS thread");
431 stack_ptr = pointer_casts_are_bad;
432 LOG_DEBUG(
"FreeRTOS: Read stack pointer at 0x%" PRIx64
", value 0x%" PRIx64,
433 thread_id +
param->thread_stack_offset,
437 int cm4_fpu_enabled = 0;
447 LOG_ERROR(
"Could not read CPACR register to check FPU state");
452 if (cpacr & 0x00F00000) {
459 if (cm4_fpu_enabled == 1) {
466 LOG_OUTPUT(
"Error reading stack frame from FreeRTOS thread");
469 if ((lr_svc & 0x10) == 0)
480 *symbol_list = calloc(
519 thread_id +
param->thread_name_offset,
521 (uint8_t *)&tmp_str);
523 LOG_ERROR(
"Error reading first thread item location in FreeRTOS thread list");
528 if (tmp_str[0] ==
'\x00')
529 strcpy(tmp_str,
"No Name");
531 *
info = malloc(strlen(tmp_str)+1);
532 strcpy(*
info, tmp_str);
556 LOG_ERROR(
"Could not find target in FreeRTOS compatibility list");
static int freertos_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[])
#define FREERTOS_THREAD_NAME_STR_SIZE
struct rtos_type freertos_rtos
static int freertos_create(struct target *target)
static const struct freertos_params freertos_params_list[]
static bool freertos_detect_rtos(struct target *target)
static int freertos_update_threads(struct rtos *rtos)
static const struct symbols freertos_symbol_list[]
static int freertos_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, struct rtos_reg **reg_list, int *num_regs)
@ FREERTOS_VAL_X_PENDING_READY_LIST
@ FREERTOS_VAL_X_SUSPENDED_TASK_LIST
@ FREERTOS_VAL_X_SCHEDULER_RUNNING
@ FREERTOS_VAL_X_TASKS_WAITING_TERMINATION
@ FREERTOS_VAL_UX_TOP_USED_PRIORITY
@ FREERTOS_VAL_PX_DELAYED_TASK_LIST
@ FREERTOS_VAL_X_DELAYED_TASK_LIST1
@ FREERTOS_VAL_X_DELAYED_TASK_LIST2
@ FREERTOS_VAL_PX_CURRENT_TCB
@ FREERTOS_VAL_PX_READY_TASKS_LISTS
@ FREERTOS_VAL_PX_OVERFLOW_DELAYED_TASK_LIST
@ FREERTOS_VAL_UX_CURRENT_NUMBER_OF_TASKS
#define FREERTOS_MAX_PRIORITIES
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)
The JTAG interface can be implemented with a software or hardware fifo.
#define LOG_OUTPUT(expr ...)
#define LOG_ERROR(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_standard_cortex_m3_stacking
const struct rtos_register_stacking rtos_standard_cortex_m4f_fpu_stacking
const struct rtos_register_stacking rtos_standard_cortex_m4f_stacking
const struct rtos_register_stacking rtos_standard_nds32_n1068_stacking
const unsigned char list_next_offset
const unsigned char pointer_width
const unsigned char thread_name_offset
const struct rtos_register_stacking * stacking_info_cm3
const unsigned char thread_count_width
const unsigned char list_elem_content_offset
const unsigned char list_width
const unsigned char list_elem_next_offset
const struct rtos_register_stacking * stacking_info_cm4f_fpu
const struct rtos_register_stacking * stacking_info_cm4f
const unsigned char thread_stack_offset
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.
struct target_type * type
int target_read_buffer(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
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 struct ublast_lowlevel_priv info