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

Source: Internet
Author: User

General steps for writing a Linux:

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

2nd step: Registering and unregistering device files

3rd step: Specify and drive 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

When writing a makefile file obj-m means compiling the Linux driver as a module (. ko file), and Obj-y is compiling the Linux driver into the Linux kernel; obj-m or obj-y need to use ": =" assignment. The Make Menuconfig command allows you to configure whether each driver and other kernel programs are allowed to be compiled into the kernel. Linux system memory is divided into user space and kernel space, these two space programs can not be directly accessed. The printf function runs in user space, and the PRINTK function runs in kernel space, so Linux drivers that belong to kernel programs do not have direct access to printf functions, while user-space programs

You cannot call the PRINTK function directly. If you compile the Linux driver using a modular approach, you need to

Use m to specify the directory where the driver is located. For example, the following command is used to view the log information exported by the Linux driver:

# DMESG | grep Word_count | Tail-n 2

Or

# Cat/var/log/syslog | grep Word_count | Tail-n 2

Using Modinfo to view information about a. ko file, the device file is described by the main device number and the secondary device number.

6th. 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.