From e191bccc730389c9bca661077dbc7121828cf946 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Wed, 4 May 2022 10:25:37 -0700 Subject: [PATCH] Change set_haltgroup() to more general set_group() Change-Id: Ib91a252ac63604e54b756f70c549ccd47241fd10 Signed-off-by: Tim Newsome --- src/target/riscv/riscv-013.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 63b40c687..e179e8208 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -1503,15 +1503,20 @@ static void deinit_target(struct target *target) info->version_specific = NULL; } -static int set_haltgroup(struct target *target, bool *supported) +typedef enum { + HALTGROUP, + RESUMEGROUP +} grouptype_t; +static int set_group(struct target *target, bool *supported, unsigned group, grouptype_t grouptype) { - uint32_t write = set_field(DM_DMCS2_HGWRITE, DM_DMCS2_GROUP, target->smp); + uint32_t write = set_field(DM_DMCS2_HGWRITE, DM_DMCS2_GROUP, group); + write = set_field(write, DM_DMCS2_GROUPTYPE, 1); if (dmi_write(target, DM_DMCS2, write) != ERROR_OK) return ERROR_FAIL; uint32_t read; if (dmi_read(target, &read, DM_DMCS2) != ERROR_OK) return ERROR_FAIL; - *supported = get_field(read, DM_DMCS2_GROUP) == (unsigned)target->smp; + *supported = get_field(read, DM_DMCS2_GROUP) == group; return ERROR_OK; } @@ -1754,7 +1759,7 @@ static int examine(struct target *target) if (target->smp) { bool haltgroup_supported; - if (set_haltgroup(target, &haltgroup_supported) != ERROR_OK) + if (set_group(target, &haltgroup_supported, target->smp, HALTGROUP) != ERROR_OK) return ERROR_FAIL; if (haltgroup_supported) LOG_INFO("Core %d made part of halt group %d.", target->coreid,