RK3368 GPU version Rogue M 1.28
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue_m / generated / mm_bridge / server_mm_bridge.c
1 /*************************************************************************/ /*!
2 @File
3 @Title          Server bridge for mm
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Implements the server side of the bridge for mm
6 @License        Dual MIT/GPLv2
7
8 The contents of this file are subject to the MIT license as set out below.
9
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:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
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.
23
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.
31
32 This License is also included in this distribution in the file called
33 "MIT-COPYING".
34
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 */ /**************************************************************************/
43
44 #include <stddef.h>
45 #include <asm/uaccess.h>
46
47 #include "img_defs.h"
48
49 #include "devicemem_server.h"
50 #include "pmr.h"
51 #include "devicemem_heapcfg.h"
52 #include "physmem.h"
53
54
55 #include "common_mm_bridge.h"
56
57 #include "allocmem.h"
58 #include "pvr_debug.h"
59 #include "connection_server.h"
60 #include "pvr_bridge.h"
61 #include "rgx_bridge.h"
62 #include "srvcore.h"
63 #include "handle.h"
64
65 #if defined (SUPPORT_AUTH)
66 #include "osauth.h"
67 #endif
68
69 #include <linux/slab.h>
70
71
72 static PVRSRV_ERROR ReleasePMRExport(IMG_VOID *pvData)
73 {
74         PVR_UNREFERENCED_PARAMETER(pvData);
75
76         return PVRSRV_OK;
77 }
78 static PVRSRV_ERROR ReleasePMRExportOut(IMG_VOID *pvData)
79 {
80         PVR_UNREFERENCED_PARAMETER(pvData);
81
82         return PVRSRV_OK;
83 }
84
85
86 /* ***************************************************************************
87  * Server-side bridge entry points
88  */
89  
90 static IMG_INT
91 PVRSRVBridgePMRExportPMR(IMG_UINT32 ui32DispatchTableEntry,
92                                           PVRSRV_BRIDGE_IN_PMREXPORTPMR *psPMRExportPMRIN,
93                                           PVRSRV_BRIDGE_OUT_PMREXPORTPMR *psPMRExportPMROUT,
94                                          CONNECTION_DATA *psConnection)
95 {
96         PMR * psPMRInt = IMG_NULL;
97         PMR_EXPORT * psPMRExportInt = IMG_NULL;
98         IMG_HANDLE hPMRExportInt = IMG_NULL;
99
100
101
102
103
104         PMRLock();
105
106
107                                 {
108                                         /* Look up the address from the handle */
109                                         psPMRExportPMROUT->eError =
110                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
111                                                                                         (IMG_VOID **) &psPMRInt,
112                                                                                         psPMRExportPMRIN->hPMR,
113                                                                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR);
114                                         if(psPMRExportPMROUT->eError != PVRSRV_OK)
115                                         {
116                                                 PMRUnlock();
117                                                 goto PMRExportPMR_exit;
118                                         }
119                                 }
120
121
122         psPMRExportPMROUT->eError =
123                 PMRExportPMR(
124                                         psPMRInt,
125                                         &psPMRExportInt,
126                                         &psPMRExportPMROUT->ui64Size,
127                                         &psPMRExportPMROUT->ui32Log2Contig,
128                                         &psPMRExportPMROUT->ui64Password);
129         /* Exit early if bridged call fails */
130         if(psPMRExportPMROUT->eError != PVRSRV_OK)
131         {
132                 PMRUnlock();
133                 goto PMRExportPMR_exit;
134         }
135         PMRUnlock();
136
137
138         /*
139          * For cases where we need a cross process handle we actually allocate two.
140          * 
141          * The first one is a connection specific handle and it gets given the real
142          * release function. This handle does *NOT* get returned to the caller. It's
143          * purpose is to release any leaked resources when we either have a bad or
144          * abnormally terminated client. If we didn't do this then the resource
145          * wouldn't be freed until driver unload. If the resource is freed normally,
146          * this handle can be looked up via the cross process handle and then
147          * released accordingly.
148          * 
149          * The second one is a cross process handle and it gets given a noop release
150          * function. This handle does get returned to the caller.
151          */
152         psPMRExportPMROUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase,
153                                                         &hPMRExportInt,
154                                                         (IMG_VOID *) psPMRExportInt,
155                                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT,
156                                                         PVRSRV_HANDLE_ALLOC_FLAG_SHARED
157                                                         ,(PFN_HANDLE_RELEASE)&PMRUnexportPMR);
158         if (psPMRExportPMROUT->eError != PVRSRV_OK)
159         {
160                 goto PMRExportPMR_exit;
161         }
162
163         psPMRExportPMROUT->eError = PVRSRVAllocHandle(KERNEL_HANDLE_BASE,
164                                                         &psPMRExportPMROUT->hPMRExport,
165                                                         (IMG_VOID *) psPMRExportInt,
166                                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT,
167                                                         PVRSRV_HANDLE_ALLOC_FLAG_MULTI,
168                                                         (PFN_HANDLE_RELEASE)&ReleasePMRExport);
169         if (psPMRExportPMROUT->eError != PVRSRV_OK)
170         {
171                 goto PMRExportPMR_exit;
172         }
173
174
175
176 PMRExportPMR_exit:
177         if (psPMRExportPMROUT->eError != PVRSRV_OK)
178         {
179                 if (psPMRExportPMROUT->hPMRExport)
180                 {
181                         PVRSRV_ERROR eError = PVRSRVReleaseHandle(KERNEL_HANDLE_BASE,
182                                                 (IMG_HANDLE) psPMRExportPMROUT->hPMRExport,
183                                                 PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT);
184
185                         /* Releasing the handle should free/destroy/release the resource. This should never fail... */
186                         PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY));
187
188                 }
189
190                 if (hPMRExportInt)
191                 {
192                         PVRSRV_ERROR eError = PVRSRVReleaseHandle(psConnection->psHandleBase,
193                                                 hPMRExportInt,
194                                                 PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT);
195
196                         /* Releasing the handle should free/destroy/release the resource. This should never fail... */
197                         PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY));
198
199                         /* Avoid freeing/destroying/releasing the resource a second time below */
200                         psPMRExportInt = IMG_NULL;
201                 }
202
203                 if (psPMRExportInt)
204                 {
205                         PMRUnexportPMR(psPMRExportInt);
206                 }
207         }
208
209
210         return 0;
211 }
212
213 static IMG_INT
214 PVRSRVBridgePMRUnexportPMR(IMG_UINT32 ui32DispatchTableEntry,
215                                           PVRSRV_BRIDGE_IN_PMRUNEXPORTPMR *psPMRUnexportPMRIN,
216                                           PVRSRV_BRIDGE_OUT_PMRUNEXPORTPMR *psPMRUnexportPMROUT,
217                                          CONNECTION_DATA *psConnection)
218 {
219         PMR_EXPORT * psPMRExportInt = IMG_NULL;
220         IMG_HANDLE hPMRExportInt = IMG_NULL;
221
222         PVR_UNREFERENCED_PARAMETER(psConnection);
223
224
225
226
227         PMRLock();
228
229
230
231         psPMRUnexportPMROUT->eError =
232                 PVRSRVLookupHandle(KERNEL_HANDLE_BASE,
233                                         (IMG_VOID **) &psPMRExportInt,
234                                         (IMG_HANDLE) psPMRUnexportPMRIN->hPMRExport,
235                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT);
236         PVR_ASSERT(psPMRUnexportPMROUT->eError == PVRSRV_OK);
237
238         /*
239          * Find the connection specific handle that represents the same data
240          * as the cross process handle as releasing it will actually call the
241          * data's real release function (see the function where the cross
242          * process handle is allocated for more details).
243          */
244         psPMRUnexportPMROUT->eError =
245                 PVRSRVFindHandle(psConnection->psHandleBase,
246                                         &hPMRExportInt,
247                                         psPMRExportInt,
248                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT);
249         PVR_ASSERT(psPMRUnexportPMROUT->eError == PVRSRV_OK);
250
251         psPMRUnexportPMROUT->eError =
252                 PVRSRVReleaseHandle(psConnection->psHandleBase,
253                                         hPMRExportInt,
254                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT);
255         PVR_ASSERT((psPMRUnexportPMROUT->eError == PVRSRV_OK) || (psPMRUnexportPMROUT->eError == PVRSRV_ERROR_RETRY));
256
257         psPMRUnexportPMROUT->eError =
258                 PVRSRVReleaseHandle(KERNEL_HANDLE_BASE,
259                                         (IMG_HANDLE) psPMRUnexportPMRIN->hPMRExport,
260                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT);
261         if ((psPMRUnexportPMROUT->eError != PVRSRV_OK) && (psPMRUnexportPMROUT->eError != PVRSRV_ERROR_RETRY))
262         {
263                 PVR_ASSERT(0);
264                 PMRUnlock();
265                 goto PMRUnexportPMR_exit;
266         }
267
268         PMRUnlock();
269
270
271 PMRUnexportPMR_exit:
272
273         return 0;
274 }
275
276 static IMG_INT
277 PVRSRVBridgePMRGetUID(IMG_UINT32 ui32DispatchTableEntry,
278                                           PVRSRV_BRIDGE_IN_PMRGETUID *psPMRGetUIDIN,
279                                           PVRSRV_BRIDGE_OUT_PMRGETUID *psPMRGetUIDOUT,
280                                          CONNECTION_DATA *psConnection)
281 {
282         PMR * psPMRInt = IMG_NULL;
283
284
285
286
287
288         PMRLock();
289
290
291                                 {
292                                         /* Look up the address from the handle */
293                                         psPMRGetUIDOUT->eError =
294                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
295                                                                                         (IMG_VOID **) &psPMRInt,
296                                                                                         psPMRGetUIDIN->hPMR,
297                                                                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR);
298                                         if(psPMRGetUIDOUT->eError != PVRSRV_OK)
299                                         {
300                                                 PMRUnlock();
301                                                 goto PMRGetUID_exit;
302                                         }
303                                 }
304
305
306         psPMRGetUIDOUT->eError =
307                 PMRGetUID(
308                                         psPMRInt,
309                                         &psPMRGetUIDOUT->ui64UID);
310         PMRUnlock();
311
312
313
314
315 PMRGetUID_exit:
316
317         return 0;
318 }
319
320 static IMG_INT
321 PVRSRVBridgePMRMakeServerExportClientExport(IMG_UINT32 ui32DispatchTableEntry,
322                                           PVRSRV_BRIDGE_IN_PMRMAKESERVEREXPORTCLIENTEXPORT *psPMRMakeServerExportClientExportIN,
323                                           PVRSRV_BRIDGE_OUT_PMRMAKESERVEREXPORTCLIENTEXPORT *psPMRMakeServerExportClientExportOUT,
324                                          CONNECTION_DATA *psConnection)
325 {
326         DEVMEM_EXPORTCOOKIE * psPMRServerExportInt = IMG_NULL;
327         PMR_EXPORT * psPMRExportOutInt = IMG_NULL;
328         IMG_HANDLE hPMRExportOutInt = IMG_NULL;
329
330
331
332
333
334
335
336                                 {
337                                         /* Look up the address from the handle */
338                                         psPMRMakeServerExportClientExportOUT->eError =
339                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
340                                                                                         (IMG_VOID **) &psPMRServerExportInt,
341                                                                                         psPMRMakeServerExportClientExportIN->hPMRServerExport,
342                                                                                         PVRSRV_HANDLE_TYPE_SERVER_EXPORTCOOKIE);
343                                         if(psPMRMakeServerExportClientExportOUT->eError != PVRSRV_OK)
344                                         {
345                                                 goto PMRMakeServerExportClientExport_exit;
346                                         }
347                                 }
348
349
350         psPMRMakeServerExportClientExportOUT->eError =
351                 PMRMakeServerExportClientExport(
352                                         psPMRServerExportInt,
353                                         &psPMRExportOutInt,
354                                         &psPMRMakeServerExportClientExportOUT->ui64Size,
355                                         &psPMRMakeServerExportClientExportOUT->ui32Log2Contig,
356                                         &psPMRMakeServerExportClientExportOUT->ui64Password);
357         /* Exit early if bridged call fails */
358         if(psPMRMakeServerExportClientExportOUT->eError != PVRSRV_OK)
359         {
360                 goto PMRMakeServerExportClientExport_exit;
361         }
362
363
364         /*
365          * For cases where we need a cross process handle we actually allocate two.
366          * 
367          * The first one is a connection specific handle and it gets given the real
368          * release function. This handle does *NOT* get returned to the caller. It's
369          * purpose is to release any leaked resources when we either have a bad or
370          * abnormally terminated client. If we didn't do this then the resource
371          * wouldn't be freed until driver unload. If the resource is freed normally,
372          * this handle can be looked up via the cross process handle and then
373          * released accordingly.
374          * 
375          * The second one is a cross process handle and it gets given a noop release
376          * function. This handle does get returned to the caller.
377          */
378         psPMRMakeServerExportClientExportOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase,
379                                                         &hPMRExportOutInt,
380                                                         (IMG_VOID *) psPMRExportOutInt,
381                                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT,
382                                                         PVRSRV_HANDLE_ALLOC_FLAG_SHARED
383                                                         ,(PFN_HANDLE_RELEASE)&PMRUnmakeServerExportClientExport);
384         if (psPMRMakeServerExportClientExportOUT->eError != PVRSRV_OK)
385         {
386                 goto PMRMakeServerExportClientExport_exit;
387         }
388
389         psPMRMakeServerExportClientExportOUT->eError = PVRSRVAllocHandle(KERNEL_HANDLE_BASE,
390                                                         &psPMRMakeServerExportClientExportOUT->hPMRExportOut,
391                                                         (IMG_VOID *) psPMRExportOutInt,
392                                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT,
393                                                         PVRSRV_HANDLE_ALLOC_FLAG_MULTI,
394                                                         (PFN_HANDLE_RELEASE)&ReleasePMRExportOut);
395         if (psPMRMakeServerExportClientExportOUT->eError != PVRSRV_OK)
396         {
397                 goto PMRMakeServerExportClientExport_exit;
398         }
399
400
401
402 PMRMakeServerExportClientExport_exit:
403         if (psPMRMakeServerExportClientExportOUT->eError != PVRSRV_OK)
404         {
405                 if (psPMRMakeServerExportClientExportOUT->hPMRExportOut)
406                 {
407                         PVRSRV_ERROR eError = PVRSRVReleaseHandle(KERNEL_HANDLE_BASE,
408                                                 (IMG_HANDLE) psPMRMakeServerExportClientExportOUT->hPMRExportOut,
409                                                 PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT);
410
411                         /* Releasing the handle should free/destroy/release the resource. This should never fail... */
412                         PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY));
413
414                 }
415
416                 if (hPMRExportOutInt)
417                 {
418                         PVRSRV_ERROR eError = PVRSRVReleaseHandle(psConnection->psHandleBase,
419                                                 hPMRExportOutInt,
420                                                 PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT);
421
422                         /* Releasing the handle should free/destroy/release the resource. This should never fail... */
423                         PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY));
424
425                         /* Avoid freeing/destroying/releasing the resource a second time below */
426                         psPMRExportOutInt = IMG_NULL;
427                 }
428
429                 if (psPMRExportOutInt)
430                 {
431                         PMRUnmakeServerExportClientExport(psPMRExportOutInt);
432                 }
433         }
434
435
436         return 0;
437 }
438
439 static IMG_INT
440 PVRSRVBridgePMRUnmakeServerExportClientExport(IMG_UINT32 ui32DispatchTableEntry,
441                                           PVRSRV_BRIDGE_IN_PMRUNMAKESERVEREXPORTCLIENTEXPORT *psPMRUnmakeServerExportClientExportIN,
442                                           PVRSRV_BRIDGE_OUT_PMRUNMAKESERVEREXPORTCLIENTEXPORT *psPMRUnmakeServerExportClientExportOUT,
443                                          CONNECTION_DATA *psConnection)
444 {
445         PMR_EXPORT * psPMRExportInt = IMG_NULL;
446         IMG_HANDLE hPMRExportInt = IMG_NULL;
447
448         PVR_UNREFERENCED_PARAMETER(psConnection);
449
450
451
452
453
454
455
456         psPMRUnmakeServerExportClientExportOUT->eError =
457                 PVRSRVLookupHandle(KERNEL_HANDLE_BASE,
458                                         (IMG_VOID **) &psPMRExportInt,
459                                         (IMG_HANDLE) psPMRUnmakeServerExportClientExportIN->hPMRExport,
460                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT);
461         PVR_ASSERT(psPMRUnmakeServerExportClientExportOUT->eError == PVRSRV_OK);
462
463         /*
464          * Find the connection specific handle that represents the same data
465          * as the cross process handle as releasing it will actually call the
466          * data's real release function (see the function where the cross
467          * process handle is allocated for more details).
468          */
469         psPMRUnmakeServerExportClientExportOUT->eError =
470                 PVRSRVFindHandle(psConnection->psHandleBase,
471                                         &hPMRExportInt,
472                                         psPMRExportInt,
473                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT);
474         PVR_ASSERT(psPMRUnmakeServerExportClientExportOUT->eError == PVRSRV_OK);
475
476         psPMRUnmakeServerExportClientExportOUT->eError =
477                 PVRSRVReleaseHandle(psConnection->psHandleBase,
478                                         hPMRExportInt,
479                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT);
480         PVR_ASSERT((psPMRUnmakeServerExportClientExportOUT->eError == PVRSRV_OK) || (psPMRUnmakeServerExportClientExportOUT->eError == PVRSRV_ERROR_RETRY));
481
482         psPMRUnmakeServerExportClientExportOUT->eError =
483                 PVRSRVReleaseHandle(KERNEL_HANDLE_BASE,
484                                         (IMG_HANDLE) psPMRUnmakeServerExportClientExportIN->hPMRExport,
485                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT);
486         if ((psPMRUnmakeServerExportClientExportOUT->eError != PVRSRV_OK) && (psPMRUnmakeServerExportClientExportOUT->eError != PVRSRV_ERROR_RETRY))
487         {
488                 PVR_ASSERT(0);
489                 goto PMRUnmakeServerExportClientExport_exit;
490         }
491
492
493
494 PMRUnmakeServerExportClientExport_exit:
495
496         return 0;
497 }
498
499 static IMG_INT
500 PVRSRVBridgePMRImportPMR(IMG_UINT32 ui32DispatchTableEntry,
501                                           PVRSRV_BRIDGE_IN_PMRIMPORTPMR *psPMRImportPMRIN,
502                                           PVRSRV_BRIDGE_OUT_PMRIMPORTPMR *psPMRImportPMROUT,
503                                          CONNECTION_DATA *psConnection)
504 {
505         PMR_EXPORT * psPMRExportInt = IMG_NULL;
506         PMR * psPMRInt = IMG_NULL;
507
508
509
510
511 #if defined (SUPPORT_AUTH)
512         psPMRImportPMROUT->eError = OSCheckAuthentication(psConnection, 1);
513         if (psPMRImportPMROUT->eError != PVRSRV_OK)
514         {
515                 goto PMRImportPMR_exit;
516         }
517 #endif
518
519         PMRLock();
520
521
522                                 {
523                                         /* Look up the address from the handle */
524                                         psPMRImportPMROUT->eError =
525                                                 PVRSRVLookupHandle(KERNEL_HANDLE_BASE,
526                                                                                         (IMG_VOID **) &psPMRExportInt,
527                                                                                         psPMRImportPMRIN->hPMRExport,
528                                                                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR_EXPORT);
529                                         if(psPMRImportPMROUT->eError != PVRSRV_OK)
530                                         {
531                                                 PMRUnlock();
532                                                 goto PMRImportPMR_exit;
533                                         }
534                                 }
535
536
537         psPMRImportPMROUT->eError =
538                 PMRImportPMR(
539                                         psPMRExportInt,
540                                         psPMRImportPMRIN->ui64uiPassword,
541                                         psPMRImportPMRIN->ui64uiSize,
542                                         psPMRImportPMRIN->ui32uiLog2Contig,
543                                         &psPMRInt);
544         /* Exit early if bridged call fails */
545         if(psPMRImportPMROUT->eError != PVRSRV_OK)
546         {
547                 PMRUnlock();
548                 goto PMRImportPMR_exit;
549         }
550         PMRUnlock();
551
552
553         psPMRImportPMROUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase,
554                                                         &psPMRImportPMROUT->hPMR,
555                                                         (IMG_VOID *) psPMRInt,
556                                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR,
557                                                         PVRSRV_HANDLE_ALLOC_FLAG_MULTI
558                                                         ,(PFN_HANDLE_RELEASE)&PMRUnrefPMR);
559         if (psPMRImportPMROUT->eError != PVRSRV_OK)
560         {
561                 goto PMRImportPMR_exit;
562         }
563
564
565
566
567 PMRImportPMR_exit:
568         if (psPMRImportPMROUT->eError != PVRSRV_OK)
569         {
570                 if (psPMRInt)
571                 {
572                         PMRUnrefPMR(psPMRInt);
573                 }
574         }
575
576
577         return 0;
578 }
579
580 static IMG_INT
581 PVRSRVBridgeDevmemIntCtxCreate(IMG_UINT32 ui32DispatchTableEntry,
582                                           PVRSRV_BRIDGE_IN_DEVMEMINTCTXCREATE *psDevmemIntCtxCreateIN,
583                                           PVRSRV_BRIDGE_OUT_DEVMEMINTCTXCREATE *psDevmemIntCtxCreateOUT,
584                                          CONNECTION_DATA *psConnection)
585 {
586         IMG_HANDLE hDeviceNodeInt = IMG_NULL;
587         DEVMEMINT_CTX * psDevMemServerContextInt = IMG_NULL;
588         IMG_HANDLE hPrivDataInt = IMG_NULL;
589
590
591
592         psDevmemIntCtxCreateOUT->hDevMemServerContext = IMG_NULL;
593
594
595
596
597                                 {
598                                         /* Look up the address from the handle */
599                                         psDevmemIntCtxCreateOUT->eError =
600                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
601                                                                                         (IMG_VOID **) &hDeviceNodeInt,
602                                                                                         psDevmemIntCtxCreateIN->hDeviceNode,
603                                                                                         PVRSRV_HANDLE_TYPE_DEV_NODE);
604                                         if(psDevmemIntCtxCreateOUT->eError != PVRSRV_OK)
605                                         {
606                                                 goto DevmemIntCtxCreate_exit;
607                                         }
608                                 }
609
610
611         psDevmemIntCtxCreateOUT->eError =
612                 DevmemIntCtxCreate(
613                                         hDeviceNodeInt,
614                                         &psDevMemServerContextInt,
615                                         &hPrivDataInt);
616         /* Exit early if bridged call fails */
617         if(psDevmemIntCtxCreateOUT->eError != PVRSRV_OK)
618         {
619                 goto DevmemIntCtxCreate_exit;
620         }
621
622
623         psDevmemIntCtxCreateOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase,
624                                                         &psDevmemIntCtxCreateOUT->hDevMemServerContext,
625                                                         (IMG_VOID *) psDevMemServerContextInt,
626                                                         PVRSRV_HANDLE_TYPE_DEVMEMINT_CTX,
627                                                         PVRSRV_HANDLE_ALLOC_FLAG_MULTI
628                                                         ,(PFN_HANDLE_RELEASE)&DevmemIntCtxDestroy);
629         if (psDevmemIntCtxCreateOUT->eError != PVRSRV_OK)
630         {
631                 goto DevmemIntCtxCreate_exit;
632         }
633
634
635         psDevmemIntCtxCreateOUT->eError = PVRSRVAllocSubHandle(psConnection->psHandleBase,
636                                                         &psDevmemIntCtxCreateOUT->hPrivData,
637                                                         (IMG_VOID *) hPrivDataInt,
638                                                         PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA,
639                                                         PVRSRV_HANDLE_ALLOC_FLAG_MULTI
640                                                         ,psDevmemIntCtxCreateOUT->hDevMemServerContext);
641         if (psDevmemIntCtxCreateOUT->eError != PVRSRV_OK)
642         {
643                 goto DevmemIntCtxCreate_exit;
644         }
645
646
647
648
649 DevmemIntCtxCreate_exit:
650         if (psDevmemIntCtxCreateOUT->eError != PVRSRV_OK)
651         {
652                 if (psDevmemIntCtxCreateOUT->hDevMemServerContext)
653                 {
654                         PVRSRV_ERROR eError = PVRSRVReleaseHandle(psConnection->psHandleBase,
655                                                 (IMG_HANDLE) psDevmemIntCtxCreateOUT->hDevMemServerContext,
656                                                 PVRSRV_HANDLE_TYPE_DEVMEMINT_CTX);
657
658                         /* Releasing the handle should free/destroy/release the resource. This should never fail... */
659                         PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY));
660
661                         /* Avoid freeing/destroying/releasing the resource a second time below */
662                         psDevMemServerContextInt = IMG_NULL;
663                 }
664
665
666                 if (psDevMemServerContextInt)
667                 {
668                         DevmemIntCtxDestroy(psDevMemServerContextInt);
669                 }
670         }
671
672
673         return 0;
674 }
675
676 static IMG_INT
677 PVRSRVBridgeDevmemIntCtxDestroy(IMG_UINT32 ui32DispatchTableEntry,
678                                           PVRSRV_BRIDGE_IN_DEVMEMINTCTXDESTROY *psDevmemIntCtxDestroyIN,
679                                           PVRSRV_BRIDGE_OUT_DEVMEMINTCTXDESTROY *psDevmemIntCtxDestroyOUT,
680                                          CONNECTION_DATA *psConnection)
681 {
682
683
684
685
686
687
688
689
690
691         psDevmemIntCtxDestroyOUT->eError =
692                 PVRSRVReleaseHandle(psConnection->psHandleBase,
693                                         (IMG_HANDLE) psDevmemIntCtxDestroyIN->hDevmemServerContext,
694                                         PVRSRV_HANDLE_TYPE_DEVMEMINT_CTX);
695         if ((psDevmemIntCtxDestroyOUT->eError != PVRSRV_OK) && (psDevmemIntCtxDestroyOUT->eError != PVRSRV_ERROR_RETRY))
696         {
697                 PVR_ASSERT(0);
698                 goto DevmemIntCtxDestroy_exit;
699         }
700
701
702
703 DevmemIntCtxDestroy_exit:
704
705         return 0;
706 }
707
708 static IMG_INT
709 PVRSRVBridgeDevmemIntHeapCreate(IMG_UINT32 ui32DispatchTableEntry,
710                                           PVRSRV_BRIDGE_IN_DEVMEMINTHEAPCREATE *psDevmemIntHeapCreateIN,
711                                           PVRSRV_BRIDGE_OUT_DEVMEMINTHEAPCREATE *psDevmemIntHeapCreateOUT,
712                                          CONNECTION_DATA *psConnection)
713 {
714         DEVMEMINT_CTX * psDevmemCtxInt = IMG_NULL;
715         DEVMEMINT_HEAP * psDevmemHeapPtrInt = IMG_NULL;
716
717
718
719
720
721
722
723                                 {
724                                         /* Look up the address from the handle */
725                                         psDevmemIntHeapCreateOUT->eError =
726                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
727                                                                                         (IMG_VOID **) &psDevmemCtxInt,
728                                                                                         psDevmemIntHeapCreateIN->hDevmemCtx,
729                                                                                         PVRSRV_HANDLE_TYPE_DEVMEMINT_CTX);
730                                         if(psDevmemIntHeapCreateOUT->eError != PVRSRV_OK)
731                                         {
732                                                 goto DevmemIntHeapCreate_exit;
733                                         }
734                                 }
735
736
737         psDevmemIntHeapCreateOUT->eError =
738                 DevmemIntHeapCreate(
739                                         psDevmemCtxInt,
740                                         psDevmemIntHeapCreateIN->sHeapBaseAddr,
741                                         psDevmemIntHeapCreateIN->uiHeapLength,
742                                         psDevmemIntHeapCreateIN->ui32Log2DataPageSize,
743                                         &psDevmemHeapPtrInt);
744         /* Exit early if bridged call fails */
745         if(psDevmemIntHeapCreateOUT->eError != PVRSRV_OK)
746         {
747                 goto DevmemIntHeapCreate_exit;
748         }
749
750
751         psDevmemIntHeapCreateOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase,
752                                                         &psDevmemIntHeapCreateOUT->hDevmemHeapPtr,
753                                                         (IMG_VOID *) psDevmemHeapPtrInt,
754                                                         PVRSRV_HANDLE_TYPE_DEVMEMINT_HEAP,
755                                                         PVRSRV_HANDLE_ALLOC_FLAG_MULTI
756                                                         ,(PFN_HANDLE_RELEASE)&DevmemIntHeapDestroy);
757         if (psDevmemIntHeapCreateOUT->eError != PVRSRV_OK)
758         {
759                 goto DevmemIntHeapCreate_exit;
760         }
761
762
763
764
765 DevmemIntHeapCreate_exit:
766         if (psDevmemIntHeapCreateOUT->eError != PVRSRV_OK)
767         {
768                 if (psDevmemHeapPtrInt)
769                 {
770                         DevmemIntHeapDestroy(psDevmemHeapPtrInt);
771                 }
772         }
773
774
775         return 0;
776 }
777
778 static IMG_INT
779 PVRSRVBridgeDevmemIntHeapDestroy(IMG_UINT32 ui32DispatchTableEntry,
780                                           PVRSRV_BRIDGE_IN_DEVMEMINTHEAPDESTROY *psDevmemIntHeapDestroyIN,
781                                           PVRSRV_BRIDGE_OUT_DEVMEMINTHEAPDESTROY *psDevmemIntHeapDestroyOUT,
782                                          CONNECTION_DATA *psConnection)
783 {
784
785
786
787
788
789
790
791
792
793         psDevmemIntHeapDestroyOUT->eError =
794                 PVRSRVReleaseHandle(psConnection->psHandleBase,
795                                         (IMG_HANDLE) psDevmemIntHeapDestroyIN->hDevmemHeap,
796                                         PVRSRV_HANDLE_TYPE_DEVMEMINT_HEAP);
797         if ((psDevmemIntHeapDestroyOUT->eError != PVRSRV_OK) && (psDevmemIntHeapDestroyOUT->eError != PVRSRV_ERROR_RETRY))
798         {
799                 PVR_ASSERT(0);
800                 goto DevmemIntHeapDestroy_exit;
801         }
802
803
804
805 DevmemIntHeapDestroy_exit:
806
807         return 0;
808 }
809
810 static IMG_INT
811 PVRSRVBridgeDevmemIntMapPMR(IMG_UINT32 ui32DispatchTableEntry,
812                                           PVRSRV_BRIDGE_IN_DEVMEMINTMAPPMR *psDevmemIntMapPMRIN,
813                                           PVRSRV_BRIDGE_OUT_DEVMEMINTMAPPMR *psDevmemIntMapPMROUT,
814                                          CONNECTION_DATA *psConnection)
815 {
816         DEVMEMINT_HEAP * psDevmemServerHeapInt = IMG_NULL;
817         DEVMEMINT_RESERVATION * psReservationInt = IMG_NULL;
818         PMR * psPMRInt = IMG_NULL;
819         DEVMEMINT_MAPPING * psMappingInt = IMG_NULL;
820
821
822
823
824
825         PMRLock();
826
827
828                                 {
829                                         /* Look up the address from the handle */
830                                         psDevmemIntMapPMROUT->eError =
831                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
832                                                                                         (IMG_VOID **) &psDevmemServerHeapInt,
833                                                                                         psDevmemIntMapPMRIN->hDevmemServerHeap,
834                                                                                         PVRSRV_HANDLE_TYPE_DEVMEMINT_HEAP);
835                                         if(psDevmemIntMapPMROUT->eError != PVRSRV_OK)
836                                         {
837                                                 PMRUnlock();
838                                                 goto DevmemIntMapPMR_exit;
839                                         }
840                                 }
841
842
843                                 {
844                                         /* Look up the address from the handle */
845                                         psDevmemIntMapPMROUT->eError =
846                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
847                                                                                         (IMG_VOID **) &psReservationInt,
848                                                                                         psDevmemIntMapPMRIN->hReservation,
849                                                                                         PVRSRV_HANDLE_TYPE_DEVMEMINT_RESERVATION);
850                                         if(psDevmemIntMapPMROUT->eError != PVRSRV_OK)
851                                         {
852                                                 PMRUnlock();
853                                                 goto DevmemIntMapPMR_exit;
854                                         }
855                                 }
856
857
858                                 {
859                                         /* Look up the address from the handle */
860                                         psDevmemIntMapPMROUT->eError =
861                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
862                                                                                         (IMG_VOID **) &psPMRInt,
863                                                                                         psDevmemIntMapPMRIN->hPMR,
864                                                                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR);
865                                         if(psDevmemIntMapPMROUT->eError != PVRSRV_OK)
866                                         {
867                                                 PMRUnlock();
868                                                 goto DevmemIntMapPMR_exit;
869                                         }
870                                 }
871
872
873         psDevmemIntMapPMROUT->eError =
874                 DevmemIntMapPMR(
875                                         psDevmemServerHeapInt,
876                                         psReservationInt,
877                                         psPMRInt,
878                                         psDevmemIntMapPMRIN->uiMapFlags,
879                                         &psMappingInt);
880         /* Exit early if bridged call fails */
881         if(psDevmemIntMapPMROUT->eError != PVRSRV_OK)
882         {
883                 PMRUnlock();
884                 goto DevmemIntMapPMR_exit;
885         }
886         PMRUnlock();
887
888
889         psDevmemIntMapPMROUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase,
890                                                         &psDevmemIntMapPMROUT->hMapping,
891                                                         (IMG_VOID *) psMappingInt,
892                                                         PVRSRV_HANDLE_TYPE_DEVMEMINT_MAPPING,
893                                                         PVRSRV_HANDLE_ALLOC_FLAG_MULTI
894                                                         ,(PFN_HANDLE_RELEASE)&DevmemIntUnmapPMR);
895         if (psDevmemIntMapPMROUT->eError != PVRSRV_OK)
896         {
897                 goto DevmemIntMapPMR_exit;
898         }
899
900
901
902
903 DevmemIntMapPMR_exit:
904         if (psDevmemIntMapPMROUT->eError != PVRSRV_OK)
905         {
906                 if (psMappingInt)
907                 {
908                         DevmemIntUnmapPMR(psMappingInt);
909                 }
910         }
911
912
913         return 0;
914 }
915
916 static IMG_INT
917 PVRSRVBridgeDevmemIntUnmapPMR(IMG_UINT32 ui32DispatchTableEntry,
918                                           PVRSRV_BRIDGE_IN_DEVMEMINTUNMAPPMR *psDevmemIntUnmapPMRIN,
919                                           PVRSRV_BRIDGE_OUT_DEVMEMINTUNMAPPMR *psDevmemIntUnmapPMROUT,
920                                          CONNECTION_DATA *psConnection)
921 {
922
923
924
925
926
927         PMRLock();
928
929
930
931
932         psDevmemIntUnmapPMROUT->eError =
933                 PVRSRVReleaseHandle(psConnection->psHandleBase,
934                                         (IMG_HANDLE) psDevmemIntUnmapPMRIN->hMapping,
935                                         PVRSRV_HANDLE_TYPE_DEVMEMINT_MAPPING);
936         if ((psDevmemIntUnmapPMROUT->eError != PVRSRV_OK) && (psDevmemIntUnmapPMROUT->eError != PVRSRV_ERROR_RETRY))
937         {
938                 PVR_ASSERT(0);
939                 PMRUnlock();
940                 goto DevmemIntUnmapPMR_exit;
941         }
942
943         PMRUnlock();
944
945
946 DevmemIntUnmapPMR_exit:
947
948         return 0;
949 }
950
951 static IMG_INT
952 PVRSRVBridgeDevmemIntReserveRange(IMG_UINT32 ui32DispatchTableEntry,
953                                           PVRSRV_BRIDGE_IN_DEVMEMINTRESERVERANGE *psDevmemIntReserveRangeIN,
954                                           PVRSRV_BRIDGE_OUT_DEVMEMINTRESERVERANGE *psDevmemIntReserveRangeOUT,
955                                          CONNECTION_DATA *psConnection)
956 {
957         DEVMEMINT_HEAP * psDevmemServerHeapInt = IMG_NULL;
958         DEVMEMINT_RESERVATION * psReservationInt = IMG_NULL;
959
960
961
962
963
964
965
966                                 {
967                                         /* Look up the address from the handle */
968                                         psDevmemIntReserveRangeOUT->eError =
969                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
970                                                                                         (IMG_VOID **) &psDevmemServerHeapInt,
971                                                                                         psDevmemIntReserveRangeIN->hDevmemServerHeap,
972                                                                                         PVRSRV_HANDLE_TYPE_DEVMEMINT_HEAP);
973                                         if(psDevmemIntReserveRangeOUT->eError != PVRSRV_OK)
974                                         {
975                                                 goto DevmemIntReserveRange_exit;
976                                         }
977                                 }
978
979
980         psDevmemIntReserveRangeOUT->eError =
981                 DevmemIntReserveRange(
982                                         psDevmemServerHeapInt,
983                                         psDevmemIntReserveRangeIN->sAddress,
984                                         psDevmemIntReserveRangeIN->uiLength,
985                                         &psReservationInt);
986         /* Exit early if bridged call fails */
987         if(psDevmemIntReserveRangeOUT->eError != PVRSRV_OK)
988         {
989                 goto DevmemIntReserveRange_exit;
990         }
991
992
993         psDevmemIntReserveRangeOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase,
994                                                         &psDevmemIntReserveRangeOUT->hReservation,
995                                                         (IMG_VOID *) psReservationInt,
996                                                         PVRSRV_HANDLE_TYPE_DEVMEMINT_RESERVATION,
997                                                         PVRSRV_HANDLE_ALLOC_FLAG_MULTI
998                                                         ,(PFN_HANDLE_RELEASE)&DevmemIntUnreserveRange);
999         if (psDevmemIntReserveRangeOUT->eError != PVRSRV_OK)
1000         {
1001                 goto DevmemIntReserveRange_exit;
1002         }
1003
1004
1005
1006
1007 DevmemIntReserveRange_exit:
1008         if (psDevmemIntReserveRangeOUT->eError != PVRSRV_OK)
1009         {
1010                 if (psReservationInt)
1011                 {
1012                         DevmemIntUnreserveRange(psReservationInt);
1013                 }
1014         }
1015
1016
1017         return 0;
1018 }
1019
1020 static IMG_INT
1021 PVRSRVBridgeDevmemIntUnreserveRange(IMG_UINT32 ui32DispatchTableEntry,
1022                                           PVRSRV_BRIDGE_IN_DEVMEMINTUNRESERVERANGE *psDevmemIntUnreserveRangeIN,
1023                                           PVRSRV_BRIDGE_OUT_DEVMEMINTUNRESERVERANGE *psDevmemIntUnreserveRangeOUT,
1024                                          CONNECTION_DATA *psConnection)
1025 {
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035         psDevmemIntUnreserveRangeOUT->eError =
1036                 PVRSRVReleaseHandle(psConnection->psHandleBase,
1037                                         (IMG_HANDLE) psDevmemIntUnreserveRangeIN->hReservation,
1038                                         PVRSRV_HANDLE_TYPE_DEVMEMINT_RESERVATION);
1039         if ((psDevmemIntUnreserveRangeOUT->eError != PVRSRV_OK) && (psDevmemIntUnreserveRangeOUT->eError != PVRSRV_ERROR_RETRY))
1040         {
1041                 PVR_ASSERT(0);
1042                 goto DevmemIntUnreserveRange_exit;
1043         }
1044
1045
1046
1047 DevmemIntUnreserveRange_exit:
1048
1049         return 0;
1050 }
1051
1052 static IMG_INT
1053 PVRSRVBridgePhysmemNewRamBackedPMR(IMG_UINT32 ui32DispatchTableEntry,
1054                                           PVRSRV_BRIDGE_IN_PHYSMEMNEWRAMBACKEDPMR *psPhysmemNewRamBackedPMRIN,
1055                                           PVRSRV_BRIDGE_OUT_PHYSMEMNEWRAMBACKEDPMR *psPhysmemNewRamBackedPMROUT,
1056                                          CONNECTION_DATA *psConnection)
1057 {
1058         IMG_HANDLE hDeviceNodeInt = IMG_NULL;
1059         IMG_BOOL *bMappingTableInt = IMG_NULL;
1060         PMR * psPMRPtrInt = IMG_NULL;
1061
1062
1063
1064
1065         if (psPhysmemNewRamBackedPMRIN->ui32NumVirtChunks != 0)
1066         {
1067                 bMappingTableInt = OSAllocMem(psPhysmemNewRamBackedPMRIN->ui32NumVirtChunks * sizeof(IMG_BOOL));
1068                 if (!bMappingTableInt)
1069                 {
1070                         psPhysmemNewRamBackedPMROUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1071         
1072                         goto PhysmemNewRamBackedPMR_exit;
1073                 }
1074         }
1075
1076                         /* Copy the data over */
1077                         if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psPhysmemNewRamBackedPMRIN->pbMappingTable, psPhysmemNewRamBackedPMRIN->ui32NumVirtChunks * sizeof(IMG_BOOL))
1078                                 || (OSCopyFromUser(NULL, bMappingTableInt, psPhysmemNewRamBackedPMRIN->pbMappingTable,
1079                                 psPhysmemNewRamBackedPMRIN->ui32NumVirtChunks * sizeof(IMG_BOOL)) != PVRSRV_OK) )
1080                         {
1081                                 psPhysmemNewRamBackedPMROUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1082
1083                                 goto PhysmemNewRamBackedPMR_exit;
1084                         }
1085
1086         PMRLock();
1087
1088
1089                                 {
1090                                         /* Look up the address from the handle */
1091                                         psPhysmemNewRamBackedPMROUT->eError =
1092                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
1093                                                                                         (IMG_VOID **) &hDeviceNodeInt,
1094                                                                                         psPhysmemNewRamBackedPMRIN->hDeviceNode,
1095                                                                                         PVRSRV_HANDLE_TYPE_DEV_NODE);
1096                                         if(psPhysmemNewRamBackedPMROUT->eError != PVRSRV_OK)
1097                                         {
1098                                                 PMRUnlock();
1099                                                 goto PhysmemNewRamBackedPMR_exit;
1100                                         }
1101                                 }
1102
1103
1104         psPhysmemNewRamBackedPMROUT->eError =
1105                 PhysmemNewRamBackedPMR(
1106                                         hDeviceNodeInt,
1107                                         psPhysmemNewRamBackedPMRIN->uiSize,
1108                                         psPhysmemNewRamBackedPMRIN->uiChunkSize,
1109                                         psPhysmemNewRamBackedPMRIN->ui32NumPhysChunks,
1110                                         psPhysmemNewRamBackedPMRIN->ui32NumVirtChunks,
1111                                         bMappingTableInt,
1112                                         psPhysmemNewRamBackedPMRIN->ui32Log2PageSize,
1113                                         psPhysmemNewRamBackedPMRIN->uiFlags,
1114                                         &psPMRPtrInt);
1115         /* Exit early if bridged call fails */
1116         if(psPhysmemNewRamBackedPMROUT->eError != PVRSRV_OK)
1117         {
1118                 PMRUnlock();
1119                 goto PhysmemNewRamBackedPMR_exit;
1120         }
1121         PMRUnlock();
1122
1123
1124         psPhysmemNewRamBackedPMROUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase,
1125                                                         &psPhysmemNewRamBackedPMROUT->hPMRPtr,
1126                                                         (IMG_VOID *) psPMRPtrInt,
1127                                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR,
1128                                                         PVRSRV_HANDLE_ALLOC_FLAG_MULTI
1129                                                         ,(PFN_HANDLE_RELEASE)&PMRUnrefPMR);
1130         if (psPhysmemNewRamBackedPMROUT->eError != PVRSRV_OK)
1131         {
1132                 goto PhysmemNewRamBackedPMR_exit;
1133         }
1134
1135
1136
1137
1138 PhysmemNewRamBackedPMR_exit:
1139         if (psPhysmemNewRamBackedPMROUT->eError != PVRSRV_OK)
1140         {
1141                 if (psPMRPtrInt)
1142                 {
1143                         PMRUnrefPMR(psPMRPtrInt);
1144                 }
1145         }
1146
1147         if (bMappingTableInt)
1148                 OSFreeMem(bMappingTableInt);
1149
1150         return 0;
1151 }
1152
1153 static IMG_INT
1154 PVRSRVBridgePMRLocalImportPMR(IMG_UINT32 ui32DispatchTableEntry,
1155                                           PVRSRV_BRIDGE_IN_PMRLOCALIMPORTPMR *psPMRLocalImportPMRIN,
1156                                           PVRSRV_BRIDGE_OUT_PMRLOCALIMPORTPMR *psPMRLocalImportPMROUT,
1157                                          CONNECTION_DATA *psConnection)
1158 {
1159         PMR * psExtHandleInt = IMG_NULL;
1160         PMR * psPMRInt = IMG_NULL;
1161
1162
1163
1164
1165
1166         PMRLock();
1167
1168
1169                                 {
1170                                         /* Look up the address from the handle */
1171                                         psPMRLocalImportPMROUT->eError =
1172                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
1173                                                                                         (IMG_VOID **) &psExtHandleInt,
1174                                                                                         psPMRLocalImportPMRIN->hExtHandle,
1175                                                                                         PVRSRV_HANDLE_TYPE_DEVMEM_MEM_IMPORT);
1176                                         if(psPMRLocalImportPMROUT->eError != PVRSRV_OK)
1177                                         {
1178                                                 PMRUnlock();
1179                                                 goto PMRLocalImportPMR_exit;
1180                                         }
1181                                 }
1182
1183
1184         psPMRLocalImportPMROUT->eError =
1185                 PMRLocalImportPMR(
1186                                         psExtHandleInt,
1187                                         &psPMRInt,
1188                                         &psPMRLocalImportPMROUT->uiSize,
1189                                         &psPMRLocalImportPMROUT->sAlign);
1190         /* Exit early if bridged call fails */
1191         if(psPMRLocalImportPMROUT->eError != PVRSRV_OK)
1192         {
1193                 PMRUnlock();
1194                 goto PMRLocalImportPMR_exit;
1195         }
1196         PMRUnlock();
1197
1198
1199         psPMRLocalImportPMROUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase,
1200                                                         &psPMRLocalImportPMROUT->hPMR,
1201                                                         (IMG_VOID *) psPMRInt,
1202                                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR,
1203                                                         PVRSRV_HANDLE_ALLOC_FLAG_MULTI
1204                                                         ,(PFN_HANDLE_RELEASE)&PMRUnrefPMR);
1205         if (psPMRLocalImportPMROUT->eError != PVRSRV_OK)
1206         {
1207                 goto PMRLocalImportPMR_exit;
1208         }
1209
1210
1211
1212
1213 PMRLocalImportPMR_exit:
1214         if (psPMRLocalImportPMROUT->eError != PVRSRV_OK)
1215         {
1216                 if (psPMRInt)
1217                 {
1218                         PMRUnrefPMR(psPMRInt);
1219                 }
1220         }
1221
1222
1223         return 0;
1224 }
1225
1226 static IMG_INT
1227 PVRSRVBridgePMRUnrefPMR(IMG_UINT32 ui32DispatchTableEntry,
1228                                           PVRSRV_BRIDGE_IN_PMRUNREFPMR *psPMRUnrefPMRIN,
1229                                           PVRSRV_BRIDGE_OUT_PMRUNREFPMR *psPMRUnrefPMROUT,
1230                                          CONNECTION_DATA *psConnection)
1231 {
1232
1233
1234
1235
1236
1237         PMRLock();
1238
1239
1240
1241
1242         psPMRUnrefPMROUT->eError =
1243                 PVRSRVReleaseHandle(psConnection->psHandleBase,
1244                                         (IMG_HANDLE) psPMRUnrefPMRIN->hPMR,
1245                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR);
1246         if ((psPMRUnrefPMROUT->eError != PVRSRV_OK) && (psPMRUnrefPMROUT->eError != PVRSRV_ERROR_RETRY))
1247         {
1248                 PVR_ASSERT(0);
1249                 PMRUnlock();
1250                 goto PMRUnrefPMR_exit;
1251         }
1252
1253         PMRUnlock();
1254
1255
1256 PMRUnrefPMR_exit:
1257
1258         return 0;
1259 }
1260
1261 static IMG_INT
1262 PVRSRVBridgeDevmemSLCFlushInvalRequest(IMG_UINT32 ui32DispatchTableEntry,
1263                                           PVRSRV_BRIDGE_IN_DEVMEMSLCFLUSHINVALREQUEST *psDevmemSLCFlushInvalRequestIN,
1264                                           PVRSRV_BRIDGE_OUT_DEVMEMSLCFLUSHINVALREQUEST *psDevmemSLCFlushInvalRequestOUT,
1265                                          CONNECTION_DATA *psConnection)
1266 {
1267         IMG_HANDLE hDeviceNodeInt = IMG_NULL;
1268         PMR * psPmrInt = IMG_NULL;
1269
1270
1271
1272
1273
1274
1275
1276                                 {
1277                                         /* Look up the address from the handle */
1278                                         psDevmemSLCFlushInvalRequestOUT->eError =
1279                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
1280                                                                                         (IMG_VOID **) &hDeviceNodeInt,
1281                                                                                         psDevmemSLCFlushInvalRequestIN->hDeviceNode,
1282                                                                                         PVRSRV_HANDLE_TYPE_DEV_NODE);
1283                                         if(psDevmemSLCFlushInvalRequestOUT->eError != PVRSRV_OK)
1284                                         {
1285                                                 goto DevmemSLCFlushInvalRequest_exit;
1286                                         }
1287                                 }
1288
1289
1290                                 {
1291                                         /* Look up the address from the handle */
1292                                         psDevmemSLCFlushInvalRequestOUT->eError =
1293                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
1294                                                                                         (IMG_VOID **) &psPmrInt,
1295                                                                                         psDevmemSLCFlushInvalRequestIN->hPmr,
1296                                                                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR);
1297                                         if(psDevmemSLCFlushInvalRequestOUT->eError != PVRSRV_OK)
1298                                         {
1299                                                 goto DevmemSLCFlushInvalRequest_exit;
1300                                         }
1301                                 }
1302
1303
1304         psDevmemSLCFlushInvalRequestOUT->eError =
1305                 DevmemSLCFlushInvalRequest(
1306                                         hDeviceNodeInt,
1307                                         psPmrInt);
1308
1309
1310
1311
1312 DevmemSLCFlushInvalRequest_exit:
1313
1314         return 0;
1315 }
1316
1317 static IMG_INT
1318 PVRSRVBridgeDevmemIsVDevAddrValid(IMG_UINT32 ui32DispatchTableEntry,
1319                                           PVRSRV_BRIDGE_IN_DEVMEMISVDEVADDRVALID *psDevmemIsVDevAddrValidIN,
1320                                           PVRSRV_BRIDGE_OUT_DEVMEMISVDEVADDRVALID *psDevmemIsVDevAddrValidOUT,
1321                                          CONNECTION_DATA *psConnection)
1322 {
1323         DEVMEMINT_CTX * psDevmemCtxInt = IMG_NULL;
1324
1325
1326
1327
1328
1329
1330
1331                                 {
1332                                         /* Look up the address from the handle */
1333                                         psDevmemIsVDevAddrValidOUT->eError =
1334                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
1335                                                                                         (IMG_VOID **) &psDevmemCtxInt,
1336                                                                                         psDevmemIsVDevAddrValidIN->hDevmemCtx,
1337                                                                                         PVRSRV_HANDLE_TYPE_DEVMEMINT_CTX);
1338                                         if(psDevmemIsVDevAddrValidOUT->eError != PVRSRV_OK)
1339                                         {
1340                                                 goto DevmemIsVDevAddrValid_exit;
1341                                         }
1342                                 }
1343
1344
1345         psDevmemIsVDevAddrValidOUT->eError =
1346                 DevmemIntIsVDevAddrValid(
1347                                         psDevmemCtxInt,
1348                                         psDevmemIsVDevAddrValidIN->sAddress);
1349
1350
1351
1352
1353 DevmemIsVDevAddrValid_exit:
1354
1355         return 0;
1356 }
1357
1358 static IMG_INT
1359 PVRSRVBridgeHeapCfgHeapConfigCount(IMG_UINT32 ui32DispatchTableEntry,
1360                                           PVRSRV_BRIDGE_IN_HEAPCFGHEAPCONFIGCOUNT *psHeapCfgHeapConfigCountIN,
1361                                           PVRSRV_BRIDGE_OUT_HEAPCFGHEAPCONFIGCOUNT *psHeapCfgHeapConfigCountOUT,
1362                                          CONNECTION_DATA *psConnection)
1363 {
1364         IMG_HANDLE hDeviceNodeInt = IMG_NULL;
1365
1366
1367
1368
1369
1370
1371
1372                                 {
1373                                         /* Look up the address from the handle */
1374                                         psHeapCfgHeapConfigCountOUT->eError =
1375                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
1376                                                                                         (IMG_VOID **) &hDeviceNodeInt,
1377                                                                                         psHeapCfgHeapConfigCountIN->hDeviceNode,
1378                                                                                         PVRSRV_HANDLE_TYPE_DEV_NODE);
1379                                         if(psHeapCfgHeapConfigCountOUT->eError != PVRSRV_OK)
1380                                         {
1381                                                 goto HeapCfgHeapConfigCount_exit;
1382                                         }
1383                                 }
1384
1385
1386         psHeapCfgHeapConfigCountOUT->eError =
1387                 HeapCfgHeapConfigCount(
1388                                         hDeviceNodeInt,
1389                                         &psHeapCfgHeapConfigCountOUT->ui32NumHeapConfigs);
1390
1391
1392
1393
1394 HeapCfgHeapConfigCount_exit:
1395
1396         return 0;
1397 }
1398
1399 static IMG_INT
1400 PVRSRVBridgeHeapCfgHeapCount(IMG_UINT32 ui32DispatchTableEntry,
1401                                           PVRSRV_BRIDGE_IN_HEAPCFGHEAPCOUNT *psHeapCfgHeapCountIN,
1402                                           PVRSRV_BRIDGE_OUT_HEAPCFGHEAPCOUNT *psHeapCfgHeapCountOUT,
1403                                          CONNECTION_DATA *psConnection)
1404 {
1405         IMG_HANDLE hDeviceNodeInt = IMG_NULL;
1406
1407
1408
1409
1410
1411
1412
1413                                 {
1414                                         /* Look up the address from the handle */
1415                                         psHeapCfgHeapCountOUT->eError =
1416                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
1417                                                                                         (IMG_VOID **) &hDeviceNodeInt,
1418                                                                                         psHeapCfgHeapCountIN->hDeviceNode,
1419                                                                                         PVRSRV_HANDLE_TYPE_DEV_NODE);
1420                                         if(psHeapCfgHeapCountOUT->eError != PVRSRV_OK)
1421                                         {
1422                                                 goto HeapCfgHeapCount_exit;
1423                                         }
1424                                 }
1425
1426
1427         psHeapCfgHeapCountOUT->eError =
1428                 HeapCfgHeapCount(
1429                                         hDeviceNodeInt,
1430                                         psHeapCfgHeapCountIN->ui32HeapConfigIndex,
1431                                         &psHeapCfgHeapCountOUT->ui32NumHeaps);
1432
1433
1434
1435
1436 HeapCfgHeapCount_exit:
1437
1438         return 0;
1439 }
1440
1441 static IMG_INT
1442 PVRSRVBridgeHeapCfgHeapConfigName(IMG_UINT32 ui32DispatchTableEntry,
1443                                           PVRSRV_BRIDGE_IN_HEAPCFGHEAPCONFIGNAME *psHeapCfgHeapConfigNameIN,
1444                                           PVRSRV_BRIDGE_OUT_HEAPCFGHEAPCONFIGNAME *psHeapCfgHeapConfigNameOUT,
1445                                          CONNECTION_DATA *psConnection)
1446 {
1447         IMG_HANDLE hDeviceNodeInt = IMG_NULL;
1448         IMG_CHAR *puiHeapConfigNameInt = IMG_NULL;
1449
1450
1451         psHeapCfgHeapConfigNameOUT->puiHeapConfigName = psHeapCfgHeapConfigNameIN->puiHeapConfigName;
1452
1453
1454         if (psHeapCfgHeapConfigNameIN->ui32HeapConfigNameBufSz != 0)
1455         {
1456                 puiHeapConfigNameInt = OSAllocMem(psHeapCfgHeapConfigNameIN->ui32HeapConfigNameBufSz * sizeof(IMG_CHAR));
1457                 if (!puiHeapConfigNameInt)
1458                 {
1459                         psHeapCfgHeapConfigNameOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1460         
1461                         goto HeapCfgHeapConfigName_exit;
1462                 }
1463         }
1464
1465
1466
1467
1468                                 {
1469                                         /* Look up the address from the handle */
1470                                         psHeapCfgHeapConfigNameOUT->eError =
1471                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
1472                                                                                         (IMG_VOID **) &hDeviceNodeInt,
1473                                                                                         psHeapCfgHeapConfigNameIN->hDeviceNode,
1474                                                                                         PVRSRV_HANDLE_TYPE_DEV_NODE);
1475                                         if(psHeapCfgHeapConfigNameOUT->eError != PVRSRV_OK)
1476                                         {
1477                                                 goto HeapCfgHeapConfigName_exit;
1478                                         }
1479                                 }
1480
1481
1482         psHeapCfgHeapConfigNameOUT->eError =
1483                 HeapCfgHeapConfigName(
1484                                         hDeviceNodeInt,
1485                                         psHeapCfgHeapConfigNameIN->ui32HeapConfigIndex,
1486                                         psHeapCfgHeapConfigNameIN->ui32HeapConfigNameBufSz,
1487                                         puiHeapConfigNameInt);
1488
1489
1490
1491         if ( !OSAccessOK(PVR_VERIFY_WRITE, (IMG_VOID*) psHeapCfgHeapConfigNameOUT->puiHeapConfigName, (psHeapCfgHeapConfigNameIN->ui32HeapConfigNameBufSz * sizeof(IMG_CHAR))) 
1492                 || (OSCopyToUser(NULL, psHeapCfgHeapConfigNameOUT->puiHeapConfigName, puiHeapConfigNameInt,
1493                 (psHeapCfgHeapConfigNameIN->ui32HeapConfigNameBufSz * sizeof(IMG_CHAR))) != PVRSRV_OK) )
1494         {
1495                 psHeapCfgHeapConfigNameOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1496
1497                 goto HeapCfgHeapConfigName_exit;
1498         }
1499
1500
1501 HeapCfgHeapConfigName_exit:
1502         if (puiHeapConfigNameInt)
1503                 OSFreeMem(puiHeapConfigNameInt);
1504
1505         return 0;
1506 }
1507
1508 static IMG_INT
1509 PVRSRVBridgeHeapCfgHeapDetails(IMG_UINT32 ui32DispatchTableEntry,
1510                                           PVRSRV_BRIDGE_IN_HEAPCFGHEAPDETAILS *psHeapCfgHeapDetailsIN,
1511                                           PVRSRV_BRIDGE_OUT_HEAPCFGHEAPDETAILS *psHeapCfgHeapDetailsOUT,
1512                                          CONNECTION_DATA *psConnection)
1513 {
1514         IMG_HANDLE hDeviceNodeInt = IMG_NULL;
1515         IMG_CHAR *puiHeapNameOutInt = IMG_NULL;
1516
1517
1518         psHeapCfgHeapDetailsOUT->puiHeapNameOut = psHeapCfgHeapDetailsIN->puiHeapNameOut;
1519
1520
1521         if (psHeapCfgHeapDetailsIN->ui32HeapNameBufSz != 0)
1522         {
1523                 puiHeapNameOutInt = OSAllocMem(psHeapCfgHeapDetailsIN->ui32HeapNameBufSz * sizeof(IMG_CHAR));
1524                 if (!puiHeapNameOutInt)
1525                 {
1526                         psHeapCfgHeapDetailsOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1527         
1528                         goto HeapCfgHeapDetails_exit;
1529                 }
1530         }
1531
1532
1533
1534
1535                                 {
1536                                         /* Look up the address from the handle */
1537                                         psHeapCfgHeapDetailsOUT->eError =
1538                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
1539                                                                                         (IMG_VOID **) &hDeviceNodeInt,
1540                                                                                         psHeapCfgHeapDetailsIN->hDeviceNode,
1541                                                                                         PVRSRV_HANDLE_TYPE_DEV_NODE);
1542                                         if(psHeapCfgHeapDetailsOUT->eError != PVRSRV_OK)
1543                                         {
1544                                                 goto HeapCfgHeapDetails_exit;
1545                                         }
1546                                 }
1547
1548
1549         psHeapCfgHeapDetailsOUT->eError =
1550                 HeapCfgHeapDetails(
1551                                         hDeviceNodeInt,
1552                                         psHeapCfgHeapDetailsIN->ui32HeapConfigIndex,
1553                                         psHeapCfgHeapDetailsIN->ui32HeapIndex,
1554                                         psHeapCfgHeapDetailsIN->ui32HeapNameBufSz,
1555                                         puiHeapNameOutInt,
1556                                         &psHeapCfgHeapDetailsOUT->sDevVAddrBase,
1557                                         &psHeapCfgHeapDetailsOUT->uiHeapLength,
1558                                         &psHeapCfgHeapDetailsOUT->ui32Log2DataPageSizeOut,
1559                                         &psHeapCfgHeapDetailsOUT->ui32Log2ImportAlignmentOut);
1560
1561
1562
1563         if ( !OSAccessOK(PVR_VERIFY_WRITE, (IMG_VOID*) psHeapCfgHeapDetailsOUT->puiHeapNameOut, (psHeapCfgHeapDetailsIN->ui32HeapNameBufSz * sizeof(IMG_CHAR))) 
1564                 || (OSCopyToUser(NULL, psHeapCfgHeapDetailsOUT->puiHeapNameOut, puiHeapNameOutInt,
1565                 (psHeapCfgHeapDetailsIN->ui32HeapNameBufSz * sizeof(IMG_CHAR))) != PVRSRV_OK) )
1566         {
1567                 psHeapCfgHeapDetailsOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1568
1569                 goto HeapCfgHeapDetails_exit;
1570         }
1571
1572
1573 HeapCfgHeapDetails_exit:
1574         if (puiHeapNameOutInt)
1575                 OSFreeMem(puiHeapNameOutInt);
1576
1577         return 0;
1578 }
1579
1580
1581
1582 /* *************************************************************************** 
1583  * Server bridge dispatch related glue 
1584  */
1585
1586
1587 PVRSRV_ERROR InitMMBridge(IMG_VOID);
1588 PVRSRV_ERROR DeinitMMBridge(IMG_VOID);
1589
1590 /*
1591  * Register all MM functions with services
1592  */
1593 PVRSRV_ERROR InitMMBridge(IMG_VOID)
1594 {
1595
1596         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_PMREXPORTPMR, PVRSRVBridgePMRExportPMR,
1597                                         IMG_NULL, IMG_NULL,
1598                                         0, 0);
1599
1600         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_PMRUNEXPORTPMR, PVRSRVBridgePMRUnexportPMR,
1601                                         IMG_NULL, IMG_NULL,
1602                                         0, 0);
1603
1604         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_PMRGETUID, PVRSRVBridgePMRGetUID,
1605                                         IMG_NULL, IMG_NULL,
1606                                         0, 0);
1607
1608         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_PMRMAKESERVEREXPORTCLIENTEXPORT, PVRSRVBridgePMRMakeServerExportClientExport,
1609                                         IMG_NULL, IMG_NULL,
1610                                         0, 0);
1611
1612         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_PMRUNMAKESERVEREXPORTCLIENTEXPORT, PVRSRVBridgePMRUnmakeServerExportClientExport,
1613                                         IMG_NULL, IMG_NULL,
1614                                         0, 0);
1615
1616         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_PMRIMPORTPMR, PVRSRVBridgePMRImportPMR,
1617                                         IMG_NULL, IMG_NULL,
1618                                         0, 0);
1619
1620         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_DEVMEMINTCTXCREATE, PVRSRVBridgeDevmemIntCtxCreate,
1621                                         IMG_NULL, IMG_NULL,
1622                                         0, 0);
1623
1624         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_DEVMEMINTCTXDESTROY, PVRSRVBridgeDevmemIntCtxDestroy,
1625                                         IMG_NULL, IMG_NULL,
1626                                         0, 0);
1627
1628         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_DEVMEMINTHEAPCREATE, PVRSRVBridgeDevmemIntHeapCreate,
1629                                         IMG_NULL, IMG_NULL,
1630                                         0, 0);
1631
1632         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_DEVMEMINTHEAPDESTROY, PVRSRVBridgeDevmemIntHeapDestroy,
1633                                         IMG_NULL, IMG_NULL,
1634                                         0, 0);
1635
1636         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_DEVMEMINTMAPPMR, PVRSRVBridgeDevmemIntMapPMR,
1637                                         IMG_NULL, IMG_NULL,
1638                                         0, 0);
1639
1640         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_DEVMEMINTUNMAPPMR, PVRSRVBridgeDevmemIntUnmapPMR,
1641                                         IMG_NULL, IMG_NULL,
1642                                         0, 0);
1643
1644         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_DEVMEMINTRESERVERANGE, PVRSRVBridgeDevmemIntReserveRange,
1645                                         IMG_NULL, IMG_NULL,
1646                                         0, 0);
1647
1648         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_DEVMEMINTUNRESERVERANGE, PVRSRVBridgeDevmemIntUnreserveRange,
1649                                         IMG_NULL, IMG_NULL,
1650                                         0, 0);
1651
1652         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_PHYSMEMNEWRAMBACKEDPMR, PVRSRVBridgePhysmemNewRamBackedPMR,
1653                                         IMG_NULL, IMG_NULL,
1654                                         0, 0);
1655
1656         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_PMRLOCALIMPORTPMR, PVRSRVBridgePMRLocalImportPMR,
1657                                         IMG_NULL, IMG_NULL,
1658                                         0, 0);
1659
1660         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_PMRUNREFPMR, PVRSRVBridgePMRUnrefPMR,
1661                                         IMG_NULL, IMG_NULL,
1662                                         0, 0);
1663
1664         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_DEVMEMSLCFLUSHINVALREQUEST, PVRSRVBridgeDevmemSLCFlushInvalRequest,
1665                                         IMG_NULL, IMG_NULL,
1666                                         0, 0);
1667
1668         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_DEVMEMISVDEVADDRVALID, PVRSRVBridgeDevmemIsVDevAddrValid,
1669                                         IMG_NULL, IMG_NULL,
1670                                         0, 0);
1671
1672         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_HEAPCFGHEAPCONFIGCOUNT, PVRSRVBridgeHeapCfgHeapConfigCount,
1673                                         IMG_NULL, IMG_NULL,
1674                                         0, 0);
1675
1676         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_HEAPCFGHEAPCOUNT, PVRSRVBridgeHeapCfgHeapCount,
1677                                         IMG_NULL, IMG_NULL,
1678                                         0, 0);
1679
1680         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_HEAPCFGHEAPCONFIGNAME, PVRSRVBridgeHeapCfgHeapConfigName,
1681                                         IMG_NULL, IMG_NULL,
1682                                         0, 0);
1683
1684         SetDispatchTableEntry(PVRSRV_BRIDGE_MM, PVRSRV_BRIDGE_MM_HEAPCFGHEAPDETAILS, PVRSRVBridgeHeapCfgHeapDetails,
1685                                         IMG_NULL, IMG_NULL,
1686                                         0, 0);
1687
1688
1689         return PVRSRV_OK;
1690 }
1691
1692 /*
1693  * Unregister all mm functions with services
1694  */
1695 PVRSRV_ERROR DeinitMMBridge(IMG_VOID)
1696 {
1697         return PVRSRV_OK;
1698 }
1699