borrowed from ubuntu git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux-firmware
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

concat-bootstrap.pl 996B

123456789101112131415161718192021222324252627282930313233
  1. # Postprocessor for dsp56k bootstrap code.
  2. #
  3. # Copyright Ben Hutchings 2011.
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. use strict;
  10. use warnings;
  11. my @memory;
  12. my %symbol;
  13. # Reconstruct memory image and symbol table
  14. while (<>) {
  15. if (/^P ([0-9A-F]{4}) ([0-9A-F]{6})\n/) {
  16. $memory[hex($1)] = hex($2);
  17. } elsif (/^I ([0-9A-F]{6}) (\w+)\n/) {
  18. $symbol{$2} = hex($1);
  19. } else {
  20. print STDERR "W: did not recognise line $.\n";
  21. }
  22. }
  23. # Concatenate first and second stage. Second stage is assembled
  24. # between 'upload' and 'upload_end', but initially loaded at
  25. # 'real' (end of the first stage).
  26. for (0 .. ($symbol{real} - 1), $symbol{upload} .. ($symbol{upload_end} - 1)) {
  27. my $word = $memory[$_] || 0;
  28. print pack('CCC', $word / 65536, ($word / 256) % 256, $word % 256);
  29. }