summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhpa <hpa>1998-04-14 05:27:20 +0000
committerhpa <hpa>1998-04-14 05:27:20 +0000
commit06e8eeeb75a44bd6df54c7e120cfa95a2dd6f8a1 (patch)
treeb14294afd5dbb58dec40875e57b48aa9f9a87537
parentec539247246461dc67b7f141b0c17be7b7caa226 (diff)
downloadsyslinux-06e8eeeb75a44bd6df54c7e120cfa95a2dd6f8a1.tar.gz
Patch generator for the -s (stupid) option.
-rw-r--r--Makefile17
-rw-r--r--genstupid.pl77
-rw-r--r--ldlinux.asm17
-rw-r--r--syslinux.asm6
4 files changed, 101 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index 70c758c6..a955254a 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@ VERSION = $(shell cat version)
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)
@@ -42,8 +42,9 @@ ifndef DATE
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
@@ -51,7 +52,7 @@ bootsect.bin: ldlinux.bin
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
@@ -60,14 +61,20 @@ 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)
diff --git a/genstupid.pl b/genstupid.pl
new file mode 100644
index 00000000..2001268e
--- /dev/null
+++ b/genstupid.pl
@@ -0,0 +1,77 @@
+#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);
diff --git a/ldlinux.asm b/ldlinux.asm
index bc0c78a8..46631b11 100644
--- a/ldlinux.asm
+++ b/ldlinux.asm
@@ -638,8 +638,9 @@ getonesec:
; 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]
@@ -654,20 +655,14 @@ getlinsec:
;
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
diff --git a/syslinux.asm b/syslinux.asm
index 40820847..0b28774b 100644
--- a/syslinux.asm
+++ b/syslinux.asm
@@ -253,6 +253,12 @@ die:
mov ax,4C01h ; Exit error status
int 21h
+;
+; This includes a small subroutine make_stupid to patch up the boot sector
+; in case we give the -s (stupid) option
+;
+ %include "stupid.inc"
+
section .data
msg_error: db 'ERROR: $'
msg_filesystem_err: db 'Filesystem not found on disk', 0Dh, 0Ah, '$'