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>
This commit is contained in:
parent
1984af4f28
commit
76ccd96f4a
|
@ -26,12 +26,13 @@ static int __do_bootm_linux(struct image_data *data, int swap)
|
|||
{
|
||||
unsigned long kernel;
|
||||
unsigned long initrd_start = 0, initrd_size = 0, initrd_end = 0;
|
||||
int ret;
|
||||
|
||||
kernel = data->os_res->start + data->os_entry;
|
||||
|
||||
initrd_start = data->initrd_address;
|
||||
|
||||
if (data->initrd_file && initrd_start == UIMAGE_INVALID_ADDRESS) {
|
||||
if (initrd_start == UIMAGE_INVALID_ADDRESS) {
|
||||
initrd_start = data->os_res->start + SZ_8M;
|
||||
|
||||
if (bootm_verbose(data)) {
|
||||
|
@ -40,16 +41,9 @@ static int __do_bootm_linux(struct image_data *data, int swap)
|
|||
}
|
||||
}
|
||||
|
||||
if (data->initrd) {
|
||||
data->initrd_res = uimage_load_to_sdram(data->initrd,
|
||||
data->initrd_num, initrd_start);
|
||||
if (!data->initrd_res)
|
||||
return -ENOMEM;
|
||||
} else if (data->initrd_file) {
|
||||
data->initrd_res = file_to_sdram(data->initrd_file, initrd_start);
|
||||
if (!data->initrd_res)
|
||||
return -ENOMEM;
|
||||
}
|
||||
ret = bootm_load_initrd(data, initrd_start);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (data->initrd_res) {
|
||||
initrd_start = data->initrd_res->start;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -109,6 +109,7 @@ static inline int linux_bootargs_overwrite(const char *bootargs)
|
|||
#endif
|
||||
|
||||
int bootm_load_os(struct image_data *data, unsigned long load_address);
|
||||
int bootm_load_initrd(struct image_data *data, unsigned long load_address);
|
||||
|
||||
#define UIMAGE_SOME_ADDRESS (UIMAGE_INVALID_ADDRESS - 1)
|
||||
|
||||
|
|
Loading…
Reference in New Issue