drm/GPU: Add support Imagination PowerVR GPU driver v1.17
[platform/kernel/linux-starfive.git] / drivers / gpu / drm / img / img-rogue / services / shared / include / devicemem_pdump.h
1 /*************************************************************************/ /*!
2 @File
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
8
9 The contents of this file are subject to the MIT license as set out below.
10
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:
17
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
20
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.
24
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.
32
33 This License is also included in this distribution in the file called
34 "MIT-COPYING".
35
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 */ /**************************************************************************/
44
45 #ifndef DEVICEMEM_PDUMP_H
46 #define DEVICEMEM_PDUMP_H
47
48 #include "devicemem.h"
49 #include "pdumpdefs.h"
50 #include "pdump.h"
51
52 #if defined(PDUMP)
53 /*
54  * DevmemPDumpLoadMem()
55  *
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.
63  */
64 void
65 DevmemPDumpLoadMem(DEVMEM_MEMDESC *psMemDesc,
66                    IMG_DEVMEM_OFFSET_T uiOffset,
67                    IMG_DEVMEM_SIZE_T uiSize,
68                    PDUMP_FLAGS_T uiPDumpFlags);
69
70 /*
71  * DevmemPDumpLoadZeroMem()
72  *
73  * As DevmemPDumpLoadMem() but the PDump allocation will be populated with
74  * zeros from the zero page in the parameter stream
75  */
76 void
77 DevmemPDumpLoadZeroMem(DEVMEM_MEMDESC *psMemDesc,
78                        IMG_DEVMEM_OFFSET_T uiOffset,
79                        IMG_DEVMEM_SIZE_T uiSize,
80                        PDUMP_FLAGS_T uiPDumpFlags);
81
82 /*
83  * DevmemPDumpLoadMemValue32()
84  *
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.
88  *
89  * (The same functionality can be achieved by the above function but the
90  *  binary PARAM file must be patched in that case.)
91  */
92 IMG_INTERNAL void
93 DevmemPDumpLoadMemValue32(DEVMEM_MEMDESC *psMemDesc,
94                           IMG_DEVMEM_OFFSET_T uiOffset,
95                           IMG_UINT32 ui32Value,
96                           PDUMP_FLAGS_T uiPDumpFlags);
97
98 /*
99  * DevmemPDumpMemValue64()
100  *
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.
104  *
105  * (The same functionality can be achieved by the above function but the
106  *  binary PARAM file must be patched in that case.)
107  */
108 IMG_INTERNAL void
109 DevmemPDumpLoadMemValue64(DEVMEM_MEMDESC *psMemDesc,
110                           IMG_DEVMEM_OFFSET_T uiOffset,
111                           IMG_UINT64 ui64Value,
112                           PDUMP_FLAGS_T uiPDumpFlags);
113
114 /*
115  * DevmemPDumpPageCatBaseToSAddr()
116  *
117  * Returns the symbolic address of a piece of memory represented by an offset
118  * into the mem descriptor.
119  */
120 PVRSRV_ERROR
121 DevmemPDumpPageCatBaseToSAddr(DEVMEM_MEMDESC *psMemDesc,
122                               IMG_DEVMEM_OFFSET_T *puiMemOffset,
123                               IMG_CHAR *pszName,
124                               IMG_UINT32 ui32Size);
125
126 /*
127  * DevmemPDumpSaveToFile()
128  *
129  * Emits a pdump SAB to cause the current contents of the memory to be written
130  * to the given file during playback
131  */
132 void
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);
138
139 /*
140  * DevmemPDumpSaveToFileVirtual()
141  *
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.
145  */
146 void
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);
153
154 /*
155  * DevmemPDumpDataDescriptor()
156  *
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.
160  */
161 void
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);
170
171
172 /*
173  *
174  * DevmemPDumpDevmemPol32()
175  *
176  * Writes a PDump 'POL' command to wait for a masked 32-bit memory location to
177  * become the specified value.
178  */
179 PVRSRV_ERROR
180 DevmemPDumpDevmemPol32(const DEVMEM_MEMDESC *psMemDesc,
181                        IMG_DEVMEM_OFFSET_T uiOffset,
182                        IMG_UINT32 ui32Value,
183                        IMG_UINT32 ui32Mask,
184                        PDUMP_POLL_OPERATOR eOperator,
185                        PDUMP_FLAGS_T ui32PDumpFlags);
186
187 #if defined(__KERNEL__)
188 /*
189  *
190  * DevmemPDumpDevmemCheck32()
191  *
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.
194  */
195 PVRSRV_ERROR
196 DevmemPDumpDevmemCheck32(const DEVMEM_MEMDESC *psMemDesc,
197                          IMG_DEVMEM_OFFSET_T uiOffset,
198                          IMG_UINT32 ui32Value,
199                          IMG_UINT32 ui32Mask,
200                          PDUMP_POLL_OPERATOR eOperator,
201                          PDUMP_FLAGS_T ui32PDumpFlags);
202 #endif
203
204 /*
205  * DevmemPDumpCBP()
206  *
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.
209  *
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
215  */
216 PVRSRV_ERROR
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);
222
223 #else /* PDUMP */
224
225 #ifdef INLINE_IS_PRAGMA
226 #pragma inline(DevmemPDumpLoadMem)
227 #endif
228 static INLINE void
229 DevmemPDumpLoadMem(DEVMEM_MEMDESC *psMemDesc,
230                    IMG_DEVMEM_OFFSET_T uiOffset,
231                    IMG_DEVMEM_SIZE_T uiSize,
232                    PDUMP_FLAGS_T uiPDumpFlags)
233 {
234         PVR_UNREFERENCED_PARAMETER(psMemDesc);
235         PVR_UNREFERENCED_PARAMETER(uiOffset);
236         PVR_UNREFERENCED_PARAMETER(uiSize);
237         PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
238 }
239
240 #ifdef INLINE_IS_PRAGMA
241 #pragma inline(DevmemPDumpLoadMemValue32)
242 #endif
243 static INLINE void
244 DevmemPDumpLoadMemValue32(DEVMEM_MEMDESC *psMemDesc,
245                           IMG_DEVMEM_OFFSET_T uiOffset,
246                           IMG_UINT32 ui32Value,
247                           PDUMP_FLAGS_T uiPDumpFlags)
248 {
249         PVR_UNREFERENCED_PARAMETER(psMemDesc);
250         PVR_UNREFERENCED_PARAMETER(uiOffset);
251         PVR_UNREFERENCED_PARAMETER(ui32Value);
252         PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
253 }
254
255 #ifdef INLINE_IS_PRAGMA
256 #pragma inline(DevmemPDumpLoadMemValue64)
257 #endif
258 static INLINE void
259 DevmemPDumpLoadMemValue64(DEVMEM_MEMDESC *psMemDesc,
260                           IMG_DEVMEM_OFFSET_T uiOffset,
261                           IMG_UINT64 ui64Value,
262                           PDUMP_FLAGS_T uiPDumpFlags)
263 {
264         PVR_UNREFERENCED_PARAMETER(psMemDesc);
265         PVR_UNREFERENCED_PARAMETER(uiOffset);
266         PVR_UNREFERENCED_PARAMETER(ui64Value);
267         PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
268 }
269
270 #ifdef INLINE_IS_PRAGMA
271 #pragma inline(DevmemPDumpPageCatBaseToSAddr)
272 #endif
273 static INLINE PVRSRV_ERROR
274 DevmemPDumpPageCatBaseToSAddr(DEVMEM_MEMDESC *psMemDesc,
275                               IMG_DEVMEM_OFFSET_T *puiMemOffset,
276                               IMG_CHAR *pszName,
277                               IMG_UINT32 ui32Size)
278 {
279         PVR_UNREFERENCED_PARAMETER(psMemDesc);
280         PVR_UNREFERENCED_PARAMETER(puiMemOffset);
281         PVR_UNREFERENCED_PARAMETER(pszName);
282         PVR_UNREFERENCED_PARAMETER(ui32Size);
283
284         return PVRSRV_OK;
285 }
286
287 #ifdef INLINE_IS_PRAGMA
288 #pragma inline(DevmemPDumpSaveToFile)
289 #endif
290 static INLINE void
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)
296 {
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);
302 }
303
304 #ifdef INLINE_IS_PRAGMA
305 #pragma inline(DevmemPDumpSaveToFileVirtual)
306 #endif
307 static INLINE void
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)
314 {
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);
321 }
322
323 #ifdef INLINE_IS_PRAGMA
324 #pragma inline(DevmemPDumpDevmemPol32)
325 #endif
326 static INLINE PVRSRV_ERROR
327 DevmemPDumpDevmemPol32(const DEVMEM_MEMDESC *psMemDesc,
328                        IMG_DEVMEM_OFFSET_T uiOffset,
329                        IMG_UINT32 ui32Value,
330                        IMG_UINT32 ui32Mask,
331                        PDUMP_POLL_OPERATOR eOperator,
332                        PDUMP_FLAGS_T ui32PDumpFlags)
333 {
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);
340
341         return PVRSRV_OK;
342 }
343
344 #ifdef INLINE_IS_PRAGMA
345 #pragma inline(DevmemPDumpCBP)
346 #endif
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)
353 {
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);
359
360         return PVRSRV_OK;
361 }
362 #endif /* PDUMP */
363 #endif /* DEVICEMEM_PDUMP_H */