📄 jtag_rdi.cpp
字号:
//////////////////////////////////////////////////////////////////////////////
// RDI_JTag.cpp //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Includes //
//////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
//////////////////////////////////////////////////////////////////////////////
// Variables //
//////////////////////////////////////////////////////////////////////////////
static RDI_ProcVec procVec;
//////////////////////////////////////////////////////////////////////////////
// DllMain //
//////////////////////////////////////////////////////////////////////////////
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
OutputDebugString("DLL_PROCESS_ATTACH");
return TRUE;
}
case DLL_THREAD_ATTACH:
{
OutputDebugString("DLL_THREAD_ATTACH");
return TRUE;
}
case DLL_THREAD_DETACH:
{
OutputDebugString("DLL_THREAD_DETACH");
return TRUE;
}
case DLL_PROCESS_DETACH:
{
OutputDebugString("DLL_PROCESS_DETACH");
return TRUE;
}
}
return FALSE;
}
//////////////////////////////////////////////////////////////////////////////
// //
//////////////////////////////////////////////////////////////////////////////
/*
* Function: RDI_OpenAgent
* Purpose: Initialisation routine for debug agent, which supports both
* hot and cold calls; the cold call is guaranteed to be the
* very first call made from the debugger into the debuggee.
*
* Input: type
* b0 0 cold start
* 1 warm start
* b1 1 reset the comms link
* b2 0/1 little/big endian
* b3 1 return endian
*
* config structure containing configuration
* information
*
* hostif used for reading/writing to a console
*
* dbg_state handle to identify the current Debugger
* state, or an umbrella-agent if toolconf
* tag "CONTROLLER_ISAGENT" is set.
*
* In/Out: agent cold start: passed in as NULL, returns
* pointer to debug agent instance
*
* warm start: pointer to debug agent instance
*
* Returns: b3 b2
* Error: RDIError_SoftInitialiseError X X If things go wrong!
* Error: RDIError_WrongByteSex 0 E bad match
* OK: RDIError_NoError 0 E match
* OK: RDIError_LittleEndian 1 X
* OK: RDIError_BigEndian 1 X
*
* Post-conditions: If no error occured, then *agent will contain a pointer
* to the debug agent instance (newly created if a cold
* start), and all parts of the system other than the
* Processor modules will have seen the open too.
*/
int MyRDI_OpenAgentProc(RDI_AgentHandle *agent, unsigned type, RDI150_ConfigPointer config, struct RDI_HostosInterface const *i, RDI_DbgState *dbg_state)
{
OutputDebugString("MyRDI_OpenAgentProc");
return RDIError_SoftInitialiseError;
}
/*
* Function: RDI_CloseAgent
* Purpose: Equivalent to the debuggee destructor.
* Ensure that all processors are also closed down
* Release any memory and close down the emulator.
* Only an RDI_open call can follow.
*
* Params: agent - handle of agent to close down
*
* Returns: RDIError_NoError
*/
int MyRDI_CloseAgentProc(RDI_AgentHandle agent)
{
OutputDebugString("MyRDI_CloseAgentProc");
return RDIError_NoError;
}
/*
* Function: RDI_OpenProc
* Purpose: This is the Initialization routine and as such is the first
* call made to the RDI. It allows the program to set up the
* initial debuggee working environment. It will be called
* later if the emulator is to be reset. There are hot and
* cold calls. On the very first cold call is equivalent to a
* constructor when memory should be claimed.
* The initialization also provides a console window for
* reading and writing text. This can be used now and in the
* future for messages. The call provides information on the
* settings on the debugger.
*
* Pre-conditions:
*
* Params:
* Input: handle Processor module handle
*
* type
* b0 0 cold start
* 1 warm start
* b1 1 reset the comms link
* b2 0/1 little/big endian
* b3 1 return endian
*
* config structure containing configuration
* information
*
* hostif used for reading/writing to a console
*
* dbg_state handle to identify the current Debugger
* state
*
* Returns: b3 b2
* Error: RDIError_SoftInitialiseError X X If things go wrong!
* Error: RDIError_WrongByteSex 0 E bad match
* OK: RDIError_NoError 0 E match
* OK: RDIError_LittleEndian 1 X
* OK: RDIError_BigEndian 1 X
*/
int MyRDI_OpenProc(RDI_ModuleHandle rdi_handle, unsigned type, RDI150_ConfigPointer config, struct RDI_HostosInterface const *i, RDI_DbgState *dbg_state)
{
OutputDebugString("MyRDI_OpenProc");
return RDIError_SoftInitialiseError;
}
/*
* Function: RDI_CloseProc
* Purpose: Close down an individual processor.
* > ISSUE <
* Behaviour is currently undefined if only a subset of
* processors are 'open' and execution is requested.
*
* Params: mh - Handle of processor to close down
*
* Returns: RDIError_NoError
*/
int MyRDI_CloseProc(RDI_ModuleHandle mh)
{
OutputDebugString("MyRDI_CloseProc");
return RDIError_NoError;
}
/*
* Function: RDI_ReadProc
* Purpose: Read memory contents in byte format from the debuggee.
* read *nbytes of data from source address and write to dest
* in the caller's address space using the processor specified.
*
* Assuming nothing went wrong with the transfer, the debuggee
* will normally return RDIError_NoError. However, if the
* debuggee has changed its byte sex, it should return a
* notification of this change, i.e. either RDIError_BigEndian
* or RDI_ErrorLittleEndian; the caller must then acknowledge
* this notification by calling RDI_Info RDIInfo_AckByteSex.
* The debuggee will keep returning this notification until an
* acknowledgement has been received.
*
* Params:
* Input: mh handle identifies processor
*
* source address
*
* access type and width of access
*
* In/Out: *nbytes In: number of bytes to read
* Out: number of bytes actually read
*
* Output: *dest destination buffer
*
* Returns:
* OK: RDIError_NoError
* RDIError_BigEndian
* RDIError_LittleEndian
* Error: RDIError_DataAbort (if a memory exception occurs)
*/
int MyRDI_ReadProc(RDI_ModuleHandle mh, ARMword source, void *dest, unsigned *nbytes, RDI_AccessType type)
{
OutputDebugString("MyRDI_ReadProc");
return RDIError_DataAbort;
}
/*
* Function: RDI_WriteProc
* Purpose: Write memory contents in byte format to the debuggee.
* read *nbytes of data from source address in the caller's
* address space, and write to dest using the processor specified.
*
* Assuming nothing went wrong with the transfer, the debuggee
* will normally return RDIError_NoError. However, if the
* debuggee has changed its byte sex, it should return a
* notification of this change, i.e. either RDIError_BigEndian
* or RDI_ErrorLittleEndian; the caller must then acknowledge
* this notification by calling RDI_Info RDIInfo_AckByteSex.
* The debuggee will keep returning this notification until an
* acknowledgement has been received.
*
* Params:
* Input: mh handle identifies processor
*
* source source buffer
*
* dest destination address
*
* access type and width of access
*
* In/Out: *nbytes In: number of bytes to write
* Out: number of bytes actually written
*
* Returns:
* OK: RDIError_NoError
* RDIError_BigEndian
* RDIError_LittleEndian
* Error: RDIError_DataAbort (if a memory exception occurs)
*/
int MyRDI_WriteProc(RDI_ModuleHandle mh, void const *source, ARMword dest, unsigned *nbytes, RDI_AccessType type)
{
OutputDebugString("MyRDI_WriteProc");
return RDIError_DataAbort;
}
/*
* Function: RDI_CPUreadProc
* Purpose: Read the register content from the specified processor.
* The mask specifies which register(s) are to be transferred
* as 32-bit ARMwords.
* The mask has been extended to support more than 32 registers
* Params:
* Input: mh handle identifies processor
*
* Input: mode mode defines register context
* ARM
* RDIMode_Curr use the current mode
* Other values match the mode bits of the PSR.
* PICCOLO *** Use of Piccolo is obsolete ***
* RDIModeBankX Transfer registers
* from bankX
*
* Input: mask[] bits defining which registers are to be
* transferred. These bits can be ORed to read any
* combination of registers.
* ARM
* b0 - b14 r0 - r14
* b15 Reserved. Bit 15 must be clear;
* targets must ignore bit 15.
* RDIReg_PC PC
* RDIReg_CPSR CPSR register
* RDIReg_SPSR SPSR register
* PICCOLO *** Use of Piccolo is obsolete ***
* b0-b<x> mask of which words in the
* bank to transfer
*
* Output: state[] destination array of ARMwords
*
* Returns:
* OK: RDIError_NoError
* Error: error code
*/
int MyRDI_CPUReadProc(RDI_ModuleHandle mh, unsigned mode, unsigned32 mask, ARMword *state)
{
OutputDebugString("MyRDI_CPUReadProc");
return RDIError_UnimplementedMessage;
}
/*
* Function: RDI_CPUwriteProc
* Purpose: Write the register content to the specified processor.
* The mask specifies which register(s) are to be transferred
* as 32-bit ARMwords. The mask has been extended to support
* more than 32 registers in RDI2.
*
* Params:
* Input: mh handle identifies processor
* Input: mode mode defines register context
* ARM
* RDIMode_Curr use the current mode
* Other values match the mode bits of the PSR.
* PICCOLO *** Use of Piccolo is obsolete ***
* As for RDI_CPUreadProc
* Input: mask[] bits defining which registers are to be
* transferred. These bits can be ORed to read any
* combination of registers.
* ARM
* b0 - b14 r0 - r14
* b15 Reserved. Bit 15 must be clear;
* targets must ignore bit 15.
* RDIReg_PC PC
* RDIReg_CPSR CPSR register
* RDIReg_SPSR SPSR register
* PICCOLO *** Use of Piccolo is obsolete ***
* As for RDI_CPUreadProc
* Input: state[] source array of ARMwords
* InOut: none
* Output: none
*
* Returns:
* OK: RDIError_NoError
* Not OK: RDIError_ReadOnly - if writing is not allowed at this time
* Error: error code
*/
int MyRDI_CPUWriteProc(RDI_ModuleHandle mh, unsigned mode, unsigned32 mask, ARMword const *state)
{
OutputDebugString("MyRDI_CPUWriteProc");
return RDIError_ReadOnly;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -