Nineth Hardware Abstraction Layer: HAL

Source: Internet
Author: User

This chapter describes the HAL, called the hardware abstract layer, which is the hardware abstraction tier, which is a set of libraries built on Linux drivers, and library is not part of the Linux kernel, but rather belongs to the application layer on top of the Linux kernel layer. The purpose of adding HAL to Android is to protect private property in addition to avoiding direct access to Linux drivers.

The reason for adding Hal to Android is as follows:
Linux drivers in traditional Linux systems typically have two types of code: the code that accesses the hardware register and the business logic code. For the code that accesses the hardware register, it is standard operation to call the standard function of the Linux kernel. While some developers of Linux-driven business logic do not want to expose the source code, these Linux-driven implementations involve some technical patents and trade secrets, exposing them to trouble. However, as a Linux driver, the source code has to be exposed, because the Linux kernel uses the GPL protocol, which requires that all programs that use the GPL-based source code must be open source. To meet the need for open source, Google added a hal,hal to the system runtime layer in the Android hierarchy that is not part of the Linux kernel, which resides on Android's system runtime layer, and Android uses Apache The license2.0 protocol, which does not require the source code based on this protocol software also must open source, Hal is part of Android, do not have to open source. For Linux driver authors who do not want to open source, the Linux driver is only equivalent to a "data setter", only the code that interacts with the register in the Linux driver, access registers only the relevant functions of the Linux kernel can do, do not want to expose the business logic code in the HAL. In this case, the Linux driver has only one shell left, and the only function is to receive data from the HAL, write the data to the specified register, or read the data from the register and return it to the HAL. A Linux drive with a HAL is equivalent to uploading data from the HAL to a register, or from a register to the HAL's "Data Setter". Hal can also be added to a full-featured Linux driver, but Hal is a shell, which is only responsible for interacting with Linux device drivers. Google joins HAL for Android The main purpose is: ① Unified hardware Call interface. Because HAL has a standard calling interface, HAL can be used to shield Linux drivers from complex, non-uniform interfaces ② solves the GPL copyright issue. Because the Linux kernel is based on the GPL protocol, and Android is based on Apache license2.0 protocol, Google moved a layer of sensitive code that was originally in the Linux driver, which freed itself from the GPL, and did not want open source Linux drivers without the need for open source ③ for some special requirements. For some hardware, there may be a need to access some of the user space resources, or in the kernel space inconvenient to complete the work and special requirements, in this case, you can use the HAL code located in the user space to assist the Linux driver to do some work.

At first the simple HAL architecture rationale was to use the library in Android systems. So files are called by Linux drivers that are located in half of the kernel space accessed through the device files. The Android app apk file can then access the library in the HAL through the NDK program, or access the library in the HAL directly from the Android application, directly using Java code. In the HAL schema, the core code in the HAL module has not changed, just adding some new HAL Schema-required entry code to enable these libraries to be automatically recognized by the Android system. The code that calls the HAL module does not need to load the. So file directly, only one ID is required to locate the corresponding. so file-stub. There is also a layer of service libraries between stubs and JNI, which uses the mechanism provided by the Android system to call the HAL to access the service library in the HAL, where the HAL Library is located by ID, Then the Android app calls the service library again. The Android Hal's source code storage location is not fixed and is typically stored in the <android source >/hardware directory. The resulting. So files are primarily placed in the/SYSTEM/LIB/HW directory of the Android system.

Nineth Hardware Abstraction Layer: HAL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.