@@ -349,48 +349,49 @@ def get_pt(self, addr, uncached=False):
349349 def invalidate_cache (self ):
350350 self .pt_cache = {}
351351
352- # def dump_table2(self, base, l1_addr):
353-
354- # def print_block(base, pte, start, last):
355- # pgcount = last - start
356- # pte.OFFSET -= pgcount
357- # print(" page (%4d): %08x ... %08x -> %016x [%d%d]" % (
358- # start, base + start*0x4000, base + (start+1)*0x4000,
359- # pte.OFFSET << self.PAGE_BITS, pte.SP_PROT_DIS, pte.VALID))
360- # if start < last:
361- # print(" ==> (%4d): ... %08x -> %016x size: %08x" % (
362- # last, base + (last+1)*0x4000,
363- # (pte.OFFSET + pgcount - 1) << self.PAGE_BITS, pgcount << self.PAGE_BITS))
364-
365- # cached, tbl = self.get_pt(l1_addr)
366-
367- # unmapped = False
368- # start = 0
369- # next_pte = self.ptecls(VALID=0)
370-
371- # for i, pte in enumerate(tbl):
372- # pte = self.ptecls(pte)
373- # if not pte.VALID:
374- # if not unmapped:
375- # if next_pte.VALID:
376- # print_block(base, next_pte, start, i)
377- # print(" ...")
378- # unmapped = True
379- # next_pte = pte
380- # continue
352+ def dump_table2 (self , base , l1_addr ):
353+
354+ def print_block (base , pte , start , last ):
355+ pgcount = last - start
356+ pte .OFFSET -= pgcount
357+ print (" page (%4d): %09x ... %09x -> %016x [%d%d%d%d]" % (
358+ start , base + start * 0x4000 , base + (start + 1 )* 0x4000 ,
359+ pte .OFFSET << self .PAGE_BITS ,
360+ pte .RDPROT , pte .WRPROT , pte .UNCACHABLE , pte .VALID ))
361+ if start < last :
362+ print (" ==> (%4d): ... %09x -> %016x size: %08x" % (
363+ last , base + (last + 1 )* 0x4000 ,
364+ (pte .OFFSET + pgcount - 1 ) << self .PAGE_BITS , pgcount << self .PAGE_BITS ))
365+
366+ cached , tbl = self .get_pt (l1_addr )
367+
368+ unmapped = False
369+ start = 0
370+ next_pte = PTE (VALID = 0 )
371+
372+ for i , pte in enumerate (tbl ):
373+ pte = PTE (pte )
374+ if not pte .VALID :
375+ if not unmapped :
376+ if next_pte .VALID :
377+ print_block (base , next_pte , start , i )
378+ print (" ..." )
379+ unmapped = True
380+ next_pte = pte
381+ continue
381382
382- # unmapped = False
383+ unmapped = False
383384
384- # if int(pte) != int(next_pte):
385- # if next_pte.VALID:
386- # print_block(base, next_pte, start, i)
387- # start = i
385+ if int (pte ) != int (next_pte ):
386+ if next_pte .VALID :
387+ print_block (base , next_pte , start , i )
388+ start = i
388389
389- # next_pte = pte
390- # next_pte.OFFSET += 1
390+ next_pte = pte
391+ next_pte .OFFSET += 1
391392
392- # if next_pte.VALID:
393- # print_block(base, next_pte, start, 2048)
393+ if next_pte .VALID :
394+ print_block (base , next_pte , start , 2048 )
394395
395396 def dump_table (self , base , l1_addr ):
396397 cached , tbl = self .get_pt (l1_addr )
@@ -410,7 +411,7 @@ def dump_table(self, base, l1_addr):
410411 i , base + i * 0x2000000 , base + (i + 1 )* 0x2000000 ,
411412 pte .OFFSET << self .PAGE_BITS ,
412413 pte .RDPROT , pte .WRPROT , pte .UNCACHABLE , pte .VALID ))
413- # self.dump_table2(base + i*0x2000000, pte.OFFSET << self.PAGE_BITS)
414+ self .dump_table2 (base + i * 0x2000000 , pte .OFFSET << self .PAGE_BITS )
414415
415416 def dump_ttbr (self , ttbr ):
416417 if not ttbr .VALID :
0 commit comments