---restore content starts---
The Nineth Chapter is mainly about the hardware abstraction layer:HAL, which is 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.
The next section speaks about the Android HAL architecture. The next step is to add HAL to the LED driver , mainly by moving all the business logic from the led driver to the Hal module, while the LED driver retains the function of the read-write register only.
Hal Steps involved:1. Writing Linux drivers 2. Writing Hal Library 3. Writing Service Library Lite led driver
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
In summary, this chapter describes a way to drive Linux in an Android system .
---restore content ends---
Android Driver Development Nineth Chapter notes