diff options
author | Michael Brown <mcb30@ipxe.org> | 2021-01-20 18:03:16 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2021-01-22 18:34:47 +0000 |
commit | 99ac69b8a9a48207913e98ac6b357c029b0eef81 (patch) | |
tree | 22f88f44671cb1fc29fe5ac47b50b5fa54b34586 /src/arch | |
parent | ae73fb5aa0c8a39d6dc688d856483610ebe12682 (diff) | |
download | ipxe-99ac69b8a9a48207913e98ac6b357c029b0eef81.tar.gz |
[image] Provide image_set_data()
Extract part of the logic in initrd_init() to a standalone function
image_set_data().
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/x86/core/runtime.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/arch/x86/core/runtime.c b/src/arch/x86/core/runtime.c index f96b23af4..4de3bfafe 100644 --- a/src/arch/x86/core/runtime.c +++ b/src/arch/x86/core/runtime.c @@ -38,7 +38,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include <ipxe/init.h> #include <ipxe/image.h> #include <ipxe/script.h> -#include <ipxe/umalloc.h> #include <realmode.h> /** Command line physical address @@ -202,23 +201,21 @@ static int initrd_init ( void ) { rc = -ENOMEM; goto err_alloc_image; } + + /* Set image name */ if ( ( rc = image_set_name ( image, "<INITRD>" ) ) != 0 ) { DBGC ( colour, "RUNTIME could not set image name: %s\n", strerror ( rc ) ); goto err_set_name; } - /* Allocate and copy initrd content */ - image->data = umalloc ( initrd_len ); - if ( ! image->data ) { - DBGC ( colour, "RUNTIME could not allocate %d bytes for " - "initrd\n", initrd_len ); - rc = -ENOMEM; - goto err_umalloc; + /* Set image content */ + if ( ( rc = image_set_data ( image, phys_to_user ( initrd_phys ), + initrd_len ) ) != 0 ) { + DBGC ( colour, "RUNTIME could not set image data: %s\n", + strerror ( rc ) ); + goto err_set_data; } - image->len = initrd_len; - memcpy_user ( image->data, 0, phys_to_user ( initrd_phys ), 0, - initrd_len ); /* Mark initrd as consumed */ initrd_phys = 0; @@ -236,7 +233,7 @@ static int initrd_init ( void ) { return 0; err_register_image: - err_umalloc: + err_set_data: err_set_name: image_put ( image ); err_alloc_image: |