Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

target/riscv: pass memory access info in struct, move write_memory pointer #1167

Open
wants to merge 1 commit into
base: riscv
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/target/riscv/riscv-011.c
Original file line number Diff line number Diff line change
Expand Up @@ -1972,9 +1972,14 @@ static int deassert_reset(struct target *target)
return wait_for_state(target, TARGET_RUNNING);
}

static int read_memory(struct target *target, target_addr_t address,
uint32_t size, uint32_t count, uint8_t *buffer, uint32_t increment)
static int read_memory(struct target *target, riscv_mem_access_info_t access)
{
target_addr_t address = access.target_address;
uint32_t size = access.element_size;
uint32_t count = access.count;
uint8_t *buffer = access.buffer.read;
uint32_t increment = access.increment;

if (increment != size) {
LOG_ERROR("read_memory with custom increment not implemented");
return ERROR_NOT_IMPLEMENTED;
Expand Down Expand Up @@ -2142,9 +2147,18 @@ static int setup_write_memory(struct target *target, uint32_t size)
return ERROR_OK;
}

static int write_memory(struct target *target, target_addr_t address,
uint32_t size, uint32_t count, const uint8_t *buffer)
static int write_memory(struct target *target, riscv_mem_access_info_t access)
{
if (access.increment != access.element_size) {
LOG_TARGET_ERROR(target, "Write increment size has to be equal to element size");
return ERROR_NOT_IMPLEMENTED;
}

target_addr_t address = access.target_address;
uint32_t size = access.element_size;
uint32_t count = access.count;
const uint8_t *buffer = access.buffer.write;

riscv011_info_t *info = get_info(target);
jtag_add_ir_scan(target->tap, &select_dbus, TAP_IDLE);

Expand Down Expand Up @@ -2371,7 +2385,9 @@ 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->authdata_read = &riscv011_authdata_read;
generic_info->authdata_write = &riscv011_authdata_write;
generic_info->print_info = &riscv011_print_info;
Expand Down Expand Up @@ -2406,7 +2422,5 @@ struct target_type riscv011_target = {
.assert_reset = assert_reset,
.deassert_reset = deassert_reset,

.write_memory = write_memory,

.arch_state = arch_state,
};
Loading
Loading