Nineth Hardware Abstraction Layer: HAL

Source: Internet
Author: User

1. HAL is a set of libraries built on Linux drivers that are not part of the Linux kernel but belong to Linux The application layer above the kernel layer.

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

Unified hardware Call interface, solve the GPL Copyright issues.

3. The drive to join HAL allows applications to not care about how Linux drives and device files interact, but just like accessing a common API and Linux drivers to interact.

4. To write a Linux driver that supports HAL :

The first step: writing Linux drivers,

Step two: Write the HAL Library

Step three: Write Service libray

5. Implement the LED driver to read and write the specified registers in the read and write functions of the device file . The rationale is that only 5 bytes are read or written from the specified register , and the 1 bytes are used to specify read-write actions and register types. The latter 4 bytes are the actual data that is read and written. when interacting with the LED driver, the specified register can be read and written to the device file only if it reads or sends 5 bytes of data.

6. Because the LED driver's device file receives not a string, but a byte type of data, it is necessary to do a separate program to the device file to write byte-form data, or to read the byte-type data from the device file.

7.HAL modules can be automatically called by the Android system, and naturally have interfaces like the main or init functions. Except that this interface is not a function, but a fixed-name struct-body variable hal_module_info_sym. in other words, all the HAL program must have a Hal_module_info_sym variable.

8. Steps and principles for writing the HAL module:

First step: defining structs and macros

Step two: Write the HAL module's open function

Step three: Define hw_module_methods_t structure variables

Fourth step: Define the hal_module_info_sym variable

Fifth step: Write the close function of the HAL module

Sixth step: Write the function that controls the LED

9. There are two ways to use linux drivers in an Android system, one is to interact directly with Linux drivers in a traditional way , Data such as direct reading and writing of device files. 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 Linux shared libraries.

Address: http://www.cnblogs.com/zpm123123

Nineth Hardware Abstraction Layer: HAL

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.