Skip to content

Commit 64af052

Browse files
committed
Fix the build.
Main change is to make riscv_addr_t be unsigned. The rest is mechanical fixing of types, print statements, and a few signed/unsigned compares. Smoketest indicates everything is working more or less as before.
1 parent 845c2f6 commit 64af052

File tree

5 files changed

+85
-77
lines changed

5 files changed

+85
-77
lines changed

src/flash/nor/fespi.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -802,17 +802,17 @@ static int steps_execute(struct algorithm_steps *as,
802802
int retval = target_write_buffer(target, data_wa->address, bytes,
803803
data_buf);
804804
if (retval != ERROR_OK) {
805-
LOG_ERROR("Failed to write data to 0x%x: %d", data_wa->address,
806-
retval);
805+
LOG_ERROR("Failed to write data to 0x%" TARGET_PRIxADDR ": %d",
806+
data_wa->address, retval);
807807
return retval;
808808
}
809809

810810
retval = target_run_algorithm(target, 0, NULL, 2, reg_params,
811811
algorithm_wa->address, algorithm_wa->address + 4,
812812
10000, NULL);
813813
if (retval != ERROR_OK) {
814-
LOG_ERROR("Failed to execute algorithm at 0x%x: %d", algorithm_wa->address,
815-
retval);
814+
LOG_ERROR("Failed to execute algorithm at 0x%" TARGET_PRIxADDR ": %d",
815+
algorithm_wa->address, retval);
816816
return retval;
817817
}
818818
}
@@ -866,8 +866,8 @@ static int fespi_write(struct flash_bank *bank, const uint8_t *buffer,
866866
retval = target_write_buffer(target, algorithm_wa->address,
867867
sizeof(algorithm_bin), algorithm_bin);
868868
if (retval != ERROR_OK) {
869-
LOG_ERROR("Failed to write code to 0x%x: %d", algorithm_wa->address,
870-
retval);
869+
LOG_ERROR("Failed to write code to 0x%" TARGET_PRIxADDR ": %d",
870+
algorithm_wa->address, retval);
871871
target_free_working_area(target, algorithm_wa);
872872
algorithm_wa = NULL;
873873
}

src/target/riscv/riscv-011.c

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#include "config.h"
1212
#endif
1313

14-
#include "target.h"
14+
#include "target/target.h"
1515
#include "target/algorithm.h"
16-
#include "target_type.h"
16+
#include "target/target_type.h"
1717
#include "log.h"
1818
#include "jtag/jtag.h"
19-
#include "register.h"
20-
#include "breakpoints.h"
19+
#include "target/register.h"
20+
#include "target/breakpoints.h"
2121
#include "helper/time_support.h"
2222
#include "riscv.h"
2323
#include "asm.h"
@@ -1630,7 +1630,7 @@ static int add_breakpoint(struct target *target,
16301630
if (breakpoint->type == BKPT_SOFT) {
16311631
if (target_read_memory(target, breakpoint->address, breakpoint->length, 1,
16321632
breakpoint->orig_instr) != ERROR_OK) {
1633-
LOG_ERROR("Failed to read original instruction at 0x%x",
1633+
LOG_ERROR("Failed to read original instruction at 0x%" TARGET_PRIxADDR,
16341634
breakpoint->address);
16351635
return ERROR_FAIL;
16361636
}
@@ -1642,8 +1642,8 @@ static int add_breakpoint(struct target *target,
16421642
retval = target_write_u16(target, breakpoint->address, ebreak_c());
16431643
}
16441644
if (retval != ERROR_OK) {
1645-
LOG_ERROR("Failed to write %d-byte breakpoint instruction at 0x%x",
1646-
breakpoint->length, breakpoint->address);
1645+
LOG_ERROR("Failed to write %d-byte breakpoint instruction at 0x%"
1646+
TARGET_PRIxADDR, breakpoint->length, breakpoint->address);
16471647
return ERROR_FAIL;
16481648
}
16491649

@@ -1672,7 +1672,7 @@ static int remove_breakpoint(struct target *target,
16721672
if (target_write_memory(target, breakpoint->address, breakpoint->length, 1,
16731673
breakpoint->orig_instr) != ERROR_OK) {
16741674
LOG_ERROR("Failed to restore instruction for %d-byte breakpoint at "
1675-
"0x%x", breakpoint->length, breakpoint->address);
1675+
"0x%" TARGET_PRIxADDR, breakpoint->length, breakpoint->address);
16761676
return ERROR_FAIL;
16771677
}
16781678

@@ -1763,7 +1763,7 @@ static int strict_step(struct target *target, bool announce)
17631763
return ERROR_OK;
17641764
}
17651765

1766-
static int step(struct target *target, int current, uint32_t address,
1766+
static int step(struct target *target, int current, target_addr_t address,
17671767
int handle_breakpoints)
17681768
{
17691769
riscv011_info_t *info = get_info(target);
@@ -2196,8 +2196,8 @@ static int riscv011_poll(struct target *target)
21962196
return poll_target(target, true);
21972197
}
21982198

2199-
static int riscv011_resume(struct target *target, int current, uint32_t address,
2200-
int handle_breakpoints, int debug_execution)
2199+
static int riscv011_resume(struct target *target, int current,
2200+
target_addr_t address, int handle_breakpoints, int debug_execution)
22012201
{
22022202
riscv011_info_t *info = get_info(target);
22032203

@@ -2266,7 +2266,7 @@ static int deassert_reset(struct target *target)
22662266
}
22672267
}
22682268

2269-
static int read_memory(struct target *target, uint32_t address,
2269+
static int read_memory(struct target *target, target_addr_t address,
22702270
uint32_t size, uint32_t count, uint8_t *buffer)
22712271
{
22722272
jtag_add_ir_scan(target->tap, &select_dbus, TAP_IDLE);
@@ -2377,18 +2377,19 @@ static int read_memory(struct target *target, uint32_t address,
23772377
wait_for_debugint_clear(target, false);
23782378

23792379
// Retry.
2380-
LOG_INFO("Retrying memory read starting from 0x%x with more delays",
2381-
address + size * i);
2380+
LOG_INFO("Retrying memory read starting from 0x%" TARGET_PRIxADDR
2381+
" with more delays", address + size * i);
23822382
} else {
23832383
i += batch_size;
23842384
}
23852385
}
23862386

23872387
if (result_value != 0) {
2388-
LOG_USER("Core got an exception (0x%x) while reading from 0x%x",
2389-
result_value, address + size * (count-1));
2388+
LOG_USER("Core got an exception (0x%x) while reading from 0x%"
2389+
TARGET_PRIxADDR, result_value, address + size * (count-1));
23902390
if (count > 1) {
2391-
LOG_USER("(It may have failed between 0x%x and 0x%x as well, but we "
2391+
LOG_USER("(It may have failed between 0x%" TARGET_PRIxADDR
2392+
" and 0x%" TARGET_PRIxADDR " as well, but we "
23922393
"didn't check then.)",
23932394
address, address + size * (count-2) + size - 1);
23942395
}
@@ -2431,7 +2432,7 @@ static int setup_write_memory(struct target *target, uint32_t size)
24312432
return ERROR_OK;
24322433
}
24332434

2434-
static int write_memory(struct target *target, uint32_t address,
2435+
static int write_memory(struct target *target, target_addr_t address,
24352436
uint32_t size, uint32_t count, const uint8_t *buffer)
24362437
{
24372438
riscv011_info_t *info = get_info(target);
@@ -2536,8 +2537,8 @@ static int write_memory(struct target *target, uint32_t address,
25362537
// Retry.
25372538
// Set t0 back to what it should have been at the beginning of this
25382539
// batch.
2539-
LOG_INFO("Retrying memory write starting from 0x%x with more delays",
2540-
address + size * i);
2540+
LOG_INFO("Retrying memory write starting from 0x%" TARGET_PRIxADDR
2541+
" with more delays", address + size * i);
25412542

25422543
cache_clean(target);
25432544

@@ -2554,10 +2555,11 @@ static int write_memory(struct target *target, uint32_t address,
25542555
}
25552556

25562557
if (result_value != 0) {
2557-
LOG_ERROR("Core got an exception (0x%x) while writing to 0x%x",
2558-
result_value, address + size * (count-1));
2558+
LOG_ERROR("Core got an exception (0x%x) while writing to 0x%"
2559+
TARGET_PRIxADDR, result_value, address + size * (count-1));
25592560
if (count > 1) {
2560-
LOG_ERROR("(It may have failed between 0x%x and 0x%x as well, but we "
2561+
LOG_ERROR("(It may have failed between 0x%" TARGET_PRIxADDR
2562+
" and 0x%" TARGET_PRIxADDR " as well, but we "
25612563
"didn't check then.)",
25622564
address, address + size * (count-2) + size - 1);
25632565
}

src/target/riscv/riscv-013.c

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#include "config.h"
1212
#endif
1313

14-
#include "target.h"
14+
#include "target/target.h"
1515
#include "target/algorithm.h"
16-
#include "target_type.h"
16+
#include "target/target_type.h"
1717
#include "log.h"
1818
#include "jtag/jtag.h"
19-
#include "register.h"
20-
#include "breakpoints.h"
19+
#include "target/register.h"
20+
#include "target/breakpoints.h"
2121
#include "helper/time_support.h"
2222
#include "riscv.h"
2323
#include "debug_defines.h"
@@ -34,7 +34,8 @@ static riscv_addr_t riscv013_progbuf_addr(struct target *target);
3434
static riscv_addr_t riscv013_progbuf_size(struct target *target);
3535
static riscv_addr_t riscv013_data_size(struct target *target);
3636
static riscv_addr_t riscv013_data_addr(struct target *target);
37-
static void riscv013_set_autoexec(struct target *target, int offset, bool enabled);
37+
static void riscv013_set_autoexec(struct target *target, unsigned index,
38+
bool enabled);
3839
static int riscv013_debug_buffer_register(struct target *target, riscv_addr_t addr);
3940
static void riscv013_clear_abstract_error(struct target *target);
4041

@@ -52,8 +53,10 @@ static bool riscv013_is_halted(struct target *target);
5253
static enum riscv_halt_reason riscv013_halt_reason(struct target *target);
5354
static void riscv013_debug_buffer_enter(struct target *target, struct riscv_program *p);
5455
static void riscv013_debug_buffer_leave(struct target *target, struct riscv_program *p);
55-
static void riscv013_write_debug_buffer(struct target *target, int i, riscv_insn_t d);
56-
static riscv_insn_t riscv013_read_debug_buffer(struct target *target, int i);
56+
static void riscv013_write_debug_buffer(struct target *target, unsigned index,
57+
riscv_insn_t d);
58+
static riscv_insn_t riscv013_read_debug_buffer(struct target *target, unsigned
59+
index);
5760
static int riscv013_execute_debug_buffer(struct target *target);
5861
static void riscv013_fill_dmi_write_u64(struct target *target, char *buf, int a, uint64_t d);
5962
static void riscv013_fill_dmi_read_u64(struct target *target, char *buf, int a);
@@ -862,8 +865,8 @@ static int add_breakpoint(struct target *target,
862865
if (breakpoint->type == BKPT_SOFT) {
863866
if (target_read_memory(target, breakpoint->address, breakpoint->length, 1,
864867
breakpoint->orig_instr) != ERROR_OK) {
865-
LOG_ERROR("Failed to read original instruction at 0x%x",
866-
breakpoint->address);
868+
LOG_ERROR("Failed to read original instruction at 0x%"
869+
TARGET_PRIxADDR, breakpoint->address);
867870
return ERROR_FAIL;
868871
}
869872

@@ -874,8 +877,8 @@ static int add_breakpoint(struct target *target,
874877
retval = target_write_u16(target, breakpoint->address, ebreak_c());
875878
}
876879
if (retval != ERROR_OK) {
877-
LOG_ERROR("Failed to write %d-byte breakpoint instruction at 0x%x",
878-
breakpoint->length, breakpoint->address);
880+
LOG_ERROR("Failed to write %d-byte breakpoint instruction at 0x%"
881+
TARGET_PRIxADDR, breakpoint->length, breakpoint->address);
879882
return ERROR_FAIL;
880883
}
881884

@@ -903,7 +906,8 @@ static int remove_breakpoint(struct target *target,
903906
if (target_write_memory(target, breakpoint->address, breakpoint->length, 1,
904907
breakpoint->orig_instr) != ERROR_OK) {
905908
LOG_ERROR("Failed to restore instruction for %d-byte breakpoint at "
906-
"0x%x", breakpoint->length, breakpoint->address);
909+
"0x%" TARGET_PRIxADDR, breakpoint->length,
910+
breakpoint->address);
907911
return ERROR_FAIL;
908912
}
909913

@@ -1203,7 +1207,7 @@ static int deassert_reset(struct target *target)
12031207
return ERROR_OK;
12041208
}
12051209

1206-
static int read_memory(struct target *target, uint32_t address,
1210+
static int read_memory(struct target *target, target_addr_t address,
12071211
uint32_t size, uint32_t count, uint8_t *buffer)
12081212
{
12091213
RISCV013_INFO(info);
@@ -1397,7 +1401,7 @@ static int read_memory(struct target *target, uint32_t address,
13971401
return ERROR_OK;
13981402
}
13991403

1400-
static int write_memory(struct target *target, uint32_t address,
1404+
static int write_memory(struct target *target, target_addr_t address,
14011405
uint32_t size, uint32_t count, const uint8_t *buffer)
14021406
{
14031407
RISCV013_INFO(info);
@@ -1770,14 +1774,14 @@ void riscv013_debug_buffer_leave(struct target *target, struct riscv_program *pr
17701774
{
17711775
}
17721776

1773-
void riscv013_write_debug_buffer(struct target *target, int index, riscv_insn_t data)
1777+
void riscv013_write_debug_buffer(struct target *target, unsigned index, riscv_insn_t data)
17741778
{
17751779
if (index >= riscv013_progbuf_size(target))
17761780
return dmi_write(target, DMI_DATA0 + index - riscv013_progbuf_size(target), data);
17771781
return dmi_write(target, DMI_PROGBUF0 + index, data);
17781782
}
17791783

1780-
riscv_insn_t riscv013_read_debug_buffer(struct target *target, int index)
1784+
riscv_insn_t riscv013_read_debug_buffer(struct target *target, unsigned index)
17811785
{
17821786
if (index >= riscv013_progbuf_size(target))
17831787
return dmi_read(target, DMI_DATA0 + index - riscv013_progbuf_size(target));
@@ -1958,22 +1962,22 @@ riscv_addr_t riscv013_data_addr(struct target *target)
19581962
return info->data_addr;
19591963
}
19601964

1961-
void riscv013_set_autoexec(struct target *target, int offset, bool enabled)
1965+
void riscv013_set_autoexec(struct target *target, unsigned index, bool enabled)
19621966
{
1963-
if (offset >= riscv013_progbuf_size(target)) {
1964-
LOG_DEBUG("setting bit %d in AUTOEXECDATA to %d", offset, enabled);
1967+
if (index >= riscv013_progbuf_size(target)) {
1968+
LOG_DEBUG("setting bit %d in AUTOEXECDATA to %d", index, enabled);
19651969
uint32_t aa = dmi_read(target, DMI_ABSTRACTAUTO);
19661970
uint32_t aa_aed = get_field(aa, DMI_ABSTRACTAUTO_AUTOEXECDATA);
1967-
aa_aed &= ~(1 << (offset - riscv013_progbuf_size(target)));
1968-
aa_aed |= (enabled << (offset - riscv013_progbuf_size(target)));
1971+
aa_aed &= ~(1 << (index - riscv013_progbuf_size(target)));
1972+
aa_aed |= (enabled << (index - riscv013_progbuf_size(target)));
19691973
aa = set_field(aa, DMI_ABSTRACTAUTO_AUTOEXECDATA, aa_aed);
19701974
dmi_write(target, DMI_ABSTRACTAUTO, aa);
19711975
} else {
1972-
LOG_DEBUG("setting bit %d in AUTOEXECPROGBUF to %d", offset, enabled);
1976+
LOG_DEBUG("setting bit %d in AUTOEXECPROGBUF to %d", index, enabled);
19731977
uint32_t aa = dmi_read(target, DMI_ABSTRACTAUTO);
19741978
uint32_t aa_aed = get_field(aa, DMI_ABSTRACTAUTO_AUTOEXECPROGBUF);
1975-
aa_aed &= ~(1 << offset);
1976-
aa_aed |= (enabled << offset);
1979+
aa_aed &= ~(1 << index);
1980+
aa_aed |= (enabled << index);
19771981
aa = set_field(aa, DMI_ABSTRACTAUTO_AUTOEXECPROGBUF, aa_aed);
19781982
dmi_write(target, DMI_ABSTRACTAUTO, aa);
19791983
}

0 commit comments

Comments
 (0)