Writing Device Drivers

Example Device Tree

Figure 1-2 illustrates a sample device tree.

Figure 1-2 Example Device Tree

Graphic

In Figure 1-2, the root node is the parent node of the child nodes SUNW,ffb leaf node (a frame buffer), a pseudo bus nexus node, and a PCI bus nexus node.

The SUNW,ffb leaf node represents a system frame buffer. The pseudo bus nexus node is the parent of any pseudo device drivers (drivers without hardware). The PCI bus nexus node further has two PCI bus nexus nodes as its children representing two PCI-to-PCI bridges.

The lower left PCI bus nexus node is the parent of the child nodes; ebus bus nexus node, network leaf node (ethernet), and ide bus nexus node.

The ebus bus nexus node is the parent of the child nodes fdthree leaf node (a floppy disk device) and se leaf node (a serial device).

The ide bus nexus node is the parent of the child nodes dad leaf node (a disk device) and sd leaf node (a CD-ROM device).

Device Drivers

Associated with each leaf or bus nexus node can be a device driver. Each driver exports a device operations structure dev_ops(9S) that defines the operations that the device driver can perform. The device operations structure contains function pointers for generic operations such as attach(9E), detach(9E), and getinfo(9E). It also contains a pointer to a set of operations specific to bus nexus drivers and a pointer to a set of operations specific to leaf drivers.