1 /*************************************************************************/ /*!
3 @Title Device Memory Management PDump internal
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Services internal interface to PDump device memory management
6 functions that are shared between client and server code.
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 */ /**************************************************************************/
45 #ifndef DEVICEMEM_PDUMP_H
46 #define DEVICEMEM_PDUMP_H
48 #include "devicemem.h"
49 #include "pdumpdefs.h"
54 * DevmemPDumpLoadMem()
56 * takes a memory descriptor, offset, and size, and takes the current contents
57 * of the memory at that location and writes it to the prm pdump file, and
58 * emits a pdump LDB to load the data from that file. The intention here is
59 * that the contents of the simulated buffer upon pdump playback will be made
60 * to be the same as they are when this command is run, enabling pdump of
61 * cases where the memory has been modified externally, i.e. by the host cpu
62 * or by a third party.
65 DevmemPDumpLoadMem(DEVMEM_MEMDESC *psMemDesc,
66 IMG_DEVMEM_OFFSET_T uiOffset,
67 IMG_DEVMEM_SIZE_T uiSize,
68 PDUMP_FLAGS_T uiPDumpFlags);
71 * DevmemPDumpLoadZeroMem()
73 * As DevmemPDumpLoadMem() but the PDump allocation will be populated with
74 * zeros from the zero page in the parameter stream
77 DevmemPDumpLoadZeroMem(DEVMEM_MEMDESC *psMemDesc,
78 IMG_DEVMEM_OFFSET_T uiOffset,
79 IMG_DEVMEM_SIZE_T uiSize,
80 PDUMP_FLAGS_T uiPDumpFlags);
83 * DevmemPDumpLoadMemValue32()
85 * As above but dumps the value at a dword-aligned address in plain text to
86 * the pdump script2 file. Useful for patching a buffer at pdump playback by
87 * simply editing the script output file.
89 * (The same functionality can be achieved by the above function but the
90 * binary PARAM file must be patched in that case.)
93 DevmemPDumpLoadMemValue32(DEVMEM_MEMDESC *psMemDesc,
94 IMG_DEVMEM_OFFSET_T uiOffset,
96 PDUMP_FLAGS_T uiPDumpFlags);
99 * DevmemPDumpMemValue64()
101 * As above but dumps the 64bit-value at a dword-aligned address in plain text
102 * to the pdump script2 file. Useful for patching a buffer at pdump playback by
103 * simply editing the script output file.
105 * (The same functionality can be achieved by the above function but the
106 * binary PARAM file must be patched in that case.)
109 DevmemPDumpLoadMemValue64(DEVMEM_MEMDESC *psMemDesc,
110 IMG_DEVMEM_OFFSET_T uiOffset,
111 IMG_UINT64 ui64Value,
112 PDUMP_FLAGS_T uiPDumpFlags);
115 * DevmemPDumpPageCatBaseToSAddr()
117 * Returns the symbolic address of a piece of memory represented by an offset
118 * into the mem descriptor.
121 DevmemPDumpPageCatBaseToSAddr(DEVMEM_MEMDESC *psMemDesc,
122 IMG_DEVMEM_OFFSET_T *puiMemOffset,
124 IMG_UINT32 ui32Size);
127 * DevmemPDumpSaveToFile()
129 * Emits a pdump SAB to cause the current contents of the memory to be written
130 * to the given file during playback
133 DevmemPDumpSaveToFile(DEVMEM_MEMDESC *psMemDesc,
134 IMG_DEVMEM_OFFSET_T uiOffset,
135 IMG_DEVMEM_SIZE_T uiSize,
136 const IMG_CHAR *pszFilename,
137 IMG_UINT32 uiFileOffset);
140 * DevmemPDumpSaveToFileVirtual()
142 * Emits a pdump SAB, just like DevmemPDumpSaveToFile(), but uses the virtual
143 * address and device MMU context to cause the pdump player to traverse the
144 * MMU page tables itself.
147 DevmemPDumpSaveToFileVirtual(DEVMEM_MEMDESC *psMemDesc,
148 IMG_DEVMEM_OFFSET_T uiOffset,
149 IMG_DEVMEM_SIZE_T uiSize,
150 const IMG_CHAR *pszFilename,
151 IMG_UINT32 ui32FileOffset,
152 IMG_UINT32 ui32PdumpFlags);
155 * DevmemPDumpDataDescriptor()
157 * Emits a pdump CMD:OutputData, using the virtual address and device MMU
158 * context. Provides more flexibility than a pdump SAB because metadata can
159 * be passed to an external pdump player library via the command header.
162 DevmemPDumpDataDescriptor(DEVMEM_MEMDESC *psMemDesc,
163 IMG_DEVMEM_OFFSET_T uiOffset,
164 IMG_DEVMEM_SIZE_T uiSize,
165 const IMG_CHAR *pszFilename,
166 IMG_UINT32 ui32HeaderType,
167 IMG_UINT32 ui32ElementType,
168 IMG_UINT32 ui32ElementCount,
169 IMG_UINT32 ui32PdumpFlags);
174 * DevmemPDumpDevmemPol32()
176 * Writes a PDump 'POL' command to wait for a masked 32-bit memory location to
177 * become the specified value.
180 DevmemPDumpDevmemPol32(const DEVMEM_MEMDESC *psMemDesc,
181 IMG_DEVMEM_OFFSET_T uiOffset,
182 IMG_UINT32 ui32Value,
184 PDUMP_POLL_OPERATOR eOperator,
185 PDUMP_FLAGS_T ui32PDumpFlags);
187 #if defined(__KERNEL__)
190 * DevmemPDumpDevmemCheck32()
192 * Writes a PDump 'POL' command to run a single-shot check for a masked
193 * 32-bit memory location to match the specified value.
196 DevmemPDumpDevmemCheck32(const DEVMEM_MEMDESC *psMemDesc,
197 IMG_DEVMEM_OFFSET_T uiOffset,
198 IMG_UINT32 ui32Value,
200 PDUMP_POLL_OPERATOR eOperator,
201 PDUMP_FLAGS_T ui32PDumpFlags);
207 * Polls for space in circular buffer. Reads the read offset from memory and
208 * waits until there is enough space to write the packet.
210 * psMemDesc - MemDesc which contains the read offset
211 * uiReadOffset - Offset into MemDesc to the read offset
212 * uiWriteOffset - Current write offset
213 * uiPacketSize - Size of packet to write
214 * uiBufferSize - Size of circular buffer
217 DevmemPDumpCBP(const DEVMEM_MEMDESC *psMemDesc,
218 IMG_DEVMEM_OFFSET_T uiReadOffset,
219 IMG_DEVMEM_OFFSET_T uiWriteOffset,
220 IMG_DEVMEM_SIZE_T uiPacketSize,
221 IMG_DEVMEM_SIZE_T uiBufferSize);
225 #ifdef INLINE_IS_PRAGMA
226 #pragma inline(DevmemPDumpLoadMem)
229 DevmemPDumpLoadMem(DEVMEM_MEMDESC *psMemDesc,
230 IMG_DEVMEM_OFFSET_T uiOffset,
231 IMG_DEVMEM_SIZE_T uiSize,
232 PDUMP_FLAGS_T uiPDumpFlags)
234 PVR_UNREFERENCED_PARAMETER(psMemDesc);
235 PVR_UNREFERENCED_PARAMETER(uiOffset);
236 PVR_UNREFERENCED_PARAMETER(uiSize);
237 PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
240 #ifdef INLINE_IS_PRAGMA
241 #pragma inline(DevmemPDumpLoadMemValue32)
244 DevmemPDumpLoadMemValue32(DEVMEM_MEMDESC *psMemDesc,
245 IMG_DEVMEM_OFFSET_T uiOffset,
246 IMG_UINT32 ui32Value,
247 PDUMP_FLAGS_T uiPDumpFlags)
249 PVR_UNREFERENCED_PARAMETER(psMemDesc);
250 PVR_UNREFERENCED_PARAMETER(uiOffset);
251 PVR_UNREFERENCED_PARAMETER(ui32Value);
252 PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
255 #ifdef INLINE_IS_PRAGMA
256 #pragma inline(DevmemPDumpLoadMemValue64)
259 DevmemPDumpLoadMemValue64(DEVMEM_MEMDESC *psMemDesc,
260 IMG_DEVMEM_OFFSET_T uiOffset,
261 IMG_UINT64 ui64Value,
262 PDUMP_FLAGS_T uiPDumpFlags)
264 PVR_UNREFERENCED_PARAMETER(psMemDesc);
265 PVR_UNREFERENCED_PARAMETER(uiOffset);
266 PVR_UNREFERENCED_PARAMETER(ui64Value);
267 PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
270 #ifdef INLINE_IS_PRAGMA
271 #pragma inline(DevmemPDumpPageCatBaseToSAddr)
273 static INLINE PVRSRV_ERROR
274 DevmemPDumpPageCatBaseToSAddr(DEVMEM_MEMDESC *psMemDesc,
275 IMG_DEVMEM_OFFSET_T *puiMemOffset,
279 PVR_UNREFERENCED_PARAMETER(psMemDesc);
280 PVR_UNREFERENCED_PARAMETER(puiMemOffset);
281 PVR_UNREFERENCED_PARAMETER(pszName);
282 PVR_UNREFERENCED_PARAMETER(ui32Size);
287 #ifdef INLINE_IS_PRAGMA
288 #pragma inline(DevmemPDumpSaveToFile)
291 DevmemPDumpSaveToFile(DEVMEM_MEMDESC *psMemDesc,
292 IMG_DEVMEM_OFFSET_T uiOffset,
293 IMG_DEVMEM_SIZE_T uiSize,
294 const IMG_CHAR *pszFilename,
295 IMG_UINT32 uiFileOffset)
297 PVR_UNREFERENCED_PARAMETER(psMemDesc);
298 PVR_UNREFERENCED_PARAMETER(uiOffset);
299 PVR_UNREFERENCED_PARAMETER(uiSize);
300 PVR_UNREFERENCED_PARAMETER(pszFilename);
301 PVR_UNREFERENCED_PARAMETER(uiFileOffset);
304 #ifdef INLINE_IS_PRAGMA
305 #pragma inline(DevmemPDumpSaveToFileVirtual)
308 DevmemPDumpSaveToFileVirtual(DEVMEM_MEMDESC *psMemDesc,
309 IMG_DEVMEM_OFFSET_T uiOffset,
310 IMG_DEVMEM_SIZE_T uiSize,
311 const IMG_CHAR *pszFilename,
312 IMG_UINT32 ui32FileOffset,
313 IMG_UINT32 ui32PdumpFlags)
315 PVR_UNREFERENCED_PARAMETER(psMemDesc);
316 PVR_UNREFERENCED_PARAMETER(uiOffset);
317 PVR_UNREFERENCED_PARAMETER(uiSize);
318 PVR_UNREFERENCED_PARAMETER(pszFilename);
319 PVR_UNREFERENCED_PARAMETER(ui32FileOffset);
320 PVR_UNREFERENCED_PARAMETER(ui32PdumpFlags);
323 #ifdef INLINE_IS_PRAGMA
324 #pragma inline(DevmemPDumpDevmemPol32)
326 static INLINE PVRSRV_ERROR
327 DevmemPDumpDevmemPol32(const DEVMEM_MEMDESC *psMemDesc,
328 IMG_DEVMEM_OFFSET_T uiOffset,
329 IMG_UINT32 ui32Value,
331 PDUMP_POLL_OPERATOR eOperator,
332 PDUMP_FLAGS_T ui32PDumpFlags)
334 PVR_UNREFERENCED_PARAMETER(psMemDesc);
335 PVR_UNREFERENCED_PARAMETER(uiOffset);
336 PVR_UNREFERENCED_PARAMETER(ui32Value);
337 PVR_UNREFERENCED_PARAMETER(ui32Mask);
338 PVR_UNREFERENCED_PARAMETER(eOperator);
339 PVR_UNREFERENCED_PARAMETER(ui32PDumpFlags);
344 #ifdef INLINE_IS_PRAGMA
345 #pragma inline(DevmemPDumpCBP)
347 static INLINE PVRSRV_ERROR
348 DevmemPDumpCBP(const DEVMEM_MEMDESC *psMemDesc,
349 IMG_DEVMEM_OFFSET_T uiReadOffset,
350 IMG_DEVMEM_OFFSET_T uiWriteOffset,
351 IMG_DEVMEM_SIZE_T uiPacketSize,
352 IMG_DEVMEM_SIZE_T uiBufferSize)
354 PVR_UNREFERENCED_PARAMETER(psMemDesc);
355 PVR_UNREFERENCED_PARAMETER(uiReadOffset);
356 PVR_UNREFERENCED_PARAMETER(uiWriteOffset);
357 PVR_UNREFERENCED_PARAMETER(uiPacketSize);
358 PVR_UNREFERENCED_PARAMETER(uiBufferSize);
363 #endif /* DEVICEMEM_PDUMP_H */