Six, the first Linux driver: Count the number of words-study notes

Source: Internet
Author: User

6th. First Linux driver: Count the number of words-study notes

First, let's look at:

Printer drivers Write data: For printer drivers, you need to receive these written data and send them to the printer via the PC's port, USB, and other ports. Implementing this process requires that the Linux driver respond to the data passed by the application. This is the Linux-driven event, although there is no concept of events in C, but there is a concept similar to events, which is called the callback (callback) function. Therefore, the most important step in writing a Linux driver is to write a callback function, otherwise data that interacts with the device file will not be processed. Figure 6-1 is the relationship between application software, device files, drivers, and hardware.

Ii. steps to write a Linux driver

The Inux driver has its own rules as well as other types of Linux programs. Readers who are just starting to get in touch with Linux driver development may not know much about how to develop a Linux driver. To address this confusion, this section provides general steps for writing a basic Linux driver. Readers can follow these steps to learn about Linux driver Development Step-by-step.

1th Step: Build Linux driver skeleton (load and unload Linux drivers)

2nd step: Registering and unregistering device files

3rd Step: Specify driver-related information

4th step: Specify the callback function

5th step: Writing Business logic

6th step: Writing the Makefile file

7th step: Compiling Linux drivers

8th step: Install and uninstall Linux drivers

Iii. preparation before writing Linux drivers

First use the following command to build the directory where the Linux driver is stored.

Then use the following command to build the driver source code file (word_count.c)

Finally write a makefile file, which is actually the 6th step in writing the Linux driver described in section 6.2.

Iv. writing the skeleton of a Linux driver

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.

Ast;mso-hansi-theme-font:minor-fareast ' >3 configuring wired networks because Android is inherently Linux, you can use the Linux command ifconfig to set the IP mask and subnet mask, Set up the gateway with the rout command.

Six, the first Linux driver: Count the number of words-study notes

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.