1 /*************************************************************************/ /*!
3 @Title Server bridge for syncsexport
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Implements the server side of the bridge for syncsexport
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 "sync_server.h"
52 #include "common_syncsexport_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 PVRSRVBridgeSyncPrimServerSecureExport(IMG_UINT32 ui32DispatchTableEntry,
77 PVRSRV_BRIDGE_IN_SYNCPRIMSERVERSECUREEXPORT *psSyncPrimServerSecureExportIN,
78 PVRSRV_BRIDGE_OUT_SYNCPRIMSERVERSECUREEXPORT *psSyncPrimServerSecureExportOUT,
79 CONNECTION_DATA *psConnection)
81 SERVER_SYNC_PRIMITIVE * psSyncHandleInt = IMG_NULL;
82 SERVER_SYNC_EXPORT * psExportInt = IMG_NULL;
83 IMG_HANDLE hExportInt = IMG_NULL;
84 CONNECTION_DATA *psSecureConnection;
93 /* Look up the address from the handle */
94 psSyncPrimServerSecureExportOUT->eError =
95 PVRSRVLookupHandle(psConnection->psHandleBase,
96 (IMG_VOID **) &psSyncHandleInt,
97 psSyncPrimServerSecureExportIN->hSyncHandle,
98 PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE);
99 if(psSyncPrimServerSecureExportOUT->eError != PVRSRV_OK)
101 goto SyncPrimServerSecureExport_exit;
106 psSyncPrimServerSecureExportOUT->eError =
107 PVRSRVSyncPrimServerSecureExportKM(psConnection,
109 &psSyncPrimServerSecureExportOUT->Export,
110 &psExportInt, &psSecureConnection);
111 /* Exit early if bridged call fails */
112 if(psSyncPrimServerSecureExportOUT->eError != PVRSRV_OK)
114 goto SyncPrimServerSecureExport_exit;
118 psSyncPrimServerSecureExportOUT->eError = PVRSRVAllocHandle(psSecureConnection->psHandleBase,
120 (IMG_VOID *) psExportInt,
121 PVRSRV_HANDLE_TYPE_SERVER_SYNC_EXPORT,
122 PVRSRV_HANDLE_ALLOC_FLAG_SHARED
123 ,(PFN_HANDLE_RELEASE)&PVRSRVSyncPrimServerSecureUnexportKM);
124 if (psSyncPrimServerSecureExportOUT->eError != PVRSRV_OK)
126 goto SyncPrimServerSecureExport_exit;
132 SyncPrimServerSecureExport_exit:
133 if (psSyncPrimServerSecureExportOUT->eError != PVRSRV_OK)
137 PVRSRVSyncPrimServerSecureUnexportKM(psExportInt);
146 PVRSRVBridgeSyncPrimServerSecureUnexport(IMG_UINT32 ui32DispatchTableEntry,
147 PVRSRV_BRIDGE_IN_SYNCPRIMSERVERSECUREUNEXPORT *psSyncPrimServerSecureUnexportIN,
148 PVRSRV_BRIDGE_OUT_SYNCPRIMSERVERSECUREUNEXPORT *psSyncPrimServerSecureUnexportOUT,
149 CONNECTION_DATA *psConnection)
160 psSyncPrimServerSecureUnexportOUT->eError =
161 PVRSRVReleaseHandle(psConnection->psHandleBase,
162 (IMG_HANDLE) psSyncPrimServerSecureUnexportIN->hExport,
163 PVRSRV_HANDLE_TYPE_SERVER_SYNC_EXPORT);
164 if ((psSyncPrimServerSecureUnexportOUT->eError != PVRSRV_OK) && (psSyncPrimServerSecureUnexportOUT->eError != PVRSRV_ERROR_RETRY))
167 goto SyncPrimServerSecureUnexport_exit;
172 SyncPrimServerSecureUnexport_exit:
178 PVRSRVBridgeSyncPrimServerSecureImport(IMG_UINT32 ui32DispatchTableEntry,
179 PVRSRV_BRIDGE_IN_SYNCPRIMSERVERSECUREIMPORT *psSyncPrimServerSecureImportIN,
180 PVRSRV_BRIDGE_OUT_SYNCPRIMSERVERSECUREIMPORT *psSyncPrimServerSecureImportOUT,
181 CONNECTION_DATA *psConnection)
183 SERVER_SYNC_PRIMITIVE * psSyncHandleInt = IMG_NULL;
191 psSyncPrimServerSecureImportOUT->eError =
192 PVRSRVSyncPrimServerSecureImportKM(
193 psSyncPrimServerSecureImportIN->Export,
195 &psSyncPrimServerSecureImportOUT->ui32SyncPrimVAddr);
196 /* Exit early if bridged call fails */
197 if(psSyncPrimServerSecureImportOUT->eError != PVRSRV_OK)
199 goto SyncPrimServerSecureImport_exit;
203 psSyncPrimServerSecureImportOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase,
204 &psSyncPrimServerSecureImportOUT->hSyncHandle,
205 (IMG_VOID *) psSyncHandleInt,
206 PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE,
207 PVRSRV_HANDLE_ALLOC_FLAG_MULTI
208 ,(PFN_HANDLE_RELEASE)&PVRSRVServerSyncFreeKM);
209 if (psSyncPrimServerSecureImportOUT->eError != PVRSRV_OK)
211 goto SyncPrimServerSecureImport_exit;
217 SyncPrimServerSecureImport_exit:
218 if (psSyncPrimServerSecureImportOUT->eError != PVRSRV_OK)
222 PVRSRVServerSyncFreeKM(psSyncHandleInt);
232 /* ***************************************************************************
233 * Server bridge dispatch related glue
237 PVRSRV_ERROR InitSYNCSEXPORTBridge(IMG_VOID);
238 PVRSRV_ERROR DeinitSYNCSEXPORTBridge(IMG_VOID);
241 * Register all SYNCSEXPORT functions with services
243 PVRSRV_ERROR InitSYNCSEXPORTBridge(IMG_VOID)
246 SetDispatchTableEntry(PVRSRV_BRIDGE_SYNCSEXPORT, PVRSRV_BRIDGE_SYNCSEXPORT_SYNCPRIMSERVERSECUREEXPORT, PVRSRVBridgeSyncPrimServerSecureExport,
250 SetDispatchTableEntry(PVRSRV_BRIDGE_SYNCSEXPORT, PVRSRV_BRIDGE_SYNCSEXPORT_SYNCPRIMSERVERSECUREUNEXPORT, PVRSRVBridgeSyncPrimServerSecureUnexport,
254 SetDispatchTableEntry(PVRSRV_BRIDGE_SYNCSEXPORT, PVRSRV_BRIDGE_SYNCSEXPORT_SYNCPRIMSERVERSECUREIMPORT, PVRSRVBridgeSyncPrimServerSecureImport,
263 * Unregister all syncsexport functions with services
265 PVRSRV_ERROR DeinitSYNCSEXPORTBridge(IMG_VOID)