@@ -70,6 +70,8 @@ typedef struct cortexar_priv {
7070 uint32_t spsr [5U ];
7171 uint64_t d [16U ];
7272 uint32_t fpcsr ;
73+ uint32_t dfsr ;
74+ uint32_t dfar ;
7375 } core_regs ;
7476
7577 /* Fault status/address cache */
@@ -701,7 +703,6 @@ static target_addr_t cortexar_virt_to_phys(target_s *const target, const target_
701703static bool cortexar_oslock_unlock (target_s * const target )
702704{
703705 const uint32_t lock_status = cortex_dbg_read32 (target , CORTEXAR_DBG_OSLSR );
704- DEBUG_TARGET ("%s: OS lock status: %08" PRIx32 "\n" , __func__ , lock_status );
705706 /* Check if the lock is implemented, then if it is, if it's set */
706707 if (((lock_status & CORTEXAR_DBG_OSLSR_OS_LOCK_MODEL ) == CORTEXAR_DBG_OSLSR_OS_LOCK_MODEL_FULL ||
707708 (lock_status & CORTEXAR_DBG_OSLSR_OS_LOCK_MODEL ) == CORTEXAR_DBG_OSLSR_OS_LOCK_MODEL_PARTIAL ) &&
@@ -1022,7 +1023,8 @@ static inline uint32_t cortexar_endian_dp_read(target_s *const target, const uin
10221023{
10231024 cortexar_priv_s * const priv = (cortexar_priv_s * )target -> priv ;
10241025 uint32_t value = adiv5_dp_read (priv -> base .ap -> dp , addr );
1025- if (target -> target_options & TOPT_FLAVOUR_BE ) {
1026+ extern bool skip_swap ;
1027+ if ((target -> target_options & TOPT_FLAVOUR_BE ) && !skip_swap ) {
10261028 uint8_t tmp_value [4 ];
10271029 // The instruction run gave us back a value that we interpreted as little endian, however
10281030 write_le4 (tmp_value , 0 , value );
@@ -1035,8 +1037,9 @@ static inline uint32_t cortexar_endian_dp_read(target_s *const target, const uin
10351037static inline void cortexar_endian_dp_write (target_s * const target , const uint16_t addr , uint32_t value )
10361038{
10371039 cortexar_priv_s * const priv = (cortexar_priv_s * )target -> priv ;
1040+ extern bool skip_swap ;
10381041
1039- if (target -> target_options & TOPT_FLAVOUR_BE ) {
1042+ if (( target -> target_options & TOPT_FLAVOUR_BE ) && ! skip_swap ) {
10401043 uint8_t tmp_value [4 ];
10411044 // The instruction run gave us back a value that we interpreted as little endian, however
10421045 write_le4 (tmp_value , 0 , value );
@@ -1082,7 +1085,8 @@ static inline bool cortexar_mem_read_fast(target_s *const target, uint32_t *cons
10821085 for (size_t offset = 0 ; offset < count ; ++ offset ) {
10831086 if (!cortexar_run_read_insn (target , ARM_LDC_R0_POSTINC4_DTRTX_INSN , dest + offset ))
10841087 return false; /* Propagate failure if it happens */
1085- if (target -> target_options & TOPT_FLAVOUR_BE ) {
1088+ extern bool skip_swap ;
1089+ if ((target -> target_options & TOPT_FLAVOUR_BE ) && !skip_swap ) {
10861090 uint8_t value [4 ];
10871091 // The instruction run gave us back a value that we interpreted as little endian, however
10881092 write_le4 (value , 0 , dest [offset ]);
@@ -1226,7 +1230,8 @@ static inline bool cortexar_mem_write_fast(target_s *const target, const uint32_
12261230 /* Write each of the uint32_t's checking for failure */
12271231 for (size_t offset = 0 ; offset < count ; ++ offset ) {
12281232 uint32_t value ;
1229- if (target -> target_options & TOPT_FLAVOUR_BE )
1233+ extern bool skip_swap ;
1234+ if ((target -> target_options & TOPT_FLAVOUR_BE ) && !skip_swap )
12301235 value = read_be4 ((const void * )src , offset * 4U );
12311236 else
12321237 value = read_le4 ((const void * )src , offset * 4U );
@@ -1330,25 +1335,26 @@ static void cortexar_regs_read(target_s *const target, void *const data)
13301335{
13311336 const cortexar_priv_s * const priv = (cortexar_priv_s * )target -> priv ;
13321337 uint32_t * const regs = (uint32_t * )data ;
1338+ extern bool skip_swap ;
13331339 /* Copy the register values out from our cache */
13341340 for (size_t reg_index = 0 ; reg_index < sizeof (priv -> core_regs .r ) / sizeof (* priv -> core_regs .r ); reg_index ++ )
1335- if (target -> target_options & TOPT_FLAVOUR_BE )
1341+ if (( target -> target_options & TOPT_FLAVOUR_BE ) && ! skip_swap )
13361342 write_be4 (data , reg_index * 4 , priv -> core_regs .r [reg_index ]);
13371343 else
13381344 write_le4 (data , reg_index * 4 , priv -> core_regs .r [reg_index ]);
1339- if (target -> target_options & TOPT_FLAVOUR_BE ) {
1345+ if (( target -> target_options & TOPT_FLAVOUR_BE ) && ! skip_swap ) {
13401346 uint8_t value [4 ];
13411347 write_le4 (value , 0 , priv -> core_regs .cpsr );
13421348 regs [CORTEX_REG_CPSR ] = read_be4 (value , 0 );
13431349 } else
13441350 regs [CORTEX_REG_CPSR ] = priv -> core_regs .cpsr ;
13451351 if (target -> target_options & TOPT_FLAVOUR_FLOAT ) {
13461352 for (size_t reg_index = 0 ; reg_index < sizeof (priv -> core_regs .d ) / sizeof (* priv -> core_regs .d ); reg_index ++ )
1347- if (target -> target_options & TOPT_FLAVOUR_BE )
1353+ if (( target -> target_options & TOPT_FLAVOUR_BE ) && ! skip_swap )
13481354 write_be4 (data , (CORTEXAR_GENERAL_REG_COUNT + reg_index ) * 4 , priv -> core_regs .d [reg_index ]);
13491355 else
13501356 write_le4 (data , (CORTEXAR_GENERAL_REG_COUNT + reg_index ) * 4 , priv -> core_regs .d [reg_index ]);
1351- if (target -> target_options & TOPT_FLAVOUR_BE ) {
1357+ if (( target -> target_options & TOPT_FLAVOUR_BE ) && ! skip_swap ) {
13521358 uint8_t value [4 ];
13531359 write_le4 (value , 0 , priv -> core_regs .fpcsr );
13541360 regs [CORTEX_REG_FPCSR ] = read_be4 (value , 0 );
@@ -1361,25 +1367,26 @@ static void cortexar_regs_write(target_s *const target, const void *const data)
13611367{
13621368 cortexar_priv_s * const priv = (cortexar_priv_s * )target -> priv ;
13631369 const uint32_t * const regs = (const uint32_t * )data ;
1370+ extern bool skip_swap ;
13641371 /* Copy the new register values into our cache */
13651372 for (size_t reg_index = 0 ; reg_index < sizeof (priv -> core_regs .r ) / sizeof (* priv -> core_regs .r ); reg_index ++ )
1366- if (target -> target_options & TOPT_FLAVOUR_BE )
1373+ if (( target -> target_options & TOPT_FLAVOUR_BE ) && ! skip_swap )
13671374 priv -> core_regs .r [reg_index ] = read_be4 (data , reg_index * 4 );
13681375 else
13691376 priv -> core_regs .r [reg_index ] = read_le4 (data , reg_index * 4 );
1370- if (target -> target_options & TOPT_FLAVOUR_BE ) {
1377+ if (( target -> target_options & TOPT_FLAVOUR_BE ) && ! skip_swap ) {
13711378 uint8_t value [4 ];
13721379 write_le4 (value , 0 , regs [CORTEX_REG_CPSR ]);
13731380 priv -> core_regs .cpsr = read_be4 (value , 0 );
13741381 } else
13751382 priv -> core_regs .cpsr = regs [CORTEX_REG_CPSR ];
13761383 if (target -> target_options & TOPT_FLAVOUR_FLOAT ) {
13771384 for (size_t reg_index = 0 ; reg_index < sizeof (priv -> core_regs .r ) / sizeof (* priv -> core_regs .r ); reg_index ++ )
1378- if (target -> target_options & TOPT_FLAVOUR_BE )
1385+ if (( target -> target_options & TOPT_FLAVOUR_BE ) && ! skip_swap )
13791386 priv -> core_regs .d [reg_index ] = read_be4 (data , (reg_index + CORTEXAR_GENERAL_REG_COUNT ) * 4 );
13801387 else
13811388 priv -> core_regs .d [reg_index ] = read_le4 (data , (reg_index + CORTEXAR_GENERAL_REG_COUNT ) * 4 );
1382- if (target -> target_options & TOPT_FLAVOUR_BE ) {
1389+ if (( target -> target_options & TOPT_FLAVOUR_BE ) && ! skip_swap ) {
13831390 uint8_t value [4 ];
13841391 write_le4 (value , 0 , regs [CORTEX_REG_FPCSR ]);
13851392 priv -> core_regs .fpcsr = read_be4 (value , 0 );
@@ -1420,6 +1427,7 @@ static size_t cortexar_reg_width(const size_t reg)
14201427
14211428static size_t cortexar_reg_read (target_s * const target , const uint32_t reg , void * const data , const size_t max )
14221429{
1430+ extern bool skip_swap ;
14231431 /* Try to get a pointer to the storage for the requested register, and return -1 if that fails */
14241432 const void * const reg_ptr = cortexar_reg_ptr (target , reg );
14251433 if (!reg_ptr )
@@ -1432,7 +1440,7 @@ static size_t cortexar_reg_read(target_s *const target, const uint32_t reg, void
14321440 switch (reg_width ) {
14331441 case 4 : {
14341442 uint32_t value ;
1435- if (target -> target_options & TOPT_FLAVOUR_BE )
1443+ if (( target -> target_options & TOPT_FLAVOUR_BE ) && ! skip_swap )
14361444 value = read_be4 (reg_ptr , 0 );
14371445 else
14381446 value = read_le4 (reg_ptr , 0 );
@@ -1441,7 +1449,7 @@ static size_t cortexar_reg_read(target_s *const target, const uint32_t reg, void
14411449 }
14421450 case 8 : {
14431451 uint64_t value ;
1444- if (target -> target_options & TOPT_FLAVOUR_BE )
1452+ if (( target -> target_options & TOPT_FLAVOUR_BE ) && ! skip_swap )
14451453 value = read_be8 (reg_ptr , 0 );
14461454 else
14471455 value = read_le8 (reg_ptr , 0 );
@@ -1454,6 +1462,7 @@ static size_t cortexar_reg_read(target_s *const target, const uint32_t reg, void
14541462
14551463static size_t cortexar_reg_write (target_s * const target , const uint32_t reg , const void * const data , const size_t max )
14561464{
1465+ extern bool skip_swap ;
14571466 /* Try to get a pointer to the storage for the requested register, and return -1 if that fails */
14581467 void * const reg_ptr = cortexar_reg_ptr (target , reg );
14591468 if (!reg_ptr )
@@ -1466,15 +1475,15 @@ static size_t cortexar_reg_write(target_s *const target, const uint32_t reg, con
14661475 switch (reg_width ) {
14671476 case 4 : {
14681477 uint32_t value = read_le4 (data , 0 );
1469- if (target -> target_options & TOPT_FLAVOUR_BE ) {
1478+ if (( target -> target_options & TOPT_FLAVOUR_BE ) && ! skip_swap )
14701479 write_be4 (reg_ptr , 0 , value );
1471- } else
1480+ else
14721481 write_le4 (reg_ptr , 0 , value );
14731482 break ;
14741483 }
14751484 case 8 : {
14761485 uint64_t value = read_le8 (data , 0 );
1477- if (target -> target_options & TOPT_FLAVOUR_BE )
1486+ if (( target -> target_options & TOPT_FLAVOUR_BE ) && ! skip_swap )
14781487 write_be8 (reg_ptr , 0 , value );
14791488 else
14801489 write_le8 (reg_ptr , 0 , value );
@@ -1520,7 +1529,7 @@ static void cortexar_reset(target_s *const target)
15201529#endif
15211530
15221531 /* 10ms delay to ensure bootroms have had time to run */
1523- platform_delay (10 );
1532+ // platform_delay(10);
15241533 /* Ignore any initial errors out of reset */
15251534 target_check_error (target );
15261535}
@@ -1628,6 +1637,10 @@ static void cortexar_halt_resume(target_s *const target, const bool step)
16281637 /* Invalidate all the instruction caches if we're on a VMSA model device */
16291638 if (target -> target_options & TOPT_FLAVOUR_VIRT_MEM )
16301639 cortexar_coproc_write (target , CORTEXAR_ICIALLU , 0U );
1640+ else {
1641+ cortexar_coproc_write (target , CORTEXAR_ICIALLU , 0U );
1642+ // cortexar_run_insn(target, ARM_ISB_INSN);
1643+ }
16311644 /* Mark the fault status and address cache invalid */
16321645 priv -> core_status &= ~CORTEXAR_STATUS_FAULT_CACHE_VALID ;
16331646
0 commit comments