aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2023-01-03 10:08:18 -0800
committerTim Newsome <tim@sifive.com>2023-01-03 10:08:18 -0800
commitd2ebfc87702106ce29869fd688f188e0c238ce97 (patch)
tree6738c7ff0ba922c1d2269d1de78a5f74102b23c2
parent9efa7775d4a388719b3bc16d79ac5d294eba537a (diff)
downloadriscv-openocd-d2ebfc87702106ce29869fd688f188e0c238ce97.zip
riscv-openocd-d2ebfc87702106ce29869fd688f188e0c238ce97.tar.gz
riscv-openocd-d2ebfc87702106ce29869fd688f188e0c238ce97.tar.bz2
target/riscv: Use unsigned int for trigger indexes.
Change-Id: I1f7cf3a5c8b86f3d6825f45a67ff05822ea67d28 Signed-off-by: Tim Newsome <tim@sifive.com>
-rw-r--r--src/target/riscv/riscv.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c
index dd5eb71..1bda998 100644
--- a/src/target/riscv/riscv.c
+++ b/src/target/riscv/riscv.c
@@ -476,7 +476,7 @@ static bool can_use_napot_match(struct trigger *trigger, riscv_reg_t *tdata2)
return false;
}
-static int find_trigger(struct target *target, int type, bool chained, int *idx)
+static int find_trigger(struct target *target, int type, bool chained, unsigned int *idx)
{
RISCV_INFO(r);
@@ -517,7 +517,7 @@ static int find_first_trigger_by_id(struct target *target, int unique_id)
return -1;
}
-static int set_trigger(struct target *target, int idx, riscv_reg_t tdata1, riscv_reg_t tdata2,
+static int set_trigger(struct target *target, unsigned int idx, riscv_reg_t tdata1, riscv_reg_t tdata2,
riscv_reg_t tdata1_ignore_mask)
{
riscv_reg_t tdata1_rb, tdata2_rb;
@@ -553,7 +553,7 @@ static int set_trigger(struct target *target, int idx, riscv_reg_t tdata1, riscv
static int maybe_add_trigger_t1(struct target *target, struct trigger *trigger)
{
- int idx, ret;
+ int ret;
riscv_reg_t tdata1, tdata2;
RISCV_INFO(r);
@@ -568,6 +568,7 @@ static int maybe_add_trigger_t1(struct target *target, struct trigger *trigger)
const uint32_t bpcontrol_bpmatch = 0xf << 7;
const uint32_t bpcontrol_bpaction = 0xff << 11;
+ unsigned int idx;
ret = find_trigger(target, CSR_TDATA1_TYPE_LEGACY, false, &idx);
if (ret != ERROR_OK)
return ret;
@@ -599,7 +600,7 @@ static int maybe_add_trigger_t1(struct target *target, struct trigger *trigger)
static int maybe_add_trigger_t2(struct target *target, struct trigger *trigger)
{
- int idx, ret;
+ int ret;
riscv_reg_t tdata1, tdata2;
RISCV_INFO(r);
@@ -622,6 +623,7 @@ static int maybe_add_trigger_t2(struct target *target, struct trigger *trigger)
if (!can_use_napot_match(trigger, &tdata2))
goto MATCH_GE_LT;
+ unsigned int idx;
ret = find_trigger(target, CSR_TDATA1_TYPE_MCONTROL, false, &idx);
if (ret != ERROR_OK)
return ret;
@@ -686,7 +688,7 @@ static int maybe_add_trigger_t4(struct target *target, bool vs, bool vu,
bool nmi, bool m, bool s, bool u, riscv_reg_t interrupts,
int unique_id)
{
- int idx, ret;
+ int ret;
riscv_reg_t tdata1, tdata2;
RISCV_INFO(r);
@@ -704,6 +706,7 @@ static int maybe_add_trigger_t4(struct target *target, bool vs, bool vu,
tdata2 = interrupts;
+ unsigned int idx;
ret = find_trigger(target, CSR_TDATA1_TYPE_ITRIGGER, false, &idx);
if (ret != ERROR_OK)
return ret;
@@ -718,7 +721,7 @@ static int maybe_add_trigger_t5(struct target *target, bool vs, bool vu,
bool m, bool s, bool u, riscv_reg_t exception_codes,
int unique_id)
{
- int idx, ret;
+ int ret;
riscv_reg_t tdata1, tdata2;
RISCV_INFO(r);
@@ -735,6 +738,7 @@ static int maybe_add_trigger_t5(struct target *target, bool vs, bool vu,
tdata2 = exception_codes;
+ unsigned int idx;
ret = find_trigger(target, CSR_TDATA1_TYPE_ETRIGGER, false, &idx);
if (ret != ERROR_OK)
return ret;
@@ -747,7 +751,7 @@ static int maybe_add_trigger_t5(struct target *target, bool vs, bool vu,
static int maybe_add_trigger_t6(struct target *target, struct trigger *trigger)
{
- int idx, ret;
+ int ret;
riscv_reg_t tdata1, tdata2;
RISCV_INFO(r);
@@ -769,6 +773,7 @@ static int maybe_add_trigger_t6(struct target *target, struct trigger *trigger)
if (!can_use_napot_match(trigger, &tdata2))
goto MATCH_GE_LT;
+ unsigned int idx;
ret = find_trigger(target, CSR_TDATA1_TYPE_MCONTROL6, false, &idx);
if (ret != ERROR_OK)
return ret;