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

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

?? arm7tdmi.c

?? JTAG控制源代碼.rar JTAG控制源代碼.rar
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
 * arm7tdmi.c:	implement the core routes for ARM7TDMI
 *
 * Copyright (C) 2004, OPEN-JTAG, All rights reserved.
 */

#include <windows.h>
#include "../tool.h"
#include "../xjerr.h"
#include "../tapctrl.h"
#include "arm7tdmi.h"
#include "ice.h"



//Used to record some important staus of the arm7tdmi
arm7tdmi_status_t arm7tdmi_status;
static arm7tdmi_breakpt_list_t *arm7tdmi_breakpt_head = NULL;
static arm7tdmi_watchpt_status_t arm7tdmi_watchpt_status = {0, 0};

/*
 * arm7tdmi_init() -
 *		Used to initialize the arm7tdmi's core status.
 *		Please call this route before starting any debug
 *		operations.
 */
int arm7tdmi_init(void)
{
	arm7tdmi_status.by = -1;
	arm7tdmi_status.scanchain = 3;				//On reset, scan chain 3 is selected by default.
	arm7tdmi_status.from = ARM7TDMI_FROM_ARM;
	arm7tdmi_status.state = ARM7TDMI_SYSTEM_STATE;
	arm7tdmi_status.endian = ARM7TDMI_LITTLE_END;
	
	return XJ_OK;	
}


/*
 * arm7tdmi_connect_scanchain() - 
 *		Used to select specific scan chian of arm7tmi and put
 *		the selected scan chain into test state. Before returning,
 *		the avtive scan chain is updated.
 *
 *		@sc_num: the scan chain to be selected.
 */
int arm7tdmi_connect_scanchain(int sc_num)
{
	int status;
	int shift_out;

	if(sc_num < 0 || sc_num > ARM7TDMI_NUMOF_SCANCHAIN)
		return XJ_ERROR;

	/*
	 * In SYSTEM state, select scan chain 0 and 1 is not allowed. Select scan
	 * chain 0 or 1 when in SYSTEM state will affect the debug and put the debug
	 * into unpredictable situation.
	 */
	if( (arm7tdmi_status.state != ARM7TDMI_DEBUG_STATE) && (sc_num != 2) )
		return XJERR_TARGET_RUNNING;

	status = tapctrl_acs_ireg(JTAG_SCAN_N);
	if(status != XJ_OK)
		return status;

	status = tapctrl_acs_dreg(ARM7TDMI_REGLEN_SCSEL, &sc_num, &shift_out);
	if(status != XJ_OK)
		return status;
	if(shift_out != 0x8)			//shift out should be b1000
		return XJERR_SCANCHAIN_FAIL;

	//Enter INTEST state
	status = tapctrl_acs_ireg(JTAG_INTEST);
	if(status != XJ_OK)
		return status;
	
	//Update the active scan chain
	arm7tdmi_status.scanchain = sc_num;

	return XJ_OK;
}


/*
 * arm7tdmi_acs_sc1() - 
 *		Used to acces scan chain 1. By calling this route, ARM/THUMB 
 *		instructions can be scaned into the databus and clocked into
 *		the pipeline. When scan chain 1 is selected and put into 
 *		INTEST state, everytime enter the RUN-TEST/IDLE state, a DCLK
 *		is generated. Please make sure scan chain 1 is selected and 
 *		put it into INTEST state before calling this route.
 * 
 *		Due to the reverse bit sequence of scan chain 1 cells,
 *		all the data shifted in and out from scan chain 1 should
 *		be reversed.
 *
 *		@shift_in:  data shifted into scan chain 1
 *		@shift_out: data shifted out from scan chain 1
 */
