#!perl -w # (C) 2003-2007 Willem Jan Hengeveld # Web: http://www.xs4all.nl/~itsme/ # http://wiki.xda-developers.com/ # # $Id$ # # todo: remove fixed allocation of 'flashman' area. # this should be reported by splitrom. use strict; use Getopt::Long; my $verbose=0; GetOptions("v"=>\$verbose); my $blockmask= eval(shift || 0x3ffff); my @gaps; my $prev; while (<>) { if (/^(\w+) - (\w+) ..\s+(.{25})/) { my ($start, $end)= (hex($1), hex($2)); (my $desc= $3) =~ s/\s+$//; $end = ($end+$blockmask)&~$blockmask; my $cur= { start=>$start, end=>$end, desc=>$desc, }; if ($prev && $cur->{start} > $prev->{end}) { push @gaps, { start=>$prev->{end}, end=>$cur->{start}, desc=>"$prev->{desc} .. $cur->{desc}", }; } $prev= $cur; } } my $cur= { start=>0x81f00000, end=>0x82000000, desc=>"flashman area", }; if ($prev && $cur->{start} > $prev->{end}) { push @gaps, { start=>$prev->{end}, end=>$cur->{start}, desc=>"$prev->{desc} .. $cur->{desc}", }; } my $total= 0; if ($verbose) { print map { $total += $_->{end}-$_->{start}; sprintf("%08lx - %08lx (%08lx) %s\n", $_->{start}, $_->{end}, $_->{end}-$_->{start}, $_->{desc}); } @gaps; printf("total: %08lx\n", $total); } else { print map { sprintf("start%d=%08lx\nsize%d=%08lx\n", $_,$gaps[$_]{start}, $_,$gaps[$_]{end}-$gaps[$_]{start}); } (0..$#gaps); }