The Android hardware abstraction layer, in short, is the encapsulation of the Linux kernel driver, which provides an interface to the lower level of implementation detail.
support for hardware is divided into two tiers, one layer in user space, one layer in kernel space (Kernel spaces) , where the hardware abstraction layer runs in user space while the Linux kernel driver runs in kernel space. Why should this be arranged? Is it not OK to integrate the hardware abstraction layer and kernel drive into the kernel space? From the point of view of technology implementation, it is possible, however, from a commercial point of view, the hardware support logic are placed in the kernel space, may harm the interests of manufacturers. We know that the Linux kernel source code is copyrighted to the GNU License, and the Android source code is copyrighted to the Apache License, which, when publishing the product, must advertise the source code, which does not need to publish the source code. If you put all your hardware-supported code on the Linux driver layer, that means that the release of the source code to open the driver, and open the source code means that the hardware related to the parameters and implementation of the public, in the mobile phone market competition is fierce today, the manufacturers, the damage is very large. As a result, Android is thinking of dividing its hardware support into a hardware abstraction layer and a kernel-driven layer, the kernel-driven layer provides only simple access to hardware logic, such as a channel for reading and writing hardware registers, as to what values are read from the hardware or what values are written to the logic in the hardware, which are placed in the hardware abstraction layer. So we can hide the trade secrets. It is also because of this layering that Android is kicked out of the Linux kernel mainline code tree.
you think, Android in the kernel space of the driver's hardware support is incomplete, when the Linux kernel porting to other machines, due to lack of hardware abstraction layer of support, the hardware is completely useless, That's why Android is an open system, not an open-source system.
Putting these arguments aside, learning the Android hardware abstraction layer is extremely useful for understanding the entire Android system, as it comes down to the hardware driver layer of the Android system, the hardware abstraction layer, the Run-time library, the application framework layer, and so on, The following diagram illustrates the location of the hardware abstraction layer in the Android system and its relationship to the other layers:
In the process of learning the Android hardware abstraction layer, we will learn how to write hardware drivers in kernel space, how to add interfaces to the hardware abstraction layer to support access to hardware, how to provide hardware access at system startup, and how to write JNI so that hardware can be accessed through the Java interface.
The above is a simple introduction to the Android HAL, follow-up continue to supplement the relevant information, thank you for your support for this site!