public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Gregory CLEMENT <gregory.clement@bootlin.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 7/7] MIPS: bootm: Add support for Vcore III linux kernel
Date: Fri, 30 Nov 2018 15:16:57 +0100	[thread overview]
Message-ID: <87wooumyzq.fsf@bootlin.com> (raw)
In-Reply-To: <4f5db2bd-fb75-d500-1b20-1a65dbe03eaa@gmail.com> (Daniel Schwierzeck's message of "Sun, 28 Oct 2018 18:54:02 +0100")

Hi Daniel,
 
 On dim., oct. 28 2018, Daniel Schwierzeck <daniel.schwierzeck@gmail.com> wrote:

> Hi Gregory,
>
> sorry for the late response.
>
> Am 09.10.18 um 13:58 schrieb Gregory CLEMENT:
>> The kernels built for the Vcore III linux kernel have different
>> expectation in the way the data were passed.
>> 
>> Unlike with yamon, the command line is expected to be a single string
>> passed in argv[1]. An other expectation is that the arguments are located
>> in the cached address space.
>
> I'm still not convinced whether this patch is necessary. As far as I
> understand, you can boot a mainline kernel with the device-tree blob way
> or with the legacy way. The latter makes sense when booting a mainline
> kernel with Redboot. But what's the use case for booting a mainline
> kernel in mainline U-Boot in the legacy way? Do you still want to boot
> out-of-tree legacy kernels with mainline U-Boot?

Currently there is only redboot which is used , but there is already
mainline kernel in legacy format. The purpose of it, is to be able to
switch from reboot to u-Boot but still being able to boot the mainline
kernel currently used.

As a bonus it could also allow to boot old out of tree kernel, but I
don't think it is something planed.

>
> Apart from this is this single cmdline string specific to Redboot or
> only to Microsemi? The former would be acceptable for a generic patch to

Actually I don't know.

> emulate a Redboot interface (similar to the YAMON one). But this should
> be configurable for the user via Kconfig. You could enable this by
> default with an "imply MIPS_BOOT_CMDLINE_REDBOOT" in your SoC/board
> specific Kconfig part.
>
>> 
>> However, like yamon, they expect that rd_start and rd_size was passed by
>> the bootloader in the command line of the kernel, and besides that it
>> also wait for the root=/dev/ram0.
>
> Who exactly needs "root=/dev/ram0"? Normally the generic MIPS setup code
> only needs "rd_start" and "rd_size" from cmdline respectively
> "linux,initrd-start" and "linux,initrd-end" from the device-tree blob.

If it is a problem I think that we can use a U-boot script to take care
of this value.

Gregory

>
>> 
>> Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
>> ---
>>  arch/mips/lib/bootm.c | 77 ++++++++++++++++++++++++++++++++-----------
>>  1 file changed, 57 insertions(+), 20 deletions(-)
>> 
>> diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
>> index deca5189e3..803d5e1de3 100644
>> --- a/arch/mips/lib/bootm.c
>> +++ b/arch/mips/lib/bootm.c
>> @@ -15,6 +15,11 @@ DECLARE_GLOBAL_DATA_PTR;
>>  #define	LINUX_MAX_ENVS		256
>>  #define	LINUX_MAX_ARGS		256
>>  
>> +enum legacy_boot_type {
>> +	LEGACY_BOOT_YAML,
>> +	LEGACY_BOOT_VCORE,
>> +};
>> +
>>  static int linux_argc;
>>  static char **linux_argv;
>>  static char *linux_argp;
>> @@ -44,22 +49,46 @@ void arch_lmb_reserve(struct lmb *lmb)
>>  	lmb_reserve(lmb, sp, gd->ram_top - sp);
>>  }
>>  
>> -static void linux_cmdline_init(void)
>> +static void linux_cmdline_init(enum legacy_boot_type boot_type)
>>  {
>> +	switch (boot_type) {
>> +		/*
>> +		 * Vcore III linux kernels expect arguments in the cached
>> +		 * address space. They also expect the command line being a
>> +		 * single string in the first argument
>> +		 */
>> +	case LEGACY_BOOT_VCORE:
>> +		linux_argv = (char **)(gd->bd->bi_boot_params);
>> +		linux_argp = (char *)(linux_argv + LINUX_MAX_ARGS);
>> +		linux_argv[1] = linux_argp;
>> +		break;
>> +	case LEGACY_BOOT_YAML:
>> +	/* fallthrough */
>> +	default:
>> +		linux_argv = (char **)UNCACHED_SDRAM(gd->bd->bi_boot_params);
>> +		linux_argp = (char *)(linux_argv + LINUX_MAX_ARGS);
>> +	}
>>  	linux_argc = 1;
>> -	linux_argv = (char **)UNCACHED_SDRAM(gd->bd->bi_boot_params);
>>  	linux_argv[0] = 0;
>> -	linux_argp = (char *)(linux_argv + LINUX_MAX_ARGS);
>>  }
>>  
>> -static void linux_cmdline_set(const char *value, size_t len)
>> +static void linux_cmdline_set(const char *value, size_t len,
>> +			      enum legacy_boot_type boot_type)
>>  {
>> -	linux_argv[linux_argc] = linux_argp;
>>  	memcpy(linux_argp, value, len);
>> -	linux_argp[len] = 0;
>> -
>> +	switch (boot_type) {
>> +	case LEGACY_BOOT_VCORE:
>> +		linux_argv[linux_argc] = linux_argp;
>> +		linux_argp[len] = 0;
>> +		linux_argc++;
>> +	case LEGACY_BOOT_YAML:
>> +		/* fallthrough */
>> +	default:
>> +		linux_argp[len] = ' ';
>> +		linux_argp[len + 1] = 0;
>> +		linux_argc = 2;
>> +	}
>>  	linux_argp += len + 1;
>> -	linux_argc++;
>>  }
>>  
>>  static void linux_cmdline_dump(void)
>> @@ -73,12 +102,11 @@ static void linux_cmdline_dump(void)
>>  		debug("   arg %03d: %s\n", i, linux_argv[i]);
>>  }
>>  
>> -static void linux_cmdline_legacy(bootm_headers_t *images)
>> +static void linux_cmdline_legacy(bootm_headers_t *images,
>> +				 enum legacy_boot_type boot_type)
>>  {
>>  	const char *bootargs, *next, *quote;
>> -
>> -	linux_cmdline_init();
>> -
>> +	linux_cmdline_init(boot_type);
>>  	bootargs = env_get("bootargs");
>>  	if (!bootargs)
>>  		return;
>> @@ -104,7 +132,7 @@ static void linux_cmdline_legacy(bootm_headers_t *images)
>>  		if (!next)
>>  			next = bootargs + strlen(bootargs);
>>  
>> -		linux_cmdline_set(bootargs, next - bootargs);
>> +		linux_cmdline_set(bootargs, next - bootargs, boot_type);
>>  
>>  		if (*next)
>>  			next++;
>> @@ -113,7 +141,8 @@ static void linux_cmdline_legacy(bootm_headers_t *images)
>>  	}
>>  }
>>  
>> -static void linux_cmdline_append(bootm_headers_t *images)
>> +static void linux_cmdline_append(bootm_headers_t *images,
>> +				 enum legacy_boot_type boot_type)
>>  {
>>  	char buf[24];
>>  	ulong mem, rd_start, rd_size;
>> @@ -121,7 +150,7 @@ static void linux_cmdline_append(bootm_headers_t *images)
>>  	/* append mem */
>>  	mem = gd->ram_size >> 20;
>>  	sprintf(buf, "mem=%luM", mem);
>> -	linux_cmdline_set(buf, strlen(buf));
>> +	linux_cmdline_set(buf, strlen(buf), boot_type);
>>  
>>  	/* append rd_start and rd_size */
>>  	rd_start = images->initrd_start;
>> @@ -129,9 +158,13 @@ static void linux_cmdline_append(bootm_headers_t *images)
>>  
>>  	if (rd_size) {
>>  		sprintf(buf, "rd_start=0x%08lX", rd_start);
>> -		linux_cmdline_set(buf, strlen(buf));
>> +		linux_cmdline_set(buf, strlen(buf), boot_type);
>>  		sprintf(buf, "rd_size=0x%lX", rd_size);
>> -		linux_cmdline_set(buf, strlen(buf));
>> +		linux_cmdline_set(buf, strlen(buf), boot_type);
>> +		if (boot_type ==  LEGACY_BOOT_VCORE) {
>> +			sprintf(buf, "root=/dev/ram0");
>> +			linux_cmdline_set(buf, strlen(buf), boot_type);
>> +		}
>>  	}
>>  }
>>  
>> @@ -276,11 +309,15 @@ static void boot_prep_linux(bootm_headers_t *images)
>>  		boot_reloc_fdt(images);
>>  		boot_setup_fdt(images);
>>  	} else {
>> -		if (CONFIG_IS_ENABLED(MIPS_BOOT_CMDLINE_LEGACY)) {
>> -			linux_cmdline_legacy(images);
>> +		if (CONFIG_IS_ENABLED(SOC_VCOREIII)) {
>> +			linux_cmdline_legacy(images, LEGACY_BOOT_VCORE);
>> +			linux_cmdline_append(images, LEGACY_BOOT_VCORE);
>> +			linux_cmdline_dump();
>> +		} else if (CONFIG_IS_ENABLED(MIPS_BOOT_CMDLINE_LEGACY)) {
>> +			linux_cmdline_legacy(images, 0);
>>  
>>  			if (!CONFIG_IS_ENABLED(MIPS_BOOT_ENV_LEGACY))
>> -				linux_cmdline_append(images);
>> +				linux_cmdline_append(images, LEGACY_BOOT_YAML);
>>  
>>  			linux_cmdline_dump();
>>  		}
>> 
>
> -- 
> - Daniel
>

-- 
Gregory Clement, Bootlin
Embedded Linux and Kernel engineering
http://bootlin.com

      reply	other threads:[~2018-11-30 14:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-09 11:58 [U-Boot] [PATCH v2 0/7] Add support for the SoCs found in Microsemi switches Gregory CLEMENT
2018-10-09 11:58 ` [U-Boot] [PATCH v2 1/7] MIPS: move create_tlb() in an proper header: mipsregs.h Gregory CLEMENT
2018-10-09 11:58 ` [U-Boot] [PATCH v2 2/7] MIPS: Allow to prefetch and lock instructions into cache Gregory CLEMENT
2018-10-09 11:58 ` [U-Boot] [PATCH v2 3/7] MSCC: add support for Ocelot SoCs Gregory CLEMENT
2018-10-28 18:50   ` Daniel Schwierzeck
2018-11-30 14:48     ` Gregory CLEMENT
2018-10-09 11:58 ` [U-Boot] [PATCH v2 4/7] MSCC: add support for Luton SoCs Gregory CLEMENT
2018-10-09 11:58 ` [U-Boot] [PATCH v2 5/7] MSCC: add board support for the Ocelots based evaluation boards Gregory CLEMENT
2018-10-09 11:58 ` [U-Boot] [PATCH v2 6/7] MSCC: add board support for the Luton based evaluation board Gregory CLEMENT
2018-10-09 11:58 ` [U-Boot] [PATCH v2 7/7] MIPS: bootm: Add support for Vcore III linux kernel Gregory CLEMENT
2018-10-28 17:54   ` Daniel Schwierzeck
2018-11-30 14:16     ` Gregory CLEMENT [this message]

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=87wooumyzq.fsf@bootlin.com \
    --to=gregory.clement@bootlin.com \
    --cc=u-boot@lists.denx.de \
    /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