summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2007-01-13 18:28:51 +0100
committerMichael Brown2007-01-13 18:28:51 +0100
commitf11900a9c6c85b6167a3ad6c6a3efc6c9b8e1686 (patch)
tree2c27f878393b052239b7285042f712bb09b8e946
parentAdd header for pxe_boot() (diff)
downloadipxe-f11900a9c6c85b6167a3ad6c6a3efc6c9b8e1686.tar.gz
ipxe-f11900a9c6c85b6167a3ad6c6a3efc6c9b8e1686.tar.xz
ipxe-f11900a9c6c85b6167a3ad6c6a3efc6c9b8e1686.zip
I prefer IMAGE_XXX to XXX_IMAGE.
Add IMAGE_PXE to use the new image format framework. "kernel pxelinux.0" now works.
-rw-r--r--src/arch/i386/image/pxe_image.c83
-rw-r--r--src/config.h21
-rw-r--r--src/core/config.c22
3 files changed, 105 insertions, 21 deletions
diff --git a/src/arch/i386/image/pxe_image.c b/src/arch/i386/image/pxe_image.c
new file mode 100644
index 000000000..f88c45970
--- /dev/null
+++ b/src/arch/i386/image/pxe_image.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
+ *
+ * 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 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.
+ */
+
+/**
+ * @file
+ *
+ * PXE image format
+ *
+ */
+
+#include <gpxe/uaccess.h>
+#include <gpxe/image.h>
+#include <gpxe/segment.h>
+#include <pxe_call.h>
+
+/** PXE load address segment */
+#define PXE_LOAD_SEGMENT 0
+
+/** PXE load address offset */
+#define PXE_LOAD_OFFSET 0x7c00
+
+struct image_type pxe_image_type __image_type ( PROBE_PXE );
+
+/**
+ * Execute PXE image
+ *
+ * @v image PXE image
+ * @ret rc Return status code
+ */
+static int pxe_exec ( struct image *image __unused ) {
+ return pxe_boot();
+}
+
+/**
+ * Load PXE image into memory
+ *
+ * @v image PXE file
+ * @ret rc Return status code
+ */
+int pxe_load ( struct image *image ) {
+ userptr_t buffer = real_to_user ( 0, 0x7c00 );
+ size_t filesz = image->len;
+ size_t memsz = image->len;
+ int rc;
+
+ /* There are no signature checks for PXE; we will accept anything */
+ if ( ! image->type )
+ image->type = &pxe_image_type;
+
+ /* Verify and prepare segment */
+ if ( ( rc = prep_segment ( buffer, filesz, memsz ) != 0 ) ) {
+ DBG ( "PXE image could not prepare segment: %s\n",
+ strerror ( rc ) );
+ return rc;
+ }
+
+ /* Copy image to segment */
+ memcpy_user ( buffer, 0, image->data, 0, filesz );
+
+ return 0;
+}
+
+/** PXE image type */
+struct image_type pxe_image_type __image_type ( PROBE_PXE ) = {
+ .name = "PXE",
+ .load = pxe_load,
+ .exec = pxe_exec,
+};
diff --git a/src/config.h b/src/config.h
index b8ab9291f..a219d6454 100644
--- a/src/config.h
+++ b/src/config.h
@@ -98,16 +98,16 @@
* you want to use.
*
*/
-#undef TAGGED_IMAGE /* NBI image support */
-#undef ELF64_IMAGE /* ELF64 image support */
-#undef ELF_IMAGE /* ELF image support */
-#undef COFF_IMAGE /* COFF image support */
-#undef FREEBSD_IMAGE /* FreeBSD kernel image support */
-#define MULTIBOOT_IMAGE /* MultiBoot image support */
-#undef AOUT_IMAGE /* a.out image support */
-#undef WINCE_IMAGE /* WinCE image support */
-#undef PXE_IMAGE /* PXE image support */
-#define SCRIPT_IMAGE /* gPXE script image support */
+#undef IMAGE_NBI /* NBI image support */
+#undef IMAGE_ELF64 /* ELF64 image support */
+#undef IMAGE_ELF /* ELF image support */
+#undef IMAGE_COFF /* COFF image support */
+#undef IMAGE_FREEBSD /* FreeBSD kernel image support */
+#define IMAGE_MULTIBOOT /* MultiBoot image support */
+#undef IMAGE_AOUT /* a.out image support */
+#undef IMAGE_WINCE /* WinCE image support */
+#define IMAGE_PXE /* PXE image support */
+#define IMAGE_SCRIPT /* gPXE script image support */
/* @END general.h */
@@ -122,6 +122,7 @@
#define IFMGMT_CMD /* Interface management commands */
#define ROUTE_CMD /* Routing table management commands */
#define IMAGE_CMD /* Image management commands */
+#define DHCP_CMD /* DHCP management commands */
/* @END general.h */
diff --git a/src/core/config.c b/src/core/config.c
index 6f113c0bd..b27ad6c1e 100644
--- a/src/core/config.c
+++ b/src/core/config.c
@@ -110,34 +110,34 @@ REQUIRE_OBJECT ( nmb );
* Drag in all requested image formats
*
*/
-#ifdef TAGGED_IMAGE
+#ifdef IMAGE_NBI
REQUIRE_OBJECT ( nbi );
#endif
-#ifdef ELF64_IMAGE
+#ifdef IMAGE_ELF64
REQUIRE_OBJECT ( elf64 );
#endif
-#ifdef ELF_IMAGE
+#ifdef IMAGE_ELF
REQUIRE_OBJECT ( elf );
#endif
-#ifdef COFF_IMAGE
+#ifdef IMAGE_ELF
REQUIRE_OBJECT ( coff );
#endif
-#ifdef FREEBSD_IMAGE
+#ifdef IMAGE_FREEBSD
REQUIRE_OBJECT ( freebsd );
#endif
-#ifdef MULTIBOOT_IMAGE
+#ifdef IMAGE_MULTIBOOT
REQUIRE_OBJECT ( multiboot );
#endif
-#ifdef AOUT_IMAGE
+#ifdef IMAGE_AOUT
REQUIRE_OBJECT ( aout );
#endif
-#ifdef WINCE_IMAGE
+#ifdef IMAGE_WINCE
REQUIRE_OBJECT ( wince );
#endif
-#ifdef PXE_IMAGE
-REQUIRE_OBJECT ( pxe );
+#ifdef IMAGE_PXE
+REQUIRE_OBJECT ( pxe_image );
#endif
-#ifdef SCRIPT_IMAGE
+#ifdef IMAGE_SCRIPT
REQUIRE_OBJECT ( script );
#endif