SOURCES = ldlinux.asm syslinux.asm syslinux.c
TARGETS = bootsect.bin ldlinux.sys syslinux.com syslinux
DOCS = COPYING NEWS README TODO syslinux.doc keytab-lilo.doc
-OTHER = Makefile bin2c.pl now.pl keytab-lilo.pl version
+OTHER = Makefile bin2c.pl now.pl genstupid.pl keytab-lilo.pl version
all: $(TARGETS)
ls -l $(TARGETS)
DATE = $(shell perl now.pl)
endif
-ldlinux.bin: ldlinux.asm
+ldlinux.bin: ldlinux.asm genstupid.pl
$(NASM) -f bin -dVERSION="'$(VERSION)'" -dDATE_STR="'$(DATE)'" -l ldlinux.lst -o ldlinux.bin ldlinux.asm
+ perl genstupid.pl < ldlinux.lst
bootsect.bin: ldlinux.bin
dd if=ldlinux.bin of=bootsect.bin bs=512 count=1
ldlinux.sys: ldlinux.bin
dd if=ldlinux.bin of=ldlinux.sys bs=512 skip=1
-syslinux.com: syslinux.asm bootsect.bin ldlinux.sys
+syslinux.com: syslinux.asm bootsect.bin ldlinux.sys stupid.inc
$(NASM) -f bin -l syslinux.lst -o syslinux.com syslinux.asm
bootsect_bin.c: bootsect.bin bin2c.pl
ldlinux_bin.c: ldlinux.sys bin2c.pl
perl bin2c.pl ldlinux < ldlinux.sys > ldlinux_bin.c
-syslinux: syslinux.o bootsect_bin.o ldlinux_bin.o
+syslinux: syslinux.o bootsect_bin.o ldlinux_bin.o stupid.o
$(CC) $(LDFLAGS) -o syslinux syslinux.o bootsect_bin.o ldlinux_bin.o
+stupid.o: stupid.c
+
+stupid.c: ldlinux.asm
+
+stupid.inc: ldlinux.asm
+
install: all
install -c syslinux $(BINDIR)
tidy:
- rm -f ldlinux.bin *.lst *.o *_bin.c
+ rm -f ldlinux.bin *.lst *.o *_bin.c stupid.*
clean: tidy
rm -f $(TARGETS)
--- /dev/null
+#ident "$Id$"
+## -----------------------------------------------------------------------
+##
+## Copyright 1998 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., 675 Mass Ave, Cambridge MA 02139,
+## USA; either version 2 of the License, or (at your option) any later
+## version; incorporated herein by reference.
+##
+## -----------------------------------------------------------------------
+
+#
+# This file is part of the SYSLINUX compilation sequence.
+#
+
+undef $addr, $begin, $end;
+$isbegin = 0; $isend = 0;
+
+while ( $line = <STDIN> ) {
+ if ( $line =~ /^\s*([0-9]+) ([0-9A-F]{8}) / ) {
+ $addr = hex $2;
+ if ( $isbegin ) {
+ $begin = $addr;
+ $isbegin = 0;
+ }
+ if ( $isend ) {
+ $end = $addr;
+ $isend = 0;
+ }
+ }
+ if ( $line =~ /^[0-9A-F\s]+__BEGIN_STUPID_PATCH_AREA\:/ ) {
+ $isbegin = 1;
+ } elsif ( $line =~ /^[0-9A-F\s]+__END_STUPID_PATCH_AREA\:/ ) {
+ $isend = 1;
+ }
+}
+
+if ( !defined($begin) || !defined($end) || $end > 512 || ($end-$begin) < 3 ) {
+ print STDERR "$0: error locating STUPID_PATCH_AREA\n";
+ exit 1;
+}
+
+open(CFILE, "> stupid.c") || die "$0: cannot create stupid.c: $!\n";
+
+$addr = $begin;
+printf CFILE "extern unsigned char bootsect[];\n";
+printf CFILE "void make_stupid(void)\n";
+printf CFILE "{\n";
+printf CFILE "\tbootsect[0x%x] = 0xbd;\n", $addr++;
+printf CFILE "\tbootsect[0x%x] = 0x01;\n", $addr++;
+printf CFILE "\tbootsect[0x%x] = 0x00;\n", $addr++;
+while ( $addr < $end ) {
+ printf CFILE "\tbootsect[0x%x] = 0x90;\n", $addr++;
+}
+print CFILE "}\n";
+
+close(CFILE);
+
+open(ASMFILE, "> stupid.inc") || die "$0: cannot open stupid.inc: $!\n";
+
+printf ASMFILE "\tsection .text\n";
+printf ASMFILE "make_stupid:\n";
+printf ASMFILE "\tmov si, .stupid_patch\n";
+printf ASMFILE "\tmov di, BootSector+0%Xh\n", $begin;
+printf ASMFILE "\tmov cx, %d\n", $end-$begin;
+printf ASMFILE "\trep movsb\n";
+printf ASMFILE "\tret\n";
+printf ASMFILE "\tsection .data\n";
+printf ASMFILE ".stupid_patch:\n";
+printf ASMFILE "\tmov bp,1\n";
+for ( $addr = $begin + 3 ; $addr < $end ; $addr++ ) {
+ printf ASMFILE "\tnop\n";
+}
+
+close(ASMFILE);
; On return, BX points to the first byte after the transferred
; block.
;
-; When compiling with the STUPID option, this is replaced by a
-; routine which loads one sector at a time.
+; The "stupid patch area" gets replaced by the code
+; mov bp,1 ; nop ... (BD 01 00 90 90...) when installing with
+; the -s option.
;
getlinsec:
mov si,[bsSecPerTrack]
;
gls_nextchunk: push si ; <A> bsSecPerTrack
push bp ; <B> Sectors to transfer
-%ifdef STUPID
- mov bp,1
- nop ; Minimize size of patch
- nop
- nop
- nop
- nop
-%else
+
+__BEGIN_STUPID_PATCH_AREA:
sub si,cx ; Sectors left on track
cmp bp,si
jna gls_lastchunk
mov bp,si ; No more than a trackful, please!
+__END_STUPID_PATCH_AREA:
gls_lastchunk:
-%endif
push ax ; <C> Cylinder #
push dx ; <D> Head #
push bp ; <E> Number of sectors we're transferring