usb驱动开发15——设备生命线

本文详细探讨了USB驱动开发中的关键结构体`struct usb_hcd`和`struct usb_bus`,阐述了两者之间的关系以及在Linux设备模型中的作用。通过对`struct usb_bus`成员的分析,揭示了USB总线的编号、名称、DMA支持以及带宽管理等核心概念,并介绍了如何在设备模型和sysfs中体现。此外,还提到了USB监视器在内核中的实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

总算是进入了HCD的片儿区,既然来到一个片区,怎么都要去拜会一下山头几个大哥吧。,先回忆一些我们怎么到这里的?给你列举一个调用函数过程usb_control_msg->usb_internal_control_msg->usb_start_wait_urb->usb_submit_urb->usb_hcd_submit_urb。这个山头儿,王中之王就是drivers/usb/core/hcd.h里定义的struct usb_hcd。

/*-------------------------------------------------------------------------*/

/*

* USB Host Controller Driver (usb_hcd) framework

*

* Since "struct usb_bus" is so thin, you can't share much code in it.

* This framework is a layer over that, and should be more sharable.

*/

/*-------------------------------------------------------------------------*/

struct usb_hcd {
   

/*

* housekeeping

*/

struct usb_bus self; /* hcd is-a bus */

struct kref kref; /* reference counter */

const char *product_desc; /* product/vendor string */

char irq_descr[24]; /* driver + bus # */

struct timer_list rh_timer; /* drives root-hub polling */

struct urb *status_urb; /* the current status urb */

#ifdef CONFIG_PM

struct work_struct wakeup_work; /* for remote wakeup */

#endif

/*

* hardware info/state

*/

const struct hc_driver *driver; /* hw-specific hooks */

/* Flags that need to be manipulated atomically */

unsigned long flags;

#define HCD_FLAG_HW_ACCESSIBLE 0x00000001

#define HCD_FLAG_SAW_IRQ 0x00000002

unsigned rh_registered:1;/* is root hub registered? */

/* The next flag is a stopgap, to be removed when all the HCDs

* support the new root-hub polling mechanism. */

unsigned uses_new_polling:1;

unsigned poll_rh:1; /* poll for rh status? */

unsigned poll_pending:1; /* status has changed? */

unsigned wireless:1; /* Wireless USB HCD */

int irq; /* irq allocated */

void __iomem *regs; /* device memory/io */

u64 rsrc_start; /* memory/io resource start */

u64 rsrc_len; /* memory/io resource length */
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kcyuan

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值