From owner-svn-src-projects@FreeBSD.ORG Wed Oct 28 21:27:57 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 541D2106568B; Wed, 28 Oct 2009 21:27:57 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 29D448FC16; Wed, 28 Oct 2009 21:27:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9SLRvxQ072819; Wed, 28 Oct 2009 21:27:57 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9SLRvvD072817; Wed, 28 Oct 2009 21:27:57 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200910282127.n9SLRvvD072817@svn.freebsd.org> From: Andrew Thompson Date: Wed, 28 Oct 2009 21:27:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198562 - projects/mips/sys/mips/atheros X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2009 21:27:57 -0000 Author: thompsa Date: Wed Oct 28 21:27:56 2009 New Revision: 198562 URL: http://svn.freebsd.org/changeset/base/198562 Log: Parse and save the command line passed in from RedBoot (exec -c "xxx") and also the board specific environment variables. This is not ar71xx specific and should be shared better. Modified: projects/mips/sys/mips/atheros/ar71xx_machdep.c Modified: projects/mips/sys/mips/atheros/ar71xx_machdep.c ============================================================================== --- projects/mips/sys/mips/atheros/ar71xx_machdep.c Wed Oct 28 21:25:22 2009 (r198561) +++ projects/mips/sys/mips/atheros/ar71xx_machdep.c Wed Oct 28 21:27:56 2009 (r198562) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -59,6 +60,42 @@ __FBSDID("$FreeBSD$"); extern int *edata; extern int *end; uint32_t ar711_base_mac[ETHER_ADDR_LEN]; +/* 4KB static data aread to keep a copy of the bootload env until + the dynamic kenv is setup */ +char boot1_env[4096]; + +/* + * We get a string in from Redboot with the all the arguments together, + * "foo=bar bar=baz". Split them up and save in kenv. + */ +static void +parse_argv(char *str) +{ + char *n, *v; + + while ((v = strsep(&str, " ")) != NULL) { + if (*v == '\0') + continue; + if (*v == '-') { + while (*v != '\0') { + v++; + switch (*v) { + case 'a': boothowto |= RB_ASKNAME; break; + case 'd': boothowto |= RB_KDB; break; + case 'g': boothowto |= RB_GDB; break; + case 's': boothowto |= RB_SINGLE; break; + case 'v': boothowto |= RB_VERBOSE; break; + } + } + } else { + n = strsep(&v, "="); + if (v == NULL) + setenv(n, "1"); + else + setenv(n, v); + } + } +} void platform_halt(void) @@ -154,6 +191,7 @@ platform_start(__register_t a0 __unused, platform_counter_freq = ar71xx_cpu_freq(); mips_timer_init_params(platform_counter_freq, 1); cninit(); + init_static_kenv(boot1_env, sizeof(boot1_env)); printf("platform frequency: %lld\n", platform_counter_freq); printf("arguments: \n"); @@ -164,8 +202,10 @@ platform_start(__register_t a0 __unused, printf("Cmd line:"); if (MIPS_IS_VALID_PTR(argv)) { - for (i = 0; i < argc; i++) + for (i = 0; i < argc; i++) { printf(" %s", argv[i]); + parse_argv(argv[i]); + } } else printf ("argv is invalid"); @@ -173,8 +213,10 @@ platform_start(__register_t a0 __unused, printf("Environment:\n"); if (MIPS_IS_VALID_PTR(envp)) { - for (i = 0; envp[i]; i+=2) + for (i = 0; envp[i]; i+=2) { printf(" %s = %s\n", envp[i], envp[i+1]); + setenv(envp[i], envp[i+1]); + } } else printf ("envp is invalid\n");