Nineth Hardware Abstraction Layer: HAL

Source: Internet
Author: User


HAL (Hardware abstraction layer, hardware abstraction tier) is a set of libraries built on Linux drivers. This library is not part of the Linux kernel, but rather belongs to the application layer on top of the Linux kernel layer.

The calling interface for unified hardware. Because HAL has a standard calling interface, HAL can be used to mask Linux to drive complex, non-uniform interfaces. 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 driver up a level so that the sensitive code was freed from the GPL. Linux-driven authors who don't want to open up will have no need to open up.
There are two ways to use Linux drivers in Android. One is to interact directly with the Lmux driver through traditional means. 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 (. So) and then the application accesses the Linux shared library.
Hal is a set of libraries built on Linux drivers that are not part of the Linux kernel, but that belong to the application layer on top of the Linux kernel layer. Google for Android to join HAL mainly has the following purposes: Unified hardware Call interface, solve the GPL copyright issues. The drive to join the HAL allows the application to interact with the Linux driver without needing to care about how the Linux driver and device files interact, just like accessing a generic API.

Enable 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. 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 write data to the device file in bytes, or to read the byte-type data from the device file.

The 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. The steps and principles of writing a HAL module: defining structs and macros, writing the Open function of the HAL module, defining hw_module_methods_t struct variables, defining hal_module_info_sym variables, writing the close function of the HAL module, Writing functions to control LEDs

There are two ways to use Linux drivers in an Android system, and 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.

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.