Deep understanding of the Linux kernel-I/O architecture and device drivers

Source: Internet
Author: User
Tags call back

System bus:
1. Link the data flow between CPU, RAM, I/O devices. For example: PCI, ISA, EISA, MCA, SCSI, USB
2, any i\o device has and can only link a bus.

I\o Port:
1. Each device connected to the I\O bus has its own set of i\o addresses, often referred to as i\o ports.
2, a total of 65,536 8-bit ports
3, can speak 2 8-bit as a 16-bit (must start from the even), 2 16 bits as a 32-bit port (must start from 4 times times)
4. Read and write commands in, ins, out, outs to port
5, in order to improve performance to provide control register, status register, input register, output register

I\o Interface:
1, dedicated I\o interface: dedicated to a specific hardware device; keyboard interface, graphics interface, disk interface, mouse interface, network interface
2, Universal I\o Interface: Used to connect a number of different hardware devices, usually external devices. Port, serial, PCMCIA interface, SCSI interface, USB

Device Controller:
1, complex equipment needs, typical disk controller, can be used to resolve advanced commands, converted to processing disk low-level disk operations.
2, simple equipment does not need, such as programmable interrupt Controller, programmable interval timer.
Device Driver Model:1, Power Management (control of different voltage levels on the power line of the device)
2. Plug and Play (transparent resource allocation when configuring the device)
3, Hot plug (System runtime support device insertion and removal)
4, the kernel is solely responsible for the power management of all hardware devices, when the computer enters standby, the kernel immediately forces each to respond to the ' standby ' status of the device installed in a certain order to enter the standby state
5, in order to meet the above functions, for all the bus, equipment and device drivers in the system provides a unified view, that is, the device driver model.

Device files:
1. i\o device can be treated as a special file called device file, which can use system call to read, write
2, according to the basic characteristics of the device driver, device files can be divided into two blocks and characters
3, block device data can be randomly accessed, the transfer of data less time, and roughly the same. such as hard disks, floppy disks, CD-ROM drives, DVD players, etc.
4, the character device data or can not be randomly accessed, or can but access to random data is largely dependent on the location of the data within the device, such as tape drives
5, the general device file name is irrelevant, the key is the device type, the main device number, the secondary device number
6, the main device number and the second device number is 65536,linux maximum
2.6 Extended main device number 12 bit, secondary device number 20 bit
7, the best solution when the dynamic allocation of device numbers; Dynamic creation of device files


Device drivers:
1. Foo_read function for implementing the Read method of the File object
2. Foo_interrupt function for processing interrupts
3, when the user issued a read system call on the device file, a command is sent to the control register of the device, after a period of time, the device puts a byte of data into the input register, as a result of the read system call back

Direct access to Memory (DMA):
1, not through the CPU, the device directly and RAM data transfer
2. If the DMA and CPU access the same memory simultaneously, the conflict is resolved by the hardware circuit called the memory arbiter.
3, the most used is the disk drive and other need to transfer a large number of bytes of equipment.
4, the DMA setting time is longer, a small amount of data use CPU more efficient
5. The synchronization DMA is triggered by the process, such as playing movies, music, when playing music, the memory data with DMA to the sound card playback
6, asynchronous DMA has a hardware device trigger, such as network card, network card received data, interrupt, the data DMA to the memory

I\o levels supported by the kernel:
1, not supported at all: The application can only use the appropriate in, out assembly language directly with the device i| O Port Interaction

2, Minimum support: The kernel does not recognize the hardware device, but can identify the I\o interface, the user program treats the I\o interface as a sequential device capable of reading and writing streams
3, Extended Support: Internal nuclear power identification hardware, and processing i\o interface itself. This device may not have a corresponding device file.

Character Device drivers:
1, relatively simple, does not involve complex to cache policy, disk cache
2, some must achieve complex to the communication protocol

Deep understanding of the Linux kernel-I/O architecture and device drivers

Related Article

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.