Chinaunix首页 | 论坛 | 博客
  • 博客访问: 963549
  • 博文数量: 173
  • 博客积分: 3436
  • 博客等级: 中校
  • 技术积分: 1886
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-07 09:29
文章分类

全部博文(173)

文章存档

2016年(6)

2015年(10)

2014年(14)

2013年(8)

2012年(36)

2011年(63)

2010年(19)

2009年(17)

分类: BSD

2012-09-24 10:11:54

BSD usbconfig source code:

and lib code:

sys code:

so we may get all BSD related code in this repository:

Repository Root:



关于freeBSD下的USB驱动,
在/dev/usb/storage/目录下就有文件:
umass.c, urio.c, ustorage_fs.c
尤其是umass.c和ustorage_fs.c的区别:
分别有如下代码:

点击(此处)折叠或打开

  1. static int
  2. umass_probe(device_t dev)
  3. {
  4.     struct usb_attach_arg *uaa = device_get_ivars(dev);
  5.     struct umass_probe_proto temp;

  6.     if (uaa->usb_mode != USB_MODE_HOST) {
  7.         return (ENXIO);
  8.     }
  9.     temp = umass_probe_proto(dev, uaa);

  10.     return (temp.error);
  11. }


点击(此处)折叠或打开

  1. static int
  2. ustorage_fs_probe(device_t dev)
  3. {
  4.     struct usb_attach_arg *uaa = device_get_ivars(dev);
  5.     struct usb_interface_descriptor *id;

  6.     if (uaa->usb_mode != USB_MODE_DEVICE) {
  7.         return (ENXIO);
  8.     }
  9.     /* Check for a standards compliant device */
  10.     id = usbd_get_interface_descriptor(uaa->iface);
  11.     if ((id == NULL) ||
  12.      (id->bInterfaceClass != UICLASS_MASS) ||
  13.      (id->bInterfaceSubClass != UISUBCLASS_SCSI) ||
  14.      (id->bInterfaceProtocol != UIPROTO_MASS_BBB)) {
  15.         return (ENXIO);
  16.     }
  17.     return (BUS_PROBE_GENERIC);
  18. }
同样都是device的驱动,为什么mode不相同?求高人指点。

answer from HPS:
umass.c is providing a class HOST driver for memory sticks.
ustorage_fs.c is providing a class DEVICE driver for memory sticks, I.E. emulating a memory stick. Of course you need a host controller which supports this, typically called OTG or USB device controllers.
--HPS

Normal 0 false false false EN-US ZH-CN X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";}


阅读(1197) | 评论(0) | 转发(0) |
0

上一篇:FreeBSD查看硬件信息

下一篇:USB iso bInterval

给主人留下些什么吧!~~