blkdev in oftree

Samuel Rydh mol-devel@lists.maconlinux.org
Fri, 17 Oct 2003 12:38:57 +0200


On Tue, Oct 14, 2003 at 06:12:30PM +0200, Axel D?rfler wrote:
> Hi,
> 
> I am currently writing an OpenFirmware based boot loader. It is 
> responsible to load the kernel and modules required for a stand-alone 
> boot process.
> On a real machine (like a PowerMac G4), I can just scan the OF device 
> tree for "block" devices and get all disks accessible to the OF.
> With MOL, I don't know how I can connect the blkdev option in molrc to 
> a node in the OF device tree. When I scan the tree, I will only see the 
> nodes that are explicetly defined in my oftree file, but none of them 
> points to the devices added by the blkdev option.

The 'mol-blk' node represents all exported block devices. The OF path is

	/mol-blk@channel/disk@unit:partition

(for now, only a single channel is supported). The unit number
is related to a particular blkdev line.

However, after a closer look at the of-mol source code, I noticed that
the open/read/write methods of the mol-blk node are not connected
to the underlying infrastructure (I was pretty certain I had
implemented this, but the code is indeed not there...). The
pseudo filesystem (which contains files explicitly exported from
the molrc file) is supported though.

The of-mol implementation is currently used to boot MacOS 9
and linux (yaboot). In the former case, special support code
is used to find and load the boot image (the newworld ROM).
In the yaboot case, everything of interest resides in the
pseudo filesystem.

Adding OF functionality to the mol-blk node should be
simple enough; the infrastructure (like opening device specs)
is already present. It is mostly a question about associating
ihandles with the the corresponding device spec (or file spec
for that matter). The best solution would probably be to
use ihandles internally rather than a filesystem/fd pair.
I intend to address this issue shortly.

> BTW is it possible to get a prompt at OpenFirmware level?

No. Only the client side of OF is implemented (no forth
interpreting).

> On a related topic: how would I normally boot another OS with MOL?
> I am currently "abusing" the --linux settings to boot my
> boot loader (using oftree.linux & molrc.linux).

Well, almost everything is configurable from the molrc files.
It works as follows:

1) Command-line options are transformed into molrc defines
2) /etc/mol/session.map is parsed
3) /etc/mol/molrc.linux is included from session.map
4) /usr/share/mol/0.9.xx/config/molrc.post is parsed

The molrc.post file defines default values and some stuff that
users normally don't care about (which oftree to use, for instace).
Everything in molrc.post can be overridden by adding definitions
in other molrc files.

The oftree file is used to configure the MOL "hardware". Some
OS-specific tweaks are also necessary and these are controlled
by the 'boot_method' molrc key. For instance, oldworld MacOS
does not have an interrupt tree and expects PCI-roms with
drivers while MacOS 9 looks for drivers encoded as
device tree properties.

At the moment, the linux mode is currently the "generic boot"
mode so abusing it is quite OK. There is also a --elf mode
which can be used, but it might need some tweaking. Anyway,
I intend to rename the linux mode to 'generic' or 'ofboot' and
just let the --linux switch invoke the default linux config
file.

In any case, to boot a complete OS, one normally has to add
some MOL driver to the OS although I guess one theoretically
could run it without custom drivers if one configure the
device tree to include somethings like

i) The gc/heathrow interrupt controller
ii) Framebuffer using OF
iii) The emulated OHCI USB controller for disk access
iv) Keyboard access through the VIA chip

Whether the OS can cope with this hardware set is another story
entirely...

/Samuel