亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? memory.c

?? jtag burn source code for linux
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
 * target/arm7tdmi/memory.c: implements the ARM7TDMI target's memory read/write
 * 			     operations.
 *
 * Copyright (C) 2003, Rongkai zhan <zhanrk@163.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * 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
 */

/* $Id$ */

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

#include "jtager.h"
#include "jtag.h"
#include "target.h"

int arm7tdmi_memory_read8(u8 *buf, u32 address, u32 length)
{
	int i, retval;
	u32 addr = address;
	scan_chain_t *sc1 = &arm7tdmi_target.sc[1];

	if ((buf == NULL) || (length == 0))
		return -ERR_INVALID_PARAM;
	else if (target->status == TARGET_STATUS_RUNNING)
		return -ERR_TARGET_IS_RUNNING;
	else if (target->mode == TARGET_MODE_THUMB)
		return -ERR_TARGET_IN_THUMB_MODE;

	i = retval = 0;

	arm7tdmi_ice_set_breakpt();

	/*
	 * Select scan chain 1, and use INTEST instruction to make scan
	 * chain 1 into the internal test mode.
	 */
	retval = jtag_select_scanchain(1);
	if (retval)
		return retval;
	retval = jtag_write_ireg(JTAG_INTEST);
	if (retval)
		return retval;

	
	/* read one byte each time */
	while (i < length) {
		/*
		 * Load R0 with the address to read.
		 * LDR R0, PC+xx = 0xE59F0000
		 */
		sc1->writein[0] = 0xE59F0000;
		sc1->writein[1] = DEBUG_SPEED;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = ARM_NOP;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = addr;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = ARM_NOP;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);

		/* two NOPs are needed, and i don't know why? */
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);

		/* NOP with bit33 set HIGH */
		sc1->writein[0] = ARM_NOP;
		sc1->writein[1] = SYSTEM_SPEED;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		/* LDRB R1, [R0] = 1110 0101 1101 0000 0001 0000 0000 0000 */
		sc1->writein[0] = 0xE5D01000;
		sc1->writein[1] = DEBUG_SPEED;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);

		/* Write RESTART instruction into the TAP controller.
	 	 * When the state machine enters the Run-Test/Idle state,
		 * the ARM7TDMI core will revert back to system mode,
		 * and it will resynchronize clock to MCLK.
	 	 */
		jtag_write_ireg(JTAG_RESTART);
				
		/*
		 * Now, the ARM7TDMI core re-entered the debug state.
		 * Before the debug session continues, we must load the 
		 * TAP controller with the INTEST instruction. We can use
		 * the instruction "STR R1, [R1]" running at debug-speed
		 * to read out the contents of register R1.
		 */
		jtag_select_scanchain(1);
		jtag_write_ireg(JTAG_INTEST);

		/* STR R1, [R1] = 1110 0101 1000 0001 0001 0000 0000 0000 */
		sc1->writein[0] = 0xE5811000;
		sc1->writein[1] = DEBUG_SPEED;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);

		sc1->writein[0] = ARM_NOP;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		buf[i] = (u8)(sc1->readout[0] & 0x000000FF);
		
		i++;
		addr++;
	} /* end of while (i < length) */

	/*
	 * Finally, clear breakpt ...
	 */
	arm7tdmi_ice_clear_breakpt();
	return 0;
} /* end of arm7tdmi_memory_read8(...) */

