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