📄 dbgioctls.c
字号:
// -----------------------------------------------------------------------
// INTEL CORPORATION MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS
// MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// INTEL CORPORATION ASSUMES NO RESPONSIBILITY FOR ANY ERRORS THAT MAY
// APPEAR IN THIS DOCUMENT. INTEL CORPORATION MAKES NO COMMITMENT TO
// UPDATE NOR TO KEEP CURRENT THE INFORMATION CONTAINED IN THIS DOCUMENT.
// -----------------------------------------------------------------------
//
// XScale Browser debug extension implementation
#ifdef USING_XSCALEBROWSER
#define WINCEMACRO 1
#include "windows.h"
#include "dbgioctl.h"
// GLOBALS
DWORD XSCBwrThreadID = (DWORD)INVALID_HANDLE_VALUE;
DWORD XSCBwrProcessID = (DWORD)INVALID_HANDLE_VALUE;
XSCContextArea XSCBwrSaveThreadContextArea;
// storage for the original OS DATA-Abort handler address while
// a modified execution trace handler is active
//
static PFNVOID pfOSDataAbortHandler;
// QueryContextRegs Id-Table
//
// This tables contains the coprocessor IDs that are saved by the bsp
// for every thread (OEMSave/RestoreCoProcRegister)
//
// Coprocessor ID format:
// Bit 31-28 Bit 27-16 Bit15-12 Bit 11-8 Bit 7-4 Bit 3-0
// CP# <reserved> opcode_1 CRn opcode_2 CRm
//
// BSP-SPECIFIC---------------------START-----------------------------------
#define XSCBWR_NUM_CXTREGS_SAVED 22
// QueryContextRegs IdTable Struct
// This table has the same 'layout' as the save/restore puts
// the registers in memory - it is not linear with respect
// to simply increasing the registers, it is interleaved
DWORD XSCBwrQryCxtRegsIdTable[XSCBWR_NUM_CXTREGS_SAVED] = {
0x10000200, // wC2 (CoProc1, Reg 2) - WCSSF
0x10000300, // wC3 - WCASF
0x00002100, // wR0 (CoProc0, Reg 0) & ACC0 for PXA250!
0x00002101, // wR1
0x00002102, // wR2
0x10000900, // wC8 - Also WCGR0
0x00002103, // wR3
0x00002104, // wR4
0x00002105, // wR5
0x00002106, // wR6
0x00002107, // wR7
0x00002108, // wR8
0x00002109, // wR9
0x0000210a, // wR10
0x0000210b, // wR11
0x0000210c, // wR12
0x0000210d, // wR13
0x0000210e, // wR14
0x0000210f, // wR15
0x10000900, // wC9 - WCGR1
0x10000a00, // wC10 - WCGR2
0x10000b00, // wC11 - WCGR3
};
// This array acts as an index for the above registers in the global context
// save area. As this area has both 32 & 64-bit elements, it is not a linear
// index, as such, this table will "Translate" from one to the other.
// By indexing both in parallel,
//
int CxtRegXLTNTable[XSCBWR_NUM_CXTREGS_SAVED] =
{
1, // wC2 (CoProc1, Reg 2) - WCSSF = Array Pos. 1 ([0] = saved flag)
2, // wC3 - WCASF
3, // wR0 (CoProc0, Reg 0) & ACC0 for Cotulla!!!! = Pos. 3 & 4
5, // wR1
7, // wR2
9, // wC8 - Also WCGR0
10, // wR3
12, // wR4
14, // wR5
16, // wR6
18, // wR7
20, // wR8
22, // wR9
24, // wR10
26, // wR11
28, // wR12
30, // wR13
32, // wR14
34, // wR15
36, // wC9 - WCGR1
37, // wC10 - WCGR2
38 // wC11 - WCGR3
};
// BSP-SPECIFIC----------------------END------------------------------------
/*-------------------------------------------------------------------------
* Function: GetVersionIoctl
*-------------------------------------------------------------------------
* Description: process the get version command from
* the XScale Browser
*-------------------------------------------------------------------------
* Pre/Side/Post: prototype matches OEMIoControl
*-------------------------------------------------------------------------
*/
static BOOL GetVersionIoctl(DWORD dwIoControlCode,
LPVOID lpInBuf, DWORD nInBufSize,
LPVOID lpOutBuf, DWORD nOutBufSize,
LPDWORD lpBytesReturned)
{
// output buffer format
PXSCBwrVersion pXSCBwrVersion;
// Return Value
BOOL retval = FALSE;
if ( (lpOutBuf == NULL ) ||
(sizeof(XSCBwrVersion) > nOutBufSize) ||
(lpBytesReturned == NULL)
)
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return(retval);
}
pXSCBwrVersion = (PXSCBwrVersion)lpOutBuf;
pXSCBwrVersion->Major = XSCBWR_V_MAJOR;
pXSCBwrVersion->Minor = XSCBWR_V_MINOR;
// Set the Bytes Returned size
*lpBytesReturned = sizeof(XSCBwrVersion);
// Set the return value
retval = TRUE;
return(retval);
}
/*-------------------------------------------------------------------------
* Function: ReadCoProcessorIoctl
*-------------------------------------------------------------------------
* Description: process the coprocessor read command from
* the XScale Browser
*-------------------------------------------------------------------------
* Pre/Side/Post: prototype matches OEMIoControl
*-------------------------------------------------------------------------
*/
static BOOL ReadCoProcessorIoctl(DWORD dwIoControlCode,
LPVOID lpInBuf, DWORD nInBufSize,
LPVOID lpOutBuf, DWORD nOutBufSize,
LPDWORD lpBytesReturned)
{
// CoProc Read Input Buffer Ptr
PXSCBwrRdRegIn pXSCBwrRdRegInBuf;
// CoProc Read Output Buffer Ptr
PXSCBwrRdRegOut pXSCBwrRdRegOutBuf;
// Return Value
BOOL retval = FALSE;
// RETAILMSG(1,(TEXT("In XSDBG READ COPROCESSOR\n")));
//Check the size of the input & Output buffers
if ((lpInBuf == NULL) || (lpOutBuf == NULL))
{
SetLastError(ERROR_INVALID_PARAMETER);
return(retval);
}
if ( (sizeof(XSCBwrRdRegOut) > nOutBufSize) || (lpBytesReturned == NULL) )
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return(retval);
}
pXSCBwrRdRegInBuf = (PXSCBwrRdRegIn)lpInBuf;
pXSCBwrRdRegOutBuf = (PXSCBwrRdRegOut)lpOutBuf;
// execute the 'read'
XSCBwrExecuteCoProcCode((pXSCBwrRdRegInBuf->OpCode),
(&pXSCBwrRdRegOutBuf->Reg1),
(&pXSCBwrRdRegOutBuf->Reg2));
// Set the Bytes Returned size
*lpBytesReturned = sizeof(XSCBwrRdRegOut);
// Set the return value
retval = TRUE;
return(retval);
}
/*-------------------------------------------------------------------------
* Function: WriteCoProcessorIoctl
*-------------------------------------------------------------------------
* Description: Process the coprocessor write command from
* the XScale Browser
*-------------------------------------------------------------------------
* Pre/Side/Post: prototype matches OEMIoControl
*-------------------------------------------------------------------------
*/
static BOOL WriteCoProcessorIoctl(DWORD dwIoControlCode,
LPVOID lpInBuf, DWORD nInBufSize,
LPVOID lpOutBuf, DWORD nOutBufSize,
LPDWORD lpBytesReturned)
{
// CoProc Write Input Buffer Ptr
PXSCBwrWrteRegIn pXSCBwrWrteRegInBuf;
// Set the default return value
BOOL retval = FALSE;
//Check the size of the input & Output buffers (no output buffer for write)
//
if ((lpInBuf == NULL) || (nInBufSize < (sizeof(XSCBwrWrteRegIn)) ) )
{
SetLastError(ERROR_INVALID_PARAMETER);
return(retval);
}
//Now assign the input buffer
pXSCBwrWrteRegInBuf = (PXSCBwrWrteRegIn)lpInBuf;
// execute the 'write'
//
XSCBwrExecuteCoProcCode((pXSCBwrWrteRegInBuf->OpCode),
(&pXSCBwrWrteRegInBuf->Reg1),
(&pXSCBwrWrteRegInBuf->Reg2));
// Set the Bytes Returned size
*lpBytesReturned = 0;
// Set the return value
retval = TRUE;
return(retval);
}
/*-------------------------------------------------------------------------
* Function: SetTaskIoctl
*-------------------------------------------------------------------------
* Description: Set the thread context for context registers and trace
*-------------------------------------------------------------------------
* Pre/Side/Post: prototype matches OEMIoControl
*-------------------------------------------------------------------------
*/
static BOOL SetTaskIoctl(DWORD dwIoControlCode,
LPVOID lpInBuf, DWORD nInBufSize,
LPVOID lpOutBuf, DWORD nOutBufSize,
LPDWORD lpBytesReturned)
{
// Set Task Input Buffer Ptr
PXSCBwrSetTaskIn pXSCBwrSetTaskInBuf;
// Set the default return value
BOOL retval = FALSE;
//Check the size of the input buffer
if ((lpInBuf == NULL) || (sizeof(XSCBwrSetTaskIn) > nInBufSize))
{
SetLastError(ERROR_INVALID_PARAMETER);
return(retval);
}
if ( (lpBytesReturned == NULL) )
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return(retval);
}
pXSCBwrSetTaskInBuf = (PXSCBwrSetTaskIn)lpInBuf;
if ( pXSCBwrSetTaskInBuf->ThreadID )
{
XSCBwrThreadID = pXSCBwrSetTaskInBuf->ThreadID;
XSCBwrProcessID = pXSCBwrSetTaskInBuf->ProcessID;
}
else
{
// thread set to 0: Browser is detaching from thread
//
XSCBwrThreadID = XSCBwrProcessID = (DWORD)INVALID_HANDLE_VALUE;
}
// Set the Bytes Returned size
*lpBytesReturned = 0;
// Set the return value
retval = TRUE;
return(retval);
}
/*-------------------------------------------------------------------------
* Function: QueryContextRegistersIoctl
*-------------------------------------------------------------------------
* Description: Query the context saved coprocessor registers
*-------------------------------------------------------------------------
* Pre/Side/Post: prototype matches OEMIoControl
*-------------------------------------------------------------------------
*/
static BOOL QueryContextRegistersIoctl(DWORD dwIoControlCode,
LPVOID lpInBuf, DWORD nInBufSize,
LPVOID lpOutBuf, DWORD nOutBufSize,
LPDWORD lpBytesReturned)
{
// Context Query Output Buffer Ptr
PXSCBwrQryCxtRegsOut pXSCBwrQryCxtRegsOutBuf;
// Set the default return value
BOOL retval = FALSE;
//Check the size of the input & Output buffers (No input buffer for Query)
if ((lpOutBuf == NULL) || (nOutBufSize < (sizeof(XSCBwrQryCxtRegsOut)) ) )
{
SetLastError(ERROR_INVALID_PARAMETER);
return(retval);
}
//Now assign the Output pointer to a buffer pointer
pXSCBwrQryCxtRegsOutBuf = (PXSCBwrQryCxtRegsOut)lpOutBuf;
// BSP-SPECIFIC---------------------START-------------------------------------
pXSCBwrQryCxtRegsOutBuf->Count = 22;
memcpy(pXSCBwrQryCxtRegsOutBuf->IdTable,
XSCBwrQryCxtRegsIdTable, sizeof(XSCBwrQryCxtRegsIdTable));
// BSP-SPECIFIC----------------------END--------------------------------------
*lpBytesReturned = sizeof(pXSCBwrQryCxtRegsOutBuf);
// Set the return value
retval = TRUE;
return(retval);
}
/*-------------------------------------------------------------------------
* Function: ReadContextRegisterIoctl
*-------------------------------------------------------------------------
* Description: Read one coprocessor register from saved context
*-------------------------------------------------------------------------
* Pre/Side/Post: prototype matches OEMIoControl
*-------------------------------------------------------------------------
*/
static BOOL ReadContextRegisterIoctl(DWORD dwIoControlCode,
LPVOID lpInBuf, DWORD nInBufSize,
LPVOID lpOutBuf, DWORD nOutBufSize,
LPDWORD lpBytesReturned)
{
// Context Read Reg Input Buffer Ptr
PXSCBwrRdCxtRegIn pXSCBwrRdCxtRegInBuf;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -