Re: labels within a property value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux