Skip to content

Commit

Permalink
Merge pull request #1194 from fk-sc/fk-sc/merge-read-write
Browse files Browse the repository at this point in the history
target/riscv: merged read/write functions to one access function
  • Loading branch information
en-sc authored Feb 21, 2025
2 parents fac1412 + dce6182 commit 56b7830
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 178 deletions.
13 changes: 10 additions & 3 deletions src/target/riscv/riscv-011.c
Original file line number Diff line number Diff line change
Expand Up @@ -2325,6 +2325,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 @@ -2416,9 +2425,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 56b7830

Please sign in to comment.