1 /*************************************************************************/ /*!
3 @Title Server bridge for breakpoint
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Implements the server side of the bridge for breakpoint
6 @License Dual MIT/GPLv2
8 The contents of this file are subject to the MIT license as set out below.
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
32 This License is also included in this distribution in the file called
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /**************************************************************************/
45 #include <asm/uaccess.h>
49 #include "rgxbreakpoint.h"
52 #include "common_breakpoint_bridge.h"
55 #include "pvr_debug.h"
56 #include "connection_server.h"
57 #include "pvr_bridge.h"
58 #include "rgx_bridge.h"
62 #include <linux/slab.h>
66 #if !defined(EXCLUDE_BREAKPOINT_BRIDGE)
70 /* ***************************************************************************
71 * Server-side bridge entry points
75 PVRSRVBridgeRGXSetBreakpoint(IMG_UINT32 ui32DispatchTableEntry,
76 PVRSRV_BRIDGE_IN_RGXSETBREAKPOINT *psRGXSetBreakpointIN,
77 PVRSRV_BRIDGE_OUT_RGXSETBREAKPOINT *psRGXSetBreakpointOUT,
78 CONNECTION_DATA *psConnection)
80 IMG_HANDLE hPrivData = psRGXSetBreakpointIN->hPrivData;
81 IMG_HANDLE hPrivDataInt = NULL;
89 /* Lock over handle lookup. */
97 /* Look up the address from the handle */
98 psRGXSetBreakpointOUT->eError =
99 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
100 (void **) &hPrivDataInt,
102 PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA,
104 if(psRGXSetBreakpointOUT->eError != PVRSRV_OK)
107 goto RGXSetBreakpoint_exit;
110 /* Release now we have looked up handles. */
113 psRGXSetBreakpointOUT->eError =
114 PVRSRVRGXSetBreakpointKM(psConnection, OSGetDevData(psConnection),
116 psRGXSetBreakpointIN->eFWDataMaster,
117 psRGXSetBreakpointIN->ui32BreakpointAddr,
118 psRGXSetBreakpointIN->ui32HandlerAddr,
119 psRGXSetBreakpointIN->ui32DM);
124 RGXSetBreakpoint_exit:
126 /* Lock over handle lookup cleanup. */
135 /* Unreference the previously looked up handle */
138 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
140 PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA);
143 /* Release now we have cleaned up look up handles. */
152 PVRSRVBridgeRGXClearBreakpoint(IMG_UINT32 ui32DispatchTableEntry,
153 PVRSRV_BRIDGE_IN_RGXCLEARBREAKPOINT *psRGXClearBreakpointIN,
154 PVRSRV_BRIDGE_OUT_RGXCLEARBREAKPOINT *psRGXClearBreakpointOUT,
155 CONNECTION_DATA *psConnection)
157 IMG_HANDLE hPrivData = psRGXClearBreakpointIN->hPrivData;
158 IMG_HANDLE hPrivDataInt = NULL;
166 /* Lock over handle lookup. */
174 /* Look up the address from the handle */
175 psRGXClearBreakpointOUT->eError =
176 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
177 (void **) &hPrivDataInt,
179 PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA,
181 if(psRGXClearBreakpointOUT->eError != PVRSRV_OK)
184 goto RGXClearBreakpoint_exit;
187 /* Release now we have looked up handles. */
190 psRGXClearBreakpointOUT->eError =
191 PVRSRVRGXClearBreakpointKM(psConnection, OSGetDevData(psConnection),
197 RGXClearBreakpoint_exit:
199 /* Lock over handle lookup cleanup. */
208 /* Unreference the previously looked up handle */
211 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
213 PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA);
216 /* Release now we have cleaned up look up handles. */
225 PVRSRVBridgeRGXEnableBreakpoint(IMG_UINT32 ui32DispatchTableEntry,
226 PVRSRV_BRIDGE_IN_RGXENABLEBREAKPOINT *psRGXEnableBreakpointIN,
227 PVRSRV_BRIDGE_OUT_RGXENABLEBREAKPOINT *psRGXEnableBreakpointOUT,
228 CONNECTION_DATA *psConnection)
230 IMG_HANDLE hPrivData = psRGXEnableBreakpointIN->hPrivData;
231 IMG_HANDLE hPrivDataInt = NULL;
239 /* Lock over handle lookup. */
247 /* Look up the address from the handle */
248 psRGXEnableBreakpointOUT->eError =
249 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
250 (void **) &hPrivDataInt,
252 PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA,
254 if(psRGXEnableBreakpointOUT->eError != PVRSRV_OK)
257 goto RGXEnableBreakpoint_exit;
260 /* Release now we have looked up handles. */
263 psRGXEnableBreakpointOUT->eError =
264 PVRSRVRGXEnableBreakpointKM(psConnection, OSGetDevData(psConnection),
270 RGXEnableBreakpoint_exit:
272 /* Lock over handle lookup cleanup. */
281 /* Unreference the previously looked up handle */
284 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
286 PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA);
289 /* Release now we have cleaned up look up handles. */
298 PVRSRVBridgeRGXDisableBreakpoint(IMG_UINT32 ui32DispatchTableEntry,
299 PVRSRV_BRIDGE_IN_RGXDISABLEBREAKPOINT *psRGXDisableBreakpointIN,
300 PVRSRV_BRIDGE_OUT_RGXDISABLEBREAKPOINT *psRGXDisableBreakpointOUT,
301 CONNECTION_DATA *psConnection)
303 IMG_HANDLE hPrivData = psRGXDisableBreakpointIN->hPrivData;
304 IMG_HANDLE hPrivDataInt = NULL;
312 /* Lock over handle lookup. */
320 /* Look up the address from the handle */
321 psRGXDisableBreakpointOUT->eError =
322 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
323 (void **) &hPrivDataInt,
325 PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA,
327 if(psRGXDisableBreakpointOUT->eError != PVRSRV_OK)
330 goto RGXDisableBreakpoint_exit;
333 /* Release now we have looked up handles. */
336 psRGXDisableBreakpointOUT->eError =
337 PVRSRVRGXDisableBreakpointKM(psConnection, OSGetDevData(psConnection),
343 RGXDisableBreakpoint_exit:
345 /* Lock over handle lookup cleanup. */
354 /* Unreference the previously looked up handle */
357 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
359 PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA);
362 /* Release now we have cleaned up look up handles. */
371 PVRSRVBridgeRGXOverallocateBPRegisters(IMG_UINT32 ui32DispatchTableEntry,
372 PVRSRV_BRIDGE_IN_RGXOVERALLOCATEBPREGISTERS *psRGXOverallocateBPRegistersIN,
373 PVRSRV_BRIDGE_OUT_RGXOVERALLOCATEBPREGISTERS *psRGXOverallocateBPRegistersOUT,
374 CONNECTION_DATA *psConnection)
384 psRGXOverallocateBPRegistersOUT->eError =
385 PVRSRVRGXOverallocateBPRegistersKM(psConnection, OSGetDevData(psConnection),
386 psRGXOverallocateBPRegistersIN->ui32TempRegs,
387 psRGXOverallocateBPRegistersIN->ui32SharedRegs);
402 /* ***************************************************************************
403 * Server bridge dispatch related glue
406 static IMG_BOOL bUseLock = IMG_TRUE;
407 #endif /* EXCLUDE_BREAKPOINT_BRIDGE */
409 #if !defined(EXCLUDE_BREAKPOINT_BRIDGE)
410 PVRSRV_ERROR InitBREAKPOINTBridge(void);
411 PVRSRV_ERROR DeinitBREAKPOINTBridge(void);
414 * Register all BREAKPOINT functions with services
416 PVRSRV_ERROR InitBREAKPOINTBridge(void)
419 SetDispatchTableEntry(PVRSRV_BRIDGE_BREAKPOINT, PVRSRV_BRIDGE_BREAKPOINT_RGXSETBREAKPOINT, PVRSRVBridgeRGXSetBreakpoint,
422 SetDispatchTableEntry(PVRSRV_BRIDGE_BREAKPOINT, PVRSRV_BRIDGE_BREAKPOINT_RGXCLEARBREAKPOINT, PVRSRVBridgeRGXClearBreakpoint,
425 SetDispatchTableEntry(PVRSRV_BRIDGE_BREAKPOINT, PVRSRV_BRIDGE_BREAKPOINT_RGXENABLEBREAKPOINT, PVRSRVBridgeRGXEnableBreakpoint,
428 SetDispatchTableEntry(PVRSRV_BRIDGE_BREAKPOINT, PVRSRV_BRIDGE_BREAKPOINT_RGXDISABLEBREAKPOINT, PVRSRVBridgeRGXDisableBreakpoint,
431 SetDispatchTableEntry(PVRSRV_BRIDGE_BREAKPOINT, PVRSRV_BRIDGE_BREAKPOINT_RGXOVERALLOCATEBPREGISTERS, PVRSRVBridgeRGXOverallocateBPRegisters,
439 * Unregister all breakpoint functions with services
441 PVRSRV_ERROR DeinitBREAKPOINTBridge(void)
445 #else /* EXCLUDE_BREAKPOINT_BRIDGE */
446 /* This bridge is conditional on EXCLUDE_BREAKPOINT_BRIDGE - when defined,
447 * do not populate the dispatch table with its functions
449 #define InitBREAKPOINTBridge() \
452 #define DeinitBREAKPOINTBridge() \
455 #endif /* EXCLUDE_BREAKPOINT_BRIDGE */