Android Deep Explore Nineth Chapter

Source: Internet
Author: User

Hal is a set of libraries built on Linux drivers. This library is not part of the Linux kernel but is the application layer on top of the Linux kernel layer.

Google's main purpose for adding Hal to Android is as follows:

1, the unified hardware call interface.

2, solve the GPL copyright issue.

3, for a number of special requirements.

To write a Linux driver that supports HAL:

1. Write Linux drivers

2. Writing Hal Library

3. Write Service Library

Steps and principles for writing HAL modules:

1. Define structure and macro

2. Write the HAL module's Open function

3. Define HW_MODULE_METHODS_T structure variables

4. Define HAL_MODULE_INFO_SYM variables

5. Write the close function of the HAL module

6, write the function of the control LED

There are two ways to use Linux drivers in an Android system. One is to interact directly with Linux drivers in a traditional way. For example, directly read and write data from a device file. The other is Android-specific, which is through the HAL module. The HAL module essentially interacts with the Linux driver through a Linux shared library, and then the application accesses the Linux shared library. Early HAL modules have applications that are called directly by accessing the Linux shared library. The higher version of the Android system adds a stub to HAL. In other words, specify an ID for each HAL shared library, and then use that ID to match a certain rule to find the Linux shared library. So the Linux shared library to replace the file name, mobile location is very convenient. Google also recommends using stubs to write HAL modules.

Android Deep Explore Nineth Chapter

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.