aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2023-06-02 16:13:37 -0700
committerTim Newsome <tim@sifive.com>2023-06-20 09:22:27 -0700
commit9d8bbb559d86a4fdca89111f87f01d9973013eee (patch)
tree1a8000036d865402e48c30c3adde972526d39033 /src
parent866282ba9ec812c99d9de885ee3314c19b329e51 (diff)
downloadriscv-openocd-9d8bbb559d86a4fdca89111f87f01d9973013eee.zip
riscv-openocd-9d8bbb559d86a4fdca89111f87f01d9973013eee.tar.gz
riscv-openocd-9d8bbb559d86a4fdca89111f87f01d9973013eee.tar.bz2
target/riscv: Tweak set_group().
Make it callable earlier, handle `supported` being NULL, and make enum names more clear. Change-Id: If4d286b54ccfc01eb5de5a57eb18f748c920e979 Signed-off-by: Tim Newsome <tim@sifive.com>
Diffstat (limited to 'src')
-rw-r--r--src/target/riscv/riscv-013.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index 69180a6..7c7ca19 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -67,6 +67,13 @@ static int read_memory(struct target *target, target_addr_t address,
static int write_memory(struct target *target, target_addr_t address,
uint32_t size, uint32_t count, const uint8_t *buffer);
+typedef enum {
+ HALT_GROUP,
+ RESUME_GROUP
+} grouptype_t;
+static int set_group(struct target *target, bool *supported, unsigned int group,
+ grouptype_t grouptype);
+
/**
* Since almost everything can be accomplish by scanning the dbus register, all
* functions here assume dbus is already selected. The exception are functions
@@ -1591,22 +1598,20 @@ static void deinit_target(struct target *target)
info->version_specific = NULL;
}
-typedef enum {
- HALTGROUP,
- RESUMEGROUP
-} grouptype_t;
-static int set_group(struct target *target, bool *supported, unsigned group, grouptype_t grouptype)
+static int set_group(struct target *target, bool *supported, unsigned int group,
+ grouptype_t grouptype)
{
uint32_t write_val = DM_DMCS2_HGWRITE;
assert(group <= 31);
write_val = set_field(write_val, DM_DMCS2_GROUP, group);
- write_val = set_field(write_val, DM_DMCS2_GROUPTYPE, (grouptype == HALTGROUP) ? 0 : 1);
+ write_val = set_field(write_val, DM_DMCS2_GROUPTYPE, (grouptype == HALT_GROUP) ? 0 : 1);
if (dmi_write(target, DM_DMCS2, write_val) != ERROR_OK)
return ERROR_FAIL;
uint32_t read_val;
if (dmi_read(target, &read_val, DM_DMCS2) != ERROR_OK)
return ERROR_FAIL;
- *supported = get_field(read_val, DM_DMCS2_GROUP) == group;
+ if (supported)
+ *supported = (get_field(read_val, DM_DMCS2_GROUP) == group);
return ERROR_OK;
}
@@ -1880,7 +1885,7 @@ static int examine(struct target *target)
if (target->smp) {
bool haltgroup_supported;
- if (set_group(target, &haltgroup_supported, target->smp, HALTGROUP) != ERROR_OK)
+ if (set_group(target, &haltgroup_supported, target->smp, HALT_GROUP) != ERROR_OK)
return ERROR_FAIL;
if (haltgroup_supported)
LOG_INFO("Core %d made part of halt group %d.", target->coreid,