From owner-svn-src-all@freebsd.org Sat Apr 16 19:44:42 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4DD93AEEF77; Sat, 16 Apr 2016 19:44:42 +0000 (UTC) (envelope-from sgalabov@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0641811B2; Sat, 16 Apr 2016 19:44:41 +0000 (UTC) (envelope-from sgalabov@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3GJifD8006452; Sat, 16 Apr 2016 19:44:41 GMT (envelope-from sgalabov@FreeBSD.org) Received: (from sgalabov@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3GJif5G006451; Sat, 16 Apr 2016 19:44:41 GMT (envelope-from sgalabov@FreeBSD.org) Message-Id: <201604161944.u3GJif5G006451@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sgalabov set sender to sgalabov@FreeBSD.org using -f From: Stanislav Galabov Date: Sat, 16 Apr 2016 19:44:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298127 - head/sys/mips/mediatek X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Apr 2016 19:44:42 -0000 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));