int arm7tdmi_acs_sc1(u32 *shift_in, u32 *shift_out)
{
	int status;
	u32 in_temp[2];
	u32 out_temp[2];

	//In DEBUG state?
	if(arm7tdmi_status.state != ARM7TDMI_DEBUG_STATE)
		return XJERR_TARGET_RUNNING;
	
	//Scan chain 1 selected?
	if(arm7tdmi_status.scanchain != 1)
		return XJERR_SC1_NOT_SELECTED;
	
	tool_reverse_bit_order(ARM7TDMI_REGLEN_SC1, shift_in, in_temp);		//Revert shifted in
	status = tapctrl_acs_dreg(ARM7TDMI_REGLEN_SC1, in_temp, out_temp);
	tool_reverse_bit_order(ARM7TDMI_REGLEN_SC1, out_temp, shift_out);	//Revert shifted out
	
	return XJ_OK;
}


/*
 * arm7tdmi_system_reste() -
 *		This route use nRESET to reset the system.
 *		To reset the system by nRESET, there must have a
 *		connection between the jtag interface and nRESET
 */
int arm7tdmi_system_reset(void)
{
	return XJ_OK;
}


/*
 * arm7tdmi_enter_dbgstat() - 
 *		This route is used to force the target enter DEBUG state by 
 *		forcing DEBUGRQ signal HIGH. The value of PC when entering
 *		DEBUG state is recorded. 
 *
 *		The obtained value of PC indicates the next instruction to 
 *		be executed on exit from DEBUG state, which is important and
 *		critcal to resume the normal execution of program under debug.
 *		It is for later use to return from the DEBUG state back to 
 *		the SYSTEM state.
 *
 *		Please modify this function carefully.
 * 
 *		@pc:	used to return the value of PC which indicates the
 *				next instruction to be execute on exit from DEBUG
 *				state.
 */
int arm7tdmi_enter_dbgstat(u32 *pc)
{
	int status;
	u32 r0;
	u32 dbgstat;
	u32 shift_in[2];
	u32 shift_out[2];

	if(pc == NULL)
		return XJERR_INVALID_PARAMATER;

	//Check whether already in DEBUG state?
	if(arm7tdmi_status.state == ARM7TDMI_DEBUG_STATE)
		return XJERR_TARGET_HALTED;

	//Enter DEBUG state by forcing DEBUGRQ signal HIGH 
	
	//Select scan chain 2
	status = arm7tdmi_connect_scanchain(2);
	if(status != XJ_OK)
		return status;
	
	//Write DEBUG control register
	status = arm7tdmi_ice_write(ARM7TDMI_ICE_DBGCTRL, 0x6);
	status = tapctrl_runtest();

	//Check the DBGACK signal to judge whether operation success?
	status = arm7tdmi_ice_read(ARM7TDMI_ICE_DBGSTAT, &dbgstat);
	if(status != XJ_OK)
		return status;
	if( (dbgstat & 0x1) == 0 )
		return XJERR_ENTDBG_FAIL;

	//Successful, update the arm7tdmi status
	arm7tdmi_status.by = ARM7TDMI_BY_BREAKPT;
	arm7tdmi_status.state = ARM7TDMI_DEBUG_STATE;
	
	if (dbgstat & 0x10)
		arm7tdmi_status.from = ARM7TDMI_FROM_THUMB;
	else
		arm7tdmi_status.from = ARM7TDMI_FROM_ARM;

	/*
	 * Don't forget to clear the DEBUG control register to 
	 * avoid enter DEBUG state. This is necessary.
	 */
	arm7tdmi_ice_write(ARM7TDMI_ICE_DBGCTRL, 0x0);


	/*
	 * Try to obtain the value of PC when entering DEBUG state. The obtained
	 * value of PC indicates the next instruction to be executed on exit from
	 * DEBUG state.
	 */

	//Select scan chain 1
	status = arm7tdmi_connect_scanchain(1);
	if(status != XJ_OK)
		return status;

	if(arm7tdmi_status.from == ARM7TDMI_FROM_ARM){    //Enter DEBUG from ARM state

		//Step 1 - Read R0

		//STR R0, [R0] = 0xE5800000					
		shift_in[0] = 0xE5800000;					//Instruction 1
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//NOP
		shift_in[0] = ARM7TDMI_NOP;					//Instruction 2
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//NOP
		shift_in[0] = ARM7TDMI_NOP;					//Instruction 3
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//NOP
		shift_in[0] = ARM7TDMI_NOP;
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);
		r0 = shift_out[0];

		//Step 2 - Move PC to R0

		//MOV R0, PC = 0xE1A0000F
		shift_in[0] = 0xE1A0000F;					//Instruction 4
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);	

		//NOP
		shift_in[0] = ARM7TDMI_NOP;					
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//NOP
		shift_in[0] = ARM7TDMI_NOP;					
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//Step 3 - Read the value of PC from R0

		//STR R0, [R0] = 0xE5800000
		shift_in[0] = 0xE5800000;					
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//NOP
		shift_in[0] = ARM7TDMI_NOP;					
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//NOP
		shift_in[0] = ARM7TDMI_NOP;					
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//NOP
		shift_in[0] = ARM7TDMI_NOP;					
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);
		*pc = shift_out[0];

		/* 
		 * Entry into DEBUG state through a debug request is similar to a 
		 * breakpoint. However, unlike a breakpoint, the last instruction 
		 * has completed execution and so must not be refetched on exit 
		 * from DEBUG state. You can assume that entry to DEBUG state adds
		 * three addresses to the PC and every instruction executed in DEBUG
		 * state adds one address. To move the value of PC to R0, 4 instructions
		 * have been executed in DEBUG state. So, the value of PC which 
		 * indicates the next instruction should be executed on exit from 
		 * DEBUG state is
		 *				pc - 4 x (3 + 4)
		 */
		*pc -= 28;

	}else{		//Enter DEBUG from THUMB state
		
		//Step 1 - Read R0 

		//STR R0, [R0] = 0x60006000
		shift_in[0] = 0x60006000;					//Instruction 1
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//NOP 
		shift_in[0] = 0x1C001C00;					//Instruction 2
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//NOP 
		shift_in[0] = 0x1C001C00;					//Instruction 3
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//R0
		shift_in[0] = 0x1C001C00;					
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);
		r0 = shift_out[0];

		//Step 2 - Move PC to R0

		//MOV R0, PC = 0x46784678
		shift_in[0] = 0x46784678;					//Instruction 4			
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//NOP 
		shift_in[0] = 0x1C001C00;					
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//NOP 
		shift_in[0] = 0x1C001C00;					
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//Step 3 - Read the value of PC from R0

		//STR R0, [R0] = 0x60006000
		shift_in[0] = 0x60006000;					
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//NOP 
		shift_in[0] = 0x1C001C00;					
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//NOP 
		shift_in[0] = 0x1C001C00;					
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//NOP 
		shift_in[0] = 0x1C001C00;					
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);
		*pc = shift_out[0];

		/* 
		 * Entry into DEBUG state through a debug request is similar to a 
		 * breakpoint. However, unlike a breakpoint, the last instruction 
		 * has completed execution and so must not be refetched on exit 
		 * from DEBUG state. You can assume that entry to DEBUG state adds
		 * three addresses to the PC and every instruction executed in DEBUG
		 * state adds one address. To move the value of PC to R0, 4 instructions
		 * have been executed in DEBUG state. So, the value of PC which 
		 * indicates the next instruction should be executed on exit from 
		 * DEBUG state is
		 *				pc - 2 x (3 + 4)
		 */
		*pc -= 14;

		//Step4 - Switch from THUMB state to ARM state

		/*
		 * When enter DEBUG state from THUBM state, we make ARM7TDMI enter ARM 
		 * state before any other debug operation is performed. Before leave the
		 * DEBUG state, we make ARM7TDMI return back to THUMB state before the
		 * normal operation is resumed.
		 */

		//BX PC = 0x47784778
		shift_in[0] = 0x47784778;					
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//NOP 
		shift_in[0] = 0x1C001C00;					
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);

		//NOP 
		shift_in[0] = 0x1C001C00;					
		shift_in[1] = ARM7TDMI_DEBUG_SPEED;
		arm7tdmi_acs_sc1(shift_in, shift_out);
	}

	//Last Step - Restore R0
	arm7tdmi_core_wri_reg(ARM7TDMI_R0, r0);

	return XJ_OK;
}


