@@ -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)
@@ -547,6 +549,7 @@ static void cortexar_regs_save(target_s *const target)
547549
548550static inline void cortexar_core_reg_write (target_s * const target , const uint8_t reg , const uint32_t value )
549551{
552+ cortexar_priv_s * const priv = (cortexar_priv_s * )target -> priv ;
550553 /* If the register is a GPR and not the program counter, use a "simple" MCR to read */
551554 if (reg < 15U )
552555 /* Build and issue a coprocessor to core transfer for the requested register and send the new data */
@@ -638,16 +641,33 @@ static void cortexar_coproc_write(target_s *const target, const uint8_t coproc,
638641 ENCODE_CP_ACCESS (coproc & 0xfU , (op >> 8U ) & 0x7U , 0U , (op >> 4U ) & 0xfU , op & 0xfU , (op >> 12U ) & 0x7U ));
639642}
640643
644+ /*
645+ * Check if the provided address falls within defined RAM ranges for the target
646+ */
647+ static bool cortexar_check_is_addr_in_ram (target_s * const target , const target_addr_t addr )
648+ {
649+ for (target_ram_s * r = target -> ram ; r ; r = r -> next ) {
650+ if (addr >= r -> start && addr < r -> start + r -> length ) {
651+ return true;
652+ }
653+ }
654+ return false;
655+ }
656+
641657/*
642658 * Perform a virtual to physical address translation.
643659 * NB: This requires the core to be halted! Trashes r0.
644660 */
645661static target_addr_t cortexar_virt_to_phys (target_s * const target , const target_addr_t virt_addr )
646662{
663+ /* If address is a RAM location for the target, keep it as-is. */
664+ if (cortexar_check_is_addr_in_ram (target , virt_addr )) {
665+ return virt_addr ;
666+ }
667+
647668 /* Check if the target is PMSA and return early if it is */
648669 if (!(target -> target_options & TOPT_FLAVOUR_VIRT_MEM ))
649670 return virt_addr ;
650-
651671 /*
652672 * Now we know the target is VMSA and so has the address translation machinery,
653673 * start by loading r0 with the VA to translate and request its translation
@@ -1455,6 +1475,7 @@ static void cortexar_halt_resume(target_s *const target, const bool step)
14551475 /* Invalidate all the instruction caches if we're on a VMSA model device */
14561476 if (target -> target_options & TOPT_FLAVOUR_VIRT_MEM )
14571477 cortexar_coproc_write (target , CORTEXAR_ICIALLU , 0U );
1478+
14581479 /* Mark the fault status and address cache invalid */
14591480 priv -> core_status &= ~CORTEXAR_STATUS_FAULT_CACHE_VALID ;
14601481
0 commit comments