Hello!

The attached patch implements automatic hardcoding of stage2 size
into stage1 and stage1_lba

ChangeLog:
        * Makefile.am: process stage1 after stage2
        * stage1/Makefile.am: new rules for creating stage2_size.h
        from ../stage2/stage2
        * stage1/stage1.S: include stage2_size.h and use STAGE2_SIZE
        in the default blocklist
        * stage1/stage1_lba.S: Likewise

Pavel Roskin
Index: Makefile.am
===================================================================
RCS file: /usr/local/cvs/grub/Makefile.am,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- Makefile.am 1999/09/14 19:37:17     1.1.1.1
+++ Makefile.am 1999/09/14 20:18:10     1.2
@@ -1,4 +1,6 @@
-SUBDIRS = stage1 netboot stage2 grub docs debian
+# stage1 is built after stage2, so that the size of stage2 is
+# encoded into stage1
+SUBDIRS = netboot stage2 stage1 grub docs debian
 EXTRA_DIST = BUGS
 
 # We get $(PACKAGE) and $(VERSION) from debian/changelog.
Index: stage1/Makefile.am
===================================================================
RCS file: /usr/local/cvs/grub/stage1/Makefile.am,v
retrieving revision 1.1.1.1
retrieving revision 1.4
diff -u -r1.1.1.1 -r1.4
--- stage1/Makefile.am  1999/09/14 19:37:17     1.1.1.1
+++ stage1/Makefile.am  1999/09/14 20:52:16     1.4
@@ -1,14 +1,20 @@
 pkgdatadir = $(datadir)/$(PACKAGE)/$(host_cpu)-$(host_vendor)
 nodist_pkgdata_DATA = stage1 stage1_lba
-CLEANFILES = $(pkgdata_DATA)
 
+BUILT_SOURCES = stage2_size.h
+CLEANFILES = $(pkgdata_DATA) $(BUILT_SOURCES)
+
 # We can't use builtins or standard includes.
 AM_CFLAGS = $(STAGE1_CFLAGS) -fno-builtin -nostdinc
 LDFLAGS = -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00
 
 noinst_PROGRAMS = stage1.exec stage1_lba.exec
-stage1_exec_SOURCES = stage1.S stage1.h
-stage1_lba_exec_SOURCES = stage1_lba.S stage1.h
+stage1_exec_SOURCES = stage1.S stage1.h stage2_size.h
+stage1_lba_exec_SOURCES = stage1_lba.S stage1.h stage2_size.h
 
 %: %.exec
        $(OBJCOPY) -O binary $< $@
+
+stage2_size.h: ../stage2/stage2
+       ls -l ../stage2/stage2 | \
+           $(AWK) '{print "#define STAGE2_SIZE " $$5;}' > stage2_size.h
Index: stage1/stage1.S
===================================================================
RCS file: /usr/local/cvs/grub/stage1/stage1.S,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- stage1/stage1.S     1999/09/14 19:37:17     1.1.1.1
+++ stage1/stage1.S     1999/09/14 20:18:57     1.2
@@ -19,6 +19,7 @@
  */
 
 #include <stage1.h>
+#include "stage2_size.h"
 
 /*
  *  defines for the code go here
@@ -398,7 +399,8 @@
 #else
        .long 1         /* this is the sector start parameter, in logical
                           sectors from the start of the disk, sector 0 */
-       .word 130       /* this is the number of sectors to read */
+                       /* this is the number of sectors to read */
+       .word (STAGE2_SIZE + 511) / 512
        .word 0x0800    /* this is the segment of the starting address
                           to load the data into */
 #endif
Index: stage1/stage1_lba.S
===================================================================
RCS file: /usr/local/cvs/grub/stage1/stage1_lba.S,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- stage1/stage1_lba.S 1999/09/14 19:37:17     1.1.1.1
+++ stage1/stage1_lba.S 1999/09/14 20:18:57     1.2
@@ -19,6 +19,7 @@
  */
 
 #include <stage1.h>
+#include "stage2_size.h"
        
 /*
  *  defines for the code go here
@@ -345,7 +346,8 @@
 #else
        .long 1         /* this is the sector start parameter, in logical
                           sectors from the start of the disk, sector 0 */
-       .word 130       /* this is the number of sectors to read */
+                       /* this is the number of sectors to read */
+       .word (STAGE2_SIZE + 511) / 512
        .word 0x0800    /* this is the segment of the starting address
                           to load the data into */
 #endif

Reply via email to