Hardware abstraction

Source: Wikipedia, the free encyclopedia.

Hardware abstractions are sets of routines in

software that provide programs with access to hardware
resources through programming interfaces. The programming interface allows all devices in a particular class C of hardware devices to be accessed through identical interfaces even though C may contain different subclasses of devices that each provide a different hardware interface.

Hardware abstractions often allow programmers to write

high-level language without having to care about CPU-specific instructions. Then it is the job of the compiler to generate a CPU-specific executable. The same type of abstraction is made in operating systems, but OS APIs now represent the primitive operations of the machine, rather than an ISA. This allows a programmer to use OS-level operations (e.g. task creation/deletion) in their programs while retaining portability
over a variety of different platforms.

Overview

Many early computer systems did not have any form of hardware abstraction. This meant that anyone writing a program for such a system would have to know how each hardware device communicated with the rest of the system. This was a significant challenge to software developers since they then had to know how every hardware device in a system worked to ensure the software's compatibility. With hardware abstraction, rather than the program communicating directly with the hardware device, it communicates to the operating system what the device should do, which then generates a hardware-dependent instruction to the device. This meant programmers didn't need to know how specific devices worked, making their programs compatible with any device.

An example of this might be a "Joystick" abstraction. The

I2C address) of the hardware so that a programmer using the abstracted API, does not need to understand the details of 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. A "nudge forward" can be from a potentiometer
or from a capacitive touch sensor that recognises "swipe" gestures, as long as they both provide a signal related to "movement".

As physical limitations (e.g. resolution of sensor, temporal update frequency) 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., use of feet). One can always specify the abstraction "drive to" and let the implementor 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.

Examples of "abstractions" on a PC include video input, printers, audio input and output, block devices (e.g. hard disk drives or USB flash drive), etc.

In certain computer science domains, such as operating systems or embedded systems, the abstractions have slightly different appearances (for instance, Operating Systems tend to have more standardized interfaces), but the concept of abstraction and encapsulation of complexity are common, and deep.

The hardware abstraction layer reside below the

application programming interface
(API) in a software stack, whereas the application layer (often written in a high level language) resides above the API and communicates with the hardware by calling functions in the API.

In operating systems

A hardware abstraction layer (HAL) is an

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.

PCIe
, etc., allowing drivers to also be highly portable with a minimum of code modification.

Operating systems having a defined HAL are more easily portable across different hardware. This is especially important for embedded systems that run on dozens of different platforms.

Microsoft Windows

The Hardware Abstraction Layer in the architecture of Windows NT

The

instruction set applicable to those systems. For example, the SGI Intel x86-based workstations were not IBM PC compatible workstations, but due to the HAL, Windows 2000 was able to run on them.[4][failed verification
]

Since

AS/400

An "extreme" example of a HAL can be found in the

AS/400 architectures, currently implemented in the IBM i operating system. Most compilers for those systems generate an abstract machine code; the Licensed Internal Code, or LIC, translates this virtual machine code into native code for the processor on which it is running and executes the resulting native code.[6] (The exceptions are compilers that generate the LIC itself; those compilers are not available outside IBM.) This was so successful that application software and operating system software above the LIC layer that were compiled on the original S/38 run without modification and without recompilation on the latest AS/400 systems, despite the fact that the underlying hardware has been changed dramatically; at least three different types of processors have been in use.[6]

Android

forward compatible to support future versions of Android to ease the development of firmware updates.[7] Before Project Treble Android relied on various non-standardized legacy HALs.[8]

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

References

  1. ^ "Portability and supported hardware platforms". The NetBSD Foundation. Retrieved 12 May 2009.
  2. ^ "Windows NT Hardware Abstraction Layer (HAL)". Microsoft. 31 October 2006. Retrieved 25 August 2007.
  3. ^ "Changing hardware abstraction layer in Windows 2000 / XP – Smallvoid.com". 15 January 2001. Retrieved 18 September 2020.
  4. .
  5. ^ .
  6. ^ "Google's "Project Treble" solves one of Android's many update roadblocks". Ars Technica. 12 May 2017. Retrieved 12 May 2017.
  7. ^ "Conventional & legacy HALs". Android Open Source Project.

Further reading