diff options
Diffstat (limited to 'sgx/services4/srvkm/env/linux/pdump.c')
-rw-r--r-- | sgx/services4/srvkm/env/linux/pdump.c | 279 |
1 files changed, 228 insertions, 51 deletions
diff --git a/sgx/services4/srvkm/env/linux/pdump.c b/sgx/services4/srvkm/env/linux/pdump.c index 13d9b0d..192640f 100644 --- a/sgx/services4/srvkm/env/linux/pdump.c +++ b/sgx/services4/srvkm/env/linux/pdump.c @@ -1,28 +1,44 @@ -/********************************************************************** - * - * Copyright (C) Imagination Technologies Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful but, except - * as otherwise stated in writing, without any warranty; without even the - * implied warranty of merchantability or fitness for a particular purpose. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Contact Information: - * Imagination Technologies Ltd. <gpl-support@imgtec.com> - * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - * - ******************************************************************************/ +/*************************************************************************/ /*! +@Title Parameter dump macro target routines +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved +@License Dual MIT/GPLv2 + +The contents of this file are subject to the MIT license as set out below. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 ("GPL") in which case the provisions +of GPL are applicable instead of those above. + +If you wish to allow use of your version of this file only under the terms of +GPL, and not to allow others to use your version of this file under the terms +of the MIT license, indicate your decision by deleting the provisions above +and replace them with the notice and other provisions required by GPL as set +out in the file called "GPL-COPYING" included in this distribution. If you do +not delete the provisions above, a recipient may use your version of this file +under the terms of either the MIT license or GPL. + +This License is also included in this distribution in the file called +"MIT-COPYING". + +EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS +PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ /**************************************************************************/ #if defined (SUPPORT_SGX) || defined (SUPPORT_VGX) #if defined (PDUMP) @@ -30,7 +46,7 @@ #include <asm/atomic.h> #include <stdarg.h> #if defined (SUPPORT_SGX) -#include "sgxdefs.h" +#include "sgxdefs.h" /* Is this still needed? */ #endif #include "services_headers.h" @@ -39,14 +55,14 @@ #include "dbgdrvif.h" #if defined (SUPPORT_SGX) -#include "sgxmmu.h" +#include "sgxmmu.h"/* Is this still needed? */ #endif #include "mm.h" #include "pdump_km.h" #include "pdump_int.h" -#include <linux/kernel.h> -#include <linux/string.h> +#include <linux/kernel.h> // sprintf +#include <linux/string.h> // strncpy, strlen static IMG_BOOL PDumpWriteString2 (IMG_CHAR * pszString, IMG_UINT32 ui32Flags); static IMG_BOOL PDumpWriteILock (PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32Count, IMG_UINT32 ui32Flags); @@ -56,6 +72,9 @@ static IMG_VOID DbgSetMarker (PDBG_STREAM psStream, IMG_UINT32 ui32Marker); #define PDUMP_DATAMASTER_PIXEL (1) #define PDUMP_DATAMASTER_EDM (3) +/* + Maximum file size to split output files +*/ #define MAX_FILE_SIZE 0x40000000 static atomic_t gsPDumpSuspended = ATOMIC_INIT(0); @@ -87,13 +106,14 @@ static PDBG_PDUMP_STATE gsDBGPdumpState = {{IMG_NULL}, 0, IMG_NULL, IMG_NULL, IM -IMG_VOID DBGDrvGetServiceTable(IMG_VOID **fn_table); - static inline IMG_BOOL PDumpSuspended(IMG_VOID) { return (atomic_read(&gsPDumpSuspended) != 0) ? IMG_TRUE : IMG_FALSE; } +/*! + * \name PDumpOSGetScriptString + */ PVRSRV_ERROR PDumpOSGetScriptString(IMG_HANDLE *phScript, IMG_UINT32 *pui32MaxLen) { @@ -106,6 +126,9 @@ PVRSRV_ERROR PDumpOSGetScriptString(IMG_HANDLE *phScript, return PVRSRV_OK; } +/*! + * \name PDumpOSGetMessageString + */ PVRSRV_ERROR PDumpOSGetMessageString(IMG_CHAR **ppszMsg, IMG_UINT32 *pui32MaxLen) { @@ -118,6 +141,9 @@ PVRSRV_ERROR PDumpOSGetMessageString(IMG_CHAR **ppszMsg, return PVRSRV_OK; } +/*! + * \name PDumpOSGetFilenameString + */ PVRSRV_ERROR PDumpOSGetFilenameString(IMG_CHAR **ppszFile, IMG_UINT32 *pui32MaxLen) { @@ -130,11 +156,17 @@ PVRSRV_ERROR PDumpOSGetFilenameString(IMG_CHAR **ppszFile, return PVRSRV_OK; } +/*! + * \name PDumpOSWriteString2 + */ IMG_BOOL PDumpOSWriteString2(IMG_HANDLE hScript, IMG_UINT32 ui32Flags) { return PDumpWriteString2(hScript, ui32Flags); } +/*! + * \name PDumpOSBufprintf + */ PVRSRV_ERROR PDumpOSBufprintf(IMG_HANDLE hBuf, IMG_UINT32 ui32ScriptSizeMax, IMG_CHAR* pszFormat, ...) { IMG_CHAR* pszBuf = hBuf; @@ -147,7 +179,7 @@ PVRSRV_ERROR PDumpOSBufprintf(IMG_HANDLE hBuf, IMG_UINT32 ui32ScriptSizeMax, IMG va_end(vaArgs); - if (n>=(IMG_INT32)ui32ScriptSizeMax || n==-1) + if (n>=(IMG_INT32)ui32ScriptSizeMax || n==-1) /* glibc >= 2.1 or glibc 2.0 */ { PVR_DPF((PVR_DBG_ERROR, "Buffer overflow detected, pdump output may be incomplete.")); @@ -160,13 +192,16 @@ PVRSRV_ERROR PDumpOSBufprintf(IMG_HANDLE hBuf, IMG_UINT32 ui32ScriptSizeMax, IMG return PVRSRV_OK; } +/*! + * \name PDumpOSVSprintf + */ PVRSRV_ERROR PDumpOSVSprintf(IMG_CHAR *pszComment, IMG_UINT32 ui32ScriptSizeMax, IMG_CHAR* pszFormat, PDUMP_va_list vaArgs) { IMG_INT32 n; n = vsnprintf(pszComment, ui32ScriptSizeMax, pszFormat, vaArgs); - if (n>=(IMG_INT32)ui32ScriptSizeMax || n==-1) + if (n>=(IMG_INT32)ui32ScriptSizeMax || n==-1) /* glibc >= 2.1 or glibc 2.0 */ { PVR_DPF((PVR_DBG_ERROR, "Buffer overflow detected, pdump output may be incomplete.")); @@ -176,13 +211,19 @@ PVRSRV_ERROR PDumpOSVSprintf(IMG_CHAR *pszComment, IMG_UINT32 ui32ScriptSizeMax, return PVRSRV_OK; } +/*! + * \name PDumpOSDebugPrintf + */ IMG_VOID PDumpOSDebugPrintf(IMG_CHAR* pszFormat, ...) { PVR_UNREFERENCED_PARAMETER(pszFormat); - + /* FIXME: Implement using services PVR_DBG or otherwise with kprintf */ } +/*! + * \name PDumpOSSprintf + */ PVRSRV_ERROR PDumpOSSprintf(IMG_CHAR *pszComment, IMG_UINT32 ui32ScriptSizeMax, IMG_CHAR *pszFormat, ...) { IMG_INT32 n; @@ -194,7 +235,7 @@ PVRSRV_ERROR PDumpOSSprintf(IMG_CHAR *pszComment, IMG_UINT32 ui32ScriptSizeMax, va_end(vaArgs); - if (n>=(IMG_INT32)ui32ScriptSizeMax || n==-1) + if (n>=(IMG_INT32)ui32ScriptSizeMax || n==-1) /* glibc >= 2.1 or glibc 2.0 */ { PVR_DPF((PVR_DBG_ERROR, "Buffer overflow detected, pdump output may be incomplete.")); @@ -204,6 +245,9 @@ PVRSRV_ERROR PDumpOSSprintf(IMG_CHAR *pszComment, IMG_UINT32 ui32ScriptSizeMax, return PVRSRV_OK; } +/*! + * \name PDumpOSBuflen + */ IMG_UINT32 PDumpOSBuflen(IMG_HANDLE hBuffer, IMG_UINT32 ui32BufferSizeMax) { IMG_CHAR* pszBuf = hBuffer; @@ -216,15 +260,18 @@ IMG_UINT32 PDumpOSBuflen(IMG_HANDLE hBuffer, IMG_UINT32 ui32BufferSizeMax) return(ui32Count); } +/*! + * \name PDumpOSVerifyLineEnding + */ IMG_VOID PDumpOSVerifyLineEnding(IMG_HANDLE hBuffer, IMG_UINT32 ui32BufferSizeMax) { IMG_UINT32 ui32Count; IMG_CHAR* pszBuf = hBuffer; - + /* strlen */ ui32Count = PDumpOSBuflen(hBuffer, ui32BufferSizeMax); - + /* Put \r \n sequence at the end if it isn't already there */ if ((ui32Count >= 1) && (pszBuf[ui32Count-1] != '\n') && (ui32Count<ui32BufferSizeMax)) { pszBuf[ui32Count] = '\n'; @@ -240,22 +287,34 @@ IMG_VOID PDumpOSVerifyLineEnding(IMG_HANDLE hBuffer, IMG_UINT32 ui32BufferSizeMa } } +/*! + * \name PDumpOSGetStream + */ IMG_HANDLE PDumpOSGetStream(IMG_UINT32 ePDumpStream) { return (IMG_HANDLE)gsDBGPdumpState.psStream[ePDumpStream]; } +/*! + * \name PDumpOSGetStreamOffset + */ IMG_UINT32 PDumpOSGetStreamOffset(IMG_UINT32 ePDumpStream) { PDBG_STREAM psStream = gsDBGPdumpState.psStream[ePDumpStream]; return gpfnDbgDrv->pfnGetStreamOffset(psStream); } +/*! + * \name PDumpOSGetParamFileNum + */ IMG_UINT32 PDumpOSGetParamFileNum(IMG_VOID) { return gsDBGPdumpState.ui32ParamFileNum; } +/*! + * \name PDumpOSWriteString + */ IMG_BOOL PDumpOSWriteString(IMG_HANDLE hStream, IMG_UINT8 *psui8Data, IMG_UINT32 ui32Size, @@ -268,14 +327,21 @@ IMG_BOOL PDumpOSWriteString(IMG_HANDLE hStream, ui32Flags); } +/*! + * \name PDumpOSCheckForSplitting + */ IMG_VOID PDumpOSCheckForSplitting(IMG_HANDLE hStream, IMG_UINT32 ui32Size, IMG_UINT32 ui32Flags) { - + /* File size limit not implemented for this OS. + */ PVR_UNREFERENCED_PARAMETER(hStream); PVR_UNREFERENCED_PARAMETER(ui32Size); PVR_UNREFERENCED_PARAMETER(ui32Flags); } +/*! + * \name PDumpOSJTInitialised + */ IMG_BOOL PDumpOSJTInitialised(IMG_VOID) { if(gpfnDbgDrv) @@ -285,11 +351,17 @@ IMG_BOOL PDumpOSJTInitialised(IMG_VOID) return IMG_FALSE; } +/*! + * \name PDumpOSIsSuspended + */ inline IMG_BOOL PDumpOSIsSuspended(IMG_VOID) { return (atomic_read(&gsPDumpSuspended) != 0) ? IMG_TRUE : IMG_FALSE; } +/*! + * \name PDumpOSCPUVAddrToDevPAddr + */ IMG_VOID PDumpOSCPUVAddrToDevPAddr(PVRSRV_DEVICE_TYPE eDeviceType, IMG_HANDLE hOSMemHandle, IMG_UINT32 ui32Offset, @@ -300,19 +372,23 @@ IMG_VOID PDumpOSCPUVAddrToDevPAddr(PVRSRV_DEVICE_TYPE eDeviceType, IMG_CPU_PHYADDR sCpuPAddr; PVR_UNREFERENCED_PARAMETER(pui8LinAddr); - PVR_UNREFERENCED_PARAMETER(ui32PageSize); + PVR_UNREFERENCED_PARAMETER(ui32PageSize); /* for when no assert */ - + /* Caller must now alway supply hOSMemHandle, even though we only (presently) + use it here in the linux implementation */ PVR_ASSERT (hOSMemHandle != IMG_NULL); sCpuPAddr = OSMemHandleToCpuPAddr(hOSMemHandle, ui32Offset); PVR_ASSERT((sCpuPAddr.uiAddr & (ui32PageSize - 1)) == 0); - + /* convert CPU physical addr to device physical */ *psDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); } +/*! + * \name PDumpOSCPUVAddrToPhysPages + */ IMG_VOID PDumpOSCPUVAddrToPhysPages(IMG_HANDLE hOSMemHandle, IMG_UINT32 ui32Offset, IMG_PUINT8 pui8LinAddr, @@ -321,7 +397,9 @@ IMG_VOID PDumpOSCPUVAddrToPhysPages(IMG_HANDLE hOSMemHandle, { if(hOSMemHandle) { - + /* + * If a Services memory handle is provided then use it. + */ IMG_CPU_PHYADDR sCpuPAddr; PVR_UNREFERENCED_PARAMETER(pui8LinAddr); @@ -338,6 +416,9 @@ IMG_VOID PDumpOSCPUVAddrToPhysPages(IMG_HANDLE hOSMemHandle, } } +/*! + * \name PDumpOSDebugDriverWrite + */ IMG_UINT32 PDumpOSDebugDriverWrite( PDBG_STREAM psStream, PDUMP_DDWMODE eDbgDrvWriteMode, IMG_UINT8 *pui8Data, @@ -365,29 +446,43 @@ IMG_UINT32 PDumpOSDebugDriverWrite( PDBG_STREAM psStream, return 0xFFFFFFFFU; } +/*! + * \name PDumpOSReleaseExecution + */ IMG_VOID PDumpOSReleaseExecution(IMG_VOID) { OSReleaseThreadQuanta(); } +/************************************************************************** + * Function Name : PDumpInit + * Outputs : None + * Returns : + * Description : Reset connection to vldbgdrv + * Then try to connect to PDUMP streams +**************************************************************************/ IMG_VOID PDumpInit(IMG_VOID) { IMG_UINT32 i; DBGKM_CONNECT_NOTIFIER sConnectNotifier; - + /* If we tried this earlier, then we might have connected to the driver + * But if pdump.exe was running then the stream connected would fail + */ if (!gpfnDbgDrv) { - DBGDrvGetServiceTable((IMG_VOID **)&gpfnDbgDrv); + DBGDrvGetServiceTable(&gpfnDbgDrv); - + // If something failed then no point in trying to connect streams if (gpfnDbgDrv == IMG_NULL) { return; } - + /* + * Pass the connection notify callback + */ sConnectNotifier.pfnConnectNotifier = &PDumpConnectionNotify; gpfnDbgDrv->pfnSetConnectNotifier(sConnectNotifier); @@ -457,7 +552,9 @@ init_failed: gsDBGPdumpState.pszMsg = IMG_NULL; } - + /* + * Remove the connection notify callback + */ sConnectNotifier.pfnConnectNotifier = 0; gpfnDbgDrv->pfnSetConnectNotifier(sConnectNotifier); @@ -493,13 +590,22 @@ IMG_VOID PDumpDeInit(IMG_VOID) gsDBGPdumpState.pszMsg = IMG_NULL; } - + /* + * Remove the connection notify callback + */ sConnectNotifier.pfnConnectNotifier = 0; gpfnDbgDrv->pfnSetConnectNotifier(sConnectNotifier); gpfnDbgDrv = IMG_NULL; } +/************************************************************************** + * Function Name : PDumpStartInitPhaseKM + * Inputs : None + * Outputs : None + * Returns : None + * Description : Resume init phase state +**************************************************************************/ PVRSRV_ERROR PDumpStartInitPhaseKM(IMG_VOID) { IMG_UINT32 i; @@ -515,6 +621,13 @@ PVRSRV_ERROR PDumpStartInitPhaseKM(IMG_VOID) return PVRSRV_OK; } +/************************************************************************** + * Function Name : PDumpStopInitPhaseKM + * Inputs : None + * Outputs : None + * Returns : None + * Description : End init phase state +**************************************************************************/ PVRSRV_ERROR PDumpStopInitPhaseKM(IMG_VOID) { IMG_UINT32 i; @@ -531,12 +644,26 @@ PVRSRV_ERROR PDumpStopInitPhaseKM(IMG_VOID) return PVRSRV_OK; } +/************************************************************************** + * Function Name : PDumpIsLastCaptureFrameKM + * Inputs : None + * Outputs : None + * Returns : True or false + * Description : Tests whether the current frame is being pdumped +**************************************************************************/ IMG_BOOL PDumpIsLastCaptureFrameKM(IMG_VOID) { return gpfnDbgDrv->pfnIsLastCaptureFrame(gsDBGPdumpState.psStream[PDUMP_STREAM_SCRIPT2]); } +/************************************************************************** + * Function Name : PDumpIsCaptureFrameKM + * Inputs : None + * Outputs : None + * Returns : True or false + * Description : Tests whether the current frame is being pdumped +**************************************************************************/ IMG_BOOL PDumpOSIsCaptureFrameKM(IMG_VOID) { if (PDumpSuspended()) @@ -546,6 +673,13 @@ IMG_BOOL PDumpOSIsCaptureFrameKM(IMG_VOID) return gpfnDbgDrv->pfnIsCaptureFrame(gsDBGPdumpState.psStream[PDUMP_STREAM_SCRIPT2], IMG_FALSE); } +/************************************************************************** + * Function Name : PDumpSetFrameKM + * Inputs : None + * Outputs : None + * Returns : None + * Description : Sets a frame +**************************************************************************/ PVRSRV_ERROR PDumpOSSetFrameKM(IMG_UINT32 ui32Frame) { IMG_UINT32 ui32Stream; @@ -562,12 +696,30 @@ PVRSRV_ERROR PDumpOSSetFrameKM(IMG_UINT32 ui32Frame) } +/***************************************************************************** + FUNCTION : PDumpWriteString2 + + PURPOSE : + + PARAMETERS : + + RETURNS : +*****************************************************************************/ static IMG_BOOL PDumpWriteString2(IMG_CHAR * pszString, IMG_UINT32 ui32Flags) { return PDumpWriteILock(gsDBGPdumpState.psStream[PDUMP_STREAM_SCRIPT2], (IMG_UINT8 *) pszString, strlen(pszString), ui32Flags); } +/***************************************************************************** + FUNCTION : PDumpWriteILock + + PURPOSE : Writes, making sure it all goes... + + PARAMETERS : + + RETURNS : +*****************************************************************************/ static IMG_BOOL PDumpWriteILock(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32Count, IMG_UINT32 ui32Flags) { IMG_UINT32 ui32Written = 0; @@ -578,7 +730,9 @@ static IMG_BOOL PDumpWriteILock(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_U } - + /* + Set the stream marker to split output files + */ if (psStream == gsDBGPdumpState.psStream[PDUMP_STREAM_PARAM2]) { @@ -604,11 +758,31 @@ static IMG_BOOL PDumpWriteILock(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_U return IMG_TRUE; } +/***************************************************************************** + FUNCTION : DbgSetFrame + + PURPOSE : Sets the frame in the stream + + PARAMETERS : psStream - Stream pointer + ui32Frame - Frame number to set + + RETURNS : None +*****************************************************************************/ static IMG_VOID DbgSetFrame(PDBG_STREAM psStream, IMG_UINT32 ui32Frame) { gpfnDbgDrv->pfnSetFrame(psStream, ui32Frame); } +/***************************************************************************** + FUNCTION : DbgSetMarker + + PURPOSE : Sets the marker of the stream to split output files + + PARAMETERS : psStream - Stream pointer + ui32Marker - Marker number to set + + RETURNS : None +*****************************************************************************/ static IMG_VOID DbgSetMarker(PDBG_STREAM psStream, IMG_UINT32 ui32Marker) { gpfnDbgDrv->pfnSetMarker(psStream, ui32Marker); @@ -624,5 +798,8 @@ IMG_VOID PDumpResumeKM(IMG_VOID) atomic_dec(&gsPDumpSuspended); } -#endif -#endif +#endif /* #if defined (PDUMP) */ +#endif /* #if defined (SUPPORT_SGX) */ +/***************************************************************************** + End of file (PDUMP.C) +*****************************************************************************/ |