rtos: constify symbol names and lists
authorSpencer Oliver <spen@spen-soft.co.uk>
Thu, 11 Sep 2014 21:07:10 +0000 (22:07 +0100)
committerSpencer Oliver <spen@spen-soft.co.uk>
Mon, 6 Oct 2014 11:57:29 +0000 (11:57 +0000)
Change-Id: I72f3cd50fc6a33a178e72e169c9660e707751524
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2292
Tested-by: jenkins
src/rtos/ChibiOS.c
src/rtos/FreeRTOS.c
src/rtos/ThreadX.c
src/rtos/eCos.c
src/rtos/embKernel.c
src/rtos/linux.c
src/rtos/rtos.c
src/rtos/rtos.h

index 85da6f8114a460439c153d826ec8ad65e518ffc4..46fdca323fcdf7ec1bb3bb80288a0d4c427931b4 100644 (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;
 }
index 57307d5f24c7e53619b489d05302fd56c042f8f5..1e699c6adfe1983256c3bc76741fafc8dcc1c035 100644 (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",
index 50df9ecd9290975d6a723a67af94c77d1710f7ee..88470b62ff198c6a83ace509a08286bbc41edb23 100644 (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
index 742437bb0146b8426f6e24b95e05784ae588fc48..62fb3b7bc29aa4a5f4e474c2006d330836dd8dfc 100644 (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
index 9f5fa50f073e179529616a501f98b26ed33aaa3c..6cb42d14e8577cf543cb35a3804d5f234cdea39e 100644 (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;
 }
 
index f2a48a2559702a45efe5cc1e190447831a546f20..9021d8c25476684f98032ebe11a002aa44b0646a 100644 (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
 };
index 9ceeb2610cc482279cfafe8ee7775d73c09c7dc4..735c1065b576ccde05586e6f00c1c859ec1d3467 100644 (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;
 
index a81f67e216bd4d3deacd1f8126cca8c0ce31128c..980d95d51802e03f165ded8e257bd2a240d1a46a 100644 (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);