A hardware abstraction is software that provides access to hardware in a way that hides details that might otherwise make using the hardware difficult. Typically, access is provided via a software interface that allows devices that share a level of similarity to be accessed via the same software actions even though the devices provide different hardware interfaces. A hardware abstraction can support the development of cross-platform applications.

Early software was developed without a hardware abstraction, which required a developer to understand multiple devices in order to provide compatibility. With hardware abstraction, the software leverages the abstraction to access significantly different hardware via the same interface. The abstraction (often implemented in the operating system) which then performs the hardware-specific operations. This allows software to be compatible with all devices supported by the abstraction.

Consider a joystick device, of which there are many physical implementations. It could be accessible via an application programming interface (API) that supports common operations such as moving, firing, configuring sensitivity, and so on across variety of different joysticks. A Joystick abstraction hides details (e.g., register format, I2C address) so programmers using the abstraction do not need to understand details regarding the device's physical interface. This also allows code reuse since the same code can process standardized messages from any kind of implementation which supplies the joystick abstraction. For example, a "nudge forward" can be from a potentiometer or from a capacitive touch sensor that recognizes "swipe" gestures, as long as they both provide a signal related to "movement".

As physical limitations may vary with hardware, an API can do little to hide that, other than by assuming a "least common denominator" model. Thus, certain deep architectural decisions from the implementation may become relevant to users of a particular instantiation of an abstraction.

A good metaphor is the abstraction of transportation. Both bicycling and driving a car are transportation. They both have commonalities (e.g., you must steer) and physical differences (e.g., power source). One can always specify the abstraction "drive to" and let the implementer decide whether bicycling or driving a car is best. The "wheeled terrestrial transport" function is abstracted and the details of "how to drive" are encapsulated.

Programming

A high-level programming language provides for hardware abstraction by allowing a programmer write an algorithm without using instructions that are unique to a central processing unit (CPU) or its instruction set architecture (ISA) the primitive operations of a CPU. For example, a compiler generates the CPU-specific instructions for a particular ISA. In this way, source code can support portability across multiple platforms.

Hardware abstraction layer

A hardware abstraction layer (HAL) is an abstraction layer, implemented in software, between the physical hardware of a computer and the software that runs on that computer. Its function is to hide differences in hardware from most of the operating system kernel, so that most of the kernel-mode code does not need to be changed to run on systems with different hardware. On Microsoft Windows, HAL can basically be considered to be the driver for the motherboard and allows instructions from higher level computer languages to communicate with lower level components, but prevents direct access to the hardware.

CP/M (CP/M BIOS), DOS (DOS BIOS), Solaris, Linux, BSD, macOS, and some other portable operating systems also have a HAL, even if it is not explicitly designated as such. Some operating systems, such as Linux, have the ability to insert one while running, like Adeos. The NetBSD operating system is widely known as having a clean hardware abstraction layer which allows it to be highly portable.

Since Windows Vista and Windows Server 2008, the HAL used is automatically determined during startup. Before Project Treble, Android relied on various non-standardized legacy HALs.

Halium is an Android-based HAL used by several mobile operating systems such as Ubuntu Touch and LuneOS to run on smartphones with Android pre-installed.

See also

  • ACPI (Advanced Configuration and Power Interface)
  • BIOS (Basic Input/Output System)
  • Board support package
  • DeviceKit
  • Devicetree
  • Haiku Device Kit
  • HAL (software) (Hardware Abstraction Layer)
  • Hardware-dependent software
  • Nanokernel
  • Picokernel
  • Protection ring
  • UEFI (Unified Extensible Firmware Interface)
  • Windows Driver Frameworks
  • DirectX

References

</references>

Further reading