]> www.infradead.org Git - users/borneoa/openocd-next.git/commitdiff
rtos/FreeRTOS: fix next pointer member offset in FreeRTOS lists
authorChien Wong <m@xv97.com>
Tue, 8 Apr 2025 12:33:56 +0000 (20:33 +0800)
committerAntonio Borneo <borneo.antonio@gmail.com>
Fri, 9 May 2025 12:08:39 +0000 (12:08 +0000)
Currently, we are using offset of xListEnd.pxPrevious in List_t for
list_next_offset and offset of pxPrevious in ListItem_t for
list_elem_next_offset. This is confusing. Fix this.
As the related lists are doubly linked lists, only iteration order is
changed without breaking functionality.
Also document those offsets.

Change-Id: I8beacc235ee781ab4e3b415fccad7b72ec55b098
Signed-off-by: Chien Wong <m@xv97.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8833
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
src/rtos/freertos.c

index bd7b4220e37ab7a38550c29df601cde71860289b..5a9224ec08cfef3c4224e96420fbdb27734188a5 100644 (file)
@@ -30,12 +30,12 @@ struct freertos_params {
        const char *target_name;
        const unsigned char thread_count_width;
        const unsigned char pointer_width;
-       const unsigned char list_next_offset;
-       const unsigned char list_width;
-       const unsigned char list_elem_next_offset;
-       const unsigned char list_elem_content_offset;
-       const unsigned char thread_stack_offset;
-       const unsigned char thread_name_offset;
+       const unsigned char list_next_offset;                   /* offsetof(List_t, xListEnd.pxNext) */
+       const unsigned char list_width;                                 /* sizeof(List_t) */
+       const unsigned char list_elem_next_offset;              /* offsetof(ListItem_t, pxNext) */
+       const unsigned char list_elem_content_offset;   /* offsetof(ListItem_t, pvOwner) */
+       const unsigned char thread_stack_offset;                /* offsetof(TCB_t, pxTopOfStack) */
+       const unsigned char thread_name_offset;                 /* offsetof(TCB_t, pcTaskName) */
        const struct rtos_register_stacking *stacking_info_cm3;
        const struct rtos_register_stacking *stacking_info_cm4f;
        const struct rtos_register_stacking *stacking_info_cm4f_fpu;
@@ -46,9 +46,9 @@ static const struct freertos_params freertos_params_list[] = {
        "cortex_m",                     /* target_name */
        4,                                              /* thread_count_width; */
        4,                                              /* pointer_width; */
-       16,                                             /* list_next_offset; */
+       12,                                             /* list_next_offset; */
        20,                                             /* list_width; */
-       8,                                              /* list_elem_next_offset; */
+       4,                                              /* list_elem_next_offset; */
        12,                                             /* list_elem_content_offset */
        0,                                              /* thread_stack_offset; */
        52,                                             /* thread_name_offset; */
@@ -60,9 +60,9 @@ static const struct freertos_params freertos_params_list[] = {
        "hla_target",                   /* target_name */
        4,                                              /* thread_count_width; */
        4,                                              /* pointer_width; */
-       16,                                             /* list_next_offset; */
+       12,                                             /* list_next_offset; */
        20,                                             /* list_width; */
-       8,                                              /* list_elem_next_offset; */
+       4,                                              /* list_elem_next_offset; */
        12,                                             /* list_elem_content_offset */
        0,                                              /* thread_stack_offset; */
        52,                                             /* thread_name_offset; */