wiki:DeviceDrivers

Version 3 (modified by Jiri Svoboda, 13 years ago) ( diff )

What is a driver

Writing Device Drivers for HelenOS

What is a device driver?

The hardware an OS runs on can be modelled as a hierarchy of (peripheral) interconnects (buses) to which devices are attached. Each bus provides connectivity to devices or other buses. This hiearchy can be often represented as a tree (or directed acyclic graph), where inner (nexus) nodes correspond to buses and leaf nodes correspond to devices.

Needless to say this is just a model, meaning nothing is given a priori, the model can look differently depending on our choice. It is often not clear what is a device and what is not, where are the boundaries of a particular device, etc. Consequently, there is also no clear line between what still is a device driver and what is not.

Usually devices (or their drivers) have one or more of the following traits. When a system is coming up, it attempts to transitively discover all buses and devices connected to it. For each bus or device it selects the appropriate driver. The driver takes (complete) control of the bus or device and makes its services available to the system (to other drivers in case of a bus, to applications in case of a device). The driver abstracts away the details of a particular device model and provides an interface common to a class of devices (e.g. Ethernet adapter). The system often also virtualizes the device, providing concurrent access to multiple clients, but this can be done at a higher level, rather than in the driver itself.

Overview of Drivers in HelenOS

DDF (Device Driver Framework)

DDF Driver Structure

  • #include <ddf/driver.h>
  • driver_t
  • driver_ops_t
  • ddf_dev_ops_t

Device and Function Life Cycle

  • ddf_fun_create()
  • ddf_fun_destroy()
  • ddf_fun_add_match_id()
  • ddf_fun_add_to_category()
  • ddf_fun_bind()
  • ddf_fun_unbind()
  • ddf_fun_online()
  • ddf_fun_offline()

Soft State Management

  • ddf_dev_data_alloc()
  • ddf_fun_data_alloc()

Exposing Driver Services to Clients

Traditional I/O Device Drivers

Programmed I/O

Interrupts

DMA

USB Device Drivers

Note: See TracWiki for help on using the wiki.