Skip to content

Commit dce6182

Browse files
committed
target/riscv: merged read/write functions to one access function
Commit merges read/write functions to access function. It allows to decrease amount of code duplication. Signed-off-by: Farid Khaydari <[email protected]>
1 parent fac1412 commit dce6182

File tree

4 files changed

+111
-178
lines changed

4 files changed

+111
-178
lines changed

src/target/riscv/riscv-011.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,6 +2325,15 @@ static int write_memory(struct target *target, const riscv_mem_access_args_t arg
23252325
return ERROR_FAIL;
23262326
}
23272327

2328+
static int access_memory(struct target *target, const riscv_mem_access_args_t args)
2329+
{
2330+
assert(riscv_mem_access_is_valid(args));
2331+
const bool is_write = riscv_mem_access_is_write(args);
2332+
if (is_write)
2333+
return write_memory(target, args);
2334+
return read_memory(target, args);
2335+
}
2336+
23282337
static int arch_state(struct target *target)
23292338
{
23302339
return ERROR_OK;
@@ -2416,9 +2425,7 @@ static int init_target(struct command_context *cmd_ctx,
24162425
{
24172426
LOG_DEBUG("init");
24182427
RISCV_INFO(generic_info);
2419-
/* TODO: replace read and write with single access function*/
2420-
generic_info->read_memory = read_memory;
2421-
generic_info->write_memory = write_memory;
2428+
generic_info->access_memory = access_memory;
24222429
generic_info->authdata_read = &riscv011_authdata_read;
24232430
generic_info->authdata_write = &riscv011_authdata_write;
24242431
generic_info->print_info = &riscv011_print_info;

0 commit comments

Comments
 (0)