[OpenBIOS] Beginners How-To for DTS and OpenFirmware?

Thomas Huth thuth at redhat.com
Thu Nov 24 08:05:27 CET 2016


On 23.11.2016 22:43, Mark Cave-Ayland wrote:
> On 22/11/16 07:58, Thomas Huth wrote:
> 
>> But if you want the full-blown Open Firmware interface, you either have
>> got to construct the device tree in Forth (AFAIK), or you've got to use
>> some other magic to translate a FDT to an Open Firmware device tree, for
>> example. Not sure about OpenBIOS, but at least SLOF has some code
>> already to transform an FDT into an Open Firmware DT, so you might want
>> to peek there:
>> https://github.com/aik/SLOF/blob/master/board-qemu/slof/fdt.fs
> 
> Funnily enough one of the conversations I had with Ben a while back was
> as to whether it was worth switching OpenBIOS to libfdt.
> 
> While it works well for the tree properties, I'm not exactly clear how
> it would work in the case of binding Forth words into the device tree
> nodes (e.g. as in
> https://github.com/openbios/openbios/blob/ef8a14e8afb47635c9c5f7524a52c3251827e296/arch/ppc/qemu/tree.fs)
> and other arbitrary C functions without getting messy.
> 
> How does SLOF cope with this?

SLOF transforms the FDT from QEMU to its internal, Forth-based
representation once, then adds some necessary Forth words manually where
required. E.g. have a look at the end of this file here:

https://github.com/aik/SLOF/blob/master/board-qemu/slof/tree.fs

It's doing things like this to add missing words:

s" /aliases" find-device
   : open  true ;
   : close ;
device-end

Once the device tree is in place, the FDT is discarded and never used again.

IMHO, libfdt is nice if you need to create a FDT only once (e.g. to pass
it to the OS), or if you only need to read from a FDT, but it is not
very well suited for dynamic manipulations - and since there is also no
concept of device tree node functions (Forth words) in here, it does not
make too much sense to completely base an Open Firmware implementation
on this library. For your firmware-internal representation, you better
use something else, and not a FDT.

 Thomas




More information about the OpenBIOS mailing list