X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Ftarget%2Fmips32_dmaacc.c;h=308507b488464b08f519edbf9ec362b827b0c47f;hp=7d3c2dabab13774120a03f575ffca295f3c1d0d6;hb=962b3eb40cc5b69d9b3d6fcc4c5d56c4d204a307;hpb=b48a94f05da3a887f1978da01db77b79513d4aa9 diff --git a/src/target/mips32_dmaacc.c b/src/target/mips32_dmaacc.c index 7d3c2dabab..308507b488 100644 --- a/src/target/mips32_dmaacc.c +++ b/src/target/mips32_dmaacc.c @@ -20,14 +20,28 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * ***************************************************************************/ + #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "mips32_dmaacc.h" +static int mips32_dmaacc_read_mem8(struct mips_ejtag *ejtag_info, + uint32_t addr, int count, uint8_t *buf); +static int mips32_dmaacc_read_mem16(struct mips_ejtag *ejtag_info, + uint32_t addr, int count, uint16_t *buf); +static int mips32_dmaacc_read_mem32(struct mips_ejtag *ejtag_info, + uint32_t addr, int count, uint32_t *buf); + +static int mips32_dmaacc_write_mem8(struct mips_ejtag *ejtag_info, + uint32_t addr, int count, uint8_t *buf); +static int mips32_dmaacc_write_mem16(struct mips_ejtag *ejtag_info, + uint32_t addr, int count, uint16_t *buf); +static int mips32_dmaacc_write_mem32(struct mips_ejtag *ejtag_info, + uint32_t addr, int count, uint32_t *buf); /* * The following logic shamelessly cloned from HairyDairyMaid's wrt54g_debrick @@ -71,14 +85,12 @@ begin_ejtag_dma_read: mips_ejtag_set_instr(ejtag_info, EJTAG_INST_CONTROL); ejtag_ctrl = ejtag_info->ejtag_ctrl; mips_ejtag_drscan_32(ejtag_info, &ejtag_ctrl); - if (ejtag_ctrl & EJTAG_CTRL_DERR) - { + if (ejtag_ctrl & EJTAG_CTRL_DERR) { if (retries--) { - LOG_ERROR("DMA Read Addr = %08" PRIx32 " Data = ERROR ON READ (retrying)\n", addr); + LOG_ERROR("DMA Read Addr = %08" PRIx32 " Data = ERROR ON READ (retrying)", addr); goto begin_ejtag_dma_read; - } - else - LOG_ERROR("DMA Read Addr = %08" PRIx32 " Data = ERROR ON READ\n", addr); + } else + LOG_ERROR("DMA Read Addr = %08" PRIx32 " Data = ERROR ON READ", addr); return ERROR_JTAG_DEVICE_ERROR; } @@ -100,7 +112,8 @@ begin_ejtag_dma_read_h: /* Initiate DMA Read & set DSTRT */ mips_ejtag_set_instr(ejtag_info, EJTAG_INST_CONTROL); - ejtag_ctrl = EJTAG_CTRL_DMAACC | EJTAG_CTRL_DRWN | EJTAG_CTRL_DMA_HALFWORD | EJTAG_CTRL_DSTRT | ejtag_info->ejtag_ctrl; + ejtag_ctrl = EJTAG_CTRL_DMAACC | EJTAG_CTRL_DRWN | EJTAG_CTRL_DMA_HALFWORD | + EJTAG_CTRL_DSTRT | ejtag_info->ejtag_ctrl; mips_ejtag_drscan_32(ejtag_info, &ejtag_ctrl); /* Wait for DSTRT to Clear */ @@ -117,14 +130,12 @@ begin_ejtag_dma_read_h: mips_ejtag_set_instr(ejtag_info, EJTAG_INST_CONTROL); ejtag_ctrl = ejtag_info->ejtag_ctrl; mips_ejtag_drscan_32(ejtag_info, &ejtag_ctrl); - if (ejtag_ctrl & EJTAG_CTRL_DERR) - { + if (ejtag_ctrl & EJTAG_CTRL_DERR) { if (retries--) { - LOG_ERROR("DMA Read Addr = %08" PRIx32 " Data = ERROR ON READ (retrying)\n", addr); + LOG_ERROR("DMA Read Addr = %08" PRIx32 " Data = ERROR ON READ (retrying)", addr); goto begin_ejtag_dma_read_h; - } - else - LOG_ERROR("DMA Read Addr = %08" PRIx32 " Data = ERROR ON READ\n", addr); + } else + LOG_ERROR("DMA Read Addr = %08" PRIx32 " Data = ERROR ON READ", addr); return ERROR_JTAG_DEVICE_ERROR; } @@ -169,14 +180,12 @@ begin_ejtag_dma_read_b: mips_ejtag_set_instr(ejtag_info, EJTAG_INST_CONTROL); ejtag_ctrl = ejtag_info->ejtag_ctrl; mips_ejtag_drscan_32(ejtag_info, &ejtag_ctrl); - if (ejtag_ctrl & EJTAG_CTRL_DERR) - { + if (ejtag_ctrl & EJTAG_CTRL_DERR) { if (retries--) { - LOG_ERROR("DMA Read Addr = %08" PRIx32 " Data = ERROR ON READ (retrying)\n", addr); + LOG_ERROR("DMA Read Addr = %08" PRIx32 " Data = ERROR ON READ (retrying)", addr); goto begin_ejtag_dma_read_b; - } - else - LOG_ERROR("DMA Read Addr = %08" PRIx32 " Data = ERROR ON READ\n", addr); + } else + LOG_ERROR("DMA Read Addr = %08" PRIx32 " Data = ERROR ON READ", addr); return ERROR_JTAG_DEVICE_ERROR; } @@ -232,14 +241,12 @@ begin_ejtag_dma_write: mips_ejtag_set_instr(ejtag_info, EJTAG_INST_CONTROL); ejtag_ctrl = ejtag_info->ejtag_ctrl; mips_ejtag_drscan_32(ejtag_info, &ejtag_ctrl); - if (ejtag_ctrl & EJTAG_CTRL_DERR) - { + if (ejtag_ctrl & EJTAG_CTRL_DERR) { if (retries--) { - LOG_ERROR("DMA Write Addr = %08" PRIx32 " Data = ERROR ON WRITE (retrying)\n", addr); + LOG_ERROR("DMA Write Addr = %08" PRIx32 " Data = ERROR ON WRITE (retrying)", addr); goto begin_ejtag_dma_write; - } - else - LOG_ERROR("DMA Write Addr = %08" PRIx32 " Data = ERROR ON WRITE\n", addr); + } else + LOG_ERROR("DMA Write Addr = %08" PRIx32 " Data = ERROR ON WRITE", addr); return ERROR_JTAG_DEVICE_ERROR; } @@ -283,14 +290,12 @@ begin_ejtag_dma_write_h: mips_ejtag_set_instr(ejtag_info, EJTAG_INST_CONTROL); ejtag_ctrl = ejtag_info->ejtag_ctrl; mips_ejtag_drscan_32(ejtag_info, &ejtag_ctrl); - if (ejtag_ctrl & EJTAG_CTRL_DERR) - { + if (ejtag_ctrl & EJTAG_CTRL_DERR) { if (retries--) { - LOG_ERROR("DMA Write Addr = %08" PRIx32 " Data = ERROR ON WRITE (retrying)\n", addr); + LOG_ERROR("DMA Write Addr = %08" PRIx32 " Data = ERROR ON WRITE (retrying)", addr); goto begin_ejtag_dma_write_h; - } - else - LOG_ERROR("DMA Write Addr = %08" PRIx32 " Data = ERROR ON WRITE\n", addr); + } else + LOG_ERROR("DMA Write Addr = %08" PRIx32 " Data = ERROR ON WRITE", addr); return ERROR_JTAG_DEVICE_ERROR; } @@ -335,14 +340,12 @@ begin_ejtag_dma_write_b: mips_ejtag_set_instr(ejtag_info, EJTAG_INST_CONTROL); ejtag_ctrl = ejtag_info->ejtag_ctrl; mips_ejtag_drscan_32(ejtag_info, &ejtag_ctrl); - if (ejtag_ctrl & EJTAG_CTRL_DERR) - { + if (ejtag_ctrl & EJTAG_CTRL_DERR) { if (retries--) { - LOG_ERROR("DMA Write Addr = %08" PRIx32 " Data = ERROR ON WRITE (retrying)\n", addr); + LOG_ERROR("DMA Write Addr = %08" PRIx32 " Data = ERROR ON WRITE (retrying)", addr); goto begin_ejtag_dma_write_b; - } - else - LOG_ERROR("DMA Write Addr = %08" PRIx32 " Data = ERROR ON WRITE\n", addr); + } else + LOG_ERROR("DMA Write Addr = %08" PRIx32 " Data = ERROR ON WRITE", addr); return ERROR_JTAG_DEVICE_ERROR; } @@ -351,52 +354,54 @@ begin_ejtag_dma_write_b: int mips32_dmaacc_read_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, void *buf) { - switch (size) - { + switch (size) { case 1: - return mips32_dmaacc_read_mem8(ejtag_info, addr, count, (uint8_t*)buf); + return mips32_dmaacc_read_mem8(ejtag_info, addr, count, (uint8_t *)buf); case 2: - return mips32_dmaacc_read_mem16(ejtag_info, addr, count, (uint16_t*)buf); + return mips32_dmaacc_read_mem16(ejtag_info, addr, count, (uint16_t *)buf); case 4: - return mips32_dmaacc_read_mem32(ejtag_info, addr, count, (uint32_t*)buf); + return mips32_dmaacc_read_mem32(ejtag_info, addr, count, (uint32_t *)buf); } return ERROR_OK; } -int mips32_dmaacc_read_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint32_t *buf) +static int mips32_dmaacc_read_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint32_t *buf) { int i; int retval; for (i = 0; i < count; i++) { - if ((retval = ejtag_dma_read(ejtag_info, addr + i*sizeof(*buf), &buf[i])) != ERROR_OK) + retval = ejtag_dma_read(ejtag_info, addr + i * sizeof(*buf), &buf[i]); + if (retval != ERROR_OK) return retval; } return ERROR_OK; } -int mips32_dmaacc_read_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint16_t *buf) +static int mips32_dmaacc_read_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint16_t *buf) { int i; int retval; for (i = 0; i < count; i++) { - if ((retval = ejtag_dma_read_h(ejtag_info, addr + i*sizeof(*buf), &buf[i])) != ERROR_OK) + retval = ejtag_dma_read_h(ejtag_info, addr + i * sizeof(*buf), &buf[i]); + if (retval != ERROR_OK) return retval; } return ERROR_OK; } -int mips32_dmaacc_read_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint8_t *buf) +static int mips32_dmaacc_read_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint8_t *buf) { int i; int retval; for (i = 0; i < count; i++) { - if ((retval = ejtag_dma_read_b(ejtag_info, addr + i*sizeof(*buf), &buf[i])) != ERROR_OK) + retval = ejtag_dma_read_b(ejtag_info, addr + i * sizeof(*buf), &buf[i]); + if (retval != ERROR_OK) return retval; } @@ -405,52 +410,54 @@ int mips32_dmaacc_read_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int co int mips32_dmaacc_write_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, void *buf) { - switch (size) - { + switch (size) { case 1: - return mips32_dmaacc_write_mem8(ejtag_info, addr, count, (uint8_t*)buf); + return mips32_dmaacc_write_mem8(ejtag_info, addr, count, (uint8_t *)buf); case 2: - return mips32_dmaacc_write_mem16(ejtag_info, addr, count,(uint16_t*)buf); + return mips32_dmaacc_write_mem16(ejtag_info, addr, count, (uint16_t *)buf); case 4: - return mips32_dmaacc_write_mem32(ejtag_info, addr, count, (uint32_t*)buf); + return mips32_dmaacc_write_mem32(ejtag_info, addr, count, (uint32_t *)buf); } return ERROR_OK; } -int mips32_dmaacc_write_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint32_t *buf) +static int mips32_dmaacc_write_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint32_t *buf) { int i; int retval; for (i = 0; i < count; i++) { - if ((retval = ejtag_dma_write(ejtag_info, addr + i*sizeof(*buf), buf[i])) != ERROR_OK) + retval = ejtag_dma_write(ejtag_info, addr + i * sizeof(*buf), buf[i]); + if (retval != ERROR_OK) return retval; } return ERROR_OK; } -int mips32_dmaacc_write_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint16_t *buf) +static int mips32_dmaacc_write_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint16_t *buf) { int i; int retval; for (i = 0; i < count; i++) { - if ((retval = ejtag_dma_write_h(ejtag_info, addr + i*sizeof(*buf), buf[i])) != ERROR_OK) + retval = ejtag_dma_write_h(ejtag_info, addr + i * sizeof(*buf), buf[i]); + if (retval != ERROR_OK) return retval; } return ERROR_OK; } -int mips32_dmaacc_write_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint8_t *buf) +static int mips32_dmaacc_write_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint8_t *buf) { int i; int retval; for (i = 0; i < count; i++) { - if ((retval = ejtag_dma_write_b(ejtag_info, addr + i*sizeof(*buf), buf[i])) != ERROR_OK) + retval = ejtag_dma_write_b(ejtag_info, addr + i * sizeof(*buf), buf[i]); + if (retval != ERROR_OK) return retval; }