Device model


In Fuchsia, device drivers are implemented as ELF shared libraries (DSOs), which are loaded into Driver Host processes. The Driver Manager process, contains the Device Coordinator which keeps track of drivers and devices, manages the discovery of drivers, the creation and direction of Driver Host processes, and maintains the Device Filesystem (devfs), which is the mechanism through which userspace services and applications (constrained by their namespaces) gain access to devices.

The Driver Manager views devices as part of a single unified tree. The branches (and sub-branches) of that tree consist of some number of devices within a Driver Host process. The decision as to how to sub-divide the overall tree among Driver Hosts is based on system policy for isolating drivers for security or stability reasons and colocating drivers for performance reasons.

Devices, Drivers, and Driver Hosts

Here's a (slightly trimmed for clarity) dump of the tree of devices in Fuchsia running on Qemu x86-64:

$ dm dump
   <root> pid=1509
      [null] pid=1509 /boot/driver/
      [zero] pid=1509 /boot/driver/
      <misc> pid=1645
         [console] pid=1645 /boot/driver/
         [dmctl] pid=1645 /boot/driver/
         [ptmx] pid=1645 /boot/driver/
         [i8042-keyboard] pid=1645 /boot/driver/
            [hid-device-001] pid=1645 /boot/driver/
         [i8042-mouse] pid=1645 /boot/driver/
            [hid-device-002] pid=1645 /boot/driver/
      <sys> pid=1416 /boot/driver/
         [acpi] pid=1416 /boot/driver/
         [pci] pid=1416 /boot/driver/
            [00:00:00] pid=1416 /boot/driver/
            [00:01:00] pid=1416 /boot/driver/
               <00:01:00> pid=2015 /boot/driver/
                  [bochs_vbe] pid=2015 /boot/driver/
                     [framebuffer] pid=2015 /boot/driver/
            [00:02:00] pid=1416 /boot/driver/
               <00:02:00> pid=2052 /boot/driver/
                  [e1000] pid=4628 /boot/driver/
                     [ethernet] pid=2052 /boot/driver/
            [00:1f:00] pid=1416 /boot/driver/
            [00:1f:02] pid=1416 /boot/driver/
               <00:1f:02> pid=2156 /boot/driver/
                  [ahci] pid=2156 /boot/driver/
            [00:1f:03] pid=1416 /boot/driver/

The names in square brackets are devices. The names in angle brackets are proxy devices, which are instantiated in the “lower” driver host, when process isolation is being provided. The pid= field indicates the process object id of the driver host process that device is contained within. The path indicates which driver implements that device.

Above, for example, the pid 1416 driver host contains the pci bus driver, which has created devices for each PCI device in the system. PCI device 00:02:00 happens to be an intel ethernet interface, which we have a driver for ( A new driver host (pid 2052) is created, set up with a proxy device for PCI 00:02:00, and the intel ethernet driver is loaded and bound to it.

Proxy devices are invisible within the Device filesystem, so this ethernet device appears as /dev/sys/platform/pci/00:02:00/e1000.