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>
68 /* ***************************************************************************
69 * Bridge proxy functions
73 SyncPrimServerSecureUnexportResManProxy(IMG_HANDLE hResmanItem)
77 eError = ResManFreeResByPtr(hResmanItem);
79 /* Freeing a resource should never fail... */
80 PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY));
87 /* ***************************************************************************
88 * Server-side bridge entry points
92 PVRSRVBridgeSyncPrimServerSecureExport(IMG_UINT32 ui32BridgeID,
93 PVRSRV_BRIDGE_IN_SYNCPRIMSERVERSECUREEXPORT *psSyncPrimServerSecureExportIN,
94 PVRSRV_BRIDGE_OUT_SYNCPRIMSERVERSECUREEXPORT *psSyncPrimServerSecureExportOUT,
95 CONNECTION_DATA *psConnection)
97 SERVER_SYNC_PRIMITIVE * psSyncHandleInt = IMG_NULL;
98 IMG_HANDLE hSyncHandleInt2 = IMG_NULL;
99 SERVER_SYNC_EXPORT * psExportInt = IMG_NULL;
100 IMG_HANDLE hExportInt2 = IMG_NULL;
101 CONNECTION_DATA *psSecureConnection;
103 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SYNCSEXPORT_SYNCPRIMSERVERSECUREEXPORT);
110 /* Look up the address from the handle */
111 psSyncPrimServerSecureExportOUT->eError =
112 PVRSRVLookupHandle(psConnection->psHandleBase,
113 (IMG_HANDLE *) &hSyncHandleInt2,
114 psSyncPrimServerSecureExportIN->hSyncHandle,
115 PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE);
116 if(psSyncPrimServerSecureExportOUT->eError != PVRSRV_OK)
118 goto SyncPrimServerSecureExport_exit;
121 /* Look up the data from the resman address */
122 psSyncPrimServerSecureExportOUT->eError = ResManFindPrivateDataByPtr(hSyncHandleInt2, (IMG_VOID **) &psSyncHandleInt);
124 if(psSyncPrimServerSecureExportOUT->eError != PVRSRV_OK)
126 goto SyncPrimServerSecureExport_exit;
130 psSyncPrimServerSecureExportOUT->eError =
131 PVRSRVSyncPrimServerSecureExportKM(psConnection,
133 &psSyncPrimServerSecureExportOUT->Export,
134 &psExportInt, &psSecureConnection);
135 /* Exit early if bridged call fails */
136 if(psSyncPrimServerSecureExportOUT->eError != PVRSRV_OK)
138 goto SyncPrimServerSecureExport_exit;
141 /* Create a resman item and overwrite the handle with it */
142 hExportInt2 = ResManRegisterRes(psSecureConnection->hResManContext,
143 RESMAN_TYPE_SERVER_SYNC_EXPORT,
145 (RESMAN_FREE_FN)&PVRSRVSyncPrimServerSecureUnexportKM);
146 if (hExportInt2 == IMG_NULL)
148 psSyncPrimServerSecureExportOUT->eError = PVRSRV_ERROR_UNABLE_TO_REGISTER_RESOURCE;
149 goto SyncPrimServerSecureExport_exit;
153 SyncPrimServerSecureExport_exit:
154 if (psSyncPrimServerSecureExportOUT->eError != PVRSRV_OK)
156 /* If we have a valid resman item we should undo the bridge function by freeing the resman item */
159 PVRSRV_ERROR eError = ResManFreeResByPtr(hExportInt2);
161 /* Freeing a resource should never fail... */
162 PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY));
164 else if (psExportInt)
166 PVRSRVSyncPrimServerSecureUnexportKM(psExportInt);
175 PVRSRVBridgeSyncPrimServerSecureUnexport(IMG_UINT32 ui32BridgeID,
176 PVRSRV_BRIDGE_IN_SYNCPRIMSERVERSECUREUNEXPORT *psSyncPrimServerSecureUnexportIN,
177 PVRSRV_BRIDGE_OUT_SYNCPRIMSERVERSECUREUNEXPORT *psSyncPrimServerSecureUnexportOUT,
178 CONNECTION_DATA *psConnection)
180 IMG_HANDLE hExportInt2 = IMG_NULL;
182 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SYNCSEXPORT_SYNCPRIMSERVERSECUREUNEXPORT);
189 /* Look up the address from the handle */
190 psSyncPrimServerSecureUnexportOUT->eError =
191 PVRSRVLookupHandle(psConnection->psHandleBase,
192 (IMG_HANDLE *) &hExportInt2,
193 psSyncPrimServerSecureUnexportIN->hExport,
194 PVRSRV_HANDLE_TYPE_SERVER_SYNC_EXPORT);
195 if(psSyncPrimServerSecureUnexportOUT->eError != PVRSRV_OK)
197 goto SyncPrimServerSecureUnexport_exit;
202 psSyncPrimServerSecureUnexportOUT->eError = SyncPrimServerSecureUnexportResManProxy(hExportInt2);
203 /* Exit early if bridged call fails */
204 if(psSyncPrimServerSecureUnexportOUT->eError != PVRSRV_OK)
206 goto SyncPrimServerSecureUnexport_exit;
209 psSyncPrimServerSecureUnexportOUT->eError =
210 PVRSRVReleaseHandle(psConnection->psHandleBase,
211 (IMG_HANDLE) psSyncPrimServerSecureUnexportIN->hExport,
212 PVRSRV_HANDLE_TYPE_SERVER_SYNC_EXPORT);
215 SyncPrimServerSecureUnexport_exit:
221 PVRSRVBridgeSyncPrimServerSecureImport(IMG_UINT32 ui32BridgeID,
222 PVRSRV_BRIDGE_IN_SYNCPRIMSERVERSECUREIMPORT *psSyncPrimServerSecureImportIN,
223 PVRSRV_BRIDGE_OUT_SYNCPRIMSERVERSECUREIMPORT *psSyncPrimServerSecureImportOUT,
224 CONNECTION_DATA *psConnection)
226 SERVER_SYNC_PRIMITIVE * psSyncHandleInt = IMG_NULL;
227 IMG_HANDLE hSyncHandleInt2 = IMG_NULL;
229 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SYNCSEXPORT_SYNCPRIMSERVERSECUREIMPORT);
235 psSyncPrimServerSecureImportOUT->eError =
236 PVRSRVSyncPrimServerSecureImportKM(
237 psSyncPrimServerSecureImportIN->Export,
239 &psSyncPrimServerSecureImportOUT->ui32SyncPrimVAddr);
240 /* Exit early if bridged call fails */
241 if(psSyncPrimServerSecureImportOUT->eError != PVRSRV_OK)
243 goto SyncPrimServerSecureImport_exit;
246 /* Create a resman item and overwrite the handle with it */
247 hSyncHandleInt2 = ResManRegisterRes(psConnection->hResManContext,
248 RESMAN_TYPE_SERVER_SYNC_PRIMITIVE,
250 (RESMAN_FREE_FN)&PVRSRVServerSyncFreeKM);
251 if (hSyncHandleInt2 == IMG_NULL)
253 psSyncPrimServerSecureImportOUT->eError = PVRSRV_ERROR_UNABLE_TO_REGISTER_RESOURCE;
254 goto SyncPrimServerSecureImport_exit;
256 psSyncPrimServerSecureImportOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase,
257 &psSyncPrimServerSecureImportOUT->hSyncHandle,
258 (IMG_HANDLE) hSyncHandleInt2,
259 PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE,
260 PVRSRV_HANDLE_ALLOC_FLAG_NONE
262 if (psSyncPrimServerSecureImportOUT->eError != PVRSRV_OK)
264 goto SyncPrimServerSecureImport_exit;
268 SyncPrimServerSecureImport_exit:
269 if (psSyncPrimServerSecureImportOUT->eError != PVRSRV_OK)
271 /* If we have a valid resman item we should undo the bridge function by freeing the resman item */
274 PVRSRV_ERROR eError = ResManFreeResByPtr(hSyncHandleInt2);
276 /* Freeing a resource should never fail... */
277 PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY));
279 else if (psSyncHandleInt)
281 PVRSRVServerSyncFreeKM(psSyncHandleInt);
291 /* ***************************************************************************
292 * Server bridge dispatch related glue
295 PVRSRV_ERROR RegisterSYNCSEXPORTFunctions(IMG_VOID);
296 IMG_VOID UnregisterSYNCSEXPORTFunctions(IMG_VOID);
299 * Register all SYNCSEXPORT functions with services
301 PVRSRV_ERROR RegisterSYNCSEXPORTFunctions(IMG_VOID)
303 SetDispatchTableEntry(PVRSRV_BRIDGE_SYNCSEXPORT_SYNCPRIMSERVERSECUREEXPORT, PVRSRVBridgeSyncPrimServerSecureExport);
304 SetDispatchTableEntry(PVRSRV_BRIDGE_SYNCSEXPORT_SYNCPRIMSERVERSECUREUNEXPORT, PVRSRVBridgeSyncPrimServerSecureUnexport);
305 SetDispatchTableEntry(PVRSRV_BRIDGE_SYNCSEXPORT_SYNCPRIMSERVERSECUREIMPORT, PVRSRVBridgeSyncPrimServerSecureImport);
311 * Unregister all syncsexport functions with services
313 IMG_VOID UnregisterSYNCSEXPORTFunctions(IMG_VOID)