John McCarthy <jgmcc@magma.ca> cleans up the usage of the
[fw/openocd] / src / target / mips_m4k.c
index 0db7a94bc5c8535f67d26b8386f6e569d712feda..be7f59ec8c38ab7e2bd334605985f110b59c14a9 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "mips32.h"
 #include "mips_m4k.h"
+#include "mips32_dmaacc.h"
 #include "jtag.h"
 #include "log.h"
 
@@ -131,13 +132,14 @@ int mips_m4k_poll(target_t *target)
        int retval;
        mips32_common_t *mips32 = target->arch_info;
        mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
+       u32 ejtag_ctrl = ejtag_info->ejtag_ctrl;
        
        /* read ejtag control reg */
        jtag_add_end_state(TAP_RTI);
        mips_ejtag_set_instr(ejtag_info, EJTAG_INST_CONTROL, NULL);
-       mips_ejtag_drscan_32(ejtag_info, &ejtag_info->ejtag_ctrl);
+       mips_ejtag_drscan_32(ejtag_info, &ejtag_ctrl);
        
-       if (ejtag_info->ejtag_ctrl & EJTAG_CTRL_BRKST)
+       if (ejtag_ctrl & EJTAG_CTRL_BRKST)
        {
                if ((target->state == TARGET_RUNNING) || (target->state == TARGET_RESET))
                {
@@ -166,19 +168,19 @@ int mips_m4k_poll(target_t *target)
                target->state = TARGET_RUNNING;
        }
        
-       if (ejtag_info->ejtag_ctrl & EJTAG_CTRL_ROCC)
+       if (ejtag_ctrl & EJTAG_CTRL_ROCC)
        {
                /* we have detected a reset, clear flag
                 * otherwise ejtag will not work */
                jtag_add_end_state(TAP_RTI);
-               ejtag_info->ejtag_ctrl &= ~EJTAG_CTRL_ROCC;
+               ejtag_ctrl = ejtag_info->ejtag_ctrl & ~EJTAG_CTRL_ROCC;
                
                mips_ejtag_set_instr(ejtag_info, EJTAG_INST_CONTROL, NULL);
-               mips_ejtag_drscan_32(ejtag_info, &ejtag_info->ejtag_ctrl);
+               mips_ejtag_drscan_32(ejtag_info, &ejtag_ctrl);
                LOG_DEBUG("Reset Detected");
        }
        
-//     LOG_DEBUG("ctrl=0x%08X", ejtag_info->ejtag_ctrl);
+//     LOG_DEBUG("ctrl=0x%08X", ejtag_ctrl);
        
        return ERROR_OK;
 }
@@ -512,7 +514,11 @@ int mips_m4k_read_memory(struct target_s *target, u32 address, u32 size, u32 cou
                case 4:
                case 2:
                case 1:
-                       return mips32_pracc_read_mem(ejtag_info, address, size, count, (void *)buffer);
+                       /* if noDMA off, use DMAACC mode for memory read */
+                       if(ejtag_info->impcode & (1<<14))
+                               return mips32_pracc_read_mem(ejtag_info, address, size, count, (void *)buffer);
+                       else
+                               return mips32_dmaacc_read_mem(ejtag_info, address, size, count, (void *)buffer);
                default:
                        LOG_ERROR("BUG: we shouldn't get here");
                        exit(-1);
@@ -547,7 +553,11 @@ int mips_m4k_write_memory(struct target_s *target, u32 address, u32 size, u32 co
                case 4:
                case 2:
                case 1:
-                       mips32_pracc_write_mem(ejtag_info, address, size, count, (void *)buffer);
+                       /* if noDMA off, use DMAACC mode for memory write */
+                       if(ejtag_info->impcode & (1<<14))
+                               mips32_pracc_write_mem(ejtag_info, address, size, count, (void *)buffer);
+                       else
+                               mips32_dmaacc_write_mem(ejtag_info, address, size, count, (void *)buffer);
                        break;
                default:
                        LOG_ERROR("BUG: we shouldn't get here");