blob: 5c8603c85f20720ae8f3dab122aad5956119f145 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 * cmdline.c: Kernel command line creation using ARCS argc/argv.
7 *
8 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
9 */
10#include <linux/init.h>
11#include <linux/kernel.h>
12#include <linux/string.h>
13
14#include <asm/sgialib.h>
15#include <asm/bootinfo.h>
16
17#undef DEBUG_CMDLINE
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019static char *ignored[] = {
20 "ConsoleIn=",
21 "ConsoleOut=",
22 "SystemPartition=",
23 "OSLoader=",
24 "OSLoadPartition=",
25 "OSLoadFilename=",
26 "OSLoadOptions="
27};
28
29static char *used_arc[][2] = {
30 { "OSLoadPartition=", "root=" },
31 { "OSLoadOptions=", "" }
32};
33
34static char * __init move_firmware_args(char* cp)
35{
36 char *s;
37 int actr, i;
38
39 actr = 1; /* Always ignore argv[0] */
40
41 while (actr < prom_argc) {
42 for(i = 0; i < ARRAY_SIZE(used_arc); i++) {
43 int len = strlen(used_arc[i][0]);
44
45 if (!strncmp(prom_argv(actr), used_arc[i][0], len)) {
46 /* Ok, we want it. First append the replacement... */
47 strcat(cp, used_arc[i][1]);
48 cp += strlen(used_arc[i][1]);
49 /* ... and now the argument */
Roel Kluinfa091872007-11-02 19:59:05 +010050 s = strchr(prom_argv(actr), '=');
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 if (s) {
52 s++;
53 strcpy(cp, s);
54 cp += strlen(s);
55 }
56 *cp++ = ' ';
57 break;
58 }
59 }
60 actr++;
61 }
62
63 return cp;
64}
65
66void __init prom_init_cmdline(void)
67{
68 char *cp;
69 int actr, i;
70
71 actr = 1; /* Always ignore argv[0] */
72
73 cp = arcs_cmdline;
74 /*
75 * Move ARC variables to the beginning to make sure they can be
76 * overridden by later arguments.
77 */
78 cp = move_firmware_args(cp);
79
80 while (actr < prom_argc) {
81 for (i = 0; i < ARRAY_SIZE(ignored); i++) {
82 int len = strlen(ignored[i]);
83
84 if (!strncmp(prom_argv(actr), ignored[i], len))
85 goto pic_cont;
86 }
87 /* Ok, we want it. */
88 strcpy(cp, prom_argv(actr));
89 cp += strlen(prom_argv(actr));
90 *cp++ = ' ';
91
92 pic_cont:
93 actr++;
94 }
95
96 if (cp != arcs_cmdline) /* get rid of trailing space */
97 --cp;
98 *cp = '\0';
99
100#ifdef DEBUG_CMDLINE
101 printk(KERN_DEBUG "prom cmdline: %s\n", arcs_cmdline);
102#endif
103}