RK3368 GPU version Rogue M 1.28
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue_m / 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 "pvrsrv_error.h"
49 #include "pmr.h"
50
51
52 typedef struct _PDUMP_PHYSMEM_INFO_T_ PDUMP_PHYSMEM_INFO_T;
53
54 #if defined(PDUMP)
55 extern PVRSRV_ERROR
56 PDumpPMRMalloc(const IMG_CHAR *pszDevSpace,
57                const IMG_CHAR *pszSymbolicAddress,
58                IMG_UINT64 ui64Size,
59                /* alignment is alignment of start of buffer _and_
60                   minimum contiguity - i.e. smallest allowable
61                   page-size. */
62                IMG_DEVMEM_ALIGN_T uiAlign,
63                IMG_BOOL bForcePersistent,
64                IMG_HANDLE *phHandlePtr);
65
66 IMG_INTERNAL IMG_VOID
67 PDumpPMRMallocPMR(const PMR *psPMR,
68                   IMG_DEVMEM_SIZE_T uiSize,
69                   IMG_DEVMEM_ALIGN_T uiBlockSize,
70                   IMG_BOOL bForcePersistent,
71                   IMG_HANDLE *phPDumpAllocInfoPtr);
72
73 extern
74 PVRSRV_ERROR PDumpPMRFree(IMG_HANDLE hPDumpAllocationInfoHandle);
75 #else   /* PDUMP */
76
77 #ifdef INLINE_IS_PRAGMA
78 #pragma inline(PVRSRVSyncPrimPDumpPolKM)
79 #endif
80 static INLINE PVRSRV_ERROR
81 PDumpPMRMalloc(const IMG_CHAR *pszDevSpace,
82                const IMG_CHAR *pszSymbolicAddress,
83                IMG_UINT64 ui64Size,
84                IMG_DEVMEM_ALIGN_T uiAlign,
85                IMG_BOOL bForcePersistent,
86                IMG_HANDLE *phHandlePtr)
87 {
88         PVR_UNREFERENCED_PARAMETER(pszDevSpace);
89         PVR_UNREFERENCED_PARAMETER(pszSymbolicAddress);
90         PVR_UNREFERENCED_PARAMETER(ui64Size);
91         PVR_UNREFERENCED_PARAMETER(uiAlign);
92         PVR_UNREFERENCED_PARAMETER(bForcePersistent);
93         PVR_UNREFERENCED_PARAMETER(phHandlePtr);
94         PVR_UNREFERENCED_PARAMETER(bForcePersistent);
95         return PVRSRV_OK;
96 }
97
98 static INLINE IMG_VOID
99 PDumpPMRMallocPMR(const PMR *psPMR,
100                   IMG_DEVMEM_SIZE_T uiSize,
101                   IMG_DEVMEM_ALIGN_T uiBlockSize,
102                   IMG_BOOL bForcePersistent,
103                   IMG_HANDLE *phPDumpAllocInfoPtr)
104 {
105         PVR_UNREFERENCED_PARAMETER(psPMR);
106         PVR_UNREFERENCED_PARAMETER(uiSize);
107         PVR_UNREFERENCED_PARAMETER(uiBlockSize);
108         PVR_UNREFERENCED_PARAMETER(bForcePersistent);
109         PVR_UNREFERENCED_PARAMETER(phPDumpAllocInfoPtr);
110 }
111
112 #ifdef INLINE_IS_PRAGMA
113 #pragma inline(PVRSRVSyncPrimPDumpPolKM)
114 #endif
115 static INLINE PVRSRV_ERROR
116 PDumpPMRFree(IMG_HANDLE hPDumpAllocationInfoHandle)
117 {
118         PVR_UNREFERENCED_PARAMETER(hPDumpAllocationInfoHandle);
119         return PVRSRV_OK;
120 }
121 #endif  /* PDUMP */
122
123 #define PMR_DEFAULT_PREFIX "PMR"
124 #define PMR_SYMBOLICADDR_FMTSPEC "%s%llu"
125
126 #if defined(PDUMP)
127 #define PDUMP_PHYSMEM_MALLOC_OSPAGES(pszPDumpMemDevName, ui32SerialNum, ui32Size, ui32Align, phHandlePtr) \
128     PDumpPMRMalloc(pszPDumpMemDevName, PMR_OSALLOCPAGES_PREFIX, ui32SerialNum, ui32Size, ui32Align, phHandlePtr)
129 #define PDUMP_PHYSMEM_FREE_OSPAGES(hHandle) \
130     PDumpPMRFree(hHandle)
131 #else
132 #define PDUMP_PHYSMEM_MALLOC_OSPAGES(pszPDumpMemDevName, ui32SerialNum, ui32Size, ui32Align, phHandlePtr) \
133     ((IMG_VOID)(*phHandlePtr=IMG_NULL))
134 #define PDUMP_PHYSMEM_FREE_OSPAGES(hHandle) \
135     ((IMG_VOID)(0))
136 #endif // defined(PDUMP)
137
138 extern PVRSRV_ERROR
139 PDumpPMRWRW32(const IMG_CHAR *pszDevSpace,
140             const IMG_CHAR *pszSymbolicName,
141             IMG_DEVMEM_OFFSET_T uiOffset,
142             IMG_UINT32 ui32Value,
143             PDUMP_FLAGS_T uiPDumpFlags);
144
145 extern PVRSRV_ERROR
146 PDumpPMRWRW64(const IMG_CHAR *pszDevSpace,
147             const IMG_CHAR *pszSymbolicName,
148             IMG_DEVMEM_OFFSET_T uiOffset,
149             IMG_UINT64 ui64Value,
150             PDUMP_FLAGS_T uiPDumpFlags);
151
152 extern PVRSRV_ERROR
153 PDumpPMRLDB(const IMG_CHAR *pszDevSpace,
154             const IMG_CHAR *pszSymbolicName,
155             IMG_DEVMEM_OFFSET_T uiOffset,
156             IMG_DEVMEM_SIZE_T uiSize,
157             const IMG_CHAR *pszFilename,
158             IMG_UINT32 uiFileOffset,
159             PDUMP_FLAGS_T uiPDumpFlags);
160
161 extern PVRSRV_ERROR
162 PDumpPMRSAB(const IMG_CHAR *pszDevSpace,
163             const IMG_CHAR *pszSymbolicName,
164             IMG_DEVMEM_OFFSET_T uiOffset,
165             IMG_DEVMEM_SIZE_T uiSize,
166             const IMG_CHAR *pszFileName,
167             IMG_UINT32 uiFileOffset);
168
169 /*
170   PDumpPMRPOL()
171
172   emits a POL to the PDUMP.
173 */
174 extern PVRSRV_ERROR
175 PDumpPMRPOL(const IMG_CHAR *pszMempaceName,
176             const IMG_CHAR *pszSymbolicName,
177             IMG_DEVMEM_OFFSET_T uiOffset,
178             IMG_UINT32 ui32Value,
179             IMG_UINT32 ui32Mask,
180             PDUMP_POLL_OPERATOR eOperator,
181             IMG_UINT32 uiCount,
182             IMG_UINT32 uiDelay,
183             PDUMP_FLAGS_T uiPDumpFlags);
184
185 extern PVRSRV_ERROR
186 PDumpPMRCBP(const IMG_CHAR *pszMemspaceName,
187             const IMG_CHAR *pszSymbolicName,
188             IMG_DEVMEM_OFFSET_T uiReadOffset,
189             IMG_DEVMEM_OFFSET_T uiWriteOffset,
190             IMG_DEVMEM_SIZE_T uiPacketSize,
191             IMG_DEVMEM_SIZE_T uiBufferSize);
192
193 /*
194  * PDumpWriteBuffer()
195  *
196  * writes a binary blob to the pdump param stream containing the
197  * current contents of the memory, and returns the filename and offset
198  * of where that blob is located (for use in a subsequent LDB, for
199  * example)
200  *
201  * Caller to provide buffer to receive filename, and declare the size
202  * of that buffer
203  */
204 extern PVRSRV_ERROR
205 PDumpWriteBuffer(IMG_UINT8 *pcBuffer,
206                  IMG_SIZE_T uiNumBytes,
207                  PDUMP_FLAGS_T uiPDumpFlags,
208                  IMG_CHAR *pszFilenameOut,
209                  IMG_SIZE_T uiFilenameBufSz,
210                  PDUMP_FILEOFFSET_T *puiOffsetOut);
211
212 #endif /* #ifndef SRVSRV_PDUMP_PHYSMEM_H */