diff --git a/src/rtos/FreeRTOS.c b/src/rtos/FreeRTOS.c index 24b829070..a480c4461 100644 --- a/src/rtos/FreeRTOS.c +++ b/src/rtos/FreeRTOS.c @@ -31,18 +31,14 @@ #include "target/armv7m.h" #include "target/cortex_m.h" - - #define FREERTOS_MAX_PRIORITIES 63 -#define FreeRTOS_STRUCT(int_type, ptr_type, list_prev_offset) - /* FIXME: none of the _width parameters are actually observed properly! * you WILL need to edit more if you actually attempt to target a 8/16/64 * bit target! */ -struct FreeRTOS_params { +struct freertos_params { const char *target_name; const unsigned char thread_count_width; const unsigned char pointer_width; @@ -57,7 +53,7 @@ struct FreeRTOS_params { const struct rtos_register_stacking *stacking_info_cm4f_fpu; }; -static const struct FreeRTOS_params FreeRTOS_params_list[] = { +static const struct freertos_params freertos_params_list[] = { { "cortex_m", /* target_name */ 4, /* thread_count_width; */ @@ -68,9 +64,9 @@ static const struct FreeRTOS_params FreeRTOS_params_list[] = { 12, /* list_elem_content_offset */ 0, /* thread_stack_offset; */ 52, /* thread_name_offset; */ - &rtos_standard_Cortex_M3_stacking, /* stacking_info */ - &rtos_standard_Cortex_M4F_stacking, - &rtos_standard_Cortex_M4F_FPU_stacking, + &rtos_standard_cortex_m3_stacking, /* stacking_info */ + &rtos_standard_cortex_m4f_stacking, + &rtos_standard_cortex_m4f_fpu_stacking, }, { "hla_target", /* target_name */ @@ -82,9 +78,9 @@ static const struct FreeRTOS_params FreeRTOS_params_list[] = { 12, /* list_elem_content_offset */ 0, /* thread_stack_offset; */ 52, /* thread_name_offset; */ - &rtos_standard_Cortex_M3_stacking, /* stacking_info */ - &rtos_standard_Cortex_M4F_stacking, - &rtos_standard_Cortex_M4F_FPU_stacking, + &rtos_standard_cortex_m3_stacking, /* stacking_info */ + &rtos_standard_cortex_m4f_stacking, + &rtos_standard_cortex_m4f_fpu_stacking, }, { "nds32_v3", /* target_name */ @@ -96,30 +92,30 @@ static const struct FreeRTOS_params FreeRTOS_params_list[] = { 12, /* list_elem_content_offset */ 0, /* thread_stack_offset; */ 52, /* thread_name_offset; */ - &rtos_standard_NDS32_N1068_stacking, /* stacking_info */ - &rtos_standard_Cortex_M4F_stacking, - &rtos_standard_Cortex_M4F_FPU_stacking, + &rtos_standard_nds32_n1068_stacking, /* stacking_info */ + &rtos_standard_cortex_m4f_stacking, + &rtos_standard_cortex_m4f_fpu_stacking, }, }; -static bool FreeRTOS_detect_rtos(struct target *target); -static int FreeRTOS_create(struct target *target); -static int FreeRTOS_update_threads(struct rtos *rtos); -static int FreeRTOS_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, +static bool freertos_detect_rtos(struct target *target); +static int freertos_create(struct target *target); +static int freertos_update_threads(struct rtos *rtos); +static int freertos_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, struct rtos_reg **reg_list, int *num_regs); -static int FreeRTOS_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[]); +static int freertos_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[]); -struct rtos_type FreeRTOS_rtos = { +struct rtos_type freertos_rtos = { .name = "FreeRTOS", - .detect_rtos = FreeRTOS_detect_rtos, - .create = FreeRTOS_create, - .update_threads = FreeRTOS_update_threads, - .get_thread_reg_list = FreeRTOS_get_thread_reg_list, - .get_symbol_list_to_lookup = FreeRTOS_get_symbol_list_to_lookup, + .detect_rtos = freertos_detect_rtos, + .create = freertos_create, + .update_threads = freertos_update_threads, + .get_thread_reg_list = freertos_get_thread_reg_list, + .get_symbol_list_to_lookup = freertos_get_symbol_list_to_lookup, }; -enum FreeRTOS_symbol_values { +enum freertos_symbol_values { FREERTOS_VAL_PX_CURRENT_TCB = 0, FREERTOS_VAL_PX_READY_TASKS_LISTS = 1, FREERTOS_VAL_X_DELAYED_TASK_LIST1 = 2, @@ -138,7 +134,7 @@ struct symbols { bool optional; }; -static const struct symbols FreeRTOS_symbol_list[] = { +static const struct symbols freertos_symbol_list[] = { { "pxCurrentTCB", false }, { "pxReadyTasksLists", false }, { "xDelayedTaskList1", false }, @@ -158,16 +154,16 @@ static const struct symbols FreeRTOS_symbol_list[] = { /* may be problems reading if sizes are not 32 bit long integers. */ /* test mallocs for failure */ -static int FreeRTOS_update_threads(struct rtos *rtos) +static int freertos_update_threads(struct rtos *rtos) { int retval; unsigned int tasks_found = 0; - const struct FreeRTOS_params *param; + const struct freertos_params *param; if (rtos->rtos_specific_params == NULL) return -1; - param = (const struct FreeRTOS_params *) rtos->rtos_specific_params; + param = (const struct freertos_params *) rtos->rtos_specific_params; if (rtos->symbols == NULL) { LOG_ERROR("No symbols for FreeRTOS"); @@ -400,11 +396,11 @@ static int FreeRTOS_update_threads(struct rtos *rtos) return 0; } -static int FreeRTOS_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, +static int freertos_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, struct rtos_reg **reg_list, int *num_regs) { int retval; - const struct FreeRTOS_params *param; + const struct freertos_params *param; int64_t stack_ptr = 0; if (rtos == NULL) @@ -416,7 +412,7 @@ static int FreeRTOS_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, if (rtos->rtos_specific_params == NULL) return -1; - param = (const struct FreeRTOS_params *) rtos->rtos_specific_params; + param = (const struct freertos_params *) rtos->rtos_specific_params; /* Read the stack pointer */ uint32_t pointer_casts_are_bad; @@ -456,15 +452,15 @@ static int FreeRTOS_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, if (cm4_fpu_enabled == 1) { /* Read the LR to decide between stacking with or without FPU */ - uint32_t LR_svc = 0; + uint32_t lr_svc = 0; retval = target_read_u32(rtos->target, stack_ptr + 0x20, - &LR_svc); + &lr_svc); if (retval != ERROR_OK) { LOG_OUTPUT("Error reading stack frame from FreeRTOS thread"); return retval; } - if ((LR_svc & 0x10) == 0) + if ((lr_svc & 0x10) == 0) return rtos_generic_stack_read(rtos->target, param->stacking_info_cm4f_fpu, stack_ptr, reg_list, num_regs); else return rtos_generic_stack_read(rtos->target, param->stacking_info_cm4f, stack_ptr, reg_list, num_regs); @@ -472,15 +468,15 @@ static int FreeRTOS_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, return rtos_generic_stack_read(rtos->target, param->stacking_info_cm3, stack_ptr, reg_list, num_regs); } -static int FreeRTOS_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[]) +static int freertos_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[]) { unsigned int i; *symbol_list = calloc( - ARRAY_SIZE(FreeRTOS_symbol_list), sizeof(struct symbol_table_elem)); + ARRAY_SIZE(freertos_symbol_list), sizeof(struct symbol_table_elem)); - for (i = 0; i < ARRAY_SIZE(FreeRTOS_symbol_list); i++) { - (*symbol_list)[i].symbol_name = FreeRTOS_symbol_list[i].name; - (*symbol_list)[i].optional = FreeRTOS_symbol_list[i].optional; + for (i = 0; i < ARRAY_SIZE(freertos_symbol_list); i++) { + (*symbol_list)[i].symbol_name = freertos_symbol_list[i].name; + (*symbol_list)[i].optional = freertos_symbol_list[i].optional; } return 0; @@ -488,15 +484,15 @@ static int FreeRTOS_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_l #if 0 -static int FreeRTOS_set_current_thread(struct rtos *rtos, threadid_t thread_id) +static int freertos_set_current_thread(struct rtos *rtos, threadid_t thread_id) { return 0; } -static int FreeRTOS_get_thread_ascii_info(struct rtos *rtos, threadid_t thread_id, char **info) +static int freertos_get_thread_ascii_info(struct rtos *rtos, threadid_t thread_id, char **info) { int retval; - const struct FreeRTOS_params *param; + const struct freertos_params *param; if (rtos == NULL) return -1; @@ -507,7 +503,7 @@ static int FreeRTOS_get_thread_ascii_info(struct rtos *rtos, threadid_t thread_i if (rtos->rtos_specific_params == NULL) return -3; - param = (const struct FreeRTOS_params *) rtos->rtos_specific_params; + param = (const struct freertos_params *) rtos->rtos_specific_params; #define FREERTOS_THREAD_NAME_STR_SIZE (200) char tmp_str[FREERTOS_THREAD_NAME_STR_SIZE]; @@ -533,7 +529,7 @@ static int FreeRTOS_get_thread_ascii_info(struct rtos *rtos, threadid_t thread_i #endif -static bool FreeRTOS_detect_rtos(struct target *target) +static bool freertos_detect_rtos(struct target *target) { if ((target->rtos->symbols != NULL) && (target->rtos->symbols[FREERTOS_VAL_PX_READY_TASKS_LISTS].address != 0)) { @@ -543,11 +539,11 @@ static bool FreeRTOS_detect_rtos(struct target *target) return false; } -static int FreeRTOS_create(struct target *target) +static int freertos_create(struct target *target) { - for (unsigned int i = 0; i < ARRAY_SIZE(FreeRTOS_params_list); i++) - if (strcmp(FreeRTOS_params_list[i].target_name, target->type->name) == 0) { - target->rtos->rtos_specific_params = (void *)&FreeRTOS_params_list[i]; + for (unsigned int i = 0; i < ARRAY_SIZE(freertos_params_list); i++) + if (strcmp(freertos_params_list[i].target_name, target->type->name) == 0) { + target->rtos->rtos_specific_params = (void *)&freertos_params_list[i]; return 0; } diff --git a/src/rtos/ThreadX.c b/src/rtos/ThreadX.c index 3b4c2d701..5eadce9ca 100644 --- a/src/rtos/ThreadX.c +++ b/src/rtos/ThreadX.c @@ -35,20 +35,20 @@ static const struct rtos_register_stacking *get_stacking_info_arm926ejs(const st static int is_thread_id_valid(const struct rtos *rtos, int64_t thread_id); static int is_thread_id_valid_arm926ejs(const struct rtos *rtos, int64_t thread_id); -static bool ThreadX_detect_rtos(struct target *target); -static int ThreadX_create(struct target *target); -static int ThreadX_update_threads(struct rtos *rtos); -static int ThreadX_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, struct rtos_reg **reg_list, int *num_regs); -static int ThreadX_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[]); +static bool threadx_detect_rtos(struct target *target); +static int threadx_create(struct target *target); +static int threadx_update_threads(struct rtos *rtos); +static int threadx_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, struct rtos_reg **reg_list, int *num_regs); +static int threadx_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[]); -struct ThreadX_thread_state { +struct threadx_thread_state { int value; const char *desc; }; -static const struct ThreadX_thread_state ThreadX_thread_states[] = { +static const struct threadx_thread_state threadx_thread_states[] = { { 0, "Ready" }, { 1, "Completed" }, { 2, "Terminated" }, @@ -65,7 +65,7 @@ static const struct ThreadX_thread_state ThreadX_thread_states[] = { { 13, "Waiting - Mutex" }, }; -#define THREADX_NUM_STATES ARRAY_SIZE(ThreadX_thread_states) +#define THREADX_NUM_STATES ARRAY_SIZE(threadx_thread_states) #define ARM926EJS_REGISTERS_SIZE_SOLICITED (11 * 4) static const struct stack_register_offset rtos_threadx_arm926ejs_stack_offsets_solicited[] = { @@ -127,7 +127,7 @@ static const struct rtos_register_stacking rtos_threadx_arm926ejs_stacking[] = { }, }; -struct ThreadX_params { +struct threadx_params { const char *target_name; unsigned char pointer_width; unsigned char thread_stack_offset; @@ -140,7 +140,7 @@ struct ThreadX_params { int (*fn_is_thread_id_valid)(const struct rtos *rtos, int64_t thread_id); }; -static const struct ThreadX_params ThreadX_params_list[] = { +static const struct threadx_params threadx_params_list[] = { { "cortex_m", /* target_name */ 4, /* pointer_width; */ @@ -148,7 +148,7 @@ static const struct ThreadX_params ThreadX_params_list[] = { 40, /* thread_name_offset; */ 48, /* thread_state_offset; */ 136, /* thread_next_offset */ - &rtos_standard_Cortex_M3_stacking, /* stacking_info */ + &rtos_standard_cortex_m3_stacking, /* stacking_info */ 1, /* stacking_info_nb */ NULL, /* fn_get_stacking_info */ NULL, /* fn_is_thread_id_valid */ @@ -160,7 +160,7 @@ static const struct ThreadX_params ThreadX_params_list[] = { 40, /* thread_name_offset; */ 48, /* thread_state_offset; */ 136, /* thread_next_offset */ - &rtos_standard_Cortex_R4_stacking, /* stacking_info */ + &rtos_standard_cortex_r4_stacking, /* stacking_info */ 1, /* stacking_info_nb */ NULL, /* fn_get_stacking_info */ NULL, /* fn_is_thread_id_valid */ @@ -179,32 +179,32 @@ static const struct ThreadX_params ThreadX_params_list[] = { }, }; -enum ThreadX_symbol_values { +enum threadx_symbol_values { THREADX_VAL_TX_THREAD_CURRENT_PTR = 0, THREADX_VAL_TX_THREAD_CREATED_PTR = 1, THREADX_VAL_TX_THREAD_CREATED_COUNT = 2, }; -static const char * const ThreadX_symbol_list[] = { +static const char * const threadx_symbol_list[] = { "_tx_thread_current_ptr", "_tx_thread_created_ptr", "_tx_thread_created_count", NULL }; -const struct rtos_type ThreadX_rtos = { +const struct rtos_type threadx_rtos = { .name = "ThreadX", - .detect_rtos = ThreadX_detect_rtos, - .create = ThreadX_create, - .update_threads = ThreadX_update_threads, - .get_thread_reg_list = ThreadX_get_thread_reg_list, - .get_symbol_list_to_lookup = ThreadX_get_symbol_list_to_lookup, + .detect_rtos = threadx_detect_rtos, + .create = threadx_create, + .update_threads = threadx_update_threads, + .get_thread_reg_list = threadx_get_thread_reg_list, + .get_symbol_list_to_lookup = threadx_get_symbol_list_to_lookup, }; static const struct rtos_register_stacking *get_stacking_info(const struct rtos *rtos, int64_t stack_ptr) { - const struct ThreadX_params *param = (const struct ThreadX_params *) rtos->rtos_specific_params; + const struct threadx_params *param = (const struct threadx_params *) rtos->rtos_specific_params; if (param->fn_get_stacking_info != NULL) return param->fn_get_stacking_info(rtos, stack_ptr); @@ -214,12 +214,12 @@ static const struct rtos_register_stacking *get_stacking_info(const struct rtos static int is_thread_id_valid(const struct rtos *rtos, int64_t thread_id) { - const struct ThreadX_params *param; + const struct threadx_params *param; if (rtos->rtos_specific_params == NULL) return 0; /* invalid */ - param = (const struct ThreadX_params *) rtos->rtos_specific_params; + param = (const struct threadx_params *) rtos->rtos_specific_params; if (param->fn_is_thread_id_valid != NULL) return param->fn_is_thread_id_valid(rtos, thread_id); @@ -229,7 +229,7 @@ static int is_thread_id_valid(const struct rtos *rtos, int64_t thread_id) static const struct rtos_register_stacking *get_stacking_info_arm926ejs(const struct rtos *rtos, int64_t stack_ptr) { - const struct ThreadX_params *param = (const struct ThreadX_params *) rtos->rtos_specific_params; + const struct threadx_params *param = (const struct threadx_params *) rtos->rtos_specific_params; int retval; uint32_t flag; @@ -256,12 +256,12 @@ static int is_thread_id_valid_arm926ejs(const struct rtos *rtos, int64_t thread_ return (thread_id != 0 && thread_id != 1); } -static int ThreadX_update_threads(struct rtos *rtos) +static int threadx_update_threads(struct rtos *rtos) { int retval; int tasks_found = 0; int thread_list_size = 0; - const struct ThreadX_params *param; + const struct threadx_params *param; if (rtos == NULL) return -1; @@ -269,7 +269,7 @@ static int ThreadX_update_threads(struct rtos *rtos) if (rtos->rtos_specific_params == NULL) return -3; - param = (const struct ThreadX_params *) rtos->rtos_specific_params; + param = (const struct threadx_params *) rtos->rtos_specific_params; if (rtos->symbols == NULL) { LOG_ERROR("No symbols for ThreadX"); @@ -395,13 +395,13 @@ static int ThreadX_update_threads(struct rtos *rtos) } for (i = 0; (i < THREADX_NUM_STATES) && - (ThreadX_thread_states[i].value != thread_status); i++) { + (threadx_thread_states[i].value != thread_status); i++) { /* empty */ } const char *state_desc; if (i < THREADX_NUM_STATES) - state_desc = ThreadX_thread_states[i].desc; + state_desc = threadx_thread_states[i].desc; else state_desc = "Unknown state"; @@ -431,11 +431,11 @@ static int ThreadX_update_threads(struct rtos *rtos) return 0; } -static int ThreadX_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, +static int threadx_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, struct rtos_reg **reg_list, int *num_regs) { int retval; - const struct ThreadX_params *param; + const struct threadx_params *param; if (rtos == NULL) return -1; @@ -446,7 +446,7 @@ static int ThreadX_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, if (rtos->rtos_specific_params == NULL) return -3; - param = (const struct ThreadX_params *) rtos->rtos_specific_params; + param = (const struct threadx_params *) rtos->rtos_specific_params; /* Read the stack pointer */ int64_t stack_ptr = 0; @@ -477,19 +477,19 @@ static int ThreadX_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, return rtos_generic_stack_read(rtos->target, stacking_info, stack_ptr, reg_list, num_regs); } -static int ThreadX_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[]) +static int threadx_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[]) { unsigned int i; *symbol_list = calloc( - ARRAY_SIZE(ThreadX_symbol_list), sizeof(struct symbol_table_elem)); + ARRAY_SIZE(threadx_symbol_list), sizeof(struct symbol_table_elem)); - for (i = 0; i < ARRAY_SIZE(ThreadX_symbol_list); i++) - (*symbol_list)[i].symbol_name = ThreadX_symbol_list[i]; + for (i = 0; i < ARRAY_SIZE(threadx_symbol_list); i++) + (*symbol_list)[i].symbol_name = threadx_symbol_list[i]; return 0; } -static bool ThreadX_detect_rtos(struct target *target) +static bool threadx_detect_rtos(struct target *target) { if ((target->rtos->symbols != NULL) && (target->rtos->symbols[THREADX_VAL_TX_THREAD_CREATED_PTR].address != 0)) { @@ -501,12 +501,12 @@ static bool ThreadX_detect_rtos(struct target *target) #if 0 -static int ThreadX_set_current_thread(struct rtos *rtos, threadid_t thread_id) +static int threadx_set_current_thread(struct rtos *rtos, threadid_t thread_id) { return 0; } -static int ThreadX_get_thread_detail(struct rtos *rtos, +static int threadx_get_thread_detail(struct rtos *rtos, threadid_t thread_id, struct thread_detail *detail) { @@ -516,7 +516,7 @@ static int ThreadX_get_thread_detail(struct rtos *rtos, #define THREADX_THREAD_NAME_STR_SIZE (200) char tmp_str[THREADX_THREAD_NAME_STR_SIZE]; - const struct ThreadX_params *param; + const struct threadx_params *param; if (rtos == NULL) return -1; @@ -527,7 +527,7 @@ static int ThreadX_get_thread_detail(struct rtos *rtos, if (rtos->rtos_specific_params == NULL) return -3; - param = (const struct ThreadX_params *) rtos->rtos_specific_params; + param = (const struct threadx_params *) rtos->rtos_specific_params; if (rtos->symbols == NULL) { LOG_ERROR("No symbols for ThreadX"); @@ -576,13 +576,13 @@ static int ThreadX_get_thread_detail(struct rtos *rtos, } for (i = 0; (i < THREADX_NUM_STATES) && - (ThreadX_thread_states[i].value != thread_status); i++) { + (threadx_thread_states[i].value != thread_status); i++) { /* empty */ } char *state_desc; if (i < THREADX_NUM_STATES) - state_desc = ThreadX_thread_states[i].desc; + state_desc = threadx_thread_states[i].desc; else state_desc = "Unknown state"; @@ -595,11 +595,11 @@ static int ThreadX_get_thread_detail(struct rtos *rtos, #endif -static int ThreadX_create(struct target *target) +static int threadx_create(struct target *target) { - for (unsigned int i = 0; i < ARRAY_SIZE(ThreadX_params_list); i++) - if (strcmp(ThreadX_params_list[i].target_name, target->type->name) == 0) { - target->rtos->rtos_specific_params = (void *)&ThreadX_params_list[i]; + for (unsigned int i = 0; i < ARRAY_SIZE(threadx_params_list); i++) + if (strcmp(threadx_params_list[i].target_name, target->type->name) == 0) { + target->rtos->rtos_specific_params = (void *)&threadx_params_list[i]; target->rtos->current_thread = 0; target->rtos->thread_details = NULL; return 0; diff --git a/src/rtos/chibios.c b/src/rtos/chibios.c index 2a23017cd..cb471b485 100644 --- a/src/rtos/chibios.c +++ b/src/rtos/chibios.c @@ -62,9 +62,9 @@ struct chibios_chdebug { uint8_t cf_off_time; /**< @brief Offset of @p p_time field. */ }; -#define GET_CH_KERNEL_MAJOR(codedVersion) ((codedVersion >> 11) & 0x1f) -#define GET_CH_KERNEL_MINOR(codedVersion) ((codedVersion >> 6) & 0x1f) -#define GET_CH_KERNEL_PATCH(codedVersion) ((codedVersion >> 0) & 0x3f) +#define GET_CH_KERNEL_MAJOR(coded_version) ((coded_version >> 11) & 0x1f) +#define GET_CH_KERNEL_MINOR(coded_version) ((coded_version >> 6) & 0x1f) +#define GET_CH_KERNEL_PATCH(coded_version) ((coded_version >> 0) & 0x3f) /** * @brief ChibiOS thread states. @@ -184,10 +184,10 @@ static int chibios_update_memory_signature(struct rtos *rtos) } /* Convert endianness of version field */ - const uint8_t *versionTarget = (const uint8_t *) + const uint8_t *versiontarget = (const uint8_t *) &signature->ch_version; signature->ch_version = rtos->target->endianness == TARGET_LITTLE_ENDIAN ? - le_to_h_u32(versionTarget) : be_to_h_u32(versionTarget); + le_to_h_u32(versiontarget) : be_to_h_u32(versiontarget); const uint16_t ch_version = signature->ch_version; LOG_INFO("Successfully loaded memory map of ChibiOS/RT target " diff --git a/src/rtos/chromium-ec.c b/src/rtos/chromium-ec.c index 05d5b29b2..1c8f4e3f4 100644 --- a/src/rtos/chromium-ec.c +++ b/src/rtos/chromium-ec.c @@ -36,7 +36,7 @@ static const struct chromium_ec_params chromium_ec_params_list[] = { .task_offset_sp = 0, .task_offset_events = 4, .task_offset_runtime = 8, - .stacking = &rtos_standard_Cortex_M3_stacking, + .stacking = &rtos_standard_cortex_m3_stacking, }, { @@ -46,7 +46,7 @@ static const struct chromium_ec_params chromium_ec_params_list[] = { .task_offset_sp = 0, .task_offset_events = 4, .task_offset_runtime = 8, - .stacking = &rtos_standard_Cortex_M3_stacking, + .stacking = &rtos_standard_cortex_m3_stacking, }, }; diff --git a/src/rtos/eCos.c b/src/rtos/eCos.c index 1b1e73e60..a9feb8019 100644 --- a/src/rtos/eCos.c +++ b/src/rtos/eCos.c @@ -84,7 +84,7 @@ static const char * const eCos_symbol_list[] = { NULL }; -const struct rtos_type eCos_rtos = { +const struct rtos_type ecos_rtos = { .name = "eCos", .detect_rtos = eCos_detect_rtos, diff --git a/src/rtos/embKernel.c b/src/rtos/embKernel.c index 620d16baa..259399bc3 100644 --- a/src/rtos/embKernel.c +++ b/src/rtos/embKernel.c @@ -31,21 +31,21 @@ #define EMBKERNEL_MAX_THREAD_NAME_STR_SIZE (64) -static bool embKernel_detect_rtos(struct target *target); -static int embKernel_create(struct target *target); -static int embKernel_update_threads(struct rtos *rtos); -static int embKernel_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, +static bool embkernel_detect_rtos(struct target *target); +static int embkernel_create(struct target *target); +static int embkernel_update_threads(struct rtos *rtos); +static int embkernel_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, struct rtos_reg **reg_list, int *num_regs); -static int embKernel_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[]); +static int embkernel_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[]); -struct rtos_type embKernel_rtos = { +struct rtos_type embkernel_rtos = { .name = "embKernel", - .detect_rtos = embKernel_detect_rtos, - .create = embKernel_create, - .update_threads = embKernel_update_threads, + .detect_rtos = embkernel_detect_rtos, + .create = embkernel_create, + .update_threads = embkernel_update_threads, .get_thread_reg_list = - embKernel_get_thread_reg_list, - .get_symbol_list_to_lookup = embKernel_get_symbol_list_to_lookup, + embkernel_get_thread_reg_list, + .get_symbol_list_to_lookup = embkernel_get_symbol_list_to_lookup, }; enum { @@ -57,7 +57,7 @@ enum { SYMBOL_ID_S_CURRENT_TASK_COUNT = 5, }; -static const char * const embKernel_symbol_list[] = { +static const char * const embkernel_symbol_list[] = { "Rtos::sCurrentTask", "Rtos::sListReady", "Rtos::sListSleep", @@ -66,7 +66,7 @@ static const char * const embKernel_symbol_list[] = { "Rtos::sCurrentTaskCount", NULL }; -struct embKernel_params { +struct embkernel_params { const char *target_name; const unsigned char pointer_width; const unsigned char thread_count_width; @@ -80,7 +80,7 @@ struct embKernel_params { const struct rtos_register_stacking *stacking_info; }; -static const struct embKernel_params embKernel_params_list[] = { +static const struct embkernel_params embkernel_params_list[] = { { "cortex_m", /* target_name */ 4, /* pointer_width */ @@ -92,7 +92,7 @@ static const struct embKernel_params embKernel_params_list[] = { 4, /*thread_priority_width */ 4, /*iterable_next_offset */ 12, /*iterable_task_owner_offset */ - &rtos_embkernel_Cortex_M_stacking, /* stacking_info*/ + &rtos_embkernel_cortex_m_stacking, /* stacking_info*/ }, { "hla_target", /* target_name */ 4, /* pointer_width */ @@ -104,11 +104,11 @@ static const struct embKernel_params embKernel_params_list[] = { 4, /*thread_priority_width */ 4, /*iterable_next_offset */ 12, /*iterable_task_owner_offset */ - &rtos_embkernel_Cortex_M_stacking, /* stacking_info */ + &rtos_embkernel_cortex_m_stacking, /* stacking_info */ } }; -static bool embKernel_detect_rtos(struct target *target) +static bool embkernel_detect_rtos(struct target *target) { if (target->rtos->symbols != NULL) { if (target->rtos->symbols[SYMBOL_ID_S_CURRENT_TASK].address != 0) @@ -117,24 +117,24 @@ static bool embKernel_detect_rtos(struct target *target) return false; } -static int embKernel_create(struct target *target) +static int embkernel_create(struct target *target) { size_t i = 0; - while ((i < ARRAY_SIZE(embKernel_params_list)) && - (0 != strcmp(embKernel_params_list[i].target_name, target->type->name))) + while ((i < ARRAY_SIZE(embkernel_params_list)) && + (0 != strcmp(embkernel_params_list[i].target_name, target->type->name))) i++; - if (i >= ARRAY_SIZE(embKernel_params_list)) { + if (i >= ARRAY_SIZE(embkernel_params_list)) { LOG_WARNING("Could not find target \"%s\" in embKernel compatibility " "list", target->type->name); return -1; } - target->rtos->rtos_specific_params = (void *) &embKernel_params_list[i]; + target->rtos->rtos_specific_params = (void *) &embkernel_params_list[i]; return 0; } -static int embKernel_get_tasks_details(struct rtos *rtos, int64_t iterable, const struct embKernel_params *param, +static int embkernel_get_tasks_details(struct rtos *rtos, int64_t iterable, const struct embkernel_params *param, struct thread_detail *details, const char *state_str) { int64_t task = 0; @@ -181,11 +181,11 @@ static int embKernel_get_tasks_details(struct rtos *rtos, int64_t iterable, cons return 0; } -static int embKernel_update_threads(struct rtos *rtos) +static int embkernel_update_threads(struct rtos *rtos) { /* int i = 0; */ int retval; - const struct embKernel_params *param; + const struct embkernel_params *param; if (rtos == NULL) return -1; @@ -206,7 +206,7 @@ static int embKernel_update_threads(struct rtos *rtos) /* wipe out previous thread details if any */ rtos_free_threadlist(rtos); - param = (const struct embKernel_params *) rtos->rtos_specific_params; + param = (const struct embkernel_params *) rtos->rtos_specific_params; retval = target_read_buffer(rtos->target, rtos->symbols[SYMBOL_ID_S_CURRENT_TASK].address, param->pointer_width, (uint8_t *) &rtos->current_thread); @@ -237,7 +237,7 @@ static int embKernel_update_threads(struct rtos *rtos) return ERROR_FAIL; } - int threadIdx = 0; + int thread_idx = 0; /* Look for ready tasks */ for (int pri = 0; pri < max_used_priority; pri++) { /* Get first item in queue */ @@ -247,9 +247,9 @@ static int embKernel_update_threads(struct rtos *rtos) (uint8_t *) &iterable); if (retval != ERROR_OK) return retval; - for (; iterable && threadIdx < thread_list_size; threadIdx++) { + for (; iterable && thread_idx < thread_list_size; thread_idx++) { /* Get info from this iterable item */ - retval = embKernel_get_tasks_details(rtos, iterable, param, &rtos->thread_details[threadIdx], "Ready"); + retval = embkernel_get_tasks_details(rtos, iterable, param, &rtos->thread_details[thread_idx], "Ready"); if (retval != ERROR_OK) return retval; /* Get next iterable item */ @@ -265,9 +265,9 @@ static int embKernel_update_threads(struct rtos *rtos) (uint8_t *) &iterable); if (retval != ERROR_OK) return retval; - for (; iterable && threadIdx < thread_list_size; threadIdx++) { + for (; iterable && thread_idx < thread_list_size; thread_idx++) { /*Get info from this iterable item */ - retval = embKernel_get_tasks_details(rtos, iterable, param, &rtos->thread_details[threadIdx], "Sleeping"); + retval = embkernel_get_tasks_details(rtos, iterable, param, &rtos->thread_details[thread_idx], "Sleeping"); if (retval != ERROR_OK) return retval; /*Get next iterable item */ @@ -283,9 +283,9 @@ static int embKernel_update_threads(struct rtos *rtos) (uint8_t *) &iterable); if (retval != ERROR_OK) return retval; - for (; iterable && threadIdx < thread_list_size; threadIdx++) { + for (; iterable && thread_idx < thread_list_size; thread_idx++) { /* Get info from this iterable item */ - retval = embKernel_get_tasks_details(rtos, iterable, param, &rtos->thread_details[threadIdx], "Suspended"); + retval = embkernel_get_tasks_details(rtos, iterable, param, &rtos->thread_details[thread_idx], "Suspended"); if (retval != ERROR_OK) return retval; /*Get next iterable item */ @@ -296,16 +296,16 @@ static int embKernel_update_threads(struct rtos *rtos) } rtos->thread_count = 0; - rtos->thread_count = threadIdx; - LOG_OUTPUT("Found %u tasks\n", (unsigned int)threadIdx); + rtos->thread_count = thread_idx; + LOG_OUTPUT("Found %u tasks\n", (unsigned int)thread_idx); return 0; } -static int embKernel_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, +static int embkernel_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, struct rtos_reg **reg_list, int *num_regs) { int retval; - const struct embKernel_params *param; + const struct embkernel_params *param; int64_t stack_ptr = 0; if (rtos == NULL) @@ -317,7 +317,7 @@ static int embKernel_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, if (rtos->rtos_specific_params == NULL) return -1; - param = (const struct embKernel_params *) rtos->rtos_specific_params; + param = (const struct embkernel_params *) rtos->rtos_specific_params; /* Read the stack pointer */ retval = target_read_buffer(rtos->target, thread_id + param->thread_stack_offset, param->pointer_width, @@ -330,13 +330,13 @@ static int embKernel_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, return rtos_generic_stack_read(rtos->target, param->stacking_info, stack_ptr, reg_list, num_regs); } -static int embKernel_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[]) +static int embkernel_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[]) { unsigned int i; - *symbol_list = calloc(ARRAY_SIZE(embKernel_symbol_list), sizeof(struct symbol_table_elem)); + *symbol_list = calloc(ARRAY_SIZE(embkernel_symbol_list), sizeof(struct symbol_table_elem)); - for (i = 0; i < ARRAY_SIZE(embKernel_symbol_list); i++) - (*symbol_list)[i].symbol_name = embKernel_symbol_list[i]; + for (i = 0; i < ARRAY_SIZE(embkernel_symbol_list); i++) + (*symbol_list)[i].symbol_name = embkernel_symbol_list[i]; return 0; } diff --git a/src/rtos/linux.c b/src/rtos/linux.c index 4b96a931d..0a15efaac 100644 --- a/src/rtos/linux.c +++ b/src/rtos/linux.c @@ -260,7 +260,7 @@ static int linux_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list static char *linux_ps_command(struct target *target); -const struct rtos_type Linux_os = { +const struct rtos_type linux_rtos = { .name = "linux", .detect_rtos = linux_os_detect, .create = linux_os_create, @@ -431,8 +431,8 @@ static int get_current(struct target *target, int create) buf = reg_list[13]->value; val = get_buffer(target, buf); ti_addr = (val & 0xffffe000); - uint32_t TS_addr = ti_addr + 0xc; - retval = fill_buffer(target, TS_addr, buffer); + uint32_t ts_addr = ti_addr + 0xc; + retval = fill_buffer(target, ts_addr, buffer); if (retval == ERROR_OK) { uint32_t TS = get_buffer(target, buffer); @@ -1163,7 +1163,7 @@ static int linux_thread_extra_info(struct target *target, return ERROR_OK; } -static int linux_gdb_T_packet(struct connection *connection, +static int linux_gdb_t_packet(struct connection *connection, struct target *target, char const *packet, int packet_size) { int64_t threadid; @@ -1304,7 +1304,7 @@ static int linux_thread_packet(struct connection *connection, char const *packet switch (packet[0]) { case 'T': /* Is thread alive?*/ - linux_gdb_T_packet(connection, target, packet, packet_size); + linux_gdb_t_packet(connection, target, packet, packet_size); break; case 'H': /* Set current thread */ /* ( 'c' for step and continue, 'g' for all other operations )*/ diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c index 0374e9b5b..5fc958db2 100644 --- a/src/rtos/rtos.c +++ b/src/rtos/rtos.c @@ -27,30 +27,30 @@ #include "server/gdb_server.h" /* RTOSs */ -extern struct rtos_type FreeRTOS_rtos; -extern struct rtos_type ThreadX_rtos; -extern struct rtos_type eCos_rtos; -extern struct rtos_type Linux_os; +extern struct rtos_type freertos_rtos; +extern struct rtos_type threadx_rtos; +extern struct rtos_type ecos_rtos; +extern struct rtos_type linux_rtos; extern struct rtos_type chibios_rtos; extern struct rtos_type chromium_ec_rtos; -extern struct rtos_type embKernel_rtos; +extern struct rtos_type embkernel_rtos; extern struct rtos_type mqx_rtos; -extern struct rtos_type uCOS_III_rtos; +extern struct rtos_type ucos_iii_rtos; extern struct rtos_type nuttx_rtos; extern struct rtos_type hwthread_rtos; extern struct rtos_type riot_rtos; extern struct rtos_type zephyr_rtos; static struct rtos_type *rtos_types[] = { - &ThreadX_rtos, - &FreeRTOS_rtos, - &eCos_rtos, - &Linux_os, + &threadx_rtos, + &freertos_rtos, + &ecos_rtos, + &linux_rtos, &chibios_rtos, &chromium_ec_rtos, - &embKernel_rtos, + &embkernel_rtos, &mqx_rtos, - &uCOS_III_rtos, + &ucos_iii_rtos, &nuttx_rtos, &riot_rtos, &zephyr_rtos, diff --git a/src/rtos/rtos_embkernel_stackings.c b/src/rtos/rtos_embkernel_stackings.c index 543a8cd2a..cd4c22eac 100644 --- a/src/rtos/rtos_embkernel_stackings.c +++ b/src/rtos/rtos_embkernel_stackings.c @@ -24,7 +24,7 @@ #include "target/armv7m.h" #include "rtos_standard_stackings.h" -static const struct stack_register_offset rtos_embkernel_Cortex_M_stack_offsets[ARMV7M_NUM_CORE_REGS] = { +static const struct stack_register_offset rtos_embkernel_cortex_m_stack_offsets[ARMV7M_NUM_CORE_REGS] = { { ARMV7M_R0, 0x24, 32 }, /* r0 */ { ARMV7M_R1, 0x28, 32 }, /* r1 */ { ARMV7M_R2, 0x2c, 32 }, /* r2 */ @@ -44,10 +44,10 @@ static const struct stack_register_offset rtos_embkernel_Cortex_M_stack_offsets[ { ARMV7M_xPSR, 0x40, 32 }, /* xPSR */ }; -const struct rtos_register_stacking rtos_embkernel_Cortex_M_stacking = { +const struct rtos_register_stacking rtos_embkernel_cortex_m_stacking = { 0x40, /* stack_registers_size */ -1, /* stack_growth_direction */ ARMV7M_NUM_CORE_REGS, /* num_output_registers */ rtos_generic_stack_align8, /* stack_alignment */ - rtos_embkernel_Cortex_M_stack_offsets /* register_offsets */ + rtos_embkernel_cortex_m_stack_offsets /* register_offsets */ }; diff --git a/src/rtos/rtos_embkernel_stackings.h b/src/rtos/rtos_embkernel_stackings.h index 89a0c2f12..7850bebcd 100644 --- a/src/rtos/rtos_embkernel_stackings.h +++ b/src/rtos/rtos_embkernel_stackings.h @@ -25,6 +25,6 @@ #include "rtos.h" -extern const struct rtos_register_stacking rtos_embkernel_Cortex_M_stacking; +extern const struct rtos_register_stacking rtos_embkernel_cortex_m_stacking; #endif /* OPENOCD_RTOS_RTOS_EMBKERNEL_STACKINGS_H */ diff --git a/src/rtos/rtos_riot_stackings.c b/src/rtos/rtos_riot_stackings.c index 23f4d1786..98e02edfc 100644 --- a/src/rtos/rtos_riot_stackings.c +++ b/src/rtos/rtos_riot_stackings.c @@ -32,7 +32,7 @@ static int64_t rtos_riot_cortex_m_stack_align(struct target *target, int64_t stack_ptr) { const int XPSR_OFFSET = 0x40; - return rtos_Cortex_M_stack_align(target, stack_data, stacking, + return rtos_cortex_m_stack_align(target, stack_data, stacking, stack_ptr, XPSR_OFFSET); } diff --git a/src/rtos/rtos_standard_stackings.c b/src/rtos/rtos_standard_stackings.c index 7b054cbbc..90c642a00 100644 --- a/src/rtos/rtos_standard_stackings.c +++ b/src/rtos/rtos_standard_stackings.c @@ -23,7 +23,7 @@ #include "rtos.h" #include "target/armv7m.h" -static const struct stack_register_offset rtos_standard_Cortex_M3_stack_offsets[ARMV7M_NUM_CORE_REGS] = { +static const struct stack_register_offset rtos_standard_cortex_m3_stack_offsets[ARMV7M_NUM_CORE_REGS] = { { ARMV7M_R0, 0x20, 32 }, /* r0 */ { ARMV7M_R1, 0x24, 32 }, /* r1 */ { ARMV7M_R2, 0x28, 32 }, /* r2 */ @@ -43,7 +43,7 @@ static const struct stack_register_offset rtos_standard_Cortex_M3_stack_offsets[ { ARMV7M_xPSR, 0x3c, 32 }, /* xPSR */ }; -static const struct stack_register_offset rtos_standard_Cortex_M4F_stack_offsets[] = { +static const struct stack_register_offset rtos_standard_cortex_m4f_stack_offsets[] = { { ARMV7M_R0, 0x24, 32 }, /* r0 */ { ARMV7M_R1, 0x28, 32 }, /* r1 */ { ARMV7M_R2, 0x2c, 32 }, /* r2 */ @@ -63,7 +63,7 @@ static const struct stack_register_offset rtos_standard_Cortex_M4F_stack_offsets { ARMV7M_xPSR, 0x40, 32 }, /* xPSR */ }; -static const struct stack_register_offset rtos_standard_Cortex_M4F_FPU_stack_offsets[] = { +static const struct stack_register_offset rtos_standard_cortex_m4f_fpu_stack_offsets[] = { { ARMV7M_R0, 0x64, 32 }, /* r0 */ { ARMV7M_R1, 0x68, 32 }, /* r1 */ { ARMV7M_R2, 0x6c, 32 }, /* r2 */ @@ -84,7 +84,7 @@ static const struct stack_register_offset rtos_standard_Cortex_M4F_FPU_stack_off }; -static const struct stack_register_offset rtos_standard_Cortex_R4_stack_offsets[] = { +static const struct stack_register_offset rtos_standard_cortex_r4_stack_offsets[] = { { 0, 0x08, 32 }, /* r0 (a1) */ { 1, 0x0c, 32 }, /* r1 (a2) */ { 2, 0x10, 32 }, /* r2 (a3) */ @@ -113,7 +113,7 @@ static const struct stack_register_offset rtos_standard_Cortex_R4_stack_offsets[ { 26, 0x04, 32 }, /* CSPR */ }; -static const struct stack_register_offset rtos_standard_NDS32_N1068_stack_offsets[] = { +static const struct stack_register_offset rtos_standard_nds32_n1068_stack_offsets[] = { { 0, 0x88, 32 }, /* R0 */ { 1, 0x8C, 32 }, /* R1 */ { 2, 0x14, 32 }, /* R2 */ @@ -199,7 +199,7 @@ int64_t rtos_generic_stack_align8(struct target *target, * This is just a helper function for use in the calculate_process_stack * function for a given architecture/rtos. */ -int64_t rtos_Cortex_M_stack_align(struct target *target, +int64_t rtos_cortex_m_stack_align(struct target *target, const uint8_t *stack_data, const struct rtos_register_stacking *stacking, int64_t stack_ptr, size_t xpsr_offset) { @@ -220,70 +220,70 @@ int64_t rtos_Cortex_M_stack_align(struct target *target, return new_stack_ptr; } -static int64_t rtos_standard_Cortex_M3_stack_align(struct target *target, +static int64_t rtos_standard_cortex_m3_stack_align(struct target *target, const uint8_t *stack_data, const struct rtos_register_stacking *stacking, int64_t stack_ptr) { const int XPSR_OFFSET = 0x3c; - return rtos_Cortex_M_stack_align(target, stack_data, stacking, + return rtos_cortex_m_stack_align(target, stack_data, stacking, stack_ptr, XPSR_OFFSET); } -static int64_t rtos_standard_Cortex_M4F_stack_align(struct target *target, +static int64_t rtos_standard_cortex_m4f_stack_align(struct target *target, const uint8_t *stack_data, const struct rtos_register_stacking *stacking, int64_t stack_ptr) { const int XPSR_OFFSET = 0x40; - return rtos_Cortex_M_stack_align(target, stack_data, stacking, + return rtos_cortex_m_stack_align(target, stack_data, stacking, stack_ptr, XPSR_OFFSET); } -static int64_t rtos_standard_Cortex_M4F_FPU_stack_align(struct target *target, +static int64_t rtos_standard_cortex_m4f_fpu_stack_align(struct target *target, const uint8_t *stack_data, const struct rtos_register_stacking *stacking, int64_t stack_ptr) { const int XPSR_OFFSET = 0x80; - return rtos_Cortex_M_stack_align(target, stack_data, stacking, + return rtos_cortex_m_stack_align(target, stack_data, stacking, stack_ptr, XPSR_OFFSET); } -const struct rtos_register_stacking rtos_standard_Cortex_M3_stacking = { +const struct rtos_register_stacking rtos_standard_cortex_m3_stacking = { 0x40, /* stack_registers_size */ -1, /* stack_growth_direction */ ARMV7M_NUM_CORE_REGS, /* num_output_registers */ - rtos_standard_Cortex_M3_stack_align, /* stack_alignment */ - rtos_standard_Cortex_M3_stack_offsets /* register_offsets */ + rtos_standard_cortex_m3_stack_align, /* stack_alignment */ + rtos_standard_cortex_m3_stack_offsets /* register_offsets */ }; -const struct rtos_register_stacking rtos_standard_Cortex_M4F_stacking = { +const struct rtos_register_stacking rtos_standard_cortex_m4f_stacking = { 0x44, /* stack_registers_size 4 more for LR*/ -1, /* stack_growth_direction */ ARMV7M_NUM_CORE_REGS, /* num_output_registers */ - rtos_standard_Cortex_M4F_stack_align, /* stack_alignment */ - rtos_standard_Cortex_M4F_stack_offsets /* register_offsets */ + rtos_standard_cortex_m4f_stack_align, /* stack_alignment */ + rtos_standard_cortex_m4f_stack_offsets /* register_offsets */ }; -const struct rtos_register_stacking rtos_standard_Cortex_M4F_FPU_stacking = { +const struct rtos_register_stacking rtos_standard_cortex_m4f_fpu_stacking = { 0xcc, /* stack_registers_size 4 more for LR + 48 more for FPU S0-S15 register*/ -1, /* stack_growth_direction */ ARMV7M_NUM_CORE_REGS, /* num_output_registers */ - rtos_standard_Cortex_M4F_FPU_stack_align, /* stack_alignment */ - rtos_standard_Cortex_M4F_FPU_stack_offsets /* register_offsets */ + rtos_standard_cortex_m4f_fpu_stack_align, /* stack_alignment */ + rtos_standard_cortex_m4f_fpu_stack_offsets /* register_offsets */ }; -const struct rtos_register_stacking rtos_standard_Cortex_R4_stacking = { +const struct rtos_register_stacking rtos_standard_cortex_r4_stacking = { 0x48, /* stack_registers_size */ -1, /* stack_growth_direction */ 26, /* num_output_registers */ rtos_generic_stack_align8, /* stack_alignment */ - rtos_standard_Cortex_R4_stack_offsets /* register_offsets */ + rtos_standard_cortex_r4_stack_offsets /* register_offsets */ }; -const struct rtos_register_stacking rtos_standard_NDS32_N1068_stacking = { +const struct rtos_register_stacking rtos_standard_nds32_n1068_stacking = { 0x90, /* stack_registers_size */ -1, /* stack_growth_direction */ 32, /* num_output_registers */ rtos_generic_stack_align8, /* stack_alignment */ - rtos_standard_NDS32_N1068_stack_offsets /* register_offsets */ + rtos_standard_nds32_n1068_stack_offsets /* register_offsets */ }; diff --git a/src/rtos/rtos_standard_stackings.h b/src/rtos/rtos_standard_stackings.h index 6971efd1e..ad319d2a0 100644 --- a/src/rtos/rtos_standard_stackings.h +++ b/src/rtos/rtos_standard_stackings.h @@ -25,15 +25,15 @@ #include "rtos.h" -extern const struct rtos_register_stacking rtos_standard_Cortex_M3_stacking; -extern const struct rtos_register_stacking rtos_standard_Cortex_M4F_stacking; -extern const struct rtos_register_stacking rtos_standard_Cortex_M4F_FPU_stacking; -extern const struct rtos_register_stacking rtos_standard_Cortex_R4_stacking; -extern const struct rtos_register_stacking rtos_standard_NDS32_N1068_stacking; +extern const struct rtos_register_stacking rtos_standard_cortex_m3_stacking; +extern const struct rtos_register_stacking rtos_standard_cortex_m4f_stacking; +extern const struct rtos_register_stacking rtos_standard_cortex_m4f_fpu_stacking; +extern const struct rtos_register_stacking rtos_standard_cortex_r4_stacking; +extern const struct rtos_register_stacking rtos_standard_nds32_n1068_stacking; int64_t rtos_generic_stack_align8(struct target *target, const uint8_t *stack_data, const struct rtos_register_stacking *stacking, int64_t stack_ptr); -int64_t rtos_Cortex_M_stack_align(struct target *target, +int64_t rtos_cortex_m_stack_align(struct target *target, const uint8_t *stack_data, const struct rtos_register_stacking *stacking, int64_t stack_ptr, size_t xpsr_offset); diff --git a/src/rtos/rtos_ucos_iii_stackings.c b/src/rtos/rtos_ucos_iii_stackings.c index d093563ba..4ae0d7dc8 100644 --- a/src/rtos/rtos_ucos_iii_stackings.c +++ b/src/rtos/rtos_ucos_iii_stackings.c @@ -26,7 +26,7 @@ #include #include -static const struct stack_register_offset rtos_uCOS_III_Cortex_M_stack_offsets[] = { +static const struct stack_register_offset rtos_ucos_iii_cortex_m_stack_offsets[] = { { ARMV7M_R0, 0x20, 32 }, /* r0 */ { ARMV7M_R1, 0x24, 32 }, /* r1 */ { ARMV7M_R2, 0x28, 32 }, /* r2 */ @@ -46,7 +46,7 @@ static const struct stack_register_offset rtos_uCOS_III_Cortex_M_stack_offsets[] { ARMV7M_xPSR, 0x3c, 32 }, /* xPSR */ }; -static const struct stack_register_offset rtos_uCOS_III_eSi_RISC_stack_offsets[] = { +static const struct stack_register_offset rtos_ucos_iii_esi_risc_stack_offsets[] = { { ESIRISC_SP, -2, 32 }, /* sp */ { ESIRISC_RA, 0x48, 32 }, /* ra */ { ESIRISC_R2, 0x44, 32 }, /* r2 */ @@ -67,18 +67,18 @@ static const struct stack_register_offset rtos_uCOS_III_eSi_RISC_stack_offsets[] { ESIRISC_CAS, 0x08, 32 }, /* CAS */ }; -const struct rtos_register_stacking rtos_uCOS_III_Cortex_M_stacking = { +const struct rtos_register_stacking rtos_ucos_iii_cortex_m_stacking = { 0x40, /* stack_registers_size */ -1, /* stack_growth_direction */ - ARRAY_SIZE(rtos_uCOS_III_Cortex_M_stack_offsets), /* num_output_registers */ + ARRAY_SIZE(rtos_ucos_iii_cortex_m_stack_offsets), /* num_output_registers */ rtos_generic_stack_align8, /* stack_alignment */ - rtos_uCOS_III_Cortex_M_stack_offsets /* register_offsets */ + rtos_ucos_iii_cortex_m_stack_offsets /* register_offsets */ }; -const struct rtos_register_stacking rtos_uCOS_III_eSi_RISC_stacking = { +const struct rtos_register_stacking rtos_ucos_iii_esi_risc_stacking = { 0x4c, /* stack_registers_size */ -1, /* stack_growth_direction */ - ARRAY_SIZE(rtos_uCOS_III_eSi_RISC_stack_offsets), /* num_output_registers */ + ARRAY_SIZE(rtos_ucos_iii_esi_risc_stack_offsets), /* num_output_registers */ NULL, /* stack_alignment */ - rtos_uCOS_III_eSi_RISC_stack_offsets /* register_offsets */ + rtos_ucos_iii_esi_risc_stack_offsets /* register_offsets */ }; diff --git a/src/rtos/rtos_ucos_iii_stackings.h b/src/rtos/rtos_ucos_iii_stackings.h index a9398138b..f2f120fd9 100644 --- a/src/rtos/rtos_ucos_iii_stackings.h +++ b/src/rtos/rtos_ucos_iii_stackings.h @@ -25,7 +25,7 @@ #include -extern const struct rtos_register_stacking rtos_uCOS_III_Cortex_M_stacking; -extern const struct rtos_register_stacking rtos_uCOS_III_eSi_RISC_stacking; +extern const struct rtos_register_stacking rtos_ucos_iii_cortex_m_stacking; +extern const struct rtos_register_stacking rtos_ucos_iii_esi_risc_stacking; #endif /* OPENOCD_RTOS_RTOS_UCOS_III_STACKINGS_H */ diff --git a/src/rtos/uCOS-III.c b/src/rtos/uCOS-III.c index 1aed4846f..26b53a927 100644 --- a/src/rtos/uCOS-III.c +++ b/src/rtos/uCOS-III.c @@ -37,7 +37,7 @@ #define UCOS_III_MAX_THREADS 256 #endif -struct uCOS_III_params { +struct ucos_iii_params { const char *target_name; const unsigned char pointer_width; symbol_address_t thread_stack_offset; @@ -53,7 +53,7 @@ struct uCOS_III_params { symbol_address_t threads[]; }; -static const struct uCOS_III_params uCOS_III_params_list[] = { +static const struct ucos_iii_params ucos_iii_params_list[] = { { "cortex_m", /* target_name */ sizeof(uint32_t), /* pointer_width */ @@ -65,7 +65,7 @@ static const struct uCOS_III_params uCOS_III_params_list[] = { 0, /* thread_next_offset */ false, /* thread_offsets_updated */ 1, /* threadid_start */ - &rtos_uCOS_III_Cortex_M_stacking, /* stacking_info */ + &rtos_ucos_iii_cortex_m_stacking, /* stacking_info */ 0, /* num_threads */ }, { @@ -79,12 +79,12 @@ static const struct uCOS_III_params uCOS_III_params_list[] = { 0, /* thread_next_offset */ false, /* thread_offsets_updated */ 1, /* threadid_start */ - &rtos_uCOS_III_eSi_RISC_stacking, /* stacking_info */ + &rtos_ucos_iii_esi_risc_stacking, /* stacking_info */ 0, /* num_threads */ }, }; -static const char * const uCOS_III_symbol_list[] = { +static const char * const ucos_iii_symbol_list[] = { "OSRunning", "OSTCBCurPtr", "OSTaskDbgListPtr", @@ -100,7 +100,7 @@ static const char * const uCOS_III_symbol_list[] = { NULL }; -enum uCOS_III_symbol_values { +enum ucos_iii_symbol_values { UCOS_III_VAL_OS_RUNNING, UCOS_III_VAL_OS_TCB_CUR_PTR, UCOS_III_VAL_OS_TASK_DBG_LIST_PTR, @@ -115,7 +115,7 @@ enum uCOS_III_symbol_values { UCOS_III_VAL_OS_TCB_DBG_NEXT_PTR_OFFSET, }; -static const char * const uCOS_III_thread_state_list[] = { +static const char * const ucos_iii_thread_state_list[] = { "Ready", "Delay", "Pend", @@ -126,10 +126,10 @@ static const char * const uCOS_III_thread_state_list[] = { "Pend Timeout Suspended", }; -static int uCOS_III_find_or_create_thread(struct rtos *rtos, symbol_address_t thread_address, +static int ucos_iii_find_or_create_thread(struct rtos *rtos, symbol_address_t thread_address, threadid_t *threadid) { - struct uCOS_III_params *params = rtos->rtos_specific_params; + struct ucos_iii_params *params = rtos->rtos_specific_params; size_t thread_index; for (thread_index = 0; thread_index < params->num_threads; thread_index++) @@ -148,10 +148,10 @@ found: return ERROR_OK; } -static int uCOS_III_find_thread_address(struct rtos *rtos, threadid_t threadid, +static int ucos_iii_find_thread_address(struct rtos *rtos, threadid_t threadid, symbol_address_t *thread_address) { - struct uCOS_III_params *params = rtos->rtos_specific_params; + struct ucos_iii_params *params = rtos->rtos_specific_params; size_t thread_index; thread_index = threadid - params->threadid_start; @@ -164,9 +164,9 @@ static int uCOS_III_find_thread_address(struct rtos *rtos, threadid_t threadid, return ERROR_OK; } -static int uCOS_III_find_last_thread_address(struct rtos *rtos, symbol_address_t *thread_address) +static int ucos_iii_find_last_thread_address(struct rtos *rtos, symbol_address_t *thread_address) { - struct uCOS_III_params *params = rtos->rtos_specific_params; + struct ucos_iii_params *params = rtos->rtos_specific_params; int retval; /* read the thread list head */ @@ -200,15 +200,15 @@ static int uCOS_III_find_last_thread_address(struct rtos *rtos, symbol_address_t return ERROR_OK; } -static int uCOS_III_update_thread_offsets(struct rtos *rtos) +static int ucos_iii_update_thread_offsets(struct rtos *rtos) { - struct uCOS_III_params *params = rtos->rtos_specific_params; + struct ucos_iii_params *params = rtos->rtos_specific_params; if (params->thread_offsets_updated) return ERROR_OK; const struct thread_offset_map { - enum uCOS_III_symbol_values symbol_value; + enum ucos_iii_symbol_values symbol_value; symbol_address_t *thread_offset; } thread_offset_maps[] = { { @@ -255,15 +255,15 @@ static int uCOS_III_update_thread_offsets(struct rtos *rtos) return ERROR_OK; } -static bool uCOS_III_detect_rtos(struct target *target) +static bool ucos_iii_detect_rtos(struct target *target) { return target->rtos->symbols != NULL && target->rtos->symbols[UCOS_III_VAL_OS_RUNNING].address != 0; } -static int uCOS_III_reset_handler(struct target *target, enum target_reset_mode reset_mode, void *priv) +static int ucos_iii_reset_handler(struct target *target, enum target_reset_mode reset_mode, void *priv) { - struct uCOS_III_params *params = target->rtos->rtos_specific_params; + struct ucos_iii_params *params = target->rtos->rtos_specific_params; params->thread_offsets_updated = false; params->num_threads = 0; @@ -271,22 +271,22 @@ static int uCOS_III_reset_handler(struct target *target, enum target_reset_mode return ERROR_OK; } -static int uCOS_III_create(struct target *target) +static int ucos_iii_create(struct target *target) { - struct uCOS_III_params *params; + struct ucos_iii_params *params; - for (size_t i = 0; i < ARRAY_SIZE(uCOS_III_params_list); i++) - if (strcmp(uCOS_III_params_list[i].target_name, target->type->name) == 0) { + for (size_t i = 0; i < ARRAY_SIZE(ucos_iii_params_list); i++) + if (strcmp(ucos_iii_params_list[i].target_name, target->type->name) == 0) { params = malloc(sizeof(*params) + (UCOS_III_MAX_THREADS * sizeof(*params->threads))); if (params == NULL) { LOG_ERROR("uCOS-III: out of memory"); return ERROR_FAIL; } - memcpy(params, &uCOS_III_params_list[i], sizeof(uCOS_III_params_list[i])); + memcpy(params, &ucos_iii_params_list[i], sizeof(ucos_iii_params_list[i])); target->rtos->rtos_specific_params = (void *)params; - target_register_reset_callback(uCOS_III_reset_handler, NULL); + target_register_reset_callback(ucos_iii_reset_handler, NULL); return ERROR_OK; } @@ -295,9 +295,9 @@ static int uCOS_III_create(struct target *target) return ERROR_FAIL; } -static int uCOS_III_update_threads(struct rtos *rtos) +static int ucos_iii_update_threads(struct rtos *rtos) { - struct uCOS_III_params *params = rtos->rtos_specific_params; + struct ucos_iii_params *params = rtos->rtos_specific_params; int retval; if (rtos->symbols == NULL) { @@ -340,7 +340,7 @@ static int uCOS_III_update_threads(struct rtos *rtos) } /* update thread offsets */ - retval = uCOS_III_update_thread_offsets(rtos); + retval = ucos_iii_update_thread_offsets(rtos); if (retval != ERROR_OK) { LOG_ERROR("uCOS-III: failed to update thread offsets"); return retval; @@ -380,7 +380,7 @@ static int uCOS_III_update_threads(struct rtos *rtos) */ symbol_address_t thread_address = 0; - retval = uCOS_III_find_last_thread_address(rtos, &thread_address); + retval = ucos_iii_find_last_thread_address(rtos, &thread_address); if (retval != ERROR_OK) { LOG_ERROR("uCOS-III: failed to find last thread address"); return retval; @@ -391,7 +391,7 @@ static int uCOS_III_update_threads(struct rtos *rtos) char thread_str_buffer[UCOS_III_MAX_STRLEN + 1]; /* find or create new threadid */ - retval = uCOS_III_find_or_create_thread(rtos, thread_address, &thread_detail->threadid); + retval = ucos_iii_find_or_create_thread(rtos, thread_address, &thread_detail->threadid); if (retval != ERROR_OK) { LOG_ERROR("uCOS-III: failed to find or create thread"); return retval; @@ -449,8 +449,8 @@ static int uCOS_III_update_threads(struct rtos *rtos) const char *thread_state_str; - if (thread_state < ARRAY_SIZE(uCOS_III_thread_state_list)) - thread_state_str = uCOS_III_thread_state_list[thread_state]; + if (thread_state < ARRAY_SIZE(ucos_iii_thread_state_list)) + thread_state_str = ucos_iii_thread_state_list[thread_state]; else thread_state_str = "Unknown"; @@ -473,16 +473,16 @@ static int uCOS_III_update_threads(struct rtos *rtos) return ERROR_OK; } -static int uCOS_III_get_thread_reg_list(struct rtos *rtos, threadid_t threadid, +static int ucos_iii_get_thread_reg_list(struct rtos *rtos, threadid_t threadid, struct rtos_reg **reg_list, int *num_regs) { - struct uCOS_III_params *params = rtos->rtos_specific_params; + struct ucos_iii_params *params = rtos->rtos_specific_params; int retval; /* find thread address for threadid */ symbol_address_t thread_address = 0; - retval = uCOS_III_find_thread_address(rtos, threadid, &thread_address); + retval = ucos_iii_find_thread_address(rtos, threadid, &thread_address); if (retval != ERROR_OK) { LOG_ERROR("uCOS-III: failed to find thread address"); return retval; @@ -508,25 +508,25 @@ static int uCOS_III_get_thread_reg_list(struct rtos *rtos, threadid_t threadid, num_regs); } -static int uCOS_III_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[]) +static int ucos_iii_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[]) { - *symbol_list = calloc(ARRAY_SIZE(uCOS_III_symbol_list), sizeof(struct symbol_table_elem)); + *symbol_list = calloc(ARRAY_SIZE(ucos_iii_symbol_list), sizeof(struct symbol_table_elem)); if (*symbol_list == NULL) { LOG_ERROR("uCOS-III: out of memory"); return ERROR_FAIL; } - for (size_t i = 0; i < ARRAY_SIZE(uCOS_III_symbol_list); i++) - (*symbol_list)[i].symbol_name = uCOS_III_symbol_list[i]; + for (size_t i = 0; i < ARRAY_SIZE(ucos_iii_symbol_list); i++) + (*symbol_list)[i].symbol_name = ucos_iii_symbol_list[i]; return ERROR_OK; } -const struct rtos_type uCOS_III_rtos = { +const struct rtos_type ucos_iii_rtos = { .name = "uCOS-III", - .detect_rtos = uCOS_III_detect_rtos, - .create = uCOS_III_create, - .update_threads = uCOS_III_update_threads, - .get_thread_reg_list = uCOS_III_get_thread_reg_list, - .get_symbol_list_to_lookup = uCOS_III_get_symbol_list_to_lookup, + .detect_rtos = ucos_iii_detect_rtos, + .create = ucos_iii_create, + .update_threads = ucos_iii_update_threads, + .get_thread_reg_list = ucos_iii_get_thread_reg_list, + .get_symbol_list_to_lookup = ucos_iii_get_symbol_list_to_lookup, }; diff --git a/src/rtos/zephyr.c b/src/rtos/zephyr.c index e5d683507..b594b2b53 100644 --- a/src/rtos/zephyr.c +++ b/src/rtos/zephyr.c @@ -193,7 +193,7 @@ static int64_t zephyr_cortex_m_stack_align(struct target *target, const uint8_t *stack_data, const struct rtos_register_stacking *stacking, int64_t stack_ptr) { - return rtos_Cortex_M_stack_align(target, stack_data, stacking, + return rtos_cortex_m_stack_align(target, stack_data, stacking, stack_ptr, ARM_XPSR_OFFSET); }