[package] busybox: enable ps wide flag by default
[openwrt.git] / package / uboot-lantiq / gct
1 #!/usr/bin/perl
2
3 #use strict;
4 #use Cwd;
5 #use Env;
6
7 my $aline;
8 my $lineid;
9 my $length;
10 my $address;
11 my @bytes;
12 my $addstr;
13 my $chsum=0;
14 my $count=0;
15 my $firstime=1;
16 my $i;
17 my $currentaddr;
18 my $tmp;
19 my $holder="";
20 my $loadaddr;
21
22 if(@ARGV < 2){
23 die("\n Syntax: ./program_SDRAM input1(memory setup) input2(*\.srec) output\n");
24 }
25
26 open(INFILE1, "<$ARGV[0]") || die("\ninput1 open fail\n");
27 open(INFILE2, "<$ARGV[1]") || die("\ninput2 open fail\n");
28 open(OUTFILE, ">$ARGV[2]") || die("\nOutput file open fail\n");
29
30 $i=0;
31 while ($line = <INFILE1>){
32 if($line=~/\w/){
33 if($line!~/[;#\*]/){
34 if($i eq 0){
35 printf OUTFILE ("33333333");
36 }
37 chomp($line);
38 $line=~s/\t//;
39 @array=split(/ +/,$line);
40 $j=0;
41 while(@array[$j]!~/\w/){
42 $j=$j+1;
43 }
44 $addr=@array[$j];
45 $regval=@array[$j+1];
46 $addr=~s/0x//;
47 $regval=~s/0x//;
48 printf OUTFILE ("%08x%08x",hex($addr),hex($regval));
49 $i=$i+1;
50 if($i eq 8){
51 $i=0;
52 printf OUTFILE ("\n");
53 }
54 }
55 }
56 }
57
58 while($i lt 8 && $i gt 0){
59 printf OUTFILE "00"x8;
60 $i=$i+1;
61 }
62
63 if($i eq 8){
64 printf OUTFILE ("\n");
65 }
66
67 while($aline=<INFILE2>){
68 $aline=uc($aline);
69 chomp($aline);
70 next if(($aline=~/^S0/) || ($aline=~/^S7/));
71 ($lineid, $length, $address, @bytes) = unpack"A2A2A8"."A2"x300, $aline;
72 $length = hex($length);
73 $address = hex($address);
74 $length -=5;
75 $i=0;
76
77 while($length>0){
78 if($firstime==1){
79 $addstr = sprintf("%x", $address);
80 $addstr = "0"x(8-length($addstr)).$addstr;
81 print OUTFILE $addstr;
82 addchsum($addstr);
83 $firstime=0;
84 $currentaddr=$address;
85 $loadaddr = $addstr;
86 }
87 else{
88 if($count==64){
89 $addstr = sprintf("%x", $currentaddr);
90 $addstr = "0"x(8-length($addstr)).$addstr;
91 print OUTFILE $addstr;
92 addchsum($addstr);
93 $count=0;
94 }
95 #printf("*** %x != %x\n", $address, $currentaddr) if $address != $currentaddr;
96 }
97 if($currentaddr < $address) {
98 print OUTFILE "00";
99 addchsum("00");
100 $count++;
101 $currentaddr++;
102 }
103 else {
104 while($count<64){
105 $bytes[$i]=~tr/ABCDEF/abcdef/;
106 print OUTFILE "$bytes[$i]";
107 addchsum($bytes[$i]);
108 $i++;
109 $count++;
110 $currentaddr++;
111 $length--;
112 last if($length==0);
113 }
114 }
115 if($count==64){
116 print OUTFILE "\n";
117 #print OUTFILE "\r";
118 }
119 }
120 }
121 if($count != 64){
122 $tmp = "00";
123 for($i=0;$i<(64-$count);$i++){
124 print OUTFILE "00";
125 addchsum($tmp);
126 }
127 print OUTFILE "\n";
128 #print OUTFILE "\r";
129 }
130
131
132 print OUTFILE "11"x4;
133 use integer;
134 $chsum=$chsum & 0xffffffff;
135 $chsum = sprintf("%X", $chsum);
136 $chsum = "0"x(8-length($chsum)).$chsum;
137 $chsum =~tr/ABCDEF/abcdef/;
138 print OUTFILE $chsum;
139 print OUTFILE "00"x60;
140 print OUTFILE "\n";
141 #print OUTFILE "\r";
142
143 print OUTFILE "99"x4;
144 print OUTFILE $loadaddr;
145 print OUTFILE "00"x60;
146 print OUTFILE "\n";
147 #print OUTFILE "\r";
148
149
150 close OUTFILE;
151 #END of Program
152
153
154
155 sub addchsum{
156 my $cc=$_[0];
157 $holder=$holder.$cc;
158 if(length($holder)==8){
159 $holder = hex($holder);
160 $chsum+=$holder;
161 $holder="";
162 }
163 }
164 #END
165
This page took 0.052913 seconds and 5 git commands to generate.