[PATCH 4/5] target/riscv/tcg/debug: set tinfo version if sdtrig enabled

Daniel Henrique Barboza posted 5 patches 1 month, 1 week ago
Maintainers: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Chao Liu <chao.liu@processmission.com>
[PATCH 4/5] target/riscv/tcg/debug: set tinfo version if sdtrig enabled
Posted by Daniel Henrique Barboza 1 month, 1 week ago
Set 'version' to 1 if we're running Debug 1.0.

Signed-off-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
---
 target/riscv/tcg/debug.c | 11 ++++++++---
 target/riscv/tcg/debug.h |  3 +++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/target/riscv/tcg/debug.c b/target/riscv/tcg/debug.c
index 8b23c8d045..06573c7b3f 100644
--- a/target/riscv/tcg/debug.c
+++ b/target/riscv/tcg/debug.c
@@ -957,9 +957,14 @@ void tdata_csr_write(CPURISCVState *env, int tdata_index, target_ulong val)
 
 target_ulong tinfo_csr_read(CPURISCVState *env)
 {
-    /* assume all triggers support the same types of triggers */
-    return BIT(TRIGGER_TYPE_AD_MATCH) |
-           BIT(TRIGGER_TYPE_AD_MATCH6);
+    target_ulong val = BIT(TRIGGER_TYPE_AD_MATCH) |
+                       BIT(TRIGGER_TYPE_AD_MATCH6);
+
+    if (debug_trigger_version_1_0(env)) {
+        val = deposit64(val, TINFO_VERSION_OFFSET, TINFO_VERSION_LEN, 1);
+    }
+
+    return val;
 }
 
 void riscv_cpu_debug_excp_handler(CPUState *cs)
diff --git a/target/riscv/tcg/debug.h b/target/riscv/tcg/debug.h
index eb635bc277..fcd92b768c 100644
--- a/target/riscv/tcg/debug.h
+++ b/target/riscv/tcg/debug.h
@@ -45,6 +45,9 @@ typedef enum {
     TRIGGER_TYPE_NUM
 } trigger_type_t;
 
+#define TINFO_VERSION_OFFSET 24
+#define TINFO_VERSION_LEN     8
+
 /* actions */
 typedef enum {
     DBG_ACTION_NONE = -1,           /* sentinel value */
-- 
2.43.0
Re: [PATCH 4/5] target/riscv/tcg/debug: set tinfo version if sdtrig enabled
Posted by Alistair Francis 3 weeks ago
On Wed, 2026-08-05 at 15:25 -0300, Daniel Henrique Barboza wrote:
> Set 'version' to 1 if we're running Debug 1.0.
> 
> Signed-off-by: Daniel Henrique Barboza
> <daniel.barboza@oss.qualcomm.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  target/riscv/tcg/debug.c | 11 ++++++++---
>  target/riscv/tcg/debug.h |  3 +++
>  2 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/target/riscv/tcg/debug.c b/target/riscv/tcg/debug.c
> index 8b23c8d045..06573c7b3f 100644
> --- a/target/riscv/tcg/debug.c
> +++ b/target/riscv/tcg/debug.c
> @@ -957,9 +957,14 @@ void tdata_csr_write(CPURISCVState *env, int
> tdata_index, target_ulong val)
>  
>  target_ulong tinfo_csr_read(CPURISCVState *env)
>  {
> -    /* assume all triggers support the same types of triggers */
> -    return BIT(TRIGGER_TYPE_AD_MATCH) |
> -           BIT(TRIGGER_TYPE_AD_MATCH6);
> +    target_ulong val = BIT(TRIGGER_TYPE_AD_MATCH) |
> +                       BIT(TRIGGER_TYPE_AD_MATCH6);
> +
> +    if (debug_trigger_version_1_0(env)) {
> +        val = deposit64(val, TINFO_VERSION_OFFSET,
> TINFO_VERSION_LEN, 1);
> +    }
> +
> +    return val;
>  }
>  
>  void riscv_cpu_debug_excp_handler(CPUState *cs)
> diff --git a/target/riscv/tcg/debug.h b/target/riscv/tcg/debug.h
> index eb635bc277..fcd92b768c 100644
> --- a/target/riscv/tcg/debug.h
> +++ b/target/riscv/tcg/debug.h
> @@ -45,6 +45,9 @@ typedef enum {
>      TRIGGER_TYPE_NUM
>  } trigger_type_t;
>  
> +#define TINFO_VERSION_OFFSET 24
> +#define TINFO_VERSION_LEN     8
> +
>  /* actions */
>  typedef enum {
>      DBG_ACTION_NONE = -1,           /* sentinel value */