Seventh chapter I/O

Source: Internet
Author: User

Although Linux drives deal directly with hardware, it is not the Linux driver that writes data directly to the hardware's memory, but interacts with the native I/O. The so-called I/O memory is a mapping in memory that is connected to the host through various interfaces.

The Linux kernel provides multiple functions that interact with I/O memory. Each hardware connected to Linux has a map header address in I/O memory.

To create an LED-driven device file:

First step: Initialize the Cdev with the Cdev_init function

Step Two: Specify the device number

Step three: Use the Cdev_init function to add a character device to the character device array in the kernel

Fourth step: Create a struct class using the Class_create macro

Fifth step: Create a device file using the Device_create function

Uninstalling a Linux-powered device file is a bit simpler and requires a call to the Device_destroy Class_destroy Unregister_chrdev_region method.

LED drivers have two ways of interacting with device files: writing string data directly and I/O control commands. Writing data directly to a device file can be done using the command line, or through the write function.

NDK Program tests and executable program tests are similar. But the NDK Library can be called by Java programs, and the most straightforward way to test Linux drivers on an Android system is to use the NDK.

A complete Linux driver consists mainly of internal processing and interaction with hardware. The internal processing mainly refers to the Linux driver loading, unloading, device file-related motion processing and business logic.

Seventh chapter I/O

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.