david/ipxe
Archived
1
0

[image] Allow for zero embedded images

Having a default script containing

  #!gpxe
  autoboot

can cause problems when entering commands to load and start a kernel
manually; the default script image will still be present when the
kernel is started and so will be treated as an initrd.  It is possible
to work around this by typing "imgfree" before any other commands, but
this is counter-intuitive.

Fix by allowing the embedded image list to be empty (in which case we
just call autoboot()), and making this the default.

Reported by alkisg@gmail.com.
This commit is contained in:
Michael Brown 2009-02-24 05:51:21 +00:00
parent 43834f5d25
commit 4f3bab1a55
6 changed files with 32 additions and 20 deletions

View File

@ -286,10 +286,6 @@ CFLAGS += $(EXTRA_CFLAGS)
ASFLAGS += $(EXTRA_ASFLAGS) ASFLAGS += $(EXTRA_ASFLAGS)
LDFLAGS += $(EXTRA_LDFLAGS) LDFLAGS += $(EXTRA_LDFLAGS)
# Embedded image(s), or default if not set
#
EMBEDDED_IMAGE = image/default.gpxe
# Inhibit -Werror if NO_WERROR is specified on make command line # Inhibit -Werror if NO_WERROR is specified on make command line
# #
ifneq ($(NO_WERROR),1) ifneq ($(NO_WERROR),1)

View File

@ -71,13 +71,17 @@ __asmcall int main ( void ) {
shell(); shell();
} else { } else {
/* User doesn't want shell; load and execute the first /* User doesn't want shell; load and execute the first
* image. If booting fails (i.e. if the image * image, or autoboot() if we have no images. If
* returns, or fails to execute), offer a second * booting fails for any reason, offer a second chance
* chance to enter the shell for diagnostics. * to enter the shell for diagnostics.
*/ */
for_each_image ( image ) { if ( have_images() ) {
image_exec ( image ); for_each_image ( image ) {
break; image_exec ( image );
break;
}
} else {
autoboot();
} }
if ( shell_banner() ) if ( shell_banner() )

View File

@ -222,13 +222,13 @@ static int kernel_exec ( int argc, char **argv ) {
} }
/** /**
* The "imgauto" command * The "chain" command
* *
* @v argc Argument count * @v argc Argument count
* @v argv Argument list * @v argv Argument list
* @ret rc Exit code * @ret rc Exit code
*/ */
static int imgauto_exec ( int argc, char **argv) { static int chain_exec ( int argc, char **argv) {
int rc; int rc;
if ( ( rc = imgfetch_core_exec ( NULL, IMG_EXEC, argc, argv ) ) != 0 ) if ( ( rc = imgfetch_core_exec ( NULL, IMG_EXEC, argc, argv ) ) != 0 )
@ -563,8 +563,8 @@ struct command image_commands[] __command = {
.exec = kernel_exec, .exec = kernel_exec,
}, },
{ {
.name = "imgauto", .name = "chain",
.exec = imgauto_exec, .exec = chain_exec,
}, },
{ {
.name = "imgload", .name = "imgload",

View File

@ -1,2 +0,0 @@
#!gpxe
autoboot

View File

@ -16,7 +16,8 @@
* *
* @v refcnt Reference counter * @v refcnt Reference counter
*/ */
static void embedded_image_free ( struct refcnt *refcnt __unused ) { static void __attribute__ (( unused ))
embedded_image_free ( struct refcnt *refcnt __unused ) {
/* Do nothing */ /* Do nothing */
} }
@ -51,14 +52,18 @@ static struct image embedded_images[] = {
* Register all embedded images * Register all embedded images
*/ */
static void embedded_init ( void ) { static void embedded_init ( void ) {
unsigned int i; int i;
struct image *image; struct image *image;
void *data; void *data;
int rc; int rc;
/* Skip if we have no embedded images */
if ( ! sizeof ( embedded_images ) )
return;
/* Fix up data pointers and register images */ /* Fix up data pointers and register images */
for ( i = 0 ; i < ( sizeof ( embedded_images ) / for ( i = 0 ; i < ( int ) ( sizeof ( embedded_images ) /
sizeof ( embedded_images[0] ) ) ; i++ ) { sizeof ( embedded_images[0] ) ) ; i++ ) {
image = &embedded_images[i]; image = &embedded_images[i];
/* virt_to_user() cannot be used in a static /* virt_to_user() cannot be used in a static

View File

@ -133,6 +133,15 @@ extern struct list_head images;
#define for_each_image( image ) \ #define for_each_image( image ) \
list_for_each_entry ( (image), &images, list ) list_for_each_entry ( (image), &images, list )
/**
* Test for existence of images
*
* @ret existence Some images exist
*/
static inline int have_images ( void ) {
return ( ! list_empty ( &images ) );
}
extern struct image * alloc_image ( void ); extern struct image * alloc_image ( void );
extern int image_set_uri ( struct image *image, struct uri *uri ); extern int image_set_uri ( struct image *image, struct uri *uri );
extern int image_set_cmdline ( struct image *image, const char *cmdline ); extern int image_set_cmdline ( struct image *image, const char *cmdline );