All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Pantelis Antoniou
	<pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
Cc: Jon Loeliger <jdl-CYoMK+44s/E@public.gmane.org>,
	Grant Likely
	<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Frank Rowand
	<frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Jan Luebbe <jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	Matt Porter <mporter-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v7 2/5] DTBO magic and dtbo format options
Date: Thu, 26 May 2016 10:11:48 +1000	[thread overview]
Message-ID: <20160526001148.GP17226@voom.fritz.box> (raw)
In-Reply-To: <1464112239-29856-3-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 9292 bytes --]

On Tue, May 24, 2016 at 08:50:36PM +0300, Pantelis Antoniou wrote:
> Introduce a new magic number for dynamic plugin objects,
> which is enabled by selecting dtbo/input output options.
> 
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>

Apart from one nit this is ready to go.

> ---
>  Documentation/manual.txt |  7 +++++++
>  dtc.c                    | 14 +++++++++++---
>  dtc.h                    |  4 ++--
>  fdtdump.c                |  2 +-
>  flattree.c               | 11 ++++++-----
>  libfdt/fdt.c             |  2 +-
>  libfdt/fdt.h             |  3 ++-
>  tests/mangle-layout.c    |  7 ++++---
>  8 files changed, 34 insertions(+), 16 deletions(-)
> 
> diff --git a/Documentation/manual.txt b/Documentation/manual.txt
> index 398de32..f64c4f4 100644
> --- a/Documentation/manual.txt
> +++ b/Documentation/manual.txt
> @@ -60,6 +60,9 @@ The currently supported Input Formats are:
>      - "dtb": "blob" format.  A flattened device-tree block with
>          header in one binary blob.
>  
> +    - "dtbo" : "blob" format. Identical with "dtb" but meant
> +        for use with dynamic-device tree objects.
> +
>      - "dts": "source" format.  A text file containing a "source"
>          for a device-tree.
>  
> @@ -71,6 +74,8 @@ The currently supported Output Formats are:
>  
>       - "dtb": "blob" format
>  
> +     - "dtbo": "blob" format - for objects
> +
>       - "dts": "source" format
>  
>       - "asm": assembly language file.  A file that can be sourced
> @@ -78,6 +83,8 @@ The currently supported Output Formats are:
>          then simply be added to your Makefile.  Additionally, the
>          assembly file exports some symbols that can be used.
>  
> +     - "asmo": assembly language file for objects. Identical to "asm"

Please spell out dynamic device-tree object/overlay here, just
"object" is too vague.

