devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Frank Rowand <frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Devicetree Compiler
	<devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: labels within a property value
Date: Mon, 12 Dec 2016 14:23:28 +1100	[thread overview]
Message-ID: <20161212032328.GA31441@umbus.fritz.box> (raw)
In-Reply-To: <584DFCB6.1070403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

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

On Sun, Dec 11, 2016 at 05:26:14PM -0800, Frank Rowand wrote:
> Hi David,
> 
> The ePAPR in Appendix A (page 96) says:
> 
> 
>   Labels may also appear before or after any component of a property value, or between cells of
>   a cell array, or between bytes of a bytestring. Examples:
>   reg = reglabel: <0 sizelabel: 0x1000000>;
>   prop = [ab cd ef byte4: 00 ff fe];
>   str = start: "string value" end: ;
> 
> 
> The dtc compiler indeed allows placing a label inside a property value.
> But when I try to use that label I get the error:
> 
>    ERROR (phandle_references): Reference to non-existent node or label "DATA_1"
> or
> 
>    ERROR (path_references): Reference to non-existent node or label "DATA_1"
> 
> The three test dts files are below.
> test_label_b.dts has the usage of the label commented out (compiles ok).
> test_label_c.dts tries to use the data label as a phandle (gets first error).
> test_label_d.dts tries to use the data label as a path (gets second error).
> 
> I am trying to figure out how a data label could be used in a
> reasonable manner.  Is this maybe a construct left over from
> open firmware?

No.  OF has no notion of labels whatsoever.

> Or am I trying to use it incorrectly?  If there
> is a valid use, can you provide an example?

So, the way to understand this is that of themselves, labels are
entirely abstract.  They can be put on nodes, properties, or inside
properties.

But a reference to a label is not abstract - it needs to be expanded
to something concrete.  For a node label, it expands to either a
phandle or a path, depending on context.  For property or
within-property labels, there's nothing defined for it to expand to,
at least not yet.

So while labels are valid in lots of places, references are only valid
if they reference a node label.  Admittedly the error message for that
case is pretty misleading. [Aside: that in turn is basically because
we don't actually have a symbol table for labels and instead just
attach them to the labelled object.  That's kind of bodgy but there's
never been quite enough impetus to clean it up].

So, what use are property or within-property labels?  The only use -
so far at least - is when using -Oasm output mode.  In that mode, all
dts labels are translated into assembler labels appearing at the point
in the output corresponding to the node structure, property structure,
or within the property data.

The idea here was for making really minimal bootloaders for embedded
machines.  Specifically ones where the hardware is fixed enough that
the only dts changes necessary are in-place alterations of a few
properties (no adding/removing nodes or resizing properties).  In that
case you can use -Oasm to link the dtb directly into the bootloader
image, and you can use labels to allow the bootloader to update the
properties it needs to without any dtb parsing.

In practice of course, I don't think anyone's doing that, but it
seemed like a plausible use case when dtc was written.

-- 
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-12-12  3:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-12  1:26 labels within a property value Frank Rowand
     [not found] ` <584DFCB6.1070403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-12-12  3:23   ` David Gibson [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=20161212032328.GA31441@umbus.fritz.box \
    --to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
    --cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=frowand.list-Re5JQEeQqe8AvxtiuMwx3w@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;
as well as URLs for NNTP newsgroup(s).