Traditionally, the operating system kernel was responsible for providing an abstract interface to the hardware the system ran on. Applications used the system call interface, or performed file I/O on device nodes in order to communicate with hardware through these abstractions. This sufficed for the simple hardware of early desktop computing. Computer hardware, however, has increased in complexity and the abstractions provided by Unix kernels have not kept pace with the proliferating number of device and peripheral types now common on both server and desktop computers. Most modern buses have also become hotplug-capable and can have non-trivial topologies. As a result, devices are discovered or change state in ways which can be difficult to track through the system call interface or Unix IPC. The complexity of doing so forces application authors to re-implement hardware support logic. Some devices also require privileged helper programs to prepare them for use. These must often be invoked in ways that can be awkward to express with the Unix permissions model. Application authors resort to using setuid binaries or run service daemons to provide their own access control and privilege separation, potentially introducing security holes each time.
Design
HAL is a single daemon responsible for discovering, enumerating and mediating access to most of the hardware on the host computer. Applications communicate with HAL through the D-Bus IPC mechanism, which abstracts the hardware behind an object-basedRPC mechanism. Each logical hardware device is represented as a D-Bus object, and its bus address is used as a unique identifier. Devices include abstractions like disk partitions and visible wireless networks. The device's functionality is exposed through D-Bus interfaces, and its state accessed through properties, a set of key-value pairs. HAL broadcasts hardware events as signals on these objects; applications can listen for signals and react to the hardware events that they signify — events such as a digital camera being plugged in, an optical disc spinning up or a laptop computer closing its lid.
Implementations and obsolescence
On Linux, HAL uses /sys to discover hardware and listen for kernel hotplug events. Some Linux distributions also provide a udev rule to allow the udev daemon to notify HAL whenever new device nodes appear.
Deprecated
, Linux distributions such as Ubuntu, Debian, and Fedora and on FreeBSD, and projects such as KDE, GNOME and X.org are in the process of deprecating HAL as it has "become a large monolithic unmaintainable mess". The process is largely complete, but some use of HAL remains – Debian squeeze and Ubuntu version 10.04 remove HAL from the basic system and boot process. In Linux, it is in the process of being merged into udev and existing udev and kernel functionality. The replacement for non-Linux systems such as FreeBSD is devd. Initially a new daemon DeviceKit was planned to replace certain aspects of HAL, but in March 2009, DeviceKit was deprecated in favor of adding the same code to udev as a package: udev-extras, and some functions have now moved to udev proper.