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