The Nineth chapter:
As long as you're talking about hardware abstraction Layer Hal,hal is a set of libraries built on Linux drivers. Hal is not part of the Linux kernel but is located on the Android system runtime layer. The first thing to say is the benefits of joining HAL. Includes: Unified hardware call excuse, to solve the GPL copyright issues, for some special requirements. The basic principle of the HAL architecture is to use libraries in the Android system to invoke Linux drivers located in kernel space, and then the Android application can access the libraries in the HAL through the NDK program, or access the libraries in the HAL directly in the Android application. The location of the Android HAL source code store is not fixed and is typically stored in the Android source directory medium. The final compiled. So file is primarily placed in the/SYSTEM/LIB/HW directory of the Android system.
The general steps for writing a Linux driver that supports HAL are: The first step: writing Linux drivers, and when adding HAL for Linux drivers to protect sensitive data, the Linux code needs to be concise to put the business logic into the HAL Library. Step two: Write the HAL Library, which is the normal Linux library file, and the Service Library locates the HAL by the ID defined in the interface. Step three: Write the service Library. ServiceManager calls the service library,apk program to call the Servicemanger class to access the service Library. Each part of the program should be tested in the process of writing Linux drivers and driver-related programs.
Writing HAL module steps and principles: First step: Define struct and macro, step two: Write Hal module Open function, step three: Define hw_module_methods_t struct variable, fourth step: Define HAL_MODULE_INFO_SYM variable, Fifth step: Write the HAL module close function, step sixth: write the control led function.
Android Deep explore HAL and Driver Development-—— 9th Chapter