openocd: fix SPDX tag format for files .c
[fw/openocd] / src / rtos / ThreadX.c
index 5eadce9cada553c0a6ba6fa5e1839db0dfa7ee23..7b76fb625875ebd8bfdcc97a9dc4e6c8bed82450 100644 (file)
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
 /***************************************************************************
  *   Copyright (C) 2011 by Broadcom Corporation                            *
  *   Evan Hunter - ehunter@broadcom.com                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -112,18 +101,16 @@ static const struct stack_register_offset rtos_threadx_arm926ejs_stack_offsets_i
 
 static const struct rtos_register_stacking rtos_threadx_arm926ejs_stacking[] = {
 {
-       ARM926EJS_REGISTERS_SIZE_SOLICITED,     /* stack_registers_size */
-       -1,                                                                     /* stack_growth_direction */
-       17,                                                                     /* num_output_registers */
-       NULL,                                                           /* stack_alignment */
-       rtos_threadx_arm926ejs_stack_offsets_solicited  /* register_offsets */
+       .stack_registers_size = ARM926EJS_REGISTERS_SIZE_SOLICITED,
+       .stack_growth_direction = -1,
+       .num_output_registers = 17,
+       .register_offsets = rtos_threadx_arm926ejs_stack_offsets_solicited
 },
 {
-       ARM926EJS_REGISTERS_SIZE_INTERRUPT,     /* stack_registers_size */
-       -1,                                                                     /* stack_growth_direction */
-       17,                                                                     /* num_output_registers */
-       NULL,                                                           /* stack_alignment */
-       rtos_threadx_arm926ejs_stack_offsets_interrupt  /* register_offsets */
+       .stack_registers_size = ARM926EJS_REGISTERS_SIZE_INTERRUPT,
+       .stack_growth_direction = -1,
+       .num_output_registers = 17,
+       .register_offsets = rtos_threadx_arm926ejs_stack_offsets_interrupt
 },
 };
 
@@ -177,6 +164,18 @@ static const struct threadx_params threadx_params_list[] = {
        get_stacking_info_arm926ejs,            /* fn_get_stacking_info */
        is_thread_id_valid_arm926ejs,           /* fn_is_thread_id_valid */
        },
+       {
+       "hla_target",                           /* target_name */
+       4,                                                      /* pointer_width; */
+       8,                                                      /* thread_stack_offset; */
+       40,                                                     /* thread_name_offset; */
+       48,                                                     /* thread_state_offset; */
+       136,                                            /* thread_next_offset */
+       &rtos_standard_cortex_m3_stacking,      /* stacking_info */
+       1,                                                      /* stacking_info_nb */
+       NULL,                                           /* fn_get_stacking_info */
+       NULL,                                           /* fn_is_thread_id_valid */
+       },
 };
 
 enum threadx_symbol_values {
@@ -206,7 +205,7 @@ static const struct rtos_register_stacking *get_stacking_info(const struct rtos
 {
        const struct threadx_params *param = (const struct threadx_params *) rtos->rtos_specific_params;
 
-       if (param->fn_get_stacking_info != NULL)
+       if (param->fn_get_stacking_info)
                return param->fn_get_stacking_info(rtos, stack_ptr);
 
        return param->stacking_info + 0;
@@ -216,12 +215,12 @@ static int is_thread_id_valid(const struct rtos *rtos, int64_t thread_id)
 {
        const struct threadx_params *param;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return 0; /* invalid */
 
        param = (const struct threadx_params *) rtos->rtos_specific_params;
 
-       if (param->fn_is_thread_id_valid != NULL)
+       if (param->fn_is_thread_id_valid)
                return param->fn_is_thread_id_valid(rtos, thread_id);
 
        return (thread_id != 0);
@@ -263,15 +262,15 @@ static int threadx_update_threads(struct rtos *rtos)
        int thread_list_size = 0;
        const struct threadx_params *param;
 
-       if (rtos == NULL)
+       if (!rtos)
                return -1;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return -3;
 
        param = (const struct threadx_params *) rtos->rtos_specific_params;
 
-       if (rtos->symbols == NULL) {
+       if (!rtos->symbols) {
                LOG_ERROR("No symbols for ThreadX");
                return -4;
        }
@@ -437,13 +436,13 @@ static int threadx_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
        int retval;
        const struct threadx_params *param;
 
-       if (rtos == NULL)
+       if (!rtos)
                return -1;
 
        if (!is_thread_id_valid(rtos, thread_id))
                return -2;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return -3;
 
        param = (const struct threadx_params *) rtos->rtos_specific_params;
@@ -469,7 +468,7 @@ static int threadx_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
        const struct rtos_register_stacking *stacking_info =
                        get_stacking_info(rtos, stack_ptr);
 
-       if (stacking_info == NULL) {
+       if (!stacking_info) {
                LOG_ERROR("Unknown stacking info for thread id=0x%" PRIx64, (uint64_t)thread_id);
                return -6;
        }
@@ -491,7 +490,7 @@ static int threadx_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_li
 
 static bool threadx_detect_rtos(struct target *target)
 {
-       if ((target->rtos->symbols != NULL) &&
+       if ((target->rtos->symbols) &&
                        (target->rtos->symbols[THREADX_VAL_TX_THREAD_CREATED_PTR].address != 0)) {
                /* looks like ThreadX */
                return true;
@@ -518,18 +517,18 @@ static int threadx_get_thread_detail(struct rtos *rtos,
 
        const struct threadx_params *param;
 
-       if (rtos == NULL)
+       if (!rtos)
                return -1;
 
        if (thread_id == 0)
                return -2;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return -3;
 
        param = (const struct threadx_params *) rtos->rtos_specific_params;
 
-       if (rtos->symbols == NULL) {
+       if (!rtos->symbols) {
                LOG_ERROR("No symbols for ThreadX");
                return -3;
        }