The HAL hardware abstraction layer is a set of libraries built on Linux drivers. belongs to the application layer on the Linux kernel layer. The main purpose of HAL is to avoid direct access to the Linux driver for the application and to protect "private property". Traditional Linux drivers typically have two types of code: the code that accesses the hardware register and the business logic code.
Why on Android adding HAL to the
To meet the requirements of Linux driver authors who do not want open source. The HAL is located at the Android System Runtime layer. That is, HAL is part of Android. So there's no need for open source.
Google's main purpose for adding HAL to Android
1. The calling interface of the unified hardware. Because HAL has a standard calling interface, HAL can be used to mask Linux to drive complex, non-uniform interfaces.
2. Fixed the GPL copyright issue. Because the Linux kernel is based on the GPL protocol, Android is based on the Apache Licence 2.0 protocol. So Google shifted the sensitive code that was already on Linux to drive China up one level. This way, these sensitive code is freed from the GPL, and the Linux drivers who don't want open source don't need to open up.
3. For a number of special requirements. For some hardware, you may need access to some user-space resources, or work that is inconvenient in kernel space, and special needs. In this case, the HAL code located in the user space can be used to assist the Linux driver to do some work.
Android HAL Architecture
Added HAL for LED driver
To write a Linux driver that supports HAL
1. Writing Linux Drivers
2. Writing the HAL Library
3. Writing the service Library
There are two ways to use Linux drivers in an Android system: 1. Interact directly with Linux drivers in a traditional way. 2.android unique, through the HAL module. Essentially, the Linux shared library (. So) interacts with the Linux driver and then the application accesses the Linux shared library.
Hardware Abstraction Layer: HAL