2 USB questions (endpoints and implementation to PC architecture)

I would like to ask two things I still don't get after reading many articles on USB, including the official USB 2.0 specs.

  1. What exactly is endpoints and what is their purpose ? Let me explain a bit: From what I understood, an endpoint is source or destination of data. I don't want to be rude, but my head hurts because I cannot really understand why. I mean, USB is a serial bus, so it should only care about delivering data to the proper destination. A destination is a device. Why include multiple destinations in one device in the form of endpoints? I mean, the USB device can then manage data the way it wants, to any logical structure developer wants, so why to add it to transfer specs?

  2. In USB host on PC, there is that USB host loads appropriate drivers to device. So, lets say I plug in some USB custom class device. The USB host driver will then get its IDs and so, and after knowing the device it should load its drivers. But I thought that device drivers are present in kernel, so how can drivers be additionally loaded?

Furthermore, let's say my USB host is connected to PC via PCI. So my USB host device will generate some PCI interrupt to get attention of OS, and than OS first must load USB host driver. Isn't this too slow process? I mean, yes even USB 3.0 is MUCH slower than CPU can handle, but still...

2 Answers

1, What exactly is endpoints and what is its purpose? Let me explain a bit: From what I understood, endpoint is source or destination of data. But, WTF? I dont want to be rude, but my head hurts becouse I cannot really understand why. I mean, USB is serial bus, so it should only care about delivering data to proper destination. Destination is device. Why to more include multiple destinations in device in form of endpoints?

Yes, the "endpoint" is a just a USB concept, namely the endpoint of a connection to a device.

The reason a device can have multiple endpoints is that there may be multiple kinds of communication going on at a time, for example control data and actual device data. To separate these, multiple endpoints are needed (a bit like the data+control channel which FTP uses).

"USB in a nutshell" explains this quite nicely:

2, In USB host on PC, there is that USB host loads apropriate drivers to device. So, lets say I plug in some USB custom class device. USB host driver will than get its IDs and so, and after knowing the device it should load its drivers. But I thought that device drivers are present in kernel, so how can be additionally loaded?

Usually only the low-level USB drivers are built into the kernel. Higher-level drivers, particularly vendor-specific drivers are loaded on demand. How this works depends on the OS, but most modern OS can load drivers into the kernel at runtime, e.g. Linux using modules, or Windows using the Windows Driver Model.

Furthermore, lets say my USB host is connected to Pc via PCI. So my USB host device will generate some PCI interrupt to get attention of OS, and than OS first must load USB host driver. Isn´t this too slow process? I mean, yes even USB 3.0 is MUCH slower than CPU can handle, but still...

That question is not quite clear. Yes, the OS must load drivers, and yes, this may take some seconds, but it is only done once. And PCI will not be a problem, because PCI is much faster than even USB 3.0.

5

If I understand the question correctly, perhaps these questions might illuminate things:

How should a USB hub announce itself?

How should a device that emulates multiple devices (e.g. a keyboard + trackpad) announce itself?

For the second item, I can only speak from what I know about Linux, but the driver is loaded from disk into kernel the first time it is needed (if it is modular), but from that point out it is in memory. This means fast response times, but potentially sluggish setup times. That seems normal / acceptable to me.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like