Devicetree
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cc: Dirk Brandewie
	<dirk.j.brandewie-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Subject: Re: [PATCH] dtc: Add command line option to force size alignment of blob.
Date: Sat, 13 Nov 2010 23:24:28 -0700	[thread overview]
Message-ID: <20101114062428.GE2355@angua.secretlab.ca> (raw)
In-Reply-To: <1289584920-4703-1-git-send-email-dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On Fri, Nov 12, 2010 at 10:02:00AM -0800, dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
> From: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> 
> This patch adds a command line argument to allow the user to request
> the that the blob be padded out to modulo <bytes> size.
> 
> Signed-off-by: Dirk Brandewie <dirk.j.brandewie-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

As commented elsewhere; this option isn't needed.  The kernel should
handle its own alignment requirements.  Nack.

g.

> ---
>  Documentation/manual.txt |    3 +++
>  dtc.c                    |   10 ++++++++--
>  flattree.c               |   20 +++++++++++++++++++-
>  3 files changed, 30 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/manual.txt b/Documentation/manual.txt
> index f8a8a7b..c899396 100644
> --- a/Documentation/manual.txt
> +++ b/Documentation/manual.txt
> @@ -117,6 +117,9 @@ Options:
>  	Ensure the blob at least <bytes> long, adding additional
>  	space if needed.
>  
> +    -a <bytes>
> +        Ensure the blob is modulo <bytes> in length.
> + 
>      -v
>  	Print DTC version and exit.
>  
> diff --git a/dtc.c b/dtc.c
> index 8b31d20..4e1abd4 100644
> --- a/dtc.c
> +++ b/dtc.c
> @@ -77,6 +77,8 @@ static void  __attribute__ ((noreturn)) usage(void)
>  	fprintf(stderr, "\t\tMake the blob at least <bytes> long (extra space)\n");
>  	fprintf(stderr, "\t-p <bytes>\n");
>  	fprintf(stderr, "\t\tAdd padding to the blob of <bytes> long (extra space)\n");
> +	fprintf(stderr, "\t-a <bytes>\n");
> +	fprintf(stderr, "\t\t Add padding make the blob modulo <bytes> in size\n");
>  	fprintf(stderr, "\t-b <number>\n");
>  	fprintf(stderr, "\t\tSet the physical boot cpu\n");
>  	fprintf(stderr, "\t-f\n");
> @@ -108,8 +110,9 @@ int main(int argc, char *argv[])
>  	reservenum = 0;
>  	minsize    = 0;
>  	padsize    = 0;
> -
> -	while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:vH:")) != EOF) {
> +	align_size = 0;
> +	
> +	while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:a:fcqb:vH:")) != EOF) {
>  		switch (opt) {
>  		case 'I':
>  			inform = optarg;
> @@ -132,6 +135,9 @@ int main(int argc, char *argv[])
>  		case 'p':
>  			padsize = strtol(optarg, NULL, 0);
>  			break;
> +		case 'a':
> +			alignsize = strtol(optarg, NULL, 0);
> +			break;
>  		case 'f':
>  			force = 1;
>  			break;
> diff --git a/flattree.c b/flattree.c
> index ead0332..e908609 100644
> --- a/flattree.c
> +++ b/flattree.c
> @@ -373,7 +373,8 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version)
>  	struct data strbuf     = empty_data;
>  	struct fdt_header fdt;
>  	int padlen = 0;
> -
> +	int align_len = 0;
> +	
>  	for (i = 0; i < ARRAY_SIZE(version_table); i++) {
>  		if (version_table[i].version == version)
>  			vi = &version_table[i];
> @@ -411,6 +412,20 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version)
>  	}
>  
>  	/*
> +	 * If the user asked for alignment of the end of the blob,
> +	 * adjust the totalsize. 
> +	 */
> +
> +	if (align_size > 0)
> +		align_len = align_size;
> +
> +	if (align_len > 0) {
> +		int tsize = fdt32_to_cpu(fdt.totalsize);
> +		tsize += alignlen;
> +		fdt.totalsize = cpu_to_fdt32(tsize);
> +	}
> +
> +	/*
>  	 * Assemble the blob: start with the header, add with alignment
>  	 * the reserve buffer, add the reserve map terminating zeroes,
>  	 * the device tree itself, and finally the strings.
> @@ -427,6 +442,9 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version)
>  	 */
>  	if (padlen > 0)
>  		blob = data_append_zeroes(blob, padlen);
> +	
> +	if (align_len > 0)
> +		blob = data_append_align(blob, align_len);
>  
>  	if (fwrite(blob.val, blob.len, 1, f) != 1) {
>  		if (ferror(f))
> -- 
> 1.7.2.3
> 
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss

      parent reply	other threads:[~2010-11-14  6:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-12 18:02 [PATCH] dtc: Add command line option to force size alignment of blob dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
     [not found] ` <1289584920-4703-1-git-send-email-dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-11-14  0:36   ` David Gibson
2010-11-14  6:24   ` Grant Likely [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=20101114062428.GE2355@angua.secretlab.ca \
    --to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=dirk.j.brandewie-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /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