Device model

Introduction

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 a legacy 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:

$ driver dump
[root] pid=4766 fuchsia-boot:///#meta/platform-bus.cm
   [sys] pid=4766
      [platform] pid=4766
         [pt] pid=4766 fuchsia-boot:///#meta/platform-bus-x86.cm
            [acpi] pid=4766
               [pwrbtn] pid=4766 fuchsia-boot:///#meta/hid.cm
               [_SB_] pid=4766
               [PCI0] pid=4766
               [ISA_] pid=4766
               [RTC_] pid=7264 fuchsia-boot:///#meta/intel-rtc.cm
                  [rtc] pid=7264
               [KBD_] pid=7359 fuchsia-boot:///#meta/pc-ps2.cm
                  [i8042] pid=7359
                     [i8042-keyboard] pid=7359
                     [i8042-mouse] pid=7359
               [MOU_] pid=4766
               [COM1] pid=4766
               [PRES] pid=4766
               [GPE0] pid=4766
               [FWCF] pid=4766
               [S00_] pid=4766
               [S08_] pid=4766
               [S10_] pid=4766
               [S18_] pid=4766
               [S20_] pid=4766
               [S28_] pid=4766
               [S30_] pid=4766
               [S38_] pid=4766
               [S58_] pid=4766
               [HPET] pid=4766
               [LNKE] pid=4766
               [LNKF] pid=4766
               [LNKG] pid=4766
               [LNKH] pid=4766
               [GSIE] pid=4766
               [GSIF] pid=4766
               [GSIG] pid=4766
               [GSIH] pid=4766
               [GFBY] pid=4766
               [GFEV] pid=4766
               [GFPP] pid=4766
               [GFFB] pid=4766
               [GFAU] pid=4766
               [GFSK] pid=4766
               [GFRT] pid=4766
               [GFRO] pid=4766
               [CPUS] pid=4766
               [_TZ_] pid=4766
            [PCI0] pid=4766 fuchsia-boot:///#meta/bus-pci.cm
               [bus] pid=4766
                  [00_00_0] pid=4766
                  [00_00_0_] pid=4766
                  [00_01_0] pid=4766
                  [00_01_0_] pid=4766
                  [00_02_0] pid=4766 fuchsia-boot:///#meta/virtio_block.cm
                     [virtio-block] pid=4766 fuchsia-boot:///#meta/block.core.cm
                        [block] pid=4766 fuchsia-boot:///#meta/fvm.cm
                           [fvm] pid=4766
                              [blobfs-p-1] pid=4766 fuchsia-boot:///#meta/block.core.cm
                                 [block] pid=4766
                              [data-p-2] pid=4766 fuchsia-boot:///#meta/block.core.cm
                                 [block] pid=4766 fuchsia-boot:///#meta/zxcrypt.cm
                                    [zxcrypt] pid=4766
                                       [unsealed] pid=4766 fuchsia-boot:///#meta/block.core.cm
                                          [block] pid=4766
                  [00_02_0_] pid=4766
                  [00_03_0] pid=4766
                  [00_03_0_] pid=4766
                  [00_04_0] pid=4766 fuchsia-boot:///#meta/virtio_ethernet.cm
                     [virtio-net] pid=4766 fuchsia-boot:///#meta/netdevice-migration.cm
                        [netdevice-migration] pid=4766 fuchsia-boot:///#meta/network-device.cm
                           [network-device] pid=4766
                  [00_04_0_] pid=4766
                  [00_05_0] pid=4766
                  [00_05_0_] pid=4766
                  [00_06_0] pid=4766
                  [00_06_0_] pid=4766
                  [00_07_0] pid=4766
                  [00_07_0_] pid=4766
                  [00_0b_0] pid=4766
                  [00_0b_0_] pid=4766
                  [00_1f_0] pid=4766
                  [00_1f_0_] pid=4766
                  [00_1f_2] pid=4766
                  [00_1f_2_] pid=4766
                  [00_1f_3] pid=4766
                  [00_1f_3_] pid=4766
         [ram-disk] pid=4766 fuchsia-boot:///#meta/ramdisk.cm
            [ramctl] pid=4766
         [ram-nand] pid=4766
         [virtual-audio] pid=4766 fuchsia-pkg://fuchsia.com/virtual_audio#meta/virtual_audio_driver.cm
            [virtual_audio] pid=4766
         [bt-hci-emulator] pid=4766
         [00_00_1b] pid=4766 fuchsia-boot:///#meta/sysmem.cm
            [sysmem] pid=4766

The names in square brackets are nodes. The pid= field indicates the process object id of the driver host process that device is contained within. The URL is the component manifest of the driver that is bound to the node. Nodes that do not have a URL do not have a driver bound to them.

Above, for example, the pid 4766 driver host contains the pci bus driver, which has created child nodes for each PCI device in the system. Its child node 00_04_0 has a network device on it, which the virtio ethernet driver has bound to, with a component URL of fuchsia-boot:///#meta/virtio_ethernet.cm.