Hardware Abstraction Layer: HAL

Source: Internet
Author: User

In this section we examine the hardware abstraction layer: Halhal, a set of libraries built on Linux drivers. Just started to introduce why to add HAL to Android, the purpose is three, one, unified hardware call interface. Second, solve the GPL copyright issue. Third, for some special requirements. You can use the HAL code located in user space to assist the Linux driver in doing some work. HAL has the following main 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.
The first step: defining structs and Macros writing HAL modules requires 3 very important structures, and in the first step you need to define two new structures.
The second step: The Open function of writing the HAL module is the entry point of the HAL module. In this example, the Led_device_open function is used. This function mainly does the following three work. Initializes the hw_device_t of the sub-structure. Open the device file. Initializes the register.
Step three: Define hw_module_methhods_t structure variables
Fourth step: Define the Hal_module_info_sym function
Fifth step: Write the close function of the HAL module and call the Close function when the HAL module is unloaded
Sixth step: Write the function that controls the LED

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.