Date: Sat, 16 Apr 2016 19:44:41 +0000 (UTC) From: Stanislav Galabov <sgalabov@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298127 - head/sys/mips/mediatek Message-ID: <201604161944.u3GJif5G006451@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sgalabov Date: Sat Apr 16 19:44:41 2016 New Revision: 298127 URL: https://svnweb.freebsd.org/changeset/base/298127 Log: 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 Modified: head/sys/mips/mediatek/mtk_machdep.c Modified: head/sys/mips/mediatek/mtk_machdep.c ============================================================================== --- head/sys/mips/mediatek/mtk_machdep.c Sat Apr 16 19:42:54 2016 (r298126) +++ head/sys/mips/mediatek/mtk_machdep.c Sat Apr 16 19:44:41 2016 (r298127) @@ -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, 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, 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));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604161944.u3GJif5G006451>