Skip to content

Commit fc57ee5

Browse files
committed
cortexar: pc set correctly, hard breakpoints working in RAM
* PC is getting set correctly now. * I'm able to set hard breakpoints for RAM addresses by bypassing the cortexar_virt_to_phys function's logic when the address falls within defined RAM.
1 parent 3d71884 commit fc57ee5

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/target/cortexar.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ static const uint16_t cortexar_spsr_encodings[5] = {
312312
/* Instruction Cache Invalidate ALL to Unification */
313313
#define CORTEXAR_ICIALLU 15U, ENCODE_CP_REG(7U, 5U, 0U, 0U)
314314
/* Data Cache Clean + Invalidate by Set/Way to Unification */
315+
#define CORTEXAR_DCCSW 15U, ENCODE_CP_REG(7U, 10U, 0U, 2U)
316+
/* Data Cache Clean + Invalidate by Set/Way to Unification */
315317
#define CORTEXAR_DCCISW 15U, ENCODE_CP_REG(7U, 14U, 0U, 2U)
316318
/* Address Translate Stage 1 Current state PL1 Read */
317319
#define CORTEXAR_ATS1CPR 15U, ENCODE_CP_REG(7U, 8U, 0U, 0U)
@@ -638,16 +640,33 @@ static void cortexar_coproc_write(target_s *const target, const uint8_t coproc,
638640
ENCODE_CP_ACCESS(coproc & 0xfU, (op >> 8U) & 0x7U, 0U, (op >> 4U) & 0xfU, op & 0xfU, (op >> 12U) & 0x7U));
639641
}
640642

643+
/*
644+
* Check if the provided address falls within defined RAM ranges for the target
645+
*/
646+
static bool cortexar_check_is_addr_in_ram(target_s *const target, const target_addr_t addr)
647+
{
648+
for (target_ram_s *r = target->ram; r; r = r->next) {
649+
if (addr >= r->start && addr < r->start + r->length) {
650+
return true;
651+
}
652+
}
653+
return false;
654+
}
655+
641656
/*
642657
* Perform a virtual to physical address translation.
643658
* NB: This requires the core to be halted! Trashes r0.
644659
*/
645660
static target_addr_t cortexar_virt_to_phys(target_s *const target, const target_addr_t virt_addr)
646661
{
662+
/* If address is a RAM location for the target, keep it as-is. */
663+
if (cortexar_check_is_addr_in_ram(target, virt_addr)) {
664+
return virt_addr;
665+
}
666+
647667
/* Check if the target is PMSA and return early if it is */
648668
if (!(target->target_options & TOPT_FLAVOUR_VIRT_MEM))
649669
return virt_addr;
650-
651670
/*
652671
* Now we know the target is VMSA and so has the address translation machinery,
653672
* start by loading r0 with the VA to translate and request its translation
@@ -1455,6 +1474,7 @@ static void cortexar_halt_resume(target_s *const target, const bool step)
14551474
/* Invalidate all the instruction caches if we're on a VMSA model device */
14561475
if (target->target_options & TOPT_FLAVOUR_VIRT_MEM)
14571476
cortexar_coproc_write(target, CORTEXAR_ICIALLU, 0U);
1477+
14581478
/* Mark the fault status and address cache invalid */
14591479
priv->core_status &= ~CORTEXAR_STATUS_FAULT_CACHE_VALID;
14601480

0 commit comments

Comments
 (0)