Since the beginning of this year we've been busy
in the Andromeda team. One of the things we've been working at is the
driver model. Our design is fairly simple, and I think I can explain
it, so here we go.
The device model consists of a tree of devices.
Starting with the root device. This is a virtual device to which
everything is attached in some form. Attached to this device are for
example the CPU's, memory, the PCI bus and some virtual buses.
The reason for choosing a tree instead of a plain
list of devices is simple. When the system is to shut down or to
suspend, we want to disable the devices first, then the buses and
last the power supply (if necessary). If we're to walk a plain list
things are to shut down in random order which might get interesting
since for example the PCI bus has been shut down before the graphics
card is so it never receives the shut down signal.
The reason why the CPU's, Memory and PCI are
attached to the root device are simply the fact that they are at the
head of the system. The reason for the virtual buses might not be so
obvious yet.
There are 2 virtual buses. One for virtual devices
which reside in memory and don't really have to be suspended, and
can't have physical hardware attached to them, and then there's the
legacy devices. These can be the VGA and PS/2 controller to name a
few.
Devices in the model are nothing more than data
structures with a file pointer, open function, name/unique
identifier, driver pointer and a void pointer for special data
structures. When interaction with the devices is needed, the device
file can be opened and written to. The device might respond and by
reading from the device file the answer can be retrieved.
In the case of a permanent storage device this
file can hold pointers to partitions which can in turn hold files
which can then be mounted to the VFS.
No comments:
Post a Comment