From: Yannick GICQUEL <yannick.gicquel@open.eurogiciel.org>
To: linux-m68k@vger.kernel.org
Subject: [RFC 7/8] m68k: mmu: add u-boot command line support in setup_arch()
Date: Wed, 8 Jul 2015 11:51:31 +0200 [thread overview]
Message-ID: <1436349092-2214-8-git-send-email-yannick.gicquel@gmail.com> (raw)
In-Reply-To: <1436349092-2214-1-git-send-email-yannick.gicquel@gmail.com>
This part was ported from setup_no.c
Signed-off-by: Yannick GICQUEL <yannick.gicquel@gmail.com>
---
arch/m68k/kernel/setup_mm.c | 80 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
diff --git a/arch/m68k/kernel/setup_mm.c b/arch/m68k/kernel/setup_mm.c
index 0bc6f77..94be970 100644
--- a/arch/m68k/kernel/setup_mm.c
+++ b/arch/m68k/kernel/setup_mm.c
@@ -225,6 +225,68 @@ static void __init m68k_parse_bootinfo(const struct bi_record *record)
#endif
}
+#if defined(CONFIG_UBOOT)
+/*
+ * parse_uboot_commandline
+ *
+ * Copies u-boot commandline arguments and store them in the proper linux
+ * variables.
+ *
+ * Assumes:
+ * _init_sp global contains the address in the stack pointer when the
+ * kernel starts (see head.S::_start)
+ *
+ * U-Boot calling convention:
+ * (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
+ *
+ * _init_sp can be parsed as such
+ *
+ * _init_sp+00 = u-boot cmd after jsr into kernel (skip)
+ * _init_sp+04 = &kernel board_info (residual data)
+ * _init_sp+08 = &initrd_start
+ * _init_sp+12 = &initrd_end
+ * _init_sp+16 = &cmd_start
+ * _init_sp+20 = &cmd_end
+ *
+ * This also assumes that the memory locations pointed to are still
+ * unmodified. U-boot places them near the end of external SDRAM.
+ *
+ * Argument(s):
+ * commandp = the linux commandline arg container to fill.
+ * size = the sizeof commandp.
+ *
+ * Returns:
+ */
+static void __init parse_uboot_commandline(char *commandp, int size)
+{
+ extern unsigned long _init_sp;
+ unsigned long *sp;
+ unsigned long uboot_kbd;
+ unsigned long uboot_initrd_start, uboot_initrd_end;
+ unsigned long uboot_cmd_start, uboot_cmd_end;
+
+
+ sp = (unsigned long *)_init_sp;
+ uboot_kbd = sp[1];
+ uboot_initrd_start = sp[2];
+ uboot_initrd_end = sp[3];
+ uboot_cmd_start = sp[4];
+ uboot_cmd_end = sp[5];
+
+ if (uboot_cmd_start && uboot_cmd_end)
+ strncpy(commandp, (const char *)uboot_cmd_start, size);
+#if defined(CONFIG_BLK_DEV_INITRD)
+ if (uboot_initrd_start && uboot_initrd_end &&
+ (uboot_initrd_end > uboot_initrd_start)) {
+ initrd_start = uboot_initrd_start;
+ initrd_end = uboot_initrd_end;
+ printk(KERN_INFO "initrd at 0x%lx:0x%lx\n",
+ initrd_start, initrd_end);
+ }
+#endif /* if defined(CONFIG_BLK_DEV_INITRD) */
+}
+#endif /* #if defined(CONFIG_UBOOT) */
+
void __init setup_arch(char **cmdline_p)
{
#ifndef CONFIG_SUN3
@@ -274,6 +336,24 @@ void __init setup_arch(char **cmdline_p)
strncpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE);
m68k_command_line[CL_SIZE - 1] = 0;
#endif /* CONFIG_BOOTPARAM */
+
+#if defined(CONFIG_UBOOT)
+ /* CONFIG_UBOOT and CONFIG_BOOTPARAM defined, concatenate cmdline */
+ #if defined(CONFIG_BOOTPARAM)
+ /* Add the whitespace separator */
+ m68k_command_line[strlen(CONFIG_BOOTPARAM_STRING)] = ' ';
+ /* Parse uboot command line into the rest of the buffer */
+ parse_uboot_commandline(
+ &m68k_command_line[(strlen(CONFIG_BOOTPARAM_STRING)+1)],
+ (sizeof(m68k_command_line) -
+ (strlen(CONFIG_BOOTPARAM_STRING)+1)));
+ /* Only CONFIG_UBOOT defined, create cmdline */
+ #else
+ parse_uboot_commandline(&m68k_command_line[0], sizeof(m68k_command_line));
+ #endif /* CONFIG_BOOTPARAM */
+ m68k_command_line[sizeof(m68k_command_line) - 1] = 0;
+#endif /* CONFIG_UBOOT */
+
*cmdline_p = m68k_command_line;
memcpy(boot_command_line, *cmdline_p, CL_SIZE);
--
1.9.1.286.g5172cb3
next prev parent reply other threads:[~2015-07-08 9:51 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-08 9:51 [RFC 0/8] m5441x: mmu support patchset Yannick GICQUEL
2015-07-08 9:51 ` [RFC 1/8] m68k: coldfire: unlink FPU presence from MMU activation Yannick GICQUEL
2015-07-08 13:36 ` Greg Ungerer
2015-07-17 10:46 ` Yannick GICQUEL
2015-07-08 14:03 ` Geert Uytterhoeven
2015-07-08 14:12 ` Greg Ungerer
2015-07-08 14:20 ` Geert Uytterhoeven
2015-07-08 9:51 ` [RFC 2/8] m68k: fix build issue in setup_arch() when no FPU Yannick GICQUEL
2015-07-08 14:04 ` Geert Uytterhoeven
2015-07-08 9:51 ` [RFC 3/8] m68k: add dummy dump_fpu() when FPU is not present Yannick GICQUEL
2015-07-08 9:51 ` [RFC 4/8] m68k: m5441x: add ColdFire 5441x CPU MMU memory init code Yannick GICQUEL
2015-07-08 13:45 ` Greg Ungerer
2015-07-08 9:51 ` [RFC 5/8] m68k: m5441x: fix ACR0 base address when MBAR is not present Yannick GICQUEL
2015-07-08 9:51 ` [RFC 6/8] m68k: m5441x: set rambar to end of SRAM physical addr space Yannick GICQUEL
2015-07-08 13:53 ` Greg Ungerer
2015-07-17 10:47 ` Yannick GICQUEL
2015-07-08 9:51 ` Yannick GICQUEL [this message]
2015-07-08 14:03 ` [RFC 7/8] m68k: mmu: add u-boot command line support in setup_arch() Greg Ungerer
2015-07-08 9:51 ` [RFC 8/8] m68k: uImage generation support Yannick GICQUEL
2015-07-08 14:07 ` [RFC 0/8] m5441x: mmu support patchset Greg Ungerer
2015-07-17 10:30 ` Yannick GICQUEL
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1436349092-2214-8-git-send-email-yannick.gicquel@gmail.com \
--to=yannick.gicquel@open.eurogiciel.org \
--cc=linux-m68k@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).