aboutsummaryrefslogtreecommitdiff
path: root/src/arch/x86
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2021-01-25 16:18:28 +0000
committerMichael Brown <mcb30@ipxe.org>2021-01-25 17:03:56 +0000
commit989a7a8032db02eb0524bd78a674d3b087dea3a6 (patch)
tree3ead7f99b466e3274d29dbeb0df7374905ff92d5 /src/arch/x86
parentffc41ae9d12f319be67053e529091c8710303d3c (diff)
downloadipxe-989a7a8032db02eb0524bd78a674d3b087dea3a6.zip
ipxe-989a7a8032db02eb0524bd78a674d3b087dea3a6.tar.gz
ipxe-989a7a8032db02eb0524bd78a674d3b087dea3a6.tar.bz2
[image] Provide image_memory()
Consolidate the remaining logic common to initrd_init() and imgmem() into a shared image_memory() function. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/x86')
-rw-r--r--src/arch/x86/core/runtime.c44
1 files changed, 5 insertions, 39 deletions
diff --git a/src/arch/x86/core/runtime.c b/src/arch/x86/core/runtime.c
index 4de3bfa..02072b5 100644
--- a/src/arch/x86/core/runtime.c
+++ b/src/arch/x86/core/runtime.c
@@ -179,7 +179,6 @@ static int cmdline_init ( void ) {
*/
static int initrd_init ( void ) {
struct image *image;
- int rc;
/* Do nothing if no initrd was specified */
if ( ! initrd_phys ) {
@@ -193,51 +192,18 @@ static int initrd_init ( void ) {
DBGC ( colour, "RUNTIME found initrd at [%x,%x)\n",
initrd_phys, ( initrd_phys + initrd_len ) );
- /* Allocate image */
- image = alloc_image ( NULL );
+ /* Create initrd image */
+ image = image_memory ( "<INITRD>", phys_to_user ( initrd_phys ),
+ initrd_len );
if ( ! image ) {
- DBGC ( colour, "RUNTIME could not allocate image for "
- "initrd\n" );
- 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;
- }
-
- /* 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;
+ DBGC ( colour, "RUNTIME could not create initrd image\n" );
+ return -ENOMEM;
}
/* Mark initrd as consumed */
initrd_phys = 0;
- /* Register image */
- if ( ( rc = register_image ( image ) ) != 0 ) {
- DBGC ( colour, "RUNTIME could not register initrd: %s\n",
- strerror ( rc ) );
- goto err_register_image;
- }
-
- /* Drop our reference to the image */
- image_put ( image );
-
return 0;
-
- err_register_image:
- err_set_data:
- err_set_name:
- image_put ( image );
- err_alloc_image:
- return rc;
}
/**