Patchwork [U-Boot,03/11] MIPS: bootm: add support for LMB

login
register
mail settings
Submitter Daniel Schwierzeck
Date June 8, 2013, 10:42 p.m.
Message ID <1370731370-32767-4-git-send-email-daniel.schwierzeck@gmail.com>
Download mbox | patch
Permalink /patch/249987/
State Superseded
Delegated to: Daniel Schwierzeck
Headers show

Comments

Daniel Schwierzeck - June 8, 2013, 10:42 p.m.
This is required for init ramdisk relocation and device tree
support.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
---
 arch/mips/include/asm/config.h |  2 ++
 arch/mips/lib/bootm.c          | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)

Patch

diff --git a/arch/mips/include/asm/config.h b/arch/mips/include/asm/config.h
index 049c44e..36438be 100644
--- a/arch/mips/include/asm/config.h
+++ b/arch/mips/include/asm/config.h
@@ -21,4 +21,6 @@ 
 #ifndef _ASM_CONFIG_H_
 #define _ASM_CONFIG_H_
 
+#define CONFIG_LMB
+
 #endif
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 5540477..1b0b06a 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -43,6 +43,27 @@  static int linux_env_idx;
 static void linux_params_init(ulong start, char *commandline);
 static void linux_env_set(char *env_name, char *env_val);
 
+static ulong arch_get_sp(void)
+{
+	ulong ret;
+
+	__asm__ __volatile__("move %0, $sp" : "=r"(ret) : );
+
+	return ret;
+}
+
+void arch_lmb_reserve(struct lmb *lmb)
+{
+	ulong sp;
+
+	sp = arch_get_sp();
+	debug("## Current stack ends at 0x%08lx\n", sp);
+
+	/* adjust sp by 4K to be safe */
+	sp -= 4096;
+	lmb_reserve(lmb, sp, CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp);
+}
+
 static void boot_prep_linux(bootm_headers_t *images)
 {
 	char *commandline = getenv("bootargs");