OpenOCD
zephyr.c File Reference
Include dependency graph for zephyr.c:

Go to the source code of this file.

Data Structures

struct  zephyr_array
 
struct  zephyr_params
 
struct  zephyr_thread
 

Macros

#define ARC_AUX_SEC_BUILD_REG   0xdb
 
#define ARC_REG_NUM   38
 
#define ARM_XPSR_OFFSET   28
 
#define UNIMPLEMENTED   0xFFFFFFFFU
 

Enumerations

enum  zephyr_offsets {
  OFFSET_VERSION , OFFSET_K_CURR_THREAD , OFFSET_K_THREADS , OFFSET_T_ENTRY ,
  OFFSET_T_NEXT_THREAD , OFFSET_T_STATE , OFFSET_T_USER_OPTIONS , OFFSET_T_PRIO ,
  OFFSET_T_STACK_POINTER , OFFSET_T_NAME , OFFSET_T_ARCH , OFFSET_T_PREEMPT_FLOAT ,
  OFFSET_T_COOP_FLOAT , OFFSET_T_ARM_EXC_RETURN , OFFSET_MAX
}
 
enum  zephyr_symbol_values {
  ZEPHYR_VAL__KERNEL , ZEPHYR_VAL__KERNEL_OPENOCD_OFFSETS , ZEPHYR_VAL__KERNEL_OPENOCD_SIZE_T_SIZE , ZEPHYR_VAL__KERNEL_OPENOCD_NUM_OFFSETS ,
  ZEPHYR_VAL_COUNT
}
 

Functions

static void * zephyr_array_append (struct zephyr_array *array, size_t size)
 
static void * zephyr_array_detach_ptr (struct zephyr_array *array)
 
static void zephyr_array_free (struct zephyr_array *array)
 
static void zephyr_array_init (struct zephyr_array *array)
 
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 int zephyr_create (struct target *target)
 
static bool zephyr_detect_rtos (struct target *target)
 
static int zephyr_fetch_thread (const struct rtos *rtos, struct zephyr_thread *thread, uint32_t ptr)
 
