Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  * cmdline.c: Kernel command line creation using ARCS argc/argv.
0007  *
0008  * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
0009  */
0010 #include <linux/bug.h>
0011 #include <linux/init.h>
0012 #include <linux/kernel.h>
0013 #include <linux/string.h>
0014 
0015 #include <asm/sgialib.h>
0016 #include <asm/bootinfo.h>
0017 
0018 #undef DEBUG_CMDLINE
0019 
0020 /*
0021  * A 32-bit ARC PROM pass arguments and environment as 32-bit pointer.
0022  * These macro take care of sign extension.
0023  */
0024 #define prom_argv(index) ((char *) (long)argv[(index)])
0025 
0026 static char *ignored[] = {
0027     "ConsoleIn=",
0028     "ConsoleOut=",
0029     "SystemPartition=",
0030     "OSLoader=",
0031     "OSLoadPartition=",
0032     "OSLoadFilename=",
0033     "OSLoadOptions="
0034 };
0035 
0036 static char *used_arc[][2] = {
0037     { "OSLoadPartition=", "root=" },
0038     { "OSLoadOptions=", "" }
0039 };
0040 
0041 static char __init *move_firmware_args(int argc, LONG *argv, char *cp)
0042 {
0043     char *s;
0044     int actr, i;
0045 
0046     actr = 1; /* Always ignore argv[0] */
0047 
0048     while (actr < argc) {
0049         for(i = 0; i < ARRAY_SIZE(used_arc); i++) {
0050             int len = strlen(used_arc[i][0]);
0051 
0052             if (!strncmp(prom_argv(actr), used_arc[i][0], len)) {
0053             /* Ok, we want it. First append the replacement... */
0054                 strcat(cp, used_arc[i][1]);
0055                 cp += strlen(used_arc[i][1]);
0056                 /* ... and now the argument */
0057                 s = strchr(prom_argv(actr), '=');
0058                 if (s) {
0059                     s++;
0060                     strcpy(cp, s);
0061                     cp += strlen(s);
0062                 }
0063                 *cp++ = ' ';
0064                 break;
0065             }
0066         }
0067         actr++;
0068     }
0069 
0070     return cp;
0071 }
0072 
0073 void __init prom_init_cmdline(int argc, LONG *argv)
0074 {
0075     char *cp;
0076     int actr, i;
0077 
0078     actr = 1; /* Always ignore argv[0] */
0079 
0080     cp = arcs_cmdline;
0081     /*
0082      * Move ARC variables to the beginning to make sure they can be
0083      * overridden by later arguments.
0084      */
0085     cp = move_firmware_args(argc, argv, cp);
0086 
0087     while (actr < argc) {
0088         for (i = 0; i < ARRAY_SIZE(ignored); i++) {
0089             int len = strlen(ignored[i]);
0090 
0091             if (!strncmp(prom_argv(actr), ignored[i], len))
0092                 goto pic_cont;
0093         }
0094         /* Ok, we want it. */
0095         strcpy(cp, prom_argv(actr));
0096         cp += strlen(prom_argv(actr));
0097         *cp++ = ' ';
0098 
0099     pic_cont:
0100         actr++;
0101     }
0102 
0103     if (cp != arcs_cmdline)     /* get rid of trailing space */
0104         --cp;
0105     *cp = '\0';
0106 
0107 #ifdef DEBUG_CMDLINE
0108     printk(KERN_DEBUG "prom cmdline: %s\n", arcs_cmdline);
0109 #endif
0110 }