diff options
Diffstat (limited to 'drivers/gpu/pvr/pdump.c')
-rw-r--r-- | drivers/gpu/pvr/pdump.c | 627 |
1 files changed, 627 insertions, 0 deletions
diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c new file mode 100644 index 00000000000..0cae749cd46 --- /dev/null +++ b/drivers/gpu/pvr/pdump.c | |||
@@ -0,0 +1,627 @@ | |||
1 | /********************************************************************** | ||
2 | * | ||
3 | * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms and conditions of the GNU General Public License, | ||
7 | * version 2, as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope it will be useful but, except | ||
10 | * as otherwise stated in writing, without any warranty; without even the | ||
11 | * implied warranty of merchantability or fitness for a particular purpose. | ||
12 | * See the GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along with | ||
15 | * this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
17 | * | ||
18 | * The full GNU General Public License is included in this distribution in | ||
19 | * the file called "COPYING". | ||
20 | * | ||
21 | * Contact Information: | ||
22 | * Imagination Technologies Ltd. <gpl-support@imgtec.com> | ||
23 | * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK | ||
24 | * | ||
25 | ******************************************************************************/ | ||
26 | |||
27 | #if defined (SUPPORT_SGX) || defined (SUPPORT_VGX) | ||
28 | #if defined (PDUMP) | ||
29 | |||
30 | #include <asm/atomic.h> | ||
31 | #include <stdarg.h> | ||
32 | #if defined (SUPPORT_SGX) | ||
33 | #include "sgxdefs.h" | ||
34 | #endif | ||
35 | #include "services_headers.h" | ||
36 | |||
37 | #include "pvrversion.h" | ||
38 | #include "pvr_debug.h" | ||
39 | |||
40 | #include "dbgdrvif.h" | ||
41 | #if defined (SUPPORT_SGX) | ||
42 | #include "sgxmmu.h" | ||
43 | #endif | ||
44 | #include "mm.h" | ||
45 | #include "pdump_km.h" | ||
46 | #include "pdump_int.h" | ||
47 | |||
48 | #include <linux/kernel.h> | ||
49 | #include <linux/string.h> | ||
50 | |||
51 | static IMG_BOOL PDumpWriteString2 (IMG_CHAR * pszString, IMG_UINT32 ui32Flags); | ||
52 | static IMG_BOOL PDumpWriteILock (PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32Count, IMG_UINT32 ui32Flags); | ||
53 | static IMG_VOID DbgSetFrame (PDBG_STREAM psStream, IMG_UINT32 ui32Frame); | ||
54 | static IMG_VOID DbgSetMarker (PDBG_STREAM psStream, IMG_UINT32 ui32Marker); | ||
55 | |||
56 | #define PDUMP_DATAMASTER_PIXEL (1) | ||
57 | #define PDUMP_DATAMASTER_EDM (3) | ||
58 | |||
59 | #define MAX_FILE_SIZE 0x40000000 | ||
60 | |||
61 | static atomic_t gsPDumpSuspended = ATOMIC_INIT(0); | ||
62 | |||
63 | static PDBGKM_SERVICE_TABLE gpfnDbgDrv = IMG_NULL; | ||
64 | |||
65 | |||
66 | |||
67 | IMG_CHAR *pszStreamName[PDUMP_NUM_STREAMS] = { "ParamStream2", | ||
68 | "ScriptStream2", | ||
69 | "DriverInfoStream"}; | ||
70 | typedef struct PDBG_PDUMP_STATE_TAG | ||
71 | { | ||
72 | PDBG_STREAM psStream[PDUMP_NUM_STREAMS]; | ||
73 | IMG_UINT32 ui32ParamFileNum; | ||
74 | |||
75 | IMG_CHAR *pszMsg; | ||
76 | IMG_CHAR *pszScript; | ||
77 | IMG_CHAR *pszFile; | ||
78 | |||
79 | } PDBG_PDUMP_STATE; | ||
80 | |||
81 | static PDBG_PDUMP_STATE gsDBGPdumpState = {{IMG_NULL}, 0, IMG_NULL, IMG_NULL, IMG_NULL}; | ||
82 | |||
83 | #define SZ_MSG_SIZE_MAX PVRSRV_PDUMP_MAX_COMMENT_SIZE-1 | ||
84 | #define SZ_SCRIPT_SIZE_MAX PVRSRV_PDUMP_MAX_COMMENT_SIZE-1 | ||
85 | #define SZ_FILENAME_SIZE_MAX PVRSRV_PDUMP_MAX_COMMENT_SIZE-1 | ||
86 | |||
87 | |||
88 | |||
89 | |||
90 | IMG_VOID DBGDrvGetServiceTable(IMG_VOID **fn_table); | ||
91 | |||
92 | static inline IMG_BOOL PDumpSuspended(IMG_VOID) | ||
93 | { | ||
94 | return (atomic_read(&gsPDumpSuspended) != 0) ? IMG_TRUE : IMG_FALSE; | ||
95 | } | ||
96 | |||
97 | PVRSRV_ERROR PDumpOSGetScriptString(IMG_HANDLE *phScript, | ||
98 | IMG_UINT32 *pui32MaxLen) | ||
99 | { | ||
100 | *phScript = (IMG_HANDLE)gsDBGPdumpState.pszScript; | ||
101 | *pui32MaxLen = SZ_SCRIPT_SIZE_MAX; | ||
102 | if ((!*phScript) || PDumpSuspended()) | ||
103 | { | ||
104 | return PVRSRV_ERROR_PDUMP_NOT_ACTIVE; | ||
105 | } | ||
106 | return PVRSRV_OK; | ||
107 | } | ||
108 | |||
109 | PVRSRV_ERROR PDumpOSGetMessageString(IMG_CHAR **ppszMsg, | ||
110 | IMG_UINT32 *pui32MaxLen) | ||
111 | { | ||
112 | *ppszMsg = gsDBGPdumpState.pszMsg; | ||
113 | *pui32MaxLen = SZ_MSG_SIZE_MAX; | ||
114 | if ((!*ppszMsg) || PDumpSuspended()) | ||
115 | { | ||
116 | return PVRSRV_ERROR_PDUMP_NOT_ACTIVE; | ||
117 | } | ||
118 | return PVRSRV_OK; | ||
119 | } | ||
120 | |||
121 | PVRSRV_ERROR PDumpOSGetFilenameString(IMG_CHAR **ppszFile, | ||
122 | IMG_UINT32 *pui32MaxLen) | ||
123 | { | ||
124 | *ppszFile = gsDBGPdumpState.pszFile; | ||
125 | *pui32MaxLen = SZ_FILENAME_SIZE_MAX; | ||
126 | if ((!*ppszFile) || PDumpSuspended()) | ||
127 | { | ||
128 | return PVRSRV_ERROR_PDUMP_NOT_ACTIVE; | ||
129 | } | ||
130 | return PVRSRV_OK; | ||
131 | } | ||
132 | |||
133 | IMG_BOOL PDumpOSWriteString2(IMG_HANDLE hScript, IMG_UINT32 ui32Flags) | ||
134 | { | ||
135 | return PDumpWriteString2(hScript, ui32Flags); | ||
136 | } | ||
137 | |||
138 | PVRSRV_ERROR PDumpOSBufprintf(IMG_HANDLE hBuf, IMG_UINT32 ui32ScriptSizeMax, IMG_CHAR* pszFormat, ...) | ||
139 | { | ||
140 | IMG_CHAR* pszBuf = hBuf; | ||
141 | IMG_INT32 n; | ||
142 | va_list vaArgs; | ||
143 | |||
144 | va_start(vaArgs, pszFormat); | ||
145 | |||
146 | n = vsnprintf(pszBuf, ui32ScriptSizeMax, pszFormat, vaArgs); | ||
147 | |||
148 | va_end(vaArgs); | ||
149 | |||
150 | if (n>=(IMG_INT32)ui32ScriptSizeMax || n==-1) | ||
151 | { | ||
152 | PVR_DPF((PVR_DBG_ERROR, "Buffer overflow detected, pdump output may be incomplete.")); | ||
153 | |||
154 | return PVRSRV_ERROR_PDUMP_BUF_OVERFLOW; | ||
155 | } | ||
156 | |||
157 | #if defined(PDUMP_DEBUG_OUTFILES) | ||
158 | g_ui32EveryLineCounter++; | ||
159 | #endif | ||
160 | return PVRSRV_OK; | ||
161 | } | ||
162 | |||
163 | PVRSRV_ERROR PDumpOSVSprintf(IMG_CHAR *pszComment, IMG_UINT32 ui32ScriptSizeMax, IMG_CHAR* pszFormat, PDUMP_va_list vaArgs) | ||
164 | { | ||
165 | IMG_INT32 n; | ||
166 | |||
167 | n = vsnprintf(pszComment, ui32ScriptSizeMax, pszFormat, vaArgs); | ||
168 | |||
169 | if (n>=(IMG_INT32)ui32ScriptSizeMax || n==-1) | ||
170 | { | ||
171 | PVR_DPF((PVR_DBG_ERROR, "Buffer overflow detected, pdump output may be incomplete.")); | ||
172 | |||
173 | return PVRSRV_ERROR_PDUMP_BUF_OVERFLOW; | ||
174 | } | ||
175 | |||
176 | return PVRSRV_OK; | ||
177 | } | ||
178 | |||
179 | IMG_VOID PDumpOSDebugPrintf(IMG_CHAR* pszFormat, ...) | ||
180 | { | ||
181 | PVR_UNREFERENCED_PARAMETER(pszFormat); | ||
182 | |||
183 | |||
184 | } | ||
185 | |||
186 | PVRSRV_ERROR PDumpOSSprintf(IMG_CHAR *pszComment, IMG_UINT32 ui32ScriptSizeMax, IMG_CHAR *pszFormat, ...) | ||
187 | { | ||
188 | IMG_INT32 n; | ||
189 | va_list vaArgs; | ||
190 | |||
191 | va_start(vaArgs, pszFormat); | ||
192 | |||
193 | n = vsnprintf(pszComment, ui32ScriptSizeMax, pszFormat, vaArgs); | ||
194 | |||
195 | va_end(vaArgs); | ||
196 | |||
197 | if (n>=(IMG_INT32)ui32ScriptSizeMax || n==-1) | ||
198 | { | ||
199 | PVR_DPF((PVR_DBG_ERROR, "Buffer overflow detected, pdump output may be incomplete.")); | ||
200 | |||
201 | return PVRSRV_ERROR_PDUMP_BUF_OVERFLOW; | ||
202 | } | ||
203 | |||
204 | return PVRSRV_OK; | ||
205 | } | ||
206 | |||
207 | IMG_UINT32 PDumpOSBuflen(IMG_HANDLE hBuffer, IMG_UINT32 ui32BufferSizeMax) | ||
208 | { | ||
209 | IMG_CHAR* pszBuf = hBuffer; | ||
210 | IMG_UINT32 ui32Count = 0; | ||
211 | |||
212 | while ((pszBuf[ui32Count]!=0) && (ui32Count<ui32BufferSizeMax) ) | ||
213 | { | ||
214 | ui32Count++; | ||
215 | } | ||
216 | return(ui32Count); | ||
217 | } | ||
218 | |||
219 | IMG_VOID PDumpOSVerifyLineEnding(IMG_HANDLE hBuffer, IMG_UINT32 ui32BufferSizeMax) | ||
220 | { | ||
221 | IMG_UINT32 ui32Count; | ||
222 | IMG_CHAR* pszBuf = hBuffer; | ||
223 | |||
224 | |||
225 | ui32Count = PDumpOSBuflen(hBuffer, ui32BufferSizeMax); | ||
226 | |||
227 | |||
228 | if ((ui32Count >= 1) && (pszBuf[ui32Count-1] != '\n') && (ui32Count<ui32BufferSizeMax)) | ||
229 | { | ||
230 | pszBuf[ui32Count] = '\n'; | ||
231 | ui32Count++; | ||
232 | pszBuf[ui32Count] = '\0'; | ||
233 | } | ||
234 | if ((ui32Count >= 2) && (pszBuf[ui32Count-2] != '\r') && (ui32Count<ui32BufferSizeMax)) | ||
235 | { | ||
236 | pszBuf[ui32Count-1] = '\r'; | ||
237 | pszBuf[ui32Count] = '\n'; | ||
238 | ui32Count++; | ||
239 | pszBuf[ui32Count] = '\0'; | ||
240 | } | ||
241 | } | ||
242 | |||
243 | IMG_HANDLE PDumpOSGetStream(IMG_UINT32 ePDumpStream) | ||
244 | { | ||
245 | return (IMG_HANDLE)gsDBGPdumpState.psStream[ePDumpStream]; | ||
246 | } | ||
247 | |||
248 | IMG_UINT32 PDumpOSGetStreamOffset(IMG_UINT32 ePDumpStream) | ||
249 | { | ||
250 | PDBG_STREAM psStream = gsDBGPdumpState.psStream[ePDumpStream]; | ||
251 | return gpfnDbgDrv->pfnGetStreamOffset(psStream); | ||
252 | } | ||
253 | |||
254 | IMG_UINT32 PDumpOSGetParamFileNum(IMG_VOID) | ||
255 | { | ||
256 | return gsDBGPdumpState.ui32ParamFileNum; | ||
257 | } | ||
258 | |||
259 | IMG_BOOL PDumpOSWriteString(IMG_HANDLE hStream, | ||
260 | IMG_UINT8 *psui8Data, | ||
261 | IMG_UINT32 ui32Size, | ||
262 | IMG_UINT32 ui32Flags) | ||
263 | { | ||
264 | PDBG_STREAM psStream = (PDBG_STREAM)hStream; | ||
265 | return PDumpWriteILock(psStream, | ||
266 | psui8Data, | ||
267 | ui32Size, | ||
268 | ui32Flags); | ||
269 | } | ||
270 | |||
271 | IMG_VOID PDumpOSCheckForSplitting(IMG_HANDLE hStream, IMG_UINT32 ui32Size, IMG_UINT32 ui32Flags) | ||
272 | { | ||
273 | |||
274 | PVR_UNREFERENCED_PARAMETER(hStream); | ||
275 | PVR_UNREFERENCED_PARAMETER(ui32Size); | ||
276 | PVR_UNREFERENCED_PARAMETER(ui32Flags); | ||
277 | } | ||
278 | |||
279 | IMG_BOOL PDumpOSJTInitialised(IMG_VOID) | ||
280 | { | ||
281 | if(gpfnDbgDrv) | ||
282 | { | ||
283 | return IMG_TRUE; | ||
284 | } | ||
285 | return IMG_FALSE; | ||
286 | } | ||
287 | |||
288 | inline IMG_BOOL PDumpOSIsSuspended(IMG_VOID) | ||
289 | { | ||
290 | return (atomic_read(&gsPDumpSuspended) != 0) ? IMG_TRUE : IMG_FALSE; | ||
291 | } | ||
292 | |||
293 | IMG_VOID PDumpOSCPUVAddrToDevPAddr(PVRSRV_DEVICE_TYPE eDeviceType, | ||
294 | IMG_HANDLE hOSMemHandle, | ||
295 | IMG_UINT32 ui32Offset, | ||
296 | IMG_UINT8 *pui8LinAddr, | ||
297 | IMG_UINT32 ui32PageSize, | ||
298 | IMG_DEV_PHYADDR *psDevPAddr) | ||
299 | { | ||
300 | IMG_CPU_PHYADDR sCpuPAddr; | ||
301 | |||
302 | PVR_UNREFERENCED_PARAMETER(pui8LinAddr); | ||
303 | PVR_UNREFERENCED_PARAMETER(ui32PageSize); | ||
304 | |||
305 | |||
306 | |||
307 | PVR_ASSERT (hOSMemHandle != IMG_NULL); | ||
308 | |||
309 | sCpuPAddr = OSMemHandleToCpuPAddr(hOSMemHandle, ui32Offset); | ||
310 | PVR_ASSERT((sCpuPAddr.uiAddr & (ui32PageSize - 1)) == 0); | ||
311 | |||
312 | |||
313 | *psDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); | ||
314 | } | ||
315 | |||
316 | IMG_VOID PDumpOSCPUVAddrToPhysPages(IMG_HANDLE hOSMemHandle, | ||
317 | IMG_UINT32 ui32Offset, | ||
318 | IMG_PUINT8 pui8LinAddr, | ||
319 | IMG_UINT32 ui32DataPageMask, | ||
320 | IMG_UINT32 *pui32PageOffset) | ||
321 | { | ||
322 | if(hOSMemHandle) | ||
323 | { | ||
324 | |||
325 | IMG_CPU_PHYADDR sCpuPAddr; | ||
326 | |||
327 | PVR_UNREFERENCED_PARAMETER(pui8LinAddr); | ||
328 | |||
329 | sCpuPAddr = OSMemHandleToCpuPAddr(hOSMemHandle, ui32Offset); | ||
330 | *pui32PageOffset = sCpuPAddr.uiAddr & ui32DataPageMask; | ||
331 | } | ||
332 | else | ||
333 | { | ||
334 | PVR_UNREFERENCED_PARAMETER(hOSMemHandle); | ||
335 | PVR_UNREFERENCED_PARAMETER(ui32Offset); | ||
336 | |||
337 | *pui32PageOffset = ((IMG_UINT32)pui8LinAddr & ui32DataPageMask); | ||
338 | } | ||
339 | } | ||
340 | |||
341 | IMG_UINT32 PDumpOSDebugDriverWrite( PDBG_STREAM psStream, | ||
342 | PDUMP_DDWMODE eDbgDrvWriteMode, | ||
343 | IMG_UINT8 *pui8Data, | ||
344 | IMG_UINT32 ui32BCount, | ||
345 | IMG_UINT32 ui32Level, | ||
346 | IMG_UINT32 ui32DbgDrvFlags) | ||
347 | { | ||
348 | switch(eDbgDrvWriteMode) | ||
349 | { | ||
350 | case PDUMP_WRITE_MODE_CONTINUOUS: | ||
351 | PVR_UNREFERENCED_PARAMETER(ui32DbgDrvFlags); | ||
352 | return gpfnDbgDrv->pfnDBGDrivWrite2(psStream, pui8Data, ui32BCount, ui32Level); | ||
353 | case PDUMP_WRITE_MODE_LASTFRAME: | ||
354 | return gpfnDbgDrv->pfnWriteLF(psStream, pui8Data, ui32BCount, ui32Level, ui32DbgDrvFlags); | ||
355 | case PDUMP_WRITE_MODE_BINCM: | ||
356 | PVR_UNREFERENCED_PARAMETER(ui32DbgDrvFlags); | ||
357 | return gpfnDbgDrv->pfnWriteBINCM(psStream, pui8Data, ui32BCount, ui32Level); | ||
358 | case PDUMP_WRITE_MODE_PERSISTENT: | ||
359 | PVR_UNREFERENCED_PARAMETER(ui32DbgDrvFlags); | ||
360 | return gpfnDbgDrv->pfnWritePersist(psStream, pui8Data, ui32BCount, ui32Level); | ||
361 | default: | ||
362 | PVR_UNREFERENCED_PARAMETER(ui32DbgDrvFlags); | ||
363 | break; | ||
364 | } | ||
365 | return 0xFFFFFFFFU; | ||
366 | } | ||
367 | |||
368 | IMG_VOID PDumpOSReleaseExecution(IMG_VOID) | ||
369 | { | ||
370 | OSReleaseThreadQuanta(); | ||
371 | } | ||
372 | |||
373 | IMG_VOID PDumpInit(IMG_VOID) | ||
374 | { | ||
375 | IMG_UINT32 i; | ||
376 | DBGKM_CONNECT_NOTIFIER sConnectNotifier; | ||
377 | |||
378 | |||
379 | if (!gpfnDbgDrv) | ||
380 | { | ||
381 | DBGDrvGetServiceTable((IMG_VOID **)&gpfnDbgDrv); | ||
382 | |||
383 | |||
384 | |||
385 | if (gpfnDbgDrv == IMG_NULL) | ||
386 | { | ||
387 | return; | ||
388 | } | ||
389 | |||
390 | |||
391 | sConnectNotifier.pfnConnectNotifier = &PDumpConnectionNotify; | ||
392 | gpfnDbgDrv->pfnSetConnectNotifier(sConnectNotifier); | ||
393 | |||
394 | if(!gsDBGPdumpState.pszFile) | ||
395 | { | ||
396 | if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_FILENAME_SIZE_MAX, (IMG_PVOID *)&gsDBGPdumpState.pszFile, 0, | ||
397 | "Filename string") != PVRSRV_OK) | ||
398 | { | ||
399 | goto init_failed; | ||
400 | } | ||
401 | } | ||
402 | |||
403 | if(!gsDBGPdumpState.pszMsg) | ||
404 | { | ||
405 | if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_MSG_SIZE_MAX, (IMG_PVOID *)&gsDBGPdumpState.pszMsg, 0, | ||
406 | "Message string") != PVRSRV_OK) | ||
407 | { | ||
408 | goto init_failed; | ||
409 | } | ||
410 | } | ||
411 | |||
412 | if(!gsDBGPdumpState.pszScript) | ||
413 | { | ||
414 | if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_SCRIPT_SIZE_MAX, (IMG_PVOID *)&gsDBGPdumpState.pszScript, 0, | ||
415 | "Script string") != PVRSRV_OK) | ||
416 | { | ||
417 | goto init_failed; | ||
418 | } | ||
419 | } | ||
420 | |||
421 | for(i=0; i < PDUMP_NUM_STREAMS; i++) | ||
422 | { | ||
423 | gsDBGPdumpState.psStream[i] = gpfnDbgDrv->pfnCreateStream(pszStreamName[i], | ||
424 | DEBUG_CAPMODE_FRAMED, | ||
425 | DEBUG_OUTMODE_STREAMENABLE, | ||
426 | 0, | ||
427 | 10); | ||
428 | |||
429 | gpfnDbgDrv->pfnSetCaptureMode(gsDBGPdumpState.psStream[i],DEBUG_CAPMODE_FRAMED,0xFFFFFFFF, 0xFFFFFFFF, 1); | ||
430 | gpfnDbgDrv->pfnSetFrame(gsDBGPdumpState.psStream[i],0); | ||
431 | } | ||
432 | |||
433 | PDUMPCOMMENT("Driver Product Name: %s", VS_PRODUCT_NAME); | ||
434 | PDUMPCOMMENT("Driver Product Version: %s (%s)", PVRVERSION_STRING, PVRVERSION_FILE); | ||
435 | PDUMPCOMMENT("Start of Init Phase"); | ||
436 | } | ||
437 | |||
438 | return; | ||
439 | |||
440 | init_failed: | ||
441 | |||
442 | if(gsDBGPdumpState.pszFile) | ||
443 | { | ||
444 | OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_FILENAME_SIZE_MAX, (IMG_PVOID) gsDBGPdumpState.pszFile, 0); | ||
445 | gsDBGPdumpState.pszFile = IMG_NULL; | ||
446 | } | ||
447 | |||
448 | if(gsDBGPdumpState.pszScript) | ||
449 | { | ||
450 | OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_SCRIPT_SIZE_MAX, (IMG_PVOID) gsDBGPdumpState.pszScript, 0); | ||
451 | gsDBGPdumpState.pszScript = IMG_NULL; | ||
452 | } | ||
453 | |||
454 | if(gsDBGPdumpState.pszMsg) | ||
455 | { | ||
456 | OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_MSG_SIZE_MAX, (IMG_PVOID) gsDBGPdumpState.pszMsg, 0); | ||
457 | gsDBGPdumpState.pszMsg = IMG_NULL; | ||
458 | } | ||
459 | |||
460 | |||
461 | sConnectNotifier.pfnConnectNotifier = 0; | ||
462 | gpfnDbgDrv->pfnSetConnectNotifier(sConnectNotifier); | ||
463 | |||
464 | gpfnDbgDrv = IMG_NULL; | ||
465 | } | ||
466 | |||
467 | |||
468 | IMG_VOID PDumpDeInit(IMG_VOID) | ||
469 | { | ||
470 | IMG_UINT32 i; | ||
471 | DBGKM_CONNECT_NOTIFIER sConnectNotifier; | ||
472 | |||
473 | for(i=0; i < PDUMP_NUM_STREAMS; i++) | ||
474 | { | ||
475 | gpfnDbgDrv->pfnDestroyStream(gsDBGPdumpState.psStream[i]); | ||
476 | } | ||
477 | |||
478 | if(gsDBGPdumpState.pszFile) | ||
479 | { | ||
480 | OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_FILENAME_SIZE_MAX, (IMG_PVOID) gsDBGPdumpState.pszFile, 0); | ||
481 | gsDBGPdumpState.pszFile = IMG_NULL; | ||
482 | } | ||
483 | |||
484 | if(gsDBGPdumpState.pszScript) | ||
485 | { | ||
486 | OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_SCRIPT_SIZE_MAX, (IMG_PVOID) gsDBGPdumpState.pszScript, 0); | ||
487 | gsDBGPdumpState.pszScript = IMG_NULL; | ||
488 | } | ||
489 | |||
490 | if(gsDBGPdumpState.pszMsg) | ||
491 | { | ||
492 | OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_MSG_SIZE_MAX, (IMG_PVOID) gsDBGPdumpState.pszMsg, 0); | ||
493 | gsDBGPdumpState.pszMsg = IMG_NULL; | ||
494 | } | ||
495 | |||
496 | |||
497 | sConnectNotifier.pfnConnectNotifier = 0; | ||
498 | gpfnDbgDrv->pfnSetConnectNotifier(sConnectNotifier); | ||
499 | |||
500 | gpfnDbgDrv = IMG_NULL; | ||
501 | } | ||
502 | |||
503 | PVRSRV_ERROR PDumpStartInitPhaseKM(IMG_VOID) | ||
504 | { | ||
505 | IMG_UINT32 i; | ||
506 | |||
507 | if (gpfnDbgDrv) | ||
508 | { | ||
509 | PDUMPCOMMENT("Start Init Phase"); | ||
510 | for(i=0; i < PDUMP_NUM_STREAMS; i++) | ||
511 | { | ||
512 | gpfnDbgDrv->pfnStartInitPhase(gsDBGPdumpState.psStream[i]); | ||
513 | } | ||
514 | } | ||
515 | return PVRSRV_OK; | ||
516 | } | ||
517 | |||
518 | PVRSRV_ERROR PDumpStopInitPhaseKM(IMG_VOID) | ||
519 | { | ||
520 | IMG_UINT32 i; | ||
521 | |||
522 | if (gpfnDbgDrv) | ||
523 | { | ||
524 | PDUMPCOMMENT("Stop Init Phase"); | ||
525 | |||
526 | for(i=0; i < PDUMP_NUM_STREAMS; i++) | ||
527 | { | ||
528 | gpfnDbgDrv->pfnStopInitPhase(gsDBGPdumpState.psStream[i]); | ||
529 | } | ||
530 | } | ||
531 | return PVRSRV_OK; | ||
532 | } | ||
533 | |||
534 | IMG_BOOL PDumpIsLastCaptureFrameKM(IMG_VOID) | ||
535 | { | ||
536 | return gpfnDbgDrv->pfnIsLastCaptureFrame(gsDBGPdumpState.psStream[PDUMP_STREAM_SCRIPT2]); | ||
537 | } | ||
538 | |||
539 | |||
540 | IMG_BOOL PDumpIsCaptureFrameKM(IMG_VOID) | ||
541 | { | ||
542 | if (PDumpSuspended()) | ||
543 | { | ||
544 | return IMG_FALSE; | ||
545 | } | ||
546 | return gpfnDbgDrv->pfnIsCaptureFrame(gsDBGPdumpState.psStream[PDUMP_STREAM_SCRIPT2], IMG_FALSE); | ||
547 | } | ||
548 | |||
549 | PVRSRV_ERROR PDumpSetFrameKM(IMG_UINT32 ui32Frame) | ||
550 | { | ||
551 | IMG_UINT32 ui32Stream; | ||
552 | |||
553 | for (ui32Stream = 0; ui32Stream < PDUMP_NUM_STREAMS; ui32Stream++) | ||
554 | { | ||
555 | if (gsDBGPdumpState.psStream[ui32Stream]) | ||
556 | { | ||
557 | DbgSetFrame(gsDBGPdumpState.psStream[ui32Stream], ui32Frame); | ||
558 | } | ||
559 | } | ||
560 | |||
561 | return PVRSRV_OK; | ||
562 | } | ||
563 | |||
564 | |||
565 | static IMG_BOOL PDumpWriteString2(IMG_CHAR * pszString, IMG_UINT32 ui32Flags) | ||
566 | { | ||
567 | return PDumpWriteILock(gsDBGPdumpState.psStream[PDUMP_STREAM_SCRIPT2], (IMG_UINT8 *) pszString, strlen(pszString), ui32Flags); | ||
568 | } | ||
569 | |||
570 | |||
571 | static IMG_BOOL PDumpWriteILock(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32Count, IMG_UINT32 ui32Flags) | ||
572 | { | ||
573 | IMG_UINT32 ui32Written = 0; | ||
574 | if ((psStream == IMG_NULL) || PDumpSuspended() || ((ui32Flags & PDUMP_FLAGS_NEVER) != 0)) | ||
575 | { | ||
576 | return IMG_TRUE; | ||
577 | } | ||
578 | |||
579 | |||
580 | |||
581 | |||
582 | if (psStream == gsDBGPdumpState.psStream[PDUMP_STREAM_PARAM2]) | ||
583 | { | ||
584 | IMG_UINT32 ui32ParamOutPos = gpfnDbgDrv->pfnGetStreamOffset(gsDBGPdumpState.psStream[PDUMP_STREAM_PARAM2]); | ||
585 | |||
586 | if (ui32ParamOutPos + ui32Count > MAX_FILE_SIZE) | ||
587 | { | ||
588 | if ((gsDBGPdumpState.psStream[PDUMP_STREAM_SCRIPT2] && PDumpWriteString2("\r\n-- Splitting pdump output file\r\n\r\n", ui32Flags))) | ||
589 | { | ||
590 | DbgSetMarker(gsDBGPdumpState.psStream[PDUMP_STREAM_PARAM2], ui32ParamOutPos); | ||
591 | gsDBGPdumpState.ui32ParamFileNum++; | ||
592 | } | ||
593 | } | ||
594 | } | ||
595 | |||
596 | ui32Written = DbgWrite(psStream, pui8Data, ui32Count, ui32Flags); | ||
597 | |||
598 | if (ui32Written == 0xFFFFFFFF) | ||
599 | { | ||
600 | return IMG_FALSE; | ||
601 | } | ||
602 | |||
603 | return IMG_TRUE; | ||
604 | } | ||
605 | |||
606 | static IMG_VOID DbgSetFrame(PDBG_STREAM psStream, IMG_UINT32 ui32Frame) | ||
607 | { | ||
608 | gpfnDbgDrv->pfnSetFrame(psStream, ui32Frame); | ||
609 | } | ||
610 | |||
611 | static IMG_VOID DbgSetMarker(PDBG_STREAM psStream, IMG_UINT32 ui32Marker) | ||
612 | { | ||
613 | gpfnDbgDrv->pfnSetMarker(psStream, ui32Marker); | ||
614 | } | ||
615 | |||
616 | IMG_VOID PDumpSuspendKM(IMG_VOID) | ||
617 | { | ||
618 | atomic_inc(&gsPDumpSuspended); | ||
619 | } | ||
620 | |||
621 | IMG_VOID PDumpResumeKM(IMG_VOID) | ||
622 | { | ||
623 | atomic_dec(&gsPDumpSuspended); | ||
624 | } | ||
625 | |||
626 | #endif | ||
627 | #endif | ||