diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-01-09 10:15:35 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-01-14 12:36:03 +0100 |
commit | 76ccd96f4a92c028ea531a098b58356208b0815b (patch) | |
tree | 5971a9c383bb12d7d2a2e5e01dc07b96f011de5b /common/bootm.c | |
parent | 1984af4f28bdabc88881ec8d04eea039855b62e4 (diff) | |
download | barebox-76ccd96f4a92c028ea531a098b58356208b0815b.tar.gz barebox-76ccd96f4a92c028ea531a098b58356208b0815b.tar.xz |
bootm: introduce bootm_load_initrd helper
Make the bootm handlers simpler by factoring out an initrd load
function.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/bootm.c')
-rw-r--r-- | common/bootm.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/common/bootm.c b/common/bootm.c index 5ad10d9a02..9ccbe8fafd 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -85,6 +85,44 @@ int bootm_load_os(struct image_data *data, unsigned long load_address) return -EINVAL; } +/* + * bootm_load_initrd() - load initrd to RAM + * + * @data: image data context + * @load_address: The address where the initrd should be loaded to + * + * This loads the initrd to a RAM location. load_address must be a valid + * address. If the image_data doesn't have a initrd specified this function + * still returns successful as an initrd is optional. Check data->initrd_res + * to see if an initrd has been loaded. + * + * Return: 0 on success, negative error code otherwise + */ +int bootm_load_initrd(struct image_data *data, unsigned long load_address) +{ + if (data->initrd_res) + return 0; + + if (data->initrd) { + data->initrd_res = uimage_load_to_sdram(data->initrd, + data->initrd_num, load_address); + if (!data->initrd_res) + return -ENOMEM; + + return 0; + } + + if (data->initrd_file) { + data->initrd_res = file_to_sdram(data->initrd_file, load_address); + if (!data->initrd_res) + return -ENOMEM; + + return 0; + } + + return 0; +} + static int bootm_open_os_uimage(struct image_data *data) { int ret; |