/* 
 * arm7tdmi_check_dbgstat() -
 *		After some breakpts or watchpts are setting, this route is used
 *		to check the DEBUG status register to check whether the ARM7TDMI
 *		enter DEBUG state by breakpt/watchpt. 
 *
 *		When DBGACK flag is not set, XJ_ERROR is returned. When DBGACK 
 *		flag is set, it means the ARM7TDMI is in DEBUG state. Next, try
 *		to obtain the value of PC when entering the DEBUG state. 
 *
 *		The obtained value of PC indicates the next instruction to be 
 *		executed on exit from DEBUG state, which is important and
 *		critcal to resume the normal execution of program under debug.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美国产日韩在线观看| 天堂影院一区二区| 五月天激情综合网| 丰满少妇在线播放bd日韩电影| 色欲综合视频天天天| 久久久亚洲高清| 性做久久久久久免费观看| 国产福利一区二区三区| 欧美一区二区在线视频| 亚洲视频小说图片| 丁香六月久久综合狠狠色| 91麻豆精品国产91久久久资源速度| 国产精品久久一级| 国产精品一区在线观看乱码| 欧美日韩精品电影| 一区二区三区免费网站| 国产91色综合久久免费分享| 精品国产髙清在线看国产毛片| 亚洲在线观看免费| 欧美影院精品一区| 亚洲精品中文字幕在线观看| 成人av网站大全| 国产日韩av一区| 成人综合在线网站| 国产无人区一区二区三区| 久久精品国产99久久6| 制服丝袜亚洲色图| 亚洲一区二区在线观看视频| 91视频国产观看| 中文字幕欧美一区| 成人av手机在线观看| 久久精品一区二区三区av| 国产在线日韩欧美| 久久精品夜色噜噜亚洲a∨| 狠狠色综合播放一区二区| 欧美videofree性高清杂交| 美女精品一区二区| 久久这里只有精品6| 国产一区二区精品久久| 国产亚洲一区二区在线观看| 国产剧情av麻豆香蕉精品| 国产三级精品三级| 国产91精品精华液一区二区三区 | 蜜芽一区二区三区| 欧美高清视频不卡网| 麻豆成人91精品二区三区| 亚洲国产精品久久一线不卡| 欧美影院午夜播放| 日韩高清不卡在线| 欧美精品一区二| 北条麻妃一区二区三区| 亚洲精品日韩一| 欧美人伦禁忌dvd放荡欲情| 久久国产精品色| 国产精品视频一二| 色哦色哦哦色天天综合| 肉肉av福利一精品导航| 久久久精品免费免费| 91网站在线观看视频| 丝袜亚洲精品中文字幕一区| 亚洲精品一区二区精华| 99re6这里只有精品视频在线观看| 亚洲美女免费视频| 欧美成人欧美edvon| 波多野洁衣一区| 日本不卡高清视频| 亚洲欧美日韩久久精品| 欧美一区二区三区在线观看| 国产乱码精品一区二区三区五月婷| 综合久久久久久| 欧美成人vr18sexvr| 日本久久电影网| 国产自产2019最新不卡| 亚洲精品少妇30p| 久久综合久久久久88| 欧美日韩三级视频| 国产成人夜色高潮福利影视| 亚洲午夜av在线| 国产精品久久久久久一区二区三区 | 精品国产乱码久久久久久久| 91视频一区二区三区| 精品一区二区久久| 亚洲成年人网站在线观看| 国产精品人成在线观看免费 | 日韩中文字幕亚洲一区二区va在线 | 欧美精品黑人性xxxx| 成人一级片在线观看| 美女一区二区在线观看| 一区二区三区欧美亚洲| 国产精品护士白丝一区av| 日韩欧美一区二区免费| 欧美视频一区二区三区四区| 国产**成人网毛片九色 | 亚洲乱码日产精品bd| 国产清纯白嫩初高生在线观看91 | 亚洲精品国产无套在线观| 久久综合久久久久88| 91精品在线观看入口| 在线看日本不卡| 91美女在线看| 91热门视频在线观看| 风间由美一区二区av101| 国产资源精品在线观看| 久久成人18免费观看| 日本va欧美va欧美va精品| 亚洲风情在线资源站| 一区二区三区不卡视频在线观看| 国产精品毛片a∨一区二区三区| 久久一日本道色综合| www一区二区| 久久精品在这里| 欧美国产精品久久| 欧美国产精品劲爆| 国产精品久久久久久久久快鸭| 欧美国产成人在线| 中文一区二区在线观看| 中文字幕欧美区| 国产精品嫩草影院com| 国产精品的网站| 亚洲猫色日本管| 亚洲乱码国产乱码精品精的特点| 亚洲六月丁香色婷婷综合久久| 亚洲色图欧美在线| 亚洲成人精品影院| 日本不卡视频一二三区| 激情五月激情综合网| 国产精品一区二区果冻传媒| 成人综合在线观看| 在线日韩国产精品| 欧美一区二区在线观看| 26uuu精品一区二区| 中文无字幕一区二区三区| 一区二区三区四区国产精品| 亚洲一区二区av在线| 日日夜夜免费精品视频| 国产在线观看一区二区| 成人高清伦理免费影院在线观看| 91浏览器在线视频| 制服视频三区第一页精品| 精品三级在线观看| 国产精品―色哟哟| 五月激情综合婷婷| 国产精品自产自拍| 色噜噜狠狠色综合中国| 91精品国产综合久久小美女| 久久一区二区视频| 亚洲女同一区二区| 精品一区免费av| 一本到三区不卡视频| 欧美一区二区三区免费大片| 中文字幕电影一区| 亚洲成人三级小说| 成人永久免费视频| 91精品黄色片免费大全| 国产精品免费视频观看| 日韩电影网1区2区| jlzzjlzz国产精品久久| 日韩精品中文字幕一区二区三区| 国产精品视频观看| 免费的国产精品| 欧洲亚洲精品在线| 国产色91在线| 日本美女一区二区| 日本道色综合久久| 国产日韩精品久久久| 免费观看91视频大全| 91久久一区二区| 国产精品美女久久久久高潮| 日韩国产成人精品| 色婷婷综合久久久久中文| 久久久久久麻豆| 麻豆一区二区99久久久久| 欧美影院精品一区| 亚洲欧美视频在线观看视频| 激情图片小说一区| 4hu四虎永久在线影院成人| 综合中文字幕亚洲| 国产精品亚洲一区二区三区在线| 欧美另类久久久品| 亚洲一线二线三线视频| 成人免费电影视频| 国产亚洲欧美一区在线观看| 日韩电影一区二区三区| 欧美天天综合网| 亚洲一区二区3| 欧美四级电影网| 一区二区三区高清不卡| 色综合久久久久综合体桃花网| 国产精品无码永久免费888| 国产美女娇喘av呻吟久久| 日韩免费高清av| 久久精品国产免费| 欧美精品一区二区三区很污很色的| 五月激情六月综合| 欧美精品九九99久久| 日韩国产欧美三级| 日韩欧美国产wwwww| 捆绑调教美女网站视频一区| 日韩女优av电影在线观看| 日本vs亚洲vs韩国一区三区二区|