2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
8 #include <linux/init.h>
9 #include <linux/kernel.h>
10 #include <linux/string.h>
12 #include <asm/addrspace.h>
13 #include <asm/fw/fw.h>
19 #ifndef CONFIG_HAVE_PLAT_FW_INIT_CMDLINE
20 void __init fw_init_cmdline(void)
24 /* Validate command line parameters. */
25 if ((fw_arg0 >= CKSEG0) || (fw_arg1 < CKSEG0)) {
29 fw_argc = (fw_arg0 & 0x0000ffff);
30 _fw_argv = (int *)fw_arg1;
33 /* Validate environment pointer. */
37 _fw_envp = (int *)fw_arg2;
39 for (i = 1; i < fw_argc; i++) {
40 strlcat(arcs_cmdline, fw_argv(i), COMMAND_LINE_SIZE);
41 if (i < (fw_argc - 1))
42 strlcat(arcs_cmdline, " ", COMMAND_LINE_SIZE);
47 char * __init fw_getcmdline(void)
49 return &(arcs_cmdline[0]);
52 char *fw_getenv(char *envname)
56 if (_fw_envp != NULL && fw_envp(0) != NULL) {
58 * Return a pointer to the given environment variable.
59 * YAMON uses "name", "value" pairs, while U-Boot uses
62 int i, yamon, index = 0;
64 yamon = (strchr(fw_envp(index), '=') == NULL);
67 while (fw_envp(index)) {
68 if (strncmp(envname, fw_envp(index), i) == 0) {
70 result = fw_envp(index + 1);
72 } else if (fw_envp(index)[i] == '=') {
73 result = fw_envp(index) + i + 1;
78 /* Increment array index. */
89 unsigned long fw_getenvl(char *envname)
91 unsigned long envl = 0UL;
95 str = fw_getenv(envname);
97 tmp = kstrtoul(str, 0, &envl);