1 /*************************************************************************/ /*!
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
8 The contents of this file are subject to the MIT license as set out below.
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
32 This License is also included in this distribution in the file called
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /***************************************************************************/
46 #include "img_types.h"
47 #include "pdump_mmu.h"
48 #include "pdump_osfunc.h"
50 #include "pdump_physmem.h"
52 #include "pvr_debug.h"
53 #include "pvrsrv_error.h"
55 #define MAX_PDUMP_MMU_CONTEXTS (10)
56 static IMG_UINT32 guiPDumpMMUContextAvailabilityMask = (1<<MAX_PDUMP_MMU_CONTEXTS)-1;
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")
63 /* Array used to look-up debug strings from MMU_LEVEL */
64 static IMG_CHAR ai8MMULevelStringLookup[MMU_LEVEL_LAST][15] =
73 _ContiguousPDumpBytes(const IMG_CHAR *pszSymbolicName,
74 IMG_UINT32 ui32SymAddrOffset,
76 IMG_UINT32 uiNumBytes,
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;
88 PDUMP_GET_SCRIPT_AND_FILE_STRING();
89 PVR_UNREFERENCED_PARAMETER(ui32MaxLenFileName);
91 /* Caller has PDUMP_LOCK */
93 if (!bFlush && uiAccumulatedBytes > 0)
95 /* do some tests for contiguity. If it fails, we flush anyway */
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 */
107 /* Flush if necessary */
108 if (bFlush && uiAccumulatedBytes > 0)
110 eErr = PDumpWriteParameter((IMG_UINT8 *)(uintptr_t)pvBasePointer,
111 uiAccumulatedBytes, ui32Flags,
112 &ui32ParamOutPos, pszFileName);
113 if (eErr == PVRSRV_OK)
115 eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript,
116 "LDB %s:0x%X 0x%X 0x%X %s",
126 PVR_LOGG_IF_ERROR(eErr, "PDumpOSBufprintf", ErrOut);
128 PDumpWriteScript(hScript, ui32Flags);
131 else if (eErr != PVRSRV_ERROR_PDUMP_NOT_ALLOWED)
133 PVR_LOGG_IF_ERROR(eErr, "PDumpWriteParameter", ErrOut);
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.
143 uiAccumulatedBytes = 0;
147 /* Initialise offsets and pointers if necessary */
148 if (uiAccumulatedBytes == 0)
150 ui32BaseOffset = ui32BeyondLastOffset = ui32SymAddrOffset;
151 pvBeyondLastPointer = pvBasePointer = (const IMG_CHAR *)pvBytes;
154 /* Accumulate some bytes */
155 ui32BeyondLastOffset += uiNumBytes;
156 pvBeyondLastPointer += uiNumBytes;
157 uiAccumulatedBytes += uiNumBytes;
164 /**************************************************************************
165 * Function Name : PDumpMMUMalloc
168 * Returns : PVRSRV_ERROR
170 **************************************************************************/
171 PVRSRV_ERROR PDumpMMUMalloc(const IMG_CHAR *pszPDumpDevName,
173 IMG_DEV_PHYADDR *psDevPAddr,
175 IMG_UINT32 ui32Align,
176 PDUMP_MMU_TYPE eMMUType)
178 PVRSRV_ERROR eErr = PVRSRV_OK;
179 IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS;
180 IMG_UINT64 ui64SymbolicAddr;
183 PDUMP_GET_SCRIPT_STRING();
185 if (eMMULevel >= MMU_LEVEL_LAST)
187 eErr = PVRSRV_ERROR_INVALID_PARAMS;
194 Write a comment to the PDump2 script streams indicating the memory allocation
196 eErr = PDumpOSBufprintf(hScript,
198 "-- MALLOC :%s:%s Size=0x%08X Alignment=0x%08X DevPAddr=0x%08llX",
200 ai8MMULevelStringLookup[eMMULevel],
204 if(eErr != PVRSRV_OK)
209 PDumpWriteScript(hScript, ui32Flags);
212 construct the symbolic address
214 ui64SymbolicAddr = (IMG_UINT64)psDevPAddr->uiAddr;
217 Write to the MMU script stream indicating the memory allocation
219 if (eMMUType == PDUMP_MMU_TYPE_MIPS_MICROAPTIV)
221 pszMMUPX = MIPSMMUPX_FMT(eMMULevel);
225 pszMMUPX = MMUPX_FMT(eMMULevel);
227 eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "MALLOC :%s:%s%016llX 0x%X 0x%X",
233 /* don't need this sDevPAddr.uiAddr*/);
234 if(eErr != PVRSRV_OK)
238 PDumpWriteScript(hScript, ui32Flags);
247 /**************************************************************************
248 * Function Name : PDumpMMUFree
251 * Returns : PVRSRV_ERROR
253 **************************************************************************/
254 PVRSRV_ERROR PDumpMMUFree(const IMG_CHAR *pszPDumpDevName,
256 IMG_DEV_PHYADDR *psDevPAddr,
257 PDUMP_MMU_TYPE eMMUType)
259 PVRSRV_ERROR eErr = PVRSRV_OK;
260 IMG_UINT64 ui64SymbolicAddr;
261 IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS;
264 PDUMP_GET_SCRIPT_STRING();
266 if (eMMULevel >= MMU_LEVEL_LAST)
268 eErr = PVRSRV_ERROR_INVALID_PARAMS;
274 Write a comment to the PDUMP2 script streams indicating the memory free
276 eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "-- FREE :%s:%s",
277 pszPDumpDevName, ai8MMULevelStringLookup[eMMULevel]);
278 if(eErr != PVRSRV_OK)
283 PDumpWriteScript(hScript, ui32Flags);
286 construct the symbolic address
288 ui64SymbolicAddr = (IMG_UINT64)psDevPAddr->uiAddr;
291 Write to the MMU script stream indicating the memory free
293 if (eMMUType == PDUMP_MMU_TYPE_MIPS_MICROAPTIV)
295 pszMMUPX = MIPSMMUPX_FMT(eMMULevel);
299 pszMMUPX = MMUPX_FMT(eMMULevel);
301 eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "FREE :%s:%s%016llX",
305 if(eErr != PVRSRV_OK)
309 PDumpWriteScript(hScript, ui32Flags);
318 /**************************************************************************
319 * Function Name : PDumpMMUMalloc2
322 * Returns : PVRSRV_ERROR
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,
329 IMG_UINT32 ui32Align)
331 PVRSRV_ERROR eErr = PVRSRV_OK;
332 IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS;
334 PDUMP_GET_SCRIPT_STRING();
338 Write a comment to the PDump2 script streams indicating the memory allocation
340 eErr = PDumpOSBufprintf(hScript,
342 "-- MALLOC :%s:%s Size=0x%08X Alignment=0x%08X\n",
347 if(eErr != PVRSRV_OK)
352 PDumpWriteScript(hScript, ui32Flags);
355 Write to the MMU script stream indicating the memory allocation
357 eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "MALLOC :%s:%s 0x%X 0x%X\n",
362 /* don't need this sDevPAddr.uiAddr*/);
363 if(eErr != PVRSRV_OK)
367 PDumpWriteScript(hScript, ui32Flags);
375 /**************************************************************************
376 * Function Name : PDumpMMUFree2
379 * Returns : PVRSRV_ERROR
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)
386 PVRSRV_ERROR eErr = PVRSRV_OK;
387 IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS;
389 PDUMP_GET_SCRIPT_STRING();
393 Write a comment to the PDUMP2 script streams indicating the memory free
395 eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "-- FREE :%s:%s\n",
396 pszPDumpDevName, pszTableType);
397 if(eErr != PVRSRV_OK)
402 PDumpWriteScript(hScript, ui32Flags);
405 Write to the MMU script stream indicating the memory free
407 eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "FREE :%s:%s\n",
410 if(eErr != PVRSRV_OK)
414 PDumpWriteScript(hScript, ui32Flags);
421 /*******************************************************************************************************
422 * Function Name : PDumpPTBaseObjectToMem64
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,
430 IMG_DEVMEM_OFFSET_T uiLogicalOffsetSource,
431 IMG_DEVMEM_OFFSET_T uiLogicalOffsetDest,
432 IMG_UINT32 ui32Flags,
434 IMG_UINT64 ui64PxSymAddr)
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;
444 PDUMP_GET_SCRIPT_STRING()
446 eErr = PMR_PDumpSymbolicAddr(psPMRDest,
448 PHYSMEM_PDUMP_MEMSPACE_MAX_LENGTH,
450 PHYSMEM_PDUMP_SYMNAME_MAX_LENGTH,
452 &uiPDumpSymbolicOffsetDest,
456 if (eErr != PVRSRV_OK)
463 eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "WRW64 :%s:%s:0x%llX :%s:%s%016llX:0x%llX",aszMemspaceNameDest, aszSymbolicNameDest,
464 uiPDumpSymbolicOffsetDest, pszPDumpDevName, MIPSMMUPX_FMT(eMMULevel), ui64PxSymAddr,
468 if (eErr != PVRSRV_OK)
475 PDumpWriteScript(hScript, ui32Flags);
483 /**************************************************************************
484 * Function Name : PDumpMMUDumpPxEntries
487 * Returns : PVRSRV_ERROR
489 **************************************************************************/
490 PVRSRV_ERROR PDumpMMUDumpPxEntries(MMU_LEVEL eMMULevel,
491 const IMG_CHAR *pszPDumpDevName,
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)
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;
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;
524 PDUMP_GET_SCRIPT_STRING();
528 eErr = PVRSRV_ERROR_PDUMP_NOT_AVAILABLE;
533 if (PDumpIsDumpSuspended())
541 eErr = PVRSRV_ERROR_INVALID_PARAMS;
547 create the symbolic address of the Px
549 ui64PxSymAddr = sPxDevPAddr.uiAddr;
551 if (eMMUType == PDUMP_MMU_TYPE_MIPS_MICROAPTIV)
553 pszMMUPX = MIPSMMUPX_FMT(eMMULevel);
557 pszMMUPX = MMUPX_FMT(eMMULevel);
559 OSSNPrintf(aszPxSymbolicAddr,
560 PHYSMEM_PDUMP_SYMNAME_MAX_LENGTH,
569 traverse PxEs, dumping entries
571 for(uiPxEIdx = uiFirstEntry;
572 uiPxEIdx < uiFirstEntry + uiNumEntries;
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);
579 /* Calc the symbolic address of the PxE value and HW protflags */
580 /* just read it here */
581 switch(uiBytesPerEntry)
585 pui32PxMem = pvPxMem;
586 ui64PxE64 = pui32PxMem[uiPxEIdx];
588 pvRawBytes = &pui32PxMem[uiPxEIdx];
593 pui64PxMem = pvPxMem;
594 ui64PxE64 = pui64PxMem[uiPxEIdx];
596 pvRawBytes = &pui64PxMem[uiPxEIdx];
601 PVR_DPF((PVR_DBG_ERROR, "PDumpMMUPxEntries: error"));
608 ui64PxEValueSymAddr = (ui64PxE64 & uiAddrMask) >> uiAddrShift << uiLog2Align;
609 ui64Protflags64 = ui64PxE64 & uiPxEProtMask;
610 bPxEValid = (ui64Protflags64 & uiDataValidEnable) ? IMG_TRUE : IMG_FALSE;
613 _ContiguousPDumpBytes(aszPxSymbolicAddr, ui32SymAddrOffset, IMG_TRUE,
615 ui32Flags | PDUMP_FLAGS_CONTINUOUS);
617 iShiftAmount = (IMG_INT32)(uiLog2Align - uiAddrShift);
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
626 if (pszSymbolicAddr == NULL)
628 pszSymbolicAddr = "none";
631 if (eMMULevel == MMU_LEVEL_1)
633 if (iShiftAmount == 0)
635 eErr = PDumpOSBufprintf(hScript,
637 "WRW%s :%s:%s%016llX:0x%08X :%s:%s:0x%llx | 0x%llX\n",
647 uiSymbolicAddrOffset,
648 /* ORing prot flags */
653 eErr = PDumpOSBufprintf(hScript,
655 "WRW :%s:$1 :%s:%s:0x%llx\n",
661 uiSymbolicAddrOffset);
666 if (eMMUType == PDUMP_MMU_TYPE_MIPS_MICROAPTIV)
668 pszMMUPX = MIPSMMUPX_FMT(eMMULevel - 1);
672 pszMMUPX = MMUPX_FMT(eMMULevel - 1);
674 eErr = PDumpOSBufprintf(hScript,
676 "WRW :%s:$1 :%s:%s%016llX:0x0",
682 ui64PxEValueSymAddr);
683 if (eMMUType == PDUMP_MMU_TYPE_MIPS_MICROAPTIV)
685 pszMMUPX = MIPSMMUPX_FMT(eMMULevel);
689 pszMMUPX = MMUPX_FMT(eMMULevel);
692 if (eErr != PVRSRV_OK)
696 PDumpWriteScript(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS);
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)
709 /* Page X Address is specified in units larger
710 than the position in the PxE would suggest. */
711 eErr = PDumpOSBufprintf(hScript,
713 "SHR :%s:$1 :%s:$1 0x%X",
720 if (eErr != PVRSRV_OK)
724 PDumpWriteScript(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS);
726 else if (iShiftAmount < 0)
728 /* Page X Address is specified in units smaller
729 than the position in the PxE would suggest. */
730 eErr = PDumpOSBufprintf(hScript,
732 "SHL :%s:$1 :%s:$1 0x%X",
739 if (eErr != PVRSRV_OK)
743 PDumpWriteScript(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS);
746 if (eMMULevel == MMU_LEVEL_1)
748 if( iShiftAmount != 0)
750 /* Now we can "or" in the protection flags */
751 eErr = PDumpOSBufprintf(hScript,
753 "OR :%s:$1 :%s:$1 0x%llX",
760 if (eErr != PVRSRV_OK)
764 PDumpWriteScript(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS);
765 eErr = PDumpOSBufprintf(hScript,
767 "WRW%s :%s:%s%016llX:0x%08X :%s:$1 ",
776 if(eErr != PVRSRV_OK)
780 PDumpWriteScript(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS);
786 /* Now we can "or" in the protection flags */
787 eErr = PDumpOSBufprintf(hScript,
789 "OR :%s:$1 :%s:$1 0x%llX",
796 if (eErr != PVRSRV_OK)
800 PDumpWriteScript(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS);
802 /* Finally, we write the register into the actual PxE */
803 eErr = PDumpOSBufprintf(hScript,
805 "WRW%s :%s:%s%016llX:0x%08X :%s:$1",
814 if(eErr != PVRSRV_OK)
818 PDumpWriteScript(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS);
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)
835 /* flush out any partly accumulated stuff for LDB */
836 _ContiguousPDumpBytes(aszPxSymbolicAddr, ui32SymAddrOffset, IMG_TRUE,
838 ui32Flags | PDUMP_FLAGS_CONTINUOUS);
847 /**************************************************************************
848 * Function Name : _PdumpAllocMMUContext
849 * Inputs : pui32MMUContextID
851 * Returns : PVRSRV_ERROR
852 * Description : pdump util to allocate MMU contexts
853 **************************************************************************/
854 static PVRSRV_ERROR _PdumpAllocMMUContext(IMG_UINT32 *pui32MMUContextID)
858 /* there are MAX_PDUMP_MMU_CONTEXTS contexts available, find one */
859 for(i=0; i<MAX_PDUMP_MMU_CONTEXTS; i++)
861 if((guiPDumpMMUContextAvailabilityMask & (1U << i)))
864 guiPDumpMMUContextAvailabilityMask &= ~(1U << i);
865 *pui32MMUContextID = i;
870 PVR_DPF((PVR_DBG_ERROR, "_PdumpAllocMMUContext: no free MMU context ids"));
872 return PVRSRV_ERROR_MMU_CONTEXT_NOT_FOUND;
876 /**************************************************************************
877 * Function Name : _PdumpFreeMMUContext
878 * Inputs : ui32MMUContextID
880 * Returns : PVRSRV_ERROR
881 * Description : pdump util to free MMU contexts
882 **************************************************************************/
883 static PVRSRV_ERROR _PdumpFreeMMUContext(IMG_UINT32 ui32MMUContextID)
885 if(ui32MMUContextID < MAX_PDUMP_MMU_CONTEXTS)
888 PVR_ASSERT (!(guiPDumpMMUContextAvailabilityMask & (1U << ui32MMUContextID)));
889 guiPDumpMMUContextAvailabilityMask |= (1U << ui32MMUContextID);
893 PVR_DPF((PVR_DBG_ERROR, "_PdumpFreeMMUContext: MMU context ids invalid"));
895 return PVRSRV_ERROR_MMU_CONTEXT_NOT_FOUND;
899 /**************************************************************************
900 * Function Name : PDumpMMUAllocMMUContext
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)
911 IMG_UINT64 ui64PCSymAddr;
914 IMG_UINT32 ui32MMUContextID;
915 PVRSRV_ERROR eErr = PVRSRV_OK;
916 PDUMP_GET_SCRIPT_STRING();
918 eErr = _PdumpAllocMMUContext(&ui32MMUContextID);
919 if(eErr != PVRSRV_OK)
921 PVR_DPF((PVR_DBG_ERROR, "%s: _PdumpAllocMMUContext failed: %d",
928 create the symbolic address of the PC
930 ui64PCSymAddr = sPCDevPAddr.uiAddr;
932 if (eMMUType == PDUMP_MMU_TYPE_MIPS_MICROAPTIV)
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;
941 pszMMUPX = MMUPX_FMT(3);
946 eErr = PDumpOSBufprintf(hScript,
948 "MMU :%s:v%d %d :%s:%s%016llX",
950 pszPDumpMemSpaceName,
954 /* PC base address */
955 pszPDumpMemSpaceName,
958 if(eErr != PVRSRV_OK)
965 PDumpWriteScript(hScript, PDUMP_FLAGS_CONTINUOUS);
968 /* return the MMU Context ID */
969 *pui32MMUContextID = ui32MMUContextID;
976 /**************************************************************************
977 * Function Name : PDumpMMUFreeMMUContext
980 * Returns : PVRSRV_ERROR
981 * Description : Free MMU Context
982 **************************************************************************/
983 PVRSRV_ERROR PDumpMMUFreeMMUContext(const IMG_CHAR *pszPDumpMemSpaceName,
984 IMG_UINT32 ui32MMUContextID)
986 PVRSRV_ERROR eErr = PVRSRV_OK;
987 PDUMP_GET_SCRIPT_STRING();
990 eErr = PDumpOSBufprintf(hScript,
992 "-- Clear MMU Context for memory space %s", pszPDumpMemSpaceName);
993 if(eErr != PVRSRV_OK)
998 PDumpWriteScript(hScript, PDUMP_FLAGS_CONTINUOUS);
1000 eErr = PDumpOSBufprintf(hScript,
1003 pszPDumpMemSpaceName,
1005 if(eErr != PVRSRV_OK)
1010 PDumpWriteScript(hScript, PDUMP_FLAGS_CONTINUOUS);
1012 eErr = _PdumpFreeMMUContext(ui32MMUContextID);
1013 if(eErr != PVRSRV_OK)
1015 PVR_DPF((PVR_DBG_ERROR, "%s: _PdumpFreeMMUContext failed: %d",
1026 /**************************************************************************
1027 * Function Name : PDumpMMUActivateCatalog
1030 * Returns : PVRSRV_ERROR
1032 **************************************************************************/
1033 PVRSRV_ERROR PDumpMMUActivateCatalog(const IMG_CHAR *pszPDumpRegSpaceName,
1034 const IMG_CHAR *pszPDumpRegName,
1035 IMG_UINT32 uiRegAddr,
1036 const IMG_CHAR *pszPDumpPCSymbolicName)
1038 IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS;
1039 PVRSRV_ERROR eErr = PVRSRV_OK;
1041 PDUMP_GET_SCRIPT_STRING();
1045 eErr = PVRSRV_ERROR_PDUMP_NOT_AVAILABLE;
1050 if (PDumpIsDumpSuspended())
1057 eErr = PDumpOSBufprintf(hScript, ui32MaxLen,
1058 "-- Write Page Catalogue Address to %s",
1060 if(eErr != PVRSRV_OK)
1065 PDumpWriteScript(hScript, ui32Flags);
1067 eErr = PDumpOSBufprintf(hScript,
1069 "WRW :%s:0x%04X %s:0",
1071 pszPDumpRegSpaceName,
1074 pszPDumpPCSymbolicName);
1075 if (eErr != PVRSRV_OK)
1079 PDumpWriteScript(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS);
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)
1097 PVRSRV_ERROR eErr = PVRSRV_OK;
1099 // "SAB :%s:v%x:0x%010llX 0x%08X 0x%08X %s.bin",
1101 PDUMP_GET_SCRIPT_STRING();
1105 eErr = PVRSRV_ERROR_PDUMP_NOT_AVAILABLE;
1110 if (PDumpIsDumpSuspended())
1118 eErr = PDumpOSBufprintf(hScript,
1120 "SAB :%s:v%x:" IMG_DEV_VIRTADDR_FMTSPEC " "
1121 IMG_DEVMEM_SIZE_FMTSPEC " "
1123 pszPDumpMemNamespace,
1125 sDevAddrStart.uiAddr,
1129 if (eErr != PVRSRV_OK)
1134 PDumpWriteScript(hScript, ui32PDumpFlags);
1142 /**************************************************************************
1143 * Function Name : PdumpWireUpMipsTLB
1144 **************************************************************************/
1145 PVRSRV_ERROR PdumpWireUpMipsTLB(PMR *psPMRSource,
1147 IMG_DEVMEM_OFFSET_T uiLogicalOffsetSource,
1148 IMG_DEVMEM_OFFSET_T uiLogicalOffsetDest,
1149 IMG_UINT32 ui32AllocationFlags,
1150 IMG_UINT32 ui32Flags)
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;
1163 PDUMP_GET_SCRIPT_STRING()
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);
1174 if (eErr != PVRSRV_OK)
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);
1189 if (eErr != PVRSRV_OK)
1196 eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "WRW :%s:$1 :%s:%s:0x%llX", aszMemspaceNameSource,
1197 aszMemspaceNameSource, aszSymbolicNameSource,
1198 uiPDumpSymbolicOffsetSource);
1200 if (eErr != PVRSRV_OK)
1204 PDumpWriteScript(hScript, ui32Flags);
1206 eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "SHR :%s:$1 :%s:$1 0x6", aszMemspaceNameSource,
1207 aszMemspaceNameSource);
1209 if (eErr != PVRSRV_OK)
1213 PDumpWriteScript(hScript, ui32Flags);
1215 eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "AND :%s:$1 :%s:$1 0x03FFFFC0", aszMemspaceNameSource,
1216 aszMemspaceNameSource);
1218 if (eErr != PVRSRV_OK)
1222 PDumpWriteScript(hScript, ui32Flags);
1224 eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "OR :%s:$1 :%s:$1 0x%X", aszMemspaceNameSource,
1225 aszMemspaceNameSource, ui32AllocationFlags);
1227 if (eErr != PVRSRV_OK)
1231 PDumpWriteScript(hScript, ui32Flags);
1233 eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "WRW :%s:%s:0x%llX :%s:$1",aszMemspaceNameDest, aszSymbolicNameDest,
1234 uiPDumpSymbolicOffsetDest, aszMemspaceNameSource);
1237 if (eErr != PVRSRV_OK)
1241 PDumpWriteScript(hScript, ui32Flags);
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)
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;
1264 PDUMP_GET_SCRIPT_STRING()
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);
1276 if (eErr != PVRSRV_OK)
1283 eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "WRW :%s:$1 :%s:%s:0x%llX", aszMemspaceNameDest,
1284 aszMemspaceNameDest, aszSymbolicNameDest,
1285 uiPDumpSymbolicOffsetDest);
1287 if (eErr != PVRSRV_OK)
1291 PDumpWriteScript(hScript, ui32Flags);
1293 eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "AND :%s:$1 :%s:$1 0x%X", aszMemspaceNameDest,
1294 aszMemspaceNameDest, ui32MipsTLBValidClearMask);
1296 if (eErr != PVRSRV_OK)
1300 PDumpWriteScript(hScript, ui32Flags);
1304 eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "WRW :%s:%s:0x%llX :%s:$1",aszMemspaceNameDest, aszSymbolicNameDest,
1305 uiPDumpSymbolicOffsetDest, aszMemspaceNameDest);
1308 if (eErr != PVRSRV_OK)
1312 PDumpWriteScript(hScript, ui32Flags);
1322 #endif /* #if defined (PDUMP) */