* [patch] cmdline.c rewrite
@ 2003-02-04 6:13 Andrew Clausen
2003-02-04 9:24 ` Guido Guenther
0 siblings, 1 reply; 11+ messages in thread
From: Andrew Clausen @ 2003-02-04 6:13 UTC (permalink / raw)
To: Linux-MIPS
Hi all,
This patch is mainly a cleanup. There is only one change (improvement!)
in the semantics:
Some kernel parameters are auto-generated. eg: root= (always has been
broken). Anyway, the old version of cmdline.c added these auto-generated
parameters unconditionally. Now, it old adds them if there's no
collision with old parameters. Is that Right?
Cheers,
Andrew
Index: cmdline.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/arc/cmdline.c,v
retrieving revision 1.5.2.3
diff -u -r1.5.2.3 cmdline.c
--- cmdline.c 5 Aug 2002 23:53:30 -0000 1.5.2.3
+++ cmdline.c 24 Jan 2003 06:43:57 -0000
@@ -6,6 +6,8 @@
* cmdline.c: Kernel command line creation using ARCS argc/argv.
*
* Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
+ * Copyright (C) 2003 Silicon Graphics, Inc.
+ * modifications by Andrew Clausen (clausen@gnu.org)
*/
#include <linux/init.h>
#include <linux/kernel.h>
@@ -16,96 +18,76 @@
#undef DEBUG_CMDLINE
-char arcs_cmdline[CL_SIZE];
+char arcs_cmdline[CL_SIZE]; /* initialized to empty */
+static int __initdata arg_count = 0;
char * __init prom_getcmdline(void)
{
- return &(arcs_cmdline[0]);
+ return arcs_cmdline;
}
-static char *ignored[] = {
+static void __init append_translated_arg(const char* match, const char* trans)
+{
+ int len = strlen(match);
+ int i;
+
+ /* don't repeat arguments, like "root=X root=Y", unless the
+ * replacement string "trans" is empty, in which case the user is
+ * getting exactly what they asked for.
+ */
+ if (strlen(trans) > 0 && strstr(arcs_cmdline, trans))
+ return;
+
+ for (i = 1; i < prom_argc; i++) {
+ if (!strncmp(prom_argv(i), match, len)) {
+ if (arg_count++)
+ strcat(arcs_cmdline, " ");
+ strcat(arcs_cmdline, trans);
+ strcat(arcs_cmdline, prom_argv(i) + len);
+ return;
+ }
+ }
+}
+
+static char __initdata *ignored_args[] = {
"ConsoleIn=",
"ConsoleOut=",
"SystemPartition=",
"OSLoader=",
"OSLoadPartition=",
"OSLoadFilename=",
- "OSLoadOptions="
-};
-#define NENTS(foo) ((sizeof((foo)) / (sizeof((foo[0])))))
-
-static char *used_arc[][2] = {
- { "OSLoadPartition=", "root=" },
- { "OSLoadOptions=", "" }
+ "OSLoadOptions=",
+ NULL
};
-static char * __init move_firmware_args(char* cp)
+static int __init is_arg_useful(const char* arg)
{
- char *s;
- int actr, i;
-
- actr = 1; /* Always ignore argv[0] */
-
- while (actr < prom_argc) {
- for(i = 0; i < NENTS(used_arc); i++) {
- int len = strlen(used_arc[i][0]);
-
- if (!strncmp(prom_argv(actr), used_arc[i][0], len)) {
- /* Ok, we want it. First append the replacement... */
- strcat(cp, used_arc[i][1]);
- cp += strlen(used_arc[i][1]);
- /* ... and now the argument */
- s = strstr(prom_argv(actr), "=");
- if (s) {
- s++;
- strcpy(cp, s);
- cp += strlen(s);
- }
- *cp++ = ' ';
- break;
- }
- }
- actr++;
+ int i;
+ for (i = 0; ignored_args[i] != NULL; i++) {
+ if (!strncmp(arg, ignored_args[i], strlen(ignored_args[i]) - 1))
+ return 0;
}
-
- return cp;
+ return 1;
}
-
-void __init prom_init_cmdline(void)
+static void __init append_untranslated_args(void)
{
- char *cp;
- int actr, i;
-
- actr = 1; /* Always ignore argv[0] */
-
- cp = &(arcs_cmdline[0]);
- /*
- * Move ARC variables to the beginning to make sure they can be
- * overridden by later arguments.
- */
- cp = move_firmware_args(cp);
-
- while (actr < prom_argc) {
- for (i = 0; i < NENTS(ignored); i++) {
- int len = strlen(ignored[i]);
-
- if (!strncmp(prom_argv(actr), ignored[i], len))
- goto pic_cont;
+ int i;
+ for (i = 1; i < prom_argc; i++) {
+ if (is_arg_useful(prom_argv(i))) {
+ if (arg_count++)
+ strcat(arcs_cmdline, " ");
+ strcat(arcs_cmdline, prom_argv(i));
}
- /* Ok, we want it. */
- strcpy(cp, prom_argv(actr));
- cp += strlen(prom_argv(actr));
- *cp++ = ' ';
-
- pic_cont:
- actr++;
}
- if (cp != &(arcs_cmdline[0])) /* get rid of trailing space */
- --cp;
- *cp = '\0';
+}
+void __init prom_init_cmdline(void)
+{
+ append_translated_arg("OSLoadOptions=", "");
+ append_translated_arg("OSLoadPartition=", "root=");
+ append_untranslated_args();
#ifdef DEBUG_CMDLINE
- prom_printf("prom_init_cmdline: %s\n", &(arcs_cmdline[0]));
+ prom_printf("prom_init_cmdline: \"%s\"\n", arcs_cmdline);
#endif
}
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [patch] cmdline.c rewrite
2003-02-04 6:13 [patch] cmdline.c rewrite Andrew Clausen
@ 2003-02-04 9:24 ` Guido Guenther
2003-02-04 22:39 ` Andrew Clausen
0 siblings, 1 reply; 11+ messages in thread
From: Guido Guenther @ 2003-02-04 9:24 UTC (permalink / raw)
To: Linux-MIPS
On Tue, Feb 04, 2003 at 05:13:23PM +1100, Andrew Clausen wrote:
> Some kernel parameters are auto-generated. eg: root= (always has been
> broken). Anyway, the old version of cmdline.c added these auto-generated
Can you explain in what way root= was broken?
-- Guido
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] cmdline.c rewrite
2003-02-04 9:24 ` Guido Guenther
@ 2003-02-04 22:39 ` Andrew Clausen
2003-02-04 23:12 ` Guido Guenther
0 siblings, 1 reply; 11+ messages in thread
From: Andrew Clausen @ 2003-02-04 22:39 UTC (permalink / raw)
To: Guido Guenther, Linux-MIPS
On Tue, Feb 04, 2003 at 10:24:17AM +0100, Guido Guenther wrote:
> On Tue, Feb 04, 2003 at 05:13:23PM +1100, Andrew Clausen wrote:
> > Some kernel parameters are auto-generated. eg: root= (always has been
> > broken). Anyway, the old version of cmdline.c added these auto-generated
> Can you explain in what way root= was broken?
It was blindly copying from the environment variable a string
looking like dksc(0,1,2). This should be translated (somehow)
to something looking like /dev/sdb1. This would have to be
done after the hard disk probes.
Does Linux have some other notation for addressing devices by
their location on the bus? (I recall a flamewar on the topic...)
Cheers,
Andrew
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] cmdline.c rewrite
2003-02-04 22:39 ` Andrew Clausen
@ 2003-02-04 23:12 ` Guido Guenther
2003-02-04 23:19 ` Andrew Clausen
0 siblings, 1 reply; 11+ messages in thread
From: Guido Guenther @ 2003-02-04 23:12 UTC (permalink / raw)
To: linux-mips
On Wed, Feb 05, 2003 at 09:39:30AM +1100, Andrew Clausen wrote:
> It was blindly copying from the environment variable a string
> looking like dksc(0,1,2). This should be translated (somehow)
> to something looking like /dev/sdb1. This would have to be
> done after the hard disk probes.
If you set OSLoadPartition=/dev/sda1 (or whatever) - it allows you to
boot from hard disk without any boot loader involved. If you have a
bootloader (which is only true for IP22 [1]) it sets up the kernels
commandline properly anyway - so where's the problem? nfsroot?
-- Guido
[1] talking only about SGI mips systems here
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] cmdline.c rewrite
2003-02-04 23:12 ` Guido Guenther
@ 2003-02-04 23:19 ` Andrew Clausen
2003-02-04 23:45 ` Guido Guenther
0 siblings, 1 reply; 11+ messages in thread
From: Andrew Clausen @ 2003-02-04 23:19 UTC (permalink / raw)
To: Guido Guenther, linux-mips
On Wed, Feb 05, 2003 at 12:12:03AM +0100, Guido Guenther wrote:
> On Wed, Feb 05, 2003 at 09:39:30AM +1100, Andrew Clausen wrote:
> > It was blindly copying from the environment variable a string
> > looking like dksc(0,1,2). This should be translated (somehow)
> > to something looking like /dev/sdb1. This would have to be
> > done after the hard disk probes.
> If you set OSLoadPartition=/dev/sda1 (or whatever) - it allows you to
> boot from hard disk without any boot loader involved.
Huh? The firmware uses something looking like OSLoadPartition=dksc(0,1,2),
not /dev/sda1.
> If you have a
> bootloader (which is only true for IP22 [1]) it sets up the kernels
> commandline properly anyway - so where's the problem? nfsroot?
The problem is the firmware (on my IP27, anyway) uses a different
form to Linux for OSLoadPartition. OSLoadPartition tells the
firmware / bootloader (sash here) where to find the kernel.
Cheers,
Andrew
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] cmdline.c rewrite
2003-02-04 23:19 ` Andrew Clausen
@ 2003-02-04 23:45 ` Guido Guenther
2003-02-04 23:55 ` Andrew Clausen
0 siblings, 1 reply; 11+ messages in thread
From: Guido Guenther @ 2003-02-04 23:45 UTC (permalink / raw)
To: linux-mips
On Wed, Feb 05, 2003 at 10:19:09AM +1100, Andrew Clausen wrote:
> Huh? The firmware uses something looking like OSLoadPartition=dksc(0,1,2),
> not /dev/sda1.
Sure. But what we do on IP22 is to let the kernel look at OSLoadPartition and
use that as the root device - so we're actually interested in
linux device names. This is basically done since we can't store the root
device in OSLoadOptions due to limited space.
> > If you have a
> > bootloader (which is only true for IP22 [1]) it sets up the kernels
> > commandline properly anyway - so where's the problem? nfsroot?
>
> The problem is the firmware (on my IP27, anyway) uses a different
> form to Linux for OSLoadPartition. OSLoadPartition tells the
> firmware / bootloader (sash here) where to find the kernel.
Again: we don't care what the firmware wants here, we're interested what
the kernel expects. Why do you need sash for booting anyways? Can't
you let the PROM boot the kernel directly?
Anyways, I won't object to change OSLoadPartition, we have a bootloader
on IP22 so this isn't actually needed anymore.
-- Guido
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] cmdline.c rewrite
2003-02-04 23:45 ` Guido Guenther
@ 2003-02-04 23:55 ` Andrew Clausen
2003-02-05 0:07 ` Guido Guenther
0 siblings, 1 reply; 11+ messages in thread
From: Andrew Clausen @ 2003-02-04 23:55 UTC (permalink / raw)
To: Guido Guenther, linux-mips
On Wed, Feb 05, 2003 at 12:45:29AM +0100, Guido Guenther wrote:
> On Wed, Feb 05, 2003 at 10:19:09AM +1100, Andrew Clausen wrote:
> > Huh? The firmware uses something looking like OSLoadPartition=dksc(0,1,2),
> > not /dev/sda1.
> Sure. But what we do on IP22 is to let the kernel look at OSLoadPartition and
> use that as the root device - so we're actually interested in
> linux device names. This is basically done since we can't store the root
> device in OSLoadOptions due to limited space.
Limited space? Ah. I understand now.
> > > If you have a
> > > bootloader (which is only true for IP22 [1]) it sets up the kernels
> > > commandline properly anyway - so where's the problem? nfsroot?
> >
> > The problem is the firmware (on my IP27, anyway) uses a different
> > form to Linux for OSLoadPartition. OSLoadPartition tells the
> > firmware / bootloader (sash here) where to find the kernel.
>
> Again: we don't care what the firmware wants here,
I do.
> Why do you need sash for booting anyways? Can't
> you let the PROM boot the kernel directly?
No. I can't figure out why. In any case, the PROM uses OSLoadPartition
to find the kernel.
> Anyways, I won't object to change OSLoadPartition, we have a bootloader
> on IP22 so this isn't actually needed anymore.
It is on IP27.
So, we should obviously support OSLoadPartition=/dev/sda1 (=> root=/dev/sda1),
but it would also be nice to support OSLoadPartition=dksc(0,1,3).
Cheers,
Andrew
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] cmdline.c rewrite
2003-02-04 23:55 ` Andrew Clausen
@ 2003-02-05 0:07 ` Guido Guenther
2003-02-05 0:19 ` Andrew Clausen
0 siblings, 1 reply; 11+ messages in thread
From: Guido Guenther @ 2003-02-05 0:07 UTC (permalink / raw)
To: linux-mips
On Wed, Feb 05, 2003 at 10:55:43AM +1100, Andrew Clausen wrote:
> No. I can't figure out why. In any case, the PROM uses OSLoadPartition
> to find the kernel.
On IP22 the PROM uses SystemPartition to find the kernel/bootloader.
We set it to something like scsi(0)disk(1)rdisk(0)partition(8) to grab
it from the vh. Is SystemPartition used differently on IP27?
[..snip..]
> So, we should obviously support OSLoadPartition=/dev/sda1 (=> root=/dev/sda1),
> but it would also be nice to support OSLoadPartition=dksc(0,1,3).
Well we could either check if OSLoadPartition matches the linux device
naming scheme or the other way around and see if it looks like a valid
device identifier used by the PROM (I'd prefer the later, though) - or
simply make the OSLoadPartition <-> root= mapping '#ifdef CONFIG_SGI_IP22'.
-- Guido
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] cmdline.c rewrite
2003-02-05 0:07 ` Guido Guenther
@ 2003-02-05 0:19 ` Andrew Clausen
2003-02-06 16:53 ` Ralf Baechle
0 siblings, 1 reply; 11+ messages in thread
From: Andrew Clausen @ 2003-02-05 0:19 UTC (permalink / raw)
To: Guido Guenther, linux-mips
On Wed, Feb 05, 2003 at 01:07:35AM +0100, Guido Guenther wrote:
> On IP22 the PROM uses SystemPartition to find the kernel/bootloader.
> We set it to something like scsi(0)disk(1)rdisk(0)partition(8) to grab
> it from the vh. Is SystemPartition used differently on IP27?
I think SystemPartition is ignored (haven't been able to see any
evidence to the contrary... I should look in the source...)
> [..snip..]
> > So, we should obviously support OSLoadPartition=/dev/sda1 (=> root=/dev/sda1),
> > but it would also be nice to support OSLoadPartition=dksc(0,1,3).
> Well we could either check if OSLoadPartition matches the linux device
> naming scheme or the other way around and see if it looks like a valid
> device identifier used by the PROM (I'd prefer the later, though) - or
> simply make the OSLoadPartition <-> root= mapping '#ifdef CONFIG_SGI_IP22'.
I think the middle option (the one you prefer) of matching dksc(0,1,3)
and converting it /dev/sda2 is best. Just, it has to happen after the
hard disks are probed - /dev/sdXY are allocated dynamically (in
a predictable-for-end-user way), so you need to find out what it was
allocated to. Is this doable in a nice way?
BTW, I think file system labels are a much better way of identifying FSs.
Perhaps this discussion is irrelevant... people who are using
OSLoadPartition to control their bootloader should just add a root=
option.
Cheers,
Andrew
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] cmdline.c rewrite
2003-02-05 0:19 ` Andrew Clausen
@ 2003-02-06 16:53 ` Ralf Baechle
2003-02-07 0:24 ` Andrew Clausen
0 siblings, 1 reply; 11+ messages in thread
From: Ralf Baechle @ 2003-02-06 16:53 UTC (permalink / raw)
To: Andrew Clausen; +Cc: Guido Guenther, linux-mips
On Wed, Feb 05, 2003 at 11:19:11AM +1100, Andrew Clausen wrote:
> On Wed, Feb 05, 2003 at 01:07:35AM +0100, Guido Guenther wrote:
> > On IP22 the PROM uses SystemPartition to find the kernel/bootloader.
> > We set it to something like scsi(0)disk(1)rdisk(0)partition(8) to grab
> > it from the vh. Is SystemPartition used differently on IP27?
>
> I think SystemPartition is ignored (haven't been able to see any
> evidence to the contrary... I should look in the source...)
SystemPartition is to be used by the bootloader, that is sash in SGI's case.
So when booting a kernel directly from the volume header from the firmware's
point of view SystemPartition's value is irrelevant. Afair it's used for
all non-absolute filenames where absolute ARC filenames are starting with
a device specificer like scsi(0)disk(1)partition(1), not just a slash to
indicate search from the fs root.
> > [..snip..]
> > > So, we should obviously support OSLoadPartition=/dev/sda1 (=> root=/dev/sda1),
> > > but it would also be nice to support OSLoadPartition=dksc(0,1,3).
> > Well we could either check if OSLoadPartition matches the linux device
> > naming scheme or the other way around and see if it looks like a valid
> > device identifier used by the PROM (I'd prefer the later, though) - or
> > simply make the OSLoadPartition <-> root= mapping '#ifdef CONFIG_SGI_IP22'.
>
> I think the middle option (the one you prefer) of matching dksc(0,1,3)
> and converting it /dev/sda2 is best. Just, it has to happen after the
> hard disks are probed - /dev/sdXY are allocated dynamically (in
> a predictable-for-end-user way), so you need to find out what it was
> allocated to. Is this doable in a nice way?
Checkout ROOT_DEV and it's use in init/main.c. Options such as root=...
are parsed very early during bootup. After that is done you could check
if the value of ROOT_DEV is still 0 that is no root=... was passed and
fallback to a value derived from SystemPartition at some later stage.
Feel free to read the devfs code for additional transpiration ;)
> BTW, I think file system labels are a much better way of identifying FSs.
ARC dates back more than 10 years back. It was written with PC partitions
and NT as OS in mind. So don't expect fancy concepts or sanity ;-)
> Perhaps this discussion is irrelevant... people who are using
> OSLoadPartition to control their bootloader should just add a root=
> option.
The ARC code is also used by non-SGI systems and on some of those using a
non-standard variables is a bit of a pita.
SystemPartition The default path for the system partition.
OSLoader The default path for an operating-system loader program.
OSLoadPartition The default pathname of the partition containing the
program to be loaded by the operating-system loader.
OSLoadFilename The default filename of the program the operating
system loader is to load.
Btw, device names like dksc(0,1,2) came from SGI's / MIPS's pre-ARC firmware
so are deprecated since 10 years. Some things just don't want to die.
Ralf
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] cmdline.c rewrite
2003-02-06 16:53 ` Ralf Baechle
@ 2003-02-07 0:24 ` Andrew Clausen
0 siblings, 0 replies; 11+ messages in thread
From: Andrew Clausen @ 2003-02-07 0:24 UTC (permalink / raw)
To: Ralf Baechle; +Cc: Andrew Clausen, Guido Guenther, linux-mips
On Thu, Feb 06, 2003 at 05:53:33PM +0100, Ralf Baechle wrote:
> > I think SystemPartition is ignored (haven't been able to see any
> > evidence to the contrary... I should look in the source...)
>
> SystemPartition is to be used by the bootloader, that is sash in SGI's case.
AFAICT, sash ignores SystemPartition here.
> > BTW, I think file system labels are a much better way of identifying FSs.
>
> ARC dates back more than 10 years back. It was written with PC partitions
> and NT as OS in mind. So don't expect fancy concepts or sanity ;-)
I'm talking about linux. Linux should default to "root=rootfs", or
something. If linux installers set labels, that is.
> The ARC code is also used by non-SGI systems and on some of those using a
> non-standard variables is a bit of a pita.
>
> SystemPartition The default path for the system partition.
What's the "system partition"? I think this is an Irix thing,
but I don't have any evidence.
> Btw, device names like dksc(0,1,2) came from SGI's / MIPS's pre-ARC firmware
> so are deprecated since 10 years. Some things just don't want to die.
It requires a lot less typing ;)
Cheers,
Andrew
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2003-02-07 0:25 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-04 6:13 [patch] cmdline.c rewrite Andrew Clausen
2003-02-04 9:24 ` Guido Guenther
2003-02-04 22:39 ` Andrew Clausen
2003-02-04 23:12 ` Guido Guenther
2003-02-04 23:19 ` Andrew Clausen
2003-02-04 23:45 ` Guido Guenther
2003-02-04 23:55 ` Andrew Clausen
2003-02-05 0:07 ` Guido Guenther
2003-02-05 0:19 ` Andrew Clausen
2003-02-06 16:53 ` Ralf Baechle
2003-02-07 0:24 ` Andrew Clausen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox