modrom.pl revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
use strict;
use vars qw(%opts);
use bytes;
sub getromsize ($) {
my ($romref) = @_;
my $i;
print STDERR "BIOS extension ROM Image did not start with 0x55 0xAA\n"
print STDERR "$size is a strange size for a boot ROM\n"
return ($size);
}
sub addident ($) {
my ($romref) = @_;
# include the terminating NUL byte too
$s .= "\x00";
my $len = length($s);
# Put the identifier in only if the space is blank
return ($pos);
}
sub pcipnpheaders ($$) {
my ($romref, $identoffset) = @_;
my ($pci_hdr_offset, $pnp_hdr_offset);
# Sanity checks
} else {
printf "PCI header at %#x and PnP header at %#x\n",
}
if ($pci_hdr_offset > 0) {
my ($pci_vendor_id, $pci_device_id);
# if no -p option, just report what's there
if (!defined($opts{'p'})) {
printf "PCI Vendor ID %#x Device ID %#x\n",
} else {
}
}
# Point to device id string at end of ROM image
= pack('v', $identoffset);
PNP_HDR_SIZE));
}
}
sub undiheaders ($) {
my ($romref) = @_;
my ($undi_hdr_offset);
# Sanity checks
$undi_hdr_offset = 0;
} else {
printf "UNDI header at %#x\n", $undi_hdr_offset;
}
if ($undi_hdr_offset > 0) {
}
}
sub writerom ($$) {
open(R, ">$filename") or die "$filename: $!\n";
print R $$romref;
close(R);
}
sub checksum ($) {
my ($romref) = @_;
# Double check
if ($sum != 0) {
print "Checksum fails\n"
} elsif ($opts{'v'}) {
print "Checksum ok\n";
}
}
sub makerom () {
# Read in the whole ROM in one gulp
close(R);
# If PXE image, just fill the length field and write it out
if ($opts{'x'}) {
return;
}
# Size specified with -s overrides value in 3rd byte in image
# -s 0 means round up to next 512 byte block
if (defined($opts{'s'})) {
# NB: This roundup trick only works on powers of 2
}
} else {
# 0 put there by *loader.S means makerom should pick the size
if ($romsize == 0) {
# Shrink romsize down to the smallest power of two that will do
for ($romsize = MAXROMSIZE;
$romsize /= 2) { }
}
}
print STDERR "ROM size of $romsize not big enough for data, ";
# NB: This roundup trick only works on powers of 2
print "will use $romsize instead\n"
}
# Pad with 0xFF to $romsize
print "Warning: ROM size exceeds extension BIOS limit\n";
}
&undiheaders(\$rom);
# 3c503 requires last two bytes to be 0x80
}
sub modrom () {
my ($rom);
# Read in the whole ROM in one gulp
close(R);
&pcipnpheaders(\$rom);
&undiheaders(\$rom);
}
# Main routine. See how we were called and behave accordingly
&modrom();
} else {
&makerom();
}
exit(0);