Skip to content

Commit

Permalink
cortexm: allow updating demcr from outside
Browse files Browse the repository at this point in the history
Allow outside accessors to update the demcr. This is useful for updating
the exceptions to catch for handling things like devices that go into
powersave.

Signed-off-by: Sean Cross <sean@xobs.io>
  • Loading branch information
xobs authored and dragonmux committed Sep 27, 2024
1 parent 7ce749e commit 2a827f1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/target/cortexm.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,24 @@ static void cortexm_mem_write(target_s *target, target_addr64_t dest, const void
adiv5_mem_write(cortex_ap(target), dest, src, len);
}

bool target_is_cortexm(const target_s *target)
{
return target == NULL && target->regs_description == cortexm_target_description;
}

uint32_t cortexm_demcr_read(const target_s *target)
{
const cortexm_priv_s *priv = (const cortexm_priv_s *)target->priv;
return priv->demcr;
}

void cortexm_demcr_write(target_s *target, uint32_t demcr)
{
cortexm_priv_s *priv = (cortexm_priv_s *)target->priv;
priv->demcr = demcr;
target_mem32_write32(target, CORTEXM_DEMCR, demcr);
}

bool cortexm_probe(adiv5_access_port_s *ap)
{
target_s *target = target_new();
Expand Down
3 changes: 3 additions & 0 deletions src/target/cortexm.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,8 @@ void cortexm_detach(target_s *target);
void cortexm_halt_resume(target_s *target, bool step);
bool cortexm_run_stub(target_s *target, uint32_t loadaddr, uint32_t r0, uint32_t r1, uint32_t r2, uint32_t r3);
int cortexm_mem_write_aligned(target_s *target, target_addr_t dest, const void *src, size_t len, align_e align);
uint32_t cortexm_demcr_read(const target_s *target);
void cortexm_demcr_write(target_s *target, uint32_t demcr);
bool target_is_cortexm(const target_s *target);

#endif /* TARGET_CORTEXM_H */

0 comments on commit 2a827f1

Please sign in to comment.