summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2008-07-31 07:28:46 +0200
committerMichael Brown2008-07-31 07:28:46 +0200
commit12a37ab99ef4e2b198c8f7cd589f4c1a3c74f57f (patch)
treee96213d39d4df1d709dc3e9262e0d8be678b2ed4
parent[util] Add Option::ROM library and rewrite disrom.pl to use it. (diff)
downloadipxe-12a37ab99ef4e2b198c8f7cd589f4c1a3c74f57f.tar.gz
ipxe-12a37ab99ef4e2b198c8f7cd589f4c1a3c74f57f.tar.xz
ipxe-12a37ab99ef4e2b198c8f7cd589f4c1a3c74f57f.zip
[util] Add mergerom.pl
This utility is required as a workaround for legal restrictions on including GPL and non-GPL code within the same expansion ROM image. While this is not encouraged, we are prepared to accept that concatenation of ROM images and updating of the ROM header data structures can be classed as "mere aggregation" within the terms of the GPL. If in any doubt, assume that you cannot include GPL and non-GPL code within the same expansion ROM image. Contact the Etherboot team for clarification on your specific circumstances.
-rwxr-xr-xsrc/util/mergerom.pl80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/util/mergerom.pl b/src/util/mergerom.pl
new file mode 100755
index 00000000..ce1befb7
--- /dev/null
+++ b/src/util/mergerom.pl
@@ -0,0 +1,80 @@
+#!/usr/bin/perl -w
+#
+# Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
+#
+# 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 any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin";
+use Option::ROM qw ( :all );
+
+my @romfiles = @ARGV;
+my @roms = map { my $rom = new Option::ROM; $rom->load($_); $rom } @romfiles;
+
+my $baserom = shift @roms;
+my $offset = $baserom->length;
+
+foreach my $rom ( @roms ) {
+
+ # Update base length
+ $baserom->{length} += $rom->{length};
+
+ # Update PCI header, if present in both
+ my $baserom_pci = $baserom->pci_header;
+ my $rom_pci = $rom->pci_header;
+ if ( $baserom_pci && $rom_pci ) {
+
+ # Update PCI lengths
+ $baserom_pci->{image_length} += $rom_pci->{image_length};
+ if ( exists $baserom_pci->{runtime_length} ) {
+ if ( exists $rom_pci->{runtime_length} ) {
+ $baserom_pci->{runtime_length} += $rom_pci->{runtime_length};
+ } else {
+ $baserom_pci->{runtime_length} += $rom_pci->{image_length};
+ }
+ }
+
+ # Merge CLP entry point
+ if ( exists ( $baserom_pci->{clp_entry} ) &&
+ exists ( $rom_pci->{clp_entry} ) ) {
+ $baserom_pci->{clp_entry} = ( $offset + $rom_pci->{clp_entry} )
+ if $rom_pci->{clp_entry};
+ }
+ }
+
+ # Update PnP header, if present in both
+ my $baserom_pnp = $baserom->pnp_header;
+ my $rom_pnp = $rom->pnp_header;
+ if ( $baserom_pnp && $rom_pnp ) {
+ $baserom_pnp->{bcv} = ( $offset + $rom_pnp->{bcv} ) if $rom_pnp->{bcv};
+ $baserom_pnp->{bdv} = ( $offset + $rom_pnp->{bdv} ) if $rom_pnp->{bdv};
+ $baserom_pnp->{bev} = ( $offset + $rom_pnp->{bev} ) if $rom_pnp->{bev};
+ }
+
+ # Fix checksum for this ROM segment
+ $rom->fix_checksum();
+
+ $offset += $rom->length;
+}
+
+$baserom->pnp_header->fix_checksum() if $baserom->pnp_header;
+$baserom->fix_checksum();
+$baserom->save ( "-" );
+foreach my $rom ( @roms ) {
+ $rom->save ( "-" );
+}