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

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

?? arm7tdmi.c

?? JTAG和ICE操作源代碼,在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_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;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品视频1区2区3区| 337p粉嫩大胆色噜噜噜噜亚洲| 免费观看在线综合色| 欧美激情一区二区在线| 欧美电影一区二区三区| 成人福利视频在线看| 蜜桃传媒麻豆第一区在线观看| 中文字幕中文字幕在线一区| 日韩午夜在线播放| 欧美做爰猛烈大尺度电影无法无天| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 亚洲国产日韩综合久久精品| 亚洲精品一区在线观看| 欧美丝袜丝交足nylons| 波多野结衣中文一区| 国内成人免费视频| 日本午夜精品视频在线观看| 成人欧美一区二区三区小说 | 欧美亚洲日本国产| www.亚洲国产| 国产91在线观看丝袜| 国产一区高清在线| 丝袜美腿亚洲综合| 五月开心婷婷久久| 亚洲国产精品综合小说图片区| 国产精品毛片久久久久久| 久久众筹精品私拍模特| 日韩精品一区二区三区在线| 777精品伊人久久久久大香线蕉| 欧美在线不卡视频| 在线精品观看国产| 欧美性一二三区| 欧美色综合天天久久综合精品| 色综合av在线| 91九色02白丝porn| 欧美性生活久久| 欧美日韩精品综合在线| 欧美精品日韩综合在线| 91麻豆精品国产自产在线| 在线成人av影院| 日韩一级黄色大片| 欧美精品一区二区三区在线| 欧美大片一区二区| 久久综合九色综合欧美就去吻| 精品精品国产高清a毛片牛牛| 欧美电视剧在线观看完整版| 欧美一区二区视频在线观看2022| 欧美久久久久久蜜桃| 91精品国产高清一区二区三区 | 美女视频黄a大片欧美| 久久69国产一区二区蜜臀| 蜜臀av亚洲一区中文字幕| 六月丁香综合在线视频| 国产精品一级片在线观看| 成人一级黄色片| 91麻豆.com| 在线观看欧美精品| 欧美一区二区人人喊爽| www亚洲一区| 日韩一区欧美小说| 天堂va蜜桃一区二区三区 | 免费成人av在线| 国产一区二区三区四| 成人激情开心网| 91网上在线视频| 欧美精品丝袜久久久中文字幕| 日韩女优av电影| 亚洲国产成人一区二区三区| 亚洲女同ⅹxx女同tv| 亚洲不卡av一区二区三区| 蜜桃一区二区三区四区| 国产高清在线观看免费不卡| 91麻豆国产精品久久| 在线不卡中文字幕| 久久精品在线观看| 一二三区精品福利视频| 美女高潮久久久| 99在线精品观看| 在线91免费看| 国产精品女同互慰在线看| 亚洲第一福利视频在线| 国产一区二区三区| 欧洲精品一区二区三区在线观看| 欧美电影免费观看高清完整版在线 | 99在线视频精品| 欧美伦理影视网| 欧美国产日韩在线观看| 国产精品国产三级国产专播品爱网 | 日韩一区二区影院| 国产精品久久久久久妇女6080| 亚洲一区二区欧美| 国产美女av一区二区三区| 欧美在线综合视频| 国产区在线观看成人精品| 视频在线观看国产精品| 成人av先锋影音| 日韩精品一区二区三区在线观看| 亚洲精品成人精品456| 韩国一区二区在线观看| 欧美日韩日日骚| 综合欧美一区二区三区| 狠狠久久亚洲欧美| 3751色影院一区二区三区| 亚洲三级理论片| 国产91高潮流白浆在线麻豆| 91精品国产高清一区二区三区蜜臀 | 亚洲摸摸操操av| 国产精品一区不卡| 欧美mv日韩mv国产网站app| 亚洲一区二区视频在线观看| 成人国产精品免费观看| 久久免费看少妇高潮| 日韩电影免费在线| 欧美日韩国产影片| 亚洲人成精品久久久久久| 国产东北露脸精品视频| 26uuu欧美日本| 精品伊人久久久久7777人| 欧美老年两性高潮| 亚洲va韩国va欧美va| 99免费精品在线| 国产精品视频第一区| 国产又粗又猛又爽又黄91精品| 欧美肥大bbwbbw高潮| 午夜精品一区二区三区电影天堂 | 国产精品影视网| 亚洲码国产岛国毛片在线| 国产美女精品在线| 精品国产一区二区三区av性色| 视频在线观看国产精品| 欧美挠脚心视频网站| 亚洲一区二区精品视频| 在线亚洲欧美专区二区| 亚洲欧美日韩国产中文在线| 99久久免费国产| 最近日韩中文字幕| 在线一区二区三区| 亚洲精品国产精华液| 日本黄色一区二区| 亚洲综合999| 欧美日韩久久一区二区| 三级在线观看一区二区| 日韩三区在线观看| 看片网站欧美日韩| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 91精品欧美久久久久久动漫 | 肉肉av福利一精品导航| 337p亚洲精品色噜噜噜| 麻豆高清免费国产一区| 久久嫩草精品久久久精品| 东方aⅴ免费观看久久av| 国产精品亲子伦对白| 色菇凉天天综合网| 亚洲一二三区视频在线观看| 欧美一三区三区四区免费在线看| 麻豆一区二区99久久久久| 精品国产乱码久久久久久蜜臀| 成人免费视频一区二区| 亚洲精品国产a| 67194成人在线观看| 激情综合网最新| 亚洲少妇最新在线视频| 欧美精品丝袜久久久中文字幕| 韩国一区二区三区| 亚洲免费av高清| 夫妻av一区二区| 91精品国产全国免费观看| 美国一区二区三区在线播放| 国产蜜臀97一区二区三区| 在线亚洲+欧美+日本专区| 美女在线视频一区| 国产精品美女久久福利网站| 欧美日韩免费一区二区三区 | 精品国产1区二区| 成人av电影观看| 亚洲成人免费视频| 久久九九影视网| 在线观看日韩电影| 国产一区二区视频在线播放| 亚洲精品中文在线| 欧美第一区第二区| 日本精品一区二区三区高清 | 麻豆国产精品官网| 亚洲激情自拍偷拍| 精品国精品自拍自在线| 色综合视频在线观看| 久久草av在线| 一区二区三区在线影院| 久久久精品欧美丰满| 欧美色图第一页| 成人午夜在线免费| 久久国产麻豆精品| 亚洲综合免费观看高清完整版| 久久久久久久久久久黄色| 欧美日韩中文字幕精品| 不卡视频一二三四| 国产一区二区三区在线观看精品| 亚洲va中文字幕| 亚洲女人****多毛耸耸8| 久久美女艺术照精彩视频福利播放|