Android Deep Exploration <9> Insights

Source: Internet
Author: User

The HAL hardware abstraction layer is a set of libraries built on Linux drivers. This library is not part of the Linux kernel, but belongs to the application layer on the Linux kernel layer. Linux drivers typically have two types of code in a traditional Linux system. Google for Android to join Hal mainly for the following purposes: Unified hardware Call interface. Since HAL has a standard calling interface, HAL can be used to shield Linux drivers from complex, non-uniform interfaces, to solve the GPL protocol, and to address specific 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, you can use the HAL code located in the space to help Linux do some work.

The LED drivers implemented in this chapter include Linux drivers, HAL modules, service libraries, NDK programs, and Java programs.

The steps and principles for writing the HAL module are as follows:

  1. define structures and macros;
  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 functions to control LEDs;

The Linux drivers that support HAL are the following steps:

1. Write Linux drivers;

2. Writing Hal Library;

3. Writing service Library;

The HAL module essentially interacts with the Linux driver through a Linux shared library (. So) and then the application accesses the Linux shared library to interact with the Linux driver and then the application accesses the Linux shared library. Each HAL Shared library specifies an ID and then uses this ID to match certain rules to find the Linux shared library.

Android Deep Exploration <9> Insights

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.