📄 coproc.c
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
//------------------------------------------------------------------------------
//
// File: coproc.c
//
// Intel Mainstone II board coprocessor code.
// 1) saving and restoring coprocessors on context switch, and
// 2) coproc functions for xscale debug browser (xdb) trace collection
#if defined(USING_COPROCSUPPORT) || defined(USING_XSCALEBROWSER)
#define WINCEMACRO 1
#include <windows.h>
#include <oal.h>
#include <coproc.h>
#ifdef USING_XSCALEBROWSER
#include <xdbioctl.h>
#include <xdb.h>
#endif
// Prototypes for Assembly routines used for saving/restoring CoProc Registers
//
extern void Xllp_Save_WMMX_Regs(LPBYTE pArea);
extern void Xllp_Restore_WMMX_Regs(LPBYTE pArea);
// Function prototypes
//
void OALInitCoProc();
void OEMInitCoProcRegisterSavedArea(LPBYTE pArea);
void OEMSaveCoProcRegister( LPBYTE pArea );
void OEMRestoreCoProcRegister( LPBYTE pArea);
//------------------------------------------------------------------------------
//
// Function: OEMInitCoProcRegisterSavedArea
//
// This function is required to support xdb browser's trace collection mechanism.
// Init routine called during OEMInit to initialize kernel vars and function pointers.
//
void OALInitCoProc()
{
g_pOemGlobal->cbCoProcRegSize = XSCOPROCREGSAVE_SIZE;
g_pOemGlobal->fSaveCoProcReg = 1;
g_pOemGlobal->pfnInitCoProcRegs = OEMInitCoProcRegisterSavedArea;
g_pOemGlobal->pfnSaveCoProcRegs = OEMSaveCoProcRegister;
g_pOemGlobal->pfnRestoreCoProcRegs = OEMRestoreCoProcRegister;
}
//------------------------------------------------------------------------------
//
// Function: OEMInitCoProcRegisterSavedArea
//
// This function is required to support xdb browser's trace collection mechanism.
// The function sets up the memory area allocated for use in saving/restoring CoProcessor registers.
// This function is called for every thread created.
//
void OEMInitCoProcRegisterSavedArea(LPBYTE pArea)
{
// Set initial state of CoProc Reg Area (which will in turn be the Register value) here
memset( pArea, 0, XSCOPROCREGSAVE_SIZE);
}
//------------------------------------------------------------------------------
//
// Function: OEMSaveCoProcRegister
//
// This function is required to support xdb browser's trace collection mechanism.
// It is only called when both NkCoProcRegSize and fNKSaveCoProcReg are non-zero values.
// This function is called every time a thread is to be switched out, so it
// adds to the overall worst-case time of thread switches!.
//
void OEMSaveCoProcRegister( LPBYTE pArea )
{
#ifdef USING_XSCALEBROWSER
if (XSCBwrThreadID == GetCurrentThreadId()) {
XSCBwrExecutionTraceOff(0);
XSCBwrSaveThreadContextArea.ThreadId = XSCBwrThreadID;
XSCBwrSaveThreadContextArea.ContextPtr = (DWORD) pArea;
Xllp_Save_WMMX_Regs((LPBYTE)&XSCBwrSaveThreadContextArea.Context_Area[0]);
return;
}
#endif //USING_XSCALEBROWSER
Xllp_Save_WMMX_Regs(pArea);
}
//------------------------------------------------------------------------------
//
// Function: OEMRestoreCoProcRegister
//
// This function is required to support xdb browser's trace collection mechanism.
// It is only called when both cbNkCoProcRegSize and fNKSaveCoProcReg are non-zero values.
// This function is called every time a thread is to be switched in, so it
// adds to the overall worst-case time of thread switches!.
//
void OEMRestoreCoProcRegister( LPBYTE pArea)
{
#ifdef USING_XSCALEBROWSER
if (XSCBwrSaveThreadContextArea.ContextPtr == (DWORD) pArea) {
Xllp_Restore_WMMX_Regs((LPBYTE)&XSCBwrSaveThreadContextArea.Context_Area[0]);
if (XSCBwrThreadID == (DWORD) INVALID_HANDLE_VALUE)
XSCBwrSaveThreadContextArea.ContextPtr = 0;
else
XSCBwrExecutionTraceOn(0);
return;
}
#endif //USING_XSCALEBROWSER
Xllp_Restore_WMMX_Regs(pArea);
}
#endif //defined(USING_COPROCSUPPORT) || defined(USING_XSCALEBROWSER)
//------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -