summaryrefslogtreecommitdiffstats
path: root/dsp56k/concat-bootstrap.pl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 08:09:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 08:09:22 +0000
commit6b4d032d4964caaa85be4ba8f3a7874afbf958cc (patch)
treea9846103274b39705a7e8be9fc28c006c18094b1 /dsp56k/concat-bootstrap.pl
parentInitial commit. (diff)
downloadfirmware-nonfree-6b4d032d4964caaa85be4ba8f3a7874afbf958cc.tar.xz
firmware-nonfree-6b4d032d4964caaa85be4ba8f3a7874afbf958cc.zip
Adding upstream version 20230625.upstream/20230625
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dsp56k/concat-bootstrap.pl')
-rw-r--r--dsp56k/concat-bootstrap.pl33
1 files changed, 33 insertions, 0 deletions
diff --git a/dsp56k/concat-bootstrap.pl b/dsp56k/concat-bootstrap.pl
new file mode 100644
index 0000000..b6d9003
--- /dev/null
+++ b/dsp56k/concat-bootstrap.pl
@@ -0,0 +1,33 @@
+# Postprocessor for dsp56k bootstrap code.
+#
+# Copyright Ben Hutchings 2011.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+use strict;
+use warnings;
+
+my @memory;
+my %symbol;
+
+# Reconstruct memory image and symbol table
+while (<>) {
+ if (/^P ([0-9A-F]{4}) ([0-9A-F]{6})\n/) {
+ $memory[hex($1)] = hex($2);
+ } elsif (/^I ([0-9A-F]{6}) (\w+)\n/) {
+ $symbol{$2} = hex($1);
+ } else {
+ print STDERR "W: did not recognise line $.\n";
+ }
+}
+
+# Concatenate first and second stage. Second stage is assembled
+# between 'upload' and 'upload_end', but initially loaded at
+# 'real' (end of the first stage).
+for (0 .. ($symbol{real} - 1), $symbol{upload} .. ($symbol{upload_end} - 1)) {
+ my $word = $memory[$_] || 0;
+ print pack('CCC', $word / 65536, ($word / 256) % 256, $word % 256);
+}