summaryrefslogtreecommitdiffstats
path: root/src/image/script.c
diff options
context:
space:
mode:
authorMichael Brown2011-03-07 01:37:50 +0100
committerMichael Brown2011-03-07 01:37:50 +0100
commit34b6ecb2f1d7940a0065cbabd6f9dcd439b4c841 (patch)
treeea583bf6fde26b2ed12ee3c6b117055e555555d9 /src/image/script.c
parent[spi] Reset device on each access (diff)
downloadipxe-34b6ecb2f1d7940a0065cbabd6f9dcd439b4c841.tar.gz
ipxe-34b6ecb2f1d7940a0065cbabd6f9dcd439b4c841.tar.xz
ipxe-34b6ecb2f1d7940a0065cbabd6f9dcd439b4c841.zip
[image] Simplify image management
Refactor the {load,exec} image operations as {probe,exec}. This makes the probe mechanism cleaner, eliminates some forward declarations, avoids holding magic state in image->priv, eliminates the possibility of screwing up between the "load" and "exec" stages, and makes the documentation simpler since the concept of "loading" (as distinct from "executing") no longer needs to be explained. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/image/script.c')
-rw-r--r--src/image/script.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/image/script.c b/src/image/script.c
index b05abf94..3344c679 100644
--- a/src/image/script.c
+++ b/src/image/script.c
@@ -36,8 +36,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/image.h>
#include <ipxe/shell.h>
-struct image_type script_image_type __image_type ( PROBE_NORMAL );
-
/** Currently running script
*
* This is a global in order to allow goto_exec() to update the
@@ -165,12 +163,12 @@ static int script_exec ( struct image *image ) {
}
/**
- * Load script into memory
+ * Probe script image
*
* @v image Script
* @ret rc Return status code
*/
-static int script_load ( struct image *image ) {
+static int script_probe ( struct image *image ) {
static const char ipxe_magic[] = "#!ipxe";
static const char gpxe_magic[] = "#!gpxe";
linker_assert ( sizeof ( ipxe_magic ) == sizeof ( gpxe_magic ),
@@ -193,20 +191,13 @@ static int script_load ( struct image *image ) {
return -ENOEXEC;
}
- /* This is a script */
- image->type = &script_image_type;
-
- /* We don't actually load it anywhere; we will pick the lines
- * out of the image as we need them.
- */
-
return 0;
}
/** Script image type */
struct image_type script_image_type __image_type ( PROBE_NORMAL ) = {
.name = "script",
- .load = script_load,
+ .probe = script_probe,
.exec = script_exec,
};