diff options
Diffstat (limited to 'drivers/gpu/pvr/pdump_common.c')
-rw-r--r-- | drivers/gpu/pvr/pdump_common.c | 2248 |
1 files changed, 2248 insertions, 0 deletions
diff --git a/drivers/gpu/pvr/pdump_common.c b/drivers/gpu/pvr/pdump_common.c new file mode 100644 index 00000000000..430efe4eba0 --- /dev/null +++ b/drivers/gpu/pvr/pdump_common.c | |||
@@ -0,0 +1,2248 @@ | |||
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(PDUMP) | ||
28 | #include <stdarg.h> | ||
29 | |||
30 | #include "services_headers.h" | ||
31 | #if defined(SUPPORT_SGX) | ||
32 | #include "sgxdefs.h" | ||
33 | #endif | ||
34 | #include "perproc.h" | ||
35 | |||
36 | #include "pdump_km.h" | ||
37 | #include "pdump_int.h" | ||
38 | |||
39 | #if !defined(PDUMP_TEMP_BUFFER_SIZE) | ||
40 | #define PDUMP_TEMP_BUFFER_SIZE (64 * 1024U) | ||
41 | #endif | ||
42 | |||
43 | #if 1 | ||
44 | #define PDUMP_DBG(a) PDumpOSDebugPrintf (a) | ||
45 | #else | ||
46 | #define PDUMP_DBG(a) | ||
47 | #endif | ||
48 | |||
49 | #define PDUMP_DATAMASTER_PIXEL (1) | ||
50 | #define PDUMP_DATAMASTER_EDM (3) | ||
51 | |||
52 | #define PTR_PLUS(t, p, x) ((t)(((IMG_CHAR *)(p)) + (x))) | ||
53 | #define VPTR_PLUS(p, x) PTR_PLUS(IMG_VOID *, p, x) | ||
54 | #define VPTR_INC(p, x) ((p) = VPTR_PLUS(p, x)) | ||
55 | #define MAX_PDUMP_MMU_CONTEXTS (32) | ||
56 | static IMG_VOID *gpvTempBuffer = IMG_NULL; | ||
57 | static IMG_HANDLE ghTempBufferBlockAlloc; | ||
58 | static IMG_UINT16 gui16MMUContextUsage = 0; | ||
59 | |||
60 | #if defined(PDUMP_DEBUG_OUTFILES) | ||
61 | IMG_UINT32 g_ui32EveryLineCounter = 1U; | ||
62 | #endif | ||
63 | |||
64 | #ifdef INLINE_IS_PRAGMA | ||
65 | #pragma inline(_PDumpIsPersistent) | ||
66 | #endif | ||
67 | static INLINE | ||
68 | IMG_BOOL _PDumpIsPersistent(IMG_VOID) | ||
69 | { | ||
70 | PVRSRV_PER_PROCESS_DATA* psPerProc = PVRSRVFindPerProcessData(); | ||
71 | if(psPerProc == IMG_NULL) | ||
72 | { | ||
73 | |||
74 | return IMG_FALSE; | ||
75 | } | ||
76 | return psPerProc->bPDumpPersistent; | ||
77 | } | ||
78 | |||
79 | #if defined(PDUMP_DEBUG_OUTFILES) | ||
80 | static INLINE | ||
81 | IMG_UINT32 _PDumpGetPID(IMG_VOID) | ||
82 | { | ||
83 | PVRSRV_PER_PROCESS_DATA* psPerProc = PVRSRVFindPerProcessData(); | ||
84 | if(psPerProc == IMG_NULL) | ||
85 | { | ||
86 | |||
87 | return 0; | ||
88 | } | ||
89 | return psPerProc->ui32PID; | ||
90 | } | ||
91 | #endif | ||
92 | |||
93 | static IMG_VOID *GetTempBuffer(IMG_VOID) | ||
94 | { | ||
95 | |||
96 | if (gpvTempBuffer == IMG_NULL) | ||
97 | { | ||
98 | PVRSRV_ERROR eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, | ||
99 | PDUMP_TEMP_BUFFER_SIZE, | ||
100 | &gpvTempBuffer, | ||
101 | &ghTempBufferBlockAlloc, | ||
102 | "PDUMP Temporary Buffer"); | ||
103 | if (eError != PVRSRV_OK) | ||
104 | { | ||
105 | PVR_DPF((PVR_DBG_ERROR, "GetTempBuffer: OSAllocMem failed: %d", eError)); | ||
106 | } | ||
107 | } | ||
108 | |||
109 | return gpvTempBuffer; | ||
110 | } | ||
111 | |||
112 | static IMG_VOID FreeTempBuffer(IMG_VOID) | ||
113 | { | ||
114 | |||
115 | if (gpvTempBuffer != IMG_NULL) | ||
116 | { | ||
117 | PVRSRV_ERROR eError = OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, | ||
118 | PDUMP_TEMP_BUFFER_SIZE, | ||
119 | gpvTempBuffer, | ||
120 | ghTempBufferBlockAlloc); | ||
121 | if (eError != PVRSRV_OK) | ||
122 | { | ||
123 | PVR_DPF((PVR_DBG_ERROR, "FreeTempBuffer: OSFreeMem failed: %d", eError)); | ||
124 | } | ||
125 | else | ||
126 | { | ||
127 | gpvTempBuffer = IMG_NULL; | ||
128 | } | ||
129 | } | ||
130 | } | ||
131 | |||
132 | IMG_VOID PDumpInitCommon(IMG_VOID) | ||
133 | { | ||
134 | |||
135 | (IMG_VOID) GetTempBuffer(); | ||
136 | |||
137 | |||
138 | PDumpInit(); | ||
139 | } | ||
140 | |||
141 | IMG_VOID PDumpDeInitCommon(IMG_VOID) | ||
142 | { | ||
143 | |||
144 | FreeTempBuffer(); | ||
145 | |||
146 | |||
147 | PDumpDeInit(); | ||
148 | } | ||
149 | |||
150 | IMG_BOOL PDumpIsSuspended(IMG_VOID) | ||
151 | { | ||
152 | return PDumpOSIsSuspended(); | ||
153 | } | ||
154 | |||
155 | |||
156 | |||
157 | PVRSRV_ERROR PDumpRegWithFlagsKM(IMG_CHAR *pszPDumpRegName, | ||
158 | IMG_UINT32 ui32Reg, | ||
159 | IMG_UINT32 ui32Data, | ||
160 | IMG_UINT32 ui32Flags) | ||
161 | { | ||
162 | PVRSRV_ERROR eErr; | ||
163 | PDUMP_GET_SCRIPT_STRING() | ||
164 | PDUMP_DBG(("PDumpRegWithFlagsKM")); | ||
165 | |||
166 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "WRW :%s:0x%08X 0x%08X\r\n", | ||
167 | pszPDumpRegName, ui32Reg, ui32Data); | ||
168 | if(eErr != PVRSRV_OK) | ||
169 | { | ||
170 | return eErr; | ||
171 | } | ||
172 | PDumpOSWriteString2(hScript, ui32Flags); | ||
173 | |||
174 | return PVRSRV_OK; | ||
175 | } | ||
176 | |||
177 | PVRSRV_ERROR PDumpRegKM(IMG_CHAR *pszPDumpRegName, | ||
178 | IMG_UINT32 ui32Reg, | ||
179 | IMG_UINT32 ui32Data) | ||
180 | { | ||
181 | return PDumpRegWithFlagsKM(pszPDumpRegName, ui32Reg, ui32Data, PDUMP_FLAGS_CONTINUOUS); | ||
182 | } | ||
183 | |||
184 | PVRSRV_ERROR PDumpRegPolWithFlagsKM(IMG_CHAR *pszPDumpRegName, | ||
185 | IMG_UINT32 ui32RegAddr, | ||
186 | IMG_UINT32 ui32RegValue, | ||
187 | IMG_UINT32 ui32Mask, | ||
188 | IMG_UINT32 ui32Flags) | ||
189 | { | ||
190 | |||
191 | #define POLL_DELAY 1000U | ||
192 | #define POLL_COUNT_LONG (2000000000U / POLL_DELAY) | ||
193 | #define POLL_COUNT_SHORT (1000000U / POLL_DELAY) | ||
194 | |||
195 | PVRSRV_ERROR eErr; | ||
196 | IMG_UINT32 ui32PollCount; | ||
197 | |||
198 | PDUMP_GET_SCRIPT_STRING(); | ||
199 | PDUMP_DBG(("PDumpRegPolWithFlagsKM")); | ||
200 | if ( _PDumpIsPersistent() ) | ||
201 | { | ||
202 | |||
203 | return PVRSRV_OK; | ||
204 | } | ||
205 | |||
206 | #if 0 | ||
207 | if (((ui32RegAddr == EUR_CR_EVENT_STATUS) && | ||
208 | (ui32RegValue & ui32Mask & EUR_CR_EVENT_STATUS_TA_FINISHED_MASK) != 0) || | ||
209 | ((ui32RegAddr == EUR_CR_EVENT_STATUS) && | ||
210 | (ui32RegValue & ui32Mask & EUR_CR_EVENT_STATUS_PIXELBE_END_RENDER_MASK) != 0) || | ||
211 | ((ui32RegAddr == EUR_CR_EVENT_STATUS) && | ||
212 | (ui32RegValue & ui32Mask & EUR_CR_EVENT_STATUS_DPM_3D_MEM_FREE_MASK) != 0)) | ||
213 | { | ||
214 | ui32PollCount = POLL_COUNT_LONG; | ||
215 | } | ||
216 | else | ||
217 | #endif | ||
218 | { | ||
219 | ui32PollCount = POLL_COUNT_LONG; | ||
220 | } | ||
221 | |||
222 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "POL :%s:0x%08X 0x%08X 0x%08X %d %u %d\r\n", | ||
223 | pszPDumpRegName, ui32RegAddr, ui32RegValue, | ||
224 | ui32Mask, 0, ui32PollCount, POLL_DELAY); | ||
225 | if(eErr != PVRSRV_OK) | ||
226 | { | ||
227 | return eErr; | ||
228 | } | ||
229 | PDumpOSWriteString2(hScript, ui32Flags); | ||
230 | |||
231 | return PVRSRV_OK; | ||
232 | } | ||
233 | |||
234 | |||
235 | PVRSRV_ERROR PDumpRegPolKM(IMG_CHAR *pszPDumpRegName, IMG_UINT32 ui32RegAddr, IMG_UINT32 ui32RegValue, IMG_UINT32 ui32Mask) | ||
236 | { | ||
237 | return PDumpRegPolWithFlagsKM(pszPDumpRegName, ui32RegAddr, ui32RegValue, ui32Mask, PDUMP_FLAGS_CONTINUOUS); | ||
238 | } | ||
239 | |||
240 | PVRSRV_ERROR PDumpMallocPages (PVRSRV_DEVICE_IDENTIFIER *psDevID, | ||
241 | IMG_UINT32 ui32DevVAddr, | ||
242 | IMG_CPU_VIRTADDR pvLinAddr, | ||
243 | IMG_HANDLE hOSMemHandle, | ||
244 | IMG_UINT32 ui32NumBytes, | ||
245 | IMG_UINT32 ui32PageSize, | ||
246 | IMG_HANDLE hUniqueTag) | ||
247 | { | ||
248 | PVRSRV_ERROR eErr; | ||
249 | IMG_PUINT8 pui8LinAddr; | ||
250 | IMG_UINT32 ui32Offset; | ||
251 | IMG_UINT32 ui32NumPages; | ||
252 | IMG_DEV_PHYADDR sDevPAddr; | ||
253 | IMG_UINT32 ui32Page; | ||
254 | IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS; | ||
255 | |||
256 | PDUMP_GET_SCRIPT_STRING(); | ||
257 | ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; | ||
258 | |||
259 | |||
260 | #if !defined(LINUX) | ||
261 | PVR_ASSERT(((IMG_UINTPTR_T)pvLinAddr & HOST_PAGEMASK) == 0); | ||
262 | #endif | ||
263 | |||
264 | PVR_ASSERT(((IMG_UINT32) ui32DevVAddr & HOST_PAGEMASK) == 0); | ||
265 | PVR_ASSERT(((IMG_UINT32) ui32NumBytes & HOST_PAGEMASK) == 0); | ||
266 | |||
267 | |||
268 | |||
269 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "-- MALLOC :%s:VA_%08X 0x%08X %u\r\n", | ||
270 | psDevID->pszPDumpDevName, ui32DevVAddr, ui32NumBytes, ui32PageSize); | ||
271 | if(eErr != PVRSRV_OK) | ||
272 | { | ||
273 | return eErr; | ||
274 | } | ||
275 | PDumpOSWriteString2(hScript, ui32Flags); | ||
276 | |||
277 | |||
278 | |||
279 | pui8LinAddr = (IMG_PUINT8) pvLinAddr; | ||
280 | ui32Offset = 0; | ||
281 | ui32NumPages = ui32NumBytes / ui32PageSize; | ||
282 | while (ui32NumPages) | ||
283 | { | ||
284 | ui32NumPages--; | ||
285 | |||
286 | |||
287 | |||
288 | |||
289 | |||
290 | |||
291 | |||
292 | |||
293 | |||
294 | |||
295 | |||
296 | PDumpOSCPUVAddrToDevPAddr(psDevID->eDeviceType, | ||
297 | hOSMemHandle, | ||
298 | ui32Offset, | ||
299 | pui8LinAddr, | ||
300 | ui32PageSize, | ||
301 | &sDevPAddr); | ||
302 | ui32Page = (IMG_UINT32)(sDevPAddr.uiAddr / ui32PageSize); | ||
303 | |||
304 | pui8LinAddr += ui32PageSize; | ||
305 | ui32Offset += ui32PageSize; | ||
306 | |||
307 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "MALLOC :%s:PA_%08X%08X %u %u 0x%08X\r\n", | ||
308 | psDevID->pszPDumpDevName, | ||
309 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, | ||
310 | ui32Page * ui32PageSize, | ||
311 | ui32PageSize, | ||
312 | ui32PageSize, | ||
313 | ui32Page * ui32PageSize); | ||
314 | if(eErr != PVRSRV_OK) | ||
315 | { | ||
316 | return eErr; | ||
317 | } | ||
318 | PDumpOSWriteString2(hScript, ui32Flags); | ||
319 | } | ||
320 | return PVRSRV_OK; | ||
321 | } | ||
322 | |||
323 | PVRSRV_ERROR PDumpMallocPageTable (PVRSRV_DEVICE_IDENTIFIER *psDevId, | ||
324 | IMG_HANDLE hOSMemHandle, | ||
325 | IMG_UINT32 ui32Offset, | ||
326 | IMG_CPU_VIRTADDR pvLinAddr, | ||
327 | IMG_UINT32 ui32PTSize, | ||
328 | IMG_HANDLE hUniqueTag) | ||
329 | { | ||
330 | PVRSRV_ERROR eErr; | ||
331 | IMG_DEV_PHYADDR sDevPAddr; | ||
332 | IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS; | ||
333 | |||
334 | PDUMP_GET_SCRIPT_STRING(); | ||
335 | |||
336 | PVR_ASSERT(((IMG_UINTPTR_T)pvLinAddr & (ui32PTSize - 1)) == 0); | ||
337 | ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; | ||
338 | |||
339 | |||
340 | |||
341 | eErr = PDumpOSBufprintf(hScript, | ||
342 | ui32MaxLen, | ||
343 | "-- MALLOC :%s:PAGE_TABLE 0x%08X %u\r\n", | ||
344 | psDevId->pszPDumpDevName, | ||
345 | ui32PTSize, | ||
346 | ui32PTSize); | ||
347 | if(eErr != PVRSRV_OK) | ||
348 | { | ||
349 | return eErr; | ||
350 | } | ||
351 | PDumpOSWriteString2(hScript, ui32Flags); | ||
352 | |||
353 | |||
354 | |||
355 | |||
356 | |||
357 | |||
358 | |||
359 | |||
360 | PDumpOSCPUVAddrToDevPAddr(psDevId->eDeviceType, | ||
361 | hOSMemHandle, | ||
362 | ui32Offset, | ||
363 | (IMG_PUINT8) pvLinAddr, | ||
364 | ui32PTSize, | ||
365 | &sDevPAddr); | ||
366 | |||
367 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "MALLOC :%s:PA_%08X%08X 0x%X %u 0x%08X\r\n", | ||
368 | psDevId->pszPDumpDevName, | ||
369 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, | ||
370 | sDevPAddr.uiAddr, | ||
371 | ui32PTSize, | ||
372 | ui32PTSize, | ||
373 | sDevPAddr.uiAddr); | ||
374 | if(eErr != PVRSRV_OK) | ||
375 | { | ||
376 | return eErr; | ||
377 | } | ||
378 | PDumpOSWriteString2(hScript, ui32Flags); | ||
379 | |||
380 | return PVRSRV_OK; | ||
381 | } | ||
382 | |||
383 | PVRSRV_ERROR PDumpFreePages (BM_HEAP *psBMHeap, | ||
384 | IMG_DEV_VIRTADDR sDevVAddr, | ||
385 | IMG_UINT32 ui32NumBytes, | ||
386 | IMG_UINT32 ui32PageSize, | ||
387 | IMG_HANDLE hUniqueTag, | ||
388 | IMG_BOOL bInterleaved) | ||
389 | { | ||
390 | PVRSRV_ERROR eErr; | ||
391 | IMG_UINT32 ui32NumPages, ui32PageCounter; | ||
392 | IMG_DEV_PHYADDR sDevPAddr; | ||
393 | IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS; | ||
394 | PVRSRV_DEVICE_NODE *psDeviceNode; | ||
395 | |||
396 | PDUMP_GET_SCRIPT_STRING(); | ||
397 | |||
398 | PVR_ASSERT(((IMG_UINT32) sDevVAddr.uiAddr & (ui32PageSize - 1)) == 0); | ||
399 | PVR_ASSERT(((IMG_UINT32) ui32NumBytes & (ui32PageSize - 1)) == 0); | ||
400 | |||
401 | psDeviceNode = psBMHeap->pBMContext->psDeviceNode; | ||
402 | ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; | ||
403 | |||
404 | |||
405 | |||
406 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "-- FREE :%s:VA_%08X\r\n", | ||
407 | psDeviceNode->sDevId.pszPDumpDevName, sDevVAddr.uiAddr); | ||
408 | if(eErr != PVRSRV_OK) | ||
409 | { | ||
410 | return eErr; | ||
411 | } | ||
412 | PDumpOSWriteString2(hScript, ui32Flags); | ||
413 | |||
414 | |||
415 | |||
416 | ui32NumPages = ui32NumBytes / ui32PageSize; | ||
417 | for (ui32PageCounter = 0; ui32PageCounter < ui32NumPages; ui32PageCounter++) | ||
418 | { | ||
419 | if (!bInterleaved || (ui32PageCounter % 2) == 0) | ||
420 | { | ||
421 | sDevPAddr = psDeviceNode->pfnMMUGetPhysPageAddr(psBMHeap->pMMUHeap, sDevVAddr); | ||
422 | { | ||
423 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "FREE :%s:PA_%08X%08X\r\n", | ||
424 | psDeviceNode->sDevId.pszPDumpDevName, (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, sDevPAddr.uiAddr); | ||
425 | if(eErr != PVRSRV_OK) | ||
426 | { | ||
427 | return eErr; | ||
428 | } | ||
429 | PDumpOSWriteString2(hScript, ui32Flags); | ||
430 | } | ||
431 | } | ||
432 | else | ||
433 | { | ||
434 | |||
435 | } | ||
436 | |||
437 | sDevVAddr.uiAddr += ui32PageSize; | ||
438 | } | ||
439 | return PVRSRV_OK; | ||
440 | } | ||
441 | |||
442 | PVRSRV_ERROR PDumpFreePageTable (PVRSRV_DEVICE_IDENTIFIER *psDevID, | ||
443 | IMG_HANDLE hOSMemHandle, | ||
444 | IMG_CPU_VIRTADDR pvLinAddr, | ||
445 | IMG_UINT32 ui32PTSize, | ||
446 | IMG_HANDLE hUniqueTag) | ||
447 | { | ||
448 | PVRSRV_ERROR eErr; | ||
449 | IMG_DEV_PHYADDR sDevPAddr; | ||
450 | IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS; | ||
451 | |||
452 | PDUMP_GET_SCRIPT_STRING(); | ||
453 | |||
454 | PVR_UNREFERENCED_PARAMETER(ui32PTSize); | ||
455 | ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; | ||
456 | |||
457 | |||
458 | PVR_ASSERT(((IMG_UINTPTR_T)pvLinAddr & (ui32PTSize-1UL)) == 0); | ||
459 | |||
460 | |||
461 | |||
462 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "-- FREE :%s:PAGE_TABLE\r\n", psDevID->pszPDumpDevName); | ||
463 | if(eErr != PVRSRV_OK) | ||
464 | { | ||
465 | return eErr; | ||
466 | } | ||
467 | PDumpOSWriteString2(hScript, ui32Flags); | ||
468 | |||
469 | |||
470 | |||
471 | |||
472 | |||
473 | |||
474 | |||
475 | |||
476 | PDumpOSCPUVAddrToDevPAddr(psDevID->eDeviceType, | ||
477 | hOSMemHandle, | ||
478 | 0, | ||
479 | (IMG_PUINT8) pvLinAddr, | ||
480 | ui32PTSize, | ||
481 | &sDevPAddr); | ||
482 | |||
483 | { | ||
484 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "FREE :%s:PA_%08X%08X\r\n", | ||
485 | psDevID->pszPDumpDevName, | ||
486 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, | ||
487 | sDevPAddr.uiAddr); | ||
488 | if(eErr != PVRSRV_OK) | ||
489 | { | ||
490 | return eErr; | ||
491 | } | ||
492 | PDumpOSWriteString2(hScript, ui32Flags); | ||
493 | } | ||
494 | |||
495 | return PVRSRV_OK; | ||
496 | } | ||
497 | |||
498 | PVRSRV_ERROR PDumpPDRegWithFlags(PDUMP_MMU_ATTRIB *psMMUAttrib, | ||
499 | IMG_UINT32 ui32Reg, | ||
500 | IMG_UINT32 ui32Data, | ||
501 | IMG_UINT32 ui32Flags, | ||
502 | IMG_HANDLE hUniqueTag) | ||
503 | { | ||
504 | PVRSRV_ERROR eErr; | ||
505 | IMG_CHAR *pszRegString; | ||
506 | PDUMP_GET_SCRIPT_STRING() | ||
507 | |||
508 | if(psMMUAttrib->pszPDRegRegion != IMG_NULL) | ||
509 | { | ||
510 | pszRegString = psMMUAttrib->pszPDRegRegion; | ||
511 | } | ||
512 | else | ||
513 | { | ||
514 | pszRegString = psMMUAttrib->sDevId.pszPDumpRegName; | ||
515 | } | ||
516 | |||
517 | |||
518 | |||
519 | #if defined(SGX_FEATURE_36BIT_MMU) | ||
520 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, | ||
521 | "WRW :%s:$1 :%s:PA_%08X%08X:0x0\r\n", | ||
522 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
523 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
524 | (IMG_UINT32)hUniqueTag, | ||
525 | (ui32Data & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PDEAlignShift); | ||
526 | if(eErr != PVRSRV_OK) | ||
527 | { | ||
528 | return eErr; | ||
529 | } | ||
530 | PDumpOSWriteString2(hScript, ui32Flags); | ||
531 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "SHR :%s:$1 :%s:$1 0x4\r\n", | ||
532 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
533 | psMMUAttrib->sDevId.pszPDumpDevName); | ||
534 | if(eErr != PVRSRV_OK) | ||
535 | { | ||
536 | return eErr; | ||
537 | } | ||
538 | PDumpOSWriteString2(hScript, ui32Flags); | ||
539 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, | ||
540 | "WRW :%s:0x%08X: %s:$1\r\n", | ||
541 | pszRegString, | ||
542 | ui32Reg, | ||
543 | psMMUAttrib->sDevId.pszPDumpDevName); | ||
544 | if(eErr != PVRSRV_OK) | ||
545 | { | ||
546 | return eErr; | ||
547 | } | ||
548 | PDumpOSWriteString2(hScript, ui32Flags); | ||
549 | #else | ||
550 | eErr = PDumpOSBufprintf(hScript, | ||
551 | ui32MaxLen, | ||
552 | "WRW :%s:0x%08X :%s:PA_%08X%08X:0x%08X\r\n", | ||
553 | pszRegString, | ||
554 | ui32Reg, | ||
555 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
556 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, | ||
557 | (ui32Data & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PDEAlignShift, | ||
558 | ui32Data & ~psMMUAttrib->ui32PDEMask); | ||
559 | if(eErr != PVRSRV_OK) | ||
560 | { | ||
561 | return eErr; | ||
562 | } | ||
563 | PDumpOSWriteString2(hScript, ui32Flags); | ||
564 | #endif | ||
565 | return PVRSRV_OK; | ||
566 | } | ||
567 | |||
568 | PVRSRV_ERROR PDumpPDReg (PDUMP_MMU_ATTRIB *psMMUAttrib, | ||
569 | IMG_UINT32 ui32Reg, | ||
570 | IMG_UINT32 ui32Data, | ||
571 | IMG_HANDLE hUniqueTag) | ||
572 | { | ||
573 | return PDumpPDRegWithFlags(psMMUAttrib, ui32Reg, ui32Data, PDUMP_FLAGS_CONTINUOUS, hUniqueTag); | ||
574 | } | ||
575 | |||
576 | PVRSRV_ERROR PDumpMemPolKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, | ||
577 | IMG_UINT32 ui32Offset, | ||
578 | IMG_UINT32 ui32Value, | ||
579 | IMG_UINT32 ui32Mask, | ||
580 | PDUMP_POLL_OPERATOR eOperator, | ||
581 | IMG_UINT32 ui32Flags, | ||
582 | IMG_HANDLE hUniqueTag) | ||
583 | { | ||
584 | #define MEMPOLL_DELAY (1000) | ||
585 | #define MEMPOLL_COUNT (2000000000 / MEMPOLL_DELAY) | ||
586 | |||
587 | PVRSRV_ERROR eErr; | ||
588 | IMG_UINT32 ui32PageOffset; | ||
589 | IMG_UINT8 *pui8LinAddr; | ||
590 | IMG_DEV_PHYADDR sDevPAddr; | ||
591 | IMG_DEV_VIRTADDR sDevVPageAddr; | ||
592 | PDUMP_MMU_ATTRIB *psMMUAttrib; | ||
593 | |||
594 | PDUMP_GET_SCRIPT_STRING(); | ||
595 | if ( _PDumpIsPersistent() ) | ||
596 | { | ||
597 | |||
598 | return PVRSRV_OK; | ||
599 | } | ||
600 | |||
601 | |||
602 | PVR_ASSERT((ui32Offset + sizeof(IMG_UINT32)) <= psMemInfo->ui32AllocSize); | ||
603 | |||
604 | psMMUAttrib = ((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping->pBMHeap->psMMUAttrib; | ||
605 | |||
606 | |||
607 | |||
608 | eErr = PDumpOSBufprintf(hScript, | ||
609 | ui32MaxLen, | ||
610 | "-- POL :%s:VA_%08X 0x%08X 0x%08X %d %d %d\r\n", | ||
611 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
612 | psMemInfo->sDevVAddr.uiAddr + ui32Offset, | ||
613 | ui32Value, | ||
614 | ui32Mask, | ||
615 | eOperator, | ||
616 | MEMPOLL_COUNT, | ||
617 | MEMPOLL_DELAY); | ||
618 | if(eErr != PVRSRV_OK) | ||
619 | { | ||
620 | return eErr; | ||
621 | } | ||
622 | PDumpOSWriteString2(hScript, ui32Flags); | ||
623 | |||
624 | |||
625 | pui8LinAddr = psMemInfo->pvLinAddrKM; | ||
626 | |||
627 | |||
628 | pui8LinAddr += ui32Offset; | ||
629 | |||
630 | |||
631 | |||
632 | |||
633 | PDumpOSCPUVAddrToPhysPages(psMemInfo->sMemBlk.hOSMemHandle, | ||
634 | ui32Offset, | ||
635 | pui8LinAddr, | ||
636 | psMMUAttrib->ui32DataPageMask, | ||
637 | &ui32PageOffset); | ||
638 | |||
639 | |||
640 | sDevVPageAddr.uiAddr = psMemInfo->sDevVAddr.uiAddr + ui32Offset - ui32PageOffset; | ||
641 | |||
642 | PVR_ASSERT((sDevVPageAddr.uiAddr & psMMUAttrib->ui32DataPageMask) == 0); | ||
643 | |||
644 | |||
645 | BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); | ||
646 | |||
647 | |||
648 | sDevPAddr.uiAddr += ui32PageOffset; | ||
649 | |||
650 | eErr = PDumpOSBufprintf(hScript, | ||
651 | ui32MaxLen, | ||
652 | "POL :%s:PA_%08X%08X:0x%08X 0x%08X 0x%08X %d %d %d\r\n", | ||
653 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
654 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, | ||
655 | sDevPAddr.uiAddr & ~(psMMUAttrib->ui32DataPageMask), | ||
656 | sDevPAddr.uiAddr & (psMMUAttrib->ui32DataPageMask), | ||
657 | ui32Value, | ||
658 | ui32Mask, | ||
659 | eOperator, | ||
660 | MEMPOLL_COUNT, | ||
661 | MEMPOLL_DELAY); | ||
662 | if(eErr != PVRSRV_OK) | ||
663 | { | ||
664 | return eErr; | ||
665 | } | ||
666 | PDumpOSWriteString2(hScript, ui32Flags); | ||
667 | |||
668 | return PVRSRV_OK; | ||
669 | } | ||
670 | |||
671 | PVRSRV_ERROR PDumpMemKM(IMG_PVOID pvAltLinAddr, | ||
672 | PVRSRV_KERNEL_MEM_INFO *psMemInfo, | ||
673 | IMG_UINT32 ui32Offset, | ||
674 | IMG_UINT32 ui32Bytes, | ||
675 | IMG_UINT32 ui32Flags, | ||
676 | IMG_HANDLE hUniqueTag) | ||
677 | { | ||
678 | PVRSRV_ERROR eErr; | ||
679 | IMG_UINT32 ui32NumPages; | ||
680 | IMG_UINT32 ui32PageByteOffset; | ||
681 | IMG_UINT32 ui32BlockBytes; | ||
682 | IMG_UINT8* pui8LinAddr; | ||
683 | IMG_UINT8* pui8DataLinAddr = IMG_NULL; | ||
684 | IMG_DEV_VIRTADDR sDevVPageAddr; | ||
685 | IMG_DEV_VIRTADDR sDevVAddr; | ||
686 | IMG_DEV_PHYADDR sDevPAddr; | ||
687 | IMG_UINT32 ui32ParamOutPos; | ||
688 | PDUMP_MMU_ATTRIB *psMMUAttrib; | ||
689 | IMG_UINT32 ui32DataPageSize; | ||
690 | |||
691 | PDUMP_GET_SCRIPT_AND_FILE_STRING(); | ||
692 | |||
693 | psMMUAttrib = ((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping->pBMHeap->psMMUAttrib; | ||
694 | |||
695 | |||
696 | |||
697 | PVR_ASSERT((ui32Offset + ui32Bytes) <= psMemInfo->ui32AllocSize); | ||
698 | |||
699 | if (!PDumpOSJTInitialised()) | ||
700 | { | ||
701 | return PVRSRV_ERROR_PDUMP_NOT_AVAILABLE; | ||
702 | } | ||
703 | |||
704 | |||
705 | if (ui32Bytes == 0 || PDumpOSIsSuspended()) | ||
706 | { | ||
707 | return PVRSRV_OK; | ||
708 | } | ||
709 | |||
710 | |||
711 | if(pvAltLinAddr) | ||
712 | { | ||
713 | pui8DataLinAddr = pvAltLinAddr; | ||
714 | } | ||
715 | else if(psMemInfo->pvLinAddrKM) | ||
716 | { | ||
717 | pui8DataLinAddr = (IMG_UINT8 *)psMemInfo->pvLinAddrKM + ui32Offset; | ||
718 | } | ||
719 | pui8LinAddr = (IMG_UINT8 *)psMemInfo->pvLinAddrKM; | ||
720 | sDevVAddr = psMemInfo->sDevVAddr; | ||
721 | |||
722 | |||
723 | sDevVAddr.uiAddr += ui32Offset; | ||
724 | pui8LinAddr += ui32Offset; | ||
725 | |||
726 | PVR_ASSERT(pui8DataLinAddr); | ||
727 | |||
728 | PDumpOSCheckForSplitting(PDumpOSGetStream(PDUMP_STREAM_PARAM2), ui32Bytes, ui32Flags); | ||
729 | |||
730 | ui32ParamOutPos = PDumpOSGetStreamOffset(PDUMP_STREAM_PARAM2); | ||
731 | |||
732 | |||
733 | |||
734 | if(!PDumpOSWriteString(PDumpOSGetStream(PDUMP_STREAM_PARAM2), | ||
735 | pui8DataLinAddr, | ||
736 | ui32Bytes, | ||
737 | ui32Flags)) | ||
738 | { | ||
739 | return PVRSRV_ERROR_PDUMP_BUFFER_FULL; | ||
740 | } | ||
741 | |||
742 | if (PDumpOSGetParamFileNum() == 0) | ||
743 | { | ||
744 | eErr = PDumpOSSprintf(pszFileName, ui32MaxLenFileName, "%%0%%.prm"); | ||
745 | } | ||
746 | else | ||
747 | { | ||
748 | eErr = PDumpOSSprintf(pszFileName, ui32MaxLenFileName, "%%0%%_%u.prm", PDumpOSGetParamFileNum()); | ||
749 | } | ||
750 | if(eErr != PVRSRV_OK) | ||
751 | { | ||
752 | return eErr; | ||
753 | } | ||
754 | |||
755 | |||
756 | |||
757 | eErr = PDumpOSBufprintf(hScript, | ||
758 | ui32MaxLenScript, | ||
759 | "-- LDB :%s:VA_%08X%08X:0x%08X 0x%08X 0x%08X %s\r\n", | ||
760 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
761 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, | ||
762 | psMemInfo->sDevVAddr.uiAddr, | ||
763 | ui32Offset, | ||
764 | ui32Bytes, | ||
765 | ui32ParamOutPos, | ||
766 | pszFileName); | ||
767 | if(eErr != PVRSRV_OK) | ||
768 | { | ||
769 | return eErr; | ||
770 | } | ||
771 | PDumpOSWriteString2(hScript, ui32Flags); | ||
772 | |||
773 | |||
774 | |||
775 | |||
776 | PDumpOSCPUVAddrToPhysPages(psMemInfo->sMemBlk.hOSMemHandle, | ||
777 | ui32Offset, | ||
778 | pui8LinAddr, | ||
779 | psMMUAttrib->ui32DataPageMask, | ||
780 | &ui32PageByteOffset); | ||
781 | ui32DataPageSize = psMMUAttrib->ui32DataPageMask + 1; | ||
782 | ui32NumPages = (ui32PageByteOffset + ui32Bytes + psMMUAttrib->ui32DataPageMask) / ui32DataPageSize; | ||
783 | |||
784 | while(ui32NumPages) | ||
785 | { | ||
786 | ui32NumPages--; | ||
787 | |||
788 | |||
789 | sDevVPageAddr.uiAddr = sDevVAddr.uiAddr - ui32PageByteOffset; | ||
790 | |||
791 | if (ui32DataPageSize <= PDUMP_TEMP_BUFFER_SIZE) | ||
792 | { | ||
793 | |||
794 | PVR_ASSERT((sDevVPageAddr.uiAddr & psMMUAttrib->ui32DataPageMask) == 0); | ||
795 | } | ||
796 | |||
797 | |||
798 | BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); | ||
799 | |||
800 | |||
801 | sDevPAddr.uiAddr += ui32PageByteOffset; | ||
802 | |||
803 | |||
804 | if (ui32PageByteOffset + ui32Bytes > ui32DataPageSize) | ||
805 | { | ||
806 | |||
807 | ui32BlockBytes = ui32DataPageSize - ui32PageByteOffset; | ||
808 | } | ||
809 | else | ||
810 | { | ||
811 | |||
812 | ui32BlockBytes = ui32Bytes; | ||
813 | } | ||
814 | |||
815 | eErr = PDumpOSBufprintf(hScript, | ||
816 | ui32MaxLenScript, | ||
817 | "LDB :%s:PA_%08X%08X:0x%08X 0x%08X 0x%08X %s\r\n", | ||
818 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
819 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, | ||
820 | sDevPAddr.uiAddr & ~(psMMUAttrib->ui32DataPageMask), | ||
821 | sDevPAddr.uiAddr & (psMMUAttrib->ui32DataPageMask), | ||
822 | ui32BlockBytes, | ||
823 | ui32ParamOutPos, | ||
824 | pszFileName); | ||
825 | if(eErr != PVRSRV_OK) | ||
826 | { | ||
827 | return eErr; | ||
828 | } | ||
829 | PDumpOSWriteString2(hScript, ui32Flags); | ||
830 | |||
831 | |||
832 | |||
833 | #if defined(SGX_FEATURE_VARIABLE_MMU_PAGE_SIZE) | ||
834 | |||
835 | ui32PageByteOffset = (ui32PageByteOffset + ui32BlockBytes) % ui32DataPageSize; | ||
836 | #else | ||
837 | |||
838 | ui32PageByteOffset = 0; | ||
839 | #endif | ||
840 | |||
841 | ui32Bytes -= ui32BlockBytes; | ||
842 | |||
843 | sDevVAddr.uiAddr += ui32BlockBytes; | ||
844 | |||
845 | pui8LinAddr += ui32BlockBytes; | ||
846 | |||
847 | ui32ParamOutPos += ui32BlockBytes; | ||
848 | } | ||
849 | |||
850 | return PVRSRV_OK; | ||
851 | } | ||
852 | |||
853 | PVRSRV_ERROR PDumpMemPDEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, | ||
854 | IMG_HANDLE hOSMemHandle, | ||
855 | IMG_CPU_VIRTADDR pvLinAddr, | ||
856 | IMG_UINT32 ui32Bytes, | ||
857 | IMG_UINT32 ui32Flags, | ||
858 | IMG_BOOL bInitialisePages, | ||
859 | IMG_HANDLE hUniqueTag1, | ||
860 | IMG_HANDLE hUniqueTag2) | ||
861 | { | ||
862 | PDUMP_MMU_ATTRIB sMMUAttrib; | ||
863 | |||
864 | |||
865 | sMMUAttrib = *psMMUAttrib; | ||
866 | sMMUAttrib.ui32PTSize = HOST_PAGESIZE(); | ||
867 | return PDumpMemPTEntriesKM( &sMMUAttrib, | ||
868 | hOSMemHandle, | ||
869 | pvLinAddr, | ||
870 | ui32Bytes, | ||
871 | ui32Flags, | ||
872 | bInitialisePages, | ||
873 | hUniqueTag1, | ||
874 | hUniqueTag2); | ||
875 | } | ||
876 | |||
877 | PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, | ||
878 | IMG_HANDLE hOSMemHandle, | ||
879 | IMG_CPU_VIRTADDR pvLinAddr, | ||
880 | IMG_UINT32 ui32Bytes, | ||
881 | IMG_UINT32 ui32Flags, | ||
882 | IMG_BOOL bInitialisePages, | ||
883 | IMG_HANDLE hUniqueTag1, | ||
884 | IMG_HANDLE hUniqueTag2) | ||
885 | { | ||
886 | PVRSRV_ERROR eErr; | ||
887 | IMG_UINT32 ui32NumPages; | ||
888 | IMG_UINT32 ui32PageOffset; | ||
889 | IMG_UINT32 ui32BlockBytes; | ||
890 | IMG_UINT8* pui8LinAddr; | ||
891 | IMG_DEV_PHYADDR sDevPAddr; | ||
892 | IMG_CPU_PHYADDR sCpuPAddr; | ||
893 | IMG_UINT32 ui32Offset; | ||
894 | IMG_UINT32 ui32ParamOutPos; | ||
895 | IMG_UINT32 ui32PageMask; | ||
896 | |||
897 | PDUMP_GET_SCRIPT_AND_FILE_STRING(); | ||
898 | ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; | ||
899 | |||
900 | if (!PDumpOSJTInitialised()) | ||
901 | { | ||
902 | return PVRSRV_ERROR_PDUMP_NOT_AVAILABLE; | ||
903 | } | ||
904 | |||
905 | if (!pvLinAddr) | ||
906 | { | ||
907 | return PVRSRV_ERROR_INVALID_PARAMS; | ||
908 | } | ||
909 | |||
910 | if (PDumpOSIsSuspended()) | ||
911 | { | ||
912 | return PVRSRV_OK; | ||
913 | } | ||
914 | |||
915 | PDumpOSCheckForSplitting(PDumpOSGetStream(PDUMP_STREAM_PARAM2), ui32Bytes, ui32Flags); | ||
916 | |||
917 | ui32ParamOutPos = PDumpOSGetStreamOffset(PDUMP_STREAM_PARAM2); | ||
918 | |||
919 | if (bInitialisePages) | ||
920 | { | ||
921 | |||
922 | |||
923 | |||
924 | if (!PDumpOSWriteString(PDumpOSGetStream(PDUMP_STREAM_PARAM2), | ||
925 | pvLinAddr, | ||
926 | ui32Bytes, | ||
927 | ui32Flags | PDUMP_FLAGS_CONTINUOUS)) | ||
928 | { | ||
929 | return PVRSRV_ERROR_PDUMP_BUFFER_FULL; | ||
930 | } | ||
931 | |||
932 | if (PDumpOSGetParamFileNum() == 0) | ||
933 | { | ||
934 | eErr = PDumpOSSprintf(pszFileName, ui32MaxLenFileName, "%%0%%.prm"); | ||
935 | } | ||
936 | else | ||
937 | { | ||
938 | eErr = PDumpOSSprintf(pszFileName, ui32MaxLenFileName, "%%0%%_%u.prm", PDumpOSGetParamFileNum()); | ||
939 | } | ||
940 | if(eErr != PVRSRV_OK) | ||
941 | { | ||
942 | return eErr; | ||
943 | } | ||
944 | } | ||
945 | |||
946 | |||
947 | |||
948 | |||
949 | |||
950 | |||
951 | ui32PageMask = psMMUAttrib->ui32PTSize - 1; | ||
952 | |||
953 | |||
954 | |||
955 | |||
956 | ui32PageOffset = (IMG_UINT32)((IMG_UINTPTR_T)pvLinAddr & (psMMUAttrib->ui32PTSize - 1)); | ||
957 | ui32NumPages = (ui32PageOffset + ui32Bytes + psMMUAttrib->ui32PTSize - 1) / psMMUAttrib->ui32PTSize; | ||
958 | pui8LinAddr = (IMG_UINT8*) pvLinAddr; | ||
959 | |||
960 | while (ui32NumPages) | ||
961 | { | ||
962 | ui32NumPages--; | ||
963 | |||
964 | |||
965 | |||
966 | |||
967 | |||
968 | |||
969 | sCpuPAddr = OSMapLinToCPUPhys(hOSMemHandle, pui8LinAddr); | ||
970 | sDevPAddr = SysCpuPAddrToDevPAddr(psMMUAttrib->sDevId.eDeviceType, sCpuPAddr); | ||
971 | |||
972 | |||
973 | if (ui32PageOffset + ui32Bytes > psMMUAttrib->ui32PTSize) | ||
974 | { | ||
975 | |||
976 | ui32BlockBytes = psMMUAttrib->ui32PTSize - ui32PageOffset; | ||
977 | } | ||
978 | else | ||
979 | { | ||
980 | |||
981 | ui32BlockBytes = ui32Bytes; | ||
982 | } | ||
983 | |||
984 | |||
985 | |||
986 | |||
987 | if (bInitialisePages) | ||
988 | { | ||
989 | eErr = PDumpOSBufprintf(hScript, | ||
990 | ui32MaxLenScript, | ||
991 | "LDB :%s:PA_%08X%08X:0x%08X 0x%08X 0x%08X %s\r\n", | ||
992 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
993 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, | ||
994 | sDevPAddr.uiAddr & ~ui32PageMask, | ||
995 | sDevPAddr.uiAddr & ui32PageMask, | ||
996 | ui32BlockBytes, | ||
997 | ui32ParamOutPos, | ||
998 | pszFileName); | ||
999 | if(eErr != PVRSRV_OK) | ||
1000 | { | ||
1001 | return eErr; | ||
1002 | } | ||
1003 | PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); | ||
1004 | } | ||
1005 | else | ||
1006 | { | ||
1007 | for (ui32Offset = 0; ui32Offset < ui32BlockBytes; ui32Offset += sizeof(IMG_UINT32)) | ||
1008 | { | ||
1009 | IMG_UINT32 ui32PTE = *((IMG_UINT32 *) (pui8LinAddr + ui32Offset)); | ||
1010 | |||
1011 | if ((ui32PTE & psMMUAttrib->ui32PDEMask) != 0) | ||
1012 | { | ||
1013 | |||
1014 | #if defined(SGX_FEATURE_36BIT_MMU) | ||
1015 | eErr = PDumpOSBufprintf(hScript, | ||
1016 | ui32MaxLenScript, | ||
1017 | "WRW :%s:$1 :%s:PA_%08X%08X:0x0\r\n", | ||
1018 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1019 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1020 | (IMG_UINT32)hUniqueTag2, | ||
1021 | (ui32PTE & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PTEAlignShift); | ||
1022 | if(eErr != PVRSRV_OK) | ||
1023 | { | ||
1024 | return eErr; | ||
1025 | } | ||
1026 | PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); | ||
1027 | eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, "SHR :%s:$1 :%s:$1 0x4\r\n", | ||
1028 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1029 | psMMUAttrib->sDevId.pszPDumpDevName); | ||
1030 | if(eErr != PVRSRV_OK) | ||
1031 | { | ||
1032 | return eErr; | ||
1033 | } | ||
1034 | PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); | ||
1035 | eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, "OR :%s:$1 :%s:$1 0x%08X\r\n", | ||
1036 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1037 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1038 | ui32PTE & ~psMMUAttrib->ui32PDEMask); | ||
1039 | if(eErr != PVRSRV_OK) | ||
1040 | { | ||
1041 | return eErr; | ||
1042 | } | ||
1043 | PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); | ||
1044 | eErr = PDumpOSBufprintf(hScript, | ||
1045 | ui32MaxLenScript, | ||
1046 | "WRW :%s:PA_%08X%08X:0x%08X :%s:$1\r\n", | ||
1047 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1048 | (IMG_UINT32)hUniqueTag1, | ||
1049 | (sDevPAddr.uiAddr + ui32Offset) & ~ui32PageMask, | ||
1050 | (sDevPAddr.uiAddr + ui32Offset) & ui32PageMask, | ||
1051 | psMMUAttrib->sDevId.pszPDumpDevName); | ||
1052 | if(eErr != PVRSRV_OK) | ||
1053 | { | ||
1054 | return eErr; | ||
1055 | } | ||
1056 | PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); | ||
1057 | #else | ||
1058 | eErr = PDumpOSBufprintf(hScript, | ||
1059 | ui32MaxLenScript, | ||
1060 | "WRW :%s:PA_%08X%08X:0x%08X :%s:PA_%08X%08X:0x%08X\r\n", | ||
1061 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1062 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, | ||
1063 | (sDevPAddr.uiAddr + ui32Offset) & ~ui32PageMask, | ||
1064 | (sDevPAddr.uiAddr + ui32Offset) & ui32PageMask, | ||
1065 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1066 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag2, | ||
1067 | (ui32PTE & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PTEAlignShift, | ||
1068 | ui32PTE & ~psMMUAttrib->ui32PDEMask); | ||
1069 | if(eErr != PVRSRV_OK) | ||
1070 | { | ||
1071 | return eErr; | ||
1072 | } | ||
1073 | PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); | ||
1074 | #endif | ||
1075 | } | ||
1076 | else | ||
1077 | { | ||
1078 | PVR_ASSERT((ui32PTE & psMMUAttrib->ui32PTEValid) == 0UL); | ||
1079 | eErr = PDumpOSBufprintf(hScript, | ||
1080 | ui32MaxLenScript, | ||
1081 | "WRW :%s:PA_%08X%08X:0x%08X 0x%08X%08X\r\n", | ||
1082 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1083 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, | ||
1084 | (sDevPAddr.uiAddr + ui32Offset) & ~ui32PageMask, | ||
1085 | (sDevPAddr.uiAddr + ui32Offset) & ui32PageMask, | ||
1086 | (ui32PTE << psMMUAttrib->ui32PTEAlignShift), | ||
1087 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag2); | ||
1088 | if(eErr != PVRSRV_OK) | ||
1089 | { | ||
1090 | return eErr; | ||
1091 | } | ||
1092 | PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); | ||
1093 | } | ||
1094 | } | ||
1095 | } | ||
1096 | |||
1097 | |||
1098 | |||
1099 | |||
1100 | ui32PageOffset = 0; | ||
1101 | |||
1102 | ui32Bytes -= ui32BlockBytes; | ||
1103 | |||
1104 | pui8LinAddr += ui32BlockBytes; | ||
1105 | |||
1106 | ui32ParamOutPos += ui32BlockBytes; | ||
1107 | } | ||
1108 | |||
1109 | return PVRSRV_OK; | ||
1110 | } | ||
1111 | |||
1112 | PVRSRV_ERROR PDumpPDDevPAddrKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, | ||
1113 | IMG_UINT32 ui32Offset, | ||
1114 | IMG_DEV_PHYADDR sPDDevPAddr, | ||
1115 | IMG_HANDLE hUniqueTag1, | ||
1116 | IMG_HANDLE hUniqueTag2) | ||
1117 | { | ||
1118 | PVRSRV_ERROR eErr; | ||
1119 | IMG_UINT32 ui32PageByteOffset; | ||
1120 | IMG_DEV_VIRTADDR sDevVAddr; | ||
1121 | IMG_DEV_VIRTADDR sDevVPageAddr; | ||
1122 | IMG_DEV_PHYADDR sDevPAddr; | ||
1123 | IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS; | ||
1124 | IMG_UINT32 ui32ParamOutPos; | ||
1125 | PDUMP_MMU_ATTRIB *psMMUAttrib; | ||
1126 | IMG_UINT32 ui32PageMask; | ||
1127 | |||
1128 | PDUMP_GET_SCRIPT_AND_FILE_STRING(); | ||
1129 | |||
1130 | if (!PDumpOSJTInitialised()) | ||
1131 | { | ||
1132 | return PVRSRV_ERROR_PDUMP_NOT_AVAILABLE; | ||
1133 | } | ||
1134 | |||
1135 | psMMUAttrib = ((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping->pBMHeap->psMMUAttrib; | ||
1136 | ui32PageMask = psMMUAttrib->ui32PTSize - 1; | ||
1137 | |||
1138 | ui32ParamOutPos = PDumpOSGetStreamOffset(PDUMP_STREAM_PARAM2); | ||
1139 | |||
1140 | |||
1141 | if(!PDumpOSWriteString(PDumpOSGetStream(PDUMP_STREAM_PARAM2), | ||
1142 | (IMG_UINT8 *)&sPDDevPAddr, | ||
1143 | sizeof(IMG_DEV_PHYADDR), | ||
1144 | ui32Flags)) | ||
1145 | { | ||
1146 | return PVRSRV_ERROR_PDUMP_BUFFER_FULL; | ||
1147 | } | ||
1148 | |||
1149 | if (PDumpOSGetParamFileNum() == 0) | ||
1150 | { | ||
1151 | eErr = PDumpOSSprintf(pszFileName, ui32MaxLenFileName, "%%0%%.prm"); | ||
1152 | } | ||
1153 | else | ||
1154 | { | ||
1155 | eErr = PDumpOSSprintf(pszFileName, ui32MaxLenFileName, "%%0%%_%u.prm", PDumpOSGetParamFileNum()); | ||
1156 | } | ||
1157 | if(eErr != PVRSRV_OK) | ||
1158 | { | ||
1159 | return eErr; | ||
1160 | } | ||
1161 | |||
1162 | |||
1163 | eErr = PDumpOSBufprintf(hScript, | ||
1164 | ui32MaxLenScript, | ||
1165 | "-- LDB :%s:PA_0x%08X%08X:0x%08X 0x%08X 0x%08X %s\r\n", | ||
1166 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1167 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, | ||
1168 | sPDDevPAddr.uiAddr & ~ui32PageMask, | ||
1169 | sPDDevPAddr.uiAddr & ui32PageMask, | ||
1170 | sizeof(IMG_DEV_PHYADDR), | ||
1171 | ui32ParamOutPos, | ||
1172 | pszFileName); | ||
1173 | if(eErr != PVRSRV_OK) | ||
1174 | { | ||
1175 | return eErr; | ||
1176 | } | ||
1177 | PDumpOSWriteString2(hScript, ui32Flags); | ||
1178 | |||
1179 | |||
1180 | sDevVAddr = psMemInfo->sDevVAddr; | ||
1181 | ui32PageByteOffset = sDevVAddr.uiAddr & ui32PageMask; | ||
1182 | |||
1183 | sDevVPageAddr.uiAddr = sDevVAddr.uiAddr - ui32PageByteOffset; | ||
1184 | PVR_ASSERT((sDevVPageAddr.uiAddr & 0xFFF) == 0); | ||
1185 | |||
1186 | BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); | ||
1187 | sDevPAddr.uiAddr += ui32PageByteOffset + ui32Offset; | ||
1188 | |||
1189 | if ((sPDDevPAddr.uiAddr & psMMUAttrib->ui32PDEMask) != 0UL) | ||
1190 | { | ||
1191 | #if defined(SGX_FEATURE_36BIT_MMU) | ||
1192 | eErr = PDumpOSBufprintf(hScript, | ||
1193 | ui32MaxLenScript, | ||
1194 | "WRW :%s:$1 :%s:PA_%08X%08X:0x0\r\n", | ||
1195 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1196 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1197 | (IMG_UINT32)hUniqueTag2, | ||
1198 | sPDDevPAddr.uiAddr); | ||
1199 | if(eErr != PVRSRV_OK) | ||
1200 | { | ||
1201 | return eErr; | ||
1202 | } | ||
1203 | PDumpOSWriteString2(hScript, ui32Flags); | ||
1204 | |||
1205 | eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, "AND :%s:$2 :%s:$1 0xFFFFFFFF\r\n", | ||
1206 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1207 | psMMUAttrib->sDevId.pszPDumpDevName); | ||
1208 | if(eErr != PVRSRV_OK) | ||
1209 | { | ||
1210 | return eErr; | ||
1211 | } | ||
1212 | PDumpOSWriteString2(hScript, ui32Flags); | ||
1213 | |||
1214 | eErr = PDumpOSBufprintf(hScript, | ||
1215 | ui32MaxLenScript, | ||
1216 | "WRW :%s:PA_%08X%08X:0x%08X :%s:$2\r\n", | ||
1217 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1218 | (IMG_UINT32)hUniqueTag1, | ||
1219 | (sDevPAddr.uiAddr) & ~(psMMUAttrib->ui32DataPageMask), | ||
1220 | (sDevPAddr.uiAddr) & (psMMUAttrib->ui32DataPageMask), | ||
1221 | psMMUAttrib->sDevId.pszPDumpDevName); | ||
1222 | if(eErr != PVRSRV_OK) | ||
1223 | { | ||
1224 | return eErr; | ||
1225 | } | ||
1226 | PDumpOSWriteString2(hScript, ui32Flags); | ||
1227 | |||
1228 | eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, "SHR :%s:$2 :%s:$1 0x20\r\n", | ||
1229 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1230 | psMMUAttrib->sDevId.pszPDumpDevName); | ||
1231 | if(eErr != PVRSRV_OK) | ||
1232 | { | ||
1233 | return eErr; | ||
1234 | } | ||
1235 | PDumpOSWriteString2(hScript, ui32Flags); | ||
1236 | |||
1237 | eErr = PDumpOSBufprintf(hScript, | ||
1238 | ui32MaxLenScript, | ||
1239 | "WRW :%s:PA_%08X%08X:0x%08X :%s:$2\r\n", | ||
1240 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1241 | (IMG_UINT32)hUniqueTag1, | ||
1242 | (sDevPAddr.uiAddr + 4) & ~(psMMUAttrib->ui32DataPageMask), | ||
1243 | (sDevPAddr.uiAddr + 4) & (psMMUAttrib->ui32DataPageMask), | ||
1244 | psMMUAttrib->sDevId.pszPDumpDevName); | ||
1245 | if(eErr != PVRSRV_OK) | ||
1246 | { | ||
1247 | return eErr; | ||
1248 | } | ||
1249 | PDumpOSWriteString2(hScript, ui32Flags); | ||
1250 | #else | ||
1251 | eErr = PDumpOSBufprintf(hScript, | ||
1252 | ui32MaxLenScript, | ||
1253 | "WRW :%s:PA_%08X%08X:0x%08X :%s:PA_%08X%08X:0x%08X\r\n", | ||
1254 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1255 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, | ||
1256 | sDevPAddr.uiAddr & ~ui32PageMask, | ||
1257 | sDevPAddr.uiAddr & ui32PageMask, | ||
1258 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1259 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag2, | ||
1260 | sPDDevPAddr.uiAddr & psMMUAttrib->ui32PDEMask, | ||
1261 | sPDDevPAddr.uiAddr & ~psMMUAttrib->ui32PDEMask); | ||
1262 | if(eErr != PVRSRV_OK) | ||
1263 | { | ||
1264 | return eErr; | ||
1265 | } | ||
1266 | #endif | ||
1267 | } | ||
1268 | else | ||
1269 | { | ||
1270 | PVR_ASSERT(!(sDevPAddr.uiAddr & psMMUAttrib->ui32PTEValid)); | ||
1271 | eErr = PDumpOSBufprintf(hScript, | ||
1272 | ui32MaxLenScript, | ||
1273 | "WRW :%s:PA_%08X%08X:0x%08X 0x%08X\r\n", | ||
1274 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1275 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, | ||
1276 | sDevPAddr.uiAddr & ~ui32PageMask, | ||
1277 | sDevPAddr.uiAddr & ui32PageMask, | ||
1278 | sPDDevPAddr.uiAddr); | ||
1279 | if(eErr != PVRSRV_OK) | ||
1280 | { | ||
1281 | return eErr; | ||
1282 | } | ||
1283 | } | ||
1284 | PDumpOSWriteString2(hScript, ui32Flags); | ||
1285 | |||
1286 | return PVRSRV_OK; | ||
1287 | } | ||
1288 | |||
1289 | PVRSRV_ERROR PDumpCommentKM(IMG_CHAR *pszComment, IMG_UINT32 ui32Flags) | ||
1290 | { | ||
1291 | PVRSRV_ERROR eErr; | ||
1292 | IMG_CHAR pszCommentPrefix[] = "-- "; | ||
1293 | #if defined(PDUMP_DEBUG_OUTFILES) | ||
1294 | IMG_CHAR pszTemp[256]; | ||
1295 | #endif | ||
1296 | IMG_UINT32 ui32LenCommentPrefix; | ||
1297 | PDUMP_GET_SCRIPT_STRING(); | ||
1298 | PDUMP_DBG(("PDumpCommentKM")); | ||
1299 | #if defined(PDUMP_DEBUG_OUTFILES) | ||
1300 | |||
1301 | ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; | ||
1302 | #endif | ||
1303 | |||
1304 | PDumpOSVerifyLineEnding(pszComment, ui32MaxLen); | ||
1305 | |||
1306 | |||
1307 | ui32LenCommentPrefix = PDumpOSBuflen(pszCommentPrefix, sizeof(pszCommentPrefix)); | ||
1308 | |||
1309 | |||
1310 | if (!PDumpOSWriteString(PDumpOSGetStream(PDUMP_STREAM_SCRIPT2), | ||
1311 | (IMG_UINT8*)pszCommentPrefix, | ||
1312 | ui32LenCommentPrefix, | ||
1313 | ui32Flags)) | ||
1314 | { | ||
1315 | if(ui32Flags & PDUMP_FLAGS_CONTINUOUS) | ||
1316 | { | ||
1317 | return PVRSRV_ERROR_PDUMP_BUFFER_FULL; | ||
1318 | } | ||
1319 | else | ||
1320 | { | ||
1321 | return PVRSRV_ERROR_CMD_NOT_PROCESSED; | ||
1322 | } | ||
1323 | } | ||
1324 | #if defined(PDUMP_DEBUG_OUTFILES) | ||
1325 | |||
1326 | eErr = PDumpOSSprintf(pszTemp, 256, "%d-%d %s", | ||
1327 | _PDumpGetPID(), | ||
1328 | g_ui32EveryLineCounter, | ||
1329 | pszComment); | ||
1330 | |||
1331 | |||
1332 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "%s", | ||
1333 | pszTemp); | ||
1334 | #else | ||
1335 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "%s", | ||
1336 | pszComment); | ||
1337 | #endif | ||
1338 | if( (eErr != PVRSRV_OK) && | ||
1339 | (eErr != PVRSRV_ERROR_PDUMP_BUF_OVERFLOW)) | ||
1340 | { | ||
1341 | return eErr; | ||
1342 | } | ||
1343 | PDumpOSWriteString2(hScript, ui32Flags); | ||
1344 | return PVRSRV_OK; | ||
1345 | } | ||
1346 | |||
1347 | PVRSRV_ERROR PDumpCommentWithFlags(IMG_UINT32 ui32Flags, IMG_CHAR * pszFormat, ...) | ||
1348 | { | ||
1349 | PVRSRV_ERROR eErr; | ||
1350 | PDUMP_va_list ap; | ||
1351 | PDUMP_GET_MSG_STRING(); | ||
1352 | |||
1353 | |||
1354 | PDUMP_va_start(ap, pszFormat); | ||
1355 | eErr = PDumpOSVSprintf(pszMsg, ui32MaxLen, pszFormat, ap); | ||
1356 | PDUMP_va_end(ap); | ||
1357 | |||
1358 | if(eErr != PVRSRV_OK) | ||
1359 | { | ||
1360 | return eErr; | ||
1361 | } | ||
1362 | return PDumpCommentKM(pszMsg, ui32Flags); | ||
1363 | } | ||
1364 | |||
1365 | PVRSRV_ERROR PDumpComment(IMG_CHAR *pszFormat, ...) | ||
1366 | { | ||
1367 | PVRSRV_ERROR eErr; | ||
1368 | PDUMP_va_list ap; | ||
1369 | PDUMP_GET_MSG_STRING(); | ||
1370 | |||
1371 | |||
1372 | PDUMP_va_start(ap, pszFormat); | ||
1373 | eErr = PDumpOSVSprintf(pszMsg, ui32MaxLen, pszFormat, ap); | ||
1374 | PDUMP_va_end(ap); | ||
1375 | |||
1376 | if(eErr != PVRSRV_OK) | ||
1377 | { | ||
1378 | return eErr; | ||
1379 | } | ||
1380 | return PDumpCommentKM(pszMsg, PDUMP_FLAGS_CONTINUOUS); | ||
1381 | } | ||
1382 | |||
1383 | PVRSRV_ERROR PDumpDriverInfoKM(IMG_CHAR *pszString, IMG_UINT32 ui32Flags) | ||
1384 | { | ||
1385 | PVRSRV_ERROR eErr; | ||
1386 | IMG_UINT32 ui32MsgLen; | ||
1387 | PDUMP_GET_MSG_STRING(); | ||
1388 | |||
1389 | |||
1390 | eErr = PDumpOSSprintf(pszMsg, ui32MaxLen, "%s", pszString); | ||
1391 | if(eErr != PVRSRV_OK) | ||
1392 | { | ||
1393 | return eErr; | ||
1394 | } | ||
1395 | |||
1396 | |||
1397 | PDumpOSVerifyLineEnding(pszMsg, ui32MaxLen); | ||
1398 | ui32MsgLen = PDumpOSBuflen(pszMsg, ui32MaxLen); | ||
1399 | |||
1400 | if (!PDumpOSWriteString(PDumpOSGetStream(PDUMP_STREAM_DRIVERINFO), | ||
1401 | (IMG_UINT8*)pszMsg, | ||
1402 | ui32MsgLen, | ||
1403 | ui32Flags)) | ||
1404 | { | ||
1405 | if (ui32Flags & PDUMP_FLAGS_CONTINUOUS) | ||
1406 | { | ||
1407 | return PVRSRV_ERROR_PDUMP_BUFFER_FULL; | ||
1408 | } | ||
1409 | else | ||
1410 | { | ||
1411 | return PVRSRV_ERROR_CMD_NOT_PROCESSED; | ||
1412 | } | ||
1413 | } | ||
1414 | return PVRSRV_OK; | ||
1415 | } | ||
1416 | |||
1417 | PVRSRV_ERROR PDumpBitmapKM( PVRSRV_DEVICE_NODE *psDeviceNode, | ||
1418 | IMG_CHAR *pszFileName, | ||
1419 | IMG_UINT32 ui32FileOffset, | ||
1420 | IMG_UINT32 ui32Width, | ||
1421 | IMG_UINT32 ui32Height, | ||
1422 | IMG_UINT32 ui32StrideInBytes, | ||
1423 | IMG_DEV_VIRTADDR sDevBaseAddr, | ||
1424 | IMG_HANDLE hDevMemContext, | ||
1425 | IMG_UINT32 ui32Size, | ||
1426 | PDUMP_PIXEL_FORMAT ePixelFormat, | ||
1427 | PDUMP_MEM_FORMAT eMemFormat, | ||
1428 | IMG_UINT32 ui32PDumpFlags) | ||
1429 | { | ||
1430 | PVRSRV_DEVICE_IDENTIFIER *psDevId = &psDeviceNode->sDevId; | ||
1431 | |||
1432 | PVRSRV_ERROR eErr; | ||
1433 | PDUMP_GET_SCRIPT_STRING(); | ||
1434 | |||
1435 | if ( _PDumpIsPersistent() ) | ||
1436 | { | ||
1437 | return PVRSRV_OK; | ||
1438 | } | ||
1439 | |||
1440 | PDumpCommentWithFlags(ui32PDumpFlags, "\r\n-- Dump bitmap of render\r\n"); | ||
1441 | |||
1442 | |||
1443 | |||
1444 | |||
1445 | PVR_UNREFERENCED_PARAMETER(hDevMemContext); | ||
1446 | |||
1447 | #if defined(SGX_FEATURE_MULTIPLE_MEM_CONTEXTS) | ||
1448 | |||
1449 | eErr = PDumpOSBufprintf(hScript, | ||
1450 | ui32MaxLen, | ||
1451 | "SII %s %s.bin :%s:v%x:0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\r\n", | ||
1452 | pszFileName, | ||
1453 | pszFileName, | ||
1454 | psDevId->pszPDumpDevName, | ||
1455 | PDUMP_DATAMASTER_PIXEL, | ||
1456 | sDevBaseAddr.uiAddr, | ||
1457 | ui32Size, | ||
1458 | ui32FileOffset, | ||
1459 | ePixelFormat, | ||
1460 | ui32Width, | ||
1461 | ui32Height, | ||
1462 | ui32StrideInBytes, | ||
1463 | eMemFormat); | ||
1464 | #else | ||
1465 | eErr = PDumpOSBufprintf(hScript, | ||
1466 | ui32MaxLen, | ||
1467 | "SII %s %s.bin :%s:v:0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\r\n", | ||
1468 | pszFileName, | ||
1469 | pszFileName, | ||
1470 | psDevId->pszPDumpDevName, | ||
1471 | sDevBaseAddr.uiAddr, | ||
1472 | ui32Size, | ||
1473 | ui32FileOffset, | ||
1474 | ePixelFormat, | ||
1475 | ui32Width, | ||
1476 | ui32Height, | ||
1477 | ui32StrideInBytes, | ||
1478 | eMemFormat); | ||
1479 | #endif | ||
1480 | if(eErr != PVRSRV_OK) | ||
1481 | { | ||
1482 | return eErr; | ||
1483 | } | ||
1484 | |||
1485 | PDumpOSWriteString2( hScript, ui32PDumpFlags); | ||
1486 | return PVRSRV_OK; | ||
1487 | } | ||
1488 | |||
1489 | PVRSRV_ERROR PDumpReadRegKM ( IMG_CHAR *pszPDumpRegName, | ||
1490 | IMG_CHAR *pszFileName, | ||
1491 | IMG_UINT32 ui32FileOffset, | ||
1492 | IMG_UINT32 ui32Address, | ||
1493 | IMG_UINT32 ui32Size, | ||
1494 | IMG_UINT32 ui32PDumpFlags) | ||
1495 | { | ||
1496 | PVRSRV_ERROR eErr; | ||
1497 | PDUMP_GET_SCRIPT_STRING(); | ||
1498 | |||
1499 | PVR_UNREFERENCED_PARAMETER(ui32Size); | ||
1500 | |||
1501 | eErr = PDumpOSBufprintf(hScript, | ||
1502 | ui32MaxLen, | ||
1503 | "SAB :%s:0x%08X 0x%08X %s\r\n", | ||
1504 | pszPDumpRegName, | ||
1505 | ui32Address, | ||
1506 | ui32FileOffset, | ||
1507 | pszFileName); | ||
1508 | if(eErr != PVRSRV_OK) | ||
1509 | { | ||
1510 | return eErr; | ||
1511 | } | ||
1512 | |||
1513 | PDumpOSWriteString2( hScript, ui32PDumpFlags); | ||
1514 | |||
1515 | return PVRSRV_OK; | ||
1516 | } | ||
1517 | |||
1518 | IMG_BOOL PDumpTestNextFrame(IMG_UINT32 ui32CurrentFrame) | ||
1519 | { | ||
1520 | IMG_BOOL bFrameDumped; | ||
1521 | |||
1522 | |||
1523 | |||
1524 | (IMG_VOID) PDumpSetFrameKM(ui32CurrentFrame + 1); | ||
1525 | bFrameDumped = PDumpIsCaptureFrameKM(); | ||
1526 | (IMG_VOID) PDumpSetFrameKM(ui32CurrentFrame); | ||
1527 | |||
1528 | return bFrameDumped; | ||
1529 | } | ||
1530 | |||
1531 | static PVRSRV_ERROR PDumpSignatureRegister (PVRSRV_DEVICE_IDENTIFIER *psDevId, | ||
1532 | IMG_CHAR *pszFileName, | ||
1533 | IMG_UINT32 ui32Address, | ||
1534 | IMG_UINT32 ui32Size, | ||
1535 | IMG_UINT32 *pui32FileOffset, | ||
1536 | IMG_UINT32 ui32Flags) | ||
1537 | { | ||
1538 | PVRSRV_ERROR eErr; | ||
1539 | PDUMP_GET_SCRIPT_STRING(); | ||
1540 | |||
1541 | eErr = PDumpOSBufprintf(hScript, | ||
1542 | ui32MaxLen, | ||
1543 | "SAB :%s:0x%08X 0x%08X %s\r\n", | ||
1544 | psDevId->pszPDumpRegName, | ||
1545 | ui32Address, | ||
1546 | *pui32FileOffset, | ||
1547 | pszFileName); | ||
1548 | if(eErr != PVRSRV_OK) | ||
1549 | { | ||
1550 | return eErr; | ||
1551 | } | ||
1552 | |||
1553 | PDumpOSWriteString2(hScript, ui32Flags); | ||
1554 | *pui32FileOffset += ui32Size; | ||
1555 | return PVRSRV_OK; | ||
1556 | } | ||
1557 | |||
1558 | static IMG_VOID PDumpRegisterRange(PVRSRV_DEVICE_IDENTIFIER *psDevId, | ||
1559 | IMG_CHAR *pszFileName, | ||
1560 | IMG_UINT32 *pui32Registers, | ||
1561 | IMG_UINT32 ui32NumRegisters, | ||
1562 | IMG_UINT32 *pui32FileOffset, | ||
1563 | IMG_UINT32 ui32Size, | ||
1564 | IMG_UINT32 ui32Flags) | ||
1565 | { | ||
1566 | IMG_UINT32 i; | ||
1567 | for (i = 0; i < ui32NumRegisters; i++) | ||
1568 | { | ||
1569 | PDumpSignatureRegister(psDevId, pszFileName, pui32Registers[i], ui32Size, pui32FileOffset, ui32Flags); | ||
1570 | } | ||
1571 | } | ||
1572 | |||
1573 | PVRSRV_ERROR PDump3DSignatureRegisters(PVRSRV_DEVICE_IDENTIFIER *psDevId, | ||
1574 | IMG_UINT32 ui32DumpFrameNum, | ||
1575 | IMG_BOOL bLastFrame, | ||
1576 | IMG_UINT32 *pui32Registers, | ||
1577 | IMG_UINT32 ui32NumRegisters) | ||
1578 | { | ||
1579 | PVRSRV_ERROR eErr; | ||
1580 | IMG_UINT32 ui32FileOffset, ui32Flags; | ||
1581 | |||
1582 | PDUMP_GET_FILE_STRING(); | ||
1583 | |||
1584 | ui32Flags = bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0; | ||
1585 | ui32FileOffset = 0; | ||
1586 | |||
1587 | PDumpCommentWithFlags(ui32Flags, "\r\n-- Dump 3D signature registers\r\n"); | ||
1588 | eErr = PDumpOSSprintf(pszFileName, ui32MaxLen, "out%u_3d.sig", ui32DumpFrameNum); | ||
1589 | if(eErr != PVRSRV_OK) | ||
1590 | { | ||
1591 | return eErr; | ||
1592 | } | ||
1593 | |||
1594 | PDumpRegisterRange(psDevId, | ||
1595 | pszFileName, | ||
1596 | pui32Registers, | ||
1597 | ui32NumRegisters, | ||
1598 | &ui32FileOffset, | ||
1599 | sizeof(IMG_UINT32), | ||
1600 | ui32Flags); | ||
1601 | |||
1602 | return PVRSRV_OK; | ||
1603 | } | ||
1604 | |||
1605 | PVRSRV_ERROR PDumpTASignatureRegisters (PVRSRV_DEVICE_IDENTIFIER *psDevId, | ||
1606 | IMG_UINT32 ui32DumpFrameNum, | ||
1607 | IMG_UINT32 ui32TAKickCount, | ||
1608 | IMG_BOOL bLastFrame, | ||
1609 | IMG_UINT32 *pui32Registers, | ||
1610 | IMG_UINT32 ui32NumRegisters) | ||
1611 | { | ||
1612 | PVRSRV_ERROR eErr; | ||
1613 | IMG_UINT32 ui32FileOffset, ui32Flags; | ||
1614 | |||
1615 | PDUMP_GET_FILE_STRING(); | ||
1616 | |||
1617 | ui32Flags = bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0; | ||
1618 | ui32FileOffset = ui32TAKickCount * ui32NumRegisters * sizeof(IMG_UINT32); | ||
1619 | |||
1620 | PDumpCommentWithFlags(ui32Flags, "\r\n-- Dump TA signature registers\r\n"); | ||
1621 | eErr = PDumpOSSprintf(pszFileName, ui32MaxLen, "out%u_ta.sig", ui32DumpFrameNum); | ||
1622 | if(eErr != PVRSRV_OK) | ||
1623 | { | ||
1624 | return eErr; | ||
1625 | } | ||
1626 | |||
1627 | PDumpRegisterRange(psDevId, | ||
1628 | pszFileName, | ||
1629 | pui32Registers, | ||
1630 | ui32NumRegisters, | ||
1631 | &ui32FileOffset, | ||
1632 | sizeof(IMG_UINT32), | ||
1633 | ui32Flags); | ||
1634 | return PVRSRV_OK; | ||
1635 | } | ||
1636 | |||
1637 | PVRSRV_ERROR PDumpCounterRegisters (PVRSRV_DEVICE_IDENTIFIER *psDevId, | ||
1638 | IMG_UINT32 ui32DumpFrameNum, | ||
1639 | IMG_BOOL bLastFrame, | ||
1640 | IMG_UINT32 *pui32Registers, | ||
1641 | IMG_UINT32 ui32NumRegisters) | ||
1642 | { | ||
1643 | PVRSRV_ERROR eErr; | ||
1644 | IMG_UINT32 ui32FileOffset, ui32Flags; | ||
1645 | |||
1646 | PDUMP_GET_FILE_STRING(); | ||
1647 | |||
1648 | ui32Flags = bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0UL; | ||
1649 | ui32FileOffset = 0UL; | ||
1650 | |||
1651 | PDumpCommentWithFlags(ui32Flags, "\r\n-- Dump counter registers\r\n"); | ||
1652 | eErr = PDumpOSSprintf(pszFileName, ui32MaxLen, "out%u.perf", ui32DumpFrameNum); | ||
1653 | if(eErr != PVRSRV_OK) | ||
1654 | { | ||
1655 | return eErr; | ||
1656 | } | ||
1657 | |||
1658 | PDumpRegisterRange(psDevId, | ||
1659 | pszFileName, | ||
1660 | pui32Registers, | ||
1661 | ui32NumRegisters, | ||
1662 | &ui32FileOffset, | ||
1663 | sizeof(IMG_UINT32), | ||
1664 | ui32Flags); | ||
1665 | |||
1666 | return PVRSRV_OK; | ||
1667 | } | ||
1668 | |||
1669 | PVRSRV_ERROR PDumpRegRead(IMG_CHAR *pszPDumpRegName, | ||
1670 | const IMG_UINT32 ui32RegOffset, | ||
1671 | IMG_UINT32 ui32Flags) | ||
1672 | { | ||
1673 | PVRSRV_ERROR eErr; | ||
1674 | PDUMP_GET_SCRIPT_STRING(); | ||
1675 | |||
1676 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "RDW :%s:0x%X\r\n", | ||
1677 | pszPDumpRegName, | ||
1678 | ui32RegOffset); | ||
1679 | if(eErr != PVRSRV_OK) | ||
1680 | { | ||
1681 | return eErr; | ||
1682 | } | ||
1683 | PDumpOSWriteString2(hScript, ui32Flags); | ||
1684 | return PVRSRV_OK; | ||
1685 | } | ||
1686 | |||
1687 | PVRSRV_ERROR PDumpSaveMemKM (PVRSRV_DEVICE_IDENTIFIER *psDevId, | ||
1688 | IMG_CHAR *pszFileName, | ||
1689 | IMG_UINT32 ui32FileOffset, | ||
1690 | IMG_DEV_VIRTADDR sDevBaseAddr, | ||
1691 | IMG_UINT32 ui32Size, | ||
1692 | IMG_UINT32 ui32DataMaster, | ||
1693 | IMG_UINT32 ui32PDumpFlags) | ||
1694 | { | ||
1695 | PVRSRV_ERROR eErr; | ||
1696 | PDUMP_GET_SCRIPT_STRING(); | ||
1697 | |||
1698 | #if !defined(SGX_FEATURE_MULTIPLE_MEM_CONTEXTS) | ||
1699 | PVR_UNREFERENCED_PARAMETER(ui32DataMaster); | ||
1700 | #endif | ||
1701 | |||
1702 | eErr = PDumpOSBufprintf(hScript, | ||
1703 | ui32MaxLen, | ||
1704 | #if defined(SGX_FEATURE_MULTIPLE_MEM_CONTEXTS) | ||
1705 | "SAB :%s:v%x:0x%08X 0x%08X 0x%08X %s.bin\r\n", | ||
1706 | psDevId->pszPDumpDevName, | ||
1707 | ui32DataMaster, | ||
1708 | #else | ||
1709 | "SAB :%s:v:0x%08X 0x%08X 0x%08X %s.bin\r\n", | ||
1710 | psDevId->pszPDumpDevName, | ||
1711 | #endif | ||
1712 | sDevBaseAddr.uiAddr, | ||
1713 | ui32Size, | ||
1714 | ui32FileOffset, | ||
1715 | pszFileName); | ||
1716 | if(eErr != PVRSRV_OK) | ||
1717 | { | ||
1718 | return eErr; | ||
1719 | } | ||
1720 | |||
1721 | PDumpOSWriteString2(hScript, ui32PDumpFlags); | ||
1722 | return PVRSRV_OK; | ||
1723 | } | ||
1724 | |||
1725 | PVRSRV_ERROR PDumpCycleCountRegRead(PVRSRV_DEVICE_IDENTIFIER *psDevId, | ||
1726 | const IMG_UINT32 ui32RegOffset, | ||
1727 | IMG_BOOL bLastFrame) | ||
1728 | { | ||
1729 | PVRSRV_ERROR eErr; | ||
1730 | PDUMP_GET_SCRIPT_STRING(); | ||
1731 | |||
1732 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "RDW :%s:0x%X\r\n", | ||
1733 | psDevId->pszPDumpRegName, | ||
1734 | ui32RegOffset); | ||
1735 | if(eErr != PVRSRV_OK) | ||
1736 | { | ||
1737 | return eErr; | ||
1738 | } | ||
1739 | PDumpOSWriteString2(hScript, bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0); | ||
1740 | return PVRSRV_OK; | ||
1741 | } | ||
1742 | |||
1743 | |||
1744 | PVRSRV_ERROR PDumpSignatureBuffer (PVRSRV_DEVICE_IDENTIFIER *psDevId, | ||
1745 | IMG_CHAR *pszFileName, | ||
1746 | IMG_CHAR *pszBufferType, | ||
1747 | IMG_UINT32 ui32FileOffset, | ||
1748 | IMG_DEV_VIRTADDR sDevBaseAddr, | ||
1749 | IMG_UINT32 ui32Size, | ||
1750 | IMG_UINT32 ui32PDumpFlags) | ||
1751 | { | ||
1752 | PDumpCommentWithFlags(ui32PDumpFlags, "\r\n-- Dump microkernel %s signature Buffer\r\n", | ||
1753 | pszBufferType); | ||
1754 | PDumpCommentWithFlags(ui32PDumpFlags, "Buffer format (sizes in 32-bit words):\r\n"); | ||
1755 | PDumpCommentWithFlags(ui32PDumpFlags, "\tNumber of signatures per sample (1)\r\n"); | ||
1756 | PDumpCommentWithFlags(ui32PDumpFlags, "\tNumber of samples (1)\r\n"); | ||
1757 | PDumpCommentWithFlags(ui32PDumpFlags, "\tSignature register offsets (1 * number of signatures)\r\n"); | ||
1758 | PDumpCommentWithFlags(ui32PDumpFlags, "\tSignature sample values (number of samples * number of signatures)\r\n"); | ||
1759 | PDumpCommentWithFlags(ui32PDumpFlags, "Note: If buffer is full, last sample is final state after test completed\r\n"); | ||
1760 | return PDumpSaveMemKM(psDevId, pszFileName, ui32FileOffset, sDevBaseAddr, ui32Size, | ||
1761 | PDUMP_DATAMASTER_EDM, ui32PDumpFlags); | ||
1762 | } | ||
1763 | |||
1764 | |||
1765 | PVRSRV_ERROR PDumpHWPerfCBKM (PVRSRV_DEVICE_IDENTIFIER *psDevId, | ||
1766 | IMG_CHAR *pszFileName, | ||
1767 | IMG_UINT32 ui32FileOffset, | ||
1768 | IMG_DEV_VIRTADDR sDevBaseAddr, | ||
1769 | IMG_UINT32 ui32Size, | ||
1770 | IMG_UINT32 ui32PDumpFlags) | ||
1771 | { | ||
1772 | PDumpCommentWithFlags(ui32PDumpFlags, "\r\n-- Dump Hardware Performance Circular Buffer\r\n"); | ||
1773 | return PDumpSaveMemKM(psDevId, pszFileName, ui32FileOffset, sDevBaseAddr, ui32Size, | ||
1774 | PDUMP_DATAMASTER_EDM, ui32PDumpFlags); | ||
1775 | } | ||
1776 | |||
1777 | |||
1778 | PVRSRV_ERROR PDumpCBP(PPVRSRV_KERNEL_MEM_INFO psROffMemInfo, | ||
1779 | IMG_UINT32 ui32ROffOffset, | ||
1780 | IMG_UINT32 ui32WPosVal, | ||
1781 | IMG_UINT32 ui32PacketSize, | ||
1782 | IMG_UINT32 ui32BufferSize, | ||
1783 | IMG_UINT32 ui32Flags, | ||
1784 | IMG_HANDLE hUniqueTag) | ||
1785 | { | ||
1786 | PVRSRV_ERROR eErr; | ||
1787 | IMG_UINT32 ui32PageOffset; | ||
1788 | IMG_UINT8 *pui8LinAddr; | ||
1789 | IMG_DEV_VIRTADDR sDevVAddr; | ||
1790 | IMG_DEV_PHYADDR sDevPAddr; | ||
1791 | IMG_DEV_VIRTADDR sDevVPageAddr; | ||
1792 | |||
1793 | PDUMP_MMU_ATTRIB *psMMUAttrib; | ||
1794 | |||
1795 | PDUMP_GET_SCRIPT_STRING(); | ||
1796 | |||
1797 | psMMUAttrib = ((BM_BUF*)psROffMemInfo->sMemBlk.hBuffer)->pMapping->pBMHeap->psMMUAttrib; | ||
1798 | |||
1799 | |||
1800 | PVR_ASSERT((ui32ROffOffset + sizeof(IMG_UINT32)) <= psROffMemInfo->ui32AllocSize); | ||
1801 | |||
1802 | pui8LinAddr = psROffMemInfo->pvLinAddrKM; | ||
1803 | sDevVAddr = psROffMemInfo->sDevVAddr; | ||
1804 | |||
1805 | |||
1806 | pui8LinAddr += ui32ROffOffset; | ||
1807 | sDevVAddr.uiAddr += ui32ROffOffset; | ||
1808 | |||
1809 | |||
1810 | |||
1811 | |||
1812 | PDumpOSCPUVAddrToPhysPages(psROffMemInfo->sMemBlk.hOSMemHandle, | ||
1813 | ui32ROffOffset, | ||
1814 | pui8LinAddr, | ||
1815 | psMMUAttrib->ui32DataPageMask, | ||
1816 | &ui32PageOffset); | ||
1817 | |||
1818 | |||
1819 | sDevVPageAddr.uiAddr = sDevVAddr.uiAddr - ui32PageOffset; | ||
1820 | |||
1821 | PVR_ASSERT((sDevVPageAddr.uiAddr & 0xFFF) == 0); | ||
1822 | |||
1823 | |||
1824 | BM_GetPhysPageAddr(psROffMemInfo, sDevVPageAddr, &sDevPAddr); | ||
1825 | |||
1826 | |||
1827 | sDevPAddr.uiAddr += ui32PageOffset; | ||
1828 | |||
1829 | eErr = PDumpOSBufprintf(hScript, | ||
1830 | ui32MaxLen, | ||
1831 | "CBP :%s:PA_%08X%08X:0x%08X 0x%08X 0x%08X 0x%08X\r\n", | ||
1832 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
1833 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, | ||
1834 | sDevPAddr.uiAddr & ~(psMMUAttrib->ui32DataPageMask), | ||
1835 | sDevPAddr.uiAddr & (psMMUAttrib->ui32DataPageMask), | ||
1836 | ui32WPosVal, | ||
1837 | ui32PacketSize, | ||
1838 | ui32BufferSize); | ||
1839 | if(eErr != PVRSRV_OK) | ||
1840 | { | ||
1841 | return eErr; | ||
1842 | } | ||
1843 | PDumpOSWriteString2(hScript, ui32Flags); | ||
1844 | return PVRSRV_OK; | ||
1845 | } | ||
1846 | |||
1847 | |||
1848 | PVRSRV_ERROR PDumpIDLWithFlags(IMG_UINT32 ui32Clocks, IMG_UINT32 ui32Flags) | ||
1849 | { | ||
1850 | PVRSRV_ERROR eErr; | ||
1851 | PDUMP_GET_SCRIPT_STRING(); | ||
1852 | PDUMP_DBG(("PDumpIDLWithFlags")); | ||
1853 | |||
1854 | eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "IDL %u\r\n", ui32Clocks); | ||
1855 | if(eErr != PVRSRV_OK) | ||
1856 | { | ||
1857 | return eErr; | ||
1858 | } | ||
1859 | PDumpOSWriteString2(hScript, ui32Flags); | ||
1860 | return PVRSRV_OK; | ||
1861 | } | ||
1862 | |||
1863 | |||
1864 | PVRSRV_ERROR PDumpIDL(IMG_UINT32 ui32Clocks) | ||
1865 | { | ||
1866 | return PDumpIDLWithFlags(ui32Clocks, PDUMP_FLAGS_CONTINUOUS); | ||
1867 | } | ||
1868 | |||
1869 | PVRSRV_ERROR PDumpMemUM(PVRSRV_PER_PROCESS_DATA *psPerProc, | ||
1870 | IMG_PVOID pvAltLinAddrUM, | ||
1871 | IMG_PVOID pvLinAddrUM, | ||
1872 | PVRSRV_KERNEL_MEM_INFO *psMemInfo, | ||
1873 | IMG_UINT32 ui32Offset, | ||
1874 | IMG_UINT32 ui32Bytes, | ||
1875 | IMG_UINT32 ui32Flags, | ||
1876 | IMG_HANDLE hUniqueTag) | ||
1877 | { | ||
1878 | IMG_VOID *pvAddrUM; | ||
1879 | IMG_VOID *pvAddrKM; | ||
1880 | IMG_UINT32 ui32BytesDumped; | ||
1881 | IMG_UINT32 ui32CurrentOffset; | ||
1882 | |||
1883 | if (psMemInfo->pvLinAddrKM != IMG_NULL && pvAltLinAddrUM == IMG_NULL) | ||
1884 | { | ||
1885 | |||
1886 | return PDumpMemKM(IMG_NULL, | ||
1887 | psMemInfo, | ||
1888 | ui32Offset, | ||
1889 | ui32Bytes, | ||
1890 | ui32Flags, | ||
1891 | hUniqueTag); | ||
1892 | } | ||
1893 | |||
1894 | pvAddrUM = (pvAltLinAddrUM != IMG_NULL) ? pvAltLinAddrUM : ((pvLinAddrUM != IMG_NULL) ? VPTR_PLUS(pvLinAddrUM, ui32Offset) : IMG_NULL); | ||
1895 | |||
1896 | pvAddrKM = GetTempBuffer(); | ||
1897 | |||
1898 | |||
1899 | PVR_ASSERT(pvAddrUM != IMG_NULL && pvAddrKM != IMG_NULL); | ||
1900 | if (pvAddrUM == IMG_NULL || pvAddrKM == IMG_NULL) | ||
1901 | { | ||
1902 | PVR_DPF((PVR_DBG_ERROR, "PDumpMemUM: Nothing to dump")); | ||
1903 | return PVRSRV_ERROR_INVALID_PARAMS; | ||
1904 | } | ||
1905 | |||
1906 | if (ui32Bytes > PDUMP_TEMP_BUFFER_SIZE) | ||
1907 | { | ||
1908 | PDumpCommentWithFlags(ui32Flags, "Dumping 0x%08x bytes of memory, in blocks of 0x%08x bytes", ui32Bytes, (IMG_UINT32)PDUMP_TEMP_BUFFER_SIZE); | ||
1909 | } | ||
1910 | |||
1911 | ui32CurrentOffset = ui32Offset; | ||
1912 | for (ui32BytesDumped = 0; ui32BytesDumped < ui32Bytes;) | ||
1913 | { | ||
1914 | PVRSRV_ERROR eError; | ||
1915 | IMG_UINT32 ui32BytesToDump = MIN(PDUMP_TEMP_BUFFER_SIZE, ui32Bytes - ui32BytesDumped); | ||
1916 | |||
1917 | eError = OSCopyFromUser(psPerProc, | ||
1918 | pvAddrKM, | ||
1919 | pvAddrUM, | ||
1920 | ui32BytesToDump); | ||
1921 | if (eError != PVRSRV_OK) | ||
1922 | { | ||
1923 | PVR_DPF((PVR_DBG_ERROR, "PDumpMemUM: OSCopyFromUser failed (%d)", eError)); | ||
1924 | return eError; | ||
1925 | } | ||
1926 | |||
1927 | eError = PDumpMemKM(pvAddrKM, | ||
1928 | psMemInfo, | ||
1929 | ui32CurrentOffset, | ||
1930 | ui32BytesToDump, | ||
1931 | ui32Flags, | ||
1932 | hUniqueTag); | ||
1933 | |||
1934 | if (eError != PVRSRV_OK) | ||
1935 | { | ||
1936 | |||
1937 | if (ui32BytesDumped != 0) | ||
1938 | { | ||
1939 | PVR_DPF((PVR_DBG_ERROR, "PDumpMemUM: PDumpMemKM failed (%d)", eError)); | ||
1940 | } | ||
1941 | PVR_ASSERT(ui32BytesDumped == 0); | ||
1942 | return eError; | ||
1943 | } | ||
1944 | |||
1945 | VPTR_INC(pvAddrUM, ui32BytesToDump); | ||
1946 | ui32CurrentOffset += ui32BytesToDump; | ||
1947 | ui32BytesDumped += ui32BytesToDump; | ||
1948 | } | ||
1949 | |||
1950 | return PVRSRV_OK; | ||
1951 | } | ||
1952 | |||
1953 | |||
1954 | static PVRSRV_ERROR _PdumpAllocMMUContext(IMG_UINT32 *pui32MMUContextID) | ||
1955 | { | ||
1956 | IMG_UINT32 i; | ||
1957 | |||
1958 | |||
1959 | for(i=0; i<MAX_PDUMP_MMU_CONTEXTS; i++) | ||
1960 | { | ||
1961 | if((gui16MMUContextUsage & (1U << i)) == 0) | ||
1962 | { | ||
1963 | |||
1964 | gui16MMUContextUsage |= 1U << i; | ||
1965 | *pui32MMUContextID = i; | ||
1966 | return PVRSRV_OK; | ||
1967 | } | ||
1968 | } | ||
1969 | |||
1970 | PVR_DPF((PVR_DBG_ERROR, "_PdumpAllocMMUContext: no free MMU context ids")); | ||
1971 | |||
1972 | return PVRSRV_ERROR_MMU_CONTEXT_NOT_FOUND; | ||
1973 | } | ||
1974 | |||
1975 | |||
1976 | static PVRSRV_ERROR _PdumpFreeMMUContext(IMG_UINT32 ui32MMUContextID) | ||
1977 | { | ||
1978 | if(ui32MMUContextID < MAX_PDUMP_MMU_CONTEXTS) | ||
1979 | { | ||
1980 | |||
1981 | gui16MMUContextUsage &= ~(1U << ui32MMUContextID); | ||
1982 | return PVRSRV_OK; | ||
1983 | } | ||
1984 | |||
1985 | PVR_DPF((PVR_DBG_ERROR, "_PdumpFreeMMUContext: MMU context ids invalid")); | ||
1986 | |||
1987 | return PVRSRV_ERROR_MMU_CONTEXT_NOT_FOUND; | ||
1988 | } | ||
1989 | |||
1990 | |||
1991 | PVRSRV_ERROR PDumpSetMMUContext(PVRSRV_DEVICE_TYPE eDeviceType, | ||
1992 | IMG_CHAR *pszMemSpace, | ||
1993 | IMG_UINT32 *pui32MMUContextID, | ||
1994 | IMG_UINT32 ui32MMUType, | ||
1995 | IMG_HANDLE hUniqueTag1, | ||
1996 | IMG_HANDLE hOSMemHandle, | ||
1997 | IMG_VOID *pvPDCPUAddr) | ||
1998 | { | ||
1999 | IMG_UINT8 *pui8LinAddr = (IMG_UINT8 *)pvPDCPUAddr; | ||
2000 | IMG_CPU_PHYADDR sCpuPAddr; | ||
2001 | IMG_DEV_PHYADDR sDevPAddr; | ||
2002 | IMG_UINT32 ui32MMUContextID; | ||
2003 | PVRSRV_ERROR eError; | ||
2004 | |||
2005 | eError = _PdumpAllocMMUContext(&ui32MMUContextID); | ||
2006 | if(eError != PVRSRV_OK) | ||
2007 | { | ||
2008 | PVR_DPF((PVR_DBG_ERROR, "PDumpSetMMUContext: _PdumpAllocMMUContext failed: %d", eError)); | ||
2009 | return eError; | ||
2010 | } | ||
2011 | |||
2012 | |||
2013 | |||
2014 | sCpuPAddr = OSMapLinToCPUPhys(hOSMemHandle, pui8LinAddr); | ||
2015 | sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); | ||
2016 | |||
2017 | sDevPAddr.uiAddr &= ~((PVRSRV_4K_PAGE_SIZE) -1); | ||
2018 | |||
2019 | PDumpComment("Set MMU Context\r\n"); | ||
2020 | |||
2021 | PDumpComment("MMU :%s:v%d %d :%s:PA_%08X%08X\r\n", | ||
2022 | pszMemSpace, | ||
2023 | ui32MMUContextID, | ||
2024 | ui32MMUType, | ||
2025 | pszMemSpace, | ||
2026 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, | ||
2027 | sDevPAddr.uiAddr); | ||
2028 | |||
2029 | |||
2030 | *pui32MMUContextID = ui32MMUContextID; | ||
2031 | |||
2032 | return PVRSRV_OK; | ||
2033 | } | ||
2034 | |||
2035 | |||
2036 | PVRSRV_ERROR PDumpClearMMUContext(PVRSRV_DEVICE_TYPE eDeviceType, | ||
2037 | IMG_CHAR *pszMemSpace, | ||
2038 | IMG_UINT32 ui32MMUContextID, | ||
2039 | IMG_UINT32 ui32MMUType) | ||
2040 | { | ||
2041 | PVRSRV_ERROR eError; | ||
2042 | |||
2043 | PVR_UNREFERENCED_PARAMETER(eDeviceType); | ||
2044 | |||
2045 | |||
2046 | PDumpComment("Clear MMU Context for memory space %s\r\n", pszMemSpace); | ||
2047 | |||
2048 | PDumpComment("MMU :%s:v%d %d\r\n", | ||
2049 | pszMemSpace, | ||
2050 | ui32MMUContextID, | ||
2051 | ui32MMUType); | ||
2052 | |||
2053 | eError = _PdumpFreeMMUContext(ui32MMUContextID); | ||
2054 | if(eError != PVRSRV_OK) | ||
2055 | { | ||
2056 | PVR_DPF((PVR_DBG_ERROR, "PDumpClearMMUContext: _PdumpFreeMMUContext failed: %d", eError)); | ||
2057 | return eError; | ||
2058 | } | ||
2059 | |||
2060 | return PVRSRV_OK; | ||
2061 | } | ||
2062 | |||
2063 | PVRSRV_ERROR PDumpStoreMemToFile(PDUMP_MMU_ATTRIB *psMMUAttrib, | ||
2064 | IMG_CHAR *pszFileName, | ||
2065 | IMG_UINT32 ui32FileOffset, | ||
2066 | PVRSRV_KERNEL_MEM_INFO *psMemInfo, | ||
2067 | IMG_UINT32 uiAddr, | ||
2068 | IMG_UINT32 ui32Size, | ||
2069 | IMG_UINT32 ui32PDumpFlags, | ||
2070 | IMG_HANDLE hUniqueTag) | ||
2071 | { | ||
2072 | IMG_DEV_PHYADDR sDevPAddr; | ||
2073 | IMG_DEV_VIRTADDR sDevVPageAddr; | ||
2074 | IMG_UINT32 ui32PageOffset; | ||
2075 | |||
2076 | PDUMP_GET_SCRIPT_STRING(); | ||
2077 | |||
2078 | |||
2079 | |||
2080 | |||
2081 | ui32PageOffset = (IMG_UINT32)psMemInfo->pvLinAddrKM & psMMUAttrib->ui32DataPageMask; | ||
2082 | |||
2083 | |||
2084 | sDevVPageAddr.uiAddr = uiAddr - ui32PageOffset; | ||
2085 | |||
2086 | |||
2087 | BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); | ||
2088 | |||
2089 | |||
2090 | sDevPAddr.uiAddr += ui32PageOffset; | ||
2091 | |||
2092 | PDumpOSBufprintf(hScript, | ||
2093 | ui32MaxLen, | ||
2094 | "SAB :%s:PA_%08X%08X:0x%08X 0x%08X 0x%08X %s\r\n", | ||
2095 | psMMUAttrib->sDevId.pszPDumpDevName, | ||
2096 | (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, | ||
2097 | sDevPAddr.uiAddr & ~psMMUAttrib->ui32DataPageMask, | ||
2098 | sDevPAddr.uiAddr & psMMUAttrib->ui32DataPageMask, | ||
2099 | ui32Size, | ||
2100 | ui32FileOffset, | ||
2101 | pszFileName); | ||
2102 | |||
2103 | PDumpOSWriteString2(hScript, ui32PDumpFlags); | ||
2104 | |||
2105 | return PVRSRV_OK; | ||
2106 | } | ||
2107 | |||
2108 | PVRSRV_ERROR PDumpRegBasedCBP(IMG_CHAR *pszPDumpRegName, | ||
2109 | IMG_UINT32 ui32RegOffset, | ||
2110 | IMG_UINT32 ui32WPosVal, | ||
2111 | IMG_UINT32 ui32PacketSize, | ||
2112 | IMG_UINT32 ui32BufferSize, | ||
2113 | IMG_UINT32 ui32Flags) | ||
2114 | { | ||
2115 | PDUMP_GET_SCRIPT_STRING(); | ||
2116 | |||
2117 | PDumpOSBufprintf(hScript, | ||
2118 | ui32MaxLen, | ||
2119 | "CBP :%s:0x%08X 0x%08X 0x%08X 0x%08X\r\n", | ||
2120 | pszPDumpRegName, | ||
2121 | ui32RegOffset, | ||
2122 | ui32WPosVal, | ||
2123 | ui32PacketSize, | ||
2124 | ui32BufferSize); | ||
2125 | PDumpOSWriteString2(hScript, ui32Flags); | ||
2126 | |||
2127 | return PVRSRV_OK; | ||
2128 | } | ||
2129 | |||
2130 | |||
2131 | #include "syscommon.h" | ||
2132 | |||
2133 | IMG_EXPORT IMG_VOID PDumpConnectionNotify(IMG_VOID) | ||
2134 | { | ||
2135 | SYS_DATA *psSysData; | ||
2136 | PVRSRV_DEVICE_NODE *psThis; | ||
2137 | PVR_DPF((PVR_DBG_WARNING, "PDump has connected.")); | ||
2138 | |||
2139 | |||
2140 | SysAcquireData(&psSysData); | ||
2141 | |||
2142 | psThis = psSysData->psDeviceNodeList; | ||
2143 | while (psThis) | ||
2144 | { | ||
2145 | if (psThis->pfnPDumpInitDevice) | ||
2146 | { | ||
2147 | |||
2148 | psThis->pfnPDumpInitDevice(psThis); | ||
2149 | } | ||
2150 | psThis = psThis->psNext; | ||
2151 | } | ||
2152 | } | ||
2153 | |||
2154 | IMG_UINT32 DbgWrite(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32BCount, IMG_UINT32 ui32Flags) | ||
2155 | { | ||
2156 | IMG_UINT32 ui32BytesWritten = 0; | ||
2157 | IMG_UINT32 ui32Off = 0; | ||
2158 | |||
2159 | |||
2160 | if ((ui32Flags & PDUMP_FLAGS_NEVER) != 0) | ||
2161 | { | ||
2162 | return ui32BCount; | ||
2163 | } | ||
2164 | |||
2165 | while (((IMG_UINT32) ui32BCount > 0) && (ui32BytesWritten != 0xFFFFFFFFU)) | ||
2166 | { | ||
2167 | if ((ui32Flags & PDUMP_FLAGS_PERSISTENT) != 0) | ||
2168 | { | ||
2169 | |||
2170 | |||
2171 | |||
2172 | if (psStream->bInitPhaseComplete) | ||
2173 | { | ||
2174 | |||
2175 | ui32BytesWritten = PDumpOSDebugDriverWrite( psStream, | ||
2176 | PDUMP_WRITE_MODE_PERSISTENT, | ||
2177 | &pui8Data[ui32Off], ui32BCount, 1, 0); | ||
2178 | } | ||
2179 | } | ||
2180 | |||
2181 | if ((ui32Flags & PDUMP_FLAGS_CONTINUOUS) != 0) | ||
2182 | { | ||
2183 | |||
2184 | |||
2185 | if (((psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) != 0) && | ||
2186 | (psStream->ui32Start == 0xFFFFFFFFU) && | ||
2187 | (psStream->ui32End == 0xFFFFFFFFU) && | ||
2188 | psStream->bInitPhaseComplete) | ||
2189 | { | ||
2190 | ui32BytesWritten = ui32BCount; | ||
2191 | } | ||
2192 | else | ||
2193 | { | ||
2194 | ui32BytesWritten = PDumpOSDebugDriverWrite( psStream, | ||
2195 | PDUMP_WRITE_MODE_CONTINUOUS, | ||
2196 | &pui8Data[ui32Off], ui32BCount, 1, 0); | ||
2197 | } | ||
2198 | } | ||
2199 | else | ||
2200 | { | ||
2201 | if (ui32Flags & PDUMP_FLAGS_LASTFRAME) | ||
2202 | { | ||
2203 | IMG_UINT32 ui32DbgFlags; | ||
2204 | |||
2205 | ui32DbgFlags = 0; | ||
2206 | if (ui32Flags & PDUMP_FLAGS_RESETLFBUFFER) | ||
2207 | { | ||
2208 | ui32DbgFlags |= WRITELF_FLAGS_RESETBUF; | ||
2209 | } | ||
2210 | |||
2211 | ui32BytesWritten = PDumpOSDebugDriverWrite( psStream, | ||
2212 | PDUMP_WRITE_MODE_LASTFRAME, | ||
2213 | &pui8Data[ui32Off], ui32BCount, 1, ui32DbgFlags); | ||
2214 | } | ||
2215 | else | ||
2216 | { | ||
2217 | ui32BytesWritten = PDumpOSDebugDriverWrite( psStream, | ||
2218 | PDUMP_WRITE_MODE_BINCM, | ||
2219 | &pui8Data[ui32Off], ui32BCount, 1, 0); | ||
2220 | } | ||
2221 | } | ||
2222 | |||
2223 | |||
2224 | |||
2225 | |||
2226 | if (ui32BytesWritten == 0) | ||
2227 | { | ||
2228 | PDumpOSReleaseExecution(); | ||
2229 | } | ||
2230 | |||
2231 | if (ui32BytesWritten != 0xFFFFFFFF) | ||
2232 | { | ||
2233 | ui32Off += ui32BytesWritten; | ||
2234 | ui32BCount -= ui32BytesWritten; | ||
2235 | } | ||
2236 | |||
2237 | |||
2238 | } | ||
2239 | |||
2240 | |||
2241 | |||
2242 | return ui32BytesWritten; | ||
2243 | } | ||
2244 | |||
2245 | |||
2246 | |||
2247 | #else | ||
2248 | #endif | ||