Nineth Hardware Abstraction Layer: HAL

Source: Internet
Author: User

First, Android added Hal's main purpose in addition to avoiding direct access to the Linux driver, an important reason is to protect the business or personal core business logic. Linux drivers in traditional Linux systems generally have two types of code: Access to hardware register code and business logic code, for access to hardware register code, is called the Linux kernel standard function to operate and there is no secret to say. For business logic code, there are some trade secrets or technology patents in the enterprise and individuals do not want to be public, so in the Android hierarchy System Runtime layer added HAL, so HAL is not part of the Linux kernel but in the Android system Runtime layer, naturally do not have to open source. And the Linux driver is the equivalent of a "data setter", the only function is to accept the data from the HAL, and write data to the specified register, or read data from the register, returned to the HAL. The main purposes of HAL are as follows:

1. Calling interface for unified hardware

2. Fixed GPL copyright issue

3. There are some special requirements

Second, HAL Architecture

Compared to the old HAL schema, the new HAL schema adds some architectural requirements to the Ingress code, and a layer of service libraries (the HAL Library is located on this layer by ID).

Note: Although the new HAL schema is used, the old HAL schema is still supported for compatibility.

Iii. steps to write Linux drivers that support HAL

1. Write Linux drivers (Linux driver code should be as concise as possible to put business logic code in the HAL Library)

2. Write the HAL Library (class libraries file has an interface that is implemented by HAL_MODULE_INFO_SYM variables.) The Service Library locates the HAL library by ID defined in this interface)

Steps and principles for writing HAL modules:

(1) 1th step: Define struct and macro, write HAL module to use 3 very important structures (hw_module_t, hw_device_t and Hw_ module_ method_t)

(2) 2nd step: Writing the HAL module's Open function

(3) 3rd step: Define HW_ MODULE_ method_t structure variables

(4) 4th step: Define HAL_MODULE_INFO_SYM structure variables

(5) 5th step: Write the close function of the HAL module

(6) 6th step: Write the function to control the LED

3. Writing the service 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.