|
From: openocd-gerrit <ope...@us...> - 2026-09-06 14:46:02
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via c71aab122e05b31d3e56a5514babba9bbdfa6ac0 (commit)
via 3280595478bc2cdd5cd58b1a2069b3cf1d755f7c (commit)
from 70ea3c01b042f6aefd0fe7f92db416c0cec683e3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c71aab122e05b31d3e56a5514babba9bbdfa6ac0
Author: Jan Matyas <jan...@co...>
Date: Fri Jun 12 15:34:01 2026 +0200
target/riscv: refactor scratch_reserve() - use standardized macros
The original author of this commit is Farid Khaidari, see [1].
This commit refactors the scratch_reserve()
- Replacing hardcoded bit manipulation with BIT() macro
- Using GENMASK_ULL() instead of hardcoded masks for sign extension
- Applying ALIGN_UP() macro for address alignment calculations
- Using DIV_ROUND_UP() instead of manual division with addition
[1] https://github.com/riscv-collab/riscv-openocd/
commit/9d4c94e51fdaba3290a16825e48f393b9650a321
Change-Id: Ic40923ef7d9ac5ca0ffb313c9d4fc6d1457d6bbb
Signed-off-by: Farid Khaydari <f.k...@sy...>
Signed-off-by: Jan Matyas <jan...@co...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9742
Reviewed-by: Evgeniy Naydanov <eu...@gm...>
Reviewed-by: Antonio Borneo <bor...@gm...>
Tested-by: jenkins
Reviewed-by: Mark Zhuang <mar...@sp...>
Reviewed-by: Farid Khaidari <kha...@gm...>
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index ae5ca1052..449175634 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -1227,12 +1227,13 @@ static int scratch_reserve(struct target *target,
if (info->dataaccess == 1) {
/* Sign extend dataaddr. */
scratch->hart_address = info->dataaddr;
- if (info->dataaddr & (1<<11))
- scratch->hart_address |= 0xfffffffffffff000ULL;
+ if (info->dataaddr & BIT(DM_HARTINFO_DATAADDR_LENGTH - 1))
+ scratch->hart_address |=
+ GENMASK_ULL(riscv_xlen(target) - 1, DM_HARTINFO_DATAADDR_LENGTH);
/* Align. */
- scratch->hart_address = (scratch->hart_address + alignment - 1) & ~(alignment - 1);
+ scratch->hart_address = ALIGN_UP(scratch->hart_address, alignment);
- if ((size_bytes + scratch->hart_address - info->dataaddr + 3) / 4 <=
+ if (DIV_ROUND_UP(size_bytes + scratch->hart_address - info->dataaddr, 4) <=
info->datasize) {
scratch->memory_space = SPACE_DM_DATA;
scratch->debug_address = (scratch->hart_address - info->dataaddr) / 4;
@@ -1246,10 +1247,9 @@ static int scratch_reserve(struct target *target,
/* Allow for ebreak at the end of the program. */
unsigned int program_size = (program->instruction_count + 1) * 4;
- scratch->hart_address = (info->progbuf_address + program_size + alignment - 1) &
- ~(alignment - 1);
+ scratch->hart_address = ALIGN_UP(info->progbuf_address + program_size, alignment);
if ((info->progbuf_writable == YNM_YES) &&
- ((size_bytes + scratch->hart_address - info->progbuf_address + 3) / 4 <=
+ (DIV_ROUND_UP(size_bytes + scratch->hart_address - info->progbuf_address, 4) <=
info->progbufsize)) {
scratch->memory_space = SPACE_DMI_PROGBUF;
scratch->debug_address = (scratch->hart_address - info->progbuf_address) / 4;
@@ -1259,8 +1259,7 @@ static int scratch_reserve(struct target *target,
/* 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) &
- ~(alignment - 1);
+ scratch->hart_address = ALIGN_UP(scratch->area->address, alignment);
scratch->memory_space = SPACE_DMI_RAM;
scratch->debug_address = scratch->hart_address;
return ERROR_OK;
commit 3280595478bc2cdd5cd58b1a2069b3cf1d755f7c
Author: Jan Matyas <jan...@co...>
Date: Fri Jun 12 15:26:37 2026 +0200
target/riscv: fix bug in scratch_reserve
This commit fixes comparison in scratch_reserve function.
Original author of this fix is Farid Khaydari, see [1].
[1] https://github.com/riscv-collab/riscv-openocd/
commit/10f1659f5ef048486acf8ec9925d2c2e2b87f1dd
Change-Id: I64399fb640ffe3a77dd7e6692592e9dcf8986d9b
Signed-off-by: Farid Khaydari <f.k...@sy...>
Signed-off-by: Jan Matyas <jan...@co...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9741
Tested-by: jenkins
Reviewed-by: Mark Zhuang <mar...@sp...>
Reviewed-by: Antonio Borneo <bor...@gm...>
Reviewed-by: Evgeniy Naydanov <eu...@gm...>
Reviewed-by: Farid Khaidari <kha...@gm...>
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index 4925f0604..ae5ca1052 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -1232,7 +1232,7 @@ static int scratch_reserve(struct target *target,
/* Align. */
scratch->hart_address = (scratch->hart_address + alignment - 1) & ~(alignment - 1);
- if ((size_bytes + scratch->hart_address - info->dataaddr + 3) / 4 >=
+ if ((size_bytes + scratch->hart_address - info->dataaddr + 3) / 4 <=
info->datasize) {
scratch->memory_space = SPACE_DM_DATA;
scratch->debug_address = (scratch->hart_address - info->dataaddr) / 4;
@@ -1249,7 +1249,7 @@ static int scratch_reserve(struct target *target,
scratch->hart_address = (info->progbuf_address + program_size + alignment - 1) &
~(alignment - 1);
if ((info->progbuf_writable == YNM_YES) &&
- ((size_bytes + scratch->hart_address - info->progbuf_address + 3) / 4 >=
+ ((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;
-----------------------------------------------------------------------
Summary of changes:
src/target/riscv/riscv-013.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|