rtos: constify symbol names and lists

Change-Id: I72f3cd50fc6a33a178e72e169c9660e707751524
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2292
Tested-by: jenkins
This commit is contained in:
Spencer Oliver 2014-09-11 22:07:10 +01:00
parent 40815bd39a
commit 03410e92da
8 changed files with 28 additions and 29 deletions

View File

@ -36,7 +36,6 @@
#include "helper/types.h"
#include "rtos_chibios_stackings.h"
/**
* @brief ChibiOS/RT memory signature record.
*
@ -72,7 +71,7 @@ struct ChibiOS_chdebug {
/**
* @brief ChibiOS thread states.
*/
const char *ChibiOS_thread_states[] = {
static const char * const ChibiOS_thread_states[] = {
"READY", "CURRENT", "SUSPENDED", "WTSEM", "WTMTX", "WTCOND", "SLEEPING",
"WTEXIT", "WTOREVT", "WTANDEVT", "SNDMSGQ", "SNDMSG", "WTMSG", "WTQUEUE",
"FINAL"
@ -92,7 +91,7 @@ struct ChibiOS_params {
const struct rtos_register_stacking *stacking_info;
};
struct ChibiOS_params ChibiOS_params_list[] = {
static const struct ChibiOS_params ChibiOS_params_list[] = {
{
"cortex_m", /* target_name */
0,
@ -128,7 +127,7 @@ enum ChibiOS_symbol_values {
ChibiOS_VAL_chSysInit = 2
};
static char *ChibiOS_symbol_list[] = {
static const char * const ChibiOS_symbol_list[] = {
"rlist", /* Thread ready list*/
"ch_debug", /* Memory Signatur containing offsets of fields in rlist*/
"chSysInit", /* Necessary part of API, used for ChibiOS detection*/
@ -539,6 +538,6 @@ static int ChibiOS_create(struct target *target)
return -1;
}
target->rtos->rtos_specific_params = &ChibiOS_params_list[i];
target->rtos->rtos_specific_params = (void *) &ChibiOS_params_list[i];
return 0;
}

View File

@ -48,7 +48,7 @@ struct FreeRTOS_params {
const struct rtos_register_stacking *stacking_info;
};
const struct FreeRTOS_params FreeRTOS_params_list[] = {
static const struct FreeRTOS_params FreeRTOS_params_list[] = {
{
"cortex_m", /* target_name */
4, /* thread_count_width; */
@ -119,7 +119,7 @@ enum FreeRTOS_symbol_values {
FreeRTOS_VAL_uxTopUsedPriority = 10,
};
static char *FreeRTOS_symbol_list[] = {
static const char * const FreeRTOS_symbol_list[] = {
"pxCurrentTCB",
"pxReadyTasksLists",
"xDelayedTaskList1",

View File

@ -39,10 +39,10 @@ static int ThreadX_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[])
struct ThreadX_thread_state {
int value;
char *desc;
const char *desc;
};
struct ThreadX_thread_state ThreadX_thread_states[] = {
static const struct ThreadX_thread_state ThreadX_thread_states[] = {
{ 0, "Ready" },
{ 1, "Completed" },
{ 2, "Terminated" },
@ -62,7 +62,7 @@ struct ThreadX_thread_state ThreadX_thread_states[] = {
#define THREADX_NUM_STATES (sizeof(ThreadX_thread_states)/sizeof(struct ThreadX_thread_state))
struct ThreadX_params {
char *target_name;
const char *target_name;
unsigned char pointer_width;
unsigned char thread_stack_offset;
unsigned char thread_name_offset;
@ -71,7 +71,7 @@ struct ThreadX_params {
const struct rtos_register_stacking *stacking_info;
};
const struct ThreadX_params ThreadX_params_list[] = {
static const struct ThreadX_params ThreadX_params_list[] = {
{
"cortex_m", /* target_name */
4, /* pointer_width; */
@ -100,7 +100,7 @@ enum ThreadX_symbol_values {
ThreadX_VAL_tx_thread_created_count = 2,
};
static char *ThreadX_symbol_list[] = {
static const char * const ThreadX_symbol_list[] = {
"_tx_thread_current_ptr",
"_tx_thread_created_ptr",
"_tx_thread_created_count",
@ -115,7 +115,6 @@ const struct rtos_type ThreadX_rtos = {
.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 int ThreadX_update_threads(struct rtos *rtos)
@ -262,7 +261,7 @@ static int ThreadX_update_threads(struct rtos *rtos)
/* empty */
}
char *state_desc;
const char *state_desc;
if (i < THREADX_NUM_STATES)
state_desc = ThreadX_thread_states[i].desc;
else

View File

@ -37,10 +37,10 @@ static int eCos_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[]);
struct eCos_thread_state {
int value;
char *desc;
const char *desc;
};
struct eCos_thread_state eCos_thread_states[] = {
static const struct eCos_thread_state eCos_thread_states[] = {
{ 0, "Ready" },
{ 1, "Sleeping" },
{ 2, "Countsleep" },
@ -52,7 +52,7 @@ struct eCos_thread_state eCos_thread_states[] = {
#define ECOS_NUM_STATES (sizeof(eCos_thread_states)/sizeof(struct eCos_thread_state))
struct eCos_params {
char *target_name;
const char *target_name;
unsigned char pointer_width;
unsigned char thread_stack_offset;
unsigned char thread_name_offset;
@ -62,7 +62,7 @@ struct eCos_params {
const struct rtos_register_stacking *stacking_info;
};
const struct eCos_params eCos_params_list[] = {
static const struct eCos_params eCos_params_list[] = {
{
"cortex_m", /* target_name */
4, /* pointer_width; */
@ -82,7 +82,7 @@ enum eCos_symbol_values {
eCos_VAL_current_thread_ptr = 1
};
static char *eCos_symbol_list[] = {
static const char * const eCos_symbol_list[] = {
"Cyg_Thread::thread_list",
"Cyg_Scheduler_Base::current_thread",
NULL
@ -257,7 +257,7 @@ static int eCos_update_threads(struct rtos *rtos)
*/
}
char *state_desc;
const char *state_desc;
if (i < ECOS_NUM_STATES)
state_desc = eCos_thread_states[i].desc;
else

View File

@ -58,7 +58,7 @@ enum {
SYMBOL_ID_sCurrentTaskCount = 5,
};
static char *embKernel_symbol_list[] = {
static const char * const embKernel_symbol_list[] = {
"Rtos::sCurrentTask",
"Rtos::sListReady",
"Rtos::sListSleep",
@ -81,7 +81,7 @@ struct embKernel_params {
const struct rtos_register_stacking *stacking_info;
};
struct embKernel_params embKernel_params_list[] = {
static const struct embKernel_params embKernel_params_list[] = {
{
"cortex_m", /* target_name */
4, /* pointer_width */
@ -131,7 +131,7 @@ static int embKernel_create(struct target *target)
return -1;
}
target->rtos->rtos_specific_params = &embKernel_params_list[i];
target->rtos->rtos_specific_params = (void *) &embKernel_params_list[i];
return 0;
}

View File

@ -40,7 +40,7 @@
#define MAX_THREADS 200
/* specific task */
struct linux_os {
char *name;
const char *name;
uint32_t init_task_addr;
int thread_count;
int threadid_count;
@ -320,7 +320,7 @@ static int linux_os_detect(struct target *target)
static int linux_os_smp_init(struct target *target);
static int linux_os_clean(struct target *target);
#define INIT_TASK 0
static char *linux_symbol_list[] = {
static const char * const linux_symbol_list[] = {
"init_task",
NULL
};

View File

@ -147,7 +147,7 @@ int gdb_thread_packet(struct connection *connection, char const *packet, int pac
return target->rtos->gdb_thread_packet(connection, packet, packet_size);
}
static char *next_symbol(struct rtos *os, char *cur_symbol, uint64_t cur_addr)
static const char *next_symbol(struct rtos *os, char *cur_symbol, uint64_t cur_addr)
{
symbol_table_elem_t *s;
@ -191,7 +191,8 @@ int rtos_qsymbol(struct connection *connection, char const *packet, int packet_s
int rtos_detected = 0;
uint64_t addr = 0;
size_t reply_len;
char reply[GDB_BUFFER_SIZE], cur_sym[GDB_BUFFER_SIZE / 2] = "", *next_sym;
char reply[GDB_BUFFER_SIZE], cur_sym[GDB_BUFFER_SIZE / 2] = "";
const char *next_sym;
struct target *target = get_target_from_connection(connection);
struct rtos *os = target->rtos;

View File

@ -33,7 +33,7 @@ struct reg;
* Table should be terminated by an element with NULL in symbol_name
*/
typedef struct symbol_table_elem_struct {
char *symbol_name;
const char *symbol_name;
symbol_address_t address;
} symbol_table_elem_t;
@ -61,7 +61,7 @@ struct rtos {
};
struct rtos_type {
char *name;
const char *name;
int (*detect_rtos)(struct target *target);
int (*create)(struct target *target);
int (*smp_init)(struct target *target);