📄 pvr_pdump.c
字号:
/*******************************************************************************
<module>
* Name : pvr_pdump.c
* Title : PVR Debug Functionality
* Author : Dave Roberts
* Created : 17 / 11 / 03
*
* Copyright : 2003 by Imagination Technologies Limited.
* All rights reserved. No part of this software, either
* material or conceptual may be copied or distributed,
* transmitted, transcribed, stored in a retrieval system
* or translated into any human or computer language in any
* form by any means, electronic, mechanical, manual or
* other-wise, or disclosed to third parties without the
* express written permission of Imagination Technologies
* Limited, Unit 8, HomePark Industrial Estate,
* King's Langley, Hertfordshire, WD4 8LZ, U.K.
*
* Description : Implements WinCE pdump
*
* Platform : WinCE
*
* $Log: pvr_pdump.c $
</module>
********************************************************************************/
#if defined(PDUMP) && !defined(PVR_KERNEL)
#include "img_types.h"
#include "services_headers.h"
#include "pvr_bridge.h"
#include <stdio.h>
/***********************************************************************************
Function Name : PDumpInit
Inputs : ppsPDContext
Outputs : -
Returns : PDUMP_CONTEXT_HANDLE
Description : Initialise pdump resources
************************************************************************************/
IMG_BOOL PDumpInit(PDUMP_CONTEXT **ppsPDContext, IMG_HANDLE hServices)
{
PVRSRV_BRIDGE_IN_PDUMP_COMMAND sPDCom;
sPDCom.ePDumpCommandType = PDUMP_TYPE_INIT;
sPDCom.sPDumpData.sInit.bInitialise = IMG_TRUE;
sPDCom.hServicesHandleUM = hServices;
if(PVRSRVPDumpCommand(&sPDCom) != PVRSRV_OK)
{
return IMG_FALSE;
}
*ppsPDContext = sPDCom.psPDumpContext;
return IMG_TRUE;
}
/***********************************************************************************
Function Name : PDumpClose
Inputs : psPDContext
Outputs : -
Returns : Success
Description : release pdump resources
************************************************************************************/
IMG_BOOL PDumpClose(PDUMP_CONTEXT *psPDContext)
{
PVRSRV_BRIDGE_IN_PDUMP_COMMAND sPDCom;
sPDCom.ePDumpCommandType = PDUMP_TYPE_INIT;
sPDCom.sPDumpData.sInit.bInitialise = IMG_FALSE;
sPDCom.psPDumpContext = psPDContext;
if(PVRSRVPDumpCommand(&sPDCom) != PVRSRV_OK)
{
return IMG_FALSE;
}
return IMG_TRUE;
}
/*****************************************************************************
FUNCTION : PDumpDisable
PURPOSE : Enables Dumping on the context passed in. Enables global
PDumping if psPDContext == NULL
PARAMETERS : psPDContext
RETURNS :
*****************************************************************************/
IMG_VOID PDumpEnable()
{
PVRSRV_BRIDGE_IN_PDUMP_COMMAND sPDCom;
sPDCom.ePDumpCommandType = PDUMP_TYPE_ENABLE;
PVRSRVPDumpCommand(&sPDCom);
}
/*****************************************************************************
FUNCTION : PDumpDisable
PURPOSE : Disables Dumping on the context passed in. Disables global
PDumping if psPDContext == NULL
PARAMETERS : psPDContext
RETURNS :
*****************************************************************************/
IMG_VOID PDumpDisable()
{
PVRSRV_BRIDGE_IN_PDUMP_COMMAND sPDCom;
sPDCom.ePDumpCommandType = PDUMP_TYPE_DISABLE;
PVRSRVPDumpCommand(&sPDCom);
}
/*****************************************************************************
FUNCTION : PDumpDisable2D
PURPOSE : Disables 2D PDumping on the context passed in and the global context
PARAMETERS : psPDContext
RETURNS :
*****************************************************************************/
IMG_VOID PDumpDisable2D()
{
PVRSRV_BRIDGE_IN_PDUMP_COMMAND sPDCom;
sPDCom.ePDumpCommandType = PDUMP_TYPE_DISABLE_2D;
PVRSRVPDumpCommand(&sPDCom);
}
/*****************************************************************************
FUNCTION : PDumpEnableLocalScript
PURPOSE : Enables Dumping on the context passed in. Enables global
PDumping if psPDContext == NULL
PARAMETERS : psPDContext
RETURNS :
*****************************************************************************/
IMG_VOID PDumpEnableLocalScript(PDUMP_CONTEXT *psPDContext)
{
PVRSRV_BRIDGE_IN_PDUMP_COMMAND sPDCom;
sPDCom.ePDumpCommandType = PDUMP_TYPE_ENABLE_LOCAL_SCRIPT;
sPDCom.psPDumpContext = psPDContext;
PVRSRVPDumpCommand(&sPDCom);
}
/*****************************************************************************
FUNCTION : PDumpPoll
PURPOSE :
PARAMETERS :
RETURNS :
*****************************************************************************/
IMG_BOOL PDumpPoll(PDUMP_CONTEXT *psPDContext,
IMG_UINT32 ui32RegTag,
IMG_UINT32 ui32Addr,
IMG_UINT32 ui32Mask,
IMG_UINT32 ui32Value,
IMG_UINT32 ui32A,
IMG_UINT32 ui32B,
IMG_UINT32 ui32C)
{
PVRSRV_BRIDGE_IN_PDUMP_COMMAND sPDCom;
sPDCom.ePDumpCommandType = PDUMP_TYPE_WRITE_POLL;
sPDCom.psPDumpContext = psPDContext;
sPDCom.sPDumpData.sWritePoll.ui32PDumpRegType = ui32RegTag;
sPDCom.sPDumpData.sWritePoll.ui32Addr = ui32Addr;
sPDCom.sPDumpData.sWritePoll.ui32Mask = ui32Mask;
sPDCom.sPDumpData.sWritePoll.ui32Value = ui32Value;
sPDCom.sPDumpData.sWritePoll.ui32A = ui32A;
sPDCom.sPDumpData.sWritePoll.ui32B = ui32B;
sPDCom.sPDumpData.sWritePoll.ui32C = ui32C;
if(PVRSRVPDumpCommand(&sPDCom) != PVRSRV_OK)
{
return IMG_FALSE;
}
return IMG_TRUE;
}
/*****************************************************************************
FUNCTION : PDumpRegArray
PURPOSE :
PARAMETERS :
RETURNS : None
*****************************************************************************/
IMG_BOOL PDumpRegArray(PDUMP_CONTEXT *psPDContext,
IMG_UINT32 ui32RegTag,
PVRSRV_HWREG *psRegs,
IMG_UINT32 ui32RegCount)
{
PVRSRV_BRIDGE_IN_PDUMP_COMMAND sPDCom;
PVRSRV_HWREG *psTmpRegs;
IMG_UINT32 i;
sPDCom.ePDumpCommandType = PDUMP_TYPE_WRITE_REG;
sPDCom.psPDumpContext = psPDContext;
sPDCom.sPDumpData.sWriteReg.ui32PDumpRegType = ui32RegTag;
sPDCom.sPDumpData.sWriteReg.ui32RegCount = ui32RegCount;
psTmpRegs = sPDCom.sPDumpData.sWriteReg.psRegs;
/*
Copy Regs to local structure
*/
for(i=0; i < ui32RegCount; i++)
{
*psTmpRegs++ = *psRegs++;
}
if(PVRSRVPDumpCommand(&sPDCom) != PVRSRV_OK)
{
return IMG_FALSE;
}
return IMG_TRUE;
}
/***********************************************************************************
Function Name : PDumpSlavePort
Inputs : psPDContext, ui32Data
Outputs : -
Returns : Success
Description : Write 32 bits to the primitive file
************************************************************************************/
IMG_BOOL PDumpSlavePort(PDUMP_CONTEXT *psPDContext,
IMG_UINT32 ui32SPTag,
IMG_UINT32 ui32Data)
{
PVRSRV_BRIDGE_IN_PDUMP_COMMAND sPDCom;
sPDCom.ePDumpCommandType = PDUMP_TYPE_WRITE_SP;
sPDCom.psPDumpContext = psPDContext;
*sPDCom.sPDumpData.sWriteSP.pui32Data = ui32Data;
sPDCom.sPDumpData.sWriteSP.ui32PDumpSPType = ui32SPTag;
sPDCom.sPDumpData.sWriteSP.ui32DataCount = 1;
if(PVRSRVPDumpCommand(&sPDCom) != PVRSRV_OK)
{
return IMG_FALSE;
}
return IMG_TRUE;
}
/***********************************************************************************
Function Name : PDumpSlavePortRepeat
Inputs : psPDContext, ui32Data
Outputs : -
Returns : Success
Description : Write 32 bits to the primitive file
************************************************************************************/
IMG_BOOL PDumpSPBatch(PDUMP_CONTEXT *psPDContext,
IMG_UINT32 ui32SPTag,
IMG_UINT32 *pui32Addr,
IMG_UINT32 ui32Count)
{
PVRSRV_BRIDGE_IN_PDUMP_COMMAND sPDCom;
IMG_UINT32 ui32DataToWrite;
IMG_UINT32 i;
IMG_UINT32 *pui32Data;
sPDCom.ePDumpCommandType = PDUMP_TYPE_WRITE_SP;
sPDCom.psPDumpContext = psPDContext;
sPDCom.sPDumpData.sWriteSP.ui32PDumpSPType = ui32SPTag;
pui32Data = sPDCom.sPDumpData.sWriteSP.pui32Data;
/*
Break the data up into packets if it is too large
*/
while(ui32Count)
{
if(ui32Count > PDUMP_MAX_BRIDGED_DATA_COUNT)
{
ui32DataToWrite = PDUMP_MAX_BRIDGED_DATA_COUNT;
}
else
{
ui32DataToWrite = ui32Count;
}
/*
Copy data to local structure
*/
for(i=0; i<ui32DataToWrite; i++)
{
*pui32Data++ = *pui32Addr++;
}
sPDCom.sPDumpData.sWriteSP.ui32DataCount = ui32DataToWrite;
if(PVRSRVPDumpCommand(&sPDCom) != PVRSRV_OK)
{
return IMG_FALSE;
}
ui32Count -= ui32DataToWrite;
}
return IMG_TRUE;
}
/***********************************************************************************
Function Name : PDumpString
Inputs : psPDContext, pszString
Outputs : -
Returns : Success
Description : Writes a string to the script file
************************************************************************************/
IMG_BOOL PDumpString(PDUMP_CONTEXT *psPDContext, IMG_CHAR *pszString)
{
PVRSRV_BRIDGE_IN_PDUMP_COMMAND sPDCom;
sPDCom.ePDumpCommandType = PDUMP_TYPE_DUMP_STRING;
sPDCom.psPDumpContext = psPDContext;
sPDCom.sPDumpData.sWriteString.ui32StrLen = strlen(pszString);
/*
Copy string to local struct
*/
strcpy(sPDCom.sPDumpData.sWriteString.pszString, pszString);
if(PVRSRVPDumpCommand(&sPDCom) != PVRSRV_OK)
{
return IMG_FALSE;
}
return IMG_TRUE;
}
/***********************************************************************************
Function Name : PDumpUpdateFrame
Inputs : psPDContext
Outputs : -
Returns : none
Description : increments the frame count
************************************************************************************/
IMG_VOID PDumpUpdateFrame(PDUMP_CONTEXT *psPDContext)
{
PVRSRV_BRIDGE_IN_PDUMP_COMMAND sPDCom;
sPDCom.ePDumpCommandType = PDUMP_TYPE_UPDATE_FRAME;
sPDCom.psPDumpContext = psPDContext;
PVRSRVPDumpCommand(&sPDCom);
}
/*****************************************************************************
FUNCTION : PDumpReg
PURPOSE :
PARAMETERS :
RETURNS :
*****************************************************************************/
IMG_BOOL PDumpReg(PDUMP_CONTEXT *psPDContext,
IMG_UINT32 ui32RegTag,
IMG_UINT32 ui32Addr,
IMG_UINT32 ui32Value)
{
PVRSRV_HWREG sReg;
sReg.ui32RegAddr = ui32Addr;
sReg.ui32RegVal = ui32Value;
return PDumpRegArray(psPDContext, ui32RegTag, &sReg, 1);
}
/***********************************************************************************
Function Name : PDumpTex
Inputs : psPDContext, psMemInfo
Outputs : -
Returns : Success
Description : Writes a texture to the tex file and a load command to the
script file.
************************************************************************************/
IMG_BOOL PDumpTex(PDUMP_CONTEXT *psPDContext,
PVRSRV_MEM_INFO *psMemInfo)
{
PVRSRV_BRIDGE_IN_PDUMP_COMMAND sPDCom;
sPDCom.ePDumpCommandType = PDUMP_TYPE_DUMP_TEX;
sPDCom.psPDumpContext = psPDContext;
sPDCom.sPDumpData.sDumpTex.psMemInfo = psMemInfo;
if(PVRSRVPDumpCommand(&sPDCom) != PVRSRV_OK)
{
return IMG_FALSE;
}
return IMG_TRUE;
}
/***********************************************************************************
Function Name : PDumpRegisterTex
Inputs : psPDContext, psMemInfo
Outputs : -
Returns : Success
Description : Registers a texture with the context
************************************************************************************/
IMG_BOOL PDumpRegisterTex(PDUMP_CONTEXT *psPDContext,
PVRSRV_MEM_INFO *psMemInfo)
{
PVRSRV_BRIDGE_IN_PDUMP_COMMAND sPDCom;
sPDCom.ePDumpCommandType = PDUMP_TYPE_REGISTER_TEX;
sPDCom.psPDumpContext = psPDContext;
sPDCom.sPDumpData.sDumpTex.psMemInfo = psMemInfo;
if(PVRSRVPDumpCommand(&sPDCom) != PVRSRV_OK)
{
return IMG_FALSE;
}
return IMG_TRUE;
}
/***********************************************************************************
Function Name : PDumpFlushTexList
Inputs : psPDContext, psMemInfo
Outputs : -
Returns : Success
Description : Dumps all registered textures to file
************************************************************************************/
IMG_BOOL PDumpFlushTexList(PDUMP_CONTEXT *psPDContext)
{
PVRSRV_BRIDGE_IN_PDUMP_COMMAND sPDCom;
sPDCom.ePDumpCommandType = PDUMP_TYPE_FLUSH_TEX_LIST;
sPDCom.psPDumpContext = psPDContext;
if(PVRSRVPDumpCommand(&sPDCom) != PVRSRV_OK)
{
return IMG_FALSE;
}
return IMG_TRUE;
}
/*****************************************************************************
FUNCTION : PDumpFormattedStringV
PURPOSE : Special version of PDumpFormattedString that takes an argument vector
(pointer to array of args) rather than the usual variable
number of arguments
PARAMETERS : ptszFormat - A standard printf-style format string
pvArgs - Pointer to the arguments
RETURNS :
*****************************************************************************/
IMG_BOOL PDumpFormatStringV(PDUMP_CONTEXT *psPDContext, IMG_CHAR *pszFormat, IMG_PVOID pvArgs)
{
IMG_CHAR pszScript[128];
IMG_CHAR pszTmp[256];
sprintf(pszTmp, "%s%s", pszFormat, "\r\n");
vsprintf(pszScript, pszTmp, (IMG_CHAR *)pvArgs);
return PDumpString(psPDContext, pszScript);
}
#endif /* PDUMP */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -