This is an automated email from Gerrit.

Vianney le Clément de Saint-Marcq (vianney.leclem...@essensium.com) just 
uploaded a new patch set to Gerrit, which you can find at 
http://openocd.zylin.com/2806

-- gerrit

commit 77af13af4f208d1e91662cc66ee262f72541daf8
Author: Vianney le Clément de Saint-Marcq <vianney.leclem...@essensium.com>
Date:   Wed Jun 3 09:21:46 2015 +0200

    rtos/ThreadX: Add support for ARM926EJ-S
    
    Add ThreadX support for arm926ejs target.  This patch was orginally
    written and submitted by Alexander Drozdov on the openocd-devel mailing
    list on 2015-01-29 [1].
    
    There are two types of stacking, depending on the execution context:
    * Normal, saving only R4-R11, R14, and CPSR registers, and
    * Interrupt, saving all registers.
    
    The context is indicated by the first 32-bit word on the stack: 0x0 for
    a normal context, 0x1 for an interrupt context.
    
    The patch has been tested on a Cypress FX3 chip.
    
    [1] http://sourceforge.net/p/openocd/mailman/message/33287429/
    
    Change-Id: Icb2ed10df32e20e618fdafc7f91cb2abfb4d910f
    Signed-off-by: Vianney le Clément de Saint-Marcq 
<vianney.leclem...@essensium.com>
    Cc: Alexander Drozdov <adrozd...@gmail.com>

diff --git a/src/rtos/ThreadX.c b/src/rtos/ThreadX.c
index fb9f5f7..527faef 100644
--- a/src/rtos/ThreadX.c
+++ b/src/rtos/ThreadX.c
@@ -37,6 +37,9 @@ static int ThreadX_update_threads(struct rtos *rtos);
 static int ThreadX_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, 
char **hex_reg_list);
 static int ThreadX_get_symbol_list_to_lookup(symbol_table_elem_t 
*symbol_list[]);
 
+static const struct rtos_register_stacking *get_stacking_info(struct rtos 
*rtos, int64_t stack_ptr);
+static const struct rtos_register_stacking *get_stacking_info_arm926ejs(struct 
rtos *rtos, int64_t stack_ptr);
+
 struct ThreadX_thread_state {
        int value;
        const char *desc;
@@ -69,6 +72,7 @@ struct ThreadX_params {
        unsigned char thread_state_offset;
        unsigned char thread_next_offset;
        const struct rtos_register_stacking *stacking_info;
+       const struct rtos_register_stacking *(*get_stacking_info)(struct rtos 
*rtos, int64_t stack_ptr);
 };
 
 static const struct ThreadX_params ThreadX_params_list[] = {
@@ -80,6 +84,7 @@ static const struct ThreadX_params ThreadX_params_list[] = {
        48,                                                     /* 
thread_state_offset; */
        136,                                            /* thread_next_offset */
        &rtos_standard_Cortex_M3_stacking,      /* stacking_info */
+       NULL,                                           /* get_stacking_info */
        },
        {
        "cortex_r4",                            /* target_name */
@@ -89,6 +94,17 @@ static const struct ThreadX_params ThreadX_params_list[] = {
        48,                                                     /* 
thread_state_offset; */
        136,                                            /* thread_next_offset */
        &rtos_standard_Cortex_R4_stacking,      /* stacking_info */
+       NULL,                                           /* get_stacking_info */
+       },
+       {
+       "arm926ejs",                            /* target_name */
+       4,                                                      /* 
pointer_width; */
+       8,                                                      /* 
thread_stack_offset; */
+       40,                                                     /* 
thread_name_offset; */
+       48,                                                     /* 
thread_state_offset; */
+       136,                                            /* thread_next_offset */
+       rtos_standard_arm926ejs_stackings,      /* stacking_info */
+       get_stacking_info_arm926ejs,    /* get_stacking_info */
        },
 };
 
@@ -117,6 +133,33 @@ const struct rtos_type ThreadX_rtos = {
        .get_symbol_list_to_lookup = ThreadX_get_symbol_list_to_lookup,
 };
 
+static const struct rtos_register_stacking* get_stacking_info(struct rtos 
*rtos, int64_t stack_ptr)
+{
+       const struct ThreadX_params *param = rtos->rtos_specific_params;
+
+       if (param->get_stacking_info != NULL)
+               return param->get_stacking_info(rtos, stack_ptr);
+       else
+               return param->stacking_info;
+}
+
+static const struct rtos_register_stacking* get_stacking_info_arm926ejs(struct 
rtos *rtos, int64_t stack_ptr)
+{
+       const struct ThreadX_params *param = rtos->rtos_specific_params;
+       int retval;
+       uint32_t flag;
+
+       retval = target_read_buffer(rtos->target, stack_ptr,
+                                                               sizeof(flag), 
(uint8_t *)&flag);
+       if (retval != ERROR_OK)
+               return NULL;
+
+       if (flag == 0)
+               return &param->stacking_info[0];
+       else
+               return &param->stacking_info[1];
+}
+
 static int ThreadX_update_threads(struct rtos *rtos)
 {
        int retval;
@@ -299,13 +342,14 @@ static int ThreadX_get_thread_reg_list(struct rtos *rtos, 
int64_t thread_id, cha
 {
        int retval;
        const struct ThreadX_params *param;
+       const struct rtos_register_stacking *stacking_info;
 
        *hex_reg_list = NULL;
 
        if (rtos == NULL)
                return -1;
 
-       if (thread_id == 0)
+       if (thread_id == 0 || thread_id == 1)
                return -2;
 
        if (rtos->rtos_specific_params == NULL)
@@ -323,8 +367,19 @@ static int ThreadX_get_thread_reg_list(struct rtos *rtos, 
int64_t thread_id, cha
                LOG_ERROR("Error reading stack frame from ThreadX thread");
                return retval;
        }
+       if (stack_ptr == 0) {
+               LOG_ERROR("Null stack pointer in ThreadX thread");
+               return -5;
+       }
+
+       /* Get corresponding stacking info */
+       stacking_info = get_stacking_info(rtos, stack_ptr);
+       if (stacking_info == NULL) {
+               LOG_ERROR("Unknown stacking info for ThreadX thread");
+               return -6;
+       }
 
-       return rtos_generic_stack_read(rtos->target, param->stacking_info, 
stack_ptr, hex_reg_list);
+       return rtos_generic_stack_read(rtos->target, stacking_info, stack_ptr, 
hex_reg_list);
 }
 
 static int ThreadX_get_symbol_list_to_lookup(symbol_table_elem_t 
*symbol_list[])
diff --git a/src/rtos/rtos_standard_stackings.c 
b/src/rtos/rtos_standard_stackings.c
index 2eab86f..3b1c7b5 100644
--- a/src/rtos/rtos_standard_stackings.c
+++ b/src/rtos/rtos_standard_stackings.c
@@ -113,6 +113,46 @@ static const struct stack_register_offset 
rtos_standard_NDS32_N1068_stack_offset
        { 0x10, 32 },           /* IFC_LP */
 };
 
+static const struct stack_register_offset 
rtos_standard_arm926ejs_stack_offsets_normal[] = {
+       { -1,   32 },           /* r0       */
+       { -1,   32 },           /* r1       */
+       { -1,   32 },           /* r2       */
+       { -1,   32 },           /* r3       */
+       { 0x08, 32 },           /* r4       */
+       { 0x0C, 32 },           /* r5       */
+       { 0x10, 32 },           /* r6       */
+       { 0x14, 32 },           /* r7       */
+       { 0x18, 32 },           /* r8       */
+       { 0x1C, 32 },           /* r9       */
+       { 0x20, 32 },           /* r10      */
+       { 0x24, 32 },           /* r11      */
+       { -1,   32 },           /* r12      */
+       { -2,   32 },           /* sp (r13) */
+       { 0x28, 32 },           /* lr (r14) */
+       { -1,   32 },           /* pc (r15) */
+       { 0x04, 32 },           /* xPSR     */
+};
+
+static const struct stack_register_offset 
rtos_standard_arm926ejs_stack_offsets_interrupt[] = {
+       { 0x08, 32 },           /* r0       */
+       { 0x0C, 32 },           /* r1       */
+       { 0x10, 32 },           /* r2       */
+       { 0x14, 32 },           /* r3       */
+       { 0x18, 32 },           /* r4       */
+       { 0x1C, 32 },           /* r5       */
+       { 0x20, 32 },           /* r6       */
+       { 0x24, 32 },           /* r7       */
+       { 0x28, 32 },           /* r8       */
+       { 0x2C, 32 },           /* r9       */
+       { 0x30, 32 },           /* r10      */
+       { 0x34, 32 },           /* r11      */
+       { 0x38, 32 },           /* r12      */
+       { -2,   32 },           /* sp (r13) */
+       { 0x3C, 32 },           /* lr (r14) */
+       { 0x40, 32 },           /* pc (r15) */
+       { 0x04, 32 },           /* xPSR     */
+};
+
 const struct rtos_register_stacking rtos_standard_Cortex_M3_stacking = {
        0x40,                                   /* stack_registers_size */
        -1,                                             /* 
stack_growth_direction */
@@ -136,3 +176,20 @@ const struct rtos_register_stacking 
rtos_standard_NDS32_N1068_stacking = {
        8,                                      /* stack_alignment */
        rtos_standard_NDS32_N1068_stack_offsets /* register_offsets */
 };
+
+const struct rtos_register_stacking rtos_standard_arm926ejs_stackings[2] = {
+       {
+               0x2c,                           /* stack_registers_size */
+               -1,                                     /* 
stack_growth_direction */
+               17,                                     /* num_output_registers 
*/
+               0,                                      /* stack_alignment */
+               rtos_standard_arm926ejs_stack_offsets_normal    /* 
register_offsets */
+       },
+       {
+               0x44,                           /* stack_registers_size */
+               -1,                                     /* 
stack_growth_direction */
+               17,                                     /* num_output_registers 
*/
+               0,                                      /* stack_alignment */
+               rtos_standard_arm926ejs_stack_offsets_interrupt /* 
register_offsets */
+       }
+};
diff --git a/src/rtos/rtos_standard_stackings.h 
b/src/rtos/rtos_standard_stackings.h
index b76e2bb..1183662 100644
--- a/src/rtos/rtos_standard_stackings.h
+++ b/src/rtos/rtos_standard_stackings.h
@@ -30,5 +30,6 @@
 extern const struct rtos_register_stacking rtos_standard_Cortex_M3_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_arm926ejs_stackings[2];
 
 #endif /* ifndef INCLUDED_RTOS_STANDARD_STACKINGS_H_ */

-- 

------------------------------------------------------------------------------
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to