summaryrefslogtreecommitdiffstats
path: root/src/util/mergerom.pl
diff options
context:
space:
mode:
authorMichael Brown2008-08-15 05:10:35 +0200
committerMichael Brown2008-08-15 05:10:35 +0200
commit23bca8f9d86da54859996acb07a0bc07daee4955 (patch)
tree3d77f9208d182df5eb73a384cb807276318ff471 /src/util/mergerom.pl
parent[settings] Avoid overwriting the start of .text in fetch_string_setting() (diff)
downloadipxe-23bca8f9d86da54859996acb07a0bc07daee4955.tar.gz
ipxe-23bca8f9d86da54859996acb07a0bc07daee4955.tar.xz
ipxe-23bca8f9d86da54859996acb07a0bc07daee4955.zip
[util] Allow Option::ROM to understand and modify initialisation entry point
Add support for manipulating the jump instruction that forms the option ROM initialisation entry point, so that mergerom.pl can treat it just like other entry points. Add support for merging the initialisation entry point (and IBM BOFM table) to mergerom.pl; this is another slightly icky but unfortunately necessary GPL vs. NDA workaround. When mergerom.pl replaces an entry point in the original ROM, it now fills in the corresponding entry point in the merged ROM with the original value; this allows (for example) a merged initialisation entry point to do some processing and then jump back to the original entry point.
Diffstat (limited to 'src/util/mergerom.pl')
-rwxr-xr-xsrc/util/mergerom.pl28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/util/mergerom.pl b/src/util/mergerom.pl
index ce1befb7..f9c52502 100755
--- a/src/util/mergerom.pl
+++ b/src/util/mergerom.pl
@@ -23,6 +23,18 @@ use FindBin;
use lib "$FindBin::Bin";
use Option::ROM qw ( :all );
+sub merge_entry_points {
+ my $baserom_entry = \shift;
+ my $rom_entry = \shift;
+ my $offset = shift;
+
+ if ( $$rom_entry ) {
+ my $old_entry = $$baserom_entry;
+ $$baserom_entry = ( $offset + $$rom_entry );
+ $$rom_entry = $old_entry;
+ }
+}
+
my @romfiles = @ARGV;
my @roms = map { my $rom = new Option::ROM; $rom->load($_); $rom } @romfiles;
@@ -34,6 +46,12 @@ foreach my $rom ( @roms ) {
# Update base length
$baserom->{length} += $rom->{length};
+ # Merge initialisation entry point
+ merge_entry_points ( $baserom->{init}, $rom->{init}, $offset );
+
+ # Merge BOFM header
+ merge_entry_points ( $baserom->{bofm_header}, $rom->{bofm_header}, $offset );
+
# Update PCI header, if present in both
my $baserom_pci = $baserom->pci_header;
my $rom_pci = $rom->pci_header;
@@ -52,8 +70,8 @@ foreach my $rom ( @roms ) {
# 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};
+ merge_entry_points ( $baserom_pci->{clp_entry}, $rom_pci->{clp_entry},
+ $offset );
}
}
@@ -61,9 +79,9 @@ foreach my $rom ( @roms ) {
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};
+ merge_entry_points ( $baserom_pnp->{bcv}, $rom_pnp->{bcv}, $offset );
+ merge_entry_points ( $baserom_pnp->{bdv}, $rom_pnp->{bdv}, $offset );
+ merge_entry_points ( $baserom_pnp->{bev}, $rom_pnp->{bev}, $offset );
}
# Fix checksum for this ROM segment