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

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

?? arm7tdmi.c

?? ARM7,arm9通過JTAG燒寫程序源碼...C語言實現
?? 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一区二区三区免费野_久草精品视频
国产91高潮流白浆在线麻豆 | 精品国产一区二区精华| 亚洲美女电影在线| 91在线观看下载| 亚洲伦在线观看| 欧美特级限制片免费在线观看| 一区二区三区精品久久久| 欧美日韩亚洲综合在线| 美女爽到高潮91| 久久久久国产精品麻豆| 99精品一区二区| 五月婷婷激情综合| 久久久久久久综合| av成人动漫在线观看| 亚洲国产综合人成综合网站| 4438成人网| 国产伦精一区二区三区| 综合久久久久综合| 欧美色电影在线| 久久爱另类一区二区小说| 国产视频在线观看一区二区三区| 97国产精品videossex| 亚洲电影激情视频网站| 久久欧美一区二区| 在线中文字幕不卡| 国内成人免费视频| 一区二区三区四区不卡视频| 日韩丝袜美女视频| 成人一区二区三区视频| 亚洲一区在线观看免费 | 老汉av免费一区二区三区| 久久久99免费| 94-欧美-setu| 韩国三级中文字幕hd久久精品| 日韩美女啊v在线免费观看| 欧美精品乱码久久久久久| 成人一区二区三区中文字幕| 日本在线观看不卡视频| 国产精品久久久久aaaa| 日韩免费一区二区三区在线播放| 色综合久久中文字幕综合网| 久久精品72免费观看| 夜夜精品视频一区二区| 久久女同性恋中文字幕| 7777女厕盗摄久久久| 成人黄动漫网站免费app| 久久精品国内一区二区三区| 亚洲伦在线观看| 国产欧美精品一区二区三区四区| 在线不卡中文字幕播放| 色哟哟日韩精品| 高清日韩电视剧大全免费| 日韩精品91亚洲二区在线观看| 日韩一区中文字幕| 久久久久久久国产精品影院| 日韩一卡二卡三卡| 欧美日韩不卡一区| 色噜噜狠狠色综合欧洲selulu| 国产一区二区三区精品欧美日韩一区二区三区 | 石原莉奈在线亚洲二区| 国产精品传媒视频| 久久精品视频在线免费观看 | 欧美一区二区三区影视| 色悠久久久久综合欧美99| 丰满放荡岳乱妇91ww| 久热成人在线视频| 肉肉av福利一精品导航| 亚洲成人免费av| 一卡二卡欧美日韩| 亚洲人亚洲人成电影网站色| 国产精品色在线| 国产偷国产偷亚洲高清人白洁 | 91麻豆精品国产91久久久更新时间| 95精品视频在线| 91丝袜美腿高跟国产极品老师 | 欧美喷潮久久久xxxxx| 在线观看www91| 91福利在线导航| 日本韩国精品在线| 日本精品一级二级| 欧洲视频一区二区| 欧美综合一区二区三区| 欧美色国产精品| 在线不卡a资源高清| 制服.丝袜.亚洲.另类.中文 | 麻豆精品在线视频| 美日韩一区二区三区| 另类人妖一区二区av| 精品午夜久久福利影院| 激情av综合网| 风间由美性色一区二区三区| av成人老司机| 欧美亚洲综合久久| 91精品在线一区二区| 日韩欧美一区二区免费| 精品久久国产老人久久综合| 久久婷婷久久一区二区三区| 国产校园另类小说区| 国产精品传媒在线| 午夜视频一区二区| 蜜芽一区二区三区| 国产精品影视天天线| 99国产精品久久久久久久久久久| 在线国产电影不卡| 日韩欧美综合一区| 欧美国产精品一区二区三区| 亚洲综合在线第一页| 男人操女人的视频在线观看欧美| 另类综合日韩欧美亚洲| 成人黄色软件下载| 欧美老肥妇做.爰bbww| 久久综合狠狠综合久久综合88| 国产精品欧美一区二区三区| 亚洲综合免费观看高清完整版| 免费精品视频在线| 波多野结衣一区二区三区| 欧美日韩你懂得| 国产午夜精品一区二区三区嫩草| 中文字幕一区二区三区不卡| 午夜精品久久久久影视| 国产成人综合亚洲网站| 欧美视频一区二区在线观看| 久久久噜噜噜久噜久久综合| 亚洲一区在线视频| 国产99一区视频免费| 欧美麻豆精品久久久久久| 久久精品在线免费观看| 亚欧色一区w666天堂| 国产v综合v亚洲欧| 4438亚洲最大| 亚洲免费观看高清| 国产老女人精品毛片久久| 欧美调教femdomvk| 国产精品少妇自拍| 国产一区久久久| 欧美日韩的一区二区| 国产精品盗摄一区二区三区| 久久疯狂做爰流白浆xx| 欧美亚洲国产bt| 国产精品国产自产拍高清av王其| 青青草成人在线观看| 91亚洲资源网| 国产色产综合色产在线视频| 天天色天天爱天天射综合| 91免费视频网| 国产欧美日韩视频在线观看| 精品无人码麻豆乱码1区2区| 5月丁香婷婷综合| 亚洲精品免费看| 91色|porny| 国产日产欧美一区二区视频| 久久爱另类一区二区小说| 欧美一区三区四区| 亚洲第一福利视频在线| 91网站在线观看视频| 国产情人综合久久777777| 韩国午夜理伦三级不卡影院| 日韩精品中文字幕一区二区三区| 午夜电影网一区| 欧美日韩免费观看一区三区| 亚洲激情六月丁香| 色女孩综合影院| 亚洲欧美经典视频| aaa亚洲精品| 综合欧美一区二区三区| 91色视频在线| 一区二区高清免费观看影视大全| eeuss鲁一区二区三区| 日本一区二区高清| 高潮精品一区videoshd| 日本一区二区免费在线观看视频 | 亚洲444eee在线观看| 欧美这里有精品| 亚洲在线中文字幕| 欧美亚洲国产一区在线观看网站| 亚洲婷婷国产精品电影人久久| 成人99免费视频| 亚洲天堂精品视频| 91免费视频网址| 亚洲国产中文字幕在线视频综合| 欧美色区777第一页| 日韩av一区二区三区| 日韩欧美亚洲另类制服综合在线| 久久国产剧场电影| 国产欧美一区二区精品忘忧草 | 丰满白嫩尤物一区二区| 国产精品你懂的| 色先锋aa成人| 亚洲午夜激情av| 在线播放/欧美激情| 蜜桃免费网站一区二区三区| 久久综合久久综合久久综合| 成人激情小说网站| 亚洲一区在线观看视频| 日韩欧美久久一区| 粉嫩在线一区二区三区视频| 亚洲欧美激情一区二区| 正在播放一区二区| 国产麻豆成人精品| 亚洲精品综合在线|