>  
>  3) Command Line
>  
> diff --git a/dtc.c b/dtc.c
> index 5fa23c4..63c2c9c 100644
> --- a/dtc.c
> +++ b/dtc.c
> @@ -117,6 +117,8 @@ static const char *guess_type_by_name(const char *fname, const char *fallback)
>  		return "dts";
>  	if (!strcasecmp(s, ".dtb"))
>  		return "dtb";
> +	if (!strcasecmp(s, ".dtbo"))
> +		return "dtbo";
>  	return fallback;
>  }
>  
> @@ -147,6 +149,8 @@ static const char *guess_input_format(const char *fname, const char *fallback)
>  	magic = fdt32_to_cpu(magic);
>  	if (magic == FDT_MAGIC)
>  		return "dtb";
> +	if (magic == FDT_MAGIC_DTBO)
> +		return "dtbo";
>  
>  	return guess_type_by_name(fname, fallback);
>  }
> @@ -275,7 +279,7 @@ int main(int argc, char *argv[])
>  		bi = dt_from_source(arg);
>  	else if (streq(inform, "fs"))
>  		bi = dt_from_fs(arg);
> -	else if(streq(inform, "dtb"))
> +	else if(streq(inform, "dtb") || streq(inform, "dtbo"))
>  		bi = dt_from_blob(arg);
>  	else
>  		die("Unknown input format \"%s\"\n", inform);
> @@ -306,9 +310,13 @@ int main(int argc, char *argv[])
>  	if (streq(outform, "dts")) {
>  		dt_to_source(outf, bi);
>  	} else if (streq(outform, "dtb")) {
> -		dt_to_blob(outf, bi, outversion);
> +		dt_to_blob(outf, bi, FDT_MAGIC, outversion);
> +	} else if (streq(outform, "dtbo")) {
> +		dt_to_blob(outf, bi, FDT_MAGIC_DTBO, outversion);
>  	} else if (streq(outform, "asm")) {
> -		dt_to_asm(outf, bi, outversion);
> +		dt_to_asm(outf, bi, FDT_MAGIC, outversion);
> +	} else if (streq(outform, "asmo")) {
> +		dt_to_asm(outf, bi, FDT_MAGIC_DTBO, outversion);
>  	} else if (streq(outform, "null")) {
>  		/* do nothing */
>  	} else {
> diff --git a/dtc.h b/dtc.h
> index 56212c8..9d7f2d6 100644
> --- a/dtc.h
> +++ b/dtc.h
> @@ -252,8 +252,8 @@ void process_checks(bool force, struct boot_info *bi);
>  
>  /* Flattened trees */
>  
> -void dt_to_blob(FILE *f, struct boot_info *bi, int version);
> -void dt_to_asm(FILE *f, struct boot_info *bi, int version);
> +void dt_to_blob(FILE *f, struct boot_info *bi, fdt32_t magic, int version);
> +void dt_to_asm(FILE *f, struct boot_info *bi, fdt32_t magic, int version);
>  
>  struct boot_info *dt_from_blob(const char *fname);
>  
> diff --git a/fdtdump.c b/fdtdump.c
> index 9183555..11c2b8d 100644
> --- a/fdtdump.c
> +++ b/fdtdump.c
> @@ -306,7 +306,7 @@ int main(int argc, char *argv[])
>  			p = memchr(p, smagic[0], endp - p - 4);
>  			if (!p)
>  				break;
> -			if (fdt_magic(p) == FDT_MAGIC) {
> +			if (fdt_magic(p) == FDT_MAGIC || fdt_magic(p) == FDT_MAGIC_DTBO) {
>  				/* try and validate the main struct */
>  				off_t this_len = endp - p;
>  				fdt32_t max_version = 17;
> diff --git a/flattree.c b/flattree.c
> index ec14954..64ed375 100644
> --- a/flattree.c
> +++ b/flattree.c
> @@ -335,6 +335,7 @@ static struct data flatten_reserve_list(struct reserve_info *reservelist,
>  }
>  
>  static void make_fdt_header(struct fdt_header *fdt,
> +			    fdt32_t magic,
>  			    struct version_info *vi,
>  			    int reservesize, int dtsize, int strsize,
>  			    int boot_cpuid_phys)
> @@ -345,7 +346,7 @@ static void make_fdt_header(struct fdt_header *fdt,
>  
>  	memset(fdt, 0xff, sizeof(*fdt));
>  
> -	fdt->magic = cpu_to_fdt32(FDT_MAGIC);
> +	fdt->magic = cpu_to_fdt32(magic);
>  	fdt->version = cpu_to_fdt32(vi->version);
>  	fdt->last_comp_version = cpu_to_fdt32(vi->last_comp_version);
>  
> @@ -366,7 +367,7 @@ static void make_fdt_header(struct fdt_header *fdt,
>  		fdt->size_dt_struct = cpu_to_fdt32(dtsize);
>  }
>  
> -void dt_to_blob(FILE *f, struct boot_info *bi, int version)
> +void dt_to_blob(FILE *f, struct boot_info *bi, fdt32_t magic, int version)
>  {
>  	struct version_info *vi = NULL;
>  	int i;
> @@ -390,7 +391,7 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version)
>  	reservebuf = flatten_reserve_list(bi->reservelist, vi);
>  
>  	/* Make header */
> -	make_fdt_header(&fdt, vi, reservebuf.len, dtbuf.len, strbuf.len,
> +	make_fdt_header(&fdt, magic, vi, reservebuf.len, dtbuf.len, strbuf.len,
>  			bi->boot_cpuid_phys);
>  
>  	/*
> @@ -460,7 +461,7 @@ static void dump_stringtable_asm(FILE *f, struct data strbuf)
>  	}
>  }
>  
> -void dt_to_asm(FILE *f, struct boot_info *bi, int version)
> +void dt_to_asm(FILE *f, struct boot_info *bi, fdt32_t magic, int version)
>  {
>  	struct version_info *vi = NULL;
>  	int i;
> @@ -832,7 +833,7 @@ struct boot_info *dt_from_blob(const char *fname)
>  	}
>  
>  	magic = fdt32_to_cpu(magic);
> -	if (magic != FDT_MAGIC)
> +	if (magic != FDT_MAGIC && magic != FDT_MAGIC_DTBO)
>  		die("Blob has incorrect magic number\n");
>  
>  	rc = fread(&totalsize, sizeof(totalsize), 1, f);
> diff --git a/libfdt/fdt.c b/libfdt/fdt.c
> index 22286a1..28d422c 100644
> --- a/libfdt/fdt.c
> +++ b/libfdt/fdt.c
> @@ -57,7 +57,7 @@
>  
>  int fdt_check_header(const void *fdt)
>  {
> -	if (fdt_magic(fdt) == FDT_MAGIC) {
> +	if (fdt_magic(fdt) == FDT_MAGIC || fdt_magic(fdt) == FDT_MAGIC_DTBO) {
>  		/* Complete tree */
>  		if (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION)
>  			return -FDT_ERR_BADVERSION;
> diff --git a/libfdt/fdt.h b/libfdt/fdt.h
> index 526aedb..493cd55 100644
> --- a/libfdt/fdt.h
> +++ b/libfdt/fdt.h
> @@ -55,7 +55,7 @@
>  #ifndef __ASSEMBLY__
>  
>  struct fdt_header {
> -	fdt32_t magic;			 /* magic word FDT_MAGIC */
> +	fdt32_t magic;			 /* magic word FDT_MAGIC[|_DTBO] */
>  	fdt32_t totalsize;		 /* total size of DT block */
>  	fdt32_t off_dt_struct;		 /* offset to structure */
>  	fdt32_t off_dt_strings;		 /* offset to strings */
> @@ -93,6 +93,7 @@ struct fdt_property {
>  #endif /* !__ASSEMBLY */
>  
>  #define FDT_MAGIC	0xd00dfeed	/* 4: version, 4: total size */
> +#define FDT_MAGIC_DTBO	0xd00dfdb0	/* DTBO magic */
>  #define FDT_TAGSIZE	sizeof(fdt32_t)
>  
>  #define FDT_BEGIN_NODE	0x1		/* Start node: full name */
> diff --git a/tests/mangle-layout.c b/tests/mangle-layout.c
> index a76e51e..d29ebc6 100644
> --- a/tests/mangle-layout.c
> +++ b/tests/mangle-layout.c
> @@ -42,7 +42,8 @@ static void expand_buf(struct bufstate *buf, int newsize)
>  	buf->size = newsize;
>  }
>  
> -static void new_header(struct bufstate *buf, int version, const void *fdt)
> +static void new_header(struct bufstate *buf, fdt32_t magic, int version,
> +		       const void *fdt)
>  {
>  	int hdrsize;
>  
> @@ -56,7 +57,7 @@ static void new_header(struct bufstate *buf, int version, const void *fdt)
>  	expand_buf(buf, hdrsize);
>  	memset(buf->buf, 0, hdrsize);
>  
> -	fdt_set_magic(buf->buf, FDT_MAGIC);
> +	fdt_set_magic(buf->buf, magic);
>  	fdt_set_version(buf->buf, version);
>  	fdt_set_last_comp_version(buf->buf, 16);
>  	fdt_set_boot_cpuid_phys(buf->buf, fdt_boot_cpuid_phys(fdt));
> @@ -145,7 +146,7 @@ int main(int argc, char *argv[])
>  	if (fdt_version(fdt) < 17)
>  		CONFIG("Input tree must be v17");
>  
> -	new_header(&buf, version, fdt);
> +	new_header(&buf, FDT_MAGIC, version, fdt);
>  
>  	while (*blockorder) {
>  		add_block(&buf, version, *blockorder, fdt);

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2016-05-26  0:11 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-24 17:50 [PATCH v7 0/5] dtc: Dynamic DT support Pantelis Antoniou
     [not found] ` <1464112239-29856-1-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-05-24 17:50   ` [PATCH v7 1/5] util: Add xasprintf portable asprintf variant Pantelis Antoniou
     [not found]     ` <1464112239-29856-2-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-05-25  5:16       ` David Gibson
2016-05-24 17:50   ` [PATCH v7 2/5] DTBO magic and dtbo format options Pantelis Antoniou
     [not found]     ` <1464112239-29856-3-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-05-25 18:51       ` Frank Rowand
     [not found]         ` <5745F42E.9080100-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-05-26  0:10           ` David Gibson
2016-05-26  0:11       ` David Gibson [this message]
2016-05-24 17:50   ` [PATCH v7 3/5] dtc: Document the dynamic plugin internals Pantelis Antoniou
     [not found]     ` <1464112239-29856-4-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-05-25 19:13       ` Frank Rowand
     [not found]         ` <5745F95F.6000600-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-05-26  4:58           ` David Gibson
     [not found]             ` <20160526045801.GD17226-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2016-05-26  6:16               ` Pantelis Antoniou
2016-05-26  6:16                 ` Pantelis Antoniou
2016-05-26  6:14           ` Pantelis Antoniou
2016-05-26  6:14             ` Pantelis Antoniou
     [not found]             ` <1151E0EF-B811-4C0B-858A-00810BE9BA42-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-05-26  6:28               ` David Gibson
     [not found]                 ` <20160526062848.GG17226-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2016-05-26  6:31                   ` Pantelis Antoniou
     [not found]                     ` <8CAE1792-841B-4048-B6B1-1F0F973E2E34-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-05-26  6:33                       ` David Gibson
     [not found]                         ` <20160526063334.GH17226-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2016-05-26  6:36                           ` Pantelis Antoniou
     [not found]                             ` <BE239F34-7B36-4A78-BE21-AA48CB8349E4-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-05-26  7:12                               ` David Gibson
     [not found]                                 ` <20160526071243.GI17226-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2016-05-26  7:16                                   ` Pantelis Antoniou
     [not found]                                     ` <C43C3B01-5DF5-49DF-848D-0BEA48E3DB6E-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-05-26 13:49                                       ` Rob Herring
     [not found]                                         ` <CAL_JsqLTrSP577ViKRjoqyagWw4+dZuQQsTMMXdoU3n9HZSYZA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-05-26 16:55                                           ` Frank Rowand
     [not found]                                             ` <57472A9A.1060903-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-05-26 17:09                                               ` Pantelis Antoniou
     [not found]                                                 ` <EAD64177-3519-4CD2-AFB6-5EB765CC7459-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-05-26 21:31                                                   ` Frank Rowand
     [not found]                                                     ` <57476B27.9070008-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-05-27 14:52                                                       ` Pantelis Antoniou
     [not found]                                                         ` <26CE3FC4-2B09-45E9-94E2-9EA7836A684F-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-05-30  4:22                                                           ` David Gibson
     [not found]                                                             ` <20160530042210.GD17226-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2016-06-30  2:59                                                               ` Frank Rowand
2016-06-30  2:59                                                                 ` Frank Rowand
     [not found]                                                                 ` <57748B01.4050601-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-06-30  5:17                                                                   ` David Gibson
2016-05-24 17:50   ` [PATCH v7 4/5] dtc: Plugin and fixup support Pantelis Antoniou
     [not found]     ` <1464112239-29856-5-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-05-27  7:33       ` David Gibson
     [not found]         ` <20160527073306.GA17226-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2016-05-31  5:06           ` David Gibson
     [not found]             ` <20160531050634.GJ17226-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2016-06-02 17:13               ` Pantelis Antoniou
     [not found]                 ` <60DA9B11-16A5-49C6-AB27-888D4FCBE3A3-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-06-03  1:11                   ` David Gibson
2016-05-24 17:50   ` [PATCH v7 5/5] plugin: Transparently support old style syntax Pantelis Antoniou

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=20160526001148.GP17226@voom.fritz.box \
    --to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
    --cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=jdl-CYoMK+44s/E@public.gmane.org \
    --cc=jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=mporter-OWPKS81ov/FWk0Htik3J/w@public.gmane.org \
    --cc=pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org \
    --cc=robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.