Merge from Etherboot 5.4
[people/lynusvaz/gpxe.git] / src / core / main.c
index 3a112ee..35c7bb2 100644 (file)
@@ -31,16 +31,14 @@ Literature dealing with the network protocols:
 #include <lib.h>
 #endif
 
+/* Linker symbols */
+extern char _bss[], _ebss[];
+
 jmp_buf        restart_etherboot;
 int    url_port;               
 
 char as_main_program = 1;
 
-#ifdef IMAGE_FREEBSD
-int freebsd_howto = 0;
-char freebsd_kernel_env[FREEBSD_KERNEL_ENV_SIZE];
-#endif
-
 #if 0
 
 static inline unsigned long ask_boot(unsigned *index)
@@ -199,7 +197,7 @@ int main ( void ) {
                /* Probe boot device */
                if ( ! probe ( &dev ) ) {
                        /* Device found on bus, but probe failed */
-                       printf ( "...probe failed\n" );
+                       printf ( "...probe failed: %m\n" );
                        continue;
                }
 
@@ -212,14 +210,14 @@ int main ( void ) {
                /* Configure boot device */
                if ( ! configure ( &dev ) ) {
                        /* Configuration (e.g. DHCP) failed */
-                       printf ( "...configuration failed\n" );
+                       printf ( "...configuration failed: %m\n" );
                        continue;
                }
 
                /* Load boot file from the device */
                if ( ! autoload ( &dev, &image, &image_context ) ) {
                        /* Load (e.g. TFTP) failed */
-                       printf ( "...load failed\n" );
+                       printf ( "...load failed: %m\n" );
                        continue;
                }
 
@@ -233,7 +231,7 @@ int main ( void ) {
                /* Boot the image */
                if ( ! image->boot ( image_context ) ) {
                        /* Boot failed */
-                       printf ( "...boot failed\n" );
+                       printf ( "...boot failed: %m\n" );
                        continue;
                }
                
@@ -279,6 +277,16 @@ static int main_loop(int state)
                        if (dev->how_probe == PROBE_FAILED) {
                                state = -1;
                        }
+                       if (state == 1) {
+                               /* The bootp reply might have been changed, re-parse.  */
+                               decode_rfc1533(bootp_data.bootp_reply.bp_vend, 0,
+#ifdef NO_DHCP_SUPPORT
+                                              BOOTP_VENDOR_LEN + MAX_BOOTP_EXTLEN, 
+#else
+                                              DHCP_OPT_LEN + MAX_BOOTP_EXTLEN, 
+#endif /* NO_DHCP_SUPPORT */
+                                              1);
+                       }
                }
        }
        switch(state) {