Android Deep Explore--hal and Driver Development----The Nineth Chapter reading notes

Source: Internet
Author: User

Nineth Hardware Abstraction Layer: HAL

9.1 Why should I join Hal in Android?

First, Google added HAL's main purpose for Android, in addition to avoiding direct access to Linux drivers, there is one important reason, that is, to protect "private property." -For

Those who both want to publish stubble · Android, Linux drivers, and businesses or individuals who don't want to expose their core business logic, are simply the gospel.

HAL is not part of the Linux kernel, but is located on the Android system runtime layer, although these Linux. Drivers are free to users ' use, but because these Linux drive implementations involve some, technical patents or trade secrets, exposing the source code can be a big hassle. But as a Linux. Driver, you have to expose the source code. This is because the Linux kernel uses the GPL protocol, and the GPL requires that all programs that use the GPL-based source code must be open source (since Linux drivers are part of the Linux kernel, Linux drivers must be open source).

In summary, Google adds HAL's main purpose to Android:

1. The calling interface of the unified hardware. Because HAL has a standard calling interface, HAL can be used to mask Linux drivers for complex, non-uniform interfaces.

2. Fixed GP (copyright issue. Because the Linux kernel is based on the GPL protocol, Android is based on Apache Licence 2. 0, agreement. So Google played a "cross-fly" to move the sensitive code that was already in the Linux driver up one level two so that these sensitive code is free from the GPL protocol. Linux-driven authors who don't want to open up will have no need to open up.

3. For a number of special requirements. For some hardware, you may need to access the resources of some user space, or work that is inconvenient in the kernel space and special needs. In this case, the HAL code located in the user space can be used to assist the Linux driver to do some work.

9.3 Adding HAL to LED driver

9.3.1 writing a Linux driver that supports HAL write a Linux drive i.9j that supports HAL. The program is more complicated than writing a normal 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. Take a look at the specific implementation steps below. In the following sections, each step is gradually discussed.

1th Step Writing 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 needs to be as concise as possible to put business logic into hallibrary.

2nd step: Writing the HAL Library

The HAL library is an ordinary Linux library servant. 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 the ID defined in this interface.

3rd Step: Writing 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 an I library. In this chapter of the LED driver example, the Service libratγ is combined with the penalty I Library. In other words, the service library is the JNI library. In fact, this step, in addition to the *.so library file implemented with the CIC, should include a service management class (ServiceManager) written in Java. The Service Library is called by the ServiceManager. The APK program calls the ServiceManager class meter to access the Service Library.


Android Deep Explore--hal and Driver Development----The Nineth Chapter reading notes

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.