Explorar el Código

[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.
tags/v0.9.4
Michael Brown hace 16 años
padre
commit
12a37ab99e
Se han modificado 1 ficheros con 80 adiciones y 0 borrados
  1. 80
    0
      src/util/mergerom.pl

+ 80
- 0
src/util/mergerom.pl Ver fichero

@@ -0,0 +1,80 @@
1
+#!/usr/bin/perl -w
2
+#
3
+# Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
4
+#
5
+# This program is free software; you can redistribute it and/or
6
+# modify it under the terms of the GNU General Public License as
7
+# published by the Free Software Foundation; either version 2 of the
8
+# License, or any later version.
9
+#
10
+# This program is distributed in the hope that it will be useful, but
11
+# WITHOUT ANY WARRANTY; without even the implied warranty of
12
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+# General Public License for more details.
14
+#
15
+# You should have received a copy of the GNU General Public License
16
+# along with this program; if not, write to the Free Software
17
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
+
19
+use strict;
20
+use warnings;
21
+
22
+use FindBin;
23
+use lib "$FindBin::Bin";
24
+use Option::ROM qw ( :all );
25
+
26
+my @romfiles = @ARGV;
27
+my @roms = map { my $rom = new Option::ROM; $rom->load($_); $rom } @romfiles;
28
+
29
+my $baserom = shift @roms;
30
+my $offset = $baserom->length;
31
+
32
+foreach my $rom ( @roms ) {
33
+
34
+  # Update base length
35
+  $baserom->{length} += $rom->{length};
36
+
37
+  # Update PCI header, if present in both
38
+  my $baserom_pci = $baserom->pci_header;
39
+  my $rom_pci = $rom->pci_header;
40
+  if ( $baserom_pci && $rom_pci ) {
41
+
42
+    # Update PCI lengths
43
+    $baserom_pci->{image_length} += $rom_pci->{image_length};
44
+    if ( exists $baserom_pci->{runtime_length} ) {
45
+      if ( exists $rom_pci->{runtime_length} ) {
46
+	$baserom_pci->{runtime_length} += $rom_pci->{runtime_length};
47
+      } else {
48
+	$baserom_pci->{runtime_length} += $rom_pci->{image_length};
49
+      }
50
+    }
51
+
52
+    # Merge CLP entry point
53
+    if ( exists ( $baserom_pci->{clp_entry} ) &&
54
+	 exists ( $rom_pci->{clp_entry} ) ) {
55
+      $baserom_pci->{clp_entry} = ( $offset + $rom_pci->{clp_entry} )
56
+	  if $rom_pci->{clp_entry};
57
+    }
58
+  }
59
+
60
+  # Update PnP header, if present in both
61
+  my $baserom_pnp = $baserom->pnp_header;
62
+  my $rom_pnp = $rom->pnp_header;
63
+  if ( $baserom_pnp && $rom_pnp ) {
64
+    $baserom_pnp->{bcv} = ( $offset + $rom_pnp->{bcv} ) if $rom_pnp->{bcv};
65
+    $baserom_pnp->{bdv} = ( $offset + $rom_pnp->{bdv} ) if $rom_pnp->{bdv};
66
+    $baserom_pnp->{bev} = ( $offset + $rom_pnp->{bev} ) if $rom_pnp->{bev};
67
+  }
68
+
69
+  # Fix checksum for this ROM segment
70
+  $rom->fix_checksum();
71
+
72
+  $offset += $rom->length;
73
+}
74
+
75
+$baserom->pnp_header->fix_checksum() if $baserom->pnp_header;
76
+$baserom->fix_checksum();
77
+$baserom->save ( "-" );
78
+foreach my $rom ( @roms ) {
79
+  $rom->save ( "-" );
80
+}

Loading…
Cancelar
Guardar