2 ## -----------------------------------------------------------------------
4 ## Copyright 2001 H. Peter Anvin - All Rights Reserved
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 ## Boston MA 02111-1307, USA; either version 2 of the License, or
10 ## (at your option) any later version; incorporated herein by reference.
12 ## -----------------------------------------------------------------------
13 ## $Id: postprocess.pl,v 1.4 2004/12/14 22:46:25 hpa Exp $
16 # Postprocess the memdisk binary.
21 ($out,$file16,$file32) = @ARGV;
23 open(OUT, "> $out\0") or die "$0: Cannot create file: $out\n";
24 eval { binmode OUT; };
25 open(FILE, "< $file16\0") or die "$0: Cannot open file: $file16\n";
26 eval { binmode FILE };
31 $sectors = ($size + 511) >> 9;
32 $xsize = $sectors << 9;
34 read(FILE, $f16, $size);
38 if ( $size != $xsize ) {
39 # Pad to a sector boundary
40 print OUT "\0" x ($xsize-$size);
43 seek(OUT, 0x1f1, SEEK_SET); # setup_sects
44 # All sectors are setup except the first
45 print OUT pack("C", $sectors-1);
47 seek(OUT, $xsize, SEEK_SET);
50 open(FILE, "+< $file32\0") or die "$0: Cannot open file: $file32\n";
52 while ( ($n = read(FILE, $f32, 65536)) > 0 ) {