~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/fw/lib/cmdline.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  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
  4  * for more details.
  5  *
  6  * Copyright (C) 2012 MIPS Technologies, Inc.  All rights reserved.
  7  */
  8 #include <linux/init.h>
  9 #include <linux/kernel.h>
 10 #include <linux/string.h>
 11 
 12 #include <asm/addrspace.h>
 13 #include <asm/fw/fw.h>
 14 
 15 int fw_argc;
 16 int *_fw_argv;
 17 int *_fw_envp;
 18 
 19 #ifndef CONFIG_HAVE_PLAT_FW_INIT_CMDLINE
 20 void __init fw_init_cmdline(void)
 21 {
 22         int i;
 23 
 24         /* Validate command line parameters. */
 25         if ((fw_arg0 >= CKSEG0) || (fw_arg1 < CKSEG0)) {
 26                 fw_argc = 0;
 27                 _fw_argv = NULL;
 28         } else {
 29                 fw_argc = (fw_arg0 & 0x0000ffff);
 30                 _fw_argv = (int *)fw_arg1;
 31         }
 32 
 33         /* Validate environment pointer. */
 34         if (fw_arg2 < CKSEG0)
 35                 _fw_envp = NULL;
 36         else
 37                 _fw_envp = (int *)fw_arg2;
 38 
 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);
 43         }
 44 }
 45 #endif
 46 
 47 char * __init fw_getcmdline(void)
 48 {
 49         return &(arcs_cmdline[0]);
 50 }
 51 
 52 char *fw_getenv(char *envname)
 53 {
 54         char *result = NULL;
 55 
 56         if (_fw_envp != NULL && fw_envp(0) != NULL) {
 57                 /*
 58                  * Return a pointer to the given environment variable.
 59                  * YAMON uses "name", "value" pairs, while U-Boot uses
 60                  * "name=value".
 61                  */
 62                 int i, yamon, index = 0;
 63 
 64                 yamon = (strchr(fw_envp(index), '=') == NULL);
 65                 i = strlen(envname);
 66 
 67                 while (fw_envp(index)) {
 68                         if (strncmp(envname, fw_envp(index), i) == 0) {
 69                                 if (yamon) {
 70                                         result = fw_envp(index + 1);
 71                                         break;
 72                                 } else if (fw_envp(index)[i] == '=') {
 73                                         result = fw_envp(index) + i + 1;
 74                                         break;
 75                                 }
 76                         }
 77 
 78                         /* Increment array index. */
 79                         if (yamon)
 80                                 index += 2;
 81                         else
 82                                 index += 1;
 83                 }
 84         }
 85 
 86         return result;
 87 }
 88 
 89 unsigned long fw_getenvl(char *envname)
 90 {
 91         unsigned long envl = 0UL;
 92         char *str;
 93         int tmp;
 94 
 95         str = fw_getenv(envname);
 96         if (str) {
 97                 tmp = kstrtoul(str, 0, &envl);
 98                 if (tmp)
 99                         envl = 0;
100         }
101 
102         return envl;
103 }
104 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php