public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Russell King <rmk+lkml@arm.linux.org.uk>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: linux-kernel@vger.kernel.org, Richard Henderson <rth@twiddle.net>,
	Haavard Skinnemoen <hskinnemoen@atmel.com>,
	Bryan Wu <cooloney@kernel.org>, Mikael Starvik <starvik@axis.com>,
	David Howells <dhowells@redhat.com>,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Tony Luck <tony.luck@intel.com>,
	Hirokazu Takata <takata@linux-m32r.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Greg Ungerer <gerg@uclinux.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Grant Grundler <grundler@parisc-linux.org>,
	Paul Mackerras <paulus@samba.org>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Paul Mundt <lethal@linux-sh.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jeff Dike <jdike@addtoit.com>, Ingo Molnar <mingo@redhat.com>,
	Chris Zankel <chris@zankel.net>
Subject: Re: [RFC 5/8] param: arch_get_boot_command_line()
Date: Mon, 1 Dec 2008 13:18:07 +0000	[thread overview]
Message-ID: <20081201131807.GD28971@flint.arm.linux.org.uk> (raw)
In-Reply-To: <200812012326.03151.rusty@rustcorp.com.au>

On Mon, Dec 01, 2008 at 11:26:01PM +1030, Rusty Russell wrote:
> diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
> --- a/arch/arm/kernel/setup.c
> +++ b/arch/arm/kernel/setup.c
> @@ -414,9 +414,11 @@ __early_param("mem=", early_mem);
>  
>  /*
>   * Initial parsing of the command line.
> + * FIXME: Use generic early_param / core_param code here.
>   */
> -static void __init parse_cmdline(char **cmdline_p, char *from)
> +static void __init parse_cmdline(void)
>  {
> +	const char *from = boot_command_line;
>  	char c = ' ', *to = command_line;
>  	int len = 0;
>  
> @@ -448,7 +450,6 @@ static void __init parse_cmdline(char **
>  		*to++ = c;
>  	}
>  	*to = '\0';
> -	*cmdline_p = command_line;
>  }
>  
>  static void __init
> @@ -673,11 +674,24 @@ static int __init customize_machine(void
>  }
>  arch_initcall(customize_machine);
>  
> -void __init setup_arch(char **cmdline_p)
> +void arch_get_boot_command_line(void)
> +{
> +	struct machine_desc *mdesc;
> +	const char *from;
> +
> +	mdesc = setup_machine(machine_arch_type);
> +	if (mdesc->cmdline)
> +		from = mdesc->cmdline();
> +	else
> +		from = default_command_line;
> +
> +	strlcpy(boot_command_line, from, COMMAND_LINE_SIZE);

This is only half the story I'm afraid.  It doesn't take account of the
fact that the command line can be passed from the boot loader via the
ATAG structures, which are only parsed after the machine specific
fixup has happened (which can also modify the ATAGs).

You're also not guaranteed to have an ATAG list before setup_arch() is
called - it might be a param_struct, and we convert that to an ATAG list
before ATAG parsing.

So there's quite a bit which needs to be done to get at the command line.
Basically, what's required is:

- convert param struct to tag list
- if no tag list, use default tag list
- run machine specific fixups which may set memory layout
- if memory layout has been set, kill off any memory atags to prevent it
  being overwritten
- parse all atags which includes setting the command line if such a tag
  is found

Then, and only then can you be sure that you have the right command line.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:

  reply	other threads:[~2008-12-01 13:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-01 12:56 [RFC 5/8] param: arch_get_boot_command_line() Rusty Russell
2008-12-01 13:18 ` Russell King [this message]
2008-12-02  2:13   ` Rusty Russell
2008-12-02  9:23     ` Haavard Skinnemoen
2008-12-03  2:30       ` Rusty Russell
2008-12-02 17:44     ` Russell King
2008-12-03  0:41       ` Rusty Russell
2008-12-03  0:54 ` Greg Ungerer
2008-12-03  2:38   ` Rusty Russell
2008-12-03  3:20 ` [RFC 5/8] param: arch_get_boot_command_line() (take II) Rusty Russell
2008-12-03 13:18   ` David Howells
2008-12-03 22:32     ` Rusty Russell
2008-12-03 18:37   ` Luck, Tony
2008-12-03 18:37     ` Luck, Tony
2008-12-04  0:58       ` Rusty Russell
2008-12-06 20:42         ` Russell King
2008-12-07  8:44           ` Rusty Russell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081201131807.GD28971@flint.arm.linux.org.uk \
    --to=rmk+lkml@arm.linux.org.uk \
    --cc=chris@zankel.net \
    --cc=cooloney@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=geert@linux-m68k.org \
    --cc=gerg@uclinux.org \
    --cc=grundler@parisc-linux.org \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hskinnemoen@atmel.com \
    --cc=jdike@addtoit.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.org \
    --cc=ralf@linux-mips.org \
    --cc=rth@twiddle.net \
    --cc=rusty@rustcorp.com.au \
    --cc=starvik@axis.com \
    --cc=takata@linux-m32r.org \
    --cc=tony.luck@intel.com \
    --cc=ysato@users.sourceforge.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox