Android Deep Explore (Vol. 1) HAL and Driver development reading experience 9

Source: Internet
Author: User

Hardware Abstraction Layer: HAL

Google to join HAL for Android mainly has the following purposes:

1. The calling interface of the unified hardware. Since HAL has a standard calling interface, HAL can be used to shield Linux drivers from 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 played a "traversal", moving the sensitive code that was originally in the Linux drive up one level. This way, these sensitive code will get rid of the GPL, and those Linux drivers who don't want to open source will have no 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, you can use the HAL code located in the user space to assist the Linux driver to do some work.

Writing a Linux driver that supports HAL is a bit more complicated than writing an ordinary Linux driver, but it's worth the effort. Because joining the HAL makes the parts of the entire library that make up the Linux drive more independent and easier to maintain. Step 1: Write Linux drivers

"Writing Linux drivers" is nonsense from the show, but if you want to add HAL to the Linux driver and want to protect sensitive data as much as possible. Linux-driven code should be as concise as possible to put the business logic in the HAL Library.

Step 2. Writing the HAL Library

The HAL library is an ordinary Linux library (*.so) file. However, this type of library file has an interface. Implemented by Hal_module_info_sym variables. The Service library locates the HAL library by ID defined in this interface.

Step 3: Write the Service Library

Although this step is not required, the new HAL architecture requires us to do so. The Service library is also a Linux library. This step is more flexible. The Service Library can be a generic Linux library, or it can be a JNI library. In fact, this step, in addition to the *.so library file implemented in C + +, should include the Java-written service management class (ServiceManager). The service Library is called by the ServiceManager. The APK program calls the ServiceManager class to access the service Library.

Android Deep Explore (Vol. 1) HAL and Driver development reading experience 9

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.