1 /*************************************************************************/ /*!
3 @Title Server bridge for pvrtl
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Implements the server side of the bridge for pvrtl
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>
52 #include "common_pvrtl_bridge.h"
55 #include "pvr_debug.h"
56 #include "connection_server.h"
57 #include "pvr_bridge.h"
58 #include "rgx_bridge.h"
62 #if defined (SUPPORT_AUTH)
66 #include <linux/slab.h>
71 /* ***************************************************************************
72 * Server-side bridge entry points
76 PVRSRVBridgeTLConnect(IMG_UINT32 ui32DispatchTableEntry,
77 PVRSRV_BRIDGE_IN_TLCONNECT *psTLConnectIN,
78 PVRSRV_BRIDGE_OUT_TLCONNECT *psTLConnectOUT,
79 CONNECTION_DATA *psConnection)
82 PVR_UNREFERENCED_PARAMETER(psTLConnectIN);
89 psTLConnectOUT->eError =
90 TLServerConnectKM(psConnection
101 PVRSRVBridgeTLDisconnect(IMG_UINT32 ui32DispatchTableEntry,
102 PVRSRV_BRIDGE_IN_TLDISCONNECT *psTLDisconnectIN,
103 PVRSRV_BRIDGE_OUT_TLDISCONNECT *psTLDisconnectOUT,
104 CONNECTION_DATA *psConnection)
107 PVR_UNREFERENCED_PARAMETER(psTLDisconnectIN);
114 psTLDisconnectOUT->eError =
115 TLServerDisconnectKM(psConnection
126 PVRSRVBridgeTLOpenStream(IMG_UINT32 ui32DispatchTableEntry,
127 PVRSRV_BRIDGE_IN_TLOPENSTREAM *psTLOpenStreamIN,
128 PVRSRV_BRIDGE_OUT_TLOPENSTREAM *psTLOpenStreamOUT,
129 CONNECTION_DATA *psConnection)
131 IMG_CHAR *uiNameInt = IMG_NULL;
132 TL_STREAM_DESC * psSDInt = IMG_NULL;
133 DEVMEM_EXPORTCOOKIE * psClientBUFExportCookieInt = IMG_NULL;
137 psTLOpenStreamOUT->hSD = IMG_NULL;
141 uiNameInt = OSAllocMem(PRVSRVTL_MAX_STREAM_NAME_SIZE * sizeof(IMG_CHAR));
144 psTLOpenStreamOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
146 goto TLOpenStream_exit;
150 /* Copy the data over */
151 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psTLOpenStreamIN->puiName, PRVSRVTL_MAX_STREAM_NAME_SIZE * sizeof(IMG_CHAR))
152 || (OSCopyFromUser(NULL, uiNameInt, psTLOpenStreamIN->puiName,
153 PRVSRVTL_MAX_STREAM_NAME_SIZE * sizeof(IMG_CHAR)) != PVRSRV_OK) )
155 psTLOpenStreamOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
157 goto TLOpenStream_exit;
162 psTLOpenStreamOUT->eError =
163 TLServerOpenStreamKM(
165 psTLOpenStreamIN->ui32Mode,
167 &psClientBUFExportCookieInt);
168 /* Exit early if bridged call fails */
169 if(psTLOpenStreamOUT->eError != PVRSRV_OK)
171 goto TLOpenStream_exit;
175 psTLOpenStreamOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase,
176 &psTLOpenStreamOUT->hSD,
177 (IMG_VOID *) psSDInt,
178 PVRSRV_HANDLE_TYPE_PVR_TL_SD,
179 PVRSRV_HANDLE_ALLOC_FLAG_MULTI
180 ,(PFN_HANDLE_RELEASE)&TLServerCloseStreamKM);
181 if (psTLOpenStreamOUT->eError != PVRSRV_OK)
183 goto TLOpenStream_exit;
187 psTLOpenStreamOUT->eError = PVRSRVAllocSubHandle(psConnection->psHandleBase,
188 &psTLOpenStreamOUT->hClientBUFExportCookie,
189 (IMG_VOID *) psClientBUFExportCookieInt,
190 PVRSRV_HANDLE_TYPE_SERVER_EXPORTCOOKIE,
191 PVRSRV_HANDLE_ALLOC_FLAG_NONE
192 ,psTLOpenStreamOUT->hSD);
193 if (psTLOpenStreamOUT->eError != PVRSRV_OK)
195 goto TLOpenStream_exit;
202 if (psTLOpenStreamOUT->eError != PVRSRV_OK)
204 if (psTLOpenStreamOUT->hSD)
206 PVRSRV_ERROR eError = PVRSRVReleaseHandle(psConnection->psHandleBase,
207 (IMG_HANDLE) psTLOpenStreamOUT->hSD,
208 PVRSRV_HANDLE_TYPE_PVR_TL_SD);
210 /* Releasing the handle should free/destroy/release the resource. This should never fail... */
211 PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY));
213 /* Avoid freeing/destroying/releasing the resource a second time below */
220 TLServerCloseStreamKM(psSDInt);
225 OSFreeMem(uiNameInt);
231 PVRSRVBridgeTLCloseStream(IMG_UINT32 ui32DispatchTableEntry,
232 PVRSRV_BRIDGE_IN_TLCLOSESTREAM *psTLCloseStreamIN,
233 PVRSRV_BRIDGE_OUT_TLCLOSESTREAM *psTLCloseStreamOUT,
234 CONNECTION_DATA *psConnection)
245 psTLCloseStreamOUT->eError =
246 PVRSRVReleaseHandle(psConnection->psHandleBase,
247 (IMG_HANDLE) psTLCloseStreamIN->hSD,
248 PVRSRV_HANDLE_TYPE_PVR_TL_SD);
249 if ((psTLCloseStreamOUT->eError != PVRSRV_OK) && (psTLCloseStreamOUT->eError != PVRSRV_ERROR_RETRY))
252 goto TLCloseStream_exit;
263 PVRSRVBridgeTLAcquireData(IMG_UINT32 ui32DispatchTableEntry,
264 PVRSRV_BRIDGE_IN_TLACQUIREDATA *psTLAcquireDataIN,
265 PVRSRV_BRIDGE_OUT_TLACQUIREDATA *psTLAcquireDataOUT,
266 CONNECTION_DATA *psConnection)
268 TL_STREAM_DESC * psSDInt = IMG_NULL;
277 /* Look up the address from the handle */
278 psTLAcquireDataOUT->eError =
279 PVRSRVLookupHandle(psConnection->psHandleBase,
280 (IMG_VOID **) &psSDInt,
281 psTLAcquireDataIN->hSD,
282 PVRSRV_HANDLE_TYPE_PVR_TL_SD);
283 if(psTLAcquireDataOUT->eError != PVRSRV_OK)
285 goto TLAcquireData_exit;
290 psTLAcquireDataOUT->eError =
291 TLServerAcquireDataKM(
293 &psTLAcquireDataOUT->ui32ReadOffset,
294 &psTLAcquireDataOUT->ui32ReadLen);
305 PVRSRVBridgeTLReleaseData(IMG_UINT32 ui32DispatchTableEntry,
306 PVRSRV_BRIDGE_IN_TLRELEASEDATA *psTLReleaseDataIN,
307 PVRSRV_BRIDGE_OUT_TLRELEASEDATA *psTLReleaseDataOUT,
308 CONNECTION_DATA *psConnection)
310 TL_STREAM_DESC * psSDInt = IMG_NULL;
319 /* Look up the address from the handle */
320 psTLReleaseDataOUT->eError =
321 PVRSRVLookupHandle(psConnection->psHandleBase,
322 (IMG_VOID **) &psSDInt,
323 psTLReleaseDataIN->hSD,
324 PVRSRV_HANDLE_TYPE_PVR_TL_SD);
325 if(psTLReleaseDataOUT->eError != PVRSRV_OK)
327 goto TLReleaseData_exit;
332 psTLReleaseDataOUT->eError =
333 TLServerReleaseDataKM(
335 psTLReleaseDataIN->ui32ReadOffset,
336 psTLReleaseDataIN->ui32ReadLen);
348 /* ***************************************************************************
349 * Server bridge dispatch related glue
353 PVRSRV_ERROR InitPVRTLBridge(IMG_VOID);
354 PVRSRV_ERROR DeinitPVRTLBridge(IMG_VOID);
357 * Register all PVRTL functions with services
359 PVRSRV_ERROR InitPVRTLBridge(IMG_VOID)
362 SetDispatchTableEntry(PVRSRV_BRIDGE_PVRTL, PVRSRV_BRIDGE_PVRTL_TLCONNECT, PVRSRVBridgeTLConnect,
366 SetDispatchTableEntry(PVRSRV_BRIDGE_PVRTL, PVRSRV_BRIDGE_PVRTL_TLDISCONNECT, PVRSRVBridgeTLDisconnect,
370 SetDispatchTableEntry(PVRSRV_BRIDGE_PVRTL, PVRSRV_BRIDGE_PVRTL_TLOPENSTREAM, PVRSRVBridgeTLOpenStream,
374 SetDispatchTableEntry(PVRSRV_BRIDGE_PVRTL, PVRSRV_BRIDGE_PVRTL_TLCLOSESTREAM, PVRSRVBridgeTLCloseStream,
378 SetDispatchTableEntry(PVRSRV_BRIDGE_PVRTL, PVRSRV_BRIDGE_PVRTL_TLACQUIREDATA, PVRSRVBridgeTLAcquireData,
382 SetDispatchTableEntry(PVRSRV_BRIDGE_PVRTL, PVRSRV_BRIDGE_PVRTL_TLRELEASEDATA, PVRSRVBridgeTLReleaseData,
391 * Unregister all pvrtl functions with services
393 PVRSRV_ERROR DeinitPVRTLBridge(IMG_VOID)