summaryrefslogtreecommitdiffstats
path: root/src/usr/autoboot.c
diff options
context:
space:
mode:
authorMichael Brown2008-01-08 16:51:36 +0100
committerMichael Brown2008-01-08 16:51:36 +0100
commit74fd544101c8f17f35dfc2cd16738ebd5228d366 (patch)
treeb813ee1138e4397ee557144739ede124f80c65a0 /src/usr/autoboot.c
parentWhen the DHCP file/sname fields are empty, don't allow them to override (diff)
downloadipxe-74fd544101c8f17f35dfc2cd16738ebd5228d366.tar.gz
ipxe-74fd544101c8f17f35dfc2cd16738ebd5228d366.tar.xz
ipxe-74fd544101c8f17f35dfc2cd16738ebd5228d366.zip
Added the embedded pxelinux payload patch from hpa.
Diffstat (limited to 'src/usr/autoboot.c')
-rw-r--r--src/usr/autoboot.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c
index 91836978..c3b07e9a 100644
--- a/src/usr/autoboot.c
+++ b/src/usr/autoboot.c
@@ -22,6 +22,7 @@
#include <gpxe/netdevice.h>
#include <gpxe/dhcp.h>
#include <gpxe/image.h>
+#include <gpxe/embedded.h>
#include <usr/ifmgmt.h>
#include <usr/route.h>
#include <usr/dhcpmgmt.h>
@@ -46,6 +47,30 @@ static struct net_device * find_boot_netdev ( void ) {
}
/**
+ * Boot embedded image
+ *
+ * @ret rc Return status code
+ */
+static int boot_embedded_image ( void ) {
+ struct image *image;
+ int rc;
+
+ image = embedded_image();
+ if ( !image )
+ return ENOENT;
+
+ if ( ( rc = imgload ( image ) ) != 0 ) {
+ printf ( "Could not load embedded image: %s\n",
+ strerror ( rc ) );
+ } else if ( ( rc = imgexec ( image ) ) != 0 ) {
+ printf ( "Could not boot embedded image: %s\n",
+ strerror ( rc ) );
+ }
+ image_put ( image );
+ return rc;
+}
+
+/**
* Boot using filename
*
* @v filename Boot filename
@@ -115,6 +140,11 @@ static int netboot ( struct net_device *netdev ) {
return rc;
route();
+ /* Try to boot an embedded image if we have one */
+ rc = boot_embedded_image ();
+ if ( rc != ENOENT )
+ return rc;
+
/* Try to download and boot whatever we are given as a filename */
dhcp_snprintf ( buf, sizeof ( buf ),
find_global_dhcp_option ( DHCP_BOOTFILE_NAME ) );