1 /*************************************************************************/ /*!
3 @Title Shared device memory management PDump functions
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Implements common (client & server) PDump functions for the
7 @License Dual MIT/GPLv2
9 The contents of this file are subject to the MIT license as set out below.
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is
16 furnished to do so, subject to the following conditions:
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
21 Alternatively, the contents of this file may be used under the terms of
22 the GNU General Public License Version 2 ("GPL") in which case the provisions
23 of GPL are applicable instead of those above.
25 If you wish to allow use of your version of this file only under the terms of
26 GPL, and not to allow others to use your version of this file under the terms
27 of the MIT license, indicate your decision by deleting the provisions above
28 and replace them with the notice and other provisions required by GPL as set
29 out in the file called "GPL-COPYING" included in this distribution. If you do
30 not delete the provisions above, a recipient may use your version of this file
31 under the terms of either the MIT license or GPL.
33 This License is also included in this distribution in the file called
36 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
37 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
38 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
39 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
40 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
41 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
42 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43 */ /**************************************************************************/
48 #include "img_types.h"
49 #include "pvrsrv_error.h"
51 #include "devicemem.h"
52 #include "devicemem_utils.h"
53 #include "devicemem_pdump.h"
54 #include "client_pdumpmm_bridge.h"
55 #if defined(LINUX) && !defined(__KERNEL__)
57 #if defined(SUPPORT_ANDROID_PLATFORM)
58 #include "android_utils.h"
63 DevmemPDumpLoadMem(DEVMEM_MEMDESC *psMemDesc,
64 IMG_DEVMEM_OFFSET_T uiOffset,
65 IMG_DEVMEM_SIZE_T uiSize,
66 PDUMP_FLAGS_T uiPDumpFlags)
70 PVR_ASSERT(uiOffset + uiSize <= psMemDesc->psImport->uiSize);
72 eError = BridgePMRPDumpLoadMem(psMemDesc->psImport->hDevConnection,
73 psMemDesc->psImport->hPMR,
74 psMemDesc->uiOffset + uiOffset,
79 if (eError != PVRSRV_OK)
81 PVR_DPF((PVR_DBG_ERROR,
82 "%s: failed with error %d",
83 __FUNCTION__, eError));
85 PVR_ASSERT(eError == PVRSRV_OK);
89 DevmemPDumpLoadZeroMem(DEVMEM_MEMDESC *psMemDesc,
90 IMG_DEVMEM_OFFSET_T uiOffset,
91 IMG_DEVMEM_SIZE_T uiSize,
92 PDUMP_FLAGS_T uiPDumpFlags)
96 PVR_ASSERT(uiOffset + uiSize <= psMemDesc->psImport->uiSize);
98 eError = BridgePMRPDumpLoadMem(psMemDesc->psImport->hDevConnection,
99 psMemDesc->psImport->hPMR,
100 psMemDesc->uiOffset + uiOffset,
105 if (eError != PVRSRV_OK)
107 PVR_DPF((PVR_DBG_ERROR,
108 "%s: failed with error %d",
109 __FUNCTION__, eError));
111 PVR_ASSERT(eError == PVRSRV_OK);
115 DevmemPDumpLoadMemValue32(DEVMEM_MEMDESC *psMemDesc,
116 IMG_DEVMEM_OFFSET_T uiOffset,
117 IMG_UINT32 ui32Value,
118 PDUMP_FLAGS_T uiPDumpFlags)
122 eError = BridgePMRPDumpLoadMemValue32(psMemDesc->psImport->hDevConnection,
123 psMemDesc->psImport->hPMR,
124 psMemDesc->uiOffset + uiOffset,
128 if (eError != PVRSRV_OK)
130 PVR_DPF((PVR_DBG_ERROR,
131 "%s: failed with error %d",
132 __FUNCTION__, eError));
134 PVR_ASSERT(eError == PVRSRV_OK);
138 DevmemPDumpLoadMemValue64(DEVMEM_MEMDESC *psMemDesc,
139 IMG_DEVMEM_OFFSET_T uiOffset,
140 IMG_UINT64 ui64Value,
141 PDUMP_FLAGS_T uiPDumpFlags)
145 eError = BridgePMRPDumpLoadMemValue64(psMemDesc->psImport->hDevConnection,
146 psMemDesc->psImport->hPMR,
147 psMemDesc->uiOffset + uiOffset,
150 if (eError != PVRSRV_OK)
152 PVR_DPF((PVR_DBG_ERROR,
153 "%s: failed with error %d",
154 __FUNCTION__, eError));
156 PVR_ASSERT(eError == PVRSRV_OK);
159 /* FIXME: This should be server side only */
160 IMG_INTERNAL PVRSRV_ERROR
161 DevmemPDumpPageCatBaseToSAddr(DEVMEM_MEMDESC *psMemDesc,
162 IMG_DEVMEM_OFFSET_T *puiMemOffset,
167 IMG_CHAR aszMemspaceName[100];
168 IMG_CHAR aszSymbolicName[100];
169 IMG_DEVMEM_OFFSET_T uiNextSymName;
171 *puiMemOffset += psMemDesc->uiOffset;
173 eError = BridgePMRPDumpSymbolicAddr(psMemDesc->psImport->hDevConnection,
174 psMemDesc->psImport->hPMR,
176 sizeof(aszMemspaceName),
178 sizeof(aszSymbolicName),
183 if (eError != PVRSRV_OK)
185 PVR_DPF((PVR_DBG_ERROR,
186 "%s: failed with error %d",
187 __FUNCTION__, eError));
189 PVR_ASSERT(eError == PVRSRV_OK);
191 OSSNPrintf(pszName, ui32Size, "%s:%s", &aszMemspaceName[0], &aszSymbolicName[0]);
196 DevmemPDumpSaveToFile(DEVMEM_MEMDESC *psMemDesc,
197 IMG_DEVMEM_OFFSET_T uiOffset,
198 IMG_DEVMEM_SIZE_T uiSize,
199 const IMG_CHAR *pszFilename,
200 IMG_UINT32 uiFileOffset)
204 eError = BridgePMRPDumpSaveToFile(psMemDesc->psImport->hDevConnection,
205 psMemDesc->psImport->hPMR,
206 psMemDesc->uiOffset + uiOffset,
208 OSStringLength(pszFilename) + 1,
212 if (eError != PVRSRV_OK)
214 PVR_DPF((PVR_DBG_ERROR,
215 "%s: failed with error %d",
216 __FUNCTION__, eError));
218 PVR_ASSERT(eError == PVRSRV_OK);
225 DevmemPDumpSaveToFileVirtual(DEVMEM_MEMDESC *psMemDesc,
226 IMG_DEVMEM_OFFSET_T uiOffset,
227 IMG_DEVMEM_SIZE_T uiSize,
228 const IMG_CHAR *pszFilename,
229 IMG_UINT32 ui32FileOffset,
230 IMG_UINT32 ui32PdumpFlags)
233 IMG_DEV_VIRTADDR sDevAddrStart;
235 sDevAddrStart = psMemDesc->psImport->sDeviceImport.sDevVAddr;
236 sDevAddrStart.uiAddr += psMemDesc->uiOffset;
237 sDevAddrStart.uiAddr += uiOffset;
239 eError = BridgeDevmemIntPDumpSaveToFileVirtual(psMemDesc->psImport->hDevConnection,
240 psMemDesc->psImport->sDeviceImport.psHeap->psCtx->hDevMemServerContext,
243 OSStringLength(pszFilename) + 1,
248 if (eError != PVRSRV_OK)
250 PVR_DPF((PVR_DBG_ERROR,
251 "%s: failed with error %d",
252 __FUNCTION__, eError));
254 PVR_ASSERT(eError == PVRSRV_OK);
258 IMG_INTERNAL PVRSRV_ERROR
259 DevmemPDumpDevmemPol32(const DEVMEM_MEMDESC *psMemDesc,
260 IMG_DEVMEM_OFFSET_T uiOffset,
261 IMG_UINT32 ui32Value,
263 PDUMP_POLL_OPERATOR eOperator,
264 PDUMP_FLAGS_T ui32PDumpFlags)
267 IMG_DEVMEM_SIZE_T uiNumBytes;
271 if (psMemDesc->uiOffset + uiOffset + uiNumBytes >= psMemDesc->psImport->uiSize)
273 eError = PVRSRV_ERROR_DEVICEMEM_OUT_OF_RANGE;
277 eError = BridgePMRPDumpPol32(psMemDesc->psImport->hDevConnection,
278 psMemDesc->psImport->hPMR,
279 psMemDesc->uiOffset + uiOffset,
284 if (eError != PVRSRV_OK)
292 error exit paths follow
296 PVR_ASSERT(eError != PVRSRV_OK);
300 IMG_INTERNAL PVRSRV_ERROR
301 DevmemPDumpCBP(const DEVMEM_MEMDESC *psMemDesc,
302 IMG_DEVMEM_OFFSET_T uiReadOffset,
303 IMG_DEVMEM_OFFSET_T uiWriteOffset,
304 IMG_DEVMEM_SIZE_T uiPacketSize,
305 IMG_DEVMEM_SIZE_T uiBufferSize)
309 if ((psMemDesc->uiOffset + uiReadOffset) > psMemDesc->psImport->uiSize)
311 eError = PVRSRV_ERROR_DEVICEMEM_OUT_OF_RANGE;
315 eError = BridgePMRPDumpCBP(psMemDesc->psImport->hDevConnection,
316 psMemDesc->psImport->hPMR,
317 psMemDesc->uiOffset + uiReadOffset,
321 if (eError != PVRSRV_OK)
329 PVR_ASSERT(eError != PVRSRV_OK);