devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Nicolas Pitre <nicolas.pitre@linaro.org>
Cc: John Bonesio <bones@secretlab.ca>,
	Tony Lindgren <tony@atomide.com>,
	devicetree-discuss@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/3] ARM: zImage: Allow the appending of a device tree binary
Date: Sun, 12 Jun 2011 09:01:17 -0600	[thread overview]
Message-ID: <20110612150117.GB4013@ponder.secretlab.ca> (raw)
In-Reply-To: <1307858800-16712-3-git-send-email-nicolas.pitre@linaro.org>

On Sun, Jun 12, 2011 at 02:06:39AM -0400, Nicolas Pitre wrote:
> From: John Bonesio <bones@secretlab.ca>
> 
> This patch provides the ability to boot using a device tree that is appended
> to the raw binary zImage (e.g. cat zImage <filename>.dtb > zImage_w_dtb).
> 
> Signed-off-by: John Bonesio <bones@secretlab.ca>
> [nico: adjusted to latest zImage changes plus additional cleanups]
> Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>

Acked-by: Grant Likely <grant.likely@secretlab.ca>

> ---
>  arch/arm/Kconfig                |    8 ++++
>  arch/arm/boot/compressed/head.S |   70 +++++++++++++++++++++++++++++++++++++--
>  2 files changed, 75 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 9adc278..66b7d1e 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1727,6 +1727,14 @@ config ZBOOT_ROM_MMCIF
>  	  which in turn loads the rest the kernel image to RAM using the
>  	  MMCIF hardware block.
>  
> +config ARM_APPENDED_DTB
> +	bool "Use appended device tree blob to zImage"
> +	depends on OF && !ZBOOT_ROM
> +	help
> +	  With this option, the boot code will look for a device tree binary
> +	  (dtb) appended to zImage
> +	  (e.g. cat zImage <filename>.dtb > zImage_w_dtb).
> +
>  config CMDLINE
>  	string "Default kernel command string"
>  	default ""
> diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
> index f9da419..4bc009c 100644
> --- a/arch/arm/boot/compressed/head.S
> +++ b/arch/arm/boot/compressed/head.S
> @@ -216,6 +216,59 @@ restart:	adr	r0, LC0
>  		mov	r10, r6
>  #endif
>  
> +		mov	r5, #0			@ init dtb size to 0
> +#ifdef CONFIG_ARM_APPENDED_DTB
> +/*
> + *   r0  = delta
> + *   r2  = BSS start
> + *   r3  = BSS end
> + *   r4  = final kernel address
> + *   r5  = appended dtb size (still unknown)
> + *   r6  = _edata
> + *   r7  = architecture ID
> + *   r8  = atags/device tree pointer
> + *   r9  = size of decompressed image
> + *   r10 = end of this image, including  bss/stack/malloc space if non XIP
> + *   r11 = GOT start
> + *   r12 = GOT end
> + *   sp  = stack pointer
> + *
> + * if there are device trees (dtb) appended to zImage, advance r10 so that the
> + * dtb data will get relocated along with the kernel if necessary.
> + */
> +
> +		ldr	lr, [r6, #0]
> +#ifndef __ARMEB__
> +		ldr	r1, =0xedfe0dd0		@ sig is 0xd00dfeed big endian
> +#else
> +		ldr	r1, =0xd00dfeed
> +#endif
> +		cmp	lr, r1
> +		bne	dtb_check_done		@ not found
> +
> +		mov	r8, r6			@ use the appended device tree
> +
> +		/* Get the dtb's size */
> +		ldr	r5, [r6, #4]
> +#ifndef __ARMEB__
> +		/* convert lr (dtb size) to little endian */
> +		eor	r1, r5, r5, ror #16
> +		bic	r1, r1, #0x00ff0000
> +		mov	r5, r5, ror #8
> +		eor	r5, r5, r1, lsr #8
> +#endif
> +
> +		/* preserve 64-bit alignment */
> +		add	r5, r5, #7
> +		bic	r5, r5, #7
> +
> +		/* relocate some pointers past the appended dtb */
> +		add	r6, r6, r5
> +		add	r10, r10, r5
> +		add	sp, sp, r5
> +dtb_check_done:
> +#endif
> +
>  /*
>   * Check to see if we will overwrite ourselves.
>   *   r4  = final kernel address
> @@ -285,14 +338,16 @@ wont_overwrite:
>   *   r2  = BSS start
>   *   r3  = BSS end
>   *   r4  = kernel execution address
> + *   r5  = appended dtb size (0 if not present)
>   *   r7  = architecture ID
>   *   r8  = atags pointer
>   *   r11 = GOT start
>   *   r12 = GOT end
>   *   sp  = stack pointer
>   */
> -		teq	r0, #0
> +		orrs	r1, r0, r5
>  		beq	not_relocated
> +
>  		add	r11, r11, r0
>  		add	r12, r12, r0
>  
> @@ -307,12 +362,21 @@ wont_overwrite:
>  
>  		/*
>  		 * Relocate all entries in the GOT table.
> +		 * Bump bss entries to _edata + dtb size
>  		 */
>  1:		ldr	r1, [r11, #0]		@ relocate entries in the GOT
> -		add	r1, r1, r0		@ table.  This fixes up the
> -		str	r1, [r11], #4		@ C references.
> +		add	r1, r1, r0		@ This fixes up C references
> +		cmp	r1, r2			@ if entry >= bss_start &&
> +		cmphs	r3, r1			@       bss_end > entry
> +		addhi	r1, r1, r5		@    entry += dtb size
> +		str	r1, [r11], #4		@ next entry
>  		cmp	r11, r12
>  		blo	1b
> +
> +		/* bump our bss pointers too */
> +		add	r2, r2, r5
> +		add	r3, r3, r5
> +
>  #else
>  
>  		/*
> -- 
> 1.7.4
> 

  reply	other threads:[~2011-06-12 15:01 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-12  6:06 [PATCH 0/3] patches to allow DTB to be appended to the ARM zImage Nicolas Pitre
2011-06-12  6:06 ` [PATCH 1/3] ARM: zImage: ensure it is always a multiple of 64 bits in size Nicolas Pitre
2011-06-13 10:43   ` Tony Lindgren
     [not found]   ` <1307858800-16712-2-git-send-email-nicolas.pitre-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2011-06-13 11:24     ` Russell King - ARM Linux
     [not found]       ` <20110613112454.GA12325-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2011-06-13 14:06         ` Nicolas Pitre
2011-06-12  6:06 ` [PATCH 2/3] ARM: zImage: Allow the appending of a device tree binary Nicolas Pitre
2011-06-12 15:01   ` Grant Likely [this message]
2011-06-13 10:46   ` Tony Lindgren
     [not found]     ` <20110613104648.GD10951-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2011-06-13 11:26       ` Russell King - ARM Linux
     [not found]         ` <20110613112604.GB12325-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2011-06-13 14:08           ` Nicolas Pitre
2011-06-12  6:06 ` [PATCH 3/3] ARM: zImage: make sure appended DTB doesn't get overwritten by kernel .bss Nicolas Pitre
2011-06-13 10:47   ` Tony Lindgren
2011-06-12  8:15 ` [PATCH 0/3] patches to allow DTB to be appended to the ARM zImage Russell King - ARM Linux
     [not found]   ` <20110612081541.GA10283-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2011-06-12  8:34     ` Shawn Guo
     [not found]       ` <20110612083414.GA29516-+NayF8gZjK2ctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2011-06-12  9:21         ` Russell King - ARM Linux
     [not found]           ` <20110612092131.GC10283-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2011-06-12  9:38             ` Shawn Guo
     [not found]               ` <20110612093822.GB29516-+NayF8gZjK2ctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2011-06-12  9:52                 ` Russell King - ARM Linux
     [not found]                   ` <20110612095217.GD10283-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2011-06-12 10:42                     ` Shawn Guo
     [not found]                       ` <20110612104215.GC29516-+NayF8gZjK2ctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2011-06-12 10:40                         ` Russell King - ARM Linux
2011-06-13 20:19                           ` Dmitry Eremin-Solenikov
2011-06-13 23:04                           ` David Brown
     [not found]                             ` <8yaaadlfi3q.fsf-AOX6H5vLt3Uj8izMo0bVsAC/G2K4zDHf@public.gmane.org>
2011-06-13 23:13                               ` Nicolas Pitre
     [not found]                                 ` <alpine.LFD.2.00.1106131910570.2142-QuJgVwGFrdf/9pzu0YdTqQ@public.gmane.org>
2011-06-14  7:09                                   ` Nicolas Pitre
2011-06-14 14:53                                     ` Tony Lindgren
     [not found]                                       ` <20110614145329.GK23145-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2011-06-14 17:28                                         ` Nicolas Pitre
2011-06-14 20:32                                           ` Arnd Bergmann
2011-06-14 21:21                                             ` Nicolas Pitre
     [not found]                                               ` <alpine.LFD.2.00.1106141650520.2142-QuJgVwGFrdf/9pzu0YdTqQ@public.gmane.org>
2011-06-14 21:42                                                 ` Arnd Bergmann
     [not found]                                                   ` <201106142342.29405.arnd-r2nGTMty4D4@public.gmane.org>
2011-06-14 22:06                                                     ` Grant Likely
2011-06-15  8:08                                                       ` Tony Lindgren
     [not found]                                             ` <201106142232.02217.arnd-r2nGTMty4D4@public.gmane.org>
2011-06-14 22:32                                               ` Rob Herring
     [not found]                                                 ` <4DF7E191.1050705-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-06-14 23:50                                                   ` Nicolas Pitre
     [not found]                                                     ` <alpine.LFD.2.00.1106141948060.2142-QuJgVwGFrdf/9pzu0YdTqQ@public.gmane.org>
2011-06-15  2:09                                                       ` Rob Herring
2011-06-15  2:21                                                         ` Nicolas Pitre
     [not found]                                     ` <alpine.LFD.2.00.1106140300500.2142-QuJgVwGFrdf/9pzu0YdTqQ@public.gmane.org>
2011-06-14 11:25                                       ` Shawn Guo
2011-06-14 21:38                                       ` David Brown
2011-06-14 23:27                                     ` [PATCH] Support multiple MEM tags with atags->fdt conversion David Brown
2011-06-15 19:50                                       ` Nicolas Pitre
2011-06-15 20:15                                         ` David Brown
2011-06-15 20:20                                           ` Nicolas Pitre
2011-06-16  1:43                                         ` David Gibson
2011-06-20  4:03                                           ` Nicolas Pitre
2011-06-20  4:53                                             ` David Gibson
2011-06-17 20:23                                         ` David Brown
2011-06-12 11:22       ` [PATCH 0/3] patches to allow DTB to be appended to the ARM zImage Petr Štetiar
     [not found]         ` <20110612112219.GD16318-iAOvNCVgjNNH4x6Dk/4f9A@public.gmane.org>
2011-06-12 11:58           ` Russell King - ARM Linux
2011-06-12 14:15             ` Arnd Bergmann
     [not found]               ` <201106121615.24059.arnd-r2nGTMty4D4@public.gmane.org>
2011-06-12 14:34                 ` Russell King - ARM Linux
     [not found]                   ` <20110612143428.GI10283-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2011-06-12 15:01                     ` Arnd Bergmann
     [not found]                       ` <201106121701.22418.arnd-r2nGTMty4D4@public.gmane.org>
2011-06-12 15:35                         ` Russell King - ARM Linux
     [not found]                           ` <20110612153536.GL10283-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2011-06-12 15:45                             ` Nicolas Pitre
2011-06-12 14:57                 ` Grant Likely
     [not found]                   ` <20110612145751.GA4013-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2011-06-12 15:19                     ` Russell King - ARM Linux
2011-06-12 15:47                       ` Nicolas Pitre
     [not found]                         ` <alpine.LFD.2.00.1106121145570.2142-QuJgVwGFrdf/9pzu0YdTqQ@public.gmane.org>
2011-06-12 15:59                           ` Russell King - ARM Linux
     [not found]                             ` <20110612155940.GM10283-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2011-06-12 18:59                               ` Nicolas Pitre
     [not found]                                 ` <alpine.LFD.2.00.1106121454510.2142-QuJgVwGFrdf/9pzu0YdTqQ@public.gmane.org>
2011-06-13  9:51                                   ` Tony Lindgren
     [not found]                                     ` <20110613095142.GA10951-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2011-06-13 14:14                                       ` Nicolas Pitre
     [not found]                                         ` <alpine.LFD.2.00.1106131010150.2142-QuJgVwGFrdf/9pzu0YdTqQ@public.gmane.org>
2011-06-13 14:20                                           ` Russell King - ARM Linux
     [not found]                                             ` <20110613142044.GC13643-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2011-06-13 15:02                                               ` Tony Lindgren
2011-06-13 15:14                                               ` Nicolas Pitre
2011-06-13 15:17                                                 ` Grant Likely
2011-06-12 19:26                               ` Warner Losh
2011-06-13  9:59                             ` Tony Lindgren
     [not found]             ` <20110612115820.GF10283-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2011-06-12 15:41               ` Nicolas Pitre
     [not found]                 ` <alpine.LFD.2.00.1106121051380.2142-QuJgVwGFrdf/9pzu0YdTqQ@public.gmane.org>
2011-06-14  0:13                   ` David Brown
2011-09-06 11:23                     ` Linus Walleij
2011-06-21  1:40           ` David Gibson
2011-06-13  4:31 ` Grant Likely
     [not found]   ` <BANLkTik_hH9tZ5MMbOYzhZwLFTFQyJyfRg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-06-13 20:44     ` Nicolas Pitre
2011-09-05 15:43       ` Tony Lindgren
2011-09-05 19:32         ` Nicolas Pitre

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=20110612150117.GB4013@ponder.secretlab.ca \
    --to=grant.likely@secretlab.ca \
    --cc=bones@secretlab.ca \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=nicolas.pitre@linaro.org \
    --cc=tony@atomide.com \
    /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;
as well as URLs for NNTP newsgroup(s).