static int zephyr_fetch_thread_list (struct rtos *rtos, uint32_t current_thread)
 
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 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 int zephyr_get_symbol_list_to_lookup (struct symbol_table_elem **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 uint32_t zephyr_kptr (const struct rtos *rtos, enum zephyr_offsets off)
 
static int zephyr_update_threads (struct rtos *rtos)
 

Variables

static const struct stack_register_offset arc_callee_saved []
 
static const struct rtos_register_stacking arc_callee_saved_stacking
 
static struct stack_register_offset arc_cpu_saved []
 
static struct rtos_register_stacking arc_cpu_saved_stacking
 
static const struct stack_register_offset arm_callee_saved []
 
static const struct rtos_register_stacking arm_callee_saved_stacking
 
static const struct stack_register_offset arm_cpu_saved []
 
static const struct rtos_register_stacking arm_cpu_saved_fp_stacking
 
static const struct rtos_register_stacking arm_cpu_saved_nofp_stacking
 
static struct zephyr_params zephyr_params_list []
 
const struct rtos_type zephyr_rtos
 
static const struct symbol_table_elem zephyr_symbol_list []
 

Macro Definition Documentation

◆ ARC_AUX_SEC_BUILD_REG

#define ARC_AUX_SEC_BUILD_REG   0xdb

Definition at line 29 of file zephyr.c.

◆ ARC_REG_NUM

#define ARC_REG_NUM   38

Definition at line 30 of file zephyr.c.

◆ ARM_XPSR_OFFSET

#define ARM_XPSR_OFFSET   28

Definition at line 33 of file zephyr.c.

◆ UNIMPLEMENTED

#define UNIMPLEMENTED   0xFFFFFFFFU

Definition at line 26 of file zephyr.c.

Enumeration Type Documentation

◆ zephyr_offsets

Enumerator
OFFSET_VERSION 
OFFSET_K_CURR_THREAD 
OFFSET_K_THREADS 
OFFSET_T_ENTRY 
OFFSET_T_NEXT_THREAD 
OFFSET_T_STATE 
OFFSET_T_USER_OPTIONS 
OFFSET_T_PRIO 
OFFSET_T_STACK_POINTER 
OFFSET_T_NAME 
OFFSET_T_ARCH 
OFFSET_T_PREEMPT_FLOAT 
OFFSET_T_COOP_FLOAT 
OFFSET_T_ARM_EXC_RETURN 
OFFSET_MAX 

Definition at line 45 of file zephyr.c.

◆ zephyr_symbol_values

Enumerator
ZEPHYR_VAL__KERNEL 
ZEPHYR_VAL__KERNEL_OPENOCD_OFFSETS 
ZEPHYR_VAL__KERNEL_OPENOCD_SIZE_T_SIZE 
ZEPHYR_VAL__KERNEL_OPENOCD_NUM_OFFSETS 
ZEPHYR_VAL_COUNT 

Definition at line 184 of file zephyr.c.

Function Documentation

◆ zephyr_array_append()

static void* zephyr_array_append ( struct zephyr_array array,
size_t  size 
)
static

Definition at line 474 of file zephyr.c.

References zephyr_array::elements, LOG_ERROR, NULL, zephyr_array::ptr, and size.

Referenced by zephyr_fetch_thread_list().

◆ zephyr_array_detach_ptr()

static void* zephyr_array_detach_ptr ( struct zephyr_array array)
static

Definition at line 490 of file zephyr.c.

References zephyr_array::ptr, and zephyr_array_init().

Referenced by zephyr_fetch_thread_list().

◆ zephyr_array_free()

static void zephyr_array_free ( struct zephyr_array array)
static

Definition at line 468 of file zephyr.c.

References zephyr_array::ptr, and zephyr_array_init().

Referenced by zephyr_fetch_thread_list().

◆ zephyr_array_init()

static void zephyr_array_init ( struct zephyr_array array)
static

◆ zephyr_cortex_m_stack_align()

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

Definition at line 192 of file zephyr.c.

◆ zephyr_create()

◆ zephyr_detect_rtos()

static bool zephyr_detect_rtos ( struct target target)
static

◆ zephyr_fetch_thread()

◆ zephyr_fetch_thread_list()

◆ zephyr_get_arc_state()

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

◆ zephyr_get_arm_state()

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

◆ zephyr_get_symbol_list_to_lookup()

static int zephyr_get_symbol_list_to_lookup ( struct symbol_table_elem **  symbol_list)
static

Definition at line 776 of file zephyr.c.

References ERROR_FAIL, ERROR_OK, LOG_ERROR, and zephyr_symbol_list.

◆ zephyr_get_thread_reg_list()

static int zephyr_get_thread_reg_list ( struct rtos rtos,
int64_t  thread_id,
struct rtos_reg **  reg_list,
int *  num_regs 
)
static

◆ zephyr_kptr()

static uint32_t zephyr_kptr ( const struct rtos rtos,
enum zephyr_offsets  off 
)
static

◆ zephyr_update_threads()

Variable Documentation

◆ arc_callee_saved

const struct stack_register_offset arc_callee_saved[]
static
Initial value:
= {
{ ARC_R13, 0, 32 },
{ ARC_R14, 4, 32 },
{ ARC_R15, 8, 32 },
{ ARC_R16, 12, 32 },
{ ARC_R17, 16, 32 },
{ ARC_R18, 20, 32 },
{ ARC_R19, 24, 32 },
{ ARC_R20, 28, 32 },
{ ARC_R21, 32, 32 },
{ ARC_R22, 36, 32 },
{ ARC_R23, 40, 32 },
{ ARC_R24, 44, 32 },
{ ARC_R25, 48, 32 },
{ ARC_GP, 52, 32 },
{ ARC_FP, 56, 32 },
{ ARC_R30, 60, 32 }
}
@ ARC_R18
Definition: arc.h:68
@ ARC_R17
Definition: arc.h:67
@ ARC_R21
Definition: arc.h:71
@ ARC_R15
Definition: arc.h:65
@ ARC_R14
Definition: arc.h:64
@ ARC_R20
Definition: arc.h:70
@ ARC_R16
Definition: arc.h:66
@ ARC_R24
Definition: arc.h:74
@ ARC_GP
Definition: arc.h:76
@ ARC_FP
Definition: arc.h:77
@ ARC_R22
Definition: arc.h:72
@ ARC_R30
Definition: arc.h:80
@ ARC_R19
Definition: arc.h:69
@ ARC_R13
Definition: arc.h:63
@ ARC_R25
Definition: arc.h:75
@ ARC_R23
Definition: arc.h:73

Definition at line 1 of file zephyr.c.

◆ arc_callee_saved_stacking

const struct rtos_register_stacking arc_callee_saved_stacking
static
Initial value:
= {
.stack_registers_size = 64,
.stack_growth_direction = -1,
.num_output_registers = ARRAY_SIZE(arc_callee_saved),
.register_offsets = arc_callee_saved,
}
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
Definition: types.h:57
static const struct stack_register_offset arc_callee_saved[]
Definition: zephyr.c:90

Definition at line 1 of file zephyr.c.

◆ arc_cpu_saved

struct stack_register_offset arc_cpu_saved[]
static

Definition at line 1 of file zephyr.c.

Referenced by zephyr_create(), and zephyr_get_arc_state().

◆ arc_cpu_saved_stacking

struct rtos_register_stacking arc_cpu_saved_stacking
static
Initial value:
= {
.stack_registers_size = 8,
.stack_growth_direction = -1,
.num_output_registers = ARRAY_SIZE(arc_cpu_saved),
.register_offsets = arc_cpu_saved,
}
static struct stack_register_offset arc_cpu_saved[]
Definition: zephyr.c:142

Definition at line 192 of file zephyr.c.

Referenced by zephyr_create(), and zephyr_get_arc_state().

◆ arm_callee_saved

const struct stack_register_offset arm_callee_saved[]
static
Initial value:
= {
{ ARMV7M_R13, 32, 32 },
{ ARMV7M_R4, 0, 32 },
{ ARMV7M_R5, 4, 32 },
{ ARMV7M_R6, 8, 32 },
{ ARMV7M_R7, 12, 32 },
{ ARMV7M_R8, 16, 32 },
{ ARMV7M_R9, 20, 32 },
{ ARMV7M_R10, 24, 32 },
{ ARMV7M_R11, 28, 32 },
}
@ ARMV7M_R6
Definition: armv7m.h:114
@ ARMV7M_R9
Definition: armv7m.h:118
@ ARMV7M_R13
Definition: armv7m.h:123
@ ARMV7M_R7
Definition: armv7m.h:115
@ ARMV7M_R4
Definition: armv7m.h:112
@ ARMV7M_R8
Definition: armv7m.h:117
@ ARMV7M_R11
Definition: armv7m.h:120
@ ARMV7M_R10
Definition: armv7m.h:119
@ ARMV7M_R5
Definition: armv7m.h:113

Definition at line 1 of file zephyr.c.

◆ arm_callee_saved_stacking

const struct rtos_register_stacking arm_callee_saved_stacking
static
Initial value:
= {
.stack_registers_size = 36,
.stack_growth_direction = -1,
.num_output_registers = ARRAY_SIZE(arm_callee_saved),
.register_offsets = arm_callee_saved,
}
static const struct stack_register_offset arm_callee_saved[]
Definition: zephyr.c:78

Definition at line 1 of file zephyr.c.

◆ arm_cpu_saved

const struct stack_register_offset arm_cpu_saved[]
static
Initial value:
= {
{ ARMV7M_R0, 0, 32 },
{ ARMV7M_R1, 4, 32 },
{ ARMV7M_R2, 8, 32 },
{ ARMV7M_R3, 12, 32 },
{ ARMV7M_R4, -1, 32 },
{ ARMV7M_R5, -1, 32 },
{ ARMV7M_R6, -1, 32 },
{ ARMV7M_R7, -1, 32 },
{ ARMV7M_R8, -1, 32 },
{ ARMV7M_R9, -1, 32 },
{ ARMV7M_R10, -1, 32 },
{ ARMV7M_R11, -1, 32 },
{ ARMV7M_R12, 16, 32 },
{ ARMV7M_R13, -2, 32 },
{ ARMV7M_R14, 20, 32 },
{ ARMV7M_PC, 24, 32 },
{ ARMV7M_XPSR, 28, 32 },
}
@ ARMV7M_R1
Definition: armv7m.h:108
@ ARMV7M_R2
Definition: armv7m.h:109
@ ARMV7M_R3
Definition: armv7m.h:110
@ ARMV7M_R14
Definition: armv7m.h:124
@ ARMV7M_R12
Definition: armv7m.h:122
@ ARMV7M_R0
Definition: armv7m.h:107
@ ARMV7M_PC
Definition: armv7m.h:125
@ ARMV7M_XPSR
Definition: armv7m.h:127

Definition at line 1 of file zephyr.c.

◆ arm_cpu_saved_fp_stacking

const struct rtos_register_stacking arm_cpu_saved_fp_stacking
static
Initial value:
= {
.stack_registers_size = 32 + 18 * 4,
.stack_growth_direction = -1,
.num_output_registers = ARRAY_SIZE(arm_cpu_saved),
.calculate_process_stack = zephyr_cortex_m_stack_align,
.register_offsets = arm_cpu_saved,
}
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)
Definition: zephyr.c:192
static const struct stack_register_offset arm_cpu_saved[]
Definition: zephyr.c:122

