Linuxthe way drivers work and access isLinuxOne of the highlights,Linuxeach driver is mapped to a file, which is called a device file or driver file, and is saved in/ Devthe directory. This design concept makes it possible toLinuxThe driver interacts as easily as interacting with ordinary files. LinuxThe drive Exchange data is the device file Exchange data. In the case of device file interaction, you must write a callback function or the device file cannot be processed. WriteLinuxthe steps for the driver are as follows:1, establishLinuxdrive skeleton (load and unloadLinuxDrive). 2, registering and unregistering device files. 3, specifying driver-related information. 4, specifying a callback function. 5, and write business logic. 6, writingMakedilefile. 7, writingLinuxdrivers. 8, install, and uninstallLinuxDrive. The next step is to write the driver: count the number of words. In writingLinuxbefore the driver is ready to do some work, separate the driver source code in a directory. AAs required for Linux drivers, specify the following information: modules are specified using the module AUTHOR macro. Module Description: Specified using the module DESCRIPTION macro. Module aliases: Specified using the module alias macro. The open source protocol is specified using the MODULE LICENSE macro. In addition to this information, the Linux driver module itself contains this information. The Word_count driver for counting the number of words is the first complete Linux drive implemented in this book. Although the functionality of Word_count is not complex, it is enough to allow developers who have never been in touch with inux drivers to understand the complete development of Linux drivers. This chapter not only introduces an example, but also describes how to test Linux drivers using different methods. These methods are mainly differentiated by platform. For example, you can test Linux drivers directly using Ubuntu inux. There are many drivers that can be installed directly on an embedded system such as Android, just by using the corresponding Linux kernel to compile one side.
Sixth: The first Linux driver: Count the number of words