1 /**************************************************************************/ /*!
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
8 The contents of this file are subject to the MIT license as set out below.
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:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
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.
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.
32 This License is also included in this distribution in the file called
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 */ /***************************************************************************/
44 #ifndef SRVSRV_PDUMP_PHYSMEM_H
45 #define SRVSRV_PDUMP_PHYSMEM_H
47 #include "img_types.h"
49 #include "pvrsrv_error.h"
51 #include "device.h" /* For device node */
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)
57 typedef struct _PDUMP_PHYSMEM_INFO_T_ PDUMP_PHYSMEM_INFO_T;
61 PDumpGetSymbolicAddr(const IMG_HANDLE hPhysmemPDumpHandle,
62 IMG_CHAR **ppszSymbolicAddress);
65 PDumpMalloc(PVRSRV_DEVICE_NODE *psDeviceNode,
66 const IMG_CHAR *pszDevSpace,
67 const IMG_CHAR *pszSymbolicAddress,
69 /* alignment is alignment of start of buffer _and_
70 minimum contiguity - i.e. smallest allowable
72 IMG_DEVMEM_ALIGN_T uiAlign,
74 IMG_UINT32 ui32InitValue,
75 IMG_HANDLE *phHandlePtr,
76 IMG_UINT32 ui32PDumpFlags);
79 PDumpFree(PVRSRV_DEVICE_NODE *psDeviceNode,
80 IMG_HANDLE hPDumpAllocationInfoHandle);
83 PDumpMakeStringValid(IMG_CHAR *pszString,
84 IMG_UINT32 ui32StrLen);
87 #ifdef INLINE_IS_PRAGMA
88 #pragma inline(PDumpGetSymbolicAddr)
90 static INLINE PVRSRV_ERROR
91 PDumpGetSymbolicAddr(const IMG_HANDLE hPhysmemPDumpHandle,
92 IMG_CHAR **ppszSymbolicAddress)
94 PVR_UNREFERENCED_PARAMETER(hPhysmemPDumpHandle);
95 PVR_UNREFERENCED_PARAMETER(ppszSymbolicAddress);
99 static INLINE PVRSRV_ERROR
100 PDumpMalloc(const IMG_CHAR *pszDevSpace,
101 const IMG_CHAR *pszSymbolicAddress,
103 IMG_DEVMEM_ALIGN_T uiAlign,
104 IMG_BOOL bInitialise,
105 IMG_UINT32 ui32InitValue,
106 IMG_HANDLE *phHandlePtr,
107 IMG_UINT32 ui32PDumpFlags)
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);
120 static INLINE PVRSRV_ERROR
121 PDumpFree(IMG_HANDLE hPDumpAllocationInfoHandle)
123 PVR_UNREFERENCED_PARAMETER(hPDumpAllocationInfoHandle);
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"
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) \
139 #define PDUMP_PHYSMEM_MALLOC_OSPAGES(pszPDumpMemDevName, ui32SerialNum, ui32Size, ui32Align, bInitialise, ui32InitValue, phHandlePtr) \
140 ((void)(*phHandlePtr=NULL))
141 #define PDUMP_PHYSMEM_FREE_OSPAGES(hHandle) \
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);
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);
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);
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);
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);
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);
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);
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);
215 Emits a POL to the PDUMP.
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,
224 PDUMP_POLL_OPERATOR eOperator,
227 PDUMP_FLAGS_T uiPDumpFlags);
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);
239 * PDumpWriteParameterBlob()
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).
245 * Caller to provide buffer to receive filename, and declare the size of
249 PDumpWriteParameterBlob(PVRSRV_DEVICE_NODE *psDeviceNode,
252 PDUMP_FLAGS_T uiPDumpFlags,
253 IMG_CHAR *pszFilenameOut,
254 size_t uiFilenameBufSz,
255 PDUMP_FILEOFFSET_T *puiOffsetOut);
257 #endif /* #ifndef SRVSRV_PDUMP_PHYSMEM_H */