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

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Tue Nov 22 00:41:22 CET 2016

On 21/11/16 14:34, Michael wrote:

> Dear list, thank you for the help with cross-compiling for ppc64 so far!
> It is important but I overjumped enthusiastically the OF basics :-)
> I read many webpages, hints and maybe old sites etc and solved many things.
> But is there a "beginners how-to" somewhere? What I would find most usefull:
> 1) Best source-code to use? There is a version-1.1.zip, a svn repo and
> a git repo.

Definitely go for the github.com repository - SVN is no longer
supported. I did try and update the wiki after the transition, however
there is a chance I missed something.

And yes, we really haven't bumped the version number from 1.1 for a few
years now...

> 2) The names are also a bit confusing when you see it first. I know about
> the IEEE standard and a few things about the history (from wikipedia),
> but if you for example visit the website and click on the "openfirmware"
> link, the you see a page with "OpenBIOS" heading. So even if one knows
> about history, there is confusion about actual used names.

I think this has already been covered by other people :)

> 3) How is the device-tree given to OF? And how does OF handle it over
> to a linux kernel?

OF implements what is called the CIF (Client Interface) which is a
effectively a call table passed to the kernel at boot. You can find this
referenced in kernel sources as of_* functions in Linux, and various
other names for other kernels e.g. prom1275.

For Linux in particular have a browse around arch/powerpc/boot/oflib.c.

> 4) Minimal prerequisites on a new hardware, so that OF is able to run?
> E.g. which type of RAM does it need? Does it need a stack or .text segment
> or other things to run (like c-code)? ...
> If these points would be clarified, the it would be much easier for
> new people to help with e.g. additional targets or maybe new architectures.

OpenBIOS is built as an ELF executable and so uses start.S to relocate
itself and provide a C-like environment e.g. traps, MMU/virtual address
setup before calling the main executable.

So in order to get going I'd suggest you do the following:

1) Start from the QEMU sources e.g. arch/ppc/qemu/*

The non-QEMU sources are missing a *lot* of functionality/bugfixes that
haven't been tested simply because no-one has burned OpenBIOS PPC to a
real PROM for quite a while.

2) Hack arch/ppc/qemu/start.S to setup your C environment

The QEMU binaries get various bits of information from QEMU via an
ioport called the firmware configuration (or FW_CFG) interface. You'll
need to hardcode some values here, e.g. RAM size, and make sure you're
happy with the memory map comments at the top of the file.

3) Get basic serial IO working

Make sure that you've got a basic serial port working - chances are that
you'll want to change the default config in
config/examples/ppc_config.xml to use a standard 8250 serial port driver
if that's what your hardware provides.

Set this up and make sure you can get serial output by writing to a
suitable ioport location. Then also check arch/ppc/qemu/console.c since
those are the bindings called by Forth.

4) Build your basic device tree

Make some hacks around arch/ppc/qemu/tree.fs and arch/ppc/qemu/init.c to
provide a basic device tree. Once you've got serial IO and have a Forth
prompt, you're pretty much there. You can view the device tree by typing

It's always interesting to obtain feedback from people using OpenBIOS on
real hardware, so please do keep us informed of your progress and we
will do our best to answer any questions/help track down any bugs reported.



More information about the OpenBIOS mailing list