Skip to contentSkip to conversation

labels within a property value

DISCUSSION Frank Rowand 2 participants 2 messages Dec 12, 2016 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 20 lines · Frank Rowand

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"

Quoted 8 lines

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.

Quoted 2 lines

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.

Signature · 4 lines
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