1 /*----------------------------------------------------------------------------
3 *The confidential and proprietary information contained in this file may
4 *only be used by a person authorised under and to the extent permitted
5 *by a subsisting licensing agreement from ARM Limited.
7 * (C) COPYRIGHT 2008-2009,2011,2012-2013 ARM Limited.
10 *This entire notice must be reproduced on all copies of this file
11 *and copies of this file may only be made by a person if such person is
12 *permitted to do so under the terms of a subsisting license agreement
14 *Modified : $Date: 2013-08-01 18:15:13 +0100 (Thu, 01 Aug 2013) $
15 *Revision : $Revision: 66689 $
17 *-----------------------------------------------------------------------------
19 *-----------------------------------------------------------------------------
20 * Abstract :Implements all the generic APIs used for mali memory and register
22 *-----------------------------------------------------------------------------
26 **************************************************************/
31 #include <linux/string.h>
32 #include <linux/kernel.h>
35 int Mali_MemCpy(unsigned int *malidata_page,
37 unsigned int *refdata,
38 unsigned int refoffset,
41 memcpy((void *)((char *)malidata_page + (mali_va % 4096)),
42 (void *)((char *)refdata + (refoffset)),
43 len * sizeof(unsigned int));
48 int Mali_MemCpyMasked(unsigned int *malidata_page,
50 unsigned int *refdata,
51 unsigned int *refmask,
52 unsigned int refoffset,
55 unsigned int *maskptr = (unsigned int *)((char *)refmask + (refoffset));
56 unsigned int *refptr = (unsigned int *)((char *)refdata + (refoffset));
57 unsigned int *dataptr = (unsigned int *)((char *)malidata_page + (mali_va % 4096));
58 unsigned int len2 = len;
66 *dataptr = (*dataptr & ~m) | (*refptr & m);
76 int Mali_MemCmp(unsigned int *malidata_page,
78 unsigned int *refdata,
79 unsigned int refoffset,
91 res = memcmp((void *)((char *)malidata_page + (mali_va % 4096)),
92 (void *)((char *)refdata + (refoffset)),
93 len * sizeof(unsigned int));
97 printf("Error during check of %x bytes from address PA:%x, VA:%x with reference data at address %x\n",
99 ((unsigned int)malidata_page + (mali_va % 4096)),
109 int Mali_MemCmpMasked(unsigned int *malidata_page,
110 unsigned int mali_va,
111 unsigned int *refdata,
112 unsigned int *refmask,
113 unsigned int refoffset,
118 unsigned int *maskptr = (unsigned int *)((char *)refmask + (refoffset));
119 unsigned int *refptr = (unsigned int *)((char *)refdata + (refoffset));
120 unsigned int *dataptr = (unsigned int *)((char *)malidata_page + (mali_va % 4096));
121 unsigned int len2 = len;
130 if ((*dataptr++ & m) != (*refptr++ & m)) {
137 printf("Error during check of %x bytes from address PA:%x, VA:%x with reference data at address %x\n",
139 ((unsigned int)malidata_page + (mali_va % 4096)),
148 int Mali_CompareRegs(unsigned int *reference_ptr,
154 unsigned int reference_base = (unsigned int)reference_ptr;
158 unsigned int v_testvalue;
164 reference_base = reference_base + (lowreg % 0x10);
165 p = (unsigned int *)reference_base;
167 for (i=0; i < (highreg-lowreg); i += 4) {
168 v_mali = Mali_RdReg(mali_unit,mali_core,lowreg+i);
169 v_testvalue = *(p + (i/4));
170 printf ("Checking Register: %08x is value %08x\n",(mali_unit << 28) + (mali_core << 16) + lowreg + i,v_testvalue);
171 if ( v_mali != v_testvalue) {
172 printf ("Reg Compare Fail: %08x; value=%08x should be=%08x\n",(mali_unit << 28) + (mali_core << 16) + lowreg + i,v_mali,v_testvalue);
179 void Mali_DisplayReg(int unit,int core, int regnum) {
180 int v = Mali_RdReg(unit,core,regnum);
181 printf ("Reg: 0x%08x Value: %08x\n",(unit <<28)+(core<<16)+regnum,v);
184 void Mali_CheckReg(int unit,int core, int regnum, int value) {
185 int v = Mali_RdReg(unit,core,regnum);
187 printf ("Reg Compare Fail: 0x%08x Value: %08x should be=%08x\n",(unit <<28)+(core<<16)+regnum,v,value);
189 printf ("Reg Compare: 0x%08x Value: %08x\n",(unit <<28)+(core<<16)+regnum,v);
193 * This function simply prints out a given number of 32-bit words from a given location in memory
195 * It is useful for debugging the GPU's job descriptors and any memory related issues
197 void Mali_PrintMem (volatile unsigned int * memory_address, unsigned int word_count)
201 printf ("Memory readout for 0x%x:\n ", memory_address);
202 for (j=0;j<word_count;j++)
204 if ((j%4)==0 && j != 0)
208 printf ("word[%02d]=0x%08x ", j, *memory_address);
215 void Mali_ReadDescriptor (volatile unsigned int * descriptor_address)
217 Mali_PrintMem (descriptor_address, 12);