Hardware Abstraction Layer

Source: Internet
Author: User

Hal is a set of programs 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 main purpose of adding HAL is to protect "private property" in addition to trying to avoid direct access to Linux drives by the application. So how is it protected?

The HAL is located at the Android System Runtime layer, between the application framework layer and the Linux kernel layer, while Android uses the Apache Licence2.0 protocol release, the Apache Licence2.0 protocol does not require the use of Apache-based The software for the source code of the LICENCE2.0 protocol must also be open source. Since HAL is part of Android, it doesn't have to be open source. Of course join HAL There are other purposes: Unified hardware Call interface, for some special requirements.

Hal's architecture has changed greatly from the beginning to the present, and the original architecture has not been said, the new version of the Android system has changed the HAL schema to look like.

      

As you can see, the code that calls the HAL module does not need to load the. So file directly, but only through an ID to locate the appropriate. So file.

The location of the Androidhal source code store is not fixed and is typically stored in the Android source directory/hardware directory, where the Android source code directory/hardware/libhardware_ The legacy directory is used to store source code files for the mortar HAL schema. The source code for the new HAL schema is in the Android source directory/hardwarelibhardware directory. Of course, it can also be placed in the Android source code directory/hardware or other directories. The final compiled. So file is primarily placed in the/SYSTEM/LIB/HW directory of the Android system and can be placed in other directories as well.

With the above introduction to HAL already have a general understanding, then how to write a support Hal Linux driver?

1, write Linux driver, if you want to add HAL for Linux driver, and want to protect sensitive data as far as possible, the Linux driver code should be as concise as possible, put business logic into the HAL Library.

2, write Hal Library, this is actually a common Linux library file, but this kind of library file has an interface. Implemented by Hal_module_info_sym variables. The Service library locates Hal Libary by the ID defined in this interface.

3, writing service Library, this step is not necessary, but the heart of the HAL architecture requires us to do so. The Service library is also the Linxu library. This step is more flexible. The Service Library can be a generic Linux library, or it can be a JNI library.

These are the steps to write a Linux driver that supports HAL.

Hardware Abstraction Layer

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.