diff options
author | hpa <hpa> | 2001-12-10 08:20:43 +0000 |
---|---|---|
committer | hpa <hpa> | 2001-12-10 08:20:43 +0000 |
commit | fb13c33edae163e0e29bd70780dbeca2aad071f8 (patch) | |
tree | 52138013d23e001bfc394a857308dc7d95ab3f34 | |
parent | 886a10a343516d7680600faba3ebfa9735cd3dc3 (diff) | |
download | syslinux-fb13c33edae163e0e29bd70780dbeca2aad071f8.tar.gz |
Add postprocessing to set the number of setup sectors.
-rw-r--r-- | memdisk/Makefile | 4 | ||||
-rwxr-xr-x | memdisk/postprocess.pl | 41 |
2 files changed, 44 insertions, 1 deletions
diff --git a/memdisk/Makefile b/memdisk/Makefile index 9e81685c..f5358664 100644 --- a/memdisk/Makefile +++ b/memdisk/Makefile @@ -19,6 +19,7 @@ AS = as LD = ld NASM = nasm OBJCOPY = objcopy +PERL = perl # Important: init.o16 must be first!! OBJS = init.o16 setup.o16 msetup.o16 e820func.o16 memdisk.o @@ -55,8 +56,9 @@ clean: memdisk.elf: $(OBJS) $(LD) -Ttext 0 -o $@ $^ -memdisk: memdisk.elf +memdisk: memdisk.elf postprocess.pl $(OBJCOPY) -O binary $< $@ + $(PERL) postprocess.pl $@ e820test: e820func.o msetup.o e820test.o memdisk.o $(CC) $(LDFLAGS) -o $@ $^ diff --git a/memdisk/postprocess.pl b/memdisk/postprocess.pl new file mode 100755 index 00000000..894c8b0b --- /dev/null +++ b/memdisk/postprocess.pl @@ -0,0 +1,41 @@ +#!/usr/bin/perl +## ----------------------------------------------------------------------- +## +## Copyright 2001 H. Peter Anvin - All Rights Reserved +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, Inc., 53 Temple Place Ste 330, +## Bostom MA 02111-1307, USA; either version 2 of the License, or +## (at your option) any later version; incorporated herein by reference. +## +## ----------------------------------------------------------------------- +## $Id$ + +# +# Postprocess the memdisk binary. +# + +($file) = @ARGV; + +open(FILE, "+< $file\0") or die "$0: Cannot open file: $file\n"; + +@info = stat(FILE); +$size = $info[7]; + +$sectors = ($size + 511) >> 9; +$xsize = $sectors << 9; + +seek(FILE, $size, SEEK_SET); + +if ( $size != $xsize ) { + # Pad to a sector boundary + print FILE "\0" x ($xsize-$size); +} + +seek(FILE, 0x1f1, SEEK_SET); # setup_sects +# All sectors are setup except the first +print FILE pack("C", $sectors-1); + +close(FILE); + |