0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 my $basename = $ARGV[0];
0014 die "no base name specified" unless $basename;
0015
0016 while (<STDIN>) {
0017
0018
0019
0020 my($lenstring, $addrstring, $typestring, $reststring, $doscrap) =
0021 /^:(\w\w)(\w\w\w\w)(\w\w)(\w+)(\r?)$/;
0022 die "malformed line: $_" unless $reststring;
0023 last if $typestring eq '01';
0024 my($len) = hex($lenstring);
0025 my($addr) = hex($addrstring);
0026 my(@bytes) = unpack("C*", pack("H".(2*$len), $reststring));
0027
0028 push(@records, [$addr, \@bytes]);
0029 }
0030
0031 @sorted_records = sort { $a->[0] <=> $b->[0] } @records;
0032
0033 print <<"EOF";
0034 /*
0035 * ${basename}_fw.h
0036 *
0037 * Generated from ${basename}.s by ezusb_convert.pl
0038 * This file is presumed to be under the same copyright as the source file
0039 * from which it was derived.
0040 */
0041
0042 EOF
0043
0044 print "static const struct ezusb_hex_record ${basename}_firmware[] = {\n";
0045 foreach $r (@sorted_records) {
0046 printf("{ 0x%04x,\t%d,\t{", $r->[0], scalar(@{$r->[1]}));
0047 print join(", ", map {sprintf('0x%02x', $_);} @{$r->[1]});
0048 print "} },\n";
0049 }
0050 print "{ 0xffff,\t0,\t{0x00} }\n";
0051 print "};\n";