Android Deep Exploration (Volume I) nineth Chapter

Source: Internet
Author: User

HAL (Hardware abstraction layer, hardware abstraction level, is a set of libraries built on Linux drivers, Linux drivers in traditional Linux systems generally have two types of code: Access to hardware register code and business logic code HAL is not Lin Part of the UX kernel, but is located on the Android system runtime. In other words, the Linux driver should not keep any business logic code that you do not want to expose, the code is placed in the HAI layer, but only the code that interacts with the register, access registers only the relevant functions of the Linux kernel can do. If the linpx driver is arranged so that only one shell is left, the only function is to receive the data transmitted by the HA L and write the data to the specified register, or read the data from the register and return it to the HA L. All in all, Google for Android to join Hal mainly for the following purposes:

The calling interface for the hardware. The HAL has a standard calling interface, so you can use HA l to shield Linux drivers

Complex, non-uniform calling interface.

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 played a "traversal" to move the sensitive code that was originally in the Linux driver up a level, so that these sensitive code to get rid of the GPL protocol, those who do not want to open source Linux drivers are not necessary to open source.

For some special requirements for some hardware, it may be necessary to access some user space resources, or work that is inconvenient in kernel space and special needs. In this case, you can use the HAL code located in the user space to assist the Linux driver to do some work.

To write a support for the HAL Linux driver

    1. Writing Linux Drivers
    2. Writing the HAL Library
    3. Write Service Library

The LED drivers implemented include Linux drivers, Hal touch blocks, Service libraries, NDK programs, and Java programs, and all HAL programs must have Hal_module_ Info_sym variables

To write HAL module steps

    1. Defining structs and macros
    2. Writing the HAL module's Open function
    3. Defining a hw_module_methods_t struct-body variable
    4. Defining HAL_MODULE_INFO_SYM Variables
    5. Write the close function of the HAL module
    6. Writing functions to control LEDs

Android Deep Exploration (Volume I) nineth Chapter

Related Article

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.