Android Deep Exploration--Nineth chapter reading notes and Experiences

Source: Internet
Author: User

Hal Module

--9th Chapter reading notes and Experience

This chapter learns how to interact with Linux drivers that are unique to Android, which is through the HAL module. The HAL module essentially interacts with Linux through a Linux shared library (. So) and then uses the application to access the Linux shared library. Each HAL Shared library specifies an ID that, when used with this ID, finds the Linux shared library with a certain rule. Know the meaning of Hal for Android. Know the architecture of the Android HAL.

Hal is a set of libraries that are built on Linux drivers that are not part of the Linux kernel. It belongs to the application layer above the Linux kernel layer. The HAL stores any business logic code that should not be kept in the Linux driver that you do not want to expose. So HAL's purpose is to unify the hardware's calling interface, resolve QPL copyright issues, and target specific requirements.

Evolution of the Android HAL Architecture: 1. Use the library (. so file) in the Android system to invoke Linux drivers that are located in kernel space. The android application (apk file) can then access the volume library in the HAL through the NDK program, or access the library in the HAL directly from the Android application. A

Figure A figure II

2. The core code of the HAL module remains intact, adding a new code entry for the HAL schema requirements. Instead of loading. So files, you need only one ID to locate the appropriate. So file.

To write a Linux driver that supports HAL:

1. Write Linux drivers

2. Writing Hal Library

3. Write Service Library

command-line format for testing read-write register operations: Rwdev <r|w> <dev_file> <byte_count> [byte1] [Byte2] ... [Byten]. where Rwdev represents a command-line program. <r|w> indicates a read or write command. <dev_file> indicates the device file name. <byte_count> indicates the number of bytes written or read. [Byte1] [Byte2] ... [Byten] Indicates the number of bytes written. Rwdev is compiled by RW_DEV.C.

To write a HAL module that calls the LED driver:

1. Defining Structures and macros

2. Write the HAL module's Open function

3. Define HW_MODULE_METHODS_T structure variables

4. Define HAL_MODULE_INFO_SYM variables

5. Write the close function of the HAL module

6, write the function of the control LED

Android Deep Exploration--Nineth chapter reading notes and Experiences

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.