首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么Linux将USB主机控制器的供应商列为"Linux基础“?

为什么Linux将USB主机控制器的供应商列为"Linux基础“?
EN

Unix & Linux用户
提问于 2020-11-14 23:21:30
回答 1查看 1.1K关注 0票数 5

在USB主机控制器连接到PCI/PCIE总线的任何PC上,我看到以下内容:

代码语言:javascript
复制
$ cat /sys/bus/usb/devices/usb1/{idVendor,idProduct,manufacturer,product,serial}
1d6b
0002
Linux 4.14.157-amd64-x32 ehci_hcd
EHCI Host Controller
0000:00:1a.0

例如,EHCI主机控制器(在本例中具有PCI设备位置0000:00:1a.0 )用一组伪字符串描述符和供应商/产品标识符表示。在1d6b中查找供应商id usb.ids,我发现它对应于Linux。(lsusb将其列为“LinuxFoundation2.0根中心”)。但是serial引用的PCI设备是真实的,具有以下属性:

代码语言:javascript
复制
$ cat /sys/bus/pci/devices/0000:00:1a.0/{vendor,device}
0x8086
0x8c2d

pci.ids中查找这些in,我们可以发现它是Intel 8系列/C 220系列芯片组家庭USB (与lspci所说的相同)。一个真正的HW制造商的真正的硬件。

那么,为什么Linux用一些奇怪的ids来表示这个Intel硬件呢?我意识到PCI和USB厂商/产品ids可能会发生冲突,因此不可能使用PCI命名空间中的ids启动USB设备树。但是为什么是字符串描述符呢?

我猜这是因为名为"*HCI主机控制器“的整个USB实体是一个虚构的实体。但另一方面,它似乎有一个地址(总是=1),它从来没有分配给这个总线上新连接的设备。所以看起来这个USB实体可能有一些真实的东西。但保留的地址也可能只是簿记的一种方式。

我猜对了吗?主机控制器-作为USB实体-完全是虚构的吗?它从来没有作为一个实际的可寻址设备出现在电线上吗?或者它有什么真实的东西,我们实际上可以发送标准USB请求,而不是让内核简单地模仿它们的处理?

EN

回答 1

Unix & Linux用户

发布于 2022-09-26 14:13:09

Linux有一个允许主机控制器驱动程序共享代码的抽象。正如drivers/usb/core/hcd.c上的评论所言:

代码语言:javascript
复制
 * USB Host Controller Driver framework
 *
 * Plugs into usbcore (usb_bus) and lets HCDs share code, minimizing
 * HCD-specific behaviors/bugs.
 *
 * This does error checks, tracks devices and urbs, and delegates to a
 * "hc_driver" only for code (and data) that really needs to know about
 * hardware differences.  That includes root hub registers, i/o queues,
 * and so on ... but as little else as possible.
 *
 * Shared code includes most of the "root hub" code (these are emulated,
 * though each HC's hardware works differently) and PCI glue, plus request
 * tracking overhead.  The HCD code should only block on spinlocks or on
 * hardware handshaking; blocking on software events (such as other kernel
 * threads releasing resources, or completing actions) is all generic.
 *
 * Happens the USB 2.0 spec says this would be invisible inside the "USBD",
 * and includes mostly a "HCDI" (HCD Interface) along with some APIs used
 * only by the hub driver ... and that neither should be seen or used by
 * usb client device drivers.
 *

USB 1被分配给register_root_hub()中的根集线器,如下所示:

代码语言:javascript
复制
 * register_root_hub - called by usb_add_hcd() to register a root hub
 * @hcd: host controller for this root hub
 *
 * This function registers the root hub with the USB subsystem.  It sets up
 * the device properly in the device tree and then calls usb_new_device()
 * to register the usb device.  It also assigns the root hub's USB address
 * (always 1).

usb.ids数据库证实了这一点,该数据库指出,对于供应商Id 1d6b,产品Id 1、2、3分别对应于1.1、2.0和3.0根中心。

我们在Linux设备树中所拥有的是USB主机控制器(一个真正的设备)和USB根集线器(也是一个真实的设备)的混合,由上面讨论的USB框架抽象出来。

现在,一些与xHCI的现代系统也有EHCI控制器,英特尔公司的集成速率匹配中心总是连接在一起。这些不是根集线器,它们有地址2,而不是1。来自英特尔手册,第5.19.1章:

代码语言:javascript
复制
The Hubs convert low and full-speed traffic into high-speed traffic.
票数 2
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/619669

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档