common flatdevtree code

Segher Boessenkool segher at kernel.crashing.org
Thu Sep 28 10:51:52 EST 2006


>> Or unpack the tree before you operate on it.  You can pack it
>> again later if you need to pass it as a flat tree again (or the
>> bootwrapper could implement a real OF client interface, which
>> is useful for many more things!)
>>
>> A flat contiguous blob of bytes is convenient to pass around,
>> but not such a great data structure for basically anything else ;-)
>
> I agree; I think this data structure's design is explicitly static,  
> and
> now we're trying to dynamically edit it.
>
> We essentially need to do unpack/pack now whenever the size of the
> structure changes (e.g. changing a property size, adding or removing
> anything). Making that explicit (and one-time) might be a good idea:
>         tree = ft_unpack(blob);
>         n = ft_find_node(tree, "/node");
>         ft_set_prop(n, "property", value, len);
>         ...
>         blob = ft_pack(tree);

And then everything but ft_{un,}pack() don't actually operate on
a flat tree anymore; so change the prefix?  How about using of_
instead :-)

[Do you see where this is going? :-) ]


Segher




More information about the Linuxppc-dev mailing list