RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / 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  * DevmemPDumpMem()
55  *
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
63  * party.
64  */
65 extern void
66 DevmemPDumpLoadMem(DEVMEM_MEMDESC *psMemDesc,
67                    IMG_DEVMEM_OFFSET_T uiOffset,
68                    IMG_DEVMEM_SIZE_T uiSize,
69                    PDUMP_FLAGS_T uiPDumpFlags);
70
71 /*
72  * DevmemPDumpZeroMem()
73  *
74  * as DevmemPDumpMem() but the PDump allocation will be populated with zeros from
75  * the zero page in the parameter stream
76  */
77 extern void
78 DevmemPDumpLoadZeroMem(DEVMEM_MEMDESC *psMemDesc,
79                    IMG_DEVMEM_OFFSET_T uiOffset,
80                    IMG_DEVMEM_SIZE_T uiSize,
81                    PDUMP_FLAGS_T uiPDumpFlags);
82
83 /*
84  * DevmemPDumpMemValue()
85  * 
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.
89  * 
90  * (The same functionality can be achieved by the above function but
91  *  the binary PARAM file must be patched in that case.)
92  */
93 IMG_INTERNAL void
94 DevmemPDumpLoadMemValue32(DEVMEM_MEMDESC *psMemDesc,
95                         IMG_DEVMEM_OFFSET_T uiOffset,
96                         IMG_UINT32 ui32Value,
97                         PDUMP_FLAGS_T uiPDumpFlags);
98
99 /*
100  * DevmemPDumpMemValue64()
101  *
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.
105  *
106  * (The same functionality can be achieved by the above function but
107  *  the binary PARAM file must be patched in that case.)
108  */
109 IMG_INTERNAL void
110 DevmemPDumpLoadMemValue64(DEVMEM_MEMDESC *psMemDesc,
111                         IMG_DEVMEM_OFFSET_T uiOffset,
112                         IMG_UINT64 ui64Value,
113                         PDUMP_FLAGS_T uiPDumpFlags);
114
115 /*
116  * DevmemPDumpPageCatBaseToSAddr()
117  *
118  * Returns the symbolic address of a piece of memory represented
119  * by an offset into the mem descriptor.
120  */
121 extern PVRSRV_ERROR
122 DevmemPDumpPageCatBaseToSAddr(DEVMEM_MEMDESC            *psMemDesc,
123                                                           IMG_DEVMEM_OFFSET_T   *puiMemOffset,
124                                                           IMG_CHAR                              *pszName,
125                                                           IMG_UINT32                    ui32Size);
126
127 /*
128  * DevmemPDumpSaveToFile()
129  *
130  * emits a pdump SAB to cause the current contents of the memory to be
131  * written to the given file during playback
132  */
133 extern void
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);
139
140 /*
141  * DevmemPDumpSaveToFileVirtual()
142  *
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.
146  */
147 extern void
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);
154
155
156 /*
157  *
158  * Devmem_PDumpDevmemPol32()
159  *
160  * writes a PDump 'POL' command to wait for a masked 32-bit memory
161  * location to become the specified value
162  */
163 extern PVRSRV_ERROR
164 DevmemPDumpDevmemPol32(const DEVMEM_MEMDESC *psMemDesc,
165                            IMG_DEVMEM_OFFSET_T uiOffset,
166                            IMG_UINT32 ui32Value,
167                            IMG_UINT32 ui32Mask,
168                            PDUMP_POLL_OPERATOR eOperator,
169                            PDUMP_FLAGS_T ui32PDumpFlags);
170
171 /*
172  * DevmemPDumpCBP()
173  *
174  * Polls for space in circular buffer. Reads the read offset
175  * from memory and waits until there is enough space to write
176  * the packet.
177  *
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
183  */
184 extern PVRSRV_ERROR
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);
190
191 #else   /* PDUMP */
192
193 #ifdef INLINE_IS_PRAGMA
194 #pragma inline(DevmemPDumpLoadMem)
195 #endif
196 static INLINE void
197 DevmemPDumpLoadMem(DEVMEM_MEMDESC *psMemDesc,
198                    IMG_DEVMEM_OFFSET_T uiOffset,
199                    IMG_DEVMEM_SIZE_T uiSize,
200                    PDUMP_FLAGS_T uiPDumpFlags)
201 {
202         PVR_UNREFERENCED_PARAMETER(psMemDesc);
203         PVR_UNREFERENCED_PARAMETER(uiOffset);
204         PVR_UNREFERENCED_PARAMETER(uiSize);
205         PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
206 }
207
208 #ifdef INLINE_IS_PRAGMA
209 #pragma inline(DevmemPDumpLoadMemValue32)
210 #endif
211 static INLINE void
212 DevmemPDumpLoadMemValue32(DEVMEM_MEMDESC *psMemDesc,
213                         IMG_DEVMEM_OFFSET_T uiOffset,
214                         IMG_UINT32 ui32Value,
215                         PDUMP_FLAGS_T uiPDumpFlags)
216 {
217         PVR_UNREFERENCED_PARAMETER(psMemDesc);
218         PVR_UNREFERENCED_PARAMETER(uiOffset);
219         PVR_UNREFERENCED_PARAMETER(ui32Value);
220         PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
221 }
222
223 #ifdef INLINE_IS_PRAGMA
224 #pragma inline(DevmemPDumpLoadMemValue64)
225 #endif
226 static INLINE void
227 DevmemPDumpLoadMemValue64(DEVMEM_MEMDESC *psMemDesc,
228                         IMG_DEVMEM_OFFSET_T uiOffset,
229                         IMG_UINT64 ui64Value,
230                         PDUMP_FLAGS_T uiPDumpFlags)
231 {
232         PVR_UNREFERENCED_PARAMETER(psMemDesc);
233         PVR_UNREFERENCED_PARAMETER(uiOffset);
234         PVR_UNREFERENCED_PARAMETER(ui64Value);
235         PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
236 }
237
238 #ifdef INLINE_IS_PRAGMA
239 #pragma inline(DevmemPDumpLoadMemValue)
240 #endif
241 static INLINE void
242 DevmemPDumpLoadMemValue(DEVMEM_MEMDESC *psMemDesc,
243                         IMG_DEVMEM_OFFSET_T uiOffset,
244                         IMG_UINT32 ui32Value,
245                         PDUMP_FLAGS_T uiPDumpFlags)
246 {
247         PVR_UNREFERENCED_PARAMETER(psMemDesc);
248         PVR_UNREFERENCED_PARAMETER(uiOffset);
249         PVR_UNREFERENCED_PARAMETER(ui32Value);
250         PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
251 }
252
253 #ifdef INLINE_IS_PRAGMA
254 #pragma inline(DevmemPDumpPageCatBaseToSAddr)
255 #endif
256 static INLINE PVRSRV_ERROR
257 DevmemPDumpPageCatBaseToSAddr(DEVMEM_MEMDESC            *psMemDesc,
258                                                           IMG_DEVMEM_OFFSET_T   *puiMemOffset,
259                                                           IMG_CHAR                              *pszName,
260                                                           IMG_UINT32                    ui32Size)
261 {
262         PVR_UNREFERENCED_PARAMETER(psMemDesc);
263         PVR_UNREFERENCED_PARAMETER(puiMemOffset);
264         PVR_UNREFERENCED_PARAMETER(pszName);
265         PVR_UNREFERENCED_PARAMETER(ui32Size);
266
267         return PVRSRV_OK;
268 }
269
270 #ifdef INLINE_IS_PRAGMA
271 #pragma inline(DevmemPDumpSaveToFile)
272 #endif
273 static INLINE void
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)
279 {
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);
285 }
286
287 #ifdef INLINE_IS_PRAGMA
288 #pragma inline(DevmemPDumpSaveToFileVirtual)
289 #endif
290 static INLINE void
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)
297 {
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);
304 }
305
306 #ifdef INLINE_IS_PRAGMA
307 #pragma inline(DevmemPDumpDevmemPol32)
308 #endif
309 static INLINE PVRSRV_ERROR
310 DevmemPDumpDevmemPol32(const DEVMEM_MEMDESC *psMemDesc,
311                            IMG_DEVMEM_OFFSET_T uiOffset,
312                            IMG_UINT32 ui32Value,
313                            IMG_UINT32 ui32Mask,
314                            PDUMP_POLL_OPERATOR eOperator,
315                            PDUMP_FLAGS_T ui32PDumpFlags)
316 {
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);
323
324         return PVRSRV_OK;
325 }
326
327 #ifdef INLINE_IS_PRAGMA
328 #pragma inline(DevmemPDumpCBP)
329 #endif
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)
336 {
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);
342
343         return PVRSRV_OK;
344 }
345 #endif  /* PDUMP */
346 #endif  /* _DEVICEMEM_PDUMP_H_ */