rtos: remove config.h includes from stackings headers
[openocd.git] / src / rtos / nuttx.c
index 0705b17b3526259cd9441a6ed27f0a6e1ffaabeb..78271181e2e13bcfb43c98d883e4c7f57323a483 100644 (file)
@@ -1,20 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
 /***************************************************************************
  *   Copyright 2016,2017 Sony Video & Sound Products Inc.                  *
  *   Masatoshi Tateishi - Masatoshi.Tateishi@jp.sony.com                   *
  *   Masayuki Ishikawa - Masayuki.Ishikawa@jp.sony.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
@@ -32,7 +21,7 @@
 #include "server/gdb_server.h"
 
 #include "nuttx_header.h"
-
+#include "rtos_nuttx_stackings.h"
 
 int rtos_thread_packet(struct connection *connection, const char *packet, int packet_size);
 
@@ -96,64 +85,6 @@ static char *task_state_str[] = {
 #endif /* CONFIG_PAGING */
 };
 
-/* see arch/arm/include/armv7-m/irq_cmnvector.h */
-static const struct stack_register_offset nuttx_stack_offsets_cortex_m[] = {
-       { ARMV7M_R0,    0x28, 32 },             /* r0   */
-       { ARMV7M_R1,    0x2c, 32 },             /* r1   */
-       { ARMV7M_R2,    0x30, 32 },             /* r2   */
-       { ARMV7M_R3,    0x34, 32 },             /* r3   */
-       { ARMV7M_R4,    0x08, 32 },             /* r4   */
-       { ARMV7M_R5,    0x0c, 32 },             /* r5   */
-       { ARMV7M_R6,    0x10, 32 },             /* r6   */
-       { ARMV7M_R7,    0x14, 32 },             /* r7   */
-       { ARMV7M_R8,    0x18, 32 },             /* r8   */
-       { ARMV7M_R9,    0x1c, 32 },             /* r9   */
-       { ARMV7M_R10,   0x20, 32 },             /* r10  */
-       { ARMV7M_R11,   0x24, 32 },             /* r11  */
-       { ARMV7M_R12,   0x38, 32 },             /* r12  */
-       { ARMV7M_R13,     0,  32 },             /* sp   */
-       { ARMV7M_R14,   0x3c, 32 },             /* lr   */
-       { ARMV7M_PC,    0x40, 32 },             /* pc   */
-       { ARMV7M_xPSR,  0x44, 32 },             /* xPSR */
-};
-
-
-static const struct rtos_register_stacking nuttx_stacking_cortex_m = {
-       0x48,                                   /* stack_registers_size */
-       -1,                                     /* stack_growth_direction */
-       17,                                     /* num_output_registers */
-       0,                                      /* stack_alignment */
-       nuttx_stack_offsets_cortex_m   /* register_offsets */
-};
-
-static const struct stack_register_offset nuttx_stack_offsets_cortex_m_fpu[] = {
-       { ARMV7M_R0,    0x6c, 32 },             /* r0   */
-       { ARMV7M_R1,    0x70, 32 },             /* r1   */
-       { ARMV7M_R2,    0x74, 32 },             /* r2   */
-       { ARMV7M_R3,    0x78, 32 },             /* r3   */
-       { ARMV7M_R4,    0x08, 32 },             /* r4   */
-       { ARMV7M_R5,    0x0c, 32 },             /* r5   */
-       { ARMV7M_R6,    0x10, 32 },             /* r6   */
-       { ARMV7M_R7,    0x14, 32 },             /* r7   */
-       { ARMV7M_R8,    0x18, 32 },             /* r8   */
-       { ARMV7M_R9,    0x1c, 32 },             /* r9   */
-       { ARMV7M_R10,   0x20, 32 },             /* r10  */
-       { ARMV7M_R11,   0x24, 32 },             /* r11  */
-       { ARMV7M_R12,   0x7c, 32 },             /* r12  */
-       { ARMV7M_R13,     0,  32 },             /* sp   */
-       { ARMV7M_R14,   0x80, 32 },             /* lr   */
-       { ARMV7M_PC,    0x84, 32 },             /* pc   */
-       { ARMV7M_xPSR,  0x88, 32 },             /* xPSR */
-};
-
-static const struct rtos_register_stacking nuttx_stacking_cortex_m_fpu = {
-       0x8c,                                   /* stack_registers_size */
-       -1,                                     /* stack_growth_direction */
-       17,                                     /* num_output_registers */
-       0,                                      /* stack_alignment */
-       nuttx_stack_offsets_cortex_m_fpu        /* register_offsets */
-};
-
 static int pid_offset = PID;
 static int state_offset = STATE;
 static int name_offset =  NAME;
@@ -233,7 +164,7 @@ retok:
 
 static bool nuttx_detect_rtos(struct target *target)
 {
-       if ((target->rtos->symbols != NULL) &&
+       if ((target->rtos->symbols) &&
                        (target->rtos->symbols[0].address != 0) &&
                        (target->rtos->symbols[1].address != 0)) {
                return true;
@@ -259,7 +190,7 @@ static int nuttx_update_threads(struct rtos *rtos)
        uint32_t i;
        uint8_t state;
 
-       if (rtos->symbols == NULL) {
+       if (!rtos->symbols) {
                LOG_ERROR("No symbols for NuttX");
                return -3;
        }
@@ -314,7 +245,7 @@ static int nuttx_update_threads(struct rtos *rtos)
 
                        state = tcb.dat[state_offset - 8];
                        thread->extra_info_str = NULL;
-                       if (state < sizeof(task_state_str)/sizeof(char *)) {
+                       if (state < ARRAY_SIZE(task_state_str)) {
                                thread->extra_info_str = malloc(256);
                                snprintf(thread->extra_info_str, 256, "pid:%d, %s",
                                    tcb.dat[pid_offset - 8] |
@@ -393,7 +324,7 @@ static int nuttx_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list
        return 0;
 }
 
-struct rtos_type nuttx_rtos = {
+const struct rtos_type nuttx_rtos = {
        .name = "nuttx",
        .detect_rtos = nuttx_detect_rtos,
        .create = nuttx_create,

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)