Android Deep Exploration (Vol. 1) HAL and Driver Development--Reading notes (sixth)

Source: Internet
Author: User

How Linux drives work: Linux systems map each driver into a single file. These files are called device files or drive files and are saved in the/dev directory. For the driver, it is necessary to receive these written data and send them to the PC's wellhead, USB and other ports to the device. Implementing this process requires that the Linux driver respond to the data passed by the application. This is the Linux-driven event, which is the callback (callback) function.

    1. To write a Linux driver:

1) build Linu x Drive skeleton (load and unload Linu x drive):. The Linux kernel needs to load the driver first when it uses the driver. Some initialization work is required during the loading process.

2) registering and unregistering device files: Any Linux driver needs to have ← device files, otherwise the application will not be able to interact with the driver.

3) will specify driver-related information: The driver is self-describing.

4) Specify a callback function: The Linux driver contains a variety of actions, which can also be called events. A driver does not necessarily specify all the trap functions. The callback function is registered through the relevant mechanism.

5) Write business logic: Any full Linux driver will do some work related to its functionality, and the COM driver will interact with the data at the rate of transfer. The specific business logic is related to the function of the driver. The business logic may consist of multiple functions, multiple files, or even multiple Linux driver modules. The specific implementation of the reader can be based on the actual situation.

6) Write the makefile file: The Linux kernel source code compilation rules are defined by the makefile file.

7) Compile Linux drivers: Linux drivers, you can compile the kernel directly, or it can be compiled separately as a module.

8) Install and uninstall Linux drivers: If the Linux driver is compiled into the kernel, the driver will automatically load as soon as Linux uses the kernel. If the Linux driver exists separately in the module, you need to load the Linux driver module with the Insmod or Modprobe command, and use the Rmmod command to uninstall the Linux driver module.

Android Deep Exploration (Vol. 1) HAL and Driver Development--Reading notes (sixth)

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.