I'm not sure if this patch fits with the philosophy of grub design,
so I'm separating it from the rest of my PXE patch.
My PXE patch creates a "pxegrub" binary that is basically a grub
stage2 that expects to be loaded at 7C00. There is one other minor
difference, though: Anything loaded by PXE is loaded over the network,
so the concept of "boot drive" really doesn't apply in the normal way.
Therefore, pxegrub's boot_drive is initialized to NETWORK_DRIVE.
However, just setting boot_drive isn't enough. You also need a
working network address, or you can't even load a config file.
Therefore, this patch makes pxegrub (or stage2) notice when boot_drive
is NETWORK_DRIVE; and when it is, automatically call bootp() and print
the results. This allows a PXE-booted grub to load a config file via
tftp.
This patch is safe, I think: No current usage of grub sets boot_drive
to NETWORK_DRIVE, so this patch cannot break any existing behavior.
The main question, IMO, is whether it's wise always to use bootp/dhcp
rather than some other network config method. I think it's OK, but
then, I wrote it. :-)
2000-05-19 Chip Salzenberg <[EMAIL PROTECTED]>
* stage2/stage2.c (cmain): If network drive is boot drive,
perhaps due to PXE boot, autoconfig with bootp/dhcp.
* stage2/cmdline.c (enter_cmdline): If network drive is boot
drive, print network config at startup.
Index: stage2/stage2.c
diff -u -2 -r1.14 stage2.c
--- stage2/stage2.c 2000/04/22 23:29:23 1.14
+++ stage2/stage2.c 2000/05/20 05:05:46
@@ -21,4 +21,8 @@
#include "shared.h"
+#ifdef SUPPORT_NETBOOT
+# include <etherboot.h>
+#endif
+
grub_jmp_buf restart_env;
@@ -604,4 +608,9 @@
char *config_entries, *menu_entries;
char *kill = (char *) KILL_BUF;
+
+#ifdef SUPPORT_NETBOOT
+ if (boot_drive == NETWORK_DRIVE)
+ bootp ();
+#endif
/* Initialize the environment for restarting Stage 2. */
Index: stage2/cmdline.c
diff -u -2 -r1.15 cmdline.c
--- stage2/cmdline.c 2000/02/03 18:04:20 1.15
+++ stage2/cmdline.c 2000/05/20 05:05:46
@@ -114,7 +114,15 @@
enter_cmdline (char *heap, int forever)
{
- /* Initialize the data and print a message. */
init_cmdline ();
+
+ /* Print a welcome message. */
init_page ();
+#ifdef SUPPORT_NETBOOT
+ if (boot_drive == NETWORK_DRIVE)
+ {
+ print_network_configuration ();
+ printf ("\n");
+ }
+#endif
print_cmdline_message (forever);
--
Chip Salzenberg - a.k.a. - <[EMAIL PROTECTED]>
"I wanted to play hopscotch with the impenetrable mystery of existence,
but he stepped in a wormhole and had to go in early." // MST3K