summaryrefslogtreecommitdiffstats
path: root/sys/mips
diff options
context:
space:
mode:
authorsgalabov <sgalabov@FreeBSD.org>2016-04-16 19:44:41 +0000
committersgalabov <sgalabov@FreeBSD.org>2016-04-16 19:44:41 +0000
commit056d436755cf7dbd452887aba78f7895b9cccc83 (patch)
tree409d632c1750d084dce05f0e6e12880331e20560 /sys/mips
parent146045bcc36bcfd6870fe83e8064c32ad8db13e7 (diff)
downloadFreeBSD-src-056d436755cf7dbd452887aba78f7895b9cccc83.zip
FreeBSD-src-056d436755cf7dbd452887aba78f7895b9cccc83.tar.gz
Add support for boot arguments specification via fdt
Add suppport for passing boot arguments via FDT for mediatek/ralink SoCs. This was taken from kan's work on CI20. Since most OpenWRT dts files have bootargs defined, we use bsdbootargs to specify FreeBSD specific arguments. Approved by: adrian (mentor) Sponsored by: Smartcom - Bulgaria AD Differential Revision: https://reviews.freebsd.org/D5979
Diffstat (limited to 'sys/mips')
-rw-r--r--sys/mips/mediatek/mtk_machdep.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/sys/mips/mediatek/mtk_machdep.c b/sys/mips/mediatek/mtk_machdep.c
index eeadd4f..aaae780 100644
--- a/sys/mips/mediatek/mtk_machdep.c
+++ b/sys/mips/mediatek/mtk_machdep.c
@@ -192,6 +192,52 @@ mips_init(void)
#endif
}
+static void
+_parse_bootarg(char *v)
+{
+ char *n;
+
+ if (*v == '-') {
+ while (*v != '\0') {
+ v++;
+ switch (*v) {
+ case 'a': boothowto |= RB_ASKNAME; break;
+ /* Someone should simulate that ;-) */
+ case 'C': boothowto |= RB_CDROM; break;
+ case 'd': boothowto |= RB_KDB; break;
+ case 'D': boothowto |= RB_MULTIPLE; break;
+ case 'm': boothowto |= RB_MUTE; break;
+ case 'g': boothowto |= RB_GDB; break;
+ case 'h': boothowto |= RB_SERIAL; break;
+ case 'p': boothowto |= RB_PAUSE; break;
+ case 'r': boothowto |= RB_DFLTROOT; break;
+ case 's': boothowto |= RB_SINGLE; break;
+ case 'v': boothowto |= RB_VERBOSE; break;
+ }
+ }
+ } else {
+ n = strsep(&v, "=");
+ if (v == NULL)
+ kern_setenv(n, "1");
+ else
+ kern_setenv(n, v);
+ }
+}
+
+/* Parse cmd line args as env - copied from xlp_machdep. */
+/* XXX-BZ this should really be centrally provided for all (boot) code. */
+static void
+_parse_bootargs(char *cmdline)
+{
+ char *v;
+
+ while ((v = strsep(&cmdline, " \n")) != NULL) {
+ if (*v == '\0')
+ continue;
+ _parse_bootarg(v);
+ }
+}
+
void
platform_reset(void)
{
@@ -209,6 +255,8 @@ platform_start(__register_t a0 __unused, __register_t a1 __unused,
char **argv = (char **)MIPS_PHYS_TO_KSEG0(a1);
char **envp = (char **)MIPS_PHYS_TO_KSEG0(a2);
void *dtbp;
+ phandle_t chosen;
+ char buf[2048];
/* clear the BSS and SBSS segments */
kernend = (vm_offset_t)&end;
@@ -238,6 +286,13 @@ platform_start(__register_t a0 __unused, __register_t a1 __unused,
init_static_kenv(boot1_env, sizeof(boot1_env));
+ /*
+ * Get bsdbootargs from FDT if specified.
+ */
+ chosen = OF_finddevice("/chosen");
+ if (OF_getprop(chosen, "bsdbootargs", buf, sizeof(buf)) != -1)
+ _parse_bootargs(buf);
+
printf("FDT DTB at: 0x%08x\n", (uint32_t)dtbp);
printf("CPU clock: %4dMHz\n", mtk_soc_get_cpuclk()/(1000*1000));
OpenPOWER on IntegriCloud