remove redundant registers
[sitara-dss-files/am57xx-dss-files.git] / am57xx-ipu-ammu-analysis.dss
1 /*
2  * Copyright (c) 2006-2014, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
34 function d2h(d) {return ("00000000" + (d).toString(16)).slice(-8);}
36 var newline = "\n";
38 function printRegisterValue(ds, name, addr)
39 {
40         value = debugSessionDAP.memory.readWord(0,addr,false);
41         value_string = d2h(value);
42         file.write(name + " = 0x" + value_string + newline);
43         return value; // return the register value for interrogation
44 }
46 // Build a filename that includes date/time
47 var today = new Date();
48 var year4digit = today.getFullYear();
49 var month2digit = ("0" + (today.getMonth()+1)).slice(-2);
50 var day2digit = ("0" + today.getDate()).slice(-2);
51 var hour2digit = ("0" + today.getHours()).slice(-2);
52 var minutes2digit = ("0" + today.getMinutes()).slice(-2);
53 var seconds2digit = ("0" + today.getSeconds()).slice(-2);
54 var filename_date = '_' + year4digit + '-' + month2digit + '-' + day2digit + '_' + hour2digit + minutes2digit + seconds2digit; 
55 var userHomeFolder = System.getProperty("user.home");
56 var filename = userHomeFolder + '/Desktop/' + 'am57xx-ipu-ammu-analysis' + filename_date + '.txt';
58 debugSessionDAP = ds.openSession("*","CS_DAP_DebugSS");
60 try {
61         debugSessionDAP.target.connect();
62 } catch (ex) {
63         print(newline + " ERROR: Could not connect to DAP_DebugSS." + newline);
64 }
66 file = new java.io.FileWriter(filename);
69 var reg_val;
71 reg_val = printRegisterValue(debugSessionDAP, "CM_IPU1_IPU1_CLKCTRL", 0x4A005520);
72 if ( (reg_val & 0x30000) == 0<<16 ) { file.write("  * IPU1 is fully functional." + newline); }
73 if ( (reg_val & 0x30000) == (1<<16) ) { file.write("  * IPU1 is transitioning." + newline); }
74 if ( (reg_val & 0x30000) == 2<<16 ) { file.write("  * IPU1 is in idle." + newline); }
75 if ( (reg_val & 0x30000) == 3<<16 ) { file.write("  * IPU1 is disabled." + newline); }
77 decodeLargePages(debugSessionDAP, 0x58880800);
78 decodeMediumPages(debugSessionDAP, 0x58880860);
79 decodeSmallPages(debugSessionDAP, 0x58880920);
81 function decodeLargePages(ds, addr)
82 {
84         decodeLargePage(ds, addr, 0);
85         decodeLargePage(ds, addr, 1);
86         decodeLargePage(ds, addr, 2);
87         decodeLargePage(ds, addr, 3);
88 }
90 function decodeMediumPages(ds, addr)
91 {
93         decodeMediumPage(ds, addr, 0);
94         decodeMediumPage(ds, addr, 1);
95 }
97 function decodeSmallPages(ds, addr)
98 {
99         decodeSmallPage(ds, addr, 0);
100         decodeSmallPage(ds, addr, 1);
101         decodeSmallPage(ds, addr, 2);
102         decodeSmallPage(ds, addr, 3);
103         decodeSmallPage(ds, addr, 4);
104         decodeSmallPage(ds, addr, 5);
105         decodeSmallPage(ds, addr, 6);
106         decodeSmallPage(ds, addr, 7);
107         decodeSmallPage(ds, addr, 8);
108         decodeSmallPage(ds, addr, 9);
113 function decodeLargePage(ds, addr, page)
115         var phys_addr, logical_addr, policy_reg, size;
117         file.write(newline + "***** Decoding Large Page " + page + " *****" + newline + newline);
118         var reg_name = "CACHE_MMU_LARGE_ADDR_" + page;
119         logical_addr = printRegisterValue(ds, reg_name, addr+page*4);
121         addr = addr + 0x20;
122         reg_name = "CACHE_MMU_LARGE_XLTE_" + page;
123         physical_addr = printRegisterValue(ds, reg_name, addr+page*4);
124         
125         addr = addr + 0x20;
126         reg_name = "CACHE_MMU_LARGE_POLICY_" + page;
127         policy = printRegisterValue(ds, reg_name, addr+page*4);
129         file.write(newline);
131         if( (policy&1) == 0 ) {
132                 file.write("PAGE NOT ENABLED" + newline);
133         } else {
134                 file.write("PAGE ENABLED" + newline);
136                 file.write("Logical Address  = 0x" + d2h(logical_addr) + " - 0x");
137                 if( (policy & 1<<1) == 1<<1 ) { 
138                         size = 512 * 1024 * 1024; // 512 MB
139                 } else {
140                         size = 32 * 1024 * 1024; // 32MB
141                 }
142                 file.write(d2h(logical_addr+size-1) + newline);
144                 if ( (physical_addr&1) == 1 ) { // "ignore" bit
145                         physical_addr = logical_addr;
146                 }
147                 file.write("Physical address = 0x" + d2h(physical_addr) + " - 0x");
148                 file.write(d2h(physical_addr+size-1) + newline);
150                 file.write("Policy" + newline);
152                 if( (policy & 1<<19) == 1<<19 ) { 
153                         file.write(" * L1 write policy is writeback" + newline);
154                 } else { 
155                         file.write(" * L1 write policy is writethrough" + newline);
156                 }
158                 if( (policy & 1<<18) == 1<<18 ) { 
159                         file.write(" * L1 allocate policy: follow sideband" + newline);
160                 } else { 
161                         file.write(" * L1 allocate policy: no writes allocated" + newline);
162                 }
164                 if( (policy & 1<<17) == 1<<17 ) { 
165                         file.write(" * L1 writes posted" + newline);
166                 } else { 
167                         file.write(" * L1 writes non-posted" + newline);
168                 }
170                 if( (policy & 1<<16) == 1<<16 ) { 
171                         file.write(" * L1 cacheable" + newline);
172                 } else { 
173                         file.write(" * L1 noncacheable" + newline);
174                 }
176                 if( (policy & 1<<7) == 1<<7 ) { 
177                         file.write(" * Send cache exclusion sideband" + newline);
178                 } else { 
179                         file.write(" * Do not send cache exclusion sideband" + newline);
180                 }
182                 if( (policy & 1<<6) == 1<<6 ) { 
183                         file.write(" * Preload enabled" + newline);
184                 } else { 
185                         file.write(" * Preload disabled" + newline);
186                 }
188                 if( (policy & 1<<5) == 1<<5 ) { 
189                         file.write(" * Read-only" + newline);
190                 } else { 
191                         file.write(" * Read/Write" + newline);
192                 }
194                 if( (policy & 1<<4) == 1<<4 ) { 
195                         file.write(" * Execute-only" + newline);
196                 } else { 
197                         file.write(" * Read/Write/Execute" + newline);
198                 }
200                 if( (policy & 1<<3) == 1<<3 ) { 
201                         file.write(" * Follow volatile qualifier" + newline);
202                 } else { 
203                         file.write(" * Do not follow volatile qualifier" + newline);
204                 }
206                 if( (policy & 1<<1) == 1<<1 ) { 
207                         file.write(" * 512 MB page" + newline);
208                 } else { 
209                         file.write(" * 32 MB page" + newline);
210                 }
211         }
215 function decodeMediumPage(ds, addr, page)
217         var phys_addr, logical_addr, policy_reg, size;
219         file.write(newline + "***** Decoding Medium Page " + page + " *****" + newline + newline);
220         var reg_name = "CACHE_MMU_MED_ADDR_" + page;
221         logical_addr = printRegisterValue(ds, reg_name, addr+page*4);
223         addr = addr + 0x40;
224         reg_name = "CACHE_MMU_MED_XLTE_" + page;
225         physical_addr = printRegisterValue(ds, reg_name, addr+page*4);
226         
227         addr = addr + 0x40;
228         reg_name = "CACHE_MMU_MED_POLICY_" + page;
229         policy = printRegisterValue(ds, reg_name, addr+page*4);
231         file.write(newline);
233         if( (policy&1) == 0 ) {
234                 file.write("PAGE NOT ENABLED" + newline);
235         } else {
236                 file.write("PAGE ENABLED" + newline);
238                 file.write("Logical Address  = 0x" + d2h(logical_addr) + " - 0x");
239                 if( (policy & 1<<1) == 1<<1 ) { 
240                         size = 256 * 1024; // 256 KB
241                 } else {
242                         size = 128 * 1024; // 128 KB
243                 }
244                 file.write(d2h(logical_addr+size-1) + newline);
246                 if ( (physical_addr&1) == 1 ) { // "ignore" bit
247                         physical_addr = logical_addr;
248                 }
249                 file.write("Physical address = 0x" + d2h(physical_addr) + " - 0x");
250                 file.write(d2h(physical_addr+size-1) + newline);
252                 file.write("Policy" + newline);
254                 if( (policy & 1<<19) == 1<<19 ) { 
255                         file.write(" * L1 write policy is writeback" + newline);
256                 } else { 
257                         file.write(" * L1 write policy is writethrough" + newline);
258                 }
260                 if( (policy & 1<<18) == 1<<18 ) { 
261                         file.write(" * L1 allocate policy: follow sideband" + newline);
262                 } else { 
263                         file.write(" * L1 allocate policy: no writes allocated" + newline);
264                 }
266                 if( (policy & 1<<17) == 1<<17 ) { 
267                         file.write(" * L1 writes posted" + newline);
268                 } else { 
269                         file.write(" * L1 writes non-posted" + newline);
270                 }
272                 if( (policy & 1<<16) == 1<<16 ) { 
273                         file.write(" * L1 cacheable" + newline);
274                 } else { 
275                         file.write(" * L1 noncacheable" + newline);
276                 }
278                 if( (policy & 1<<7) == 1<<7 ) { 
279                         file.write(" * Send cache exclusion sideband" + newline);
280                 } else { 
281                         file.write(" * Do not send cache exclusion sideband" + newline);
282                 }
284                 if( (policy & 1<<6) == 1<<6 ) { 
285                         file.write(" * Preload enabled" + newline);
286                 } else { 
287                         file.write(" * Preload disabled" + newline);
288                 }
290                 if( (policy & 1<<5) == 1<<5 ) { 
291                         file.write(" * Read-only" + newline);
292                 } else { 
293                         file.write(" * Read/Write" + newline);
294                 }
296                 if( (policy & 1<<4) == 1<<4 ) { 
297                         file.write(" * Execute-only" + newline);
298                 } else { 
299                         file.write(" * Read/Write/Execute" + newline);
300                 }
302                 if( (policy & 1<<3) == 1<<3 ) { 
303                         file.write(" * Follow volatile qualifier" + newline);
304                 } else { 
305                         file.write(" * Do not follow volatile qualifier" + newline);
306                 }
308                 if( (policy & 1<<1) == 1<<1 ) { 
309                         file.write(" * 256 KB page" + newline);
310                 } else { 
311                         file.write(" * 128 KB page" + newline);
312                 }
313         }
316 function decodeSmallPage(ds, addr, page)
318         var phys_addr, logical_addr, policy_reg, size;
320         file.write(newline + "***** Decoding Small Page " + page + " *****" + newline + newline);
321         var reg_name = "CACHE_MMU_SMALL_ADDR_" + page;
322         logical_addr = printRegisterValue(ds, reg_name, addr+page*4);
324         addr = addr + 0x80;
325         reg_name = "CACHE_MMU_SMALL_XLTE_" + page;
326         physical_addr = printRegisterValue(ds, reg_name, addr+page*4);
327         
328         addr = addr + 0x80;
329         reg_name = "CACHE_MMU_SMALL_POLICY_" + page;
330         policy = printRegisterValue(ds, reg_name, addr+page*4);
332         file.write(newline);
334         if( (policy&1) == 0 ) {
335                 file.write("PAGE NOT ENABLED" + newline);
336         } else {
337                 file.write("PAGE ENABLED" + newline);
339                 file.write("Logical Address  = 0x" + d2h(logical_addr) + " - 0x");
340                 if( (policy & 1<<1) == 1<<1 ) { 
341                         size = 16 * 1024; // 16 KB
342                 } else {
343                         size = 4 * 1024; // 4 KB
344                 }
345                 file.write(d2h(logical_addr+size-1) + newline);
347                 if ( (physical_addr&1) == 1 ) { // "ignore" bit
348                         physical_addr = logical_addr;
349                 }
350                 file.write("Physical address = 0x" + d2h(physical_addr) + " - 0x");
351                 file.write(d2h(physical_addr+size-1) + newline);
353                 file.write("Policy" + newline);
355                 if( (policy & 1<<19) == 1<<19 ) { 
356                         file.write(" * L1 write policy is writeback" + newline);
357                 } else { 
358                         file.write(" * L1 write policy is writethrough" + newline);
359                 }
361                 if( (policy & 1<<18) == 1<<18 ) { 
362                         file.write(" * L1 allocate policy: follow sideband" + newline);
363                 } else { 
364                         file.write(" * L1 allocate policy: no writes allocated" + newline);
365                 }
367                 if( (policy & 1<<17) == 1<<17 ) { 
368                         file.write(" * L1 writes posted" + newline);
369                 } else { 
370                         file.write(" * L1 writes non-posted" + newline);
371                 }
373                 if( (policy & 1<<16) == 1<<16 ) { 
374                         file.write(" * L1 cacheable" + newline);
375                 } else { 
376                         file.write(" * L1 noncacheable" + newline);
377                 }
379                 if( (policy & 1<<7) == 1<<7 ) { 
380                         file.write(" * Send cache exclusion sideband" + newline);
381                 } else { 
382                         file.write(" * Do not send cache exclusion sideband" + newline);
383                 }
385                 if( (policy & 1<<6) == 1<<6 ) { 
386                         file.write(" * Preload enabled" + newline);
387                 } else { 
388                         file.write(" * Preload disabled" + newline);
389                 }
391                 if( (policy & 1<<5) == 1<<5 ) { 
392                         file.write(" * Read-only" + newline);
393                 } else { 
394                         file.write(" * Read/Write" + newline);
395                 }
397                 if( (policy & 1<<4) == 1<<4 ) { 
398                         file.write(" * Execute-only" + newline);
399                 } else { 
400                         file.write(" * Read/Write/Execute" + newline);
401                 }
403                 if( (policy & 1<<3) == 1<<3 ) { 
404                         file.write(" * Follow volatile qualifier" + newline);
405                 } else { 
406                         file.write(" * Do not follow volatile qualifier" + newline);
407                 }
409                 if( (policy & 1<<1) == 1<<1 ) { 
410                         file.write(" * 16 KB page" + newline);
411                 } else { 
412                         file.write(" * 4 KB page" + newline);
413                 }
414         }
418 file.close();
419 print("Created file " + filename);
420 debugSessionDAP.target.disconnect();