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

cortexar: halt core in cortexar_mem_write #2012

Merged
Merged
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
8 changes: 8 additions & 0 deletions src/target/cortexar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1220,10 +1220,15 @@ static bool cortexar_mem_write_slow(
* This writes memory by jumping from the debug unit bus to the system bus.
* NB: This requires the core to be halted! Uses instruction launches on
* the core and requires we're in debug mode to work. Trashes r0.
* If core is not halted, temporarily halts target and resumes at the end
* of the function.
*/
static void cortexar_mem_write(
target_s *const target, const target_addr64_t dest, const void *const src, const size_t len)
{
/* If system is not halted, halt temporarily within this function. */
const bool halted_in_function = cortexar_halt_and_wait(target);

cortexar_priv_s *const priv = (cortexar_priv_s *)target->priv;
DEBUG_PROTO("%s: Writing %zu bytes @0x%" PRIx64 ":", __func__, len, dest);
#ifndef DEBUG_PROTO_IS_NOOP
Expand Down Expand Up @@ -1257,6 +1262,9 @@ static void cortexar_mem_write(
cortexar_mem_write_slow(target, dest, (const uint8_t *)src, len);
/* Deal with any data faults that occurred */
cortexar_mem_handle_fault(target, __func__);

if (halted_in_function)
cortexar_halt_resume(target, false);
}

static void cortexar_regs_read(target_s *const target, void *const data)
Expand Down
Loading