Write Linux drivers and count the number of words

Source: Internet
Author: User

First, the steps to write a Linux driver

1. Build Linux Drive skeleton: that is, load and unload Linux drivers. In the Linux driver, you need to provide two functions to handle the operation of the driver initialization and exit separately. These two functions are specified by Module_init and module_exit macros, respectively.

2, registration and destruction of equipment files: Any Linux driver requires a device file, because the devices in Linux exist as files. Use the Misc_register and Misc_deregiter functions to create and remove device files.

3. Specify driver-related information: The driver is self-describing. The driver's name, the open source protocol used, the alias, the driver description, and so on are all required to be specified in the driver source code.

4. Specify the callback function: The Linux driver contains a variety of actions, that is, events. However, it is not necessary to specify all the callback functions, which are registered through the relevant mechanism.

5. Write business logic: This is the core part of the Linux drive. Any full Linux driver will do some work related to its functionality.

6, write makefile file: Linux kernel source code compilation rules are defined by the makefile file. Therefore, a Linux driver must have a makefile file.

7. Compiling Linux Drivers

8. Install and uninstall Linux drivers: Use the Insmod or modprobe command to load the driver module. Use the Rmmod command to unload the driver module.

Second, the statistics of the number of words drive

First build the Linux driver skeleton: Now write the skeleton part of the Linux driver, which is the 1th step described earlier. The skeleton section is primarily the initialization and exit functions of the Linux driver. After you have written the driver, you can test it, and the Linux driver is not necessarily done on Android devices. Because Android and Ubuntu Linux and other Linux distributions are based on the Linux kernel, most Linux drivers are available in Ubuntu Linux or other Linux distributions are tested and then re-compiled into an arm-based target file by the cross-compiler and then installed on Android for normal operation.

  

?

Write Linux drivers and count the number of words

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.