All of lore.kernel.org
 help / color / mirror / Atom feed
* labels within a property value
@ 2016-12-12  1:26 Frank Rowand
       [not found] ` <584DFCB6.1070403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Frank Rowand @ 2016-12-12  1:26 UTC (permalink / raw)
  To: David Gibson, Devicetree Compiler

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?  Or am I trying to use it incorrectly?  If there
is a valid use, can you provide an example?


$ cat test_label_b.dts

/dts-v1/;

/ {
        #address-cells = < 0x1 >;
	#size-cells = <0x1>;
        soc {
        	#address-cells = < 0x1 >;
		#size-cells = <0x1>;

                PIC_3: pic@100 {
		        reg = < DATA_1: 0x100 DATA_2: 0x20 >;
                        interrupt-controller;
                };
        };

	uart@200 {
		reg = <0x200 0x10>;
		interrupt-parent = < &PIC_3 >;
		/* my_prop = < &DATA_1 >; */
	};

};

$ cat test_label_c.dts

/dts-v1/;

/ {
        #address-cells = < 0x1 >;
	#size-cells = <0x1>;
        soc {
        	#address-cells = < 0x1 >;
		#size-cells = <0x1>;

                PIC_3: pic@100 {
		        reg = < DATA_1: 0x100 DATA_2: 0x20 >;
                        interrupt-controller;
                };
        };

	uart@200 {
		reg = <0x200 0x10>;
		interrupt-parent = < &PIC_3 >;
		my_prop = < &DATA_1 >;
	};

};


Thanks,

Frank

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: labels within a property value
       [not found] ` <584DFCB6.1070403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-12-12  3:23   ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2016-12-12  3:23 UTC (permalink / raw)
  To: Frank Rowand; +Cc: Devicetree Compiler

[-- 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 --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-12-12  3:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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.