diff options
author | Michael Brown | 2007-01-12 07:03:02 +0100 |
---|---|---|
committer | Michael Brown | 2007-01-12 07:03:02 +0100 |
commit | b9fea9cbacf34b5f075894038ad1ab81d414aeb9 (patch) | |
tree | 315d813f84603fc3011c95197cde9c3667f75162 /src/core/image.c | |
parent | Be silent if there are no network interfaces (diff) | |
download | ipxe-b9fea9cbacf34b5f075894038ad1ab81d414aeb9.tar.gz ipxe-b9fea9cbacf34b5f075894038ad1ab81d414aeb9.tar.xz ipxe-b9fea9cbacf34b5f075894038ad1ab81d414aeb9.zip |
Added IMAGE_LOADED flag and find_image()
Diffstat (limited to 'src/core/image.c')
-rw-r--r-- | src/core/image.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/core/image.c b/src/core/image.c index d093e3a1..e14e08f1 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -73,6 +73,23 @@ void unregister_image ( struct image *image ) { } /** + * Find image by name + * + * @v name Image name + * @ret image Executable/loadable image, or NULL + */ +struct image * find_image ( const char *name ) { + struct image *image; + + list_for_each_entry ( image, &images, list ) { + if ( strcmp ( image->name, name ) == 0 ) + return image; + } + + return NULL; +} + +/** * Load executable/loadable image into memory * * @v image Executable/loadable image @@ -89,6 +106,7 @@ int image_load ( struct image *image ) { return rc; } + image->flags |= IMAGE_LOADED; return 0; } @@ -111,6 +129,7 @@ int image_autoload ( struct image *image ) { image, image->type->name, strerror ( rc ) ); return rc; } + image->flags |= IMAGE_LOADED; return 0; } @@ -127,8 +146,16 @@ int image_autoload ( struct image *image ) { int image_exec ( struct image *image ) { int rc; + /* Image must be loaded first */ + if ( ! ( image->flags & IMAGE_LOADED ) ) { + DBGC ( image, "IMAGE %p could not execute: not loaded\n", + image ); + return -ENOTTY; + } + assert ( image->type != NULL ); + /* Try executing the image */ if ( ( rc = image->type->exec ( image ) ) != 0 ) { DBGC ( image, "IMAGE %p could not execute: %s\n", image, strerror ( rc ) ); |