Linux driver features Basics

Source: Internet
Author: User
Linux driver features basics-Linux general technology-Linux programming and kernel information, the following is a detailed description. Linux provides a unified abstract interface for applications through the device driver, which hides the differences and details between a large number of different devices. In Linux, the operations on hardware devices are the same as those on common files, you can use standard file operations to open, close, read, or write data to a device. Each device in the system is represented by a special device file. For example,/dev/hda represents the first IDE hard disk in the system. Each device controlled by the same device driver has the same master device number, the secondary device number is used to distinguish different devices of the same type. The Virtual File System (VFS) index node of the special File of the device contains the device number information, if you access a device through a system call, the kernel calls the appropriate device driver through the device number information summarized by the VFS index node.

In Linux, devices are divided into character devices (char device), block devices (block), and network devices (net device). Character devices are not cached during access, for devices that can be accessed like files, character device drivers must at least implement open, close, read, and write system calls. Character terminals (/dev/console) and system serial ports (/dev/tty0) are character devices. Character devices can be accessed through file system nodes. The only difference between a character device and a common file is that access to a common file can move the access pointer before and after, most character devices can only access data in sequence.

Like character devices, Block devices are also accessed through file system nodes in the/dev directory. Linux allows applications to read and write Block devices like character devices and transmit any multibyte data at a time. The difference between a block device and a character device lies only in the way in which data is managed in the kernel, that is, the interfaces of the kernel and the driver are different. The differences between these devices are transparent to users. In addition, block device read/write needs to be supported by caching. It can only be read and written in block units and can be accessed randomly, no matter where the required block is on the device, it can be read and written, character devices do not have this requirement. Block equipment mainly includes hard disk, floppy disk, CD-ROM and so on.

Network devices are not stream-oriented devices and are specially processed in Linux. Users cannot access them through file device contacts, in addition, the communication between the kernel and the network driver is completely different from that between the kernel and character devices and Block devices. The kernel calls a set of functions related to data packet transmission to process network devices.

Although there are many different types of device drivers in the Linux kernel, they all share some common features:

(1) Core code: the device driver is a part of the core. Like other code in the core, an error will cause serious damage to the system. An improperly compiled device driver can even cause system crashes, resulting in damage to the file system and data loss;

(2) Core interface: the device driver must provide a standard interface for the Linux core or its sub-systems;

(3) Core Mechanism: device drivers can use standard core services such as memory allocation, interrupted sending, and waiting for peer columns;

(4) Dynamic Loading: most Linux device drivers can be loaded when the core module sends a loading request and uninstalled when the device is not used, in this way, the core can effectively use system resources;

Configurable drivers: Linux device drivers are part of the core. You can configure the driver as needed.

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.