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