target: get_gdb_arch() accepts target via const pointer
[openocd.git] / src / target / target_type.h
index 0960e6d59392391ffc86870f247c5f73c0a9924f..bc42c2d16e630a3516868cb7033a6679c127e669 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
 /***************************************************************************
  *   Copyright (C) 2005 by Dominic Rath                                    *
  *   Dominic.Rath@gmx.de                                                   *
@@ -7,25 +9,12 @@
  *                                                                         *
  *   Copyright (C) 2008 by Spencer Oliver                                  *
  *   spen@spen-soft.co.uk                                                  *
- *                                                                         *
- *   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/>. *
  ***************************************************************************/
 
 #ifndef OPENOCD_TARGET_TARGET_TYPE_H
 #define OPENOCD_TARGET_TARGET_TYPE_H
 
-#include <jim-nvp.h>
+#include <helper/jim-nvp.h>
 
 struct target;
 
@@ -40,7 +29,6 @@ struct target_type {
         * field directly, use target_type_name() instead.
         */
        const char *name;
-       const char *deprecated_name;
 
        /* poll current target status */
        int (*poll)(struct target *target);
@@ -80,14 +68,23 @@ struct target_type {
         * state correctly.
         *
         * Otherwise the following would fail, as there will not
-        * be any "poll" invoked inbetween the "reset run" and
+        * be any "poll" invoked between the "reset run" and
         * "halt".
         *
         * reset run; halt
-     */
+        */
        int (*deassert_reset)(struct target *target);
        int (*soft_reset_halt)(struct target *target);
 
+       /**
+        * Target architecture for GDB.
+        *
+        * The string returned by this function will not be automatically freed;
+        * if dynamic allocation is used for this value, it must be managed by
+        * the target, ideally by caching the result for subsequent calls.
+        */
+       const char *(*get_gdb_arch)(const struct target *target);
+
        /**
         * Target register access for GDB.  Do @b not call this function
         * directly, use target_get_gdb_reg_list() instead.
@@ -102,6 +99,13 @@ struct target_type {
        int (*get_gdb_reg_list)(struct target *target, struct reg **reg_list[],
                        int *reg_list_size, enum target_register_class reg_class);
 
+       /**
+        * Same as get_gdb_reg_list, but doesn't read the register values.
+        * */
+       int (*get_gdb_reg_list_noread)(struct target *target,
+                       struct reg **reg_list[], int *reg_list_size,
+                       enum target_register_class reg_class);
+
        /* target memory access
        * size: 1 = byte (8bit), 2 = half-word (16bit), 4 = word (32bit)
        * count: number of items of <size>
@@ -130,8 +134,9 @@ struct target_type {
 
        int (*checksum_memory)(struct target *target, target_addr_t address,
                        uint32_t count, uint32_t *checksum);
-       int (*blank_check_memory)(struct target *target, target_addr_t address,
-                       uint32_t count, uint32_t *blank, uint8_t erased_value);
+       int (*blank_check_memory)(struct target *target,
+                       struct target_memory_check_block *blocks, int num_blocks,
+                       uint8_t erased_value);
 
        /*
         * target break-/watchpoint control
@@ -176,7 +181,7 @@ struct target_type {
        int (*run_algorithm)(struct target *target, int num_mem_params,
                        struct mem_param *mem_params, int num_reg_params,
                        struct reg_param *reg_param, target_addr_t entry_point,
-                       target_addr_t exit_point, int timeout_ms, void *arch_info);
+                       target_addr_t exit_point, unsigned int timeout_ms, void *arch_info);
        int (*start_algorithm)(struct target *target, int num_mem_params,
                        struct mem_param *mem_params, int num_reg_params,
                        struct reg_param *reg_param, target_addr_t entry_point,
@@ -184,7 +189,7 @@ struct target_type {
        int (*wait_algorithm)(struct target *target, int num_mem_params,
                        struct mem_param *mem_params, int num_reg_params,
                        struct reg_param *reg_param, target_addr_t exit_point,
-                       int timeout_ms, void *arch_info);
+                       unsigned int timeout_ms, void *arch_info);
 
        const struct command_registration *commands;
 
@@ -194,11 +199,11 @@ struct target_type {
        /* called for various config parameters */
        /* returns JIM_CONTINUE - if option not understood */
        /* otherwise: JIM_OK, or JIM_ERR, */
-       int (*target_jim_configure)(struct target *target, Jim_GetOptInfo *goi);
+       int (*target_jim_configure)(struct target *target, struct jim_getopt_info *goi);
 
        /* target commands specifically handled by the target */
        /* returns JIM_OK, or JIM_ERR, or JIM_CONTINUE - if option not understood */
-       int (*target_jim_commands)(struct target *target, Jim_GetOptInfo *goi);
+       int (*target_jim_commands)(struct target *target, struct jim_getopt_info *goi);
 
        /**
         * This method is used to perform target setup that requires
@@ -226,6 +231,17 @@ struct target_type {
        /**
         * Free all the resources allocated by the target.
         *
+        * WARNING: deinit_target is called unconditionally regardless the target has
+        * ever been examined/initialised or not.
+        * If a problem has prevented establishing JTAG/SWD/... communication
+        *  or
+        * if the target was created with -defer-examine flag and has never been
+        *  examined
+        * then it is not possible to communicate with the target.
+        *
+        * If you need to talk to the target during deinit, first check if
+        * target_was_examined()!
+        *
         * @param target The target to deinit
         */
        void (*deinit_target)(struct target *target);
@@ -270,10 +286,68 @@ struct target_type {
         */
        int (*gdb_fileio_end)(struct target *target, int retcode, int fileio_errno, bool ctrl_c);
 
+       /* Parse target-specific GDB query commands.
+        * The string pointer "response_p" is always assigned by the called function
+        * to a pointer to a NULL-terminated string, even when the function returns
+        * an error. The string memory is not freed by the caller, so this function
+        * must pay attention for possible memory leaks if the string memory is
+        * dynamically allocated.
+        */
+       int (*gdb_query_custom)(struct target *target, const char *packet, char **response_p);
+
        /* do target profiling
         */
        int (*profiling)(struct target *target, uint32_t *samples,
                        uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds);
+
+       /* Return the number of address bits this target supports. This will
+        * typically be 32 for 32-bit targets, and 64 for 64-bit targets. If not
+        * implemented, it's assumed to be 32. */
+       unsigned (*address_bits)(struct target *target);
+
+       /* Return the number of system bus data bits this target supports. This
+        * will typically be 32 for 32-bit targets, and 64 for 64-bit targets. If
+        * not implemented, it's assumed to be 32. */
+       unsigned int (*data_bits)(struct target *target);
 };
 
+extern struct target_type aarch64_target;
+extern struct target_type arcv2_target;
+extern struct target_type arm11_target;
+extern struct target_type arm720t_target;
+extern struct target_type arm7tdmi_target;
+extern struct target_type arm920t_target;
+extern struct target_type arm926ejs_target;
+extern struct target_type arm946e_target;
+extern struct target_type arm966e_target;
+extern struct target_type arm9tdmi_target;
+extern struct target_type armv8r_target;
+extern struct target_type avr32_ap7k_target;
+extern struct target_type avr_target;
+extern struct target_type cortexa_target;
+extern struct target_type cortexm_target;
+extern struct target_type cortexr4_target;
+extern struct target_type dragonite_target;
+extern struct target_type dsp563xx_target;
+extern struct target_type dsp5680xx_target;
+extern struct target_type esirisc_target;
+extern struct target_type esp32s2_target;
+extern struct target_type esp32s3_target;
+extern struct target_type esp32_target;
+extern struct target_type fa526_target;
+extern struct target_type feroceon_target;
+extern struct target_type hla_target;
+extern struct target_type ls1_sap_target;
+extern struct target_type mem_ap_target;
+extern struct target_type mips_m4k_target;
+extern struct target_type mips_mips64_target;
+extern struct target_type or1k_target;
+extern struct target_type quark_d20xx_target;
+extern struct target_type quark_x10xx_target;
+extern struct target_type riscv_target;
+extern struct target_type stm8_target;
+extern struct target_type testee_target;
+extern struct target_type xscale_target;
+extern struct target_type xtensa_chip_target;
+
 #endif /* OPENOCD_TARGET_TARGET_TYPE_H */

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)