Hallo Grub Hackers !

Here is finally the code as 'cvs diff -u' and the 3 new files.

I hope all c style rules are correct. I also added a '--enable-diskless'
feature to the 'configure.in' and edited the 'Makefile.am'.

The four files:

        (1) grub-diff-<date>.log is the 'cvs diff -u' log

        (2) netbooted.h, the header defining the diskless stuff

        (3) nbloader.S, the netboot header itself, tested with 
                        netboot-0.9.0. Important: the image is loaded
                        to 0x8000. Whatever netboot or etherboot ROM is
                        used, is must be supported to write to 0x8000.

        (4) mknbi-grub, a shell script building up the nbGrub, the
                        netbootable GRUB image. It is produced auto-
                        matically while 'make all' if the option
                        '--enable-diskless' was defined while
                        configuration.

The next stuff I will work on is the serial console ....

Further I detectet problems in the ethernet card probing
(has nothing to do with the diskless stuff !)
I have to check this. If one than more card are defined, the
probe hangs (or waits for a too long time), if a probed card is
not present.

With friendly regards

        Christoph Plattner


-----------------------------------------------------------------
private:        [EMAIL PROTECTED]
company:        [EMAIL PROTECTED]
? .deps
? stage2/nbloader.S
? stage2/mknbi-grub
? stage2/netbooted.h
Index: ChangeLog
===================================================================
RCS file: /cvs/grub/ChangeLog,v
retrieving revision 1.216
diff -u -r1.216 ChangeLog
--- ChangeLog   2000/04/12 03:10:07     1.216
+++ ChangeLog   2000/04/13 22:37:20
@@ -1,3 +1,33 @@
+2000-04-14    <[EMAIL PROTECTED]>
+
+       * netboot/main.c (decode_rfc1533): added the tag to define
+       'menu.lst' file. This tag is 'BOOTP_GRUBMENU_TAG' and defined
+       currently as tag 'T99' in the netbooted.h
+
+       * stage2/nbloader.S: added file for netboot header (tested with 
+       netboot-0.9.0)
+
+       * stage2/asm.S (_start): added some allocated space to string
+       config_file
+
+       * stage2/char_io.c (init_page): in diskless debug test mode, don't
+       do the 'cls ()'
+
+       * stage2/netbooted.h: added file for diskless netboot stuff
+
+2000-04-13    <[EMAIL PROTECTED]>
+
+       * stage2/stage2.c (grub_netbooted): added function to determine if
+       the grub was netbooted
+       (grub_prepare_diskless): prepare grub for loading config file from
+       boot server
+       (cmain): call grub_prepare_diskless () 
+
+       * stage2/Makefile.am: added nbloader and nbGrub rules for diskless
+       operation
+
+       * configure.in (CPPFLAGS): added '--enable-diskless' option
+
 2000-04-12  OKUJI Yoshinori  <[EMAIL PROTECTED]>
 
        * configure.in: Use AC_PATH_PROG instead of AC_PATH_TOOL,
Index: Makefile.in
===================================================================
RCS file: /cvs/grub/Makefile.in,v
retrieving revision 1.28
diff -u -r1.28 Makefile.in
--- Makefile.in 2000/03/27 07:57:30     1.28
+++ Makefile.in 2000/04/13 22:37:22
@@ -31,8 +31,6 @@
 includedir = @includedir@
 oldincludedir = /usr/include
 
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
Index: configure
===================================================================
RCS file: /cvs/grub/configure,v
retrieving revision 1.62
diff -u -r1.62 configure
--- configure   2000/04/12 03:10:07     1.62
+++ configure   2000/04/13 22:37:35
@@ -86,6 +86,8 @@
 ac_help="$ac_help
   --enable-via-rhine      enable Rhine-I/II driver"
 ac_help="$ac_help
+  --enable-diskless       enable diskless GRUB operation (netboot)"
+ac_help="$ac_help
   --enable-3c503-shmem    use 3c503 shared memory mode"
 ac_help="$ac_help
   --enable-3c503-aui      use AUI by default on 3c503 cards"
@@ -645,7 +647,7 @@
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:649: checking for a BSD compatible install" >&5
+echo "configure:651: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -698,7 +700,7 @@
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6
-echo "configure:702: checking whether build environment is sane" >&5
+echo "configure:704: checking whether build environment is sane" >&5
 # Just in case
 sleep 1
 echo timestamp > conftestfile
@@ -765,12 +767,12 @@
   echo "configure: warning: ${am_backtick}missing' script is too old or missing" 1>&2
 fi
 
-for ac_prog in mawk gawk nawk awk
+for ac_prog in gawk mawk nawk awk
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:774: checking for $ac_word" >&5
+echo "configure:776: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -800,7 +802,7 @@
 done
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:804: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:806: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -935,7 +937,7 @@
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:939: checking host system type" >&5
+echo "configure:941: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
@@ -969,7 +971,7 @@
 #
 
 echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... 
$ac_c" 1>&6
-echo "configure:973: checking whether to enable maintainer-specific portions of 
Makefiles" >&5
+echo "configure:975: checking whether to enable maintainer-specific portions of 
+Makefiles" >&5
     # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
 if test "${enable_maintainer_mode+set}" = set; then
   enableval="$enable_maintainer_mode"
@@ -995,7 +997,7 @@
   # Extract the first word of "perl", so it can be a program name with args.
 set dummy perl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:999: checking for $ac_word" >&5
+echo "configure:1001: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1042,7 +1044,7 @@
 #
 
 echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:1046: checking build system type" >&5
+echo "configure:1048: checking build system type" >&5
 
 build_alias=$build
 case "$build_alias" in
@@ -1068,7 +1070,7 @@
 # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with 
args.
 set dummy ${ac_tool_prefix}gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1072: checking for $ac_word" >&5
+echo "configure:1074: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1100,7 +1102,7 @@
 # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1104: checking for $ac_word" >&5
+echo "configure:1106: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1130,7 +1132,7 @@
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1134: checking for $ac_word" >&5
+echo "configure:1136: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1181,7 +1183,7 @@
       # Extract the first word of "cl", so it can be a program name with args.
 set dummy cl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1185: checking for $ac_word" >&5
+echo "configure:1187: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1213,7 +1215,7 @@
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 
1>&6
-echo "configure:1217: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" 
>&5
+echo "configure:1219: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" 
+>&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -1224,12 +1226,12 @@
 
 cat > conftest.$ac_ext << EOF
 
-#line 1228 "configure"
+#line 1230 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:1233: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
-s conftest${ac_exeext}; then
+if { (eval echo configure:1235: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
+-s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -1255,12 +1257,12 @@
   { echo "configure: error: installation or configuration problem: C compiler cannot 
create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a 
cross-compiler""... $ac_c" 1>&6
-echo "configure:1259: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a 
cross-compiler" >&5
+echo "configure:1261: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a 
+cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:1264: checking whether we are using GNU C" >&5
+echo "configure:1266: checking whether we are using GNU C" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1269,7 +1271,7 @@
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1273: \"$ac_try\") 1>&5; 
(eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1275: \"$ac_try\") 1>&5; 
+(eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -1288,7 +1290,7 @@
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1292: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1294: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1321,7 +1323,7 @@
 
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1325: checking how to run the C preprocessor" >&5
+echo "configure:1327: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -1336,13 +1338,13 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 1340 "configure"
+#line 1342 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1346: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1348: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -1353,13 +1355,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 1357 "configure"
+#line 1359 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1363: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1365: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -1370,13 +1372,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 1374 "configure"
+#line 1376 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1380: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1382: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -1409,7 +1411,7 @@
 depcc="$CC"
 depcpp="$CPP"
 echo $ac_n "checking dependency style of $depcc""... $ac_c" 1>&6
-echo "configure:1413: checking dependency style of $depcc" >&5
+echo "configure:1415: checking dependency style of $depcc" >&5
 if eval "test \"`echo '$''{'am_cv_CC_dependencies_compiler_type'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1465,7 +1467,7 @@
   # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1469: checking for $ac_word" >&5
+echo "configure:1471: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1502,7 +1504,7 @@
   # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1506: checking for $ac_word" >&5
+echo "configure:1508: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1542,7 +1544,7 @@
     STAGE1_CFLAGS="-O2"
     GRUB_CFLAGS="-O2"
     echo $ac_n "checking whether optimization for size works""... $ac_c" 1>&6
-echo "configure:1546: checking whether optimization for size works" >&5
+echo "configure:1548: checking whether optimization for size works" >&5
 if eval "test \"`echo '$''{'size_flag'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1550,14 +1552,14 @@
       saved_CFLAGS=$CFLAGS
       CFLAGS="-Os -g"
       cat > conftest.$ac_ext <<EOF
-#line 1554 "configure"
+#line 1556 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:1561: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; 
then
+if { (eval echo configure:1563: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; 
+then
   rm -rf conftest*
   size_flag=yes
 else
@@ -1591,7 +1593,7 @@
   # Extract the first word of "objcopy", so it can be a program name with args.
 set dummy objcopy; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1595: checking for $ac_word" >&5
+echo "configure:1597: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_OBJCOPY'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1627,7 +1629,7 @@
   # Extract the first word of "${ac_tool_prefix}objcopy", so it can be a program name 
with args.
 set dummy ${ac_tool_prefix}objcopy; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1631: checking for $ac_word" >&5
+echo "configure:1633: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_OBJCOPY'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1661,7 +1663,7 @@
 # Defined in acinclude.m4.
 
 echo $ac_n "checking if C symbols get an underscore after compilation""... $ac_c" 1>&6
-echo "configure:1665: checking if C symbols get an underscore after compilation" >&5
+echo "configure:1667: checking if C symbols get an underscore after compilation" >&5
 if eval "test \"`echo '$''{'grub_cv_asm_uscore'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1674,7 +1676,7 @@
 }
 EOF
 
-if { ac_try='${CC-cc} ${CFLAGS} -S conftest.c'; { (eval echo configure:1678: 
\"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.s; then
+if { ac_try='${CC-cc} ${CFLAGS} -S conftest.c'; { (eval echo configure:1680: 
+\"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.s; then
   true
 else
   { echo "configure: error: ${CC-cc} failed to produce assembly code" 1>&2; exit 1; }
@@ -1700,7 +1702,7 @@
 echo "$ac_t""$grub_cv_asm_uscore" 1>&6
 
 echo $ac_n "checking whether ${OBJCOPY} works for absolute addresses""... $ac_c" 1>&6
-echo "configure:1704: checking whether ${OBJCOPY} works for absolute addresses" >&5
+echo "configure:1706: checking whether ${OBJCOPY} works for absolute addresses" >&5
 if eval "test \"`echo '$''{'grub_cv_prog_objcopy_absolute'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1712,21 +1714,21 @@
 }
 EOF
 
-if { (eval echo configure:1716: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && 
test -s conftest.o; then :
+if { (eval echo configure:1718: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && 
+test -s conftest.o; then :
 else
   { echo "configure: error: ${CC-cc} cannot compile C source code" 1>&2; exit 1; }
 fi
 grub_cv_prog_objcopy_absolute=yes
 for link_addr in 2000 8000 7C00; do
-  if { ac_try='${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr 
conftest.o -o conftest.exec'; { (eval echo configure:1722: \"$ac_try\") 1>&5; (eval 
$ac_try) 2>&5; }; }; then :
+  if { ac_try='${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr 
+conftest.o -o conftest.exec'; { (eval echo configure:1724: \"$ac_try\") 1>&5; (eval 
+$ac_try) 2>&5; }; }; then :
   else
     { echo "configure: error: ${CC-cc} cannot link at address $link_addr" 1>&2; exit 
1; }
   fi
-  if { ac_try='${OBJCOPY-objcopy} -O binary conftest.exec conftest'; { (eval echo 
configure:1726: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then :
+  if { ac_try='${OBJCOPY-objcopy} -O binary conftest.exec conftest'; { (eval echo 
+configure:1728: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then :
   else
     { echo "configure: error: ${OBJCOPY-objcopy} cannot create binary files" 1>&2; 
exit 1; }
   fi
-  if test ! -f conftest.old || { ac_try='cmp -s conftest.old conftest'; { (eval echo 
configure:1730: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+  if test ! -f conftest.old || { ac_try='cmp -s conftest.old conftest'; { (eval echo 
+configure:1732: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
     mv -f conftest conftest.old
   else
     grub_cv_prog_objcopy_absolute=no
@@ -1743,7 +1745,7 @@
 
 
 echo $ac_n "checking whether addr32 must be in the same line as the instruction""... 
$ac_c" 1>&6
-echo "configure:1747: checking whether addr32 must be in the same line as the 
instruction" >&5
+echo "configure:1749: checking whether addr32 must be in the same line as the 
+instruction" >&5
 if eval "test \"`echo '$''{'grub_cv_asm_prefix_requirement'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1752,7 +1754,7 @@
 l1:    addr32  movb    %al, l1
 EOF
 
-if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'; { (eval echo configure:1756: 
\"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then
+if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'; { (eval echo configure:1758: 
+\"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then
   grub_cv_asm_prefix_requirement=yes
 else
   grub_cv_asm_prefix_requirement=no
@@ -1784,7 +1786,7 @@
 
 
 echo $ac_n "checking for .code16 addr32 assembler support""... $ac_c" 1>&6
-echo "configure:1788: checking for .code16 addr32 assembler support" >&5
+echo "configure:1790: checking for .code16 addr32 assembler support" >&5
 if eval "test \"`echo '$''{'grub_cv_asm_addr32'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1799,7 +1801,7 @@
   sed -e s/@ADDR32@/addr32\;/ < conftest.s.in > conftest.s
 fi
 
-if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'; { (eval echo configure:1803: 
\"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then
+if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'; { (eval echo configure:1805: 
+\"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then
   grub_cv_asm_addr32=yes
 else
   grub_cv_asm_addr32=no
@@ -1816,19 +1818,19 @@
 
 
 echo $ac_n "checking if start is defined by the compiler""... $ac_c" 1>&6
-echo "configure:1820: checking if start is defined by the compiler" >&5
+echo "configure:1822: checking if start is defined by the compiler" >&5
 if eval "test \"`echo '$''{'grub_cv_check_start_symbol'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1825 "configure"
+#line 1827 "configure"
 #include "confdefs.h"
 
 int main() {
 asm ("incl start")
 ; return 0; }
 EOF
-if { (eval echo configure:1832: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
-s conftest${ac_exeext}; then
+if { (eval echo configure:1834: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
+-s conftest${ac_exeext}; then
   rm -rf conftest*
   grub_cv_check_start_symbol=yes
 else
@@ -1852,19 +1854,19 @@
 
 
 echo $ac_n "checking if _start is defined by the compiler""... $ac_c" 1>&6
-echo "configure:1856: checking if _start is defined by the compiler" >&5
+echo "configure:1858: checking if _start is defined by the compiler" >&5
 if eval "test \"`echo '$''{'grub_cv_check_uscore_start_symbol'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1861 "configure"
+#line 1863 "configure"
 #include "confdefs.h"
 
 int main() {
 asm ("incl _start")
 ; return 0; }
 EOF
-if { (eval echo configure:1868: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
-s conftest${ac_exeext}; then
+if { (eval echo configure:1870: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
+-s conftest${ac_exeext}; then
   rm -rf conftest*
   grub_cv_check_uscore_start_symbol=yes
 else
@@ -1893,19 +1895,19 @@
 
 
 echo $ac_n "checking if __bss_start is defined by the compiler""... $ac_c" 1>&6
-echo "configure:1897: checking if __bss_start is defined by the compiler" >&5
+echo "configure:1899: checking if __bss_start is defined by the compiler" >&5
 if eval "test \"`echo '$''{'grub_cv_check_uscore_uscore_bss_start_symbol'+set}'`\" = 
set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1902 "configure"
+#line 1904 "configure"
 #include "confdefs.h"
 
 int main() {
 asm ("incl __bss_start")
 ; return 0; }
 EOF
-if { (eval echo configure:1909: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
-s conftest${ac_exeext}; then
+if { (eval echo configure:1911: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
+-s conftest${ac_exeext}; then
   rm -rf conftest*
   grub_cv_check_uscore_uscore_bss_start_symbol=yes
 else
@@ -1929,19 +1931,19 @@
 
 
 echo $ac_n "checking if _edata is defined by the compiler""... $ac_c" 1>&6
-echo "configure:1933: checking if _edata is defined by the compiler" >&5
+echo "configure:1935: checking if _edata is defined by the compiler" >&5
 if eval "test \"`echo '$''{'grub_cv_check_uscore_edata_symbol'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1938 "configure"
+#line 1940 "configure"
 #include "confdefs.h"
 
 int main() {
 asm ("incl _edata")
 ; return 0; }
 EOF
-if { (eval echo configure:1945: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
-s conftest${ac_exeext}; then
+if { (eval echo configure:1947: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
+-s conftest${ac_exeext}; then
   rm -rf conftest*
   grub_cv_check_uscore_edata_symbol=yes
 else
@@ -1965,19 +1967,19 @@
 
 
 echo $ac_n "checking if edata is defined by the compiler""... $ac_c" 1>&6
-echo "configure:1969: checking if edata is defined by the compiler" >&5
+echo "configure:1971: checking if edata is defined by the compiler" >&5
 if eval "test \"`echo '$''{'grub_cv_check_edata_symbol'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1974 "configure"
+#line 1976 "configure"
 #include "confdefs.h"
 
 int main() {
 asm ("incl edata")
 ; return 0; }
 EOF
-if { (eval echo configure:1981: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
-s conftest${ac_exeext}; then
+if { (eval echo configure:1983: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
+-s conftest${ac_exeext}; then
   rm -rf conftest*
   grub_cv_check_edata_symbol=yes
 else
@@ -2007,19 +2009,19 @@
 
 
 echo $ac_n "checking if end is defined by the compiler""... $ac_c" 1>&6
-echo "configure:2011: checking if end is defined by the compiler" >&5
+echo "configure:2013: checking if end is defined by the compiler" >&5
 if eval "test \"`echo '$''{'grub_cv_check_end_symbol'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2016 "configure"
+#line 2018 "configure"
 #include "confdefs.h"
 
 int main() {
 asm ("incl end")
 ; return 0; }
 EOF
-if { (eval echo configure:2023: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
-s conftest${ac_exeext}; then
+if { (eval echo configure:2025: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
+-s conftest${ac_exeext}; then
   rm -rf conftest*
   grub_cv_check_end_symbol=yes
 else
@@ -2043,19 +2045,19 @@
 
 
 echo $ac_n "checking if _end is defined by the compiler""... $ac_c" 1>&6
-echo "configure:2047: checking if _end is defined by the compiler" >&5
+echo "configure:2049: checking if _end is defined by the compiler" >&5
 if eval "test \"`echo '$''{'grub_cv_check_uscore_end_symbol'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2052 "configure"
+#line 2054 "configure"
 #include "confdefs.h"
 
 int main() {
 asm ("incl _end")
 ; return 0; }
 EOF
-if { (eval echo configure:2059: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
-s conftest${ac_exeext}; then
+if { (eval echo configure:2061: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
+-s conftest${ac_exeext}; then
   rm -rf conftest*
   grub_cv_check_uscore_end_symbol=yes
 else
@@ -2093,7 +2095,7 @@
 # Get the filename or the whole disk and open it.
 # Known to work on NetBSD.
 echo $ac_n "checking for opendisk in -lutil""... $ac_c" 1>&6
-echo "configure:2097: checking for opendisk in -lutil" >&5
+echo "configure:2099: checking for opendisk in -lutil" >&5
 ac_lib_var=`echo util'_'opendisk | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2101,7 +2103,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lutil  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2105 "configure"
+#line 2107 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2112,7 +2114,7 @@
 opendisk()
 ; return 0; }
 EOF
-if { (eval echo configure:2116: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
-s conftest${ac_exeext}; then
+if { (eval echo configure:2118: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
+-s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2140,7 +2142,7 @@
 # Unless the user specify --without-curses, check for curses.
 if test "x$with_curses" != "xno"; then
   echo $ac_n "checking for wgetch in -lncurses""... $ac_c" 1>&6
-echo "configure:2144: checking for wgetch in -lncurses" >&5
+echo "configure:2146: checking for wgetch in -lncurses" >&5
 ac_lib_var=`echo ncurses'_'wgetch | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2148,7 +2150,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lncurses  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2152 "configure"
+#line 2154 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2159,7 +2161,7 @@
 wgetch()
 ; return 0; }
 EOF
-if { (eval echo configure:2163: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
-s conftest${ac_exeext}; then
+if { (eval echo configure:2165: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
+-s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2182,7 +2184,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for wgetch in -lcurses""... $ac_c" 1>&6
-echo "configure:2186: checking for wgetch in -lcurses" >&5
+echo "configure:2188: checking for wgetch in -lcurses" >&5
 ac_lib_var=`echo curses'_'wgetch | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2190,7 +2192,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lcurses  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2194 "configure"
+#line 2196 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2201,7 +2203,7 @@
 wgetch()
 ; return 0; }
 EOF
-if { (eval echo configure:2205: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
-s conftest${ac_exeext}; then
+if { (eval echo configure:2207: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test 
+-s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2236,17 +2238,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2240: checking for $ac_hdr" >&5
+echo "configure:2242: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2245 "configure"
+#line 2247 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2250: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2252: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2623,6 +2625,19 @@
 fi
 
 
+# Check whether --enable-diskless or --disable-diskless was given.
+if test "${enable_diskless+set}" = set; then
+  enableval="$enable_diskless"
+  :
+fi
+
+if test "x$enable_diskless" = xyes; then
+  DISKLESS_CFLAGS="-DGRUB_DISKLESS=1"
+else
+  DISKLESS_CFLAGS=
+fi
+
+
 
 if test "x$NET_CFLAGS" != x; then
   NETBOOT_SUPPORT_TRUE=
@@ -2631,10 +2646,23 @@
   NETBOOT_SUPPORT_TRUE='#'
   NETBOOT_SUPPORT_FALSE=
 fi
+
+
+if test "xDISKLESS_CFLAGS" != x; then
+  DISKLESS_SUPPORT_TRUE=
+  DISKLESS_SUPPORT_FALSE='#'
+else
+  DISKLESS_SUPPORT_TRUE='#'
+  DISKLESS_SUPPORT_FALSE=
+fi
 if test "x$NET_CFLAGS" != x; then
   FSYS_CFLAGS="$FSYS_CFLAGS -DFSYS_TFTP=1"
+  if test "x$DISKLESS_CFLAGS" != x; then
+    NET_CFLAGS="$NET_CFLAGS $DISKLESS_CFLAGS"
+  fi
 fi
 
+
 # Check whether --enable-3c503-shmem or --disable-3c503-shmem was given.
 if test "${enable_3c503_shmem+set}" = set; then
   enableval="$enable_3c503_shmem"
@@ -2891,6 +2919,8 @@
 s%@GRUB_LIBS@%$GRUB_LIBS%g
 s%@NETBOOT_SUPPORT_TRUE@%$NETBOOT_SUPPORT_TRUE%g
 s%@NETBOOT_SUPPORT_FALSE@%$NETBOOT_SUPPORT_FALSE%g
+s%@DISKLESS_SUPPORT_TRUE@%$DISKLESS_SUPPORT_TRUE%g
+s%@DISKLESS_SUPPORT_FALSE@%$DISKLESS_SUPPORT_FALSE%g
 s%@FSYS_CFLAGS@%$FSYS_CFLAGS%g
 s%@NET_CFLAGS@%$NET_CFLAGS%g
 s%@NET_EXTRAFLAGS@%$NET_EXTRAFLAGS%g
Index: configure.in
===================================================================
RCS file: /cvs/grub/configure.in,v
retrieving revision 1.38
diff -u -r1.38 configure.in
--- configure.in        2000/04/12 03:10:07     1.38
+++ configure.in        2000/04/13 22:37:37
@@ -400,13 +400,28 @@
   NETBOOT_DRIVERS="$NETBOOT_DRIVERS via_rhine.o"
 fi
 
+dnl Extra options
+
+AC_ARG_ENABLE(diskless,
+  [  --enable-diskless       enable diskless GRUB operation (netboot)])
+if test "x$enable_diskless" = xyes; then
+  DISKLESS_CFLAGS="-DGRUB_DISKLESS=1"
+else
+  DISKLESS_CFLAGS=
+fi
+
 dnl Check if the netboot support is turned on.
 AM_CONDITIONAL(NETBOOT_SUPPORT, test "x$NET_CFLAGS" != x)
+AM_CONDITIONAL(DISKLESS_SUPPORT, test "xDISKLESS_CFLAGS" != x)
 if test "x$NET_CFLAGS" != x; then
   FSYS_CFLAGS="$FSYS_CFLAGS -DFSYS_TFTP=1"
+  if test "x$DISKLESS_CFLAGS" != x; then
+    NET_CFLAGS="$NET_CFLAGS $DISKLESS_CFLAGS"
+  fi
 fi
+
+dnl More extra options.
 
-dnl Extra options.
 AC_ARG_ENABLE(3c503-shmem,
   [  --enable-3c503-shmem    use 3c503 shared memory mode])
 if test "x$enable_3c503_shmem" = xyes; then
Index: debian/Makefile.in
===================================================================
RCS file: /cvs/grub/debian/Makefile.in,v
retrieving revision 1.22
diff -u -r1.22 Makefile.in
--- debian/Makefile.in  2000/03/27 07:57:30     1.22
+++ debian/Makefile.in  2000/04/13 22:37:38
@@ -31,8 +31,6 @@
 includedir = @includedir@
 oldincludedir = /usr/include
 
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
Index: docs/Makefile.in
===================================================================
RCS file: /cvs/grub/docs/Makefile.in,v
retrieving revision 1.33
diff -u -r1.33 Makefile.in
--- docs/Makefile.in    2000/03/27 07:57:30     1.33
+++ docs/Makefile.in    2000/04/13 22:37:40
@@ -31,8 +31,6 @@
 includedir = @includedir@
 oldincludedir = /usr/include
 
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
Index: grub/Makefile.in
===================================================================
RCS file: /cvs/grub/grub/Makefile.in,v
retrieving revision 1.27
diff -u -r1.27 Makefile.in
--- grub/Makefile.in    2000/03/27 07:57:30     1.27
+++ grub/Makefile.in    2000/04/13 22:37:44
@@ -31,8 +31,6 @@
 includedir = @includedir@
 oldincludedir = /usr/include
 
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
Index: lib/Makefile.in
===================================================================
RCS file: /cvs/grub/lib/Makefile.in,v
retrieving revision 1.7
diff -u -r1.7 Makefile.in
--- lib/Makefile.in     2000/03/27 07:57:31     1.7
+++ lib/Makefile.in     2000/04/13 22:37:45
@@ -31,8 +31,6 @@
 includedir = @includedir@
 oldincludedir = /usr/include
 
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
Index: netboot/Makefile.in
===================================================================
RCS file: /cvs/grub/netboot/Makefile.in,v
retrieving revision 1.11
diff -u -r1.11 Makefile.in
--- netboot/Makefile.in 2000/03/27 07:57:31     1.11
+++ netboot/Makefile.in 2000/04/13 22:37:49
@@ -31,8 +31,6 @@
 includedir = @includedir@
 oldincludedir = /usr/include
 
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
Index: netboot/main.c
===================================================================
RCS file: /cvs/grub/netboot/main.c,v
retrieving revision 1.5
diff -u -r1.5 main.c
--- netboot/main.c      2000/02/12 07:00:47     1.5
+++ netboot/main.c      2000/04/13 22:37:52
@@ -34,6 +34,12 @@
 
 #include <netboot_config.h>
 
+#ifdef GRUB_DISKLESS
+#include "netbooted.h"
+/* config_file string, allocated statically in stage2/asm.S */
+extern char config_file[];
+#endif
+
 struct arptable_t arptable[MAX_ARP];
 
 /* Set if the user pushes Control-C.  */
@@ -866,6 +872,19 @@
              p++;
              continue;
            }
+#ifdef GRUB_DISKLESS
+         else if (c == BOOTP_GRUBMENU_TAG)  /* special code (netbooted.h) */
+           {
+             int l;
+             
+              p++;
+             l = (int)(*(char *)p);
+             p++;
+             grub_memmove((void *)config_file,p,l);
+             p += l;
+             continue;
+           }
+#endif /* GRUB_DISKLESS */
          else if (c == RFC1533_END)
            {
              end_of_rfc1533 = end = p;
Index: stage1/Makefile.in
===================================================================
RCS file: /cvs/grub/stage1/Makefile.in,v
retrieving revision 1.30
diff -u -r1.30 Makefile.in
--- stage1/Makefile.in  2000/04/11 03:08:52     1.30
+++ stage1/Makefile.in  2000/04/13 22:37:54
@@ -30,8 +30,6 @@
 mandir = @mandir@
 includedir = @includedir@
 oldincludedir = /usr/include
-
-DESTDIR =
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 
Index: stage2/Makefile.am
===================================================================
RCS file: /cvs/grub/stage2/Makefile.am,v
retrieving revision 1.22
diff -u -r1.22 Makefile.am
--- stage2/Makefile.am  2000/03/27 07:57:31     1.22
+++ stage2/Makefile.am  2000/04/13 22:37:55
@@ -21,19 +21,37 @@
 
 # Stage 2 and Stage 1.5's.
 pkgdatadir = $(datadir)/$(PACKAGE)/$(host_cpu)-$(host_vendor)
+if DISKLESS_SUPPORT
 pkgdata_DATA = stage2 e2fs_stage1_5 fat_stage1_5 ffs_stage1_5 \
+       minix_stage1_5 nbloader nbGrub
+else
+pkgdata_DATA = stage2 e2fs_stage1_5 fat_stage1_5 ffs_stage1_5 \
        minix_stage1_5
+endif
 noinst_DATA = pre_stage2 start
+if DISKLESS_SUPPORT
+noinst_PROGRAMS = pre_stage2.exec start.exec nbloader.exec \
+       e2fs_stage1_5.exec fat_stage1_5.exec \
+       ffs_stage1_5.exec minix_stage1_5.exec
+else
 noinst_PROGRAMS = pre_stage2.exec start.exec \
        e2fs_stage1_5.exec fat_stage1_5.exec \
        ffs_stage1_5.exec minix_stage1_5.exec
+endif
 MOSTLYCLEANFILES = $(noinst_PROGRAMS)
 
 PRE_STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8200
 START_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000
+NBLOADER_LINK = $(START_LINK)
+
 if NETBOOT_SUPPORT
+if DISKLESS_SUPPORT
+STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
+       -I$(top_srcdir)/netboot -DSUPPORT_NETBOOT=1 -DGRUB_DISKLESS=1
+else
 STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
        -I$(top_srcdir)/netboot -DSUPPORT_NETBOOT=1
+endif
 else
 STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc
 endif
@@ -70,9 +88,19 @@
 # will be broken.
 start_exec-start.o: stage2_size.h
 
+nbloader_exec_SOURCES = nbloader.S
+nbloader_exec_CFLAGS = $(STAGE2_COMPILE)
+nbloader_exec_LDFLAGS = $(NBLOADER_LINK)
+
 stage2: pre_stage2 start
        -rm -f stage2
        cat start pre_stage2 > stage2
+
+if DISKLESS_SUPPORT 
+nbGrub: nbloader stage2
+       -rm -f nbGrub
+       mknbi-grub nbloader stage2 nbGrub
+endif
 
 # For e2fs_stage1_5 target.
 e2fs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \
Index: stage2/Makefile.in
===================================================================
RCS file: /cvs/grub/stage2/Makefile.in,v
retrieving revision 1.36
diff -u -r1.36 Makefile.in
--- stage2/Makefile.in  2000/03/27 07:57:31     1.36
+++ stage2/Makefile.in  2000/04/13 22:38:00
@@ -30,8 +30,6 @@
 mandir = @mandir@
 includedir = @includedir@
 oldincludedir = /usr/include
-
-DESTDIR =
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 
@@ -114,20 +112,26 @@
 
 # Stage 2 and Stage 1.5's.
 pkgdatadir = $(datadir)/$(PACKAGE)/$(host_cpu)-$(host_vendor)
-pkgdata_DATA = stage2 e2fs_stage1_5 fat_stage1_5 ffs_stage1_5 \
-       minix_stage1_5
-
+@DISKLESS_SUPPORT_TRUE@pkgdata_DATA = @DISKLESS_SUPPORT_TRUE@stage2 e2fs_stage1_5 
+fat_stage1_5 ffs_stage1_5 \
+@DISKLESS_SUPPORT_TRUE@        minix_stage1_5 nbloader nbGrub
+@DISKLESS_SUPPORT_FALSE@pkgdata_DATA = @DISKLESS_SUPPORT_FALSE@stage2 e2fs_stage1_5 
+fat_stage1_5 ffs_stage1_5 \
+@DISKLESS_SUPPORT_FALSE@       minix_stage1_5
 noinst_DATA = pre_stage2 start
-noinst_PROGRAMS = pre_stage2.exec start.exec \
-       e2fs_stage1_5.exec fat_stage1_5.exec \
-       ffs_stage1_5.exec minix_stage1_5.exec
-
+@DISKLESS_SUPPORT_TRUE@noinst_PROGRAMS = @[EMAIL PROTECTED] 
+start.exec nbloader.exec \
+@DISKLESS_SUPPORT_TRUE@        e2fs_stage1_5.exec fat_stage1_5.exec \
+@DISKLESS_SUPPORT_TRUE@        ffs_stage1_5.exec minix_stage1_5.exec
+@DISKLESS_SUPPORT_FALSE@noinst_PROGRAMS = @[EMAIL PROTECTED] 
+start.exec \
+@DISKLESS_SUPPORT_FALSE@       e2fs_stage1_5.exec fat_stage1_5.exec \
+@DISKLESS_SUPPORT_FALSE@       ffs_stage1_5.exec minix_stage1_5.exec
 MOSTLYCLEANFILES = $(noinst_PROGRAMS)
 
 PRE_STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8200
 START_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000
-@NETBOOT_SUPPORT_TRUE@STAGE2_COMPILE = @NETBOOT_SUPPORT_TRUE@$(STAGE2_CFLAGS) 
-fno-builtin -nostdinc \
-@NETBOOT_SUPPORT_TRUE@ -I$(top_srcdir)/netboot -DSUPPORT_NETBOOT=1
+NBLOADER_LINK = $(START_LINK)
+@NETBOOT_SUPPORT_TRUE@@DISKLESS_SUPPORT_TRUE@STAGE2_COMPILE = 
+@NETBOOT_SUPPORT_TRUE@@DISKLESS_SUPPORT_TRUE@$(STAGE2_CFLAGS) -fno-builtin -nostdinc \
+@NETBOOT_SUPPORT_TRUE@@DISKLESS_SUPPORT_TRUE@  -I$(top_srcdir)/netboot 
+-DSUPPORT_NETBOOT=1 -DGRUB_DISKLESS=1
+@NETBOOT_SUPPORT_TRUE@@DISKLESS_SUPPORT_FALSE@STAGE2_COMPILE = 
+@NETBOOT_SUPPORT_TRUE@@DISKLESS_SUPPORT_FALSE@$(STAGE2_CFLAGS) -fno-builtin -nostdinc 
+\
+@NETBOOT_SUPPORT_TRUE@@DISKLESS_SUPPORT_FALSE@ -I$(top_srcdir)/netboot 
+-DSUPPORT_NETBOOT=1
 @NETBOOT_SUPPORT_FALSE@STAGE2_COMPILE = @NETBOOT_SUPPORT_FALSE@$(STAGE2_CFLAGS) 
-fno-builtin -nostdinc
 
 STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
@@ -150,6 +154,10 @@
 start_exec_CFLAGS = $(STAGE2_COMPILE)
 start_exec_LDFLAGS = $(START_LINK)
 
+nbloader_exec_SOURCES = nbloader.S
+nbloader_exec_CFLAGS = $(STAGE2_COMPILE)
+nbloader_exec_LDFLAGS = $(NBLOADER_LINK)
+
 # For e2fs_stage1_5 target.
 e2fs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \
        stage1_5.c fsys_ext2fs.c bios.c
@@ -240,6 +248,10 @@
 minix_stage1_5_exec_OBJECTS =  $(am_minix_stage1_5_exec_OBJECTS)
 minix_stage1_5_exec_LDADD = $(LDADD)
 minix_stage1_5_exec_DEPENDENCIES = 
+am_nbloader_exec_OBJECTS =  nbloader_exec-nbloader.o
+nbloader_exec_OBJECTS =  $(am_nbloader_exec_OBJECTS)
+nbloader_exec_LDADD = $(LDADD)
+nbloader_exec_DEPENDENCIES = 
 am_pre_stage2_exec_OBJECTS =  pre_stage2_exec-asm.o \
 pre_stage2_exec-bios.o pre_stage2_exec-boot.o \
 pre_stage2_exec-builtins.o pre_stage2_exec-common.o \
@@ -263,8 +275,8 @@
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 DIST_SOURCES =  $(libgrub_a_SOURCES) $(e2fs_stage1_5_exec_SOURCES) \
 $(fat_stage1_5_exec_SOURCES) $(ffs_stage1_5_exec_SOURCES) \
-$(minix_stage1_5_exec_SOURCES) $(pre_stage2_exec_SOURCES) \
-$(start_exec_SOURCES)
+$(minix_stage1_5_exec_SOURCES) $(nbloader_exec_SOURCES) \
+$(pre_stage2_exec_SOURCES) $(start_exec_SOURCES)
 DATA =  $(noinst_DATA) $(pkgdata_DATA)
 
 HEADERS =  $(noinst_HEADERS)
@@ -304,7 +316,8 @@
 $(DEPDIR)/minix_stage1_5_exec-disk_io.Po \
 $(DEPDIR)/minix_stage1_5_exec-fsys_minix.Po \
 $(DEPDIR)/minix_stage1_5_exec-stage1_5.Po \
-$(DEPDIR)/minix_stage1_5_exec-start.Po $(DEPDIR)/pre_stage2_exec-asm.Po \
+$(DEPDIR)/minix_stage1_5_exec-start.Po \
+$(DEPDIR)/nbloader_exec-nbloader.Po $(DEPDIR)/pre_stage2_exec-asm.Po \
 $(DEPDIR)/pre_stage2_exec-bios.Po $(DEPDIR)/pre_stage2_exec-boot.Po \
 $(DEPDIR)/pre_stage2_exec-builtins.Po \
 $(DEPDIR)/pre_stage2_exec-char_io.Po \
@@ -324,8 +337,8 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 
 GZIP_ENV = --best
-SOURCES = $(libgrub_a_SOURCES) $(e2fs_stage1_5_exec_SOURCES) 
$(fat_stage1_5_exec_SOURCES) $(ffs_stage1_5_exec_SOURCES) 
$(minix_stage1_5_exec_SOURCES) $(pre_stage2_exec_SOURCES) $(start_exec_SOURCES)
-OBJECTS = $(am_libgrub_a_OBJECTS) $(am_e2fs_stage1_5_exec_OBJECTS) 
$(am_fat_stage1_5_exec_OBJECTS) $(am_ffs_stage1_5_exec_OBJECTS) 
$(am_minix_stage1_5_exec_OBJECTS) $(am_pre_stage2_exec_OBJECTS) 
$(am_start_exec_OBJECTS)
+SOURCES = $(libgrub_a_SOURCES) $(e2fs_stage1_5_exec_SOURCES) 
+$(fat_stage1_5_exec_SOURCES) $(ffs_stage1_5_exec_SOURCES) 
+$(minix_stage1_5_exec_SOURCES) $(nbloader_exec_SOURCES) $(pre_stage2_exec_SOURCES) 
+$(start_exec_SOURCES)
+OBJECTS = $(am_libgrub_a_OBJECTS) $(am_e2fs_stage1_5_exec_OBJECTS) 
+$(am_fat_stage1_5_exec_OBJECTS) $(am_ffs_stage1_5_exec_OBJECTS) 
+$(am_minix_stage1_5_exec_OBJECTS) $(am_nbloader_exec_OBJECTS) 
+$(am_pre_stage2_exec_OBJECTS) $(am_start_exec_OBJECTS)
 
 all: all-redirect
 .SUFFIXES:
@@ -438,6 +451,12 @@
 minix_stage1_5.exec: $(minix_stage1_5_exec_OBJECTS) 
$(minix_stage1_5_exec_DEPENDENCIES)
        @rm -f minix_stage1_5.exec
        $(LINK) $(minix_stage1_5_exec_LDFLAGS) $(minix_stage1_5_exec_OBJECTS) 
$(minix_stage1_5_exec_LDADD) $(LIBS)
+nbloader_exec-nbloader.o: nbloader.S
+       $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nbloader_exec_CFLAGS) 
+$(CFLAGS) -c -o nbloader_exec-nbloader.o `test -f nbloader.S || echo 
+'$(srcdir)/'`nbloader.S
+
+nbloader.exec: $(nbloader_exec_OBJECTS) $(nbloader_exec_DEPENDENCIES)
+       @rm -f nbloader.exec
+       $(LINK) $(nbloader_exec_LDFLAGS) $(nbloader_exec_OBJECTS) 
+$(nbloader_exec_LDADD) $(LIBS)
 pre_stage2_exec-asm.o: asm.S
        $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pre_stage2_exec_CFLAGS) 
$(CFLAGS) -c -o pre_stage2_exec-asm.o `test -f asm.S || echo '$(srcdir)/'`asm.S
 pre_stage2_exec-bios.o: bios.c
@@ -562,6 +581,7 @@
 @AMDEP@include $(DEPDIR)/minix_stage1_5_exec-fsys_minix.Po
 @AMDEP@include $(DEPDIR)/minix_stage1_5_exec-stage1_5.Po
 @AMDEP@include $(DEPDIR)/minix_stage1_5_exec-start.Po
+@AMDEP@include $(DEPDIR)/nbloader_exec-nbloader.Po
 @AMDEP@include $(DEPDIR)/pre_stage2_exec-asm.Po
 @AMDEP@include $(DEPDIR)/pre_stage2_exec-bios.Po
 @AMDEP@include $(DEPDIR)/pre_stage2_exec-boot.Po
@@ -1160,6 +1180,10 @@
 stage2: pre_stage2 start
        -rm -f stage2
        cat start pre_stage2 > stage2
+
+@DISKLESS_SUPPORT_TRUE@nbGrub: nbloader stage2
+@DISKLESS_SUPPORT_TRUE@        -rm -f nbGrub
+@DISKLESS_SUPPORT_TRUE@        mknbi-grub nbloader stage2 nbGrub
 
 # General rule for making a raw binary.
 %: %.exec
Index: stage2/asm.S
===================================================================
RCS file: /cvs/grub/stage2/asm.S,v
retrieving revision 1.26
diff -u -r1.26 asm.S
--- stage2/asm.S        2000/02/07 05:14:46     1.26
+++ stage2/asm.S        2000/04/13 22:38:06
@@ -78,6 +78,10 @@
 VARIABLE(config_file)
 #ifndef STAGE1_5
        .string "/boot/grub/menu.lst"
+       /* additional space for longer names used in diskless operation */
+#ifdef GRUB_DISKLESS   
+       .string "                          "
+#endif 
 #else   /* STAGE1_5 */
        .long   0xffffffff
        .string "/boot/grub/stage2"
Index: stage2/char_io.c
===================================================================
RCS file: /cvs/grub/stage2/char_io.c,v
retrieving revision 1.24
diff -u -r1.24 char_io.c
--- stage2/char_io.c    2000/04/02 17:22:53     1.24
+++ stage2/char_io.c    2000/04/13 22:38:09
@@ -173,7 +173,9 @@
 void
 init_page (void)
 {
+#ifndef GRUB_DEBUG_DISKLESS
   cls ();
+#endif
 
   printf ("\n    GRUB  version %s  (%dK lower / %dK upper memory)\n\n",
          version_string, mbi.mem_lower, mbi.mem_upper);
Index: stage2/stage2.c
===================================================================
RCS file: /cvs/grub/stage2/stage2.c,v
retrieving revision 1.13
diff -u -r1.13 stage2.c
--- stage2/stage2.c     2000/04/11 03:08:52     1.13
+++ stage2/stage2.c     2000/04/13 22:38:12
@@ -20,6 +20,11 @@
 
 #include "shared.h"
 
+#ifdef GRUB_DISKLESS
+#include "etherboot.h"
+#include "netbooted.h"
+#endif
+
 grub_jmp_buf restart_env;
 
 static char *
@@ -578,6 +583,70 @@
   return pos;
 }
 
+/* query if grub was diskless netbooted  */
+
+#ifdef GRUB_DISKLESS
+
+int 
+grub_netbooted (void)
+{
+  /* check for netboot header magic */
+
+  if (*((unsigned *) RAW_ADDR ( NETBOOT_DEST_ADDR )) == NETBOOT_MAGIC)
+    {
+#ifdef GRUB_DEBUG_DISKLESS
+      grub_printf ("\nGrub was netbooted\n");
+#endif
+      return (1);
+    }
+  return (0);
+}
+
+/* do bootp request and setup root on network device */
+
+void
+grub_setup_diskless (void)
+{
+  char *p;
+  
+  if (grub_netbooted ())
+    {
+      /* bootp call */
+      if (! bootp ())
+       {
+#ifdef GRUB_DEBUG_DISKLESS
+         grub_printf ("bootp for diskless operation fails\n");
+#endif
+         return;   /* stop diskless setup, grub_open will fail then */
+       }
+#ifdef GRUB_DEBUG_DISKLESS
+      print_network_configuration ();
+#endif
+      /* set root to '(nd)' */
+      p = set_device ("(nd)");
+      if (! p)
+       {
+#ifdef GRUB_DEBUG_DISKLESS
+         grub_printf ("set root for diskless operation fails <1>\n");
+#endif
+         return;   /* stop diskless setup, grub_open will fail then */
+       }
+      if (! open_device () && errnum != ERR_FSYS_MOUNT)
+       {
+#ifdef GRUB_DEBUG_DISKLESS
+         grub_printf ("set root for diskless operation fails <2>\n");
+#endif
+         return;   /* stop diskless setup, grub_open will fail then */
+       }
+      saved_partition = current_partition;
+      saved_drive = current_drive;
+#ifdef GRUB_DEBUG_DISKLESS
+      print_fsys_type ();
+#endif
+    }
+}
+
+#endif /* GRUB_DISKLESS */
 
 /* This is the starting function in C.  */
 void
@@ -604,6 +673,16 @@
       init_config ();
 
       /* Here load the configuration file.  */
+#ifdef GRUB_DISKLESS
+#ifdef GRUB_UTIL
+      if (use_config_file)
+       {
+#endif
+         grub_setup_diskless ();
+#ifdef GRUB_UTIL
+       }
+#endif
+#endif /* GRUB_DISKLESS */
 
 #ifdef GRUB_UTIL
       if (use_config_file && grub_open (config_file))
Index: util/Makefile.in
===================================================================
RCS file: /cvs/grub/util/Makefile.in,v
retrieving revision 1.7
diff -u -r1.7 Makefile.in
--- util/Makefile.in    2000/03/27 07:57:31     1.7
+++ util/Makefile.in    2000/04/13 22:38:13
@@ -31,8 +31,6 @@
 includedir = @includedir@
 oldincludedir = /usr/include
 
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
/*  -*-c-*-
 * $Id$
 *  
 * Abstract:
 *     File for diskless grub support
 * 
 * Modifications:
 * $Log$
 *
 */

#ifndef __netbooted_h__
#define __netbooted_h__

#define NETBOOT_MAGIC          0x1B031336
#define NETBOOT_DEST_ADDR      0x8000
#define BOOTP_GRUBMENU_TAG     99
#define MAX_STAGE2_BLOCKS      200

#endif /* __netbooted_h__ */
/* -*-Asm-*- */
/*
 *  GRUB  --  GRand Unified Bootloader
 *  Copyright (C) 1996   Erich Boleyn  <[EMAIL PROTECTED]>
 *  Copyright (C) 1999,2000   Free Software Foundation, Inc.
 *
 *  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; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <stage1.h>
#include <netbooted.h>
                
/*
 *  defines for the code go here
 */

        /* Absolute addresses
           This makes the assembler generate the address without support
           from the linker. (ELF can't relocate 16-bit addresses!) */
#define ABS(x) (x-_start+0x8000)

        .file   "stage1_nb.S"

        .text

        /* Tell GAS to generate 16-bit instructions so that this code works
           in real mode. */
        .code16

.globl _start; _start:
        /*
         * _start is loaded at 0x7c00 and is jumped to with CS:IP 0:0x7c00
         */

        /*
         * netboot image header
         */

        .long NETBOOT_MAGIC
        .long 0x00000004
        .word NETBOOT_DEST_ADDR
                                /* load address of the first block  */
        .word 0x0000  
        .word NETBOOT_DEST_ADDR + 0x0200
                                /* start addr of the code (stage 2) */
        .word 0x0000

        .long 0x04000004
        .long NETBOOT_DEST_ADDR + 0x0200
        .long (MAX_STAGE2_BLOCKS * 512)
        .long (MAX_STAGE2_BLOCKS * 512)
        
        . = _start + STAGE1_PARTEND

/* the last 2 bytes in the sector 0 contain the signature */
        .word   STAGE1_SIGNATURE

#!/bin/bash
#++
#
#   $Id$
#
#   mknbi-xxxx creates a netboot image of grub
#
#   usage:
#         mknbi-grub stage1_nb stage2 nb-imagename
#   $Log$
#
#--

# set -x

INC_CONF_H=./netbooted.h

if [ ! -f $CFG_INC ] ; then
        echo $0: cannot find $CFG_INC, abort.
        exit 1
fi

if [ $# -lt 3 ] ; then
        echo $0: invalid numbers of arguments "($#)", abort.
        exit 1
fi

NBIMAGE=$3
BOOTPATH=`dirname $1`

if [ ! -f $1 ] ; then
        echo $0: cannont find boot sector $1, abort.
        exit 1
fi

if [ ! -f $2 ] ; then
        echo $0: cannont find input image $2, abort.
        exit 1
fi

cp $1 $NBIMAGE
dd if=$2 of=$BOOTPATH/tmpImage bs=512 skip=1
cat $BOOTPATH/tmpImage >> $NBIMAGE

MAXBLKS=`grep "MAX_STAGE2_BLOCKS" $INC_CONF_H | \
         sed 's/^.*\( [0-9abcdefABCDEF]\)/\1/' |\
         sed 's/ //'`

echo Configured block size is $MAXBLKS

set dummy `ls -l $BOOTPATH/tmpImage`
echo $6
PADZERO=$(($MAXBLKS * 512 - $6))

dd if=/dev/zero of=$BOOTPATH/zeropad bs=1 count=$PADZERO
cat $BOOTPATH/zeropad >> $NBIMAGE

rm -f $BOOTPATH/tmpImage $BOOTPATH/zeropad
echo $NBIMAGE is written
sync


Reply via email to