Writing Device Drivers

Driver Loading and Unloading

The system loads driver binary modules from the drv subdirectory of the kernel module directory for autoconfiguration (see Copying the Driver to a Module Directory). Once a module is read into memory with all symbols resolved, the system will call the _init(9E) entry point for that module. Upon successful completion of _init(), the driver is properly registered with the system, or "loaded.” At this point, the driver is not actively managing any device; that will happen as part of device configuration.

The system unloads driver binary modules either to conserve system memory or at the explicit request of a user. Before deleting the driver code and data from memory, the _fini(9E) entry point of the driver is invoked. The driver is unloaded if and only if _fini() returns success.

Figure 5–1 illustrates a structural overview of a device driver. The shaded area of this figure highlights the driver data structures and entry points. The upper half of the shaded area contains data structures and entry points supporting driver loading and unloading; the lower half, driver configuration.

Figure 5–1 Module Loading and Autoconfiguration Entry Points

Diagram shows structures and entry points used in autoconfiguration and module loading.