Skip to content

Commit

Permalink
target/riscv: merged read/write functions to one access function
Browse files Browse the repository at this point in the history
Commit merges read/write functions to access function. It allows to decrease amount of code duplication

Signed-off-by: Farid Khaydari <[email protected]>
  • Loading branch information
fk-sc committed Dec 26, 2024
1 parent f82c5a7 commit 02d8718
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 208 deletions.
12 changes: 10 additions & 2 deletions src/target/riscv/riscv-011.c
Original file line number Diff line number Diff line change
Expand Up @@ -2298,6 +2298,15 @@ static int write_memory(struct target *target, const riscv_mem_access_args_t arg
return ERROR_FAIL;
}

static int access_memory(struct target *target, const riscv_mem_access_args_t args)
{
assert(riscv_mem_access_is_valid(args));
const bool is_write = riscv_mem_access_is_write(args);
if (is_write)
return write_memory(target, args);
return read_memory(target, args);
}

static int arch_state(struct target *target)
{
return ERROR_OK;
Expand Down Expand Up @@ -2390,8 +2399,7 @@ static int init_target(struct command_context *cmd_ctx,
LOG_DEBUG("init");
RISCV_INFO(generic_info);
/* TODO: replace read and write with single access function*/
generic_info->read_memory = read_memory;
generic_info->write_memory = write_memory;
generic_info->access_memory = access_memory;
generic_info->authdata_read = &riscv011_authdata_read;
generic_info->authdata_write = &riscv011_authdata_write;
generic_info->print_info = &riscv011_print_info;
Expand Down
Loading

0 comments on commit 02d8718

Please sign in to comment.