summaryrefslogtreecommitdiffstats
path: root/src/arch
diff options
context:
space:
mode:
authorMichael Brown2011-03-09 17:55:51 +0100
committerMichael Brown2011-03-09 17:57:34 +0100
commit9fa4ac2e9a781861e36e618eb1d461d8dc53a27c (patch)
tree437a36ae53aa9361f33c3c435c7b0978a9de42f5 /src/arch
parent[image] Generalise "currently-running script" to "currently-running image" (diff)
downloadipxe-9fa4ac2e9a781861e36e618eb1d461d8dc53a27c.tar.gz
ipxe-9fa4ac2e9a781861e36e618eb1d461d8dc53a27c.tar.xz
ipxe-9fa4ac2e9a781861e36e618eb1d461d8dc53a27c.zip
[image] Simplify use of imgdownload()
Allow imgdownload() to be called without first having to allocate (and so keep track of) an image. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/i386/image/com32.c7
-rw-r--r--src/arch/i386/image/comboot.c7
-rw-r--r--src/arch/i386/include/comboot.h3
-rw-r--r--src/arch/i386/interface/syslinux/comboot_call.c49
4 files changed, 14 insertions, 52 deletions
diff --git a/src/arch/i386/image/com32.c b/src/arch/i386/image/com32.c
index 39ff4e664..d6e48ebe1 100644
--- a/src/arch/i386/image/com32.c
+++ b/src/arch/i386/image/com32.c
@@ -132,10 +132,9 @@ static int com32_exec_loop ( struct image *image ) {
break;
case COMBOOT_EXIT_RUN_KERNEL:
- DBGC ( image, "COM32 %p: exited to run kernel %p\n",
- image, comboot_replacement_image );
- image->replacement = comboot_replacement_image;
- comboot_replacement_image = NULL;
+ assert ( image->replacement );
+ DBGC ( image, "COM32 %p: exited to run kernel %s\n",
+ image, image->replacement->name );
break;
case COMBOOT_EXIT_COMMAND:
diff --git a/src/arch/i386/image/comboot.c b/src/arch/i386/image/comboot.c
index 26bb1139a..0b924cce2 100644
--- a/src/arch/i386/image/comboot.c
+++ b/src/arch/i386/image/comboot.c
@@ -188,10 +188,9 @@ static int comboot_exec_loop ( struct image *image ) {
break;
case COMBOOT_EXIT_RUN_KERNEL:
- DBGC ( image, "COMBOOT %p: exited to run kernel %p\n",
- image, comboot_replacement_image );
- image->replacement = comboot_replacement_image;
- comboot_replacement_image = NULL;
+ assert ( image->replacement );
+ DBGC ( image, "COMBOOT %p: exited to run kernel %s\n",
+ image, image->replacement->name );
break;
case COMBOOT_EXIT_COMMAND:
diff --git a/src/arch/i386/include/comboot.h b/src/arch/i386/include/comboot.h
index 39d1d2f17..b34341398 100644
--- a/src/arch/i386/include/comboot.h
+++ b/src/arch/i386/include/comboot.h
@@ -161,9 +161,6 @@ extern int comboot_resolv ( const char *name, struct in_addr *address );
/* setjmp/longjmp context buffer used to return after loading an image */
extern rmjmp_buf comboot_return;
-/* Replacement image when exiting with COMBOOT_EXIT_RUN_KERNEL */
-extern struct image *comboot_replacement_image;
-
extern void *com32_external_esp;
#define COMBOOT_EXIT 1
diff --git a/src/arch/i386/interface/syslinux/comboot_call.c b/src/arch/i386/interface/syslinux/comboot_call.c
index 1dbc830fd..221b597d4 100644
--- a/src/arch/i386/interface/syslinux/comboot_call.c
+++ b/src/arch/i386/interface/syslinux/comboot_call.c
@@ -81,9 +81,6 @@ extern void int22_wrapper ( void );
/* setjmp/longjmp context buffer used to return after loading an image */
rmjmp_buf comboot_return;
-/* Replacement image when exiting with COMBOOT_EXIT_RUN_KERNEL */
-struct image *comboot_replacement_image;
-
/* Mode flags set by INT 22h AX=0017h */
static uint16_t comboot_graphics_mode = 0;
@@ -169,8 +166,6 @@ void comboot_force_text_mode ( void ) {
* Fetch kernel and optional initrd
*/
static int comboot_fetch_kernel ( char *kernel_file, char *cmdline ) {
- struct image *kernel = NULL;
- struct image *initrd = NULL;
char *initrd_file;
int rc;
@@ -188,18 +183,12 @@ static int comboot_fetch_kernel ( char *kernel_file, char *cmdline ) {
DBG ( "COMBOOT: fetching initrd '%s'\n", initrd_file );
- /* Allocate and fetch initrd */
- initrd = alloc_image();
- if ( ! initrd ) {
- DBG ( "COMBOOT: could not allocate initrd\n" );
- rc = -ENOMEM;
- goto out;
- }
- if ( ( rc = imgfetch ( initrd, initrd_file,
- register_image ) ) != 0 ) {
+ /* Fetch initrd */
+ if ( ( rc = imgdownload_string ( initrd_file, NULL, NULL,
+ register_and_put_image ))!=0){
DBG ( "COMBOOT: could not fetch initrd: %s\n",
strerror ( rc ) );
- goto out;
+ return rc;
}
/* Restore space after initrd name, if applicable */
@@ -210,36 +199,14 @@ static int comboot_fetch_kernel ( char *kernel_file, char *cmdline ) {
DBG ( "COMBOOT: fetching kernel '%s'\n", kernel_file );
/* Allocate and fetch kernel */
- kernel = alloc_image();
- if ( ! kernel ) {
- DBG ( "COMBOOT: could not allocate kernel\n" );
- rc = -ENOMEM;
- goto out;
- }
- if ( ( rc = imgfetch ( kernel, kernel_file,
- register_and_select_image ) ) != 0 ) {
+ if ( ( rc = imgdownload_string ( kernel_file, NULL, cmdline,
+ register_and_replace_image ) ) != 0 ) {
DBG ( "COMBOOT: could not fetch kernel: %s\n",
strerror ( rc ) );
- goto out;
- }
- if ( ( rc = image_set_cmdline ( kernel, cmdline ) ) != 0 ) {
- DBG ( "COMBOOT: could not set kernel command line: %s\n",
- strerror ( rc ) );
- goto out;
+ return rc;
}
- /* Store kernel as replacement image */
- assert ( comboot_replacement_image == NULL );
- comboot_replacement_image = image_get ( kernel );
-
- out:
- /* Drop image references unconditionally; either we want to
- * discard them, or they have been registered and we should
- * drop out local reference.
- */
- image_put ( kernel );
- image_put ( initrd );
- return rc;
+ return 0;
}