Definition at line 192 of file zephyr.c.

◆ arm_cpu_saved_nofp_stacking

const struct rtos_register_stacking arm_cpu_saved_nofp_stacking
static
Initial value:
= {
.stack_registers_size = 32,
.stack_growth_direction = -1,
.num_output_registers = ARRAY_SIZE(arm_cpu_saved),
.calculate_process_stack = zephyr_cortex_m_stack_align,
.register_offsets = arm_cpu_saved,
}

Definition at line 192 of file zephyr.c.

◆ zephyr_params_list

struct zephyr_params zephyr_params_list[]
static

Definition at line 297 of file zephyr.c.

Referenced by zephyr_create().

◆ zephyr_rtos

const struct rtos_type zephyr_rtos
Initial value:
= {
.name = "Zephyr",
.detect_rtos = zephyr_detect_rtos,
.create = zephyr_create,
.update_threads = zephyr_update_threads,
.get_thread_reg_list = zephyr_get_thread_reg_list,
.get_symbol_list_to_lookup = zephyr_get_symbol_list_to_lookup,
}
static int zephyr_get_symbol_list_to_lookup(struct symbol_table_elem **symbol_list)
Definition: zephyr.c:776
static int zephyr_create(struct target *target)
Definition: zephyr.c:417
static int zephyr_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, struct rtos_reg **reg_list, int *num_regs)
Definition: zephyr.c:746
static int zephyr_update_threads(struct rtos *rtos)
Definition: zephyr.c:635
static bool zephyr_detect_rtos(struct target *target)
Definition: zephyr.c:394

Definition at line 776 of file zephyr.c.

◆ zephyr_symbol_list

const struct symbol_table_elem zephyr_symbol_list[]
static
Initial value:
= {
{
.symbol_name = "_kernel",
.optional = false
},
{
.symbol_name = "_kernel_thread_info_offsets",
.optional = false
},
{
.symbol_name = "_kernel_thread_info_size_t_size",
.optional = false
},
{
.symbol_name = "_kernel_thread_info_num_offsets",
.optional = true
},
{
.symbol_name = NULL
}
}
#define NULL
Definition: usb.h:16

Definition at line 297 of file zephyr.c.

Referenced by zephyr_get_symbol_list_to_lookup().