"Android Deep Exploration" Vol. 1 eighth note 1314 Wang Ning

Source: Internet
Author: User

Eighth Reading notes

1.compilation is a Linux driver composed of multiple files (static reuse)

For complex Linux Drivers, it is necessary to use multiple source code files to store different function codes, which facilitates the classification and management of the code, then you must compile multiple source code files and eventually build the . Ko file or compile it into Linux Kernel

below, the introduction will 3 .c files are compiled as 3 .O file, and put this 3 .O link Span style= "Font-family:helvetica;" ) into a .ko file --

2 . Reliance on Linux driver modules (dynamic reuse)

In one drive module, the exported symbols in another drive module are used, as usual, variables, functions, etc.

The next learning is to forcibly uninstall the Linux driver, only uninstall due to uninstall exceptions caused by the Linux driver module can not be unloaded properly. Scenario 1: Initialization function crash Scenario 2: unload function blocking

The PWM driver consists of three files:PWM. C,pwm-fun.h,pwm-fun.c, wherein pwm.c is the driver main program.

3. Forcibly uninstall Linux Drivers

Scenario 1: initialization function crashes

Because the initialization function of the Linux driver module crashes, which causes the initialization function not to return normally, this is the case that the current Linux driver module has not been The Linux driver module is used, but the display has been applied once . This occurs because the value of the reference counter is inconsistent with the reference. You only need to clear the reference counter of the current Linux driver module to 0.

Scenario 2: The Unload function is blocked

When uninstalling the Linux driver using the rmmod command , the system calls the Unload function, and only if the Unload function returns successfullywill theLinux driver be uninstalled. If the Unload function is blocked,the rmmod command will also be blocked, which means that the code to unload the Linux driver module will never be executed , which is performed The rmmod command will stop there and will never return to the operating prompt of the system . The workaround is to unload the function, just replace the original unload function with an empty unload function

"Android Deep Exploration" Vol. 1 eighth note 1314 Wang Ning

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.