Sixth. First Linux driver: Count the number of words

Source: Internet
Author: User

Linux drives work and access is one of the highlights of Linux, and the Linux system maps each driver into a single file, which is called a device file or driver file, and is stored in the/dev directory. This design concept makes interacting with Linux drivers as easy as interacting with ordinary files. The Linux driver 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.

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.

The next step is to write the driver: count the number of words. Before you write a Linux driver, make some preparations to put the driver source code in a single directory. It is generally necessary for Linux drivers to 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. First Linux driver: Count the number of words

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.