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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? arm7tdmi.c

?? jtag burn source code for linux
?? C
字號:
/*
 * target/arm7tdmi/arm7tdmi: implements arm7tdmi target
 *
 * Copyright (C) 2003 2004, 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"

extern core_register_t arm7tdmi_regs[];
extern ice_register_t  arm7tdmi_ice_regs[];

target_t arm7tdmi_target = {
	.type		= TARGET_TYPE_ARM7TDMI,
	.mode		= TARGET_MODE_ARM,
	.status 	= TARGET_STATUS_RUNNING,
	.halt_reason 	= TARGET_HALTED_NONE,
	
	/*
	 * These two pointers are initialized in the function arm7tdmi_setup()
	 */
	.regs = NULL,
	.ice_regs = NULL,

	/* BYPASS register always output 0 */
	.bypass 	= {ARM7TDMI_BYPASS_REG_BITNR, 0, 0},
	.idcode 	= {ARM7TDMI_IDCODE_REG_BITNR, 0, 0},
	/* INSTRUCTION register always output b0001 during CAPTURE-DR stage */
	.instruction 	= {ARM7TDMI_INSTRUCTION_REG_BITNR, 0xffffffff, 0x01},
	/*
	 * The scan path select register always
	 * output b1000 during CAPTURE-DR stage.
	 */
	.scanpath = {ARM7TDMI_SCANPATH_REG_BITNR, 0x0, 0x08}, 
	
	/* scan chains of ARM7TDMI */
	.sc_num 	= 3, /* scan chain 0, 1, 2 */
	.active_sc 	= 0,
	.sc = {
		{"ARM7TDMI CPU core logic",
		 ARM7TDMI_SCANCHAIN0_BITNR, {0, }, {0, }, NULL},
		{"ARM7TDMI CPU core debug subset",
		 ARM7TDMI_SCANCHAIN1_BITNR, {0, }, {0, }, NULL},
		{"ARM7TDMI EmbeddedICE-RT logic",
		 ARM7TDMI_SCANCHAIN2_BITNR, {0, }, {0, }, NULL}
	},
	.private = NULL,
};

/*
 * arm7tdmi_halt - Halt the ARM7TDMI target and make it into the debug mode
 */
int arm7tdmi_halt(void)
{
	u32 status;
	int success, retval;
	int temp = 0;

	if (target->status != TARGET_STATUS_RUNNING) {
		printf("The target cpu has been halted!\n");
		return 0;
	}
	
	/*
	 * We halt the target by setting the DBGRQ bit (bit[1]) of the debug
	 * control register of ARM7TDMI EmbeddedICE-RT logic. We also set the
	 * INTDIS bit (bit[2]) of the ICE debug control register for disabling
	 * the interrupt on the target.
	 *
	 * NOTICE: Do not set DBGACK bit, please. The reason is:
	 * When a system-speed access from debug state occurs, the core will
	 * temporarily drop out of debug state, so DBGACK might go LOW.
	 * But if set the DBGACK bit of the debug control registerl,
	 * the DBGACK signal will always go HIGH.
	 */
	/* select scan chain 2 -- EmbeddedICE-RT */
	retval = jtag_select_scanchain(2);
	if (retval)
		return retval;
	retval = jtag_write_ireg(JTAG_INTEST); /* internal test mode */
	if (retval)
		return retval;
	
	/* set DBGRQ bit and disable interrupts */
	retval = arm7tdmi_ice_write(ARM7TDMI_ICE_DBGCTL, 0x6);
	if (retval)
		return retval;

	/* After sending DBGRQ, Run-Test/Idle state must be entered: */
	retval = jtag_write_ireg(JTAG_RESTART);
	if (retval)
		return retval;
	
	/* Read debug status register to see whether the DBGACK signal
	 * is asserted. If the DBGACK siganl goes HIGH, then the target
	 * has entered the debug state.
	 */
	success = 0;
	printf("Requesting HALT target ... ");
	while (temp++ < 10) {
		retval = arm7tdmi_ice_read(ARM7TDMI_ICE_DBGSTAT, &status);
		if (retval)
			return retval;
		
		if (status & 0x01) {
			/* success */
			success = 1;
			break;
		}
		//jtag_write_ireg(JTAG_RESTART);
		printf(".");
		usleep(100);
	}

	/* Whatever happens, the DBGRQ bit flag must be cleared */
	arm7tdmi_ice_write(ARM7TDMI_ICE_DBGCTL, 0x00);
	
	if (success) {
		printf("[OK]\n");
		target->status = TARGET_STATUS_HALTED;
		target->halt_reason = TARGET_HALTED_BY_DBGRQ;
		
		/*
		 * When the bit[4] of the debug status register of ARM7TDMI
		 * EmbeddedICE-RT logic is HIGH, the ARM7TDMI core has
		 * entered the debug state from THUMB mode. Otherwise the
		 * ARM7TDMI core has entered the debug state from ARM mode.
		 */
		printf("The target is halted in ");
		if (status & 0x10) {
			printf("THUMB mode.\n");
			target->mode = TARGET_MODE_THUMB;
		} else {
			printf("ARM mode.\n");
			target->mode = TARGET_MODE_ARM;
		}
		retval = 0;
		//retval = arm7tdmi_regs_read();
	} else {
		/* make the TAP controller into the Run-Test/Idle state */
		jtag_write_ireg(JTAG_RESTART);
		
		printf("[FAILED]\n");	
		retval = -ERR_TARGET_HALT_FAILED;
	}

	return retval;
} /* end of target_halt() */

/*
 * arm7tdmi_exec_instruction - Execute an instruction on the ARM7TDMI core
 * 	 		       while in debug state by scan chain 1
 * @writein: an array with 2 elements, writein[0] contains the instruction
 * 	     opcode to be executed, (writein[1] & 0x01) represents the
 * 	     value of BREAKPT signal.
 * @readout: used to return the data read out from scan chain 1
 * 
 * Return Value: the value of BREAKPT signal.
 *
 * NOTE: We assume that the target has been halted - the target has
 * been in debug state. And scan chain 1 has been selected, the INTEST
 * instruction has been written into the instruction register.
 */
int arm7tdmi_exec_instruction(u32 *writein, u32 *readout)
{
	u32 indata[2] = {0, 0};
	u32 outdata[2] = {0, 0};
	int bitnr = arm7tdmi_target.sc[1].bitnr; /* 33 bits */
	int retval;
	
	/* reverse the bit order of the data to be written in */
	reverse_bit_order(bitnr, (u8 *)writein, (u8 *)indata);
	
	/* 
	 * OK, write in and read out
	 * read or write JTAG data register will always change its state
	 * from Update-DR to Run-Test/Idle. Therefore, it will also pulse
	 * DCLK signal.
	 */
	retval = jtag_rw_dreg(bitnr, indata, outdata);
	if (retval)
		return retval;

	/* reverse the bit order of the data read out */
	reverse_bit_order(bitnr, (u8 *)outdata, (u8 *)readout);

	return retval;
} /* end of arm7tdmi_exec_instruction() */

/*
 * target_restart - Exit from the debug state, and return to
 * 		    the normal system state.
 */
int arm7tdmi_restart(void)
{
	core_register_t *reg_pc = reg_index("PC");
	core_register_t *reg_r0 = reg_index("R0");

	if (target->status == TARGET_STATUS_RUNNING)
		return -ERR_TARGET_IS_RUNNING;

	if (target->mode == TARGET_MODE_THUMB) {
		printf("Error: %s: THUMB mode is not yet implemented.\n",
			__FUNCTION__);
		return -1;
	}

	/* Cancel the DBGRQ and enable interrupts */
	jtag_select_scanchain(2);
	arm7tdmi_ice_write(0x00, 0x00);
	jtag_write_ireg(JTAG_RESTART);

	/* Select scan chain 1 and use INTEST instruction */
	jtag_select_scanchain(1);
	jtag_write_ireg(JTAG_INTEST);

	/*
	 * First, we recover the internal state of ARM7TDMI core.
	 * Use the following instructions sequence to recover R0 and PC:
	 * LDR R0, [R0] ; scan the value of PC into R0
	 * MOV PC, R0  ; update PC of the core
	 * LDR R0, [R0] ; scan in the value of R0 register
	 */

	/* LDR R0, [R0] = 0xE5900000       - restore PC */
	target->sc[1].writein[0] = 0xE5900000;
	target->sc[1].writein[1] = DEBUG_SPEED;
	arm7tdmi_exec_instruction(target->sc[1].writein, target->sc[1].readout);

	/* NOP */
	target->sc[1].writein[0] = 0xE1A00000;
	target->sc[1].writein[1] = DEBUG_SPEED;
	arm7tdmi_exec_instruction(target->sc[1].writein, target->sc[1].readout);

	/* NOP 
	 * 1st instruction is executed while fetching 3rd instruction
	 */
	target->sc[1].writein[0] = 0xE1A00000;
	target->sc[1].writein[1] = DEBUG_SPEED;
	arm7tdmi_exec_instruction(target->sc[1].writein, target->sc[1].readout);

	/* NOP                           -  scan in the value of PC */
	target->sc[1].writein[0] = reg_pc->value;
	target->sc[1].writein[1] = DEBUG_SPEED;
	arm7tdmi_exec_instruction(target->sc[1].writein, target->sc[1].readout);

	/* MOV PC, R0 = 0xE1A0F000       - put R0 into PC */
	target->sc[1].writein[0] = 0xE1A0F000;
	target->sc[1].writein[1] = DEBUG_SPEED;
	arm7tdmi_exec_instruction(target->sc[1].writein, target->sc[1].readout);

	/* NOP */
	target->sc[1].writein[0] = 0xE1A00000;
	target->sc[1].writein[1] = DEBUG_SPEED;
	arm7tdmi_exec_instruction(target->sc[1].writein, target->sc[1].readout);

	/* NOP 
	 * 1st instruction "MOV PC, R0" is executed,
	 * while fetching 3rd instruction
	 */
	target->sc[1].writein[0] = 0xE1A00000;
	target->sc[1].writein[1] = DEBUG_SPEED;
	arm7tdmi_exec_instruction(target->sc[1].writein, target->sc[1].readout);
	
	/* LDR R0, [R0] = 0xE5900000            - restore R0 */
	target->sc[1].writein[0] = 0xE5900000;
	target->sc[1].writein[1] = DEBUG_SPEED;
	arm7tdmi_exec_instruction(target->sc[1].writein, target->sc[1].readout);

	/* NOP */
	target->sc[1].writein[0] = 0xE1A00000;
	target->sc[1].writein[1] = DEBUG_SPEED;
	arm7tdmi_exec_instruction(target->sc[1].writein, target->sc[1].readout);

	/* NOP */
	target->sc[1].writein[0] = 0xE1A00000;
	target->sc[1].writein[1] = DEBUG_SPEED;
	arm7tdmi_exec_instruction(target->sc[1].writein, target->sc[1].readout);

	/* scan in the value of R0 register */
	target->sc[1].writein[0] = reg_r0->value;
	target->sc[1].writein[1] = DEBUG_SPEED;
	arm7tdmi_exec_instruction(target->sc[1].writein, target->sc[1].readout);

	/* 
	 * The penultimate instruction must be scanned in with bit33 set HIGH.
	 * insert NOP instruction: MOV R0, R0 = 0xE1A00000
	 */
	target->sc[1].writein[0] = 0xE1A00000;
	target->sc[1].writein[1] = SYSTEM_SPEED;
	arm7tdmi_exec_instruction(target->sc[1].writein, target->sc[1].readout);

	/*
	 * The final instruction is the branch instruction and it is
	 * scanned in with bit 33 set LOW. For small branches, you also
	 * can replace the final branch instruction with a substract
	 * instruction, with the PC as the destination operand.
	 * B -6 = 0xEAFFFFFA
	 */
	if (target->halt_reason == TARGET_HALTED_BY_BREAKPT)
		target->sc[1].writein[0] = 0xEAFFFFFB; /* opcode of "B -7" */
	else
		target->sc[1].writein[0] = 0xEAFFFFFA; /* opcode of "B -6" */
	target->sc[1].writein[1] = DEBUG_SPEED;	
	arm7tdmi_exec_instruction(target->sc[1].writein, target->sc[1].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);

	return 0;
} /* end of arm7tdmi_restart() */

struct target_operation arm7tdmi_tops = {
	/* ARM7TDMI EmbeddedICE-RT logic register read/write operations */
	.ice_read 	= arm7tdmi_ice_read,
	.ice_write 	= arm7tdmi_ice_write,

	/* ARM7TDMI cpu core operations */
	.halt		= arm7tdmi_halt,
	.restart	= arm7tdmi_restart,

	/* ARM7TDMI core registers read/write operations */
	.get_core_state = arm7tdmi_get_core_state,
	.register_read 	= arm7tdmi_register_read,
	.register_write	= arm7tdmi_register_write,

	/* ARM7TDMI target memory read/write operations */
	.mem_read8 = arm7tdmi_memory_read8,
	.mem_write8 = arm7tdmi_memory_write8,
	.mem_read16 	= arm7tdmi_memory_read16,
	.mem_write16 	= arm7tdmi_memory_write16,
	.mem_read32 	= arm7tdmi_memory_read32,
	.mem_write32 	= arm7tdmi_memory_write32,
};

int arm7tdmi_setup(void)
{
	arm7tdmi_target.regs = arm7tdmi_regs;
	arm7tdmi_target.ice_regs = arm7tdmi_ice_regs;

	target = &arm7tdmi_target;
	t_op = &arm7tdmi_tops;
	return 0;
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91.成人天堂一区| 一区二区三区中文免费| 亚洲欧洲成人自拍| 一级女性全黄久久生活片免费| 美女视频一区在线观看| 不卡一区二区在线| 精品福利在线导航| 天堂蜜桃91精品| 色成年激情久久综合| 久久久久久电影| 秋霞电影网一区二区| 色天天综合色天天久久| 国产亚洲精品久| 精品一二线国产| 欧美精品久久99久久在免费线| 亚洲欧洲在线观看av| 精品一区二区三区视频在线观看| 欧美亚洲国产怡红院影院| 国产精品乱人伦| 国产精品白丝jk白祙喷水网站| 69久久99精品久久久久婷婷| ...xxx性欧美| 成人国产视频在线观看| 国产日韩欧美a| 激情偷乱视频一区二区三区| 欧美一区二区三区啪啪| 亚洲成人你懂的| 在线观看日韩电影| 亚洲人精品一区| 91视频免费看| 亚洲视频小说图片| 91麻豆自制传媒国产之光| 中文在线资源观看网站视频免费不卡| 韩国毛片一区二区三区| 精品日韩在线观看| 国模套图日韩精品一区二区| 精品乱人伦一区二区三区| 久久国产精品色婷婷| 日韩精品中文字幕一区| 蜜臀精品一区二区三区在线观看 | 亚洲激情图片qvod| av成人老司机| 亚洲人成小说网站色在线 | 欧美韩国一区二区| 国产91丝袜在线播放| 国产精品另类一区| 91蜜桃在线观看| 亚洲猫色日本管| 在线观看亚洲a| 日本中文字幕一区二区视频| 欧美一区2区视频在线观看| 九色综合国产一区二区三区| 久久久久久久久久久电影| 国产精品 欧美精品| 国产精品免费久久| 91福利在线观看| 日本伊人色综合网| 国产欧美日韩精品在线| 91影视在线播放| 三级成人在线视频| 久久久久久久综合日本| 97国产精品videossex| 亚洲午夜电影在线观看| 26uuu亚洲| 色综合激情五月| 久久99日本精品| 日韩理论电影院| 日韩一区国产二区欧美三区| 国产一区二区三区精品欧美日韩一区二区三区| 亚洲国产高清在线观看视频| 91久久香蕉国产日韩欧美9色| 日日摸夜夜添夜夜添精品视频| 精品电影一区二区三区 | 国产精品1区2区3区| 亚洲欧美另类久久久精品 | 99久久国产综合精品色伊| 亚洲男同性恋视频| 日韩免费一区二区三区在线播放| 懂色中文一区二区在线播放| 一区二区三区日韩欧美| 久久这里只有精品视频网| 色婷婷国产精品久久包臀| 国产中文字幕一区| 午夜国产精品影院在线观看| 国产亚洲精品精华液| 91精品国产综合久久久蜜臀图片| 国产精品99精品久久免费| 亚欧色一区w666天堂| 中文字幕一区二区三区不卡| 日韩小视频在线观看专区| 在线观看91精品国产入口| 国产·精品毛片| 秋霞午夜av一区二区三区| 亚洲一区二区不卡免费| 国产色产综合色产在线视频| 欧美一区二区视频在线观看2020 | 亚洲欧美日韩一区二区| 久久久精品一品道一区| 日韩一区二区在线观看视频播放| 91小视频免费观看| 成人av集中营| 国产成人免费在线视频| 狠狠色狠狠色综合系列| 偷拍日韩校园综合在线| 一区二区三区中文在线观看| 成人欧美一区二区三区在线播放| 久久亚洲影视婷婷| 精品国产a毛片| 精品电影一区二区三区| 日韩欧美高清在线| 日韩欧美亚洲一区二区| 7777精品伊人久久久大香线蕉最新版| 色婷婷亚洲精品| 一本久道中文字幕精品亚洲嫩| 成人99免费视频| fc2成人免费人成在线观看播放| 国产成人免费高清| 丁香亚洲综合激情啪啪综合| 国产成人自拍在线| 粉嫩久久99精品久久久久久夜| 国产麻豆91精品| 国产成人精品一区二区三区四区 | 国产视频一区在线观看| 国产欧美日韩精品一区| 欧美国产欧美亚州国产日韩mv天天看完整| 2023国产一二三区日本精品2022| 精品国产一区二区亚洲人成毛片| 精品久久久久香蕉网| 久久精品人人做人人爽人人| 国产欧美一区二区精品久导航| 国产精品入口麻豆原神| 亚洲免费观看高清完整| 洋洋成人永久网站入口| 婷婷久久综合九色综合绿巨人| 日韩精品免费专区| 国产一区二区三区综合| 成人激情图片网| 欧美性欧美巨大黑白大战| 欧美体内she精视频| 欧美一区二区成人6969| 国产午夜精品久久久久久免费视| 国产女人水真多18毛片18精品视频 | 91老司机福利 在线| 欧美色图一区二区三区| 日韩欧美第一区| 国产精品青草久久| 亚洲aaa精品| 国产伦精品一区二区三区视频青涩 | 欧美午夜精品一区二区三区| 欧美一区二区成人| 国产精品久久一卡二卡| 天堂蜜桃一区二区三区| 国产成a人无v码亚洲福利| 色94色欧美sute亚洲线路一ni| 欧美群妇大交群中文字幕| 国产丝袜欧美中文另类| 亚洲成a人片综合在线| 国产精品99久久久久久宅男| 在线精品观看国产| 国产亚洲综合av| 五月天网站亚洲| 成人动漫av在线| 欧美tickling网站挠脚心| 一区二区在线免费| 国产黑丝在线一区二区三区| 欧美视频中文字幕| 国产精品伦一区二区三级视频| 青娱乐精品视频在线| 色婷婷av一区二区三区软件| 2024国产精品| 日本中文在线一区| 在线观看亚洲a| 中文一区在线播放| 蜜臀99久久精品久久久久久软件| 91丨porny丨最新| 日本一区二区免费在线| 日本vs亚洲vs韩国一区三区 | 激情国产一区二区| 欧美日韩在线播放| 亚洲婷婷综合久久一本伊一区| 裸体歌舞表演一区二区| 欧美主播一区二区三区| 1024国产精品| 成人免费va视频| 久久一留热品黄| 国内久久精品视频| 91麻豆精品国产91| 亚洲 欧美综合在线网络| 在线观看中文字幕不卡| 依依成人综合视频| 色婷婷综合久久久久中文一区二区 | 亚洲成人1区2区| 91精品1区2区| 依依成人精品视频| 色www精品视频在线观看| 亚洲欧洲成人av每日更新| 99精品视频一区二区| 国产精品高潮久久久久无| 99久久综合色| 亚洲男人的天堂在线观看|