Linuxeach driver is mapped to a file called a device file or a drive file, which is saved in/ Devthe directory. Linuxthe way drivers work and access isLinuxOne of the highlights, at the same time by the industry's wide acclaim. Linuxthe system maps each driver into a single file. These files, called device files or drive files, are saved in the/ Devthe directory. This design concept makes it possible toLinuxThe driver interacts as easily as interacting with ordinary files. Of course, than to visitLinuxapimore easily. Since mostLinuxdrivers have their corresponding device files, so theLinuxthe drive Exchange data becomes the exchange of data with the device file.
The steps for writing a Linux driver are as follows:
1.build linux Drive skeleton (load and unload Linux drivers).
2, registration and cancellation of equipment files.
3, specify the information related to the drive.
4, specify the callback function.
5, write business logic.
6, write makedile file.
7, write the Linux driver.
8.Install and uninstall Linux drivers.
This chapter also describes how to use different methods to testLinuxDrive. These methods are mainly differentiated by platform. For example, you can directly useUbuntu LinuxTestLinuxDrive. There are a lot of drivers that only use the correspondingLinuxThe kernel compiles one side and can be installed directly on theAndroid,Linuxand other embedded systems. Of course, you can also directlyAndroidsimulators, boards and even mobile testsLinuxDrive. In order to develop fasterLinuxmay also consider the use of6.5section describes theEclipseintegrated development environment.
the way Linux drives work is interaction. For example, to send a print command to the Linux printer driver, you can open the device file directly using the C language function Open, The C - language function IOCTL sends a print command to the drive's device file. the most important thing to write a Linux driver is to write a callback function, otherwise data that interacts with the device file cannot be processed.
First Linux driver: Count the numbers of words