summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-01-09 09:59:59 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2014-01-10 11:53:18 +0100
commit9bd67f5e6184ecd03b8e052706218f2a741027c3 (patch)
tree51a5ac95bbc796e0acd756d1fa8df9b4a65f90fb /arch
parentf1025bbf3292c8c199e23e618c062ec1e9f2f055 (diff)
downloadbarebox-9bd67f5e6184ecd03b8e052706218f2a741027c3.tar.gz
barebox-9bd67f5e6184ecd03b8e052706218f2a741027c3.tar.xz
bootm: introduce bootm_load_os helper
The common bootm code used to load uImage contents to SDRAM before calling into the handlers if possible. This makes the handlers complicated since they have to handle many cases. Instead, introduce a helper to load the os after the handlers have figured out a good load address. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/lib/bootm.c24
-rw-r--r--arch/blackfin/lib/blackfin_linux.c6
-rw-r--r--arch/nios2/lib/bootm.c6
-rw-r--r--arch/ppc/lib/ppclinux.c6
4 files changed, 19 insertions, 23 deletions
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index c0e4e15ea6..7401f2f05d 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -28,32 +28,22 @@ static int __do_bootm_linux(struct image_data *data, int swap)
unsigned long initrd_start = 0, initrd_size = 0, initrd_end = 0;
struct memory_bank *bank;
unsigned long load_address;
+ int ret;
- if (data->os_res) {
- load_address = data->os_res->start;
- } else if (data->os_address != UIMAGE_INVALID_ADDRESS) {
- load_address = data->os_address;
- } else {
+ if (data->os_address == UIMAGE_INVALID_ADDRESS) {
bank = list_first_entry(&memory_banks,
struct memory_bank, list);
load_address = bank->start + SZ_32K;
if (bootm_verbose(data))
printf("no os load address, defaulting to 0x%08lx\n",
load_address);
+ } else {
+ load_address = data->os_address;
}
- if (!data->os_res && data->os) {
- data->os_res = uimage_load_to_sdram(data->os,
- data->os_num, load_address);
- if (!data->os_res)
- return -ENOMEM;
- }
-
- if (!data->os_res) {
- data->os_res = file_to_sdram(data->os_file, load_address);
- if (!data->os_res)
- return -ENOMEM;
- }
+ ret = bootm_load_os(data, load_address);
+ if (ret)
+ return ret;
kernel = data->os_res->start + data->os_entry;
diff --git a/arch/blackfin/lib/blackfin_linux.c b/arch/blackfin/lib/blackfin_linux.c
index bb3c7745ea..2561a7e152 100644
--- a/arch/blackfin/lib/blackfin_linux.c
+++ b/arch/blackfin/lib/blackfin_linux.c
@@ -41,9 +41,11 @@ static int do_bootm_linux(struct image_data *idata)
int (*appl)(char *cmdline);
const char *cmdline = linux_bootargs_get();
char *cmdlinedest = (char *) CMD_LINE_ADDR;
+ int ret;
- if (!idata->os_res)
- return -EINVAL;
+ ret = bootm_load_os(idata, idata->os_address);
+ if (ret)
+ return ret;
appl = (void *)(idata->os_address + idata->os_entry);
printf("Starting Kernel at 0x%p\n", appl);
diff --git a/arch/nios2/lib/bootm.c b/arch/nios2/lib/bootm.c
index cc96290b8d..77da119bde 100644
--- a/arch/nios2/lib/bootm.c
+++ b/arch/nios2/lib/bootm.c
@@ -36,9 +36,11 @@ static int do_bootm_linux(struct image_data *idata)
{
void (*kernel)(int, int, int, const char *);
const char *commandline = linux_bootargs_get();
+ int ret;
- if (!idata->os_res)
- return -EINVAL;
+ ret = bootm_load_os(idata, idata->os_address);
+ if (ret)
+ return ret;
kernel = (void *)(idata->os_address + idata->os_entry);
diff --git a/arch/ppc/lib/ppclinux.c b/arch/ppc/lib/ppclinux.c
index 7c30ac3386..e25efecd43 100644
--- a/arch/ppc/lib/ppclinux.c
+++ b/arch/ppc/lib/ppclinux.c
@@ -47,9 +47,11 @@ static int do_bootm_linux(struct image_data *data)
{
void (*kernel)(void *, void *, unsigned long,
unsigned long, unsigned long);
+ int ret;
- if (!data->os_res)
- return -EINVAL;
+ ret = bootm_load_os(data, data->os_address);
+ if (ret)
+ return ret;
data->oftree = of_get_fixed_tree(data->of_root_node);
if (!data->oftree) {