Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to ask to things I still don´t get after reading many articles on USB, including oficial USB 2.0 specs.

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? I mean, USB device can than manage data whatever 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 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?

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...

Thanks for any answer, please if you know something about enpoints help, second question is more theoretical. Thanks again :)

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

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: http://www.beyondlogic.org/usbnutshell/usb3.htm

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.

share|improve this answer
1  
Nice answer, but one correction about the latter question. Yes, the whole interrupt handling process would be incredibly slow if host would be waken up for each USB request. So PCI (and it descendants like PCI-E) has a technique called Bus Mastering: the OS selects a memory region and then PCI device reads or writes data to that region without interrupting the CPU. As bus frequency is around 800MHz and single transfer involves, IIRC, 32 or 64 bits (correct me if I wrong), this can satisfy the needs for even very fast peripherals. (Probably the OP mistyped "load" for "call"). –  whitequark Aug 1 '10 at 22:20
    
Can I have question on this? When PCI device writes into memory, how is solved priority between PCi and CPU access? I mean, when CPU wants to access memory, does it have bigger priority, hence PCI device must wait until CPU is done? And second, when there is no interrupt involved, how does OS know when to switch back to driver for handling that data in RAM? Thanks. –  user32569 Aug 1 '10 at 22:26
    
To the endpoint answer, if I can ask little more, I read that articles, USB in nutshell, but I didn´t understood it. Becouse, you could diferentiated control transfer from data by its structure. Than device would first determine transfer type and than save it to right place. I just need to find some reason why to use endpoints, which would not been able to so in software instead of bus-signaling part.... –  user32569 Aug 1 '10 at 22:32
    
@b-gen-jack-o-neill: About PCI/CPU priority: Yes, there is a mechanism so CPU and other devices can coordinate RAM (or more precisely: bus) access. I don't know the specifics, though. As to endpoints: Sorry, can't help there. Maybe it was just a simpler design that way... –  sleske Aug 1 '10 at 22:37
    
Thanks. I thought it once again, and maybe I got asnwer. Maybe, this design is used to over-simplify it. So, you can just use USB HW to do all this stuff and endpoints are just output ports of that HW chip. I always considered MCU software USB, but maybe in hardware its all different. I need to look to some dedicated USB chip, but bad thing is that most of them are SMD version, thus really hard to mess with at home.... –  user32569 Aug 2 '10 at 11:10
add comment

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.

share|improve this answer
    
Well, but I can answer these questions - USB hub announce itself special control packet, the very presence of it, the special type of packet should be diferentiated from data. How to emulate multiple devices? Simple, from what I know you cannot. You cannot assign different VID and PID pairs for different endpoints. Devices that have multiple functionality uses internal USB hub. So, driver can be loaded to kernel like dll? I though that reason I must restart PC after every driver instalation is that you cant do it. –  user32569 Aug 1 '10 at 21:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.