Read the Android system source Scenario analysis notes (i)

Source: Internet
Author: User

android2.3 System driver module consists of kernel module, Hardware abstraction module, user call Module (JNI), kernel module and Linux, Hardware abstraction module need to define two structure: hw_module_t and hw_device_t.

hw_module_t contains the module ID, version number, signature, and a function pointer:

int open (struct hw_module_t* module, const char* ID, struct hw_device_t** device);

hw_device_t contains the version, the hw_module_t reference, and a function pointer:

int close (struct hw_device_t* device);

You must export a hal_module_sym symbol to reference the hw_module_t structure. These two structures can be customized by defining the two structures at the beginning of the custom structure (c idioms).

The user calls the module to load the hardware abstraction module through the Hw_get_module function.

int Hw_get_module (const char* ID, const struct hw_module_t** module);

The second parameter module receives the hardware abstraction module exported by the symbol hal_module_sym to the struct body.

The user invokes the module to open the device with the specified ID through its provided opening method, and the second parameter device receives a hw_device_t structure. The open function can return different hw_device_t structures depending on the device, and the close function may be different.

The user then invokes the module to call close or a custom function for closing or other operations through hw_device_t or a custom structure. Because it is at the user level, you need to modify ueventd.rc to modify the access rights of the device files provided by the kernel module.

Read the Android system source Scenario analysis notes (i)

Related Article

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.