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"
56 * takes a memory descriptor, offset, and size, and takes the current
57 * contents of the memory at that location and writes it to the prm
58 * pdump file, and emits a pdump LDB to load the data from that file.
59 * The intention here is that the contents of the simulated buffer
60 * upon pdump playback will be made to be the same as they are when
61 * this command is run, enabling pdump of cases where the memory has
62 * been modified externally, i.e. by the host cpu or by a third
66 DevmemPDumpLoadMem(DEVMEM_MEMDESC *psMemDesc,
67 IMG_DEVMEM_OFFSET_T uiOffset,
68 IMG_DEVMEM_SIZE_T uiSize,
69 PDUMP_FLAGS_T uiPDumpFlags);
72 * DevmemPDumpZeroMem()
74 * as DevmemPDumpMem() but the PDump allocation will be populated with zeros from
75 * the zero page in the parameter stream
78 DevmemPDumpLoadZeroMem(DEVMEM_MEMDESC *psMemDesc,
79 IMG_DEVMEM_OFFSET_T uiOffset,
80 IMG_DEVMEM_SIZE_T uiSize,
81 PDUMP_FLAGS_T uiPDumpFlags);
84 * DevmemPDumpMemValue()
86 * As above but dumps the value at a dword-aligned address in plain
87 * text to the pdump script2 file. Useful for patching a buffer at
88 * pdump playback by simply editing the script output file.
90 * (The same functionality can be achieved by the above function but
91 * the binary PARAM file must be patched in that case.)
94 DevmemPDumpLoadMemValue32(DEVMEM_MEMDESC *psMemDesc,
95 IMG_DEVMEM_OFFSET_T uiOffset,
97 PDUMP_FLAGS_T uiPDumpFlags);
100 * DevmemPDumpMemValue64()
102 * As above but dumps the 64bit-value at a dword-aligned address in plain
103 * text to the pdump script2 file. Useful for patching a buffer at
104 * pdump playback by simply editing the script output file.
106 * (The same functionality can be achieved by the above function but
107 * the binary PARAM file must be patched in that case.)
110 DevmemPDumpLoadMemValue64(DEVMEM_MEMDESC *psMemDesc,
111 IMG_DEVMEM_OFFSET_T uiOffset,
112 IMG_UINT64 ui64Value,
113 PDUMP_FLAGS_T uiPDumpFlags);
116 * DevmemPDumpPageCatBaseToSAddr()
118 * Returns the symbolic address of a piece of memory represented
119 * by an offset into the mem descriptor.
122 DevmemPDumpPageCatBaseToSAddr(DEVMEM_MEMDESC *psMemDesc,
123 IMG_DEVMEM_OFFSET_T *puiMemOffset,
125 IMG_UINT32 ui32Size);
128 * DevmemPDumpSaveToFile()
130 * emits a pdump SAB to cause the current contents of the memory to be
131 * written to the given file during playback
134 DevmemPDumpSaveToFile(DEVMEM_MEMDESC *psMemDesc,
135 IMG_DEVMEM_OFFSET_T uiOffset,
136 IMG_DEVMEM_SIZE_T uiSize,
137 const IMG_CHAR *pszFilename,
138 IMG_UINT32 uiFileOffset);
141 * DevmemPDumpSaveToFileVirtual()
143 * emits a pdump SAB, just like DevmemPDumpSaveToFile(), but uses the
144 * virtual address and device MMU context to cause the pdump player to
145 * traverse the MMU page tables itself.
148 DevmemPDumpSaveToFileVirtual(DEVMEM_MEMDESC *psMemDesc,
149 IMG_DEVMEM_OFFSET_T uiOffset,
150 IMG_DEVMEM_SIZE_T uiSize,
151 const IMG_CHAR *pszFilename,
152 IMG_UINT32 ui32FileOffset,
153 IMG_UINT32 ui32PdumpFlags);
158 * Devmem_PDumpDevmemPol32()
160 * writes a PDump 'POL' command to wait for a masked 32-bit memory
161 * location to become the specified value
164 DevmemPDumpDevmemPol32(const DEVMEM_MEMDESC *psMemDesc,
165 IMG_DEVMEM_OFFSET_T uiOffset,
166 IMG_UINT32 ui32Value,
168 PDUMP_POLL_OPERATOR eOperator,
169 PDUMP_FLAGS_T ui32PDumpFlags);
174 * Polls for space in circular buffer. Reads the read offset
175 * from memory and waits until there is enough space to write
178 * hMemDesc - MemDesc which contains the read offset
179 * uiReadOffset - Offset into MemDesc to the read offset
180 * uiWriteOffset - Current write offset
181 * uiPacketSize - Size of packet to write
182 * uiBufferSize - Size of circular buffer
185 DevmemPDumpCBP(const DEVMEM_MEMDESC *psMemDesc,
186 IMG_DEVMEM_OFFSET_T uiReadOffset,
187 IMG_DEVMEM_OFFSET_T uiWriteOffset,
188 IMG_DEVMEM_SIZE_T uiPacketSize,
189 IMG_DEVMEM_SIZE_T uiBufferSize);
193 #ifdef INLINE_IS_PRAGMA
194 #pragma inline(DevmemPDumpLoadMem)
197 DevmemPDumpLoadMem(DEVMEM_MEMDESC *psMemDesc,
198 IMG_DEVMEM_OFFSET_T uiOffset,
199 IMG_DEVMEM_SIZE_T uiSize,
200 PDUMP_FLAGS_T uiPDumpFlags)
202 PVR_UNREFERENCED_PARAMETER(psMemDesc);
203 PVR_UNREFERENCED_PARAMETER(uiOffset);
204 PVR_UNREFERENCED_PARAMETER(uiSize);
205 PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
208 #ifdef INLINE_IS_PRAGMA
209 #pragma inline(DevmemPDumpLoadMemValue32)
212 DevmemPDumpLoadMemValue32(DEVMEM_MEMDESC *psMemDesc,
213 IMG_DEVMEM_OFFSET_T uiOffset,
214 IMG_UINT32 ui32Value,
215 PDUMP_FLAGS_T uiPDumpFlags)
217 PVR_UNREFERENCED_PARAMETER(psMemDesc);
218 PVR_UNREFERENCED_PARAMETER(uiOffset);
219 PVR_UNREFERENCED_PARAMETER(ui32Value);
220 PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
223 #ifdef INLINE_IS_PRAGMA
224 #pragma inline(DevmemPDumpLoadMemValue64)
227 DevmemPDumpLoadMemValue64(DEVMEM_MEMDESC *psMemDesc,
228 IMG_DEVMEM_OFFSET_T uiOffset,
229 IMG_UINT64 ui64Value,
230 PDUMP_FLAGS_T uiPDumpFlags)
232 PVR_UNREFERENCED_PARAMETER(psMemDesc);
233 PVR_UNREFERENCED_PARAMETER(uiOffset);
234 PVR_UNREFERENCED_PARAMETER(ui64Value);
235 PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
238 #ifdef INLINE_IS_PRAGMA
239 #pragma inline(DevmemPDumpLoadMemValue)
242 DevmemPDumpLoadMemValue(DEVMEM_MEMDESC *psMemDesc,
243 IMG_DEVMEM_OFFSET_T uiOffset,
244 IMG_UINT32 ui32Value,
245 PDUMP_FLAGS_T uiPDumpFlags)
247 PVR_UNREFERENCED_PARAMETER(psMemDesc);
248 PVR_UNREFERENCED_PARAMETER(uiOffset);
249 PVR_UNREFERENCED_PARAMETER(ui32Value);
250 PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
253 #ifdef INLINE_IS_PRAGMA
254 #pragma inline(DevmemPDumpPageCatBaseToSAddr)
256 static INLINE PVRSRV_ERROR
257 DevmemPDumpPageCatBaseToSAddr(DEVMEM_MEMDESC *psMemDesc,
258 IMG_DEVMEM_OFFSET_T *puiMemOffset,
262 PVR_UNREFERENCED_PARAMETER(psMemDesc);
263 PVR_UNREFERENCED_PARAMETER(puiMemOffset);
264 PVR_UNREFERENCED_PARAMETER(pszName);
265 PVR_UNREFERENCED_PARAMETER(ui32Size);
270 #ifdef INLINE_IS_PRAGMA
271 #pragma inline(DevmemPDumpSaveToFile)
274 DevmemPDumpSaveToFile(DEVMEM_MEMDESC *psMemDesc,
275 IMG_DEVMEM_OFFSET_T uiOffset,
276 IMG_DEVMEM_SIZE_T uiSize,
277 const IMG_CHAR *pszFilename,
278 IMG_UINT32 uiFileOffset)
280 PVR_UNREFERENCED_PARAMETER(psMemDesc);
281 PVR_UNREFERENCED_PARAMETER(uiOffset);
282 PVR_UNREFERENCED_PARAMETER(uiSize);
283 PVR_UNREFERENCED_PARAMETER(pszFilename);
284 PVR_UNREFERENCED_PARAMETER(uiFileOffset);
287 #ifdef INLINE_IS_PRAGMA
288 #pragma inline(DevmemPDumpSaveToFileVirtual)
291 DevmemPDumpSaveToFileVirtual(DEVMEM_MEMDESC *psMemDesc,
292 IMG_DEVMEM_OFFSET_T uiOffset,
293 IMG_DEVMEM_SIZE_T uiSize,
294 const IMG_CHAR *pszFilename,
295 IMG_UINT32 ui32FileOffset,
296 IMG_UINT32 ui32PdumpFlags)
298 PVR_UNREFERENCED_PARAMETER(psMemDesc);
299 PVR_UNREFERENCED_PARAMETER(uiOffset);
300 PVR_UNREFERENCED_PARAMETER(uiSize);
301 PVR_UNREFERENCED_PARAMETER(pszFilename);
302 PVR_UNREFERENCED_PARAMETER(ui32FileOffset);
303 PVR_UNREFERENCED_PARAMETER(ui32PdumpFlags);
306 #ifdef INLINE_IS_PRAGMA
307 #pragma inline(DevmemPDumpDevmemPol32)
309 static INLINE PVRSRV_ERROR
310 DevmemPDumpDevmemPol32(const DEVMEM_MEMDESC *psMemDesc,
311 IMG_DEVMEM_OFFSET_T uiOffset,
312 IMG_UINT32 ui32Value,
314 PDUMP_POLL_OPERATOR eOperator,
315 PDUMP_FLAGS_T ui32PDumpFlags)
317 PVR_UNREFERENCED_PARAMETER(psMemDesc);
318 PVR_UNREFERENCED_PARAMETER(uiOffset);
319 PVR_UNREFERENCED_PARAMETER(ui32Value);
320 PVR_UNREFERENCED_PARAMETER(ui32Mask);
321 PVR_UNREFERENCED_PARAMETER(eOperator);
322 PVR_UNREFERENCED_PARAMETER(ui32PDumpFlags);
327 #ifdef INLINE_IS_PRAGMA
328 #pragma inline(DevmemPDumpCBP)
330 static INLINE PVRSRV_ERROR
331 DevmemPDumpCBP(const DEVMEM_MEMDESC *psMemDesc,
332 IMG_DEVMEM_OFFSET_T uiReadOffset,
333 IMG_DEVMEM_OFFSET_T uiWriteOffset,
334 IMG_DEVMEM_SIZE_T uiPacketSize,
335 IMG_DEVMEM_SIZE_T uiBufferSize)
337 PVR_UNREFERENCED_PARAMETER(psMemDesc);
338 PVR_UNREFERENCED_PARAMETER(uiReadOffset);
339 PVR_UNREFERENCED_PARAMETER(uiWriteOffset);
340 PVR_UNREFERENCED_PARAMETER(uiPacketSize);
341 PVR_UNREFERENCED_PARAMETER(uiBufferSize);
346 #endif /* _DEVICEMEM_PDUMP_H_ */