Nineth Reading notes

Source: Internet
Author: User

1. Hal is a set of libraries built on Linux drivers that are not part of the Linux kernel, but rather belong to the application layer on top of the Linux 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 the application to interact with Linux drivers without needing to care about how Linux drives and device files interact, just as you would access a generic API.

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 1th byte is 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.

The 7.HAL module can be automatically called by the Android system and naturally has an interface like the main or init function, except that the interface is not a function but rather a fixed-name struct-body variable hal_module_info_ SYM. In other words, all HAL programs 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, such as directly reading and writing 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.

http://www.cnblogs.com/xi940626/

Nineth Reading notes

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.