int arm7tdmi_memory_write8(u8 *buf, u32 address, u32 length)
{
	int i, retval;
	u32 addr = address;
	scan_chain_t *sc1 = &arm7tdmi_target.sc[1];

	if ((buf == NULL) || (length == 0))
		return -ERR_INVALID_PARAM;
	else if (target->status == TARGET_STATUS_RUNNING)
		return -ERR_TARGET_IS_RUNNING;
	else if (target->mode == TARGET_MODE_THUMB)
		return -ERR_TARGET_IN_THUMB_MODE;

	retval = i = 0;
	
	arm7tdmi_ice_set_breakpt();

	/*
	 * Select scan chain 1, and use INTEST instruction to make scan
	 * chain 1 into the internal test mode.
	 */
	retval = jtag_select_scanchain(1);
	if (retval)
		return retval;
	retval = jtag_write_ireg(JTAG_INTEST);
	if (retval)
		return retval;

	/* write one byte each time */
	while (i < length) {
		/*
		 * Load R0 with the address to read.
		 * LDR R0, PC+xx = 0xE59F0000
		 */
		sc1->writein[0] = 0xE59F0000;
		sc1->writein[1] = DEBUG_SPEED;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = ARM_NOP;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = addr;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = ARM_NOP;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);

		/*
		 * Clear R1 to zero. If not doing this step, when i write
		 * even number into R1, i always read back wrong result
		 * from R1. Damn it.
		 * LDR R1, [R1] = 1110 0101 1001 0001 0001 0000 0000 0000
		 */
		sc1->writein[0] = 0xE5911000;
		sc1->writein[1] = DEBUG_SPEED;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = ARM_NOP;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = 0;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = ARM_NOP;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);

		/*
		 * Load R1 with the data to write.
		 * LDR R1, [R1] = 1110 0101 1001 0001 0001 0000 0000 0000
		 */
		sc1->writein[0] = 0xE5911000;
		sc1->writein[1] = DEBUG_SPEED;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = ARM_NOP;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = (u32)buf[i];
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = ARM_NOP;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);

		/* two NOPs are needed, and i don't know why? */
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);

		/* NOP with bit33 set HIGH */
		sc1->writein[0] = ARM_NOP;
		sc1->writein[1] = SYSTEM_SPEED;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		/* STRB R1, [R0] = 1110 0101 1100 0000 0001 0000 0000 0000 */
		sc1->writein[0] = 0xE5C01000;
		sc1->writein[1] = DEBUG_SPEED;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);

		/* Write RESTART instruction into the TAP controller.
	 	 * When the state machine enters the Run-Test/Idle state,
		 * the ARM7TDMI core will revert back to system mode,
		 * and it will resynchronize clock to MCLK.
	 	 */
		jtag_write_ireg(JTAG_RESTART);
				
		/*
		 * Now, the ARM7TDMI core re-entered the debug state.
		 * Before the debug session continues, we must load the 
		 * TAP controller with the INTEST instruction.
		 */
		jtag_select_scanchain(1);
		jtag_write_ireg(JTAG_INTEST);
		
		i++;
		addr++;
	} /* end of while (i < length) */

	/*
	 * Finally, clear breakpt ...
	 */
	arm7tdmi_ice_clear_breakpt();
	return 0;
} /* end of arm7tdmi_memory_write8(...) */

/*
 * NOTE: this function has very slow read speed.
 */
int arm7tdmi_memory_read16(u16 *buf, u32 address, u32 length)
{
	int i, retval;
	u32 addr = address;
	scan_chain_t *sc1 = &arm7tdmi_target.sc[1];

	if ((buf == NULL) || (length == 0))
		return -ERR_INVALID_PARAM;
	else if (target->status == TARGET_STATUS_RUNNING)
		return -ERR_TARGET_IS_RUNNING;
	else if (target->mode == TARGET_MODE_THUMB)
		return -ERR_TARGET_IN_THUMB_MODE;

	addr &= 0xFFFFFFFE; /* align address with half word boundary */
	retval = i = 0;
	
	arm7tdmi_ice_set_breakpt();

	/*
	 * Select scan chain 1, and use INTEST instruction to make scan
	 * chain 1 into the internal test mode.
	 */
	retval = jtag_select_scanchain(1);
	if (retval)
		return retval;
	retval = jtag_write_ireg(JTAG_INTEST);
	if (retval)
		return retval;

	/* read one half-word each time */
	while (i < length) {
		/*
		 * Load R0 with the address to read.
		 * LDR R0, PC+xx = 0xE59F0000
		 */
		sc1->writein[0] = 0xE59F0000;
		sc1->writein[1] = DEBUG_SPEED;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = ARM_NOP;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = addr;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = ARM_NOP;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);

		/* two NOPs are needed, and i don't know why? */
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);

		/* NOP with bit33 set HIGH */
		sc1->writein[0] = ARM_NOP;
		sc1->writein[1] = SYSTEM_SPEED;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		/* LDRH R1, [R0] = 1110 0001 1101 0000 0001 0000 1011 0000 */
		sc1->writein[0] = 0xE1D010B0;
		sc1->writein[1] = DEBUG_SPEED;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);

		/* Write RESTART instruction into the TAP controller.
	 	 * When the state machine enters the Run-Test/Idle state,
		 * the ARM7TDMI core will revert back to system mode,
		 * and it will resynchronize clock to MCLK.
	 	 */
		jtag_write_ireg(JTAG_RESTART);
				
		/*
		 * Now, the ARM7TDMI core re-entered the debug state.
		 * Before the debug session continues, we must load the 
		 * TAP controller with the INTEST instruction. We can use
		 * the instruction "STR R1, [R1]" running at debug-speed
		 * to read out the contents of register R1.
		 */
		jtag_select_scanchain(1);
		jtag_write_ireg(JTAG_INTEST);

		/* STR R1, [R1] = 1110 0101 1000 0001 0001 0000 0000 0000 */
		sc1->writein[0] = 0xE5811000;
		sc1->writein[1] = DEBUG_SPEED;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);

		sc1->writein[0] = ARM_NOP;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		buf[i] = (u16)(sc1->readout[0] & 0x0000FFFF);
		
		i++;
		addr += 2;
	} /* end of while (i < length) */

	/*
	 * Finally, clear breakpt ...
	 */
	arm7tdmi_ice_clear_breakpt();
	return 0;
} /* end of arm7tdmi_read16(...) */

/*
 * NOTE: this function has very slow write speed.
 */
int arm7tdmi_memory_write16(u16 *buf, u32 address, u32 length)
{
	int i, retval;
	u32 addr = address;
	scan_chain_t *sc1 = &arm7tdmi_target.sc[1];

	if ((buf == NULL) || (length == 0))
		return -ERR_INVALID_PARAM;
	else if (target->status == TARGET_STATUS_RUNNING)
		return -ERR_TARGET_IS_RUNNING;
	else if (target->mode == TARGET_MODE_THUMB)
		return -ERR_TARGET_IN_THUMB_MODE;

	addr &= 0xFFFFFFFE; /* align address with half word boundary */
	retval = i = 0;
	
	arm7tdmi_ice_set_breakpt();

	/*
	 * Select scan chain 1, and use INTEST instruction to make scan
	 * chain 1 into the internal test mode.
	 */
	retval = jtag_select_scanchain(1);
	if (retval)
		return retval;
	retval = jtag_write_ireg(JTAG_INTEST);
	if (retval)
		return retval;

	/* write one half-word each time */
	while (i < length) {
		/*
		 * Load R0 with the address to read.
		 * LDR R0, PC+xx = 0xE59F0000
		 */
		sc1->writein[0] = 0xE59F0000;
		sc1->writein[1] = DEBUG_SPEED;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = ARM_NOP;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = addr;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);
		
		sc1->writein[0] = ARM_NOP;
		arm7tdmi_exec_instruction(sc1->writein, sc1->readout);

		/*
		 * Clear R1 to zero. If not doing this step, when i write
		 * even number into R1, i always read back wrong result
		 * from R1. Damn it.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美在线视频全部完| 国产精品美女久久久久久久久久久| 精品国产乱码久久久久久夜甘婷婷| 日本一区二区三区视频视频| 午夜激情久久久| 成人精品一区二区三区中文字幕| 777午夜精品视频在线播放| 国产欧美视频一区二区| 人人超碰91尤物精品国产| 99久久久国产精品| 久久九九全国免费| 日韩成人伦理电影在线观看| 日本精品裸体写真集在线观看| 久久精品在线免费观看| 欧美aa在线视频| 欧美日韩日日摸| 亚洲欧美日韩精品久久久久| 国产v日产∨综合v精品视频| 精品黑人一区二区三区久久| 日韩精品免费专区| 欧美最猛黑人xxxxx猛交| 国产精品成人免费精品自在线观看 | 中文字幕在线视频一区| 久久精品国产秦先生| 在线播放视频一区| 一区二区三区欧美激情| 91视频国产观看| 亚洲视频免费在线观看| 高清shemale亚洲人妖| 欧美变态口味重另类| 琪琪久久久久日韩精品| 在线播放中文一区| 天天爽夜夜爽夜夜爽精品视频 | 精品一区二区综合| 91麻豆精品国产综合久久久久久| 亚洲大片精品永久免费| 欧美视频在线观看一区二区| 一区二区三区四区精品在线视频| 一道本成人在线| 夜夜操天天操亚洲| 欧美午夜一区二区| 午夜av电影一区| 欧美精品精品一区| 免费日韩伦理电影| 337p日本欧洲亚洲大胆精品| 国产揄拍国内精品对白| 国产欧美日韩综合| 91原创在线视频| 亚洲尤物视频在线| 欧美电影一区二区| 久久精品99久久久| 国产无人区一区二区三区| 国产91精品在线观看| 日韩国产在线观看一区| 欧美一区二区三区白人| 激情亚洲综合在线| 久久人人爽爽爽人久久久| 成人在线一区二区三区| 一区二区三区在线视频观看58| 欧美日韩亚洲高清一区二区| 精品在线播放免费| 中文字幕在线播放不卡一区| 日本高清不卡视频| 日日嗨av一区二区三区四区| 国产人成一区二区三区影院| 97久久超碰国产精品| 婷婷丁香激情综合| 国产欧美视频一区二区三区| 欧美性大战久久| 国产乱码精品一区二区三区忘忧草 | 91麻豆精品国产91| 看片的网站亚洲| 亚洲欧美福利一区二区| 欧美乱妇15p| 99热在这里有精品免费| 香蕉成人伊视频在线观看| 久久久不卡网国产精品一区| 在线视频国内自拍亚洲视频| 国产精品77777竹菊影视小说| 亚洲激情网站免费观看| 精品国产免费久久| 一本大道综合伊人精品热热 | 亚洲欧美日韩国产中文在线| 欧美一级一区二区| 99久久国产综合精品麻豆| 久久精品国产在热久久| 亚洲码国产岛国毛片在线| 日韩亚洲欧美成人一区| 色综合视频一区二区三区高清| 久久精品国产亚洲aⅴ| 亚洲影视资源网| 国产精品国产三级国产a| 欧美一区中文字幕| 色偷偷88欧美精品久久久| 国产一区二区三区久久悠悠色av| 午夜一区二区三区视频| 国产精品毛片a∨一区二区三区| 日韩欧美一区二区免费| 欧美日韩精品福利| 色激情天天射综合网| 成人黄色片在线观看| 黄色日韩网站视频| 日韩精品电影在线| 亚洲一区二区三区不卡国产欧美| 欧美高清在线一区| 精品国产制服丝袜高跟| 日韩三级.com| 日韩欧美一区在线观看| 欧美日韩精品二区第二页| 色噜噜久久综合| 91免费视频观看| 91免费观看视频在线| 99国产精品国产精品久久| 成人禁用看黄a在线| 国产精品亚洲综合一区在线观看| 国产一区二区在线影院| 精品无码三级在线观看视频| 久久国产剧场电影| 美女高潮久久久| 久国产精品韩国三级视频| 日本成人中文字幕在线视频| 日韩电影在线免费| 日本色综合中文字幕| 麻豆成人在线观看| 国精产品一区一区三区mba视频| 九色porny丨国产精品| 精品影院一区二区久久久| 国产综合久久久久久鬼色| 韩国一区二区视频| 国产91综合一区在线观看| 成人性生交大片| 色综合久久88色综合天天| 一本到不卡免费一区二区| 欧美三级韩国三级日本一级| 在线电影院国产精品| 日韩午夜在线播放| 久久久久久久性| 亚洲色图欧洲色图| 亚洲国产cao| 狠狠色综合日日| 不卡高清视频专区| 欧美吻胸吃奶大尺度电影| 制服.丝袜.亚洲.中文.综合| 欧美草草影院在线视频| 欧美激情一区不卡| 一个色妞综合视频在线观看| 蜜桃av一区二区在线观看 | 99精品欧美一区二区三区综合在线| 99精品视频一区| 欧美精品一级二级三级| 久久蜜桃av一区二区天堂| 亚洲美女在线国产| 免费日韩伦理电影| 成人av影视在线观看| 欧美日韩免费在线视频| 亚洲精品一区二区三区99| 国产精品久久久久精k8 | 国产一区二区在线影院| 91小视频在线观看| 欧美一区二区网站| 亚洲欧洲精品成人久久奇米网| 奇米四色…亚洲| 欧美大片日本大片免费观看| 中文字幕免费不卡在线| 亚洲一区二区三区国产| 国产精品乡下勾搭老头1| 在线观看成人小视频| 2014亚洲片线观看视频免费| 亚洲国产精品久久久男人的天堂| 国产乱子伦一区二区三区国色天香 | 丰满亚洲少妇av| 91麻豆精品国产91久久久 | 91丨porny丨国产入口| 欧美变态口味重另类| 亚洲福中文字幕伊人影院| 国产精品18久久久久久久网站| 91精品国产综合久久福利软件| 亚洲欧洲日韩女同| 国内欧美视频一区二区 | 日韩av电影免费观看高清完整版在线观看| 成人综合婷婷国产精品久久蜜臀 | 欧美在线999| 亚洲人成网站在线| 高清shemale亚洲人妖| 欧美v国产在线一区二区三区| 日韩激情一二三区| 欧美日韩在线免费视频| 亚洲免费资源在线播放| 成人看片黄a免费看在线| 国产亚洲欧美在线| 久久99热国产| 欧美成人精品二区三区99精品| 日韩av一级电影| 欧美日韩精品二区第二页| 亚洲自拍偷拍麻豆| 色88888久久久久久影院按摩| 亚洲欧美激情视频在线观看一区二区三区| 国产98色在线|日韩| 国产欧美日韩视频一区二区 | 久久蜜桃av一区精品变态类天堂 |