sl@0
|
1 |
#!perl
|
sl@0
|
2 |
#
|
sl@0
|
3 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
4 |
# All rights reserved.
|
sl@0
|
5 |
# This component and the accompanying materials are made available
|
sl@0
|
6 |
# under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
7 |
# which accompanies this distribution, and is available
|
sl@0
|
8 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
9 |
#
|
sl@0
|
10 |
# Initial Contributors:
|
sl@0
|
11 |
# Nokia Corporation - initial contribution.
|
sl@0
|
12 |
#
|
sl@0
|
13 |
# Contributors:
|
sl@0
|
14 |
#
|
sl@0
|
15 |
# Description:
|
sl@0
|
16 |
#
|
sl@0
|
17 |
|
sl@0
|
18 |
# rom.pl - Build a rom
|
sl@0
|
19 |
#
|
sl@0
|
20 |
# Pre-processes the .oby/iby files then invokes rombuild.exe
|
sl@0
|
21 |
# (or other specified builder)
|
sl@0
|
22 |
|
sl@0
|
23 |
# First, read our config file
|
sl@0
|
24 |
|
sl@0
|
25 |
use strict;
|
sl@0
|
26 |
use Getopt::Long;
|
sl@0
|
27 |
use Cwd;
|
sl@0
|
28 |
|
sl@0
|
29 |
#Getopt::Long::Configure("ignore_case");
|
sl@0
|
30 |
my %opts=();
|
sl@0
|
31 |
my $param_count = scalar(@ARGV);
|
sl@0
|
32 |
my $result = GetOptions (\%opts, "assp=s",
|
sl@0
|
33 |
"inst=s",
|
sl@0
|
34 |
"type=s",
|
sl@0
|
35 |
"variant=s",
|
sl@0
|
36 |
"build=s",
|
sl@0
|
37 |
"conf=s",
|
sl@0
|
38 |
"name=s",
|
sl@0
|
39 |
"modules=s",
|
sl@0
|
40 |
"xabi=s",
|
sl@0
|
41 |
"clean",
|
sl@0
|
42 |
"quiet",
|
sl@0
|
43 |
"help",
|
sl@0
|
44 |
"_debug",
|
sl@0
|
45 |
"zip",
|
sl@0
|
46 |
"symbol",
|
sl@0
|
47 |
"noheader",
|
sl@0
|
48 |
"kerneltrace=s",
|
sl@0
|
49 |
"rombuilder=s",
|
sl@0
|
50 |
"define=s@",
|
sl@0
|
51 |
"rofsbuilder=s",
|
sl@0
|
52 |
"compress"
|
sl@0
|
53 |
);
|
sl@0
|
54 |
|
sl@0
|
55 |
my (@assps, @builds, %variants, @templates, %flags, %insts, %zip, %builder);
|
sl@0
|
56 |
my $main;
|
sl@0
|
57 |
my $kmain;
|
sl@0
|
58 |
my $toroot;
|
sl@0
|
59 |
my $e32path;
|
sl@0
|
60 |
my $rombuildpath;
|
sl@0
|
61 |
my $euserdir;
|
sl@0
|
62 |
my $elocldir;
|
sl@0
|
63 |
my $kbdir;
|
sl@0
|
64 |
my $romname;
|
sl@0
|
65 |
my $single;
|
sl@0
|
66 |
my $smain;
|
sl@0
|
67 |
my $pagedCode;
|
sl@0
|
68 |
my $debug = $opts{_debug};
|
sl@0
|
69 |
my $quiet;
|
sl@0
|
70 |
$quiet = $opts{quiet} unless $debug;
|
sl@0
|
71 |
|
sl@0
|
72 |
my $drive;
|
sl@0
|
73 |
|
sl@0
|
74 |
# discover where this script is running from to set the $toroot and $e32path variables
|
sl@0
|
75 |
|
sl@0
|
76 |
my $toolpath;
|
sl@0
|
77 |
my $Epoc32Path;
|
sl@0
|
78 |
my $EpocRoot;
|
sl@0
|
79 |
my $drive;
|
sl@0
|
80 |
my $BasePath;
|
sl@0
|
81 |
|
sl@0
|
82 |
BEGIN {
|
sl@0
|
83 |
|
sl@0
|
84 |
$EpocRoot = $ENV{EPOCROOT};
|
sl@0
|
85 |
die "ERROR: Must set the EPOCROOT environment variable.\n" if (!defined($EpocRoot));
|
sl@0
|
86 |
$EpocRoot =~ s-/-\\-go; # for those working with UNIX shells
|
sl@0
|
87 |
die "ERROR: EPOCROOT must be an absolute path, " .
|
sl@0
|
88 |
"not containing a drive letter.\n" if ($EpocRoot !~ /^\\/);
|
sl@0
|
89 |
die "ERROR: EPOCROOT must not be a UNC path.\n" if ($EpocRoot =~ /^\\\\/);
|
sl@0
|
90 |
die "ERROR: EPOCROOT must end with a backslash.\n" if ($EpocRoot !~ /\\$/);
|
sl@0
|
91 |
die "ERROR: EPOCROOT must specify an existing directory.\n" if (!-d $EpocRoot);
|
sl@0
|
92 |
|
sl@0
|
93 |
# The cpp needed a drive apparently
|
sl@0
|
94 |
my $cwd = Cwd::cwd();
|
sl@0
|
95 |
$cwd =~ /^(.)/;
|
sl@0
|
96 |
$drive = "$1:";
|
sl@0
|
97 |
|
sl@0
|
98 |
my $fp0 = $0;
|
sl@0
|
99 |
$cwd =~ s/\//\\/g;
|
sl@0
|
100 |
$fp0 =~ s/\//\\/g;
|
sl@0
|
101 |
unless ($fp0 =~ /^([A-Za-z]:)?\\/) {
|
sl@0
|
102 |
if ($cwd =~ /\\$/) {
|
sl@0
|
103 |
$fp0 = "$cwd$fp0";
|
sl@0
|
104 |
} else {
|
sl@0
|
105 |
$fp0 = "$cwd\\$fp0";
|
sl@0
|
106 |
}
|
sl@0
|
107 |
}
|
sl@0
|
108 |
|
sl@0
|
109 |
my @path = split(/\\/, $cwd);
|
sl@0
|
110 |
shift(@path);
|
sl@0
|
111 |
$toroot = ('..\\') x @path;
|
sl@0
|
112 |
$e32path = $fp0;
|
sl@0
|
113 |
$e32path =~ s/\\kernelhwsrv\\kernel\\eka\\rombuild\\rom\.pl$//i;
|
sl@0
|
114 |
$e32path =~ s/^[A-Za-z]://;
|
sl@0
|
115 |
$rombuildpath = $toroot."os\\kernelhwsrv\\kernel\\eka\\rombuild";
|
sl@0
|
116 |
$Epoc32Path = $toroot;
|
sl@0
|
117 |
$Epoc32Path =~ s/\\$//;
|
sl@0
|
118 |
$Epoc32Path .= $EpocRoot . "epoc32";
|
sl@0
|
119 |
$toolpath = "$Epoc32Path\\tools\\";
|
sl@0
|
120 |
push @INC, $toolpath;
|
sl@0
|
121 |
$BasePath = $toroot;
|
sl@0
|
122 |
$BasePath =~ s/\\$/$e32path\\/;
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
use E32Plat;
|
sl@0
|
126 |
{
|
sl@0
|
127 |
Plat_Init($toolpath);
|
sl@0
|
128 |
}
|
sl@0
|
129 |
|
sl@0
|
130 |
if ($debug) {
|
sl@0
|
131 |
print "EpocRoot = $EpocRoot\n";
|
sl@0
|
132 |
print "Epoc32Path = $Epoc32Path\n";
|
sl@0
|
133 |
print "drive = $drive\n";
|
sl@0
|
134 |
print "toolpath = $toolpath\n";
|
sl@0
|
135 |
print "toroot = $toroot\n";
|
sl@0
|
136 |
print "e32path = $e32path\n";
|
sl@0
|
137 |
print "rombuildpath = $rombuildpath\n";
|
sl@0
|
138 |
print "BasePath = $BasePath\n";
|
sl@0
|
139 |
}
|
sl@0
|
140 |
|
sl@0
|
141 |
my $cppflags="-P -undef -traditional -lang-c++ -nostdinc -iwithprefixbefore $rombuildpath -I $rombuildpath -I $Epoc32Path ";
|
sl@0
|
142 |
|
sl@0
|
143 |
# Include variant hrh file defines when processing oby and ibys with cpp
|
sl@0
|
144 |
# (Code copied from \\EPOC\master\cedar\generic\tools\romkit\tools\buildrom.pm -
|
sl@0
|
145 |
# it used relative path to the working dir but we are using absolute path seems neater)
|
sl@0
|
146 |
use E32Variant;
|
sl@0
|
147 |
use Pathutl;
|
sl@0
|
148 |
my $variantMacroHRHFile = Variant_GetMacroHRHFile();
|
sl@0
|
149 |
if($variantMacroHRHFile){
|
sl@0
|
150 |
# Using absolute paths so must include drive letter otherwise cpp will fail
|
sl@0
|
151 |
# Also adding the directory containing the HRH file to main includes paths in
|
sl@0
|
152 |
# case it includes files
|
sl@0
|
153 |
my $variantFilePath = Path_Split('Path',$variantMacroHRHFile);
|
sl@0
|
154 |
$cppflags .= " -I $drive$variantFilePath -include $drive$variantMacroHRHFile";
|
sl@0
|
155 |
}
|
sl@0
|
156 |
|
sl@0
|
157 |
if($param_count == 0 || $opts{'help'} || !$result) {
|
sl@0
|
158 |
usage();
|
sl@0
|
159 |
exit 0;
|
sl@0
|
160 |
}
|
sl@0
|
161 |
|
sl@0
|
162 |
# Now check that the options we have make sense
|
sl@0
|
163 |
|
sl@0
|
164 |
checkopts();
|
sl@0
|
165 |
|
sl@0
|
166 |
if (!$quiet) {
|
sl@0
|
167 |
print "Starting directory: ", Cwd::cwd(), "\n";
|
sl@0
|
168 |
print <<EOF;
|
sl@0
|
169 |
OPTIONS:
|
sl@0
|
170 |
\tTYPE: $opts{'type'}
|
sl@0
|
171 |
\tVARIANT: $opts{'variant'}
|
sl@0
|
172 |
\tINSTRUCTION SET: $opts{'inst'}
|
sl@0
|
173 |
\tBUILD: $opts{'build'}
|
sl@0
|
174 |
\tMODULES: $opts{'modules'}
|
sl@0
|
175 |
EOF
|
sl@0
|
176 |
}
|
sl@0
|
177 |
|
sl@0
|
178 |
#Pick out the type file
|
sl@0
|
179 |
my $skel;
|
sl@0
|
180 |
|
sl@0
|
181 |
if (-e "$opts{'type'}.oby") {
|
sl@0
|
182 |
$skel="$opts{'type'}.oby";
|
sl@0
|
183 |
} elsif (-e "$rombuildpath\\$opts{'type'}.oby") {
|
sl@0
|
184 |
$skel="$rombuildpath\\$opts{'type'}.oby";
|
sl@0
|
185 |
} else {
|
sl@0
|
186 |
die "Can't find type file for type $opts{'type'}, $!";
|
sl@0
|
187 |
}
|
sl@0
|
188 |
|
sl@0
|
189 |
print "Using type file $skel\n" if !$quiet;
|
sl@0
|
190 |
|
sl@0
|
191 |
# If clean is specified, zap all the image and .oby files
|
sl@0
|
192 |
|
sl@0
|
193 |
if($opts{'clean'}) {
|
sl@0
|
194 |
unlink glob("*.img");
|
sl@0
|
195 |
unlink "rom.oby";
|
sl@0
|
196 |
unlink "rombuild.log";
|
sl@0
|
197 |
unlink glob("*.rofs");
|
sl@0
|
198 |
unlink "rofsbuild.log";
|
sl@0
|
199 |
}
|
sl@0
|
200 |
|
sl@0
|
201 |
# Now pre-pre-process this file to point to the right places for .ibys
|
sl@0
|
202 |
# Unfortunately cpp won't do macro replacement in #include strings, so
|
sl@0
|
203 |
# we have to do it by hand
|
sl@0
|
204 |
|
sl@0
|
205 |
my $k = $opts{kerneltrace};
|
sl@0
|
206 |
|
sl@0
|
207 |
if ($opts{assp}=~/^m(\S+)/i) {
|
sl@0
|
208 |
$kbdir="kb$1";
|
sl@0
|
209 |
$kbdir="kbarm" if (lc $1 eq 'eig');
|
sl@0
|
210 |
} else {
|
sl@0
|
211 |
$kbdir="kb$opts{assp}";
|
sl@0
|
212 |
}
|
sl@0
|
213 |
$single=1 if ($opts{assp}=~/^s(\S+)/i);
|
sl@0
|
214 |
|
sl@0
|
215 |
if ($single) {
|
sl@0
|
216 |
# Hackery to cope with old compiler
|
sl@0
|
217 |
if ($main eq 'MARM') {
|
sl@0
|
218 |
$smain='SARM';
|
sl@0
|
219 |
} else {
|
sl@0
|
220 |
$smain="S$main";
|
sl@0
|
221 |
}
|
sl@0
|
222 |
} else {
|
sl@0
|
223 |
$smain=$main;
|
sl@0
|
224 |
}
|
sl@0
|
225 |
|
sl@0
|
226 |
open(X, "$skel") || die "Can't open type file $skel, $!";
|
sl@0
|
227 |
open(OUT, "> rom1.tmp") || die "Can't open output file, $!";
|
sl@0
|
228 |
|
sl@0
|
229 |
# First output the ROM name
|
sl@0
|
230 |
print OUT "\nromname=$romname\n";
|
sl@0
|
231 |
while(<X>) {
|
sl@0
|
232 |
s/\#\#ASSP\#\#/$opts{'assp'}/;
|
sl@0
|
233 |
s/\#\#VARIANT\#\#/$opts{'variant'}/;
|
sl@0
|
234 |
s/\#\#BUILD\#\#/$opts{'build'}/;
|
sl@0
|
235 |
s/\#\#MAIN\#\#/$main/;
|
sl@0
|
236 |
s/\#\#KMAIN\#\#/$kmain/;
|
sl@0
|
237 |
s/\#\#E32PATH\#\#/$e32path/;
|
sl@0
|
238 |
s/\#\#BASEPATH\#\#/$BasePath/;
|
sl@0
|
239 |
s/\#\#EUSERDIR\#\#/$euserdir/;
|
sl@0
|
240 |
s/\#\#ELOCLDIR\#\#/$elocldir/;
|
sl@0
|
241 |
s/\#\#KBDIR\#\#/$kbdir/;
|
sl@0
|
242 |
print OUT;
|
sl@0
|
243 |
}
|
sl@0
|
244 |
|
sl@0
|
245 |
close X;
|
sl@0
|
246 |
close OUT;
|
sl@0
|
247 |
|
sl@0
|
248 |
# Use cpp to pull in include chains and replace defines
|
sl@0
|
249 |
|
sl@0
|
250 |
my $defines = "";
|
sl@0
|
251 |
$defines .= "-D MAIN=$main ";
|
sl@0
|
252 |
$defines .= "-D KMAIN=$kmain ";
|
sl@0
|
253 |
$defines .= "-D EUSERDIR=$euserdir ";
|
sl@0
|
254 |
$defines .= "-D ELOCLDIR=$elocldir ";
|
sl@0
|
255 |
$defines .= "-D E32PATH=$e32path ";
|
sl@0
|
256 |
$defines .= "-D BASEPATH=$BasePath ";
|
sl@0
|
257 |
$defines .= "-D EPOCROOT=$EpocRoot ";
|
sl@0
|
258 |
$defines .= "-D SMAIN=$smain " if $smain;
|
sl@0
|
259 |
|
sl@0
|
260 |
foreach (@{$opts{'define'}}) {
|
sl@0
|
261 |
my @array=split(/,/,$_);
|
sl@0
|
262 |
foreach (@array) {
|
sl@0
|
263 |
$defines.="-D ".uc $_." ";
|
sl@0
|
264 |
$pagedCode = 1 if $_ eq 'PAGED_CODE';
|
sl@0
|
265 |
}
|
sl@0
|
266 |
}
|
sl@0
|
267 |
|
sl@0
|
268 |
if ($opts{'modules'}) {
|
sl@0
|
269 |
my @array=split(/,/,$opts{'modules'});
|
sl@0
|
270 |
foreach (@array) {
|
sl@0
|
271 |
$defines.="-D ".uc $_." ";
|
sl@0
|
272 |
}
|
sl@0
|
273 |
}
|
sl@0
|
274 |
|
sl@0
|
275 |
foreach (keys %opts) {
|
sl@0
|
276 |
next if ($_ eq 'name');
|
sl@0
|
277 |
next if ($_ eq 'modules');
|
sl@0
|
278 |
next if ($_ eq 'zip');
|
sl@0
|
279 |
next if ($_ eq 'symbol');
|
sl@0
|
280 |
next if ($_ eq 'kerneltrace');
|
sl@0
|
281 |
next if ($_ eq 'define');
|
sl@0
|
282 |
$defines.="-D ".uc $_."=".$opts{$_}." ";
|
sl@0
|
283 |
$defines.="-D ".uc $_."_".$opts{$_}." ";
|
sl@0
|
284 |
}
|
sl@0
|
285 |
|
sl@0
|
286 |
$defines.="-D SINGLE " if ($single);
|
sl@0
|
287 |
|
sl@0
|
288 |
sub IsRVCTBuild($) {
|
sl@0
|
289 |
my ($build)=@_;
|
sl@0
|
290 |
return 1 if ($build =~ /^ARMV/i);
|
sl@0
|
291 |
my @customizations = Plat_Customizations('ARMV5');
|
sl@0
|
292 |
return 1 if (grep /$build/, @customizations);
|
sl@0
|
293 |
return 0;
|
sl@0
|
294 |
}
|
sl@0
|
295 |
|
sl@0
|
296 |
$defines.="-D RVCT " if (IsRVCTBuild($main));
|
sl@0
|
297 |
|
sl@0
|
298 |
print "Using defines $defines\n" if !$quiet;
|
sl@0
|
299 |
|
sl@0
|
300 |
my $ret=1;
|
sl@0
|
301 |
my $cppcmd;
|
sl@0
|
302 |
if($opts{'build'}=~/^u/i) {
|
sl@0
|
303 |
# Unicode build
|
sl@0
|
304 |
$cppcmd = "cpp $cppflags -D UNICODE $defines rom1.tmp rom2.tmp";
|
sl@0
|
305 |
} else {
|
sl@0
|
306 |
$cppcmd = "cpp $cppflags $defines rom1.tmp rom2.tmp";
|
sl@0
|
307 |
}
|
sl@0
|
308 |
print "Executing CPP:\n\t$cppcmd\n" if $debug;
|
sl@0
|
309 |
$ret = system($cppcmd);
|
sl@0
|
310 |
die "ERROR EXECUTING CPP\n" if $ret;
|
sl@0
|
311 |
|
sl@0
|
312 |
# Zap any ## marks REMS or blank lines
|
sl@0
|
313 |
|
sl@0
|
314 |
cleanup("rom2.tmp", "rom3.tmp", $k);
|
sl@0
|
315 |
|
sl@0
|
316 |
# scan tmp file and generate auxiliary files, if required
|
sl@0
|
317 |
open TMP, "rom3.tmp" or die("Can't open rom3.tmp\n");
|
sl@0
|
318 |
my $line;
|
sl@0
|
319 |
while ($line=<TMP>)
|
sl@0
|
320 |
{
|
sl@0
|
321 |
if ($line=~/\s*gentestpaged/i) {
|
sl@0
|
322 |
genfile("paged"); }
|
sl@0
|
323 |
if ($line=~/\s*gentestnonpaged/i) {
|
sl@0
|
324 |
genfile("nonpaged"); }
|
sl@0
|
325 |
}
|
sl@0
|
326 |
|
sl@0
|
327 |
parsePatchData("rom3.tmp", "rom4.tmp");
|
sl@0
|
328 |
|
sl@0
|
329 |
# break down the oby file into rom, rofs, extensions and smr oby files
|
sl@0
|
330 |
|
sl@0
|
331 |
my $oby_index =0;
|
sl@0
|
332 |
my $dumpfile="rom.oby";
|
sl@0
|
333 |
my $rofs=0;
|
sl@0
|
334 |
my $smr=0;
|
sl@0
|
335 |
my $extension=0;
|
sl@0
|
336 |
my $corerofsname="";
|
sl@0
|
337 |
my $smrname="";
|
sl@0
|
338 |
open DUMPFILE, ">$dumpfile" or die("Can't create $dumpfile\n");
|
sl@0
|
339 |
my $line;
|
sl@0
|
340 |
open TMP, "rom4.tmp" or die("Can't open rom4.tmp\n");
|
sl@0
|
341 |
while ($line=<TMP>)
|
sl@0
|
342 |
{
|
sl@0
|
343 |
if ($line=~/^\s*rofsname/i)
|
sl@0
|
344 |
{
|
sl@0
|
345 |
close DUMPFILE; # close rom.oby or previous rofs#/extension#.oby
|
sl@0
|
346 |
$oby_index=1;
|
sl@0
|
347 |
$corerofsname=$line;
|
sl@0
|
348 |
$corerofsname =~ s/rofsname\s*=\s*//i; # save core rofs name
|
sl@0
|
349 |
$corerofsname =~ s/\s*$//g; # remove trailing \n
|
sl@0
|
350 |
unlink $corerofsname || print "unable to delete $corerofsname";
|
sl@0
|
351 |
my $dumpfile="rofs".$rofs.".oby";
|
sl@0
|
352 |
$rofs++;
|
sl@0
|
353 |
open DUMPFILE, ">$dumpfile" or (close TMP and die("Can't create $dumpfile\n"));
|
sl@0
|
354 |
}
|
sl@0
|
355 |
|
sl@0
|
356 |
if ($line=~/^\s*imagename/i)
|
sl@0
|
357 |
{
|
sl@0
|
358 |
close DUMPFILE; # close rom.oby or previous rofs#/extension#.oby
|
sl@0
|
359 |
$smrname=$line;
|
sl@0
|
360 |
$smrname =~ s/imagename\s*=\s*//i; # save smr name
|
sl@0
|
361 |
$smrname =~ s/\s*$//g; # remove trailing \n
|
sl@0
|
362 |
unlink $smrname || print "unable to delete $smrname";
|
sl@0
|
363 |
my $dumpfile="smr".$smr.".oby";
|
sl@0
|
364 |
$smr++;
|
sl@0
|
365 |
open DUMPFILE, ">$dumpfile" or (close TMP and die("Can't create $dumpfile\n"));
|
sl@0
|
366 |
}
|
sl@0
|
367 |
|
sl@0
|
368 |
if ($line=~/^\s*coreimage/i)
|
sl@0
|
369 |
{
|
sl@0
|
370 |
close DUMPFILE; # close rofs.oby
|
sl@0
|
371 |
if ($oby_index ne 1) {
|
sl@0
|
372 |
close TMP;
|
sl@0
|
373 |
die "Must specify ROFS image before ROFS extension\n";
|
sl@0
|
374 |
}
|
sl@0
|
375 |
my $name=$line;
|
sl@0
|
376 |
$name =~ s/coreimage\s*=\s*//i; # read core rofs name
|
sl@0
|
377 |
$name =~ s/\s*$//g; # remove trailing \n
|
sl@0
|
378 |
if ($name ne $corerofsname) {
|
sl@0
|
379 |
close TMP;
|
sl@0
|
380 |
die "This extension does not relate to previous ROFS\n";
|
sl@0
|
381 |
}
|
sl@0
|
382 |
$oby_index=33; # open window
|
sl@0
|
383 |
my $dumpfile="extension".$extension.".oby";
|
sl@0
|
384 |
$extension++;
|
sl@0
|
385 |
open DUMPFILE, ">$dumpfile" or (close TMP and die("Can't create $dumpfile\n"));
|
sl@0
|
386 |
}
|
sl@0
|
387 |
|
sl@0
|
388 |
if ($line=~/^\s*extensionrofs/i)
|
sl@0
|
389 |
{
|
sl@0
|
390 |
$oby_index=3 if ($oby_index eq 2);
|
sl@0
|
391 |
}
|
sl@0
|
392 |
|
sl@0
|
393 |
if (($oby_index eq 2) && !($line=~/^\s*$/)) {
|
sl@0
|
394 |
close TMP;
|
sl@0
|
395 |
die "Bad ROFS extension specification\n";
|
sl@0
|
396 |
}
|
sl@0
|
397 |
print DUMPFILE $line;
|
sl@0
|
398 |
$oby_index=2 if ($oby_index eq 33); # close window
|
sl@0
|
399 |
}
|
sl@0
|
400 |
close DUMPFILE;
|
sl@0
|
401 |
close TMP;
|
sl@0
|
402 |
|
sl@0
|
403 |
# For paged roms that use rofs, move all data= lines in rom which are not 'paging_unmovable' to rofs, so that paged ram-loaded code
|
sl@0
|
404 |
# is automatically put into rofs
|
sl@0
|
405 |
rename('rom.oby', 'rom4.tmp') || die;
|
sl@0
|
406 |
|
sl@0
|
407 |
open(IN, 'rom4.tmp') || die "Can't read rom4.tmp";
|
sl@0
|
408 |
open(ROM, '>rom.oby') || die "Can't write to rom.oby";
|
sl@0
|
409 |
|
sl@0
|
410 |
if ($oby_index >= 1 && $pagedCode) {
|
sl@0
|
411 |
open(ROFS, '>>rofs0.oby') || die "Can't append to rofs0.oby";
|
sl@0
|
412 |
}
|
sl@0
|
413 |
|
sl@0
|
414 |
while ($line=<IN>)
|
sl@0
|
415 |
{
|
sl@0
|
416 |
if(($oby_index >= 1) && ($pagedCode) && ($line=~/^\s*data\s*=/) && !($line=~/\.*paging_unmovable\s*/)) {
|
sl@0
|
417 |
print ROFS $line;
|
sl@0
|
418 |
}
|
sl@0
|
419 |
else {
|
sl@0
|
420 |
$line=~s/paging_unmovable//;
|
sl@0
|
421 |
print ROM $line;
|
sl@0
|
422 |
}
|
sl@0
|
423 |
}
|
sl@0
|
424 |
|
sl@0
|
425 |
close IN;
|
sl@0
|
426 |
close ROM;
|
sl@0
|
427 |
|
sl@0
|
428 |
if ($oby_index >= 1 && $pagedCode) {
|
sl@0
|
429 |
close ROFS;
|
sl@0
|
430 |
}
|
sl@0
|
431 |
unlink 'rom4.tmp';
|
sl@0
|
432 |
|
sl@0
|
433 |
my $flags;
|
sl@0
|
434 |
|
sl@0
|
435 |
foreach (@{$flags{$opts{'assp'}}}) {
|
sl@0
|
436 |
$flags.=" -$_";
|
sl@0
|
437 |
}
|
sl@0
|
438 |
|
sl@0
|
439 |
if($opts{'noheader'}) {
|
sl@0
|
440 |
$flags.=" -no-header";
|
sl@0
|
441 |
}
|
sl@0
|
442 |
|
sl@0
|
443 |
if($opts{'compress'}) {
|
sl@0
|
444 |
$flags.=" -compress";
|
sl@0
|
445 |
}
|
sl@0
|
446 |
|
sl@0
|
447 |
my $builder = $opts{'rombuilder'};
|
sl@0
|
448 |
$builder = "rombuild" unless ($builder);
|
sl@0
|
449 |
|
sl@0
|
450 |
|
sl@0
|
451 |
|
sl@0
|
452 |
print "$builder $flags -type-safe-link -S rom.oby 2>&1\n\n";
|
sl@0
|
453 |
|
sl@0
|
454 |
open(Y, "$builder $flags -type-safe-link -S rom.oby 2>&1 |") ||
|
sl@0
|
455 |
die "Can't start $builder command, $!";
|
sl@0
|
456 |
|
sl@0
|
457 |
my $nerrors=0;
|
sl@0
|
458 |
my $nwarnings=0;
|
sl@0
|
459 |
|
sl@0
|
460 |
while(<Y>) {
|
sl@0
|
461 |
my $error=(/^error:/i);
|
sl@0
|
462 |
my $warning=(/^warning:/i);
|
sl@0
|
463 |
print if ($error or $warning or !$quiet);
|
sl@0
|
464 |
$nerrors++ if ($error);
|
sl@0
|
465 |
$nwarnings++ if ($warning);
|
sl@0
|
466 |
}
|
sl@0
|
467 |
|
sl@0
|
468 |
print "\nGenerated .oby file is rom.oby\n" if !$quiet;
|
sl@0
|
469 |
print "\nGenerated image file is $romname\n" if (!$nerrors);
|
sl@0
|
470 |
|
sl@0
|
471 |
my$rerrors;
|
sl@0
|
472 |
my $rofsbuilder;
|
sl@0
|
473 |
if ($rofs) {
|
sl@0
|
474 |
$rofsbuilder = $opts{'rofsbuilder'};
|
sl@0
|
475 |
$rofsbuilder = "rofsbuild" unless ($rofsbuilder);
|
sl@0
|
476 |
for(my $i=0;$i<$rofs;++$i) {
|
sl@0
|
477 |
print "Executing $rofsbuilder on main rofs\n" if !$quiet;
|
sl@0
|
478 |
my $image="rofs".$i.".oby";
|
sl@0
|
479 |
system("$rofsbuilder $image");
|
sl@0
|
480 |
if ($? != 0)
|
sl@0
|
481 |
{
|
sl@0
|
482 |
print "$rofsbuilder $image returned $?\n";
|
sl@0
|
483 |
$rerrors++;
|
sl@0
|
484 |
}
|
sl@0
|
485 |
rename "rofsbuild.log", "rofs$i.log"
|
sl@0
|
486 |
}
|
sl@0
|
487 |
}
|
sl@0
|
488 |
|
sl@0
|
489 |
if ($rofs and $extension) {
|
sl@0
|
490 |
for(my $i=0;$i<$extension;++$i) {
|
sl@0
|
491 |
print "Executing $rofsbuilder on extension rofs\n" if !$quiet;
|
sl@0
|
492 |
my $image="extension".$i.".oby";
|
sl@0
|
493 |
system("$rofsbuilder $image");
|
sl@0
|
494 |
if ($? != 0)
|
sl@0
|
495 |
{
|
sl@0
|
496 |
print "$rofsbuilder $image returned $?\n";
|
sl@0
|
497 |
$rerrors++;
|
sl@0
|
498 |
}
|
sl@0
|
499 |
rename "rofsbuild.log", "extension$i.log"
|
sl@0
|
500 |
}
|
sl@0
|
501 |
}
|
sl@0
|
502 |
|
sl@0
|
503 |
if ($smr) {
|
sl@0
|
504 |
$rofsbuilder = $opts{'rofsbuilder'};
|
sl@0
|
505 |
$rofsbuilder = "rofsbuild" unless ($rofsbuilder);
|
sl@0
|
506 |
for(my $i=0;$i<$smr;++$i) {
|
sl@0
|
507 |
print "Executing $rofsbuilder on smr partition\n" if !$quiet;
|
sl@0
|
508 |
my $image="smr".$i.".oby";
|
sl@0
|
509 |
system("$rofsbuilder -smr=$image");
|
sl@0
|
510 |
if ($? != 0)
|
sl@0
|
511 |
{
|
sl@0
|
512 |
print "$rofsbuilder -smr=$image returned $?\n";
|
sl@0
|
513 |
$rerrors++;
|
sl@0
|
514 |
}
|
sl@0
|
515 |
rename "rofsbuild.log", "smr$i.log"
|
sl@0
|
516 |
}
|
sl@0
|
517 |
}
|
sl@0
|
518 |
|
sl@0
|
519 |
if ($nerrors) {
|
sl@0
|
520 |
print "\n\n Errors found during $builder!!\n\nLeaving tmp files\n";
|
sl@0
|
521 |
} elsif ($nwarnings) {
|
sl@0
|
522 |
print "\n\n Warnings during $builder!!\n\nLeaving tmp files\n";
|
sl@0
|
523 |
} elsif ($rerrors) {
|
sl@0
|
524 |
print "\n\n Errors during $rofsbuilder!!\n\nLeaving tmp files\n";
|
sl@0
|
525 |
} else {
|
sl@0
|
526 |
unlink glob("*.tmp") if !$debug;
|
sl@0
|
527 |
}
|
sl@0
|
528 |
if ($opts{zip} or $zip{$opts{assp}}) {
|
sl@0
|
529 |
my $zipname=$romname;
|
sl@0
|
530 |
$zipname =~ s/\.(\w+)$/\.zip/i;
|
sl@0
|
531 |
unlink $zipname;
|
sl@0
|
532 |
system("zip $zipname $romname");
|
sl@0
|
533 |
}
|
sl@0
|
534 |
if ($opts{symbol}) {
|
sl@0
|
535 |
my $logname=$romname;
|
sl@0
|
536 |
$logname =~ s/\.(\w+)$/\.log/i;
|
sl@0
|
537 |
my $obyname=$romname;
|
sl@0
|
538 |
$obyname =~ s/\.(\w+)$/\.oby/i;
|
sl@0
|
539 |
unlink $logname;
|
sl@0
|
540 |
unlink $obyname;
|
sl@0
|
541 |
system("rename rombuild.log $logname");
|
sl@0
|
542 |
system("rename rom.oby $obyname");
|
sl@0
|
543 |
system("maksym $logname");
|
sl@0
|
544 |
}
|
sl@0
|
545 |
|
sl@0
|
546 |
if ($nerrors || $nwarnings || $rerrors) {
|
sl@0
|
547 |
exit 4;
|
sl@0
|
548 |
}
|
sl@0
|
549 |
|
sl@0
|
550 |
exit 0;
|
sl@0
|
551 |
|
sl@0
|
552 |
|
sl@0
|
553 |
################################ Subroutines ##################################
|
sl@0
|
554 |
|
sl@0
|
555 |
sub usage {
|
sl@0
|
556 |
print <<EOT;
|
sl@0
|
557 |
|
sl@0
|
558 |
rom <options>
|
sl@0
|
559 |
|
sl@0
|
560 |
Generate a rom image for the specified target, along with a rom.oby file
|
sl@0
|
561 |
that can be fed to (a) rombuild to regenerate the image.
|
sl@0
|
562 |
|
sl@0
|
563 |
The following options are required:
|
sl@0
|
564 |
--variant=<variant> e.g. --variant=assabet
|
sl@0
|
565 |
--inst=<instruction set> e.g. --inst=arm4
|
sl@0
|
566 |
--build=<build> e.g. --build=udeb
|
sl@0
|
567 |
--type=<type of rom>
|
sl@0
|
568 |
tshell for a text shell rom
|
sl@0
|
569 |
e32tests for a rom with e32tests
|
sl@0
|
570 |
f32tests for rom with f32tests
|
sl@0
|
571 |
alltests for all the tests
|
sl@0
|
572 |
|
sl@0
|
573 |
The following are optional:
|
sl@0
|
574 |
--name=<image name> Give image file specified name
|
sl@0
|
575 |
--noheader Pass -no-header option on to rombuild
|
sl@0
|
576 |
--help This help message.
|
sl@0
|
577 |
--clean Remove existing generated files first
|
sl@0
|
578 |
--quiet Be less verbose
|
sl@0
|
579 |
--modules=<comma separated list> List of additional modules for this ROM
|
sl@0
|
580 |
--define=<comma separated list> List of CPP macros to define
|
sl@0
|
581 |
|
sl@0
|
582 |
Options may be specified as a short abbreviation
|
sl@0
|
583 |
e.g. -b udeb instead of --build udeb
|
sl@0
|
584 |
|
sl@0
|
585 |
EOT
|
sl@0
|
586 |
}
|
sl@0
|
587 |
|
sl@0
|
588 |
sub cleanup($$$) {
|
sl@0
|
589 |
my ($in, $out, $k) = @_;
|
sl@0
|
590 |
my ($line, $lastblank);
|
sl@0
|
591 |
|
sl@0
|
592 |
open(OUTPUT_FILE, "> $out") or die "Cannot open $out for output";
|
sl@0
|
593 |
open(INPUT_FILE, "< $in") or die "Cannot open for $in input";
|
sl@0
|
594 |
|
sl@0
|
595 |
while ($line=<INPUT_FILE>) {
|
sl@0
|
596 |
$line=~s/##//g;
|
sl@0
|
597 |
|
sl@0
|
598 |
# file=\epoc32\... ==> file=%EPOCROOT%\epoc32\...
|
sl@0
|
599 |
$line =~ s/(=\s*)\\epoc32/\1${EpocRoot}Epoc32/i;
|
sl@0
|
600 |
|
sl@0
|
601 |
# Now compress blank lines down to one
|
sl@0
|
602 |
|
sl@0
|
603 |
if($line=~/^\s*$/) {
|
sl@0
|
604 |
if($lastblank) {
|
sl@0
|
605 |
# Do nothing
|
sl@0
|
606 |
} else {
|
sl@0
|
607 |
# This is the first blank line
|
sl@0
|
608 |
$lastblank=1;
|
sl@0
|
609 |
print OUTPUT_FILE $line;
|
sl@0
|
610 |
}
|
sl@0
|
611 |
} else {
|
sl@0
|
612 |
# Not blank
|
sl@0
|
613 |
$lastblank=0;
|
sl@0
|
614 |
if ($k and $line=~/^\s*kerneltrace/i) {
|
sl@0
|
615 |
$line = "kerneltrace $k\n";
|
sl@0
|
616 |
}
|
sl@0
|
617 |
print OUTPUT_FILE $line if !($line=~/^\s*REM\s+/i);
|
sl@0
|
618 |
}
|
sl@0
|
619 |
}
|
sl@0
|
620 |
close(INPUT_FILE);
|
sl@0
|
621 |
close(OUTPUT_FILE);
|
sl@0
|
622 |
}
|
sl@0
|
623 |
|
sl@0
|
624 |
sub IsSmp($) {
|
sl@0
|
625 |
my %SmpKernelDirs=(
|
sl@0
|
626 |
'x86smp' => 1,
|
sl@0
|
627 |
'x86gmp' => 1,
|
sl@0
|
628 |
'arm4smp' => 1,
|
sl@0
|
629 |
'armv4smp' => 1,
|
sl@0
|
630 |
'armv5smp' => 1
|
sl@0
|
631 |
);
|
sl@0
|
632 |
|
sl@0
|
633 |
my ($kdir) = @_;
|
sl@0
|
634 |
return $SmpKernelDirs{lc $kdir};
|
sl@0
|
635 |
}
|
sl@0
|
636 |
|
sl@0
|
637 |
sub checkopts {
|
sl@0
|
638 |
unless($opts{variant}) { die "No Variant specified"; }
|
sl@0
|
639 |
$opts{'build'}="UDEB" unless($opts{'build'});
|
sl@0
|
640 |
$opts{'type'}="TSHELL" unless($opts{'type'});
|
sl@0
|
641 |
$opts{'inst'}="ARM4" unless($opts{'inst'});
|
sl@0
|
642 |
|
sl@0
|
643 |
my $additional;
|
sl@0
|
644 |
if ($opts{'modules'}) {
|
sl@0
|
645 |
$additional="_".$opts{modules};
|
sl@0
|
646 |
$additional=~ s/,/_/ig;
|
sl@0
|
647 |
}
|
sl@0
|
648 |
my $build=lc $opts{build};
|
sl@0
|
649 |
my $inst=uc $opts{'inst'};
|
sl@0
|
650 |
if ($inst eq "MARM") {
|
sl@0
|
651 |
# Hackery to cope with old compiler
|
sl@0
|
652 |
$main="MARM";
|
sl@0
|
653 |
$euserdir="MARM";
|
sl@0
|
654 |
$elocldir="MARM";
|
sl@0
|
655 |
}
|
sl@0
|
656 |
else {
|
sl@0
|
657 |
$main=$inst;
|
sl@0
|
658 |
if ($main eq "THUMB") {
|
sl@0
|
659 |
$euserdir="ARMI";
|
sl@0
|
660 |
} else {
|
sl@0
|
661 |
$euserdir=$main;
|
sl@0
|
662 |
}
|
sl@0
|
663 |
if ($main eq "ARMI" or $main eq "THUMB") {
|
sl@0
|
664 |
$elocldir="ARM4";
|
sl@0
|
665 |
} else {
|
sl@0
|
666 |
$elocldir=$main;
|
sl@0
|
667 |
}
|
sl@0
|
668 |
}
|
sl@0
|
669 |
$kmain = $opts{'xabi'};
|
sl@0
|
670 |
$kmain = $main unless ($kmain);
|
sl@0
|
671 |
if (IsSmp($kmain)) {
|
sl@0
|
672 |
$euserdir = $kmain;
|
sl@0
|
673 |
}
|
sl@0
|
674 |
if ($opts{name}) {
|
sl@0
|
675 |
$romname=$opts{name};
|
sl@0
|
676 |
} else {
|
sl@0
|
677 |
$romname=uc($opts{variant}.$additional.$main);
|
sl@0
|
678 |
if ($build=~/^\w*DEB$/i) {
|
sl@0
|
679 |
$romname.='D';
|
sl@0
|
680 |
}
|
sl@0
|
681 |
$romname.='.IMG';
|
sl@0
|
682 |
}
|
sl@0
|
683 |
}
|
sl@0
|
684 |
|
sl@0
|
685 |
sub lookupFileInfo($$)
|
sl@0
|
686 |
{
|
sl@0
|
687 |
my ($infile, $fullname) = @_;
|
sl@0
|
688 |
|
sl@0
|
689 |
my ($name, $ext) = $fullname =~ /^(.+)\.(\w+)$/ ? ($1, $2) : ($fullname, undef);
|
sl@0
|
690 |
|
sl@0
|
691 |
open TMP, $infile or die("Can't open $infile\n");
|
sl@0
|
692 |
while(<TMP>)
|
sl@0
|
693 |
{
|
sl@0
|
694 |
$_ = lc;
|
sl@0
|
695 |
if(/^\s*(\S+)\s*=\s*(\S+)\s+(\S+)/i)
|
sl@0
|
696 |
{
|
sl@0
|
697 |
my ($src, $dest) = ($2, $3);
|
sl@0
|
698 |
|
sl@0
|
699 |
my $destFullname = $dest =~ /^.*\\(.+)$/ ? $1 : $dest;
|
sl@0
|
700 |
my ($destName, $destExt) = $destFullname =~ /^(.+?)\.(\w+)$/ ? ($1, $2) : ($destFullname, undef);
|
sl@0
|
701 |
|
sl@0
|
702 |
if ($destName eq $name && (!$ext || $ext eq $destExt))
|
sl@0
|
703 |
{
|
sl@0
|
704 |
close TMP;
|
sl@0
|
705 |
return ($src, $dest);
|
sl@0
|
706 |
}
|
sl@0
|
707 |
}
|
sl@0
|
708 |
}
|
sl@0
|
709 |
|
sl@0
|
710 |
die "patchdata: Can't find file $fullname\n";
|
sl@0
|
711 |
}
|
sl@0
|
712 |
|
sl@0
|
713 |
sub lookupSymbolInfo($$)
|
sl@0
|
714 |
{
|
sl@0
|
715 |
my ($file, $name) = @_;
|
sl@0
|
716 |
|
sl@0
|
717 |
open TMP, $file or die "Can't read $file\n";
|
sl@0
|
718 |
|
sl@0
|
719 |
# ignore local symbols.
|
sl@0
|
720 |
while (<TMP> !~ /Global Symbols/) { }
|
sl@0
|
721 |
|
sl@0
|
722 |
while (<TMP>)
|
sl@0
|
723 |
{
|
sl@0
|
724 |
if (/^\s*(\S+)\s+(\S+)\s+data\s+(\S+)/i)
|
sl@0
|
725 |
{
|
sl@0
|
726 |
my ($symbol, $addr, $size) = ($1, $2, $3);
|
sl@0
|
727 |
if ($symbol eq $name)
|
sl@0
|
728 |
{
|
sl@0
|
729 |
close TMP;
|
sl@0
|
730 |
return ($addr, $size);
|
sl@0
|
731 |
}
|
sl@0
|
732 |
}
|
sl@0
|
733 |
|
sl@0
|
734 |
# This is a quick fix for RVCT 3.1, which uses the text "(EXPORTED)"
|
sl@0
|
735 |
# in the map file. Here is an example:
|
sl@0
|
736 |
#
|
sl@0
|
737 |
# KHeapMinCellSize (EXPORTED) 0x0003d81c Data 4 mem.o(.constdata)
|
sl@0
|
738 |
#
|
sl@0
|
739 |
elsif (/^\s*(\S+)\s+\(exported\)\s+(\S+)\s+data\s+(\S+)/i)
|
sl@0
|
740 |
{
|
sl@0
|
741 |
my ($symbol, $addr, $size) = ($1, $2, $3);
|
sl@0
|
742 |
if ($symbol eq $name)
|
sl@0
|
743 |
{
|
sl@0
|
744 |
close TMP;
|
sl@0
|
745 |
return ($addr, $size);
|
sl@0
|
746 |
}
|
sl@0
|
747 |
}
|
sl@0
|
748 |
}
|
sl@0
|
749 |
|
sl@0
|
750 |
die "patchdata: Can't find symbol $name\n";
|
sl@0
|
751 |
}
|
sl@0
|
752 |
|
sl@0
|
753 |
sub parsePatchData($$)
|
sl@0
|
754 |
{
|
sl@0
|
755 |
my ($infile, $outfile) = @_;
|
sl@0
|
756 |
|
sl@0
|
757 |
open IN, $infile or die("Can't read $infile\n");
|
sl@0
|
758 |
open OUT, ">$outfile" or die("Can't write $outfile\n");
|
sl@0
|
759 |
|
sl@0
|
760 |
my $line;
|
sl@0
|
761 |
while($line = <IN>)
|
sl@0
|
762 |
{
|
sl@0
|
763 |
if ($line =~ /^\s*patchdata\s+(.+?)\s*$/i)
|
sl@0
|
764 |
{
|
sl@0
|
765 |
if ($1 !~ /(\S+)\s*@\s*(\S+)\s+(\S+)\s*$/)
|
sl@0
|
766 |
{
|
sl@0
|
767 |
die "Bad patchdata command: $line\n";
|
sl@0
|
768 |
}
|
sl@0
|
769 |
|
sl@0
|
770 |
my ($file, $symbol, $value) = (lc $1, $2, $3);
|
sl@0
|
771 |
my ($srcFile, $destFile) = lookupFileInfo($infile, $file);
|
sl@0
|
772 |
my ($index, $elementSize) = (undef, undef);
|
sl@0
|
773 |
if ($symbol =~ s/:(\d+)\[(\d+)\]$//)
|
sl@0
|
774 |
{
|
sl@0
|
775 |
($index, $elementSize) = ($2, $1);
|
sl@0
|
776 |
$index = hex($index) if $index =~ /^0x/i;
|
sl@0
|
777 |
}
|
sl@0
|
778 |
|
sl@0
|
779 |
if ($srcFile =~ /\\armv5(smp)?\\/i)
|
sl@0
|
780 |
{
|
sl@0
|
781 |
my ($symbolAddr, $symbolSize) = lookupSymbolInfo("$srcFile.map", $symbol);
|
sl@0
|
782 |
|
sl@0
|
783 |
my $max;
|
sl@0
|
784 |
if (defined($index))
|
sl@0
|
785 |
{
|
sl@0
|
786 |
my $bytes;
|
sl@0
|
787 |
$bytes = 1, $max = 0xff if $elementSize == 8;
|
sl@0
|
788 |
$bytes = 2, $max = 0xffff if $elementSize == 16;
|
sl@0
|
789 |
$bytes = 4, $max = 0xffffffff if $elementSize == 32;
|
sl@0
|
790 |
die("patchdata: invalid element size $elementSize: $line\n") unless defined($bytes);
|
sl@0
|
791 |
|
sl@0
|
792 |
if ($bytes > 1 && (($symbolSize & ($bytes-1)) != 0))
|
sl@0
|
793 |
{
|
sl@0
|
794 |
die("patchdata: unexpected symbol size $symbolSize for array $symbol ($elementSize-bit elements)\n");
|
sl@0
|
795 |
}
|
sl@0
|
796 |
|
sl@0
|
797 |
if ($index >= int($symbolSize / $bytes))
|
sl@0
|
798 |
{
|
sl@0
|
799 |
die("patchdata: index $index out of bounds for $symbol of $symbolSize bytes ($elementSize-bit elements)\n");
|
sl@0
|
800 |
}
|
sl@0
|
801 |
|
sl@0
|
802 |
$symbolAddr = hex($symbolAddr) if $symbolAddr =~ /^0x/i;
|
sl@0
|
803 |
$symbolAddr += $index * $bytes;
|
sl@0
|
804 |
$symbolAddr = sprintf("0x%x", $symbolAddr);
|
sl@0
|
805 |
|
sl@0
|
806 |
$symbolSize = $bytes;
|
sl@0
|
807 |
}
|
sl@0
|
808 |
elsif ($symbolSize == 1) { $max = 0xff; }
|
sl@0
|
809 |
elsif ($symbolSize == 2) { $max = 0xffff; }
|
sl@0
|
810 |
elsif ($symbolSize == 4) { $max = 0xffffffff; }
|
sl@0
|
811 |
else { die "patchdata: Unexpected symbol size $symbolSize for $symbol\n"; }
|
sl@0
|
812 |
|
sl@0
|
813 |
$value = hex($value) if $value =~ /^0x/i;
|
sl@0
|
814 |
if ($value > $max)
|
sl@0
|
815 |
{
|
sl@0
|
816 |
print("Warning: Value overflow of $symbol\n");
|
sl@0
|
817 |
$value &= $max;
|
sl@0
|
818 |
}
|
sl@0
|
819 |
$value = sprintf("0x%08x", $value);
|
sl@0
|
820 |
|
sl@0
|
821 |
$line = "patchdata $destFile addr $symbolAddr $symbolSize $value\n";
|
sl@0
|
822 |
}
|
sl@0
|
823 |
else
|
sl@0
|
824 |
{
|
sl@0
|
825 |
$line = "";
|
sl@0
|
826 |
}
|
sl@0
|
827 |
|
sl@0
|
828 |
}
|
sl@0
|
829 |
|
sl@0
|
830 |
print OUT $line;
|
sl@0
|
831 |
}
|
sl@0
|
832 |
|
sl@0
|
833 |
close IN;
|
sl@0
|
834 |
close OUT;
|
sl@0
|
835 |
}
|
sl@0
|
836 |
|
sl@0
|
837 |
sub genfile {
|
sl@0
|
838 |
my $count=0;
|
sl@0
|
839 |
if($_[0] eq 'paged') {
|
sl@0
|
840 |
my $file='gentestpaged.txt';
|
sl@0
|
841 |
unlink $file;
|
sl@0
|
842 |
open(OUTFILE, ">$file") or die "Can't open output file, $!";
|
sl@0
|
843 |
for(my $i=0;$i<50000;++$i) {
|
sl@0
|
844 |
if(($i >5) && ($i % 40 ==0)) {
|
sl@0
|
845 |
print OUTFILE "\n";
|
sl@0
|
846 |
$count++;
|
sl@0
|
847 |
}
|
sl@0
|
848 |
if(($i+$count) % 5 ==0) {
|
sl@0
|
849 |
print OUTFILE "SATOR ";
|
sl@0
|
850 |
}
|
sl@0
|
851 |
if(($i+$count) % 5 ==1) {
|
sl@0
|
852 |
print OUTFILE "AREPO ";
|
sl@0
|
853 |
}
|
sl@0
|
854 |
if(($i+$count) % 5 ==2) {
|
sl@0
|
855 |
print OUTFILE "TENET ";
|
sl@0
|
856 |
}
|
sl@0
|
857 |
if(($i+$count) % 5 ==3) {
|
sl@0
|
858 |
print OUTFILE "OPERA ";
|
sl@0
|
859 |
}
|
sl@0
|
860 |
if(($i+$count) % 5 ==4) {
|
sl@0
|
861 |
print OUTFILE "ROTAS ";
|
sl@0
|
862 |
}
|
sl@0
|
863 |
}
|
sl@0
|
864 |
} else {
|
sl@0
|
865 |
my $file='gentestnonpaged.txt';
|
sl@0
|
866 |
unlink $file;
|
sl@0
|
867 |
open(OUTFILE, ">$file") or die "Can't open output file, $!";
|
sl@0
|
868 |
for(my $i=0;$i<20000;++$i) {
|
sl@0
|
869 |
if(($i >5) && ($i % 40 ==0)) {
|
sl@0
|
870 |
print OUTFILE "\n";
|
sl@0
|
871 |
$count++;
|
sl@0
|
872 |
}
|
sl@0
|
873 |
if(($i+$count) % 4 ==0) {
|
sl@0
|
874 |
print OUTFILE "STEP ";
|
sl@0
|
875 |
}
|
sl@0
|
876 |
if(($i+$count) % 4 ==1) {
|
sl@0
|
877 |
print OUTFILE "TIME ";
|
sl@0
|
878 |
}
|
sl@0
|
879 |
if(($i+$count) % 4 ==2) {
|
sl@0
|
880 |
print OUTFILE "EMIT ";
|
sl@0
|
881 |
}
|
sl@0
|
882 |
if(($i+$count) % 4 ==3) {
|
sl@0
|
883 |
print OUTFILE "PETS ";
|
sl@0
|
884 |
}
|
sl@0
|
885 |
}
|
sl@0
|
886 |
}
|
sl@0
|
887 |
}
|
sl@0
|
888 |
|
sl@0
|
889 |
__END__
|
sl@0
|
890 |
|
sl@0
|
891 |
# Tell emacs that this is a perl script even 'though it has a .bat extension
|
sl@0
|
892 |
# Local Variables:
|
sl@0
|
893 |
# mode:perl
|
sl@0
|
894 |
# tab-width:4
|
sl@0
|
895 |
# End:
|
sl@0
|
896 |
|