26 #define UNIMPLEMENTED 0xFFFFFFFFU
29 #define ARC_AUX_SEC_BUILD_REG 0xdb
30 #define ARC_REG_NUM 38
33 #define ARM_XPSR_OFFSET 28
74 struct rtos_reg *callee_saved_reg_list,
75 struct rtos_reg **reg_list,
int *num_regs);
110 .stack_growth_direction = -1,
117 .stack_growth_direction = -1,
193 const uint8_t *stack_data,
202 .stack_growth_direction = -1,
210 .stack_growth_direction = -1,
220 .stack_growth_direction = -1,
228 struct rtos_reg *callee_saved_reg_list,
229 struct rtos_reg **reg_list,
int *num_regs)
232 uint32_t real_stack_addr;
234 int num_callee_saved_regs;
245 real_stack_addr, &callee_saved_reg_list,
246 &num_callee_saved_regs);
254 real_stack_addr + num_callee_saved_regs * 4,
259 for (
int i = 0; i < num_callee_saved_regs; i++)
260 buf_cpy(callee_saved_reg_list[i].value,
261 (*reg_list)[callee_saved_reg_list[i].
number].value,
262 callee_saved_reg_list[i].
size);
267 unsigned short blink_offset = 0, pc_offset = 0, sp_offset = 0;
277 if (blink_offset == 0 || sp_offset == 0 || pc_offset == 0) {
278 LOG_ERROR(
"Basic registers offsets are missing, check <arc_cpu_saved> struct");
283 buf_cpy((*reg_list)[blink_offset].value,
284 (*reg_list)[pc_offset].value,
sizeof((*reg_list)[blink_offset].value));
289 stack_top = real_stack_addr + num_callee_saved_regs * 4
291 buf_cpy(&stack_top, (*reg_list)[sp_offset].value,
sizeof(stack_top));
299 struct rtos_reg *callee_saved_reg_list,
300 struct rtos_reg **reg_list,
int *num_regs)
304 int num_callee_saved_regs;
309 *
addr, &callee_saved_reg_list,
310 &num_callee_saved_regs);
315 callee_saved_reg_list[0].
value);
327 for (
int i = 1; i < num_callee_saved_regs; i++)
328 buf_cpy(callee_saved_reg_list[i].value,
329 (*reg_list)[callee_saved_reg_list[i].
number].value,
330 callee_saved_reg_list[i].
size);
344 .target_name =
"cortex_r4",
352 .target_name =
"hla_target",
361 .target_name =
"arcv2",
378 .symbol_name =
"_kernel_thread_info_offsets",
382 .symbol_name =
"_kernel_thread_info_size_t_size",
386 .symbol_name =
"_kernel_thread_info_num_offsets",
397 LOG_INFO(
"Zephyr: no symbols while detecting RTOS");
403 LOG_INFO(
"Zephyr: does it have symbol %d (%s)?", symbol,
412 LOG_INFO(
"Zephyr: all mandatory symbols found");
430 if (!strcmp(
name,
"arcv2")) {
436 LOG_DEBUG(
"ARC EM board has security subsystem, changing offsets");
446 if (!strcmp(p->target_name,
name)) {
447 LOG_INFO(
"Zephyr: target known, params at %p", p);
453 LOG_ERROR(
"Could not find target in Zephyr compatibility list");
492 void *ptr = array->
ptr;
549 thread->
name[0] =
'\0';
553 sizeof(thread->
name) - 1, (uint8_t *)thread->
name);
557 thread->
name[
sizeof(thread->
name) - 1] =
'\0';
560 LOG_DEBUG(
"Fetched thread%" PRIx32
": {entry@0x%" PRIx32
561 ", state=%" PRIu8
", useropts=%" PRIu8
", prio=%" PRId8
"}",
572 int64_t curr_id = -1;
579 LOG_ERROR(
"Could not fetch current thread pointer");
585 for (; curr; curr = thread.
next_ptr) {
608 curr_id = (int64_t)thread_array.
elements - 1;
624 td = thread_array.
ptr;
625 for (
size_t i = 0; i < thread_array.
elements; i++) {
651 LOG_ERROR(
"Can't obtain kernel struct from Zephyr");
656 LOG_ERROR(
"Please build Zephyr with CONFIG_OPENOCD option set");
664 LOG_ERROR(
"Couldn't determine size of size_t from host");
669 LOG_ERROR(
"Only size_t of 4 bytes are supported");
678 LOG_ERROR(
"Couldn't not fetch number of offsets from Zephyr");
683 LOG_ERROR(
"Number of offsets too small");
691 LOG_ERROR(
"Couldn't not fetch offsets from Zephyr");
696 LOG_ERROR(
"Unexpected OpenOCD support version %" PRIu32,
721 LOG_ERROR(
"Could not fetch offsets from Zephyr");
726 LOG_DEBUG(
"Zephyr OpenOCD support version %" PRId32,
733 LOG_ERROR(
"Could not obtain current thread ID");
739 LOG_ERROR(
"Could not obtain thread list");
747 struct rtos_reg **reg_list,
int *num_regs)
754 LOG_INFO(
"Getting thread %" PRId64
" reg list", thread_id);
771 free(callee_saved_reg_list);
static struct arc_common * target_to_arc(struct target *target)
#define CHECK_RETVAL(action)
int arc_jtag_read_aux_reg_one(struct arc_jtag *jtag_info, uint32_t addr, uint32_t *value)
Wrapper function to ease reading of one AUX register.
void * buf_cpy(const void *from, void *_to, unsigned int size)
Copies size bits out of from and into to.
enum esirisc_reg_num number
The JTAG interface can be implemented with a software or hardware fifo.
char * alloc_printf(const char *format,...)
#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)
target_addr_t rtos_cortex_m_stack_align(struct target *target, const uint8_t *stack_data, const struct rtos_register_stacking *stacking, target_addr_t stack_ptr, size_t xpsr_offset)
target_addr_t addr
Start address to search for the control block.
size_t size
Size of the control block search area.
struct arc_jtag jtag_info
const struct stack_register_offset * register_offsets
unsigned char stack_registers_size
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 struct rtos_register_stacking * cpu_saved_nofp_stacking
uint32_t offsets[OFFSET_MAX]
const struct rtos_register_stacking * cpu_saved_fp_stacking
const struct rtos_register_stacking * callee_saved_stacking
int(* get_cpu_state)(struct rtos *rtos, target_addr_t *addr, struct zephyr_params *params, struct rtos_reg *callee_saved_reg_list, struct rtos_reg **reg_list, int *num_regs)
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)
uint32_t target_buffer_get_u32(struct target *target, const uint8_t *buffer)
const char * target_type_name(const struct target *target)
Get the target type name.
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
static int zephyr_get_symbol_list_to_lookup(struct symbol_table_elem **symbol_list)
static const struct rtos_register_stacking arm_cpu_saved_fp_stacking
static target_addr_t zephyr_cortex_m_stack_align(struct target *target, const uint8_t *stack_data, const struct rtos_register_stacking *stacking, target_addr_t stack_ptr)
static const struct stack_register_offset arc_callee_saved[]
static const struct stack_register_offset arm_callee_saved[]
static void * zephyr_array_detach_ptr(struct zephyr_array *array)
static int zephyr_fetch_thread(const struct rtos *rtos, struct zephyr_thread *thread, uint32_t ptr)
static const struct rtos_register_stacking arm_cpu_saved_nofp_stacking
static int zephyr_create(struct target *target)
static int zephyr_get_arm_state(struct rtos *rtos, target_addr_t *addr, struct zephyr_params *params, struct rtos_reg *callee_saved_reg_list, struct rtos_reg **reg_list, int *num_regs)
static void zephyr_array_free(struct zephyr_array *array)
static void * zephyr_array_append(struct zephyr_array *array, size_t size)
static const struct rtos_register_stacking arm_callee_saved_stacking
const struct rtos_type zephyr_rtos
static int zephyr_fetch_thread_list(struct rtos *rtos, uint32_t current_thread)
static void zephyr_array_init(struct zephyr_array *array)
#define ARC_AUX_SEC_BUILD_REG
static const struct symbol_table_elem zephyr_symbol_list[]
static int zephyr_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, struct rtos_reg **reg_list, int *num_regs)
static struct zephyr_params zephyr_params_list[]
static struct stack_register_offset arc_cpu_saved[]
@ OFFSET_T_ARM_EXC_RETURN
static int zephyr_update_threads(struct rtos *rtos)
@ ZEPHYR_VAL__KERNEL_OPENOCD_SIZE_T_SIZE
@ ZEPHYR_VAL__KERNEL_OPENOCD_OFFSETS
@ ZEPHYR_VAL__KERNEL_OPENOCD_NUM_OFFSETS
static const struct rtos_register_stacking arc_callee_saved_stacking
static int zephyr_get_arc_state(struct rtos *rtos, target_addr_t *addr, struct zephyr_params *params, struct rtos_reg *callee_saved_reg_list, struct rtos_reg **reg_list, int *num_regs)
static bool zephyr_detect_rtos(struct target *target)
static struct rtos_register_stacking arc_cpu_saved_stacking
static const struct stack_register_offset arm_cpu_saved[]
static uint32_t zephyr_kptr(const struct rtos *rtos, enum zephyr_offsets off)