Re: [Etherboot-developers] NIC file and ROM images
Brought to you by:
marty_connor,
stefanhajnoczi
|
From: <ke...@us...> - 2002-04-12 22:32:07
|
>I'd be careful about using Perl for this kind of work. I'm rather
>turned off on Perl since I added code to compute a checksum and
>Perl 5 seconds to checksum a 1Meg binary data. That combined with the
>challenge of dealing with binary data in Perl causes me to suggest
>that is is proabably a more appropriate language for this task.
Relax, I know Perl like an old friend. I bet you tried to sum each byte
with a loop containing a substr. Perl has a built-in for doing
checksums, see unpack in perlfunc(1). Here's a quickie to verify that
the a ROM image checksums to 0.
#!/usr/bin/perl
$/ = 0777;
$sum = unpack("%8C*",<>);
print "$sum\n";
And here's a run on a 1 MB file picked at random:
$ ls -l /boot/vmlinuz_2418
-rw-r--r-- 1 root root 1008337 Mar 7 14:02
/boot/vmlinuz_2418
$ time /tmp/c.pl < /boot/vmlinuz_2418
95
real 0m0.027s
user 0m0.020s
sys 0m0.010s
>> The NIC file could also generate an include for config.c, so only one
>> place needs to be changed to support another derived image.
>
>That might be a good idea. But it falls down on the multiple drives
>in one NIC side. I would be in favor of all of the PCI ID moving into
>the drivers so drivers can be independent.
But you haven't found out yet if an image can actually contain multiple
PCI headers and do the right thing.
|