aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Matyas <50193733+JanMatCodasip@users.noreply.github.com>2019-11-20 21:00:00 +0100
committerTim Newsome <tim@sifive.com>2019-11-20 12:00:00 -0800
commit739d16d503e4a446d28e43e025f3b355d262b51f (patch)
tree2cb1a8d967e7b3c9b4e4acd252e0d6f8b7eea930
parente944de422eb9813267f9e8977124f0bbe1da1b31 (diff)
downloadriscv-openocd-739d16d503e4a446d28e43e025f3b355d262b51f.zip
riscv-openocd-739d16d503e4a446d28e43e025f3b355d262b51f.tar.gz
riscv-openocd-739d16d503e4a446d28e43e025f3b355d262b51f.tar.bz2
Fix: Take into account progbuf writability. (#424)
When allocating scratch memory within RISC-V target (scratch_reserve()), take into account whether progbuf is writable or not, as determined by examine_progbuf().
-rw-r--r--src/target/riscv/riscv-013.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index 26f8b20..a673265 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -1073,6 +1073,7 @@ static int scratch_reserve(struct target *target,
riscv013_info_t *info = get_info(target);
+ /* Option 1: See if data# registers can be used as the scratch memory */
if (info->dataaccess == 1) {
/* Sign extend dataaddr. */
scratch->hart_address = info->dataaddr;
@@ -1089,6 +1090,7 @@ static int scratch_reserve(struct target *target,
}
}
+ /* Option 2: See if progbuf can be used as the scratch memory */
if (examine_progbuf(target) != ERROR_OK)
return ERROR_FAIL;
@@ -1096,13 +1098,15 @@ static int scratch_reserve(struct target *target,
unsigned program_size = (program->instruction_count + 1) * 4;
scratch->hart_address = (info->progbuf_address + program_size + alignment - 1) &
~(alignment - 1);
- if ((size_bytes + scratch->hart_address - info->progbuf_address + 3) / 4 >=
- info->progbufsize) {
+ if ((info->progbuf_writable == YNM_YES) &&
+ ((size_bytes + scratch->hart_address - info->progbuf_address + 3) / 4 >=
+ info->progbufsize)) {
scratch->memory_space = SPACE_DMI_PROGBUF;
scratch->debug_address = (scratch->hart_address - info->progbuf_address) / 4;
return ERROR_OK;
}
+ /* Option 3: User-configured memory area as scratch RAM */
if (target_alloc_working_area(target, size_bytes + alignment - 1,
&scratch->area) == ERROR_OK) {
scratch->hart_address = (scratch->area->address + alignment - 1) &