RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / pdump_mmu.c
1 /*************************************************************************/ /*!
2 @File
3 @Title          MMU PDump functions
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Common PDump (MMU specific) functions
6 @License        Dual MIT/GPLv2
7
8 The contents of this file are subject to the MIT license as set out below.
9
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
23
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
31
32 This License is also included in this distribution in the file called
33 "MIT-COPYING".
34
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /***************************************************************************/
43
44 #if defined (PDUMP)
45
46 #include "img_types.h"
47 #include "pdump_mmu.h"
48 #include "pdump_osfunc.h"
49 #include "pdump_km.h"
50 #include "pdump_physmem.h"
51 #include "osfunc.h"
52 #include "pvr_debug.h"
53 #include "pvrsrv_error.h"
54
55 #define MAX_PDUMP_MMU_CONTEXTS  (10)
56 static IMG_UINT32 guiPDumpMMUContextAvailabilityMask = (1<<MAX_PDUMP_MMU_CONTEXTS)-1;
57
58
59 #define MMUPX_FMT(X) ((X<3) ? ((X<2) ?  "MMUPT_\0" : "MMUPD_\0") : "MMUPC_\0")
60 #define MIPSMMUPX_FMT(X) ((X<3) ? ((X<2) ?  "MIPSMMUPT_\0" : "MIPSMMUPD_\0") : "MIPSMMUPC_\0")
61
62
63 /* Array used to look-up debug strings from MMU_LEVEL */
64 static IMG_CHAR ai8MMULevelStringLookup[MMU_LEVEL_LAST][15] =
65                 {
66                                 "MMU_LEVEL_0",
67                                 "PAGE_TABLE",
68                                 "PAGE_DIRECTORY",
69                                 "PAGE_CATALOGUE",
70                 };
71
72 static PVRSRV_ERROR 
73 _ContiguousPDumpBytes(const IMG_CHAR *pszSymbolicName,
74                       IMG_UINT32 ui32SymAddrOffset,
75                       IMG_BOOL bFlush,
76                       IMG_UINT32 uiNumBytes,
77                       void *pvBytes,
78                       IMG_UINT32 ui32Flags)
79 {
80     static const IMG_CHAR *pvBeyondLastPointer;
81     static const IMG_CHAR *pvBasePointer;
82     static IMG_UINT32 ui32BeyondLastOffset;
83     static IMG_UINT32 ui32BaseOffset;
84     static IMG_UINT32 uiAccumulatedBytes = 0;
85         IMG_UINT32 ui32ParamOutPos;
86     PVRSRV_ERROR eErr = PVRSRV_OK;
87
88         PDUMP_GET_SCRIPT_AND_FILE_STRING();
89         PVR_UNREFERENCED_PARAMETER(ui32MaxLenFileName);
90
91     /* Caller has PDUMP_LOCK */
92
93     if (!bFlush && uiAccumulatedBytes > 0)
94     {
95         /* do some tests for contiguity.  If it fails, we flush anyway */
96
97         if (pvBeyondLastPointer != pvBytes ||
98             ui32SymAddrOffset != ui32BeyondLastOffset
99             /* NB: ought to check that symbolic name agrees too, but
100                we know this always to be the case in the current use-case */
101             )
102         {
103             bFlush = IMG_TRUE;
104         }
105     }
106
107     /* Flush if necessary */
108     if (bFlush && uiAccumulatedBytes > 0)
109     {        
110         eErr = PDumpWriteParameter((IMG_UINT8 *)(uintptr_t)pvBasePointer,
111                                uiAccumulatedBytes, ui32Flags,
112                                &ui32ParamOutPos, pszFileName);
113         if (eErr == PVRSRV_OK)
114         {
115                         eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript,
116                                                                         "LDB %s:0x%X 0x%X 0x%X %s",
117                                                                         /* dest */
118                                                                         pszSymbolicName,
119                                                                         ui32BaseOffset,
120                                                                         /* size */
121                                                                         uiAccumulatedBytes,
122                                                                         /* file offset */
123                                                                         ui32ParamOutPos,
124                                                                         /* filename */
125                                                                         pszFileName);
126                         PVR_LOGG_IF_ERROR(eErr, "PDumpOSBufprintf", ErrOut);
127
128                         PDumpWriteScript(hScript, ui32Flags);
129
130         }
131         else if (eErr != PVRSRV_ERROR_PDUMP_NOT_ALLOWED)
132         {
133                 PVR_LOGG_IF_ERROR(eErr, "PDumpWriteParameter", ErrOut);
134         }
135         else
136                 {
137                         /* else Write to parameter file prevented under the flags and
138                          * current state of the driver so skip write to script and error IF.
139                          */
140                         eErr = PVRSRV_OK;
141                 }
142
143                 uiAccumulatedBytes = 0;
144     }
145
146
147     /* Initialise offsets and pointers if necessary */
148     if (uiAccumulatedBytes == 0)
149     {
150         ui32BaseOffset = ui32BeyondLastOffset = ui32SymAddrOffset;
151         pvBeyondLastPointer = pvBasePointer = (const IMG_CHAR *)pvBytes;
152     }
153
154     /* Accumulate some bytes */
155     ui32BeyondLastOffset += uiNumBytes;
156     pvBeyondLastPointer += uiNumBytes;
157     uiAccumulatedBytes += uiNumBytes;
158
159 ErrOut:
160     return eErr;
161 }
162
163
164 /**************************************************************************
165  * Function Name  : PDumpMMUMalloc
166  * Inputs         : 
167  * Outputs        : 
168  * Returns        : PVRSRV_ERROR
169  * Description    : 
170 **************************************************************************/
171 PVRSRV_ERROR PDumpMMUMalloc(const IMG_CHAR                      *pszPDumpDevName,
172                                                         MMU_LEVEL                               eMMULevel,
173                                                         IMG_DEV_PHYADDR                 *psDevPAddr,
174                                                         IMG_UINT32                              ui32Size,
175                                                         IMG_UINT32                              ui32Align,
176                                                         PDUMP_MMU_TYPE          eMMUType)
177 {
178         PVRSRV_ERROR eErr = PVRSRV_OK;
179         IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS;
180         IMG_UINT64 ui64SymbolicAddr;
181         IMG_CHAR *pszMMUPX;
182
183         PDUMP_GET_SCRIPT_STRING();
184
185         if (eMMULevel >= MMU_LEVEL_LAST)
186         {
187                 eErr = PVRSRV_ERROR_INVALID_PARAMS;
188                 goto ErrOut;
189         }
190
191         PDUMP_LOCK();
192
193         /*
194                 Write a comment to the PDump2 script streams indicating the memory allocation
195         */
196         eErr = PDumpOSBufprintf(hScript,
197                                                         ui32MaxLen,
198                                                         "-- MALLOC :%s:%s Size=0x%08X Alignment=0x%08X DevPAddr=0x%08llX",
199                                                         pszPDumpDevName,
200                                                         ai8MMULevelStringLookup[eMMULevel],
201                                                         ui32Size,
202                                                         ui32Align,
203                                                         psDevPAddr->uiAddr);
204         if(eErr != PVRSRV_OK)
205         {
206                 goto ErrUnlock;
207         }
208
209         PDumpWriteScript(hScript, ui32Flags);
210
211         /*
212                 construct the symbolic address
213         */
214         ui64SymbolicAddr = (IMG_UINT64)psDevPAddr->uiAddr;
215
216         /*
217                 Write to the MMU script stream indicating the memory allocation
218         */
219         if (eMMUType == PDUMP_MMU_TYPE_MIPS_MICROAPTIV)
220         {
221                 pszMMUPX = MIPSMMUPX_FMT(eMMULevel);
222         }
223         else
224         {
225                 pszMMUPX = MMUPX_FMT(eMMULevel);
226         }
227         eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "MALLOC :%s:%s%016llX 0x%X 0x%X",
228                                                                                         pszPDumpDevName,
229                                                                                         pszMMUPX,
230                                                                                         ui64SymbolicAddr,
231                                                                                         ui32Size,
232                                                                                         ui32Align
233                                                                                         /* don't need this sDevPAddr.uiAddr*/);
234         if(eErr != PVRSRV_OK)
235         {
236                 goto ErrUnlock;
237         }
238         PDumpWriteScript(hScript, ui32Flags);
239
240 ErrUnlock:
241         PDUMP_UNLOCK();
242 ErrOut:
243         return eErr;
244 }
245
246
247 /**************************************************************************
248  * Function Name  : PDumpMMUFree
249  * Inputs         :
250  * Outputs        : 
251  * Returns        : PVRSRV_ERROR
252  * Description    : 
253 **************************************************************************/
254 PVRSRV_ERROR PDumpMMUFree(const IMG_CHAR                                *pszPDumpDevName,
255                                                         MMU_LEVEL                                       eMMULevel,
256                                                         IMG_DEV_PHYADDR                         *psDevPAddr,
257                                                         PDUMP_MMU_TYPE              eMMUType)
258 {
259         PVRSRV_ERROR eErr = PVRSRV_OK;
260         IMG_UINT64 ui64SymbolicAddr;
261         IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS;
262         IMG_CHAR *pszMMUPX;
263
264         PDUMP_GET_SCRIPT_STRING();
265
266         if (eMMULevel >= MMU_LEVEL_LAST)
267         {
268                 eErr = PVRSRV_ERROR_INVALID_PARAMS;
269                 goto ErrOut;
270         }
271
272         PDUMP_LOCK();
273         /*
274                 Write a comment to the PDUMP2 script streams indicating the memory free
275         */
276         eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "-- FREE :%s:%s", 
277                                                         pszPDumpDevName, ai8MMULevelStringLookup[eMMULevel]);
278         if(eErr != PVRSRV_OK)
279         {
280                 goto ErrUnlock;
281         }
282
283         PDumpWriteScript(hScript, ui32Flags);
284
285         /*
286                 construct the symbolic address
287         */
288         ui64SymbolicAddr = (IMG_UINT64)psDevPAddr->uiAddr;
289
290         /*
291                 Write to the MMU script stream indicating the memory free
292         */
293         if (eMMUType == PDUMP_MMU_TYPE_MIPS_MICROAPTIV)
294         {
295                 pszMMUPX = MIPSMMUPX_FMT(eMMULevel);
296         }
297         else
298         {
299                 pszMMUPX = MMUPX_FMT(eMMULevel);
300         }
301         eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "FREE :%s:%s%016llX",
302                                                         pszPDumpDevName,
303                                                         pszMMUPX,
304                                                         ui64SymbolicAddr);
305         if(eErr != PVRSRV_OK)
306         {
307                 goto ErrUnlock;
308         }
309         PDumpWriteScript(hScript, ui32Flags);
310
311 ErrUnlock:
312         PDUMP_UNLOCK();
313 ErrOut:
314         return eErr;
315 }
316
317
318 /**************************************************************************
319  * Function Name  : PDumpMMUMalloc2
320  * Inputs         :
321  * Outputs        : 
322  * Returns        : PVRSRV_ERROR
323  * Description    : 
324 **************************************************************************/
325 PVRSRV_ERROR PDumpMMUMalloc2(const IMG_CHAR                     *pszPDumpDevName,
326                                                         const IMG_CHAR                  *pszTableType,/* PAGE_CATALOGUE, PAGE_DIRECTORY, PAGE_TABLE */
327                              const IMG_CHAR *pszSymbolicAddr,
328                              IMG_UINT32                         ui32Size,
329                                                          IMG_UINT32                             ui32Align)
330 {
331         PVRSRV_ERROR eErr = PVRSRV_OK;
332         IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS;
333
334         PDUMP_GET_SCRIPT_STRING();
335
336         PDUMP_LOCK();
337         /*
338                 Write a comment to the PDump2 script streams indicating the memory allocation
339         */
340         eErr = PDumpOSBufprintf(hScript,
341                                                         ui32MaxLen,
342                                                         "-- MALLOC :%s:%s Size=0x%08X Alignment=0x%08X\n",
343                                                         pszPDumpDevName,
344                                                         pszTableType,
345                                                         ui32Size,
346                                                         ui32Align);
347         if(eErr != PVRSRV_OK)
348         {
349                 goto ErrUnlock;
350         }
351
352         PDumpWriteScript(hScript, ui32Flags);
353
354         /*
355                 Write to the MMU script stream indicating the memory allocation
356         */
357         eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "MALLOC :%s:%s 0x%X 0x%X\n",
358                                                                                         pszPDumpDevName,
359                                                                                         pszSymbolicAddr,
360                                                                                         ui32Size,
361                                                                                         ui32Align
362                                                                                         /* don't need this sDevPAddr.uiAddr*/);
363         if(eErr != PVRSRV_OK)
364         {
365                 goto ErrUnlock;
366         }
367         PDumpWriteScript(hScript, ui32Flags);
368
369 ErrUnlock:
370         PDUMP_UNLOCK();
371         return eErr;
372 }
373
374
375 /**************************************************************************
376  * Function Name  : PDumpMMUFree2
377  * Inputs         :
378  * Outputs        : 
379  * Returns        : PVRSRV_ERROR
380  * Description    : 
381 **************************************************************************/
382 PVRSRV_ERROR PDumpMMUFree2(const IMG_CHAR                               *pszPDumpDevName,
383                                                         const IMG_CHAR                          *pszTableType,/* PAGE_CATALOGUE, PAGE_DIRECTORY, PAGE_TABLE */
384                            const IMG_CHAR *pszSymbolicAddr)
385 {
386         PVRSRV_ERROR eErr  = PVRSRV_OK;
387         IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS;
388
389         PDUMP_GET_SCRIPT_STRING();
390
391         PDUMP_LOCK();
392         /*
393                 Write a comment to the PDUMP2 script streams indicating the memory free
394         */
395         eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "-- FREE :%s:%s\n", 
396                                                         pszPDumpDevName, pszTableType);
397         if(eErr != PVRSRV_OK)
398         {
399                 goto ErrUnlock;
400         }
401
402         PDumpWriteScript(hScript, ui32Flags);
403
404         /*
405                 Write to the MMU script stream indicating the memory free
406         */
407         eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "FREE :%s:%s\n",
408                             pszPDumpDevName,
409                                                         pszSymbolicAddr);
410         if(eErr != PVRSRV_OK)
411         {
412                 goto ErrUnlock;
413         }
414         PDumpWriteScript(hScript, ui32Flags);
415
416 ErrUnlock:
417         PDUMP_UNLOCK();
418         return eErr;
419 }
420
421 /*******************************************************************************************************
422  * Function Name  : PDumpPTBaseObjectToMem64
423  * Outputs        : None
424  * Returns        : PVRSRV_ERROR
425  * Description    : Create a PDUMP string, which represents a memory write from the baseobject
426  *                                      for MIPS MMU device type
427 ********************************************************************************************************/
428 PVRSRV_ERROR PDumpPTBaseObjectToMem64(const IMG_CHAR *pszPDumpDevName,
429                                                                         PMR *psPMRDest,
430                                                                   IMG_DEVMEM_OFFSET_T uiLogicalOffsetSource,
431                                                                   IMG_DEVMEM_OFFSET_T uiLogicalOffsetDest,
432                                                                   IMG_UINT32 ui32Flags,                                                           
433                                                                   MMU_LEVEL eMMULevel,
434                                                                   IMG_UINT64 ui64PxSymAddr)
435 {
436
437         IMG_CHAR aszMemspaceNameDest[PHYSMEM_PDUMP_MEMSPACE_MAX_LENGTH];
438         IMG_CHAR aszSymbolicNameDest[PHYSMEM_PDUMP_SYMNAME_MAX_LENGTH];
439         IMG_DEVMEM_OFFSET_T uiPDumpSymbolicOffsetDest;
440         IMG_DEVMEM_OFFSET_T uiNextSymNameDest;
441         PVRSRV_ERROR eErr = PVRSRV_OK;
442
443
444         PDUMP_GET_SCRIPT_STRING()
445
446         eErr = PMR_PDumpSymbolicAddr(psPMRDest,
447                                                                          uiLogicalOffsetDest,
448                                                                          PHYSMEM_PDUMP_MEMSPACE_MAX_LENGTH,
449                                                                          aszMemspaceNameDest,
450                                                                          PHYSMEM_PDUMP_SYMNAME_MAX_LENGTH,
451                                                                          aszSymbolicNameDest,
452                                                                          &uiPDumpSymbolicOffsetDest,
453                                                                          &uiNextSymNameDest);
454
455
456         if (eErr != PVRSRV_OK)
457         {
458                 return eErr;
459         }
460
461         PDUMP_LOCK();
462
463         eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "WRW64 :%s:%s:0x%llX :%s:%s%016llX:0x%llX",aszMemspaceNameDest, aszSymbolicNameDest,
464                                                         uiPDumpSymbolicOffsetDest, pszPDumpDevName, MIPSMMUPX_FMT(eMMULevel), ui64PxSymAddr,
465                                                         (IMG_UINT64)0);
466
467
468         if (eErr != PVRSRV_OK)
469         {
470                 PDUMP_UNLOCK();
471                 return eErr;
472         }
473
474
475         PDumpWriteScript(hScript, ui32Flags);
476         PDUMP_UNLOCK();
477
478         return PVRSRV_OK;
479 }
480
481
482
483 /**************************************************************************
484  * Function Name  : PDumpMMUDumpPxEntries
485  * Inputs         :
486  * Outputs        :
487  * Returns        : PVRSRV_ERROR
488  * Description    :
489 **************************************************************************/
490 PVRSRV_ERROR PDumpMMUDumpPxEntries(MMU_LEVEL eMMULevel,
491                                                                    const IMG_CHAR *pszPDumpDevName,
492                                    void *pvPxMem,
493                                    IMG_DEV_PHYADDR sPxDevPAddr,
494                                    IMG_UINT32 uiFirstEntry,
495                                    IMG_UINT32 uiNumEntries,
496                                    const IMG_CHAR *pszMemspaceName,
497                                    const IMG_CHAR *pszSymbolicAddr,
498                                    IMG_UINT64 uiSymbolicAddrOffset,
499                                    IMG_UINT32 uiBytesPerEntry,
500                                    IMG_UINT32 uiLog2Align,
501                                    IMG_UINT32 uiAddrShift,
502                                    IMG_UINT64 uiAddrMask,
503                                    IMG_UINT64 uiPxEProtMask,
504                                    IMG_UINT64 uiDataValidEnable,
505                                    IMG_UINT32 ui32Flags,
506                                    PDUMP_MMU_TYPE eMMUType)
507 {
508         PVRSRV_ERROR eErr = PVRSRV_OK;
509     IMG_UINT64 ui64PxSymAddr;
510     IMG_UINT64 ui64PxEValueSymAddr;
511     IMG_UINT32 ui32SymAddrOffset = 0;
512     IMG_UINT32 *pui32PxMem;
513     IMG_UINT64 *pui64PxMem;
514     IMG_BOOL   bPxEValid;
515     IMG_UINT32 uiPxEIdx;
516     IMG_INT32  iShiftAmount;
517     IMG_CHAR   *pszWrwSuffix = 0;
518     void *pvRawBytes = 0;
519     IMG_CHAR aszPxSymbolicAddr[PHYSMEM_PDUMP_SYMNAME_MAX_LENGTH];
520     IMG_UINT64 ui64PxE64;
521     IMG_UINT64 ui64Protflags64;
522     IMG_CHAR *pszMMUPX;
523
524         PDUMP_GET_SCRIPT_STRING();
525
526         if (!PDumpReady())
527         {
528                 eErr = PVRSRV_ERROR_PDUMP_NOT_AVAILABLE;
529                 goto ErrOut;
530         }
531
532
533         if (PDumpIsDumpSuspended())
534         {
535                 eErr = PVRSRV_OK;
536                 goto ErrOut;
537         }
538
539     if (pvPxMem == NULL)
540     {
541         eErr = PVRSRV_ERROR_INVALID_PARAMS;
542         goto ErrOut;
543     }
544
545
546         /*
547                 create the symbolic address of the Px
548         */
549         ui64PxSymAddr = sPxDevPAddr.uiAddr;
550
551         if (eMMUType == PDUMP_MMU_TYPE_MIPS_MICROAPTIV)
552         {
553                 pszMMUPX = MIPSMMUPX_FMT(eMMULevel);
554         }
555         else
556         {
557                 pszMMUPX = MMUPX_FMT(eMMULevel);
558         }
559     OSSNPrintf(aszPxSymbolicAddr,
560                PHYSMEM_PDUMP_SYMNAME_MAX_LENGTH,
561                ":%s:%s%016llX",
562                pszPDumpDevName,
563                pszMMUPX,
564                ui64PxSymAddr);
565
566     PDUMP_LOCK();
567
568         /*
569                 traverse PxEs, dumping entries
570         */
571         for(uiPxEIdx = uiFirstEntry;
572         uiPxEIdx < uiFirstEntry + uiNumEntries;
573         uiPxEIdx++)
574         {
575                 /* Calc the symbolic address offset of the PxE location
576                    This is what we have to add to the table address to get to a certain entry */
577                 ui32SymAddrOffset = (uiPxEIdx*uiBytesPerEntry);
578
579                 /* Calc the symbolic address of the PxE value and HW protflags */
580                 /* just read it here */
581                 switch(uiBytesPerEntry)
582                 {
583                         case 4:
584                         {
585                                 pui32PxMem = pvPxMem;
586                 ui64PxE64 = pui32PxMem[uiPxEIdx];
587                 pszWrwSuffix = "";
588                 pvRawBytes = &pui32PxMem[uiPxEIdx];
589                                 break;
590                         }
591                         case 8:
592                         {
593                                 pui64PxMem = pvPxMem;
594                 ui64PxE64 = pui64PxMem[uiPxEIdx];
595                 pszWrwSuffix = "64";
596                 pvRawBytes = &pui64PxMem[uiPxEIdx];
597                                 break;
598                         }
599                         default:
600                         {
601                                 PVR_DPF((PVR_DBG_ERROR, "PDumpMMUPxEntries: error"));
602                                 ui64PxE64 = 0;
603                 //!!error
604                                 break;
605                         }
606                 }
607
608         ui64PxEValueSymAddr = (ui64PxE64 & uiAddrMask) >> uiAddrShift << uiLog2Align;
609         ui64Protflags64 = ui64PxE64 & uiPxEProtMask;
610         bPxEValid = (ui64Protflags64 & uiDataValidEnable) ? IMG_TRUE : IMG_FALSE;
611         if(bPxEValid)
612         {
613             _ContiguousPDumpBytes(aszPxSymbolicAddr, ui32SymAddrOffset, IMG_TRUE,
614                                   0, 0,
615                                   ui32Flags | PDUMP_FLAGS_CONTINUOUS);
616
617             iShiftAmount = (IMG_INT32)(uiLog2Align - uiAddrShift);
618
619             /* First put the symbolic representation of the actual
620                address of the entry into a pdump internal register */
621             /* MOV seemed cleaner here, since (a) it's 64-bit; (b) the
622                target is not memory.  However, MOV cannot do the
623                "reference" of the symbolic address.  Apparently WRW is
624                correct. */
625
626                         if (pszSymbolicAddr == NULL)
627                         {
628                                 pszSymbolicAddr = "none";
629                         }
630
631             if (eMMULevel == MMU_LEVEL_1)
632             {
633                 if (iShiftAmount == 0)
634                             {
635                         eErr = PDumpOSBufprintf(hScript,
636                                                                                         ui32MaxLen,
637                                                                                         "WRW%s :%s:%s%016llX:0x%08X :%s:%s:0x%llx | 0x%llX\n",
638                                                                                         pszWrwSuffix,
639                                                                                         /* dest */
640                                                                                         pszPDumpDevName,
641                                                                                         pszMMUPX,
642                                                                                         ui64PxSymAddr,
643                                                                                         ui32SymAddrOffset,
644                                                                                         /* src */
645                                                                                         pszMemspaceName,
646                                                                                         pszSymbolicAddr,
647                                                                                         uiSymbolicAddrOffset,
648                                                                                         /* ORing prot flags */
649                                                                                         ui64Protflags64);
650                 }
651                 else
652                 {
653                         eErr = PDumpOSBufprintf(hScript,
654                                                                 ui32MaxLen,
655                                                                 "WRW :%s:$1 :%s:%s:0x%llx\n",
656                                                                 /* dest */
657                                                                 pszPDumpDevName,
658                                                                                     /* src */
659                                                                                 pszMemspaceName,
660                                                                                         pszSymbolicAddr,
661                                                                                         uiSymbolicAddrOffset);
662                 }
663             }
664             else
665             {
666                 if (eMMUType == PDUMP_MMU_TYPE_MIPS_MICROAPTIV)
667                 {
668                         pszMMUPX = MIPSMMUPX_FMT(eMMULevel - 1);
669                 }
670                 else
671                 {
672                         pszMMUPX = MMUPX_FMT(eMMULevel - 1);
673                 }
674                 eErr = PDumpOSBufprintf(hScript,
675                                     ui32MaxLen,
676                                     "WRW :%s:$1 :%s:%s%016llX:0x0",
677                                     /* dest */
678                                     pszPDumpDevName,
679                                     /* src */
680                                     pszPDumpDevName,
681                                     pszMMUPX,
682                                     ui64PxEValueSymAddr);
683                 if (eMMUType == PDUMP_MMU_TYPE_MIPS_MICROAPTIV)
684                 {
685                         pszMMUPX = MIPSMMUPX_FMT(eMMULevel);
686                 }
687                 else
688                 {
689                         pszMMUPX = MMUPX_FMT(eMMULevel);
690                 }
691             }
692             if (eErr != PVRSRV_OK)
693             {
694                 goto ErrUnlock;
695             }
696             PDumpWriteScript(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS);
697
698             /* Now shift it to the right place, if necessary: */
699             /* Now shift that value down, by the "Align shift"
700                amount, to get it into units (ought to assert that
701                we get an integer - i.e. we don't shift any bits
702                off the bottom, don't know how to do PDUMP
703                assertions yet) and then back up by the right
704                amount to get it into the position of the field.
705                This is optimised into a single shift right by the
706                difference between the two. */
707             if (iShiftAmount > 0)
708             {
709                 /* Page X Address is specified in units larger
710                    than the position in the PxE would suggest.  */
711                 eErr = PDumpOSBufprintf(hScript,
712                                         ui32MaxLen,
713                                         "SHR :%s:$1 :%s:$1 0x%X",
714                                         /* dest */
715                                         pszPDumpDevName,
716                                         /* src A */
717                                         pszPDumpDevName,
718                                         /* src B */
719                                         iShiftAmount);
720                 if (eErr != PVRSRV_OK)
721                 {
722                     goto ErrUnlock;
723                 }
724                 PDumpWriteScript(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS);
725             }
726             else if (iShiftAmount < 0)
727             {
728                 /* Page X Address is specified in units smaller
729                    than the position in the PxE would suggest.  */
730                 eErr = PDumpOSBufprintf(hScript,
731                                         ui32MaxLen,
732                                         "SHL :%s:$1 :%s:$1 0x%X",
733                                         /* dest */
734                                         pszPDumpDevName,
735                                         /* src A */
736                                         pszPDumpDevName,
737                                         /* src B */
738                                         -iShiftAmount);
739                 if (eErr != PVRSRV_OK)
740                 {
741                     goto ErrUnlock;
742                 }
743                 PDumpWriteScript(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS);
744             }
745
746             if (eMMULevel == MMU_LEVEL_1)
747             {
748                 if( iShiftAmount != 0)
749                 {
750                         /* Now we can "or" in the protection flags */
751                         eErr = PDumpOSBufprintf(hScript,
752                                                 ui32MaxLen,
753                                                 "OR :%s:$1 :%s:$1 0x%llX",
754                                                 /* dest */
755                                                 pszPDumpDevName,
756                                                 /* src A */
757                                                 pszPDumpDevName,
758                                                 /* src B */
759                                                ui64Protflags64);
760                         if (eErr != PVRSRV_OK)
761                         {
762                                 goto ErrUnlock;
763                         }
764                         PDumpWriteScript(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS);
765                         eErr = PDumpOSBufprintf(hScript,
766                                                 ui32MaxLen,
767                                                 "WRW%s :%s:%s%016llX:0x%08X :%s:$1 ",
768                                                 pszWrwSuffix,
769                                                 /* dest */
770                                                 pszPDumpDevName,
771                                                 pszMMUPX,
772                                                 ui64PxSymAddr,
773                                                 ui32SymAddrOffset,
774                                                 /* src */
775                                                 pszPDumpDevName);
776                         if(eErr != PVRSRV_OK)
777                         {
778                                 goto ErrUnlock;
779                         }
780                         PDumpWriteScript(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS);
781
782                 }
783              }
784             else
785             {
786                 /* Now we can "or" in the protection flags */
787                 eErr = PDumpOSBufprintf(hScript,
788                                         ui32MaxLen,
789                                         "OR :%s:$1 :%s:$1 0x%llX",
790                                         /* dest */
791                                         pszPDumpDevName,
792                                         /* src A */
793                                         pszPDumpDevName,
794                                         /* src B */
795                                         ui64Protflags64);
796                 if (eErr != PVRSRV_OK)
797                 {
798                         goto ErrUnlock;
799                 }
800                 PDumpWriteScript(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS);
801
802                 /* Finally, we write the register into the actual PxE */
803                 eErr = PDumpOSBufprintf(hScript,
804                                         ui32MaxLen,
805                                         "WRW%s :%s:%s%016llX:0x%08X :%s:$1",
806                                         pszWrwSuffix,
807                                         /* dest */
808                                         pszPDumpDevName,
809                                         pszMMUPX,
810                                         ui64PxSymAddr,
811                                         ui32SymAddrOffset,
812                                         /* src */
813                                         pszPDumpDevName);
814                                 if(eErr != PVRSRV_OK)
815                                 {
816                                         goto ErrUnlock;
817                                 }
818                                 PDumpWriteScript(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS);
819                 }
820         }
821         else
822         {
823             /* If the entry was "invalid", simply write the actual
824                value found to the memory location */
825             eErr = _ContiguousPDumpBytes(aszPxSymbolicAddr, ui32SymAddrOffset, IMG_FALSE,
826                                          uiBytesPerEntry, pvRawBytes,
827                                          ui32Flags | PDUMP_FLAGS_CONTINUOUS);
828             if (eErr != PVRSRV_OK)
829             {
830                 goto ErrUnlock;
831             }
832         }
833         }
834
835     /* flush out any partly accumulated stuff for LDB */
836     _ContiguousPDumpBytes(aszPxSymbolicAddr, ui32SymAddrOffset, IMG_TRUE,
837                           0, 0,
838                           ui32Flags | PDUMP_FLAGS_CONTINUOUS);
839
840 ErrUnlock:
841         PDUMP_UNLOCK();
842 ErrOut:
843         return eErr;
844 }
845
846
847 /**************************************************************************
848  * Function Name  : _PdumpAllocMMUContext
849  * Inputs         : pui32MMUContextID
850  * Outputs        : None
851  * Returns        : PVRSRV_ERROR
852  * Description    : pdump util to allocate MMU contexts
853 **************************************************************************/
854 static PVRSRV_ERROR _PdumpAllocMMUContext(IMG_UINT32 *pui32MMUContextID)
855 {
856         IMG_UINT32 i;
857
858         /* there are MAX_PDUMP_MMU_CONTEXTS contexts available, find one */
859         for(i=0; i<MAX_PDUMP_MMU_CONTEXTS; i++)
860         {
861                 if((guiPDumpMMUContextAvailabilityMask & (1U << i)))
862                 {
863                         /* mark in use */
864                         guiPDumpMMUContextAvailabilityMask &= ~(1U << i);
865                         *pui32MMUContextID = i;
866                         return PVRSRV_OK;
867                 }
868         }
869
870         PVR_DPF((PVR_DBG_ERROR, "_PdumpAllocMMUContext: no free MMU context ids"));
871
872         return PVRSRV_ERROR_MMU_CONTEXT_NOT_FOUND;
873 }
874
875
876 /**************************************************************************
877  * Function Name  : _PdumpFreeMMUContext
878  * Inputs         : ui32MMUContextID
879  * Outputs        : None
880  * Returns        : PVRSRV_ERROR
881  * Description    : pdump util to free MMU contexts
882 **************************************************************************/
883 static PVRSRV_ERROR _PdumpFreeMMUContext(IMG_UINT32 ui32MMUContextID)
884 {
885         if(ui32MMUContextID < MAX_PDUMP_MMU_CONTEXTS)
886         {
887                 /* free the id */
888         PVR_ASSERT (!(guiPDumpMMUContextAvailabilityMask & (1U << ui32MMUContextID)));
889                 guiPDumpMMUContextAvailabilityMask |= (1U << ui32MMUContextID);
890                 return PVRSRV_OK;
891         }
892
893         PVR_DPF((PVR_DBG_ERROR, "_PdumpFreeMMUContext: MMU context ids invalid"));
894
895         return PVRSRV_ERROR_MMU_CONTEXT_NOT_FOUND;
896 }
897
898
899 /**************************************************************************
900  * Function Name  : PDumpMMUAllocMMUContext
901  * Inputs         :
902  * Outputs        : None
903  * Returns        : PVRSRV_ERROR
904  * Description    : Alloc MMU Context
905 **************************************************************************/
906 PVRSRV_ERROR PDumpMMUAllocMMUContext(const IMG_CHAR *pszPDumpMemSpaceName,
907                                      IMG_DEV_PHYADDR sPCDevPAddr,
908                                      PDUMP_MMU_TYPE eMMUType,
909                                      IMG_UINT32 *pui32MMUContextID)
910 {
911     IMG_UINT64 ui64PCSymAddr;
912     IMG_CHAR *pszMMUPX;
913
914         IMG_UINT32 ui32MMUContextID;
915         PVRSRV_ERROR eErr = PVRSRV_OK;
916         PDUMP_GET_SCRIPT_STRING();
917
918         eErr = _PdumpAllocMMUContext(&ui32MMUContextID);
919         if(eErr != PVRSRV_OK)
920         {
921                 PVR_DPF((PVR_DBG_ERROR, "%s: _PdumpAllocMMUContext failed: %d",
922                                  __func__, eErr));
923         PVR_DBG_BREAK;
924                 goto ErrOut;
925         }
926
927         /*
928                 create the symbolic address of the PC
929     */
930         ui64PCSymAddr = sPCDevPAddr.uiAddr;
931
932         if (eMMUType == PDUMP_MMU_TYPE_MIPS_MICROAPTIV)
933         {
934                 pszMMUPX = MIPSMMUPX_FMT(1);
935                 /* Giving it a mock value until the Pdump player implements
936                    the support for the MIPS microAptiv MMU*/
937                 eMMUType = PDUMP_MMU_TYPE_VARPAGE_40BIT;
938         }
939         else
940         {
941                 pszMMUPX = MMUPX_FMT(3);
942         }
943
944         PDUMP_LOCK();
945
946         eErr = PDumpOSBufprintf(hScript,
947                             ui32MaxLen, 
948                             "MMU :%s:v%d %d :%s:%s%016llX",
949                             /* mmu context */
950                             pszPDumpMemSpaceName,
951                             ui32MMUContextID,
952                             /* mmu type */
953                             eMMUType,
954                             /* PC base address */
955                             pszPDumpMemSpaceName,
956                             pszMMUPX,
957                             ui64PCSymAddr);
958         if(eErr != PVRSRV_OK)
959         {
960             PDUMP_UNLOCK();
961         PVR_DBG_BREAK;
962                 goto ErrOut;
963         }
964
965         PDumpWriteScript(hScript, PDUMP_FLAGS_CONTINUOUS);
966     PDUMP_UNLOCK();
967
968         /* return the MMU Context ID */
969         *pui32MMUContextID = ui32MMUContextID;
970
971 ErrOut:
972         return eErr;
973 }
974
975
976 /**************************************************************************
977  * Function Name  : PDumpMMUFreeMMUContext
978  * Inputs         :
979  * Outputs        : None
980  * Returns        : PVRSRV_ERROR
981  * Description    : Free MMU Context
982 **************************************************************************/
983 PVRSRV_ERROR PDumpMMUFreeMMUContext(const IMG_CHAR *pszPDumpMemSpaceName,
984                                     IMG_UINT32 ui32MMUContextID)
985 {
986         PVRSRV_ERROR eErr = PVRSRV_OK;
987         PDUMP_GET_SCRIPT_STRING();
988
989         PDUMP_LOCK();
990         eErr = PDumpOSBufprintf(hScript,
991                             ui32MaxLen,
992                             "-- Clear MMU Context for memory space %s", pszPDumpMemSpaceName);
993         if(eErr != PVRSRV_OK)
994         {
995                 goto ErrUnlock;
996         }
997
998         PDumpWriteScript(hScript, PDUMP_FLAGS_CONTINUOUS);
999
1000         eErr = PDumpOSBufprintf(hScript,
1001                             ui32MaxLen, 
1002                             "MMU :%s:v%d",
1003                             pszPDumpMemSpaceName,
1004                             ui32MMUContextID);
1005         if(eErr != PVRSRV_OK)
1006         {
1007                 goto ErrUnlock;
1008         }
1009
1010         PDumpWriteScript(hScript, PDUMP_FLAGS_CONTINUOUS);
1011
1012         eErr = _PdumpFreeMMUContext(ui32MMUContextID);
1013         if(eErr != PVRSRV_OK)
1014         {
1015                 PVR_DPF((PVR_DBG_ERROR, "%s: _PdumpFreeMMUContext failed: %d",
1016                                  __func__, eErr));
1017                 goto ErrUnlock;
1018         }
1019
1020 ErrUnlock:
1021         PDUMP_UNLOCK();
1022         return eErr;
1023 }
1024
1025
1026 /**************************************************************************
1027  * Function Name  : PDumpMMUActivateCatalog
1028  * Inputs         :
1029  * Outputs        : 
1030  * Returns        : PVRSRV_ERROR
1031  * Description    : 
1032 **************************************************************************/
1033 PVRSRV_ERROR PDumpMMUActivateCatalog(const IMG_CHAR *pszPDumpRegSpaceName,
1034                                      const IMG_CHAR *pszPDumpRegName,
1035                                      IMG_UINT32 uiRegAddr,
1036                                      const IMG_CHAR *pszPDumpPCSymbolicName)
1037 {
1038         IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS;
1039         PVRSRV_ERROR eErr = PVRSRV_OK;
1040
1041         PDUMP_GET_SCRIPT_STRING();
1042
1043         if (!PDumpReady())
1044         {
1045                 eErr = PVRSRV_ERROR_PDUMP_NOT_AVAILABLE;
1046                 goto ErrOut;
1047         }
1048
1049
1050         if (PDumpIsDumpSuspended())
1051         {
1052                 goto ErrOut;
1053         }
1054
1055         PDUMP_LOCK();
1056
1057         eErr = PDumpOSBufprintf(hScript, ui32MaxLen,
1058                                                         "-- Write Page Catalogue Address to %s",
1059                                                         pszPDumpRegName);
1060         if(eErr != PVRSRV_OK)
1061         {
1062                 goto ErrUnlock;
1063         }
1064
1065         PDumpWriteScript(hScript, ui32Flags);
1066
1067     eErr = PDumpOSBufprintf(hScript,
1068                             ui32MaxLen,
1069                             "WRW :%s:0x%04X %s:0",
1070                             /* dest */
1071                             pszPDumpRegSpaceName,
1072                             uiRegAddr,
1073                             /* src */
1074                             pszPDumpPCSymbolicName);
1075     if (eErr != PVRSRV_OK)
1076     {
1077         goto ErrUnlock;
1078     }
1079     PDumpWriteScript(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS);
1080
1081 ErrUnlock:
1082         PDUMP_UNLOCK();
1083 ErrOut:
1084         return eErr;
1085 }
1086
1087
1088 PVRSRV_ERROR
1089 PDumpMMUSAB(const IMG_CHAR *pszPDumpMemNamespace,
1090                IMG_UINT32 uiPDumpMMUCtx,
1091                IMG_DEV_VIRTADDR sDevAddrStart,
1092                IMG_DEVMEM_SIZE_T uiSize,
1093                const IMG_CHAR *pszFilename,
1094                IMG_UINT32 uiFileOffset,
1095                            IMG_UINT32 ui32PDumpFlags)
1096 {    
1097         PVRSRV_ERROR eErr = PVRSRV_OK;
1098
1099     //                                                  "SAB :%s:v%x:0x%010llX 0x%08X 0x%08X %s.bin",
1100
1101         PDUMP_GET_SCRIPT_STRING();
1102
1103         if (!PDumpReady())
1104         {
1105                 eErr = PVRSRV_ERROR_PDUMP_NOT_AVAILABLE;
1106                 goto ErrOut;
1107         }
1108
1109
1110         if (PDumpIsDumpSuspended())
1111         {
1112                 eErr = PVRSRV_OK;
1113                 goto ErrOut;
1114         }
1115
1116         PDUMP_LOCK();
1117
1118         eErr = PDumpOSBufprintf(hScript,
1119                               ui32MaxLen,
1120                               "SAB :%s:v%x:" IMG_DEV_VIRTADDR_FMTSPEC " "
1121                               IMG_DEVMEM_SIZE_FMTSPEC " "
1122                               "0x%x %s.bin\n",
1123                               pszPDumpMemNamespace,
1124                               uiPDumpMMUCtx,
1125                               sDevAddrStart.uiAddr,
1126                               uiSize,
1127                               uiFileOffset,
1128                               pszFilename);
1129     if (eErr != PVRSRV_OK)
1130     {
1131         goto ErrUnlock;
1132     }
1133
1134     PDumpWriteScript(hScript, ui32PDumpFlags);
1135
1136 ErrUnlock:
1137     PDUMP_UNLOCK();
1138 ErrOut:
1139     return eErr;
1140 }
1141
1142 /**************************************************************************
1143  * Function Name  : PdumpWireUpMipsTLB
1144 **************************************************************************/
1145 PVRSRV_ERROR PdumpWireUpMipsTLB(PMR *psPMRSource,
1146                                                                 PMR *psPMRDest,
1147                                                                 IMG_DEVMEM_OFFSET_T uiLogicalOffsetSource,
1148                                                                 IMG_DEVMEM_OFFSET_T uiLogicalOffsetDest,
1149                                                                 IMG_UINT32 ui32AllocationFlags,
1150                                                                 IMG_UINT32 ui32Flags)
1151 {
1152         PVRSRV_ERROR eErr = PVRSRV_OK;
1153         IMG_CHAR aszMemspaceNameSource[PHYSMEM_PDUMP_MEMSPACE_MAX_LENGTH];
1154         IMG_CHAR aszSymbolicNameSource[PHYSMEM_PDUMP_SYMNAME_MAX_LENGTH];
1155         IMG_CHAR aszMemspaceNameDest[PHYSMEM_PDUMP_MEMSPACE_MAX_LENGTH];
1156         IMG_CHAR aszSymbolicNameDest[PHYSMEM_PDUMP_SYMNAME_MAX_LENGTH];
1157         IMG_DEVMEM_OFFSET_T uiPDumpSymbolicOffsetSource;
1158         IMG_DEVMEM_OFFSET_T uiPDumpSymbolicOffsetDest;
1159         IMG_DEVMEM_OFFSET_T uiNextSymNameSource;
1160         IMG_DEVMEM_OFFSET_T uiNextSymNameDest;
1161
1162
1163         PDUMP_GET_SCRIPT_STRING()
1164
1165         eErr = PMR_PDumpSymbolicAddr(psPMRSource,
1166                                                                          uiLogicalOffsetSource,
1167                                                                          PHYSMEM_PDUMP_MEMSPACE_MAX_LENGTH,
1168                                                                          aszMemspaceNameSource,
1169                                                                          PHYSMEM_PDUMP_SYMNAME_MAX_LENGTH,
1170                                                                          aszSymbolicNameSource,
1171                                                                          &uiPDumpSymbolicOffsetSource,
1172                                                                          &uiNextSymNameSource);
1173
1174         if (eErr != PVRSRV_OK)
1175         {
1176                 goto ErrOut;
1177         }
1178
1179         eErr = PMR_PDumpSymbolicAddr(psPMRDest,
1180                                                                          uiLogicalOffsetDest,
1181                                                                          PHYSMEM_PDUMP_MEMSPACE_MAX_LENGTH,
1182                                                                          aszMemspaceNameDest,
1183                                                                          PHYSMEM_PDUMP_SYMNAME_MAX_LENGTH,
1184                                                                          aszSymbolicNameDest,
1185                                                                          &uiPDumpSymbolicOffsetDest,
1186                                                                          &uiNextSymNameDest);
1187
1188
1189         if (eErr != PVRSRV_OK)
1190         {
1191                 goto ErrOut;
1192         }
1193
1194         PDUMP_LOCK();
1195
1196         eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "WRW :%s:$1 :%s:%s:0x%llX", aszMemspaceNameSource,
1197                                                         aszMemspaceNameSource, aszSymbolicNameSource,
1198                                                         uiPDumpSymbolicOffsetSource);
1199
1200         if (eErr != PVRSRV_OK)
1201         {
1202         goto ErrUnlock;
1203         }
1204         PDumpWriteScript(hScript, ui32Flags);
1205
1206         eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "SHR :%s:$1 :%s:$1 0x6", aszMemspaceNameSource,
1207                                                         aszMemspaceNameSource);
1208
1209         if (eErr != PVRSRV_OK)
1210         {
1211         goto ErrUnlock;
1212         }
1213         PDumpWriteScript(hScript, ui32Flags);
1214
1215         eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "AND :%s:$1 :%s:$1 0x03FFFFC0", aszMemspaceNameSource,
1216                                                         aszMemspaceNameSource);
1217
1218         if (eErr != PVRSRV_OK)
1219         {
1220         goto ErrUnlock;
1221         }
1222         PDumpWriteScript(hScript, ui32Flags);
1223
1224         eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "OR :%s:$1 :%s:$1 0x%X", aszMemspaceNameSource,
1225                                                         aszMemspaceNameSource, ui32AllocationFlags);
1226
1227         if (eErr != PVRSRV_OK)
1228         {
1229         goto ErrUnlock;
1230         }
1231         PDumpWriteScript(hScript, ui32Flags);
1232
1233         eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "WRW :%s:%s:0x%llX :%s:$1",aszMemspaceNameDest, aszSymbolicNameDest,
1234                                                         uiPDumpSymbolicOffsetDest, aszMemspaceNameSource);
1235
1236
1237         if (eErr != PVRSRV_OK)
1238         {
1239         goto ErrUnlock;
1240         }
1241         PDumpWriteScript(hScript, ui32Flags);
1242
1243 ErrUnlock:
1244     PDUMP_UNLOCK();
1245 ErrOut:
1246         return eErr;
1247 }
1248
1249 /**************************************************************************
1250  * Function Name  : PdumpInvalidateMipsTLB
1251 **************************************************************************/
1252 PVRSRV_ERROR PdumpInvalidateMipsTLB(PMR *psPMRDest,
1253                                                                         IMG_DEVMEM_OFFSET_T uiLogicalOffsetDest,
1254                                                                         IMG_UINT32 ui32MipsTLBValidClearMask,
1255                                                                         IMG_UINT32 ui32Flags)
1256 {
1257         PVRSRV_ERROR eErr = PVRSRV_OK;
1258         IMG_CHAR aszMemspaceNameDest[PHYSMEM_PDUMP_MEMSPACE_MAX_LENGTH];
1259         IMG_CHAR aszSymbolicNameDest[PHYSMEM_PDUMP_SYMNAME_MAX_LENGTH];
1260         IMG_DEVMEM_OFFSET_T uiPDumpSymbolicOffsetDest;
1261         IMG_DEVMEM_OFFSET_T uiNextSymNameDest;
1262
1263
1264         PDUMP_GET_SCRIPT_STRING()
1265
1266         eErr = PMR_PDumpSymbolicAddr(psPMRDest,
1267                                                                          uiLogicalOffsetDest,
1268                                                                          PHYSMEM_PDUMP_MEMSPACE_MAX_LENGTH,
1269                                                                          aszMemspaceNameDest,
1270                                                                          PHYSMEM_PDUMP_SYMNAME_MAX_LENGTH,
1271                                                                          aszSymbolicNameDest,
1272                                                                          &uiPDumpSymbolicOffsetDest,
1273                                                                          &uiNextSymNameDest);
1274
1275
1276         if (eErr != PVRSRV_OK)
1277         {
1278                 goto ErrOut;
1279         }
1280
1281         PDUMP_LOCK();
1282
1283         eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "WRW :%s:$1 :%s:%s:0x%llX", aszMemspaceNameDest,
1284                                                         aszMemspaceNameDest, aszSymbolicNameDest,
1285                                                         uiPDumpSymbolicOffsetDest);
1286
1287         if (eErr != PVRSRV_OK)
1288         {
1289         goto ErrUnlock;
1290         }
1291         PDumpWriteScript(hScript, ui32Flags);
1292
1293         eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "AND :%s:$1 :%s:$1 0x%X", aszMemspaceNameDest,
1294                                                         aszMemspaceNameDest, ui32MipsTLBValidClearMask);
1295
1296         if (eErr != PVRSRV_OK)
1297         {
1298         goto ErrUnlock;
1299         }
1300         PDumpWriteScript(hScript, ui32Flags);
1301
1302
1303
1304         eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "WRW :%s:%s:0x%llX :%s:$1",aszMemspaceNameDest, aszSymbolicNameDest,
1305                                                         uiPDumpSymbolicOffsetDest, aszMemspaceNameDest);
1306
1307
1308         if (eErr != PVRSRV_OK)
1309         {
1310         goto ErrUnlock;
1311         }
1312         PDumpWriteScript(hScript, ui32Flags);
1313
1314
1315 ErrUnlock:
1316     PDUMP_UNLOCK();
1317 ErrOut:
1318         return eErr;
1319 }
1320
1321
1322 #endif /* #if defined (PDUMP) */
1323