drm/GPU: Add support Imagination PowerVR GPU driver v1.17
[platform/kernel/linux-starfive.git] / drivers / gpu / drm / img / img-rogue / services / server / include / pdump_physmem.h
1 /**************************************************************************/ /*!
2 @File
3 @Title          pdump functions to assist with physmem allocations
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Implements basic low level control of MMU.
6 @License        Dual MIT/GPLv2
7
8 The contents of this file are subject to the MIT license as set out below.
9
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
23
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
31
32 This License is also included in this distribution in the file called
33 "MIT-COPYING".
34
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /***************************************************************************/
43
44 #ifndef SRVSRV_PDUMP_PHYSMEM_H
45 #define SRVSRV_PDUMP_PHYSMEM_H
46
47 #include "img_types.h"
48 #include "img_defs.h"
49 #include "pvrsrv_error.h"
50 #include "pmr.h"
51 #include "device.h" /* For device node */
52
53 #define PHYSMEM_PDUMP_MEMSPACE_MAX_LENGTH 40
54 #define PHYSMEM_PDUMP_SYMNAME_MAX_LENGTH 60
55 #define PHYSMEM_PDUMP_MEMSPNAME_SYMB_ADDR_MAX_LENGTH (PHYSMEM_PDUMP_SYMNAME_MAX_LENGTH + PHYSMEM_PDUMP_MEMSPACE_MAX_LENGTH)
56
57 typedef struct _PDUMP_PHYSMEM_INFO_T_ PDUMP_PHYSMEM_INFO_T;
58
59 #if defined(PDUMP)
60 PVRSRV_ERROR
61 PDumpGetSymbolicAddr(const IMG_HANDLE hPhysmemPDumpHandle,
62                      IMG_CHAR **ppszSymbolicAddress);
63
64 PVRSRV_ERROR
65 PDumpMalloc(PVRSRV_DEVICE_NODE *psDeviceNode,
66             const IMG_CHAR *pszDevSpace,
67             const IMG_CHAR *pszSymbolicAddress,
68             IMG_UINT64 ui64Size,
69             /* alignment is alignment of start of buffer _and_
70                minimum contiguity - i.e. smallest allowable
71                page-size. */
72             IMG_DEVMEM_ALIGN_T uiAlign,
73             IMG_BOOL bInitialise,
74             IMG_UINT32 ui32InitValue,
75             IMG_HANDLE *phHandlePtr,
76             IMG_UINT32 ui32PDumpFlags);
77
78 PVRSRV_ERROR
79 PDumpFree(PVRSRV_DEVICE_NODE *psDeviceNode,
80           IMG_HANDLE hPDumpAllocationInfoHandle);
81
82 void
83 PDumpMakeStringValid(IMG_CHAR *pszString,
84                      IMG_UINT32 ui32StrLen);
85 #else /* PDUMP */
86
87 #ifdef INLINE_IS_PRAGMA
88 #pragma inline(PDumpGetSymbolicAddr)
89 #endif
90 static INLINE PVRSRV_ERROR
91 PDumpGetSymbolicAddr(const IMG_HANDLE hPhysmemPDumpHandle,
92                      IMG_CHAR **ppszSymbolicAddress)
93 {
94         PVR_UNREFERENCED_PARAMETER(hPhysmemPDumpHandle);
95         PVR_UNREFERENCED_PARAMETER(ppszSymbolicAddress);
96         return PVRSRV_OK;
97 }
98
99 static INLINE PVRSRV_ERROR
100 PDumpMalloc(const IMG_CHAR *pszDevSpace,
101             const IMG_CHAR *pszSymbolicAddress,
102             IMG_UINT64 ui64Size,
103             IMG_DEVMEM_ALIGN_T uiAlign,
104             IMG_BOOL bInitialise,
105             IMG_UINT32 ui32InitValue,
106             IMG_HANDLE *phHandlePtr,
107             IMG_UINT32 ui32PDumpFlags)
108 {
109         PVR_UNREFERENCED_PARAMETER(pszDevSpace);
110         PVR_UNREFERENCED_PARAMETER(pszSymbolicAddress);
111         PVR_UNREFERENCED_PARAMETER(ui64Size);
112         PVR_UNREFERENCED_PARAMETER(uiAlign);
113         PVR_UNREFERENCED_PARAMETER(bInitialise);
114         PVR_UNREFERENCED_PARAMETER(ui32InitValue);
115         PVR_UNREFERENCED_PARAMETER(phHandlePtr);
116         PVR_UNREFERENCED_PARAMETER(ui32PDumpFlags);
117         return PVRSRV_OK;
118 }
119
120 static INLINE PVRSRV_ERROR
121 PDumpFree(IMG_HANDLE hPDumpAllocationInfoHandle)
122 {
123         PVR_UNREFERENCED_PARAMETER(hPDumpAllocationInfoHandle);
124         return PVRSRV_OK;
125 }
126 #endif /* PDUMP */
127
128 #define PMR_DEFAULT_PREFIX "PMR"
129 #define PMR_SYMBOLICADDR_FMTSPEC "%s%"IMG_UINT64_FMTSPEC"_%"IMG_UINT64_FMTSPEC"_%s"
130 #define PMR_MEMSPACE_FMTSPEC "%s"
131 #define PMR_MEMSPACE_CACHE_COHERENT_FMTSPEC "CC_%s"
132
133 #if defined(PDUMP)
134 #define PDUMP_PHYSMEM_MALLOC_OSPAGES(pszPDumpMemDevName, ui32SerialNum, ui32Size, ui32Align, bInitialise, ui32InitValue, phHandlePtr) \
135     PDumpMalloc(pszPDumpMemDevName, PMR_OSALLOCPAGES_PREFIX, ui32SerialNum, ui32Size, ui32Align, bInitialise, ui32InitValue, phHandlePtr, PDUMP_NONE)
136 #define PDUMP_PHYSMEM_FREE_OSPAGES(hHandle) \
137     PDumpFree(hHandle)
138 #else
139 #define PDUMP_PHYSMEM_MALLOC_OSPAGES(pszPDumpMemDevName, ui32SerialNum, ui32Size, ui32Align, bInitialise, ui32InitValue, phHandlePtr) \
140     ((void)(*phHandlePtr=NULL))
141 #define PDUMP_PHYSMEM_FREE_OSPAGES(hHandle) \
142     ((void)(0))
143 #endif /* PDUMP */
144
145 PVRSRV_ERROR
146 PDumpPMRWRW32(PVRSRV_DEVICE_NODE *psDeviceNode,
147               const IMG_CHAR *pszDevSpace,
148               const IMG_CHAR *pszSymbolicName,
149               IMG_DEVMEM_OFFSET_T uiOffset,
150               IMG_UINT32 ui32Value,
151               PDUMP_FLAGS_T uiPDumpFlags);
152
153 PVRSRV_ERROR
154 PDumpPMRWRW32InternalVarToMem(PVRSRV_DEVICE_NODE *psDeviceNode,
155                               const IMG_CHAR *pszDevSpace,
156                               const IMG_CHAR *pszSymbolicName,
157                               IMG_DEVMEM_OFFSET_T uiOffset,
158                               const IMG_CHAR *pszInternalVar,
159                               PDUMP_FLAGS_T uiPDumpFlags);
160
161 PVRSRV_ERROR
162 PDumpPMRRDW32MemToInternalVar(PVRSRV_DEVICE_NODE *psDeviceNode,
163                               const IMG_CHAR *pszInternalVar,
164                               const IMG_CHAR *pszDevSpace,
165                               const IMG_CHAR *pszSymbolicName,
166                               IMG_DEVMEM_OFFSET_T uiOffset,
167                               PDUMP_FLAGS_T uiPDumpFlags);
168
169 PVRSRV_ERROR
170 PDumpPMRWRW64(PVRSRV_DEVICE_NODE *psDeviceNode,
171               const IMG_CHAR *pszDevSpace,
172               const IMG_CHAR *pszSymbolicName,
173               IMG_DEVMEM_OFFSET_T uiOffset,
174               IMG_UINT64 ui64Value,
175               PDUMP_FLAGS_T uiPDumpFlags);
176
177 PVRSRV_ERROR
178 PDumpPMRWRW64InternalVarToMem(PVRSRV_DEVICE_NODE *psDeviceNode,
179                               const IMG_CHAR *pszDevSpace,
180                               const IMG_CHAR *pszSymbolicName,
181                               IMG_DEVMEM_OFFSET_T uiOffset,
182                               const IMG_CHAR *pszInternalVar,
183                               PDUMP_FLAGS_T uiPDumpFlags);
184
185 PVRSRV_ERROR
186 PDumpPMRRDW64MemToInternalVar(PVRSRV_DEVICE_NODE *psDeviceNode,
187                               const IMG_CHAR *pszInternalVar,
188                               const IMG_CHAR *pszDevSpace,
189                               const IMG_CHAR *pszSymbolicName,
190                               IMG_DEVMEM_OFFSET_T uiOffset,
191                               PDUMP_FLAGS_T uiPDumpFlags);
192
193 PVRSRV_ERROR
194 PDumpPMRLDB(PVRSRV_DEVICE_NODE *psDeviceNode,
195             const IMG_CHAR *pszDevSpace,
196             const IMG_CHAR *pszSymbolicName,
197             IMG_DEVMEM_OFFSET_T uiOffset,
198             IMG_DEVMEM_SIZE_T uiSize,
199             const IMG_CHAR *pszFilename,
200             IMG_UINT32 uiFileOffset,
201             PDUMP_FLAGS_T uiPDumpFlags);
202
203 PVRSRV_ERROR
204 PDumpPMRSAB(PVRSRV_DEVICE_NODE *psDeviceNode,
205             const IMG_CHAR *pszDevSpace,
206             const IMG_CHAR *pszSymbolicName,
207             IMG_DEVMEM_OFFSET_T uiOffset,
208             IMG_DEVMEM_SIZE_T uiSize,
209             const IMG_CHAR *pszFileName,
210             IMG_UINT32 uiFileOffset);
211
212 /*
213   PDumpPMRPOL()
214
215   Emits a POL to the PDUMP.
216 */
217 PVRSRV_ERROR
218 PDumpPMRPOL(PVRSRV_DEVICE_NODE *psDeviceNode,
219             const IMG_CHAR *pszMempaceName,
220             const IMG_CHAR *pszSymbolicName,
221             IMG_DEVMEM_OFFSET_T uiOffset,
222             IMG_UINT32 ui32Value,
223             IMG_UINT32 ui32Mask,
224             PDUMP_POLL_OPERATOR eOperator,
225             IMG_UINT32 uiCount,
226             IMG_UINT32 uiDelay,
227             PDUMP_FLAGS_T uiPDumpFlags);
228
229 PVRSRV_ERROR
230 PDumpPMRCBP(PVRSRV_DEVICE_NODE *psDeviceNode,
231             const IMG_CHAR *pszMemspaceName,
232             const IMG_CHAR *pszSymbolicName,
233             IMG_DEVMEM_OFFSET_T uiReadOffset,
234             IMG_DEVMEM_OFFSET_T uiWriteOffset,
235             IMG_DEVMEM_SIZE_T uiPacketSize,
236             IMG_DEVMEM_SIZE_T uiBufferSize);
237
238 /*
239  * PDumpWriteParameterBlob()
240  *
241  * Writes a binary blob to the pdump param stream containing the current
242  * contents of the memory, and returns the filename and offset of where
243  * that blob is located (for use in a subsequent LDB, for example).
244  *
245  * Caller to provide buffer to receive filename, and declare the size of
246  * that buffer.
247  */
248 PVRSRV_ERROR
249 PDumpWriteParameterBlob(PVRSRV_DEVICE_NODE *psDeviceNode,
250                         IMG_UINT8 *pcBuffer,
251                         size_t uiNumBytes,
252                         PDUMP_FLAGS_T uiPDumpFlags,
253                         IMG_CHAR *pszFilenameOut,
254                         size_t uiFilenameBufSz,
255                         PDUMP_FILEOFFSET_T *puiOffsetOut);
256
257 #endif /* #ifndef SRVSRV_PDUMP_PHYSMEM_H */