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

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

?? arm7tdmi.c

?? 一個簡易調試器(支持ARM7TDMI)
?? 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一区二区三区免费野_久草精品视频
亚洲国产日韩a在线播放性色| 懂色av一区二区三区免费观看| 国产精品一二三在| 欧美影院午夜播放| 国产欧美精品一区| 久久国内精品视频| 欧美日韩国产综合一区二区三区| 国产精品久久久久婷婷| 黑人巨大精品欧美一区| 欧美视频一区二区三区| 欧美国产一区二区| 国产在线精品国自产拍免费| 欧美日本一区二区| 亚洲综合激情另类小说区| 亚洲午夜激情av| 99国产精品国产精品久久| 成人av电影在线播放| 亚洲精品一区二区三区在线观看| 一区二区三区四区在线免费观看 | 99re这里都是精品| 久久只精品国产| 蜜臀av一区二区在线免费观看| 欧美色国产精品| 亚洲人成亚洲人成在线观看图片| 国产精品夜夜嗨| 日韩精品一区二区三区在线| 日韩电影在线一区二区| 欧美日韩在线播| 亚洲国产精品精华液网站| 日本久久电影网| 一区二区三区四区不卡在线 | 国产91对白在线观看九色| 精品少妇一区二区三区在线视频| 日韩成人一区二区| 欧美一区二区三区喷汁尤物| 日本最新不卡在线| 日韩女优毛片在线| 久久成人18免费观看| 2024国产精品| 国产一区三区三区| 欧美激情在线免费观看| 91亚洲永久精品| 亚洲国产日产av| 欧美高清www午色夜在线视频| 日韩精品高清不卡| 久久亚洲精精品中文字幕早川悠里| 国产麻豆日韩欧美久久| 国产精品毛片大码女人| 一本大道久久a久久综合婷婷| 亚洲第一搞黄网站| 精品88久久久久88久久久| 国产高清不卡一区| 亚洲制服丝袜av| 欧美一级搡bbbb搡bbbb| 国产成a人亚洲| 一级女性全黄久久生活片免费| 欧美乱妇一区二区三区不卡视频| 免费欧美在线视频| 国产日韩欧美精品综合| 在线观看网站黄不卡| 老司机精品视频在线| 久久欧美一区二区| 色香色香欲天天天影视综合网| 五月婷婷色综合| 久久你懂得1024| 欧美色图天堂网| 国产在线一区观看| 亚洲综合色成人| 久久综合av免费| 欧美日韩另类国产亚洲欧美一级| 国产一区二区三区视频在线播放| 亚洲精选免费视频| 久久久不卡网国产精品二区| 欧亚一区二区三区| 国内偷窥港台综合视频在线播放| 亚洲激情av在线| 国产目拍亚洲精品99久久精品| 9191成人精品久久| 99精品视频在线免费观看| 蜜桃视频一区二区三区在线观看| 亚洲丝袜制服诱惑| 久久综合999| 6080yy午夜一二三区久久| www.日韩大片| 国产在线一区二区综合免费视频| 亚洲在线成人精品| 国产精品成人免费| 337p日本欧洲亚洲大胆精品| 欧美专区日韩专区| 大白屁股一区二区视频| 日本va欧美va瓶| 亚洲一区二区在线视频| 欧美激情中文不卡| 久久精品这里都是精品| 欧美一区二区视频在线观看2022| 在线观看免费一区| 99视频精品在线| 成人午夜视频在线观看| 国产精品18久久久| 国产精品综合在线视频| 美女一区二区在线观看| 日韩精品1区2区3区| 亚洲高清免费视频| 午夜欧美在线一二页| 一区二区三区在线看| 亚洲三级理论片| 国产精品看片你懂得| 国产精品剧情在线亚洲| 国产精品久久福利| 国产精品嫩草99a| 国产精品女同一区二区三区| 国产精品人成在线观看免费| 久久精品一区二区三区av| 久久午夜老司机| 国产亚洲午夜高清国产拍精品| 久久久国产精品不卡| 日本一区二区在线不卡| 国产精品乱人伦| 国产精品久久久爽爽爽麻豆色哟哟| 中文幕一区二区三区久久蜜桃| 国产午夜精品久久| 亚洲视频一区在线| 亚洲国产成人av| 婷婷开心久久网| 麻豆一区二区三| 福利一区福利二区| 97久久精品人人爽人人爽蜜臀| 风间由美性色一区二区三区| 菠萝蜜视频在线观看一区| 99国产精品久久久久久久久久久| 91女厕偷拍女厕偷拍高清| 欧美综合久久久| 91精品国产综合久久久久| 欧美va天堂va视频va在线| 久久综合色天天久久综合图片| 国产婷婷一区二区| 亚洲自拍偷拍欧美| 麻豆精品国产91久久久久久| 成人午夜视频福利| 欧美性大战xxxxx久久久| 欧美大白屁股肥臀xxxxxx| 国产精品视频第一区| 亚洲综合色在线| 极品少妇一区二区| 色综合色狠狠综合色| 欧美精品日日鲁夜夜添| 国产亚洲精品7777| 亚洲二区在线视频| 国产aⅴ综合色| 欧美日韩国产综合久久| 欧美精品一区二区三区在线播放| 国产精品视频第一区| 日韩精品一二三区| 成人黄色综合网站| 欧美一级专区免费大片| 亚洲人一二三区| 久久成人羞羞网站| 91国产丝袜在线播放| 久久久夜色精品亚洲| 亚洲成av人片| 99re成人精品视频| 精品国免费一区二区三区| 亚洲影视资源网| 岛国av在线一区| 日韩免费观看高清完整版| 一区二区三区四区不卡视频 | 中文字幕不卡在线| 日韩电影在线一区| 91激情在线视频| 国产情人综合久久777777| 日韩福利视频网| 色老综合老女人久久久| 国产日韩欧美激情| 精品亚洲免费视频| 69堂精品视频| 一区二区三区免费| www.一区二区| 欧美激情综合在线| 韩国欧美一区二区| 8v天堂国产在线一区二区| 一区av在线播放| 99久久99久久精品国产片果冻| 久久久欧美精品sm网站| 日本人妖一区二区| 88在线观看91蜜桃国自产| 亚洲成人精品一区二区| 日本丰满少妇一区二区三区| 国产精品日韩精品欧美在线| 激情久久五月天| 欧美xingq一区二区| 精品一区二区三区久久| 欧美一区二区三区四区五区| 午夜视频一区在线观看| 欧美日本视频在线| 亚洲成人免费在线观看| 欧美日韩日日骚| 亚洲成av人片在线观看| 欧美精品v国产精品v日韩精品| 一区二区三区精品| 欧美影视一区在线|