Linux-driven work and access is one of the highlights of Linux, and has been widely praised by the industry. The Linux system maps each driver into a single file. These files are called device files or drive files and are saved in the/dev directory. This design concept makes interacting with Linux drivers as easy as interacting with ordinary files. Of course, it's easier than visiting Linuxapi. Since most Linux drivers have their corresponding device files, exchanging data with the Linux driver becomes the exchange of data with the device files. For example, to send a print command to a Linux printer driver, you can open the device file directly using the C function open, and then make the hepatic C function ioctl send the Print command to the drive's device file.
The Word_count driver for counting the number of words is the implementation of a full Linux drive. Although the functionality of the Word_count driver is not complex, it is enough to allow the Linux driver to understand the full development process of Linux drives before it has ever been exposed. 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 Linux. There are many drivers that can be installed directly on Android, Linux and other embedded systems as long as they are compiled with the corresponding Linux kernel. Of course, you can also test Linux drivers directly on the Android emulator, the Development Board, or even your phone.
Android Deep Exploration and Driver development (VI)