1.HAL (handerware abstraction layer, hardware abstraction layer) is a set of libraries built on Linux programs that are not part of the kernel, but that belong to the application layer on top of the kernel.
2. Reasons to join Hal in Android: There are generally two types of code in Linux drivers: code to access hardware registers and business logic code. There is no secret to the code that accesses the hardware registers, which are standard operations that call the standard functions of the Linux kernel.
3.Google joins HAL for Android Its main purpose is:
The calling interface of unified hardware;
Fixed the issue of GPL copyright;
For some special requirements.
4.andriod HAL Architecture
Use libraries in the ANDRIOD system, strip Linux drivers located in kernel space, and then andriod the application.
The basic principle of HAL is to use the library to invoke kernel space Linux drivers in the Android system.
5. Add HAL to the LED: Migrate all business logic from the LED driver to the HAL module, while the LED driver module only retains the engineering performance of the read-write register. Joining HAL makes the entire library of Linux drivers more independent and easier to maintain.
6. To write a Linux program driver that supports HAL:
1>linux driver;
2> writing Hal Library;
3> write the service Library.
7. Steps and principles for writing the HAL module:
1> Defining structs and macros
3 important structural bodies hw_module_t, hw_device_t, hw_module_methods_t
2> writing the HAL module's Open function
The Open function is the entry point for the HAL module. Initializes the hw_device_t of the structure; open the device file; Initialize the Register
3> defining hw_module_methods_t struct-body variables
The HAL module requires an open function pointer variable of the hw_module_methods_t struct to specify the open entry function
4> Defining HAL_MODULE_INFO_SYM Variables
The ID represents the identity in the Android system in the HAL module. Locate and load the HAL module by ID.
The methods variable needs to point to the address of the hw_module_methods_t struct defined in step 3rd, and when the caller finds and loads the HAL module through the ID, it finds the hw_module_methods_t struct through the methods variable and calls the Hw_ The Module_methods_t.open function.
5> writing the close function of the HAL module
The close function is called when the HAL module is unloaded
6> writing a function to control LEDs
Depending on the type and function of the device, write the appropriate function
Nineth Hardware Abstraction Layer: HAL notes