Updated slugimage to the latest upstream version, which fixes the small kernel bug which OpenWRT exposed.
SVN-Revision: 5923
This commit is contained in:
parent
e7cd65a591
commit
21262ab671
1 changed files with 91 additions and 89 deletions
|
@ -410,7 +410,7 @@ sub readInFirmware {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
# Slurp up the data, based on whether a header is present or not
|
# Slurp up the data, based on whether a header and/or data is present or not
|
||||||
if ($_->{'header'}) {
|
if ($_->{'header'}) {
|
||||||
|
|
||||||
# Read the length, and grab the data based on the length.
|
# Read the length, and grab the data based on the length.
|
||||||
|
@ -422,6 +422,11 @@ sub readInFirmware {
|
||||||
$_->{'data'} = substr($firmware_buf, $_->{'offset'} + $_->{'header'}, $data_len);
|
$_->{'data'} = substr($firmware_buf, $_->{'offset'} + $_->{'header'}, $data_len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elsif ($_->{'pseudo'} and not defined $_->{'file'} and
|
||||||
|
(substr($firmware_buf, $_->{'offset'}, $_->{'size'}) eq
|
||||||
|
(pack("C", 0xff) x $_->{'size'}))) {
|
||||||
|
$debug and printf("Skipping empty pseudo partition <%s>\n", $_->{'name'});
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
# Grab the whole partition, using the maximum size.
|
# Grab the whole partition, using the maximum size.
|
||||||
|
@ -557,6 +562,11 @@ sub readInFirmwareParts {
|
||||||
sub layoutPartitions {
|
sub layoutPartitions {
|
||||||
my(@partitions) = @_;
|
my(@partitions) = @_;
|
||||||
|
|
||||||
|
# Find the kernel partition, and save a pointer to it for later use
|
||||||
|
my $kernel;
|
||||||
|
map { ($_->{'name'} eq "Kernel") && ($kernel = $_); } @partitions;
|
||||||
|
$kernel or die "Couldn't find the kernel partition\n";
|
||||||
|
|
||||||
# Find the last variable size partition, and save a pointer to it for later use
|
# Find the last variable size partition, and save a pointer to it for later use
|
||||||
my $lastdisk;
|
my $lastdisk;
|
||||||
my $directory_offset;
|
my $directory_offset;
|
||||||
|
@ -588,46 +598,14 @@ sub layoutPartitions {
|
||||||
|
|
||||||
$debug and printf("Pointer is 0x%08X\n", $pointer);
|
$debug and printf("Pointer is 0x%08X\n", $pointer);
|
||||||
|
|
||||||
# If this is the last variable size partition, then fill the rest of the space.
|
|
||||||
if ($_->{'name'} eq $lastdisk->{'name'}) {
|
|
||||||
$_->{'size'} = paddedSize($directory_offset + $flash_start - $pointer);
|
|
||||||
$debug and printf("Padding last variable partition <%s> to 0x%08X bytes\n", $_->{'name'}, $_->{'size'});
|
|
||||||
}
|
|
||||||
|
|
||||||
# Handle requests for partition creation first.
|
|
||||||
if (defined $_->{'size'} and not defined $_->{'data'} and ($_->{'name'} ne "FIS directory")) {
|
|
||||||
|
|
||||||
# A zero size is a request to fill all available space.
|
|
||||||
if ($_->{'size'} == 0) {
|
|
||||||
# Grab the start of the FIS directory, and use all the space up to there.
|
|
||||||
$_->{'size'} = paddedSize($directory_offset + $flash_start - $pointer);
|
|
||||||
|
|
||||||
# Create an empty partition of the requested size.
|
|
||||||
$_->{'data'} = padBytes("", $_->{'size'});
|
|
||||||
|
|
||||||
$debug and printf("Creating empty partition <%s> of 0x%08X bytes\n", $_->{'name'}, $_->{'size'});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (not defined $_->{'offset'}) {
|
|
||||||
# Check to make sure that the requested size is not too large.
|
|
||||||
if (($pointer + $_->{'size'}) > ($flash_start + $directory_offset)) {
|
|
||||||
die "Ran out of flash space in <", $_->{'name'}, ">\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
# Check to make sure that the requested size is not too large.
|
|
||||||
if (($_->{'offset'} + $_->{'size'}) > ($flash_start + $directory_offset)) {
|
|
||||||
die "Ran out of flash space in <", $_->{'name'}, ">\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Then handle known partitions, and allocate them.
|
|
||||||
if (defined $_->{'size'}) {
|
|
||||||
|
|
||||||
# Determine the start and offset of the current partition.
|
# Determine the start and offset of the current partition.
|
||||||
if (defined $_->{'offset'}) {
|
if (defined $_->{'offset'}) {
|
||||||
$_->{'start'} = $flash_start + $_->{'offset'};
|
$_->{'start'} = $flash_start + $_->{'offset'};
|
||||||
|
# Check for running past the defined start of the partition.
|
||||||
|
if (($pointer > $_->{'start'}) and not $_->{'pseudo'}) {
|
||||||
|
die sprintf("Ran out of flash space before <%s> - %s too large.\n", $_->{'name'},
|
||||||
|
sprintf("0x%05X bytes", ($pointer - $_->{'start'})));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# If offset is not defined, then calculate it.
|
# If offset is not defined, then calculate it.
|
||||||
|
@ -645,9 +623,8 @@ sub layoutPartitions {
|
||||||
{ 'offset' => 0, 'size' => $_->{'header'}, 'data' => undef });
|
{ 'offset' => 0, 'size' => $_->{'header'}, 'data' => undef });
|
||||||
# Allow for the Sercomm header to be prepended to the data.
|
# Allow for the Sercomm header to be prepended to the data.
|
||||||
$size += $_->{'header'};
|
$size += $_->{'header'};
|
||||||
}
|
|
||||||
|
|
||||||
# Determine if the partition requires a Sercomm skip region.
|
# Determine if the partition overlaps the ramdisk boundary.
|
||||||
if (($_->{'offset'} < $ramdisk_offset) and
|
if (($_->{'offset'} < $ramdisk_offset) and
|
||||||
(($_->{'offset'} + $size) > $ramdisk_offset)) {
|
(($_->{'offset'} + $size) > $ramdisk_offset)) {
|
||||||
# Define the skip region for the inline Sercomm header.
|
# Define the skip region for the inline Sercomm header.
|
||||||
|
@ -657,9 +634,39 @@ sub layoutPartitions {
|
||||||
# Allow for the Sercomm header to be inserted in the data.
|
# Allow for the Sercomm header to be inserted in the data.
|
||||||
$size += 16;
|
$size += 16;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Partitions without headers cannot have skip regions.
|
||||||
|
elsif (($_->{'offset'} <= $ramdisk_offset) and
|
||||||
|
(($_->{'offset'} + $size) > $ramdisk_offset)) {
|
||||||
|
# Pad the kernel until it extends past the ramdisk offset.
|
||||||
|
push(@{$kernel->{'skips'}},
|
||||||
|
{ 'offset' => ($ramdisk_offset - $kernel->{'offset'}), 'size' => 16,
|
||||||
|
'data' => pack("N4", $block_size) });
|
||||||
|
$kernel->{'size'} = $ramdisk_offset - $kernel->{'offset'} + $block_size;
|
||||||
|
$kernel->{'data'} = padBytes($kernel->{'data'},
|
||||||
|
$kernel->{'size'} - $kernel->{'header'} - 16);
|
||||||
|
$_->{'offset'} = $ramdisk_offset + $block_size;
|
||||||
|
$_->{'start'} = $flash_start + $_->{'offset'};
|
||||||
|
$pointer = $_->{'start'};
|
||||||
|
$debug and printf("Extending kernel partition past ramdisk offset.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
# If this is the last variable size partition, then fill the rest of the space.
|
||||||
|
if ($_->{'name'} eq $lastdisk->{'name'}) {
|
||||||
|
$_->{'size'} = paddedSize($directory_offset + $flash_start - $pointer);
|
||||||
|
$debug and printf("Padding last variable partition <%s> to 0x%08X bytes\n", $_->{'name'}, $_->{'size'});
|
||||||
|
}
|
||||||
|
|
||||||
|
die sprintf("Partition size not defined in <%s>.\n", $_->{'name'})
|
||||||
|
unless defined $_->{'size'};
|
||||||
|
|
||||||
# Extend to another block if required.
|
# Extend to another block if required.
|
||||||
if ($size > $_->{'size'}) {
|
if ($size > $_->{'size'}) {
|
||||||
|
if ($_->{'name'} eq $lastdisk->{'name'}) {
|
||||||
|
die sprintf("Ran out of flash space in <%s> - %s too large.\n", $_->{'name'},
|
||||||
|
sprintf("0x%05X bytes", ($size - $_->{'size'})));
|
||||||
|
}
|
||||||
$_->{'size'} = $size;
|
$_->{'size'} = $size;
|
||||||
printf("Extending partition <%s> to 0x%08X bytes\n", $_->{'name'}, $_->{'size'});
|
printf("Extending partition <%s> to 0x%08X bytes\n", $_->{'name'}, $_->{'size'});
|
||||||
}
|
}
|
||||||
|
@ -686,8 +693,6 @@ sub layoutPartitions {
|
||||||
# Move the pointer up, in preparation for the next partition.
|
# Move the pointer up, in preparation for the next partition.
|
||||||
$pointer = paddedSize($_->{'start'} + $_->{'size'});
|
$pointer = paddedSize($_->{'start'} + $_->{'size'});
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} @partitions;
|
} @partitions;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -916,7 +921,7 @@ sub defaultPartitions {
|
||||||
'offset'=>0x007f8000, 'size'=>0x00004000,
|
'offset'=>0x007f8000, 'size'=>0x00004000,
|
||||||
'variable'=>0, 'header'=>0, 'pseudo'=>1, 'data'=>undef, 'byteswap'=>0},
|
'variable'=>0, 'header'=>0, 'pseudo'=>1, 'data'=>undef, 'byteswap'=>0},
|
||||||
{'name'=>'Microcode', 'file'=>'NPE-B',
|
{'name'=>'Microcode', 'file'=>'NPE-B',
|
||||||
'offset'=>0x007fc000, 'size'=>0x00003ff0,
|
'offset'=>0x007fc000, 'size'=>0x00003000,
|
||||||
'variable'=>0, 'header'=>16, 'pseudo'=>1, 'data'=>undef, 'byteswap'=>0},
|
'variable'=>0, 'header'=>16, 'pseudo'=>1, 'data'=>undef, 'byteswap'=>0},
|
||||||
{'name'=>'Trailer', 'file'=>'Trailer',
|
{'name'=>'Trailer', 'file'=>'Trailer',
|
||||||
'offset'=>0x007ffff0, 'size'=>0x00000010,
|
'offset'=>0x007ffff0, 'size'=>0x00000010,
|
||||||
|
@ -1110,11 +1115,8 @@ if (defined $ramdisk) {
|
||||||
if (defined $size) {
|
if (defined $size) {
|
||||||
$entry{'size'} = $size * $block_size;
|
$entry{'size'} = $size * $block_size;
|
||||||
# Create an empty partition of the requested size.
|
# Create an empty partition of the requested size.
|
||||||
$entry{'data'} = padBytes("", $entry{'size'});
|
|
||||||
if ($entry{'header'}) {
|
|
||||||
$entry{'data'} = padBytes("", $entry{'size'} - $entry{'header'});
|
$entry{'data'} = padBytes("", $entry{'size'} - $entry{'header'});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
\%entry;
|
\%entry;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue