Relationship among bus, device, and driver

Source: Internet
Author: User

Relationship among bus, device, and driver

Bus:
As the connection channel between the host and peripherals, some buses are relatively standard and form many protocols. For example
PCI, USB, 1394, IIC, etc. Any device can select a suitable bus to connect to the host. Of course, the host may be the CPU itself. The memory is also connected to the host through the bus.
The bus used is not a peripheral bus, so it is vague to talk about bus devices that use the same type of bus as the memory.
An ENI is directly connected to the CPU through the memory bus in embedded development. When writing the NIC Driver, It is troublesome to define the bus.

Driver:
A driver is a software interface that provides operations when the CPU is running. All devices must have drivers to work properly. A driver can drive multiple similar or completely different devices.

Device:
A device is a physical entity connected to the bus. Devices have different functions. Devices with the same features are classified into a class ). Such as audio equipment (sound-related), input equipment (mouse, keyboard, game pole, etc )....

From a macro perspective, any device must be connected to the host to play its role. When one mouse leaves the computer host, it is no longer a mouse. When it comes to connection, the bus will inevitably appear. Software support is required for the normal operation of any device, and driver is required for all devices. The purpose of a device is to complete the function. According to the function classification, the device must belong to a certain class.

1. The three are defined in include/Linux/device. h.

2. How are the two linked lists in the bus formed:

This requires that each time a device appears, it should be reported to the bus, or registered. Each time a driver appears, it should also be reported to the bus, or registered. For example, when the system is initialized, It scans which devices are connected and
Each device creates a struct device variable. Each time there is a driver, a struct is required.
Device_driver structure variable. Add all these variables to the corresponding linked list, and insert the device into the devices
Linked List, driver inserted into the drivers linked list. In this way, each device and driver can be found through the bus. However, if only the device in the computer has no corresponding driver, the device cannot work.
. In turn, if only the driver has no device, the driver will not play any role.

3. The two linked lists on the bus already exist. How are the device and driver in the linked list linked?
Each device to be used has been inserted before the computer starts. It is inserted to the location where it should be, and then the computer starts, the operating system starts initialization, and the bus starts scanning the device, each time a device is found, a struct device structure is applied for it and mounted to the devices linked list in the bus.
;

Then each driver starts initialization and starts
Register its struct
Device_driver structure, and then it goes to the devices linked list of the bus to find (traverse), to find every device that has not been bound to the driver, that is, struct
Struct in Device
The device_driver pointer is still null, and then it will observe the characteristics of the device to see if it is a device that he supports.
The device_bind_driver function.
In other words
The driver points to this driver, and the struct device_driver driver adds the struct device to his struct
In the klist klist_devices linked list. In this way, the bus, device, and driver, or the two of them, are connected.

4. Hot swapping:

The device can be inserted or pulled out after the computer is started. Therefore, it is difficult to say that there are
The driver is available for device first. Because it is possible. Device can appear at any time, while driver
It can also be loaded at any time.
Device is born, it will go to the drivers linked list of the bus to find its other half.
When the device_driver was born, it went to the devices linked list of the bus to find its devices. If a suitable one is found, then OK, call
Device_bind_driver is bound.

Http://blog.csdn.net/yinkaizhong/archive/2009/02/16/3896383.aspx

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.