Sixth: The first Linux driver: Count the number of words

Source: Internet
Author: User

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

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.