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.h"
51 #include "devicemem_server.h"
53 #include "devicemem_heapcfg.h"
57 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRExportPMR(IMG_HANDLE hBridge,
59 IMG_HANDLE *phPMRExport,
60 IMG_UINT64 *pui64Size,
61 IMG_UINT32 *pui32Log2Contig,
62 IMG_UINT64 *pui64Password)
66 PMR_EXPORT * psPMRExportInt;
67 PVR_UNREFERENCED_PARAMETER(hBridge);
69 psPMRInt = (PMR *) hPMR;
79 *phPMRExport = psPMRExportInt;
83 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRUnexportPMR(IMG_HANDLE hBridge,
84 IMG_HANDLE hPMRExport)
87 PMR_EXPORT * psPMRExportInt;
88 PVR_UNREFERENCED_PARAMETER(hBridge);
90 psPMRExportInt = (PMR_EXPORT *) hPMRExport;
99 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRGetUID(IMG_HANDLE hBridge,
101 IMG_UINT64 *pui64UID)
105 PVR_UNREFERENCED_PARAMETER(hBridge);
107 psPMRInt = (PMR *) hPMR;
117 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRMakeLocalImportHandle(IMG_HANDLE hBridge,
119 IMG_HANDLE *phExtMem)
124 PVR_UNREFERENCED_PARAMETER(hBridge);
126 psBufferInt = (PMR *) hBuffer;
129 PMRMakeLocalImportHandle(
133 *phExtMem = psExtMemInt;
137 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRUnmakeLocalImportHandle(IMG_HANDLE hBridge,
142 PVR_UNREFERENCED_PARAMETER(hBridge);
144 psExtMemInt = (PMR *) hExtMem;
147 PMRUnmakeLocalImportHandle(
153 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRImportPMR(IMG_HANDLE hBridge,
154 IMG_HANDLE hPMRExport,
155 IMG_UINT64 ui64uiPassword,
156 IMG_UINT64 ui64uiSize,
157 IMG_UINT32 ui32uiLog2Contig,
161 PMR_EXPORT * psPMRExportInt;
164 psPMRExportInt = (PMR_EXPORT *) hPMRExport;
167 PMRImportPMR(NULL, (PVRSRV_DEVICE_NODE *)((void*) hBridge)
179 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRLocalImportPMR(IMG_HANDLE hBridge,
180 IMG_HANDLE hExtHandle,
182 IMG_DEVMEM_SIZE_T *puiSize,
183 IMG_DEVMEM_ALIGN_T *psAlign)
186 PMR * psExtHandleInt;
188 PVR_UNREFERENCED_PARAMETER(hBridge);
190 psExtHandleInt = (PMR *) hExtHandle;
203 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRUnrefPMR(IMG_HANDLE hBridge,
208 PVR_UNREFERENCED_PARAMETER(hBridge);
210 psPMRInt = (PMR *) hPMR;
219 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePMRUnrefUnlockPMR(IMG_HANDLE hBridge,
224 PVR_UNREFERENCED_PARAMETER(hBridge);
226 psPMRInt = (PMR *) hPMR;
235 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePhysmemNewRamBackedPMR(IMG_HANDLE hBridge,
236 IMG_DEVMEM_SIZE_T uiSize,
237 IMG_DEVMEM_SIZE_T uiChunkSize,
238 IMG_UINT32 ui32NumPhysChunks,
239 IMG_UINT32 ui32NumVirtChunks,
240 IMG_UINT32 *pui32MappingTable,
241 IMG_UINT32 ui32Log2PageSize,
242 PVRSRV_MEMALLOCFLAGS_T uiFlags,
243 IMG_UINT32 ui32AnnotationLength,
244 const IMG_CHAR *puiAnnotation,
245 IMG_HANDLE *phPMRPtr)
252 PhysmemNewRamBackedPMR(NULL, (PVRSRV_DEVICE_NODE *)((void*) hBridge)
261 ui32AnnotationLength,
265 *phPMRPtr = psPMRPtrInt;
269 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgePhysmemNewRamBackedLockedPMR(IMG_HANDLE hBridge,
270 IMG_DEVMEM_SIZE_T uiSize,
271 IMG_DEVMEM_SIZE_T uiChunkSize,
272 IMG_UINT32 ui32NumPhysChunks,
273 IMG_UINT32 ui32NumVirtChunks,
274 IMG_UINT32 *pui32MappingTable,
275 IMG_UINT32 ui32Log2PageSize,
276 PVRSRV_MEMALLOCFLAGS_T uiFlags,
277 IMG_UINT32 ui32AnnotationLength,
278 const IMG_CHAR *puiAnnotation,
279 IMG_HANDLE *phPMRPtr)
286 PhysmemNewRamBackedLockedPMR(NULL, (PVRSRV_DEVICE_NODE *)((void*) hBridge)
295 ui32AnnotationLength,
299 *phPMRPtr = psPMRPtrInt;
303 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntPin(IMG_HANDLE hBridge,
308 PVR_UNREFERENCED_PARAMETER(hBridge);
310 psPMRInt = (PMR *) hPMR;
319 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntUnpin(IMG_HANDLE hBridge,
324 PVR_UNREFERENCED_PARAMETER(hBridge);
326 psPMRInt = (PMR *) hPMR;
335 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntPinValidate(IMG_HANDLE hBridge,
340 DEVMEMINT_MAPPING * psMappingInt;
342 PVR_UNREFERENCED_PARAMETER(hBridge);
344 psMappingInt = (DEVMEMINT_MAPPING *) hMapping;
345 psPMRInt = (PMR *) hPMR;
348 DevmemIntPinValidate(
355 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntUnpinInvalidate(IMG_HANDLE hBridge,
360 DEVMEMINT_MAPPING * psMappingInt;
362 PVR_UNREFERENCED_PARAMETER(hBridge);
364 psMappingInt = (DEVMEMINT_MAPPING *) hMapping;
365 psPMRInt = (PMR *) hPMR;
368 DevmemIntUnpinInvalidate(
375 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntCtxCreate(IMG_HANDLE hBridge,
376 IMG_BOOL bbKernelMemoryCtx,
377 IMG_HANDLE *phDevMemServerContext,
378 IMG_HANDLE *phPrivData,
379 IMG_UINT32 *pui32CPUCacheLineSize)
382 DEVMEMINT_CTX * psDevMemServerContextInt;
383 IMG_HANDLE hPrivDataInt;
387 DevmemIntCtxCreate(NULL, (PVRSRV_DEVICE_NODE *)((void*) hBridge)
390 &psDevMemServerContextInt,
392 pui32CPUCacheLineSize);
394 *phDevMemServerContext = psDevMemServerContextInt;
395 *phPrivData = hPrivDataInt;
399 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntCtxDestroy(IMG_HANDLE hBridge,
400 IMG_HANDLE hDevmemServerContext)
403 DEVMEMINT_CTX * psDevmemServerContextInt;
404 PVR_UNREFERENCED_PARAMETER(hBridge);
406 psDevmemServerContextInt = (DEVMEMINT_CTX *) hDevmemServerContext;
410 psDevmemServerContextInt);
415 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntHeapCreate(IMG_HANDLE hBridge,
416 IMG_HANDLE hDevmemCtx,
417 IMG_DEV_VIRTADDR sHeapBaseAddr,
418 IMG_DEVMEM_SIZE_T uiHeapLength,
419 IMG_UINT32 ui32Log2DataPageSize,
420 IMG_HANDLE *phDevmemHeapPtr)
423 DEVMEMINT_CTX * psDevmemCtxInt;
424 DEVMEMINT_HEAP * psDevmemHeapPtrInt;
425 PVR_UNREFERENCED_PARAMETER(hBridge);
427 psDevmemCtxInt = (DEVMEMINT_CTX *) hDevmemCtx;
434 ui32Log2DataPageSize,
435 &psDevmemHeapPtrInt);
437 *phDevmemHeapPtr = psDevmemHeapPtrInt;
441 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntHeapDestroy(IMG_HANDLE hBridge,
442 IMG_HANDLE hDevmemHeap)
445 DEVMEMINT_HEAP * psDevmemHeapInt;
446 PVR_UNREFERENCED_PARAMETER(hBridge);
448 psDevmemHeapInt = (DEVMEMINT_HEAP *) hDevmemHeap;
451 DevmemIntHeapDestroy(
457 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntMapPMR(IMG_HANDLE hBridge,
458 IMG_HANDLE hDevmemServerHeap,
459 IMG_HANDLE hReservation,
461 PVRSRV_MEMALLOCFLAGS_T uiMapFlags,
462 IMG_HANDLE *phMapping)
465 DEVMEMINT_HEAP * psDevmemServerHeapInt;
466 DEVMEMINT_RESERVATION * psReservationInt;
468 DEVMEMINT_MAPPING * psMappingInt;
469 PVR_UNREFERENCED_PARAMETER(hBridge);
471 psDevmemServerHeapInt = (DEVMEMINT_HEAP *) hDevmemServerHeap;
472 psReservationInt = (DEVMEMINT_RESERVATION *) hReservation;
473 psPMRInt = (PMR *) hPMR;
477 psDevmemServerHeapInt,
483 *phMapping = psMappingInt;
487 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntUnmapPMR(IMG_HANDLE hBridge,
491 DEVMEMINT_MAPPING * psMappingInt;
492 PVR_UNREFERENCED_PARAMETER(hBridge);
494 psMappingInt = (DEVMEMINT_MAPPING *) hMapping;
503 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntReserveRange(IMG_HANDLE hBridge,
504 IMG_HANDLE hDevmemServerHeap,
505 IMG_DEV_VIRTADDR sAddress,
506 IMG_DEVMEM_SIZE_T uiLength,
507 IMG_HANDLE *phReservation)
510 DEVMEMINT_HEAP * psDevmemServerHeapInt;
511 DEVMEMINT_RESERVATION * psReservationInt;
512 PVR_UNREFERENCED_PARAMETER(hBridge);
514 psDevmemServerHeapInt = (DEVMEMINT_HEAP *) hDevmemServerHeap;
517 DevmemIntReserveRange(
518 psDevmemServerHeapInt,
523 *phReservation = psReservationInt;
527 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntUnreserveRange(IMG_HANDLE hBridge,
528 IMG_HANDLE hReservation)
531 DEVMEMINT_RESERVATION * psReservationInt;
532 PVR_UNREFERENCED_PARAMETER(hBridge);
534 psReservationInt = (DEVMEMINT_RESERVATION *) hReservation;
537 DevmemIntUnreserveRange(
543 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeChangeSparseMem(IMG_HANDLE hBridge,
544 IMG_HANDLE hSrvDevMemHeap,
546 IMG_UINT32 ui32AllocPageCount,
547 IMG_UINT32 *pui32AllocPageIndices,
548 IMG_UINT32 ui32FreePageCount,
549 IMG_UINT32 *pui32FreePageIndices,
550 IMG_UINT32 ui32SparseFlags,
551 PVRSRV_MEMALLOCFLAGS_T uiFlags,
552 IMG_DEV_VIRTADDR sDevVAddr,
553 IMG_UINT64 ui64CPUVAddr)
556 DEVMEMINT_HEAP * psSrvDevMemHeapInt;
558 PVR_UNREFERENCED_PARAMETER(hBridge);
560 psSrvDevMemHeapInt = (DEVMEMINT_HEAP *) hSrvDevMemHeap;
561 psPMRInt = (PMR *) hPMR;
564 DevmemIntChangeSparse(
568 pui32AllocPageIndices,
570 pui32FreePageIndices,
579 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntMapPages(IMG_HANDLE hBridge,
580 IMG_HANDLE hReservation,
582 IMG_UINT32 ui32PageCount,
583 IMG_UINT32 ui32PhysicalPgOffset,
584 PVRSRV_MEMALLOCFLAGS_T uiFlags,
585 IMG_DEV_VIRTADDR sDevVAddr)
588 DEVMEMINT_RESERVATION * psReservationInt;
590 PVR_UNREFERENCED_PARAMETER(hBridge);
592 psReservationInt = (DEVMEMINT_RESERVATION *) hReservation;
593 psPMRInt = (PMR *) hPMR;
600 ui32PhysicalPgOffset,
607 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntUnmapPages(IMG_HANDLE hBridge,
608 IMG_HANDLE hReservation,
609 IMG_DEV_VIRTADDR sDevVAddr,
610 IMG_UINT32 ui32PageCount)
613 DEVMEMINT_RESERVATION * psReservationInt;
614 PVR_UNREFERENCED_PARAMETER(hBridge);
616 psReservationInt = (DEVMEMINT_RESERVATION *) hReservation;
627 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIsVDevAddrValid(IMG_HANDLE hBridge,
628 IMG_HANDLE hDevmemCtx,
629 IMG_DEV_VIRTADDR sAddress)
632 DEVMEMINT_CTX * psDevmemCtxInt;
634 psDevmemCtxInt = (DEVMEMINT_CTX *) hDevmemCtx;
637 DevmemIntIsVDevAddrValid(NULL, (PVRSRV_DEVICE_NODE *)((void*) hBridge)
645 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeHeapCfgHeapConfigCount(IMG_HANDLE hBridge,
646 IMG_UINT32 *pui32NumHeapConfigs)
652 HeapCfgHeapConfigCount(NULL, (PVRSRV_DEVICE_NODE *)((void*) hBridge)
654 pui32NumHeapConfigs);
659 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeHeapCfgHeapCount(IMG_HANDLE hBridge,
660 IMG_UINT32 ui32HeapConfigIndex,
661 IMG_UINT32 *pui32NumHeaps)
667 HeapCfgHeapCount(NULL, (PVRSRV_DEVICE_NODE *)((void*) hBridge)
675 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeHeapCfgHeapConfigName(IMG_HANDLE hBridge,
676 IMG_UINT32 ui32HeapConfigIndex,
677 IMG_UINT32 ui32HeapConfigNameBufSz,
678 IMG_CHAR *puiHeapConfigName)
684 HeapCfgHeapConfigName(NULL, (PVRSRV_DEVICE_NODE *)((void*) hBridge)
687 ui32HeapConfigNameBufSz,
693 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeHeapCfgHeapDetails(IMG_HANDLE hBridge,
694 IMG_UINT32 ui32HeapConfigIndex,
695 IMG_UINT32 ui32HeapIndex,
696 IMG_UINT32 ui32HeapNameBufSz,
697 IMG_CHAR *puiHeapNameOut,
698 IMG_DEV_VIRTADDR *psDevVAddrBase,
699 IMG_DEVMEM_SIZE_T *puiHeapLength,
700 IMG_UINT32 *pui32Log2DataPageSizeOut,
701 IMG_UINT32 *pui32Log2ImportAlignmentOut)
707 HeapCfgHeapDetails(NULL, (PVRSRV_DEVICE_NODE *)((void*) hBridge)
715 pui32Log2DataPageSizeOut,
716 pui32Log2ImportAlignmentOut);
721 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeDevmemIntRegisterPFNotifyKM(IMG_HANDLE hBridge,
722 IMG_HANDLE hDevmemCtx,
727 DEVMEMINT_CTX * psDevmemCtxInt;
728 PVR_UNREFERENCED_PARAMETER(hBridge);
730 psDevmemCtxInt = (DEVMEMINT_CTX *) hDevmemCtx;
733 DevmemIntRegisterPFNotifyKM(