1 /*************************************************************************/ /*!
3 @Title Server bridge for devicememhistory
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Implements the server side of the bridge for devicememhistory
6 @License Dual MIT/GPLv2
8 The contents of this file are subject to the MIT license as set out below.
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
32 This License is also included in this distribution in the file called
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /**************************************************************************/
45 #include <asm/uaccess.h>
49 #include "devicemem_history_server.h"
52 #include "common_devicememhistory_bridge.h"
55 #include "pvr_debug.h"
56 #include "connection_server.h"
57 #include "pvr_bridge.h"
58 #include "rgx_bridge.h"
62 #include <linux/slab.h>
67 #if defined(SUPPORT_DEVICEMEMHISTORY_BRIDGE)
71 /* ***************************************************************************
72 * Server-side bridge entry points
76 PVRSRVBridgeDevicememHistoryMap(IMG_UINT32 ui32DispatchTableEntry,
77 PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYMAP *psDevicememHistoryMapIN,
78 PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYMAP *psDevicememHistoryMapOUT,
79 CONNECTION_DATA *psConnection)
81 IMG_CHAR *uiTextInt = NULL;
83 IMG_UINT32 ui32NextOffset = 0;
84 IMG_BYTE *pArrayArgsBuffer = NULL;
85 #if !defined(INTEGRITY_OS)
86 IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
89 IMG_UINT32 ui32BufferSize =
90 (DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR)) +
94 PVR_UNREFERENCED_PARAMETER(psConnection);
98 if (ui32BufferSize != 0)
100 #if !defined(INTEGRITY_OS)
101 /* Try to use remainder of input buffer for copies if possible, word-aligned for safety. */
102 IMG_UINT32 ui32InBufferOffset = PVR_ALIGN(sizeof(*psDevicememHistoryMapIN), sizeof(unsigned long));
103 IMG_UINT32 ui32InBufferExcessSize = ui32InBufferOffset >= PVRSRV_MAX_BRIDGE_IN_SIZE ? 0 :
104 PVRSRV_MAX_BRIDGE_IN_SIZE - ui32InBufferOffset;
106 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
107 if (bHaveEnoughSpace)
109 IMG_BYTE *pInputBuffer = (IMG_BYTE *)psDevicememHistoryMapIN;
111 pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset]; }
115 pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
117 if(!pArrayArgsBuffer)
119 psDevicememHistoryMapOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
120 goto DevicememHistoryMap_exit;
127 uiTextInt = (IMG_CHAR*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
128 ui32NextOffset += DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR);
131 /* Copy the data over */
132 if (DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR) > 0)
134 if ( OSCopyFromUser(NULL, uiTextInt, psDevicememHistoryMapIN->puiText, DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR)) != PVRSRV_OK )
136 psDevicememHistoryMapOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
138 goto DevicememHistoryMap_exit;
143 psDevicememHistoryMapOUT->eError =
144 DevicememHistoryMapKM(
145 psDevicememHistoryMapIN->sDevVAddr,
146 psDevicememHistoryMapIN->uiSize,
152 DevicememHistoryMap_exit:
156 /* Allocated space should be equal to the last updated offset */
157 PVR_ASSERT(ui32BufferSize == ui32NextOffset);
159 #if defined(INTEGRITY_OS)
162 if(!bHaveEnoughSpace && pArrayArgsBuffer)
164 OSFreeMemNoStats(pArrayArgsBuffer);
172 PVRSRVBridgeDevicememHistoryUnmap(IMG_UINT32 ui32DispatchTableEntry,
173 PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYUNMAP *psDevicememHistoryUnmapIN,
174 PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYUNMAP *psDevicememHistoryUnmapOUT,
175 CONNECTION_DATA *psConnection)
177 IMG_CHAR *uiTextInt = NULL;
179 IMG_UINT32 ui32NextOffset = 0;
180 IMG_BYTE *pArrayArgsBuffer = NULL;
181 #if !defined(INTEGRITY_OS)
182 IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
185 IMG_UINT32 ui32BufferSize =
186 (DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR)) +
190 PVR_UNREFERENCED_PARAMETER(psConnection);
194 if (ui32BufferSize != 0)
196 #if !defined(INTEGRITY_OS)
197 /* Try to use remainder of input buffer for copies if possible, word-aligned for safety. */
198 IMG_UINT32 ui32InBufferOffset = PVR_ALIGN(sizeof(*psDevicememHistoryUnmapIN), sizeof(unsigned long));
199 IMG_UINT32 ui32InBufferExcessSize = ui32InBufferOffset >= PVRSRV_MAX_BRIDGE_IN_SIZE ? 0 :
200 PVRSRV_MAX_BRIDGE_IN_SIZE - ui32InBufferOffset;
202 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
203 if (bHaveEnoughSpace)
205 IMG_BYTE *pInputBuffer = (IMG_BYTE *)psDevicememHistoryUnmapIN;
207 pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset]; }
211 pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
213 if(!pArrayArgsBuffer)
215 psDevicememHistoryUnmapOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
216 goto DevicememHistoryUnmap_exit;
223 uiTextInt = (IMG_CHAR*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
224 ui32NextOffset += DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR);
227 /* Copy the data over */
228 if (DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR) > 0)
230 if ( OSCopyFromUser(NULL, uiTextInt, psDevicememHistoryUnmapIN->puiText, DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR)) != PVRSRV_OK )
232 psDevicememHistoryUnmapOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
234 goto DevicememHistoryUnmap_exit;
239 psDevicememHistoryUnmapOUT->eError =
240 DevicememHistoryUnmapKM(
241 psDevicememHistoryUnmapIN->sDevVAddr,
242 psDevicememHistoryUnmapIN->uiSize,
248 DevicememHistoryUnmap_exit:
252 /* Allocated space should be equal to the last updated offset */
253 PVR_ASSERT(ui32BufferSize == ui32NextOffset);
255 #if defined(INTEGRITY_OS)
258 if(!bHaveEnoughSpace && pArrayArgsBuffer)
260 OSFreeMemNoStats(pArrayArgsBuffer);
268 PVRSRVBridgeDevicememHistoryMapNew(IMG_UINT32 ui32DispatchTableEntry,
269 PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYMAPNEW *psDevicememHistoryMapNewIN,
270 PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYMAPNEW *psDevicememHistoryMapNewOUT,
271 CONNECTION_DATA *psConnection)
273 IMG_HANDLE hPMR = psDevicememHistoryMapNewIN->hPMR;
274 PMR * psPMRInt = NULL;
275 IMG_CHAR *uiTextInt = NULL;
277 IMG_UINT32 ui32NextOffset = 0;
278 IMG_BYTE *pArrayArgsBuffer = NULL;
279 #if !defined(INTEGRITY_OS)
280 IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
283 IMG_UINT32 ui32BufferSize =
284 (DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR)) +
291 if (ui32BufferSize != 0)
293 #if !defined(INTEGRITY_OS)
294 /* Try to use remainder of input buffer for copies if possible, word-aligned for safety. */
295 IMG_UINT32 ui32InBufferOffset = PVR_ALIGN(sizeof(*psDevicememHistoryMapNewIN), sizeof(unsigned long));
296 IMG_UINT32 ui32InBufferExcessSize = ui32InBufferOffset >= PVRSRV_MAX_BRIDGE_IN_SIZE ? 0 :
297 PVRSRV_MAX_BRIDGE_IN_SIZE - ui32InBufferOffset;
299 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
300 if (bHaveEnoughSpace)
302 IMG_BYTE *pInputBuffer = (IMG_BYTE *)psDevicememHistoryMapNewIN;
304 pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset]; }
308 pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
310 if(!pArrayArgsBuffer)
312 psDevicememHistoryMapNewOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
313 goto DevicememHistoryMapNew_exit;
320 uiTextInt = (IMG_CHAR*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
321 ui32NextOffset += DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR);
324 /* Copy the data over */
325 if (DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR) > 0)
327 if ( OSCopyFromUser(NULL, uiTextInt, psDevicememHistoryMapNewIN->puiText, DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR)) != PVRSRV_OK )
329 psDevicememHistoryMapNewOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
331 goto DevicememHistoryMapNew_exit;
335 /* Lock over handle lookup. */
343 /* Look up the address from the handle */
344 psDevicememHistoryMapNewOUT->eError =
345 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
348 PVRSRV_HANDLE_TYPE_PHYSMEM_PMR,
350 if(psDevicememHistoryMapNewOUT->eError != PVRSRV_OK)
353 goto DevicememHistoryMapNew_exit;
356 /* Release now we have looked up handles. */
359 psDevicememHistoryMapNewOUT->eError =
360 DevicememHistoryMapNewKM(
362 psDevicememHistoryMapNewIN->uiOffset,
363 psDevicememHistoryMapNewIN->sDevVAddr,
364 psDevicememHistoryMapNewIN->uiSize,
366 psDevicememHistoryMapNewIN->ui32Log2PageSize,
367 psDevicememHistoryMapNewIN->ui32AllocationIndex,
368 &psDevicememHistoryMapNewOUT->ui32AllocationIndexOut);
373 DevicememHistoryMapNew_exit:
375 /* Lock over handle lookup cleanup. */
384 /* Unreference the previously looked up handle */
387 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
389 PVRSRV_HANDLE_TYPE_PHYSMEM_PMR);
392 /* Release now we have cleaned up look up handles. */
395 /* Allocated space should be equal to the last updated offset */
396 PVR_ASSERT(ui32BufferSize == ui32NextOffset);
398 #if defined(INTEGRITY_OS)
401 if(!bHaveEnoughSpace && pArrayArgsBuffer)
403 OSFreeMemNoStats(pArrayArgsBuffer);
411 PVRSRVBridgeDevicememHistoryUnmapNew(IMG_UINT32 ui32DispatchTableEntry,
412 PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYUNMAPNEW *psDevicememHistoryUnmapNewIN,
413 PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYUNMAPNEW *psDevicememHistoryUnmapNewOUT,
414 CONNECTION_DATA *psConnection)
416 IMG_HANDLE hPMR = psDevicememHistoryUnmapNewIN->hPMR;
417 PMR * psPMRInt = NULL;
418 IMG_CHAR *uiTextInt = NULL;
420 IMG_UINT32 ui32NextOffset = 0;
421 IMG_BYTE *pArrayArgsBuffer = NULL;
422 #if !defined(INTEGRITY_OS)
423 IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
426 IMG_UINT32 ui32BufferSize =
427 (DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR)) +
434 if (ui32BufferSize != 0)
436 #if !defined(INTEGRITY_OS)
437 /* Try to use remainder of input buffer for copies if possible, word-aligned for safety. */
438 IMG_UINT32 ui32InBufferOffset = PVR_ALIGN(sizeof(*psDevicememHistoryUnmapNewIN), sizeof(unsigned long));
439 IMG_UINT32 ui32InBufferExcessSize = ui32InBufferOffset >= PVRSRV_MAX_BRIDGE_IN_SIZE ? 0 :
440 PVRSRV_MAX_BRIDGE_IN_SIZE - ui32InBufferOffset;
442 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
443 if (bHaveEnoughSpace)
445 IMG_BYTE *pInputBuffer = (IMG_BYTE *)psDevicememHistoryUnmapNewIN;
447 pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset]; }
451 pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
453 if(!pArrayArgsBuffer)
455 psDevicememHistoryUnmapNewOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
456 goto DevicememHistoryUnmapNew_exit;
463 uiTextInt = (IMG_CHAR*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
464 ui32NextOffset += DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR);
467 /* Copy the data over */
468 if (DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR) > 0)
470 if ( OSCopyFromUser(NULL, uiTextInt, psDevicememHistoryUnmapNewIN->puiText, DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR)) != PVRSRV_OK )
472 psDevicememHistoryUnmapNewOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
474 goto DevicememHistoryUnmapNew_exit;
478 /* Lock over handle lookup. */
486 /* Look up the address from the handle */
487 psDevicememHistoryUnmapNewOUT->eError =
488 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
491 PVRSRV_HANDLE_TYPE_PHYSMEM_PMR,
493 if(psDevicememHistoryUnmapNewOUT->eError != PVRSRV_OK)
496 goto DevicememHistoryUnmapNew_exit;
499 /* Release now we have looked up handles. */
502 psDevicememHistoryUnmapNewOUT->eError =
503 DevicememHistoryUnmapNewKM(
505 psDevicememHistoryUnmapNewIN->uiOffset,
506 psDevicememHistoryUnmapNewIN->sDevVAddr,
507 psDevicememHistoryUnmapNewIN->uiSize,
509 psDevicememHistoryUnmapNewIN->ui32Log2PageSize,
510 psDevicememHistoryUnmapNewIN->ui32AllocationIndex,
511 &psDevicememHistoryUnmapNewOUT->ui32AllocationIndexOut);
516 DevicememHistoryUnmapNew_exit:
518 /* Lock over handle lookup cleanup. */
527 /* Unreference the previously looked up handle */
530 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
532 PVRSRV_HANDLE_TYPE_PHYSMEM_PMR);
535 /* Release now we have cleaned up look up handles. */
538 /* Allocated space should be equal to the last updated offset */
539 PVR_ASSERT(ui32BufferSize == ui32NextOffset);
541 #if defined(INTEGRITY_OS)
544 if(!bHaveEnoughSpace && pArrayArgsBuffer)
546 OSFreeMemNoStats(pArrayArgsBuffer);
554 PVRSRVBridgeDevicememHistoryMapVRange(IMG_UINT32 ui32DispatchTableEntry,
555 PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYMAPVRANGE *psDevicememHistoryMapVRangeIN,
556 PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYMAPVRANGE *psDevicememHistoryMapVRangeOUT,
557 CONNECTION_DATA *psConnection)
559 IMG_CHAR *uiTextInt = NULL;
561 IMG_UINT32 ui32NextOffset = 0;
562 IMG_BYTE *pArrayArgsBuffer = NULL;
563 #if !defined(INTEGRITY_OS)
564 IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
567 IMG_UINT32 ui32BufferSize =
568 (DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR)) +
572 PVR_UNREFERENCED_PARAMETER(psConnection);
576 if (ui32BufferSize != 0)
578 #if !defined(INTEGRITY_OS)
579 /* Try to use remainder of input buffer for copies if possible, word-aligned for safety. */
580 IMG_UINT32 ui32InBufferOffset = PVR_ALIGN(sizeof(*psDevicememHistoryMapVRangeIN), sizeof(unsigned long));
581 IMG_UINT32 ui32InBufferExcessSize = ui32InBufferOffset >= PVRSRV_MAX_BRIDGE_IN_SIZE ? 0 :
582 PVRSRV_MAX_BRIDGE_IN_SIZE - ui32InBufferOffset;
584 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
585 if (bHaveEnoughSpace)
587 IMG_BYTE *pInputBuffer = (IMG_BYTE *)psDevicememHistoryMapVRangeIN;
589 pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset]; }
593 pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
595 if(!pArrayArgsBuffer)
597 psDevicememHistoryMapVRangeOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
598 goto DevicememHistoryMapVRange_exit;
605 uiTextInt = (IMG_CHAR*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
606 ui32NextOffset += DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR);
609 /* Copy the data over */
610 if (DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR) > 0)
612 if ( OSCopyFromUser(NULL, uiTextInt, psDevicememHistoryMapVRangeIN->puiText, DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR)) != PVRSRV_OK )
614 psDevicememHistoryMapVRangeOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
616 goto DevicememHistoryMapVRange_exit;
621 psDevicememHistoryMapVRangeOUT->eError =
622 DevicememHistoryMapVRangeKM(
623 psDevicememHistoryMapVRangeIN->sBaseDevVAddr,
624 psDevicememHistoryMapVRangeIN->ui32ui32StartPage,
625 psDevicememHistoryMapVRangeIN->ui32NumPages,
626 psDevicememHistoryMapVRangeIN->uiAllocSize,
628 psDevicememHistoryMapVRangeIN->ui32Log2PageSize,
629 psDevicememHistoryMapVRangeIN->ui32AllocationIndex,
630 &psDevicememHistoryMapVRangeOUT->ui32AllocationIndexOut);
635 DevicememHistoryMapVRange_exit:
639 /* Allocated space should be equal to the last updated offset */
640 PVR_ASSERT(ui32BufferSize == ui32NextOffset);
642 #if defined(INTEGRITY_OS)
645 if(!bHaveEnoughSpace && pArrayArgsBuffer)
647 OSFreeMemNoStats(pArrayArgsBuffer);
655 PVRSRVBridgeDevicememHistoryUnmapVRange(IMG_UINT32 ui32DispatchTableEntry,
656 PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYUNMAPVRANGE *psDevicememHistoryUnmapVRangeIN,
657 PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYUNMAPVRANGE *psDevicememHistoryUnmapVRangeOUT,
658 CONNECTION_DATA *psConnection)
660 IMG_CHAR *uiTextInt = NULL;
662 IMG_UINT32 ui32NextOffset = 0;
663 IMG_BYTE *pArrayArgsBuffer = NULL;
664 #if !defined(INTEGRITY_OS)
665 IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
668 IMG_UINT32 ui32BufferSize =
669 (DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR)) +
673 PVR_UNREFERENCED_PARAMETER(psConnection);
677 if (ui32BufferSize != 0)
679 #if !defined(INTEGRITY_OS)
680 /* Try to use remainder of input buffer for copies if possible, word-aligned for safety. */
681 IMG_UINT32 ui32InBufferOffset = PVR_ALIGN(sizeof(*psDevicememHistoryUnmapVRangeIN), sizeof(unsigned long));
682 IMG_UINT32 ui32InBufferExcessSize = ui32InBufferOffset >= PVRSRV_MAX_BRIDGE_IN_SIZE ? 0 :
683 PVRSRV_MAX_BRIDGE_IN_SIZE - ui32InBufferOffset;
685 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
686 if (bHaveEnoughSpace)
688 IMG_BYTE *pInputBuffer = (IMG_BYTE *)psDevicememHistoryUnmapVRangeIN;
690 pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset]; }
694 pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
696 if(!pArrayArgsBuffer)
698 psDevicememHistoryUnmapVRangeOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
699 goto DevicememHistoryUnmapVRange_exit;
706 uiTextInt = (IMG_CHAR*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
707 ui32NextOffset += DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR);
710 /* Copy the data over */
711 if (DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR) > 0)
713 if ( OSCopyFromUser(NULL, uiTextInt, psDevicememHistoryUnmapVRangeIN->puiText, DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR)) != PVRSRV_OK )
715 psDevicememHistoryUnmapVRangeOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
717 goto DevicememHistoryUnmapVRange_exit;
722 psDevicememHistoryUnmapVRangeOUT->eError =
723 DevicememHistoryUnmapVRangeKM(
724 psDevicememHistoryUnmapVRangeIN->sBaseDevVAddr,
725 psDevicememHistoryUnmapVRangeIN->ui32ui32StartPage,
726 psDevicememHistoryUnmapVRangeIN->ui32NumPages,
727 psDevicememHistoryUnmapVRangeIN->uiAllocSize,
729 psDevicememHistoryUnmapVRangeIN->ui32Log2PageSize,
730 psDevicememHistoryUnmapVRangeIN->ui32AllocationIndex,
731 &psDevicememHistoryUnmapVRangeOUT->ui32AllocationIndexOut);
736 DevicememHistoryUnmapVRange_exit:
740 /* Allocated space should be equal to the last updated offset */
741 PVR_ASSERT(ui32BufferSize == ui32NextOffset);
743 #if defined(INTEGRITY_OS)
746 if(!bHaveEnoughSpace && pArrayArgsBuffer)
748 OSFreeMemNoStats(pArrayArgsBuffer);
756 PVRSRVBridgeDevicememHistorySparseChange(IMG_UINT32 ui32DispatchTableEntry,
757 PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYSPARSECHANGE *psDevicememHistorySparseChangeIN,
758 PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYSPARSECHANGE *psDevicememHistorySparseChangeOUT,
759 CONNECTION_DATA *psConnection)
761 IMG_HANDLE hPMR = psDevicememHistorySparseChangeIN->hPMR;
762 PMR * psPMRInt = NULL;
763 IMG_CHAR *uiTextInt = NULL;
764 IMG_UINT32 *ui32AllocPageIndicesInt = NULL;
765 IMG_UINT32 *ui32FreePageIndicesInt = NULL;
767 IMG_UINT32 ui32NextOffset = 0;
768 IMG_BYTE *pArrayArgsBuffer = NULL;
769 #if !defined(INTEGRITY_OS)
770 IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
773 IMG_UINT32 ui32BufferSize =
774 (DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR)) +
775 (psDevicememHistorySparseChangeIN->ui32AllocPageCount * sizeof(IMG_UINT32)) +
776 (psDevicememHistorySparseChangeIN->ui32FreePageCount * sizeof(IMG_UINT32)) +
783 if (ui32BufferSize != 0)
785 #if !defined(INTEGRITY_OS)
786 /* Try to use remainder of input buffer for copies if possible, word-aligned for safety. */
787 IMG_UINT32 ui32InBufferOffset = PVR_ALIGN(sizeof(*psDevicememHistorySparseChangeIN), sizeof(unsigned long));
788 IMG_UINT32 ui32InBufferExcessSize = ui32InBufferOffset >= PVRSRV_MAX_BRIDGE_IN_SIZE ? 0 :
789 PVRSRV_MAX_BRIDGE_IN_SIZE - ui32InBufferOffset;
791 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
792 if (bHaveEnoughSpace)
794 IMG_BYTE *pInputBuffer = (IMG_BYTE *)psDevicememHistorySparseChangeIN;
796 pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset]; }
800 pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
802 if(!pArrayArgsBuffer)
804 psDevicememHistorySparseChangeOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
805 goto DevicememHistorySparseChange_exit;
812 uiTextInt = (IMG_CHAR*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
813 ui32NextOffset += DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR);
816 /* Copy the data over */
817 if (DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR) > 0)
819 if ( OSCopyFromUser(NULL, uiTextInt, psDevicememHistorySparseChangeIN->puiText, DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR)) != PVRSRV_OK )
821 psDevicememHistorySparseChangeOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
823 goto DevicememHistorySparseChange_exit;
826 if (psDevicememHistorySparseChangeIN->ui32AllocPageCount != 0)
828 ui32AllocPageIndicesInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
829 ui32NextOffset += psDevicememHistorySparseChangeIN->ui32AllocPageCount * sizeof(IMG_UINT32);
832 /* Copy the data over */
833 if (psDevicememHistorySparseChangeIN->ui32AllocPageCount * sizeof(IMG_UINT32) > 0)
835 if ( OSCopyFromUser(NULL, ui32AllocPageIndicesInt, psDevicememHistorySparseChangeIN->pui32AllocPageIndices, psDevicememHistorySparseChangeIN->ui32AllocPageCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
837 psDevicememHistorySparseChangeOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
839 goto DevicememHistorySparseChange_exit;
842 if (psDevicememHistorySparseChangeIN->ui32FreePageCount != 0)
844 ui32FreePageIndicesInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
845 ui32NextOffset += psDevicememHistorySparseChangeIN->ui32FreePageCount * sizeof(IMG_UINT32);
848 /* Copy the data over */
849 if (psDevicememHistorySparseChangeIN->ui32FreePageCount * sizeof(IMG_UINT32) > 0)
851 if ( OSCopyFromUser(NULL, ui32FreePageIndicesInt, psDevicememHistorySparseChangeIN->pui32FreePageIndices, psDevicememHistorySparseChangeIN->ui32FreePageCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
853 psDevicememHistorySparseChangeOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
855 goto DevicememHistorySparseChange_exit;
859 /* Lock over handle lookup. */
867 /* Look up the address from the handle */
868 psDevicememHistorySparseChangeOUT->eError =
869 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
872 PVRSRV_HANDLE_TYPE_PHYSMEM_PMR,
874 if(psDevicememHistorySparseChangeOUT->eError != PVRSRV_OK)
877 goto DevicememHistorySparseChange_exit;
880 /* Release now we have looked up handles. */
883 psDevicememHistorySparseChangeOUT->eError =
884 DevicememHistorySparseChangeKM(
886 psDevicememHistorySparseChangeIN->uiOffset,
887 psDevicememHistorySparseChangeIN->sDevVAddr,
888 psDevicememHistorySparseChangeIN->uiSize,
890 psDevicememHistorySparseChangeIN->ui32Log2PageSize,
891 psDevicememHistorySparseChangeIN->ui32AllocPageCount,
892 ui32AllocPageIndicesInt,
893 psDevicememHistorySparseChangeIN->ui32FreePageCount,
894 ui32FreePageIndicesInt,
895 psDevicememHistorySparseChangeIN->ui32AllocationIndex,
896 &psDevicememHistorySparseChangeOUT->ui32AllocationIndexOut);
901 DevicememHistorySparseChange_exit:
903 /* Lock over handle lookup cleanup. */
912 /* Unreference the previously looked up handle */
915 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
917 PVRSRV_HANDLE_TYPE_PHYSMEM_PMR);
920 /* Release now we have cleaned up look up handles. */
923 /* Allocated space should be equal to the last updated offset */
924 PVR_ASSERT(ui32BufferSize == ui32NextOffset);
926 #if defined(INTEGRITY_OS)
929 if(!bHaveEnoughSpace && pArrayArgsBuffer)
931 OSFreeMemNoStats(pArrayArgsBuffer);
940 /* ***************************************************************************
941 * Server bridge dispatch related glue
944 static POS_LOCK pDEVICEMEMHISTORYBridgeLock;
945 static IMG_BOOL bUseLock = IMG_TRUE;
946 #endif /* SUPPORT_DEVICEMEMHISTORY_BRIDGE */
948 #if defined(SUPPORT_DEVICEMEMHISTORY_BRIDGE)
949 PVRSRV_ERROR InitDEVICEMEMHISTORYBridge(void);
950 PVRSRV_ERROR DeinitDEVICEMEMHISTORYBridge(void);
953 * Register all DEVICEMEMHISTORY functions with services
955 PVRSRV_ERROR InitDEVICEMEMHISTORYBridge(void)
957 PVR_LOGR_IF_ERROR(OSLockCreate(&pDEVICEMEMHISTORYBridgeLock, LOCK_TYPE_PASSIVE), "OSLockCreate");
959 SetDispatchTableEntry(PVRSRV_BRIDGE_DEVICEMEMHISTORY, PVRSRV_BRIDGE_DEVICEMEMHISTORY_DEVICEMEMHISTORYMAP, PVRSRVBridgeDevicememHistoryMap,
960 pDEVICEMEMHISTORYBridgeLock, bUseLock);
962 SetDispatchTableEntry(PVRSRV_BRIDGE_DEVICEMEMHISTORY, PVRSRV_BRIDGE_DEVICEMEMHISTORY_DEVICEMEMHISTORYUNMAP, PVRSRVBridgeDevicememHistoryUnmap,
963 pDEVICEMEMHISTORYBridgeLock, bUseLock);
965 SetDispatchTableEntry(PVRSRV_BRIDGE_DEVICEMEMHISTORY, PVRSRV_BRIDGE_DEVICEMEMHISTORY_DEVICEMEMHISTORYMAPNEW, PVRSRVBridgeDevicememHistoryMapNew,
966 pDEVICEMEMHISTORYBridgeLock, bUseLock);
968 SetDispatchTableEntry(PVRSRV_BRIDGE_DEVICEMEMHISTORY, PVRSRV_BRIDGE_DEVICEMEMHISTORY_DEVICEMEMHISTORYUNMAPNEW, PVRSRVBridgeDevicememHistoryUnmapNew,
969 pDEVICEMEMHISTORYBridgeLock, bUseLock);
971 SetDispatchTableEntry(PVRSRV_BRIDGE_DEVICEMEMHISTORY, PVRSRV_BRIDGE_DEVICEMEMHISTORY_DEVICEMEMHISTORYMAPVRANGE, PVRSRVBridgeDevicememHistoryMapVRange,
972 pDEVICEMEMHISTORYBridgeLock, bUseLock);
974 SetDispatchTableEntry(PVRSRV_BRIDGE_DEVICEMEMHISTORY, PVRSRV_BRIDGE_DEVICEMEMHISTORY_DEVICEMEMHISTORYUNMAPVRANGE, PVRSRVBridgeDevicememHistoryUnmapVRange,
975 pDEVICEMEMHISTORYBridgeLock, bUseLock);
977 SetDispatchTableEntry(PVRSRV_BRIDGE_DEVICEMEMHISTORY, PVRSRV_BRIDGE_DEVICEMEMHISTORY_DEVICEMEMHISTORYSPARSECHANGE, PVRSRVBridgeDevicememHistorySparseChange,
978 pDEVICEMEMHISTORYBridgeLock, bUseLock);
985 * Unregister all devicememhistory functions with services
987 PVRSRV_ERROR DeinitDEVICEMEMHISTORYBridge(void)
989 PVR_LOGR_IF_ERROR(OSLockDestroy(pDEVICEMEMHISTORYBridgeLock), "OSLockDestroy");
992 #else /* SUPPORT_DEVICEMEMHISTORY_BRIDGE */
993 /* This bridge is conditional on SUPPORT_DEVICEMEMHISTORY_BRIDGE - when not defined,
994 * do not populate the dispatch table with its functions
996 #define InitDEVICEMEMHISTORYBridge() \
999 #define DeinitDEVICEMEMHISTORYBridge() \
1002 #endif /* SUPPORT_DEVICEMEMHISTORY_BRIDGE */