blob: cd6b6a400a31666623cac293ba18434fa4530bbc [file] [log] [blame]
/*************************************************************************/ /*!
@File
@Title RGX Breakpoint routines
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description RGX Breakpoint routines
@License MIT
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.
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.
*/ /**************************************************************************/
#include "rgxbreakpoint.h"
#include "pvr_debug.h"
#include "rgxutils.h"
#include "rgxfwutils.h"
#include "rgxmem.h"
#include "device.h"
#include "sync_internal.h"
#include "pdump_km.h"
#include "pvrsrv.h"
PVRSRV_ERROR PVRSRVRGXSetBreakpointKM(CONNECTION_DATA * psConnection,
PVRSRV_DEVICE_NODE * psDeviceNode,
IMG_HANDLE hMemCtxPrivData,
RGXFWIF_DM eFWDataMaster,
IMG_UINT32 ui32BPAddr,
IMG_UINT32 ui32HandlerAddr,
IMG_UINT32 ui32DataMaster)
{
PVRSRV_RGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice;
DEVMEM_MEMDESC *psFWMemContextMemDesc = RGXGetFWMemDescFromMemoryContextHandle(hMemCtxPrivData);
PVRSRV_ERROR eError = PVRSRV_OK;
RGXFWIF_KCCB_CMD sBPCmd;
PVR_UNREFERENCED_PARAMETER(psConnection);
#if !defined(PVRSRV_USE_BRIDGE_LOCK)
OSLockAcquire(psDevInfo->hBPLock);
#endif
if (psDevInfo->bBPSet == IMG_TRUE)
{
eError = PVRSRV_ERROR_BP_ALREADY_SET;
goto unlock;
}
sBPCmd.eCmdType = RGXFWIF_KCCB_CMD_BP;
sBPCmd.uCmdData.sBPData.ui32BPAddr = ui32BPAddr;
sBPCmd.uCmdData.sBPData.ui32HandlerAddr = ui32HandlerAddr;
sBPCmd.uCmdData.sBPData.ui32BPDM = ui32DataMaster;
sBPCmd.uCmdData.sBPData.bEnable = IMG_TRUE;
sBPCmd.uCmdData.sBPData.ui32Flags = RGXFWIF_BPDATA_FLAGS_WRITE;
RGXSetFirmwareAddress(&sBPCmd.uCmdData.sBPData.psFWMemContext,
psFWMemContextMemDesc,
0 ,
RFW_FWADDR_NOREF_FLAG);
eError = RGXScheduleCommand(psDevInfo,
eFWDataMaster,
&sBPCmd,
sizeof(sBPCmd),
0,
PDUMP_FLAGS_CONTINUOUS);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXSetBreakpointKM: RGXScheduleCommand failed. Error:%u", eError));
goto unlock;
}
/* Wait for FW to complete */
eError = RGXWaitForFWOp(psDevInfo, eFWDataMaster, psDeviceNode->psSyncPrim, PDUMP_FLAGS_CONTINUOUS);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"PVRSRVRGXSetBreakpointKM: Wait for completion aborted with error (%u)", eError));
goto unlock;
}
psDevInfo->eBPDM = eFWDataMaster;
psDevInfo->bBPSet = IMG_TRUE;
unlock:
#if !defined(PVRSRV_USE_BRIDGE_LOCK)
OSLockRelease(psDevInfo->hBPLock);
#endif
return eError;
}
PVRSRV_ERROR PVRSRVRGXClearBreakpointKM(CONNECTION_DATA * psConnection,
PVRSRV_DEVICE_NODE * psDeviceNode,
IMG_HANDLE hMemCtxPrivData)
{
PVRSRV_RGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice;
DEVMEM_MEMDESC *psFWMemContextMemDesc = RGXGetFWMemDescFromMemoryContextHandle(hMemCtxPrivData);
PVRSRV_ERROR eError = PVRSRV_OK;
RGXFWIF_KCCB_CMD sBPCmd;
PVR_UNREFERENCED_PARAMETER(psConnection);
sBPCmd.eCmdType = RGXFWIF_KCCB_CMD_BP;
sBPCmd.uCmdData.sBPData.ui32BPAddr = 0;
sBPCmd.uCmdData.sBPData.ui32HandlerAddr = 0;
sBPCmd.uCmdData.sBPData.bEnable = IMG_FALSE;
sBPCmd.uCmdData.sBPData.ui32Flags = RGXFWIF_BPDATA_FLAGS_WRITE | RGXFWIF_BPDATA_FLAGS_CTL;
#if !defined(PVRSRV_USE_BRIDGE_LOCK)
OSLockAcquire(psDevInfo->hBPLock);
#endif
RGXSetFirmwareAddress(&sBPCmd.uCmdData.sBPData.psFWMemContext,
psFWMemContextMemDesc,
0 ,
RFW_FWADDR_NOREF_FLAG);
eError = RGXScheduleCommand(psDevInfo,
psDevInfo->eBPDM,
&sBPCmd,
sizeof(sBPCmd),
0,
PDUMP_FLAGS_CONTINUOUS);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXClearBreakpointKM: RGXScheduleCommand failed. Error:%u", eError));
goto unlock;
}
/* Wait for FW to complete */
eError = RGXWaitForFWOp(psDevInfo, psDevInfo->eBPDM, psDeviceNode->psSyncPrim, PDUMP_FLAGS_CONTINUOUS);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"PVRSRVRGXClearBreakpointKM: Wait for completion aborted with error (%u)", eError));
goto unlock;
}
psDevInfo->bBPSet = IMG_FALSE;
unlock:
#if !defined(PVRSRV_USE_BRIDGE_LOCK)
OSLockRelease(psDevInfo->hBPLock);
#endif
return eError;
}
PVRSRV_ERROR PVRSRVRGXEnableBreakpointKM(CONNECTION_DATA * psConnection,
PVRSRV_DEVICE_NODE * psDeviceNode,
IMG_HANDLE hMemCtxPrivData)
{
PVRSRV_RGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice;
DEVMEM_MEMDESC *psFWMemContextMemDesc = RGXGetFWMemDescFromMemoryContextHandle(hMemCtxPrivData);
PVRSRV_ERROR eError = PVRSRV_OK;
RGXFWIF_KCCB_CMD sBPCmd;
PVR_UNREFERENCED_PARAMETER(psConnection);
#if !defined(PVRSRV_USE_BRIDGE_LOCK)
OSLockAcquire(psDevInfo->hBPLock);
#endif
if (psDevInfo->bBPSet == IMG_FALSE)
{
eError = PVRSRV_ERROR_BP_NOT_SET;
goto unlock;
}
sBPCmd.eCmdType = RGXFWIF_KCCB_CMD_BP;
sBPCmd.uCmdData.sBPData.bEnable = IMG_TRUE;
sBPCmd.uCmdData.sBPData.ui32Flags = RGXFWIF_BPDATA_FLAGS_CTL;
RGXSetFirmwareAddress(&sBPCmd.uCmdData.sBPData.psFWMemContext,
psFWMemContextMemDesc,
0 ,
RFW_FWADDR_NOREF_FLAG);
eError = RGXScheduleCommand(psDevInfo,
psDevInfo->eBPDM,
&sBPCmd,
sizeof(sBPCmd),
0,
PDUMP_FLAGS_CONTINUOUS);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXEnableBreakpointKM: RGXScheduleCommand failed. Error:%u", eError));
goto unlock;
}
/* Wait for FW to complete */
eError = RGXWaitForFWOp(psDevInfo, psDevInfo->eBPDM, psDeviceNode->psSyncPrim, PDUMP_FLAGS_CONTINUOUS);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"PVRSRVRGXEnableBreakpointKM: Wait for completion aborted with error (%u)", eError));
goto unlock;
}
unlock:
#if !defined(PVRSRV_USE_BRIDGE_LOCK)
OSLockRelease(psDevInfo->hBPLock);
#endif
return eError;
}
PVRSRV_ERROR PVRSRVRGXDisableBreakpointKM(CONNECTION_DATA * psConnection,
PVRSRV_DEVICE_NODE * psDeviceNode,
IMG_HANDLE hMemCtxPrivData)
{
PVRSRV_RGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice;
DEVMEM_MEMDESC *psFWMemContextMemDesc = RGXGetFWMemDescFromMemoryContextHandle(hMemCtxPrivData);
PVRSRV_ERROR eError = PVRSRV_OK;
RGXFWIF_KCCB_CMD sBPCmd;
PVR_UNREFERENCED_PARAMETER(psConnection);
#if !defined(PVRSRV_USE_BRIDGE_LOCK)
OSLockAcquire(psDevInfo->hBPLock);
#endif
if (psDevInfo->bBPSet == IMG_FALSE)
{
eError = PVRSRV_ERROR_BP_NOT_SET;
goto unlock;
}
sBPCmd.eCmdType = RGXFWIF_KCCB_CMD_BP;
sBPCmd.uCmdData.sBPData.bEnable = IMG_FALSE;
sBPCmd.uCmdData.sBPData.ui32Flags = RGXFWIF_BPDATA_FLAGS_CTL;
RGXSetFirmwareAddress(&sBPCmd.uCmdData.sBPData.psFWMemContext,
psFWMemContextMemDesc,
0 ,
RFW_FWADDR_NOREF_FLAG);
eError = RGXScheduleCommand(psDevInfo,
psDevInfo->eBPDM,
&sBPCmd,
sizeof(sBPCmd),
0,
PDUMP_FLAGS_CONTINUOUS);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXDisableBreakpointKM: RGXScheduleCommand failed. Error:%u", eError));
goto unlock;
}
/* Wait for FW to complete */
eError = RGXWaitForFWOp(psDevInfo, psDevInfo->eBPDM, psDeviceNode->psSyncPrim, PDUMP_FLAGS_CONTINUOUS);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"PVRSRVRGXDisableBreakpointKM: Wait for completion aborted with error (%u)", eError));
goto unlock;
}
unlock:
#if !defined(PVRSRV_USE_BRIDGE_LOCK)
OSLockRelease(psDevInfo->hBPLock);
#endif
return eError;
}
PVRSRV_ERROR PVRSRVRGXOverallocateBPRegistersKM(CONNECTION_DATA * psConnection,
PVRSRV_DEVICE_NODE * psDeviceNode,
IMG_UINT32 ui32TempRegs,
IMG_UINT32 ui32SharedRegs)
{
#if !defined(PVRSRV_USE_BRIDGE_LOCK)
PVRSRV_RGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice;
#endif
PVRSRV_ERROR eError = PVRSRV_OK;
RGXFWIF_KCCB_CMD sBPCmd;
PVR_UNREFERENCED_PARAMETER(psConnection);
sBPCmd.eCmdType = RGXFWIF_KCCB_CMD_BP;
sBPCmd.uCmdData.sBPData.ui32Flags = RGXFWIF_BPDATA_FLAGS_REGS;
sBPCmd.uCmdData.sBPData.ui32TempRegs = ui32TempRegs;
sBPCmd.uCmdData.sBPData.ui32SharedRegs = ui32SharedRegs;
#if !defined(PVRSRV_USE_BRIDGE_LOCK)
OSLockAcquire(psDevInfo->hBPLock);
#endif
eError = RGXScheduleCommand(psDeviceNode->pvDevice,
RGXFWIF_DM_GP,
&sBPCmd,
sizeof(sBPCmd),
0,
PDUMP_FLAGS_CONTINUOUS);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXOverallocateBPRegistersKM: RGXScheduleCommand failed. Error:%u", eError));
goto unlock;
}
/* Wait for FW to complete */
eError = RGXWaitForFWOp(psDeviceNode->pvDevice, RGXFWIF_DM_GP, psDeviceNode->psSyncPrim, PDUMP_FLAGS_CONTINUOUS);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"PVRSRVRGXOverallocateBPRegistersKM: Wait for completion aborted with error (%u)", eError));
goto unlock;
}
unlock:
#if !defined(PVRSRV_USE_BRIDGE_LOCK)
OSLockRelease(psDevInfo->hBPLock);
#endif
return eError;
}
/******************************************************************************
End of file (rgxbreakpoint.c)
******************************************************************************/