From ceaed2b1e54ebf14d600e02fef016c8df5cc4d40 Mon Sep 17 00:00:00 2001 From: Marian Balakowicz Date: Thu, 31 Jan 2008 13:57:17 +0100 Subject: [new uImage] Move ramdisk loading to a common routine Ramdisk loading code, including initrd_high variable handling, was duplicated for PPC and M68K platforms. This patch creates common helper routine that is being called from both platform do_bootm_linux() routines. Signed-off-by: Marian Balakowicz --- lib_m68k/bootm.c | 114 +++++++++++++------------------------------------------ 1 file changed, 26 insertions(+), 88 deletions(-) (limited to 'lib_m68k') diff --git a/lib_m68k/bootm.c b/lib_m68k/bootm.c index dac52763a..3fd38e98d 100644 --- a/lib_m68k/bootm.c +++ b/lib_m68k/bootm.c @@ -44,16 +44,16 @@ DECLARE_GLOBAL_DATA_PTR; # define SHOW_BOOT_PROGRESS(arg) #endif +static ulong get_sp (void); + void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], image_header_t *hdr, int verify) { - ulong sp; + ulong sp_limit; ulong rd_data_start, rd_data_end, rd_len; - ulong initrd_high; ulong initrd_start, initrd_end; - int initrd_copy_to_ram = 1; ulong cmd_start, cmd_end; char *cmdline; @@ -61,25 +61,6 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, bd_t *kbd; void (*kernel) (bd_t *, ulong, ulong, ulong, ulong); - if ((s = getenv("initrd_high")) != NULL) { - /* a value of "no" or a similar string will act like 0, - * turning the "load high" feature off. This is intentional. - */ - initrd_high = simple_strtoul(s, NULL, 16); - if (initrd_high == ~0) - initrd_copy_to_ram = 0; - } else { /* not set, no restrictions to load high */ - initrd_high = ~0; - } - -#ifdef CONFIG_LOGBUFFER - kbd = gd->bd; - /* Prevent initrd from overwriting logbuffer */ - if (initrd_high < (kbd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD)) - initrd_high = kbd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD; - debug("## Logbuffer at 0x%08lX ", kbd->bi_memsize - LOGBUFF_LEN); -#endif - /* * Booting a (Linux) kernel image * @@ -89,19 +70,18 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, * memory, which means far enough below the current stack * pointer. */ - asm("movel %%a7, %%d0\n" - "movel %%d0, %0\n": "=d"(sp): :"%d0"); + sp_limit = get_sp(); - debug("## Current stack ends at 0x%08lX ", sp); + debug("## Current stack ends at 0x%08lX ", sp_limit); - sp -= 2048; /* just to be sure */ - if (sp > CFG_BOOTMAPSZ) - sp = CFG_BOOTMAPSZ; - sp &= ~0xF; + sp_limit -= 2048; /* just to be sure */ + if (sp_limit > CFG_BOOTMAPSZ) + sp_limit = CFG_BOOTMAPSZ; + sp_limit &= ~0xF; - debug("=> set upper limit to 0x%08lX\n", sp); + debug("=> set upper limit to 0x%08lX\n", sp_limit); - cmdline = (char *)((sp - CFG_BARGSIZE) & ~0xF); + cmdline = (char *)((sp_limit - CFG_BARGSIZE) & ~0xF); kbd = (bd_t *) (((ulong) cmdline - sizeof(bd_t)) & ~0xF); if ((s = getenv("bootargs")) == NULL) @@ -126,69 +106,17 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, kbd->bi_busfreq /= 1000000L; } + /* find kernel */ kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))image_get_ep (hdr); + /* find ramdisk */ get_ramdisk (cmdtp, flag, argc, argv, hdr, verify, IH_ARCH_M68K, &rd_data_start, &rd_data_end); - rd_len = rd_data_end - rd_data_start; - if (rd_data_start) { - if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */ - initrd_start = rd_data_start; - initrd_end = rd_data_end; - } else { - initrd_start = (ulong) kbd - rd_len; - initrd_start &= ~(4096 - 1); /* align on page */ - - if (initrd_high) { - ulong nsp; - - /* - * the inital ramdisk does not need to be within - * CFG_BOOTMAPSZ as it is not accessed until after - * the mm system is initialised. - * - * do the stack bottom calculation again and see if - * the initrd will fit just below the monitor stack - * bottom without overwriting the area allocated - * above for command line args and board info. - */ - asm("movel %%a7, %%d0\n" - "movel %%d0, %0\n": "=d"(nsp): :"%d0"); - - nsp -= 2048; /* just to be sure */ - nsp &= ~0xF; - - if (nsp > initrd_high) /* limit as specified */ - nsp = initrd_high; - - nsp -= rd_len; - nsp &= ~(4096 - 1); /* align on page */ - - if (nsp >= sp) - initrd_start = nsp; - } - - SHOW_BOOT_PROGRESS(12); - - debug - ("## initrd at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n", - rd_data_start, rd_data_end - 1, rd_len, rd_len); - - initrd_end = initrd_start + rd_len; - printf(" Loading Ramdisk to %08lx, end %08lx ... ", - initrd_start, initrd_end); - - memmove_wd((void *)initrd_start, - (void *)rd_data_start, rd_len, CHUNKSZ); - - puts("OK\n"); - } - } else { - initrd_start = 0; - initrd_end = 0; - } + rd_len = rd_data_end - rd_data_start; + ramdisk_high (rd_data_start, rd_len, kdb, sp_limit, get_sp (), + &initrd_start, &initrd_end); debug("## Transferring control to Linux (at address %08lx) ...\n", (ulong) kernel); @@ -206,3 +134,13 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end); /* does not return */ } + +static ulong get_sp (void) +{ + ulong sp; + + asm("movel %%a7, %%d0\n" + "movel %%d0, %0\n": "=d"(sp): :"%d0"); + + return sp; +} -- cgit v1.2.3