From: <ge...@op...> - 2025-10-14 13:57:57
|
This is an automated email from Gerrit. "Tomas Vanek <va...@fb...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9169 -- gerrit commit 01b6b95787321440f5a9632cded04ba0535f5290 Author: Tomas Vanek <va...@fb...> Date: Mon Oct 13 15:39:05 2025 +0200 target: introduce target capability bits Add target_get_capab() call to identify which optional capabilities the target supports. For the beginning define bits for memory read/write while running and HW breakpoint/watchpoint manipulation at any state. Add simple usage in cortex_m.c Change-Id: I1a28f3707dfff9a2424090bb125990c7ea9a0387 Signed-off-by: Tomas Vanek <va...@fb...> diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index 42e9572602..b172d1bcd4 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -3101,6 +3101,13 @@ static int cortex_m_target_create(struct target *target) return ERROR_OK; } +static unsigned int cortex_m_get_capab(struct target *target) +{ + return TARGET_CAPAB_MEM_READ_WHILE_RUNNING + | TARGET_CAPAB_MEM_WRITE_WHILE_RUNNING + | TARGET_CAPAB_BP_WP_MANIP_AT_ANY_STATE; +} + /*--------------------------------------------------------------------------*/ static int cortex_m_verify_pointer(struct command_invocation *cmd, @@ -3405,4 +3412,6 @@ struct target_type cortexm_target = { .deinit_target = cortex_m_deinit_target, .profiling = cortex_m_profiling, + + .get_capab = cortex_m_get_capab, }; diff --git a/src/target/target.c b/src/target/target.c index bdf0ff244d..5f1c85c3a5 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -1474,6 +1474,13 @@ unsigned int target_data_bits(struct target *target) return 32; } +unsigned int target_get_capab(struct target *target) +{ + if (target->type->get_capab) + return target->type->get_capab(target); + return 0; +} + static int target_profiling(struct target *target, uint32_t *samples, uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds) { diff --git a/src/target/target.h b/src/target/target.h index 6efcc7677b..b1fc0001d8 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -20,6 +20,7 @@ #ifndef OPENOCD_TARGET_TARGET_H #define OPENOCD_TARGET_TARGET_H +#include <helper/bits.h> #include <helper/list.h> #include "helper/replacements.h" #include "helper/system.h" @@ -85,6 +86,10 @@ enum target_endianness { TARGET_BIG_ENDIAN = 1, TARGET_LITTLE_ENDIAN = 2 }; +#define TARGET_CAPAB_MEM_READ_WHILE_RUNNING BIT(0) +#define TARGET_CAPAB_MEM_WRITE_WHILE_RUNNING BIT(1) +#define TARGET_CAPAB_BP_WP_MANIP_AT_ANY_STATE BIT(2) + struct working_area { target_addr_t address; uint32_t size; @@ -690,6 +695,13 @@ unsigned int target_address_bits(struct target *target); */ unsigned int target_data_bits(struct target *target); +/** + * Return target capabilities as TARGET_CAPAB_ bits. + * + * This routine is a wrapper for target->type->get_capab + */ +unsigned int target_get_capab(struct target *target); + /** Return the *name* of this targets current state */ const char *target_state_name(const struct target *target); diff --git a/src/target/target_type.h b/src/target/target_type.h index ccbe03a476..6b1443c6b7 100644 --- a/src/target/target_type.h +++ b/src/target/target_type.h @@ -305,6 +305,10 @@ struct target_type { * 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); + + /* Return target capabilities as TARGET_CAPAB_ bits. + * Assume zero return (no optional capabilities) if not implemented */ + unsigned int (*get_capab)(struct target *target); }; // Keep in alphabetic order this list of targets -- |