1 /*************************************************************************/ /*!
2 @Title Direct client bridge for mm
3 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @License Dual MIT/GPLv2
6 The contents of this file are subject to the MIT license as set out below.
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
18 Alternatively, the contents of this file may be used under the terms of
19 the GNU General Public License Version 2 ("GPL") in which case the provisions
20 of GPL are applicable instead of those above.
22 If you wish to allow use of your version of this file only under the terms of
23 GPL, and not to allow others to use your version of this file under the terms
24 of the MIT license, indicate your decision by deleting the provisions above
25 and replace them with the notice and other provisions required by GPL as set
26 out in the file called "GPL-COPYING" included in this distribution. If you do
27 not delete the provisions above, a recipient may use your version of this file
28 under the terms of either the MIT license or GPL.
30 This License is also included in this distribution in the file called
33 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
34 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
35 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
37 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 */ /**************************************************************************/
42 #include "client_mm_bridge.h"
44 #include "pvr_debug.h"
46 /* Module specific includes */
47 #include "pvrsrv_memallocflags.h"
48 #include "devicemem_typedefs.h"
50 #include "devicemem_server.h"
52 #include "devicemem_heapcfg.h"
56 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRExportPMR(IMG_HANDLE hBridge,
58 IMG_HANDLE *phPMRExport,
59 IMG_UINT64 *pui64Size,
60 IMG_UINT32 *pui32Log2Contig,
61 IMG_UINT64 *pui64Password)
65 PMR_EXPORT * psPMRExportInt;
66 PVR_UNREFERENCED_PARAMETER(hBridge);
68 psPMRInt = (PMR *) hPMR;
78 *phPMRExport = psPMRExportInt;
82 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRUnexportPMR(IMG_HANDLE hBridge,
83 IMG_HANDLE hPMRExport)
86 PMR_EXPORT * psPMRExportInt;
87 PVR_UNREFERENCED_PARAMETER(hBridge);
89 psPMRExportInt = (PMR_EXPORT *) hPMRExport;
98 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRGetUID(IMG_HANDLE hBridge,
100 IMG_UINT64 *pui64UID)
104 PVR_UNREFERENCED_PARAMETER(hBridge);
106 psPMRInt = (PMR *) hPMR;
116 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRMakeServerExportClientExport(IMG_HANDLE hBridge,
117 DEVMEM_SERVER_EXPORTCOOKIE hPMRServerExport,
118 IMG_HANDLE *phPMRExportOut,
119 IMG_UINT64 *pui64Size,
120 IMG_UINT32 *pui32Log2Contig,
121 IMG_UINT64 *pui64Password)
124 DEVMEM_EXPORTCOOKIE * psPMRServerExportInt;
125 PMR_EXPORT * psPMRExportOutInt;
126 PVR_UNREFERENCED_PARAMETER(hBridge);
128 psPMRServerExportInt = (DEVMEM_EXPORTCOOKIE *) hPMRServerExport;
131 PMRMakeServerExportClientExport(
132 psPMRServerExportInt,
138 *phPMRExportOut = psPMRExportOutInt;
142 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRUnmakeServerExportClientExport(IMG_HANDLE hBridge,
143 IMG_HANDLE hPMRExport)
146 PMR_EXPORT * psPMRExportInt;
147 PVR_UNREFERENCED_PARAMETER(hBridge);
149 psPMRExportInt = (PMR_EXPORT *) hPMRExport;
152 PMRUnmakeServerExportClientExport(
158 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRImportPMR(IMG_HANDLE hBridge,
159 IMG_HANDLE hPMRExport,
160 IMG_UINT64 ui64uiPassword,
161 IMG_UINT64 ui64uiSize,
162 IMG_UINT32 ui32uiLog2Contig,
166 PMR_EXPORT * psPMRExportInt;
168 PVR_UNREFERENCED_PARAMETER(hBridge);
170 psPMRExportInt = (PMR_EXPORT *) hPMRExport;
184 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntCtxCreate(IMG_HANDLE hBridge,
185 IMG_HANDLE hDeviceNode,
186 IMG_HANDLE *phDevMemServerContext,
187 IMG_HANDLE *phPrivData)
190 IMG_HANDLE hDeviceNodeInt;
191 DEVMEMINT_CTX * psDevMemServerContextInt;
192 IMG_HANDLE hPrivDataInt;
193 PVR_UNREFERENCED_PARAMETER(hBridge);
195 hDeviceNodeInt = (IMG_HANDLE) hDeviceNode;
200 &psDevMemServerContextInt,
203 *phDevMemServerContext = psDevMemServerContextInt;
204 *phPrivData = hPrivDataInt;
208 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntCtxDestroy(IMG_HANDLE hBridge,
209 IMG_HANDLE hDevmemServerContext)
212 DEVMEMINT_CTX * psDevmemServerContextInt;
213 PVR_UNREFERENCED_PARAMETER(hBridge);
215 psDevmemServerContextInt = (DEVMEMINT_CTX *) hDevmemServerContext;
219 psDevmemServerContextInt);
224 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntHeapCreate(IMG_HANDLE hBridge,
225 IMG_HANDLE hDevmemCtx,
226 IMG_DEV_VIRTADDR sHeapBaseAddr,
227 IMG_DEVMEM_SIZE_T uiHeapLength,
228 IMG_UINT32 ui32Log2DataPageSize,
229 IMG_HANDLE *phDevmemHeapPtr)
232 DEVMEMINT_CTX * psDevmemCtxInt;
233 DEVMEMINT_HEAP * psDevmemHeapPtrInt;
234 PVR_UNREFERENCED_PARAMETER(hBridge);
236 psDevmemCtxInt = (DEVMEMINT_CTX *) hDevmemCtx;
243 ui32Log2DataPageSize,
244 &psDevmemHeapPtrInt);
246 *phDevmemHeapPtr = psDevmemHeapPtrInt;
250 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntHeapDestroy(IMG_HANDLE hBridge,
251 IMG_HANDLE hDevmemHeap)
254 DEVMEMINT_HEAP * psDevmemHeapInt;
255 PVR_UNREFERENCED_PARAMETER(hBridge);
257 psDevmemHeapInt = (DEVMEMINT_HEAP *) hDevmemHeap;
260 DevmemIntHeapDestroy(
266 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntMapPMR(IMG_HANDLE hBridge,
267 IMG_HANDLE hDevmemServerHeap,
268 IMG_HANDLE hReservation,
270 PVRSRV_MEMALLOCFLAGS_T uiMapFlags,
271 IMG_HANDLE *phMapping)
274 DEVMEMINT_HEAP * psDevmemServerHeapInt;
275 DEVMEMINT_RESERVATION * psReservationInt;
277 DEVMEMINT_MAPPING * psMappingInt;
278 PVR_UNREFERENCED_PARAMETER(hBridge);
280 psDevmemServerHeapInt = (DEVMEMINT_HEAP *) hDevmemServerHeap;
281 psReservationInt = (DEVMEMINT_RESERVATION *) hReservation;
282 psPMRInt = (PMR *) hPMR;
286 psDevmemServerHeapInt,
292 *phMapping = psMappingInt;
296 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntUnmapPMR(IMG_HANDLE hBridge,
300 DEVMEMINT_MAPPING * psMappingInt;
301 PVR_UNREFERENCED_PARAMETER(hBridge);
303 psMappingInt = (DEVMEMINT_MAPPING *) hMapping;
312 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntReserveRange(IMG_HANDLE hBridge,
313 IMG_HANDLE hDevmemServerHeap,
314 IMG_DEV_VIRTADDR sAddress,
315 IMG_DEVMEM_SIZE_T uiLength,
316 IMG_HANDLE *phReservation)
319 DEVMEMINT_HEAP * psDevmemServerHeapInt;
320 DEVMEMINT_RESERVATION * psReservationInt;
321 PVR_UNREFERENCED_PARAMETER(hBridge);
323 psDevmemServerHeapInt = (DEVMEMINT_HEAP *) hDevmemServerHeap;
326 DevmemIntReserveRange(
327 psDevmemServerHeapInt,
332 *phReservation = psReservationInt;
336 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntUnreserveRange(IMG_HANDLE hBridge,
337 IMG_HANDLE hReservation)
340 DEVMEMINT_RESERVATION * psReservationInt;
341 PVR_UNREFERENCED_PARAMETER(hBridge);
343 psReservationInt = (DEVMEMINT_RESERVATION *) hReservation;
346 DevmemIntUnreserveRange(
352 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePhysmemNewRamBackedPMR(IMG_HANDLE hBridge,
353 IMG_HANDLE hDeviceNode,
354 IMG_DEVMEM_SIZE_T uiSize,
355 IMG_DEVMEM_SIZE_T uiChunkSize,
356 IMG_UINT32 ui32NumPhysChunks,
357 IMG_UINT32 ui32NumVirtChunks,
358 IMG_BOOL *pbMappingTable,
359 IMG_UINT32 ui32Log2PageSize,
360 PVRSRV_MEMALLOCFLAGS_T uiFlags,
361 IMG_HANDLE *phPMRPtr)
364 IMG_HANDLE hDeviceNodeInt;
366 PVR_UNREFERENCED_PARAMETER(hBridge);
368 hDeviceNodeInt = (IMG_HANDLE) hDeviceNode;
371 PhysmemNewRamBackedPMR(
382 *phPMRPtr = psPMRPtrInt;
386 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRLocalImportPMR(IMG_HANDLE hBridge,
387 IMG_HANDLE hExtHandle,
389 IMG_DEVMEM_SIZE_T *puiSize,
390 IMG_DEVMEM_ALIGN_T *psAlign)
393 PMR * psExtHandleInt;
395 PVR_UNREFERENCED_PARAMETER(hBridge);
397 psExtHandleInt = (PMR *) hExtHandle;
410 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRUnrefPMR(IMG_HANDLE hBridge,
415 PVR_UNREFERENCED_PARAMETER(hBridge);
417 psPMRInt = (PMR *) hPMR;
426 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemSLCFlushInvalRequest(IMG_HANDLE hBridge,
427 IMG_HANDLE hDeviceNode,
431 IMG_HANDLE hDeviceNodeInt;
433 PVR_UNREFERENCED_PARAMETER(hBridge);
435 hDeviceNodeInt = (IMG_HANDLE) hDeviceNode;
436 psPmrInt = (PMR *) hPmr;
439 DevmemSLCFlushInvalRequest(
446 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIsVDevAddrValid(IMG_HANDLE hBridge,
447 IMG_HANDLE hDevmemCtx,
448 IMG_DEV_VIRTADDR sAddress)
451 DEVMEMINT_CTX * psDevmemCtxInt;
452 PVR_UNREFERENCED_PARAMETER(hBridge);
454 psDevmemCtxInt = (DEVMEMINT_CTX *) hDevmemCtx;
457 DevmemIntIsVDevAddrValid(
464 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeHeapCfgHeapConfigCount(IMG_HANDLE hBridge,
465 IMG_HANDLE hDeviceNode,
466 IMG_UINT32 *pui32NumHeapConfigs)
469 IMG_HANDLE hDeviceNodeInt;
470 PVR_UNREFERENCED_PARAMETER(hBridge);
472 hDeviceNodeInt = (IMG_HANDLE) hDeviceNode;
475 HeapCfgHeapConfigCount(
477 pui32NumHeapConfigs);
482 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeHeapCfgHeapCount(IMG_HANDLE hBridge,
483 IMG_HANDLE hDeviceNode,
484 IMG_UINT32 ui32HeapConfigIndex,
485 IMG_UINT32 *pui32NumHeaps)
488 IMG_HANDLE hDeviceNodeInt;
489 PVR_UNREFERENCED_PARAMETER(hBridge);
491 hDeviceNodeInt = (IMG_HANDLE) hDeviceNode;
502 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeHeapCfgHeapConfigName(IMG_HANDLE hBridge,
503 IMG_HANDLE hDeviceNode,
504 IMG_UINT32 ui32HeapConfigIndex,
505 IMG_UINT32 ui32HeapConfigNameBufSz,
506 IMG_CHAR *puiHeapConfigName)
509 IMG_HANDLE hDeviceNodeInt;
510 PVR_UNREFERENCED_PARAMETER(hBridge);
512 hDeviceNodeInt = (IMG_HANDLE) hDeviceNode;
515 HeapCfgHeapConfigName(
518 ui32HeapConfigNameBufSz,
524 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeHeapCfgHeapDetails(IMG_HANDLE hBridge,
525 IMG_HANDLE hDeviceNode,
526 IMG_UINT32 ui32HeapConfigIndex,
527 IMG_UINT32 ui32HeapIndex,
528 IMG_UINT32 ui32HeapNameBufSz,
529 IMG_CHAR *puiHeapNameOut,
530 IMG_DEV_VIRTADDR *psDevVAddrBase,
531 IMG_DEVMEM_SIZE_T *puiHeapLength,
532 IMG_UINT32 *pui32Log2DataPageSizeOut,
533 IMG_UINT32 *pui32Log2ImportAlignmentOut)
536 IMG_HANDLE hDeviceNodeInt;
537 PVR_UNREFERENCED_PARAMETER(hBridge);
539 hDeviceNodeInt = (IMG_HANDLE) hDeviceNode;
550 pui32Log2DataPageSizeOut,
551 pui32Log2ImportAlignmentOut);