#!perl -w
use strict;
use IO::File;
if (@ARGV!=2) {
    die "Usage: perl xtemp.pl temp.dat  imagedir\n"
}
my $ifn=shift;
my $ifh=IO::File->new($ifn, "r") or die "$ifn:$!\n";
binmode $ifh;

my $ofd=shift;

my $hdrdata;
$ifh->read($hdrdata, 0x74) or die "read header: $!\n";
my @hdr= unpack("V*", $hdrdata);
if ($hdr[0]!=0x4e455445) {
    die sprintf("invalid header magic: %08lx\n", $hdr[0]);
}

my %types= (
    2=>{ filename=>'osimage520.dat', mask=>0x001 },
    3=>{ filename=>'booter.dat',     mask=>0x002 },
    4=>{ filename=>'usbdl.dat',      mask=>0x004 },
    5=>{ filename=>'knight.dat',     mask=>0x008 },
    6=>{ filename=>'ipl.dat',        mask=>0x010 },
    7=>{ filename=>'logo.dat',       mask=>0x020 },
    8=>{ filename=>'dsp.dat',        mask=>0x040 },
    9=>{ filename=>'radio.dat',      mask=>0x100 },
);
# 10 .. 13 are NUL
# 14 : 0xf4723d0a  == 'internal'
# 15 .. 18  ?
# 19 .. 22 are 0xFFFFFFFF
# 23   flashtype


