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的区别:
分别有如下代码:
-
static int
-
umass_probe(device_t dev)
-
{
-
struct usb_attach_arg *uaa = device_get_ivars(dev);
-
struct umass_probe_proto temp;
-
-
if (uaa->usb_mode != USB_MODE_HOST) {
-
return (ENXIO);
-
}
-
temp = umass_probe_proto(dev, uaa);
-
-
return (temp.error);
-
}
和
-
static int
-
ustorage_fs_probe(device_t dev)
-
{
-
struct usb_attach_arg *uaa = device_get_ivars(dev);
-
struct usb_interface_descriptor *id;
-
-
if (uaa->usb_mode != USB_MODE_DEVICE) {
-
return (ENXIO);
-
}
-
/* Check for a standards compliant device */
-
id = usbd_get_interface_descriptor(uaa->iface);
-
if ((id == NULL) ||
-
(id->bInterfaceClass != UICLASS_MASS) ||
-
(id->bInterfaceSubClass != UISUBCLASS_SCSI) ||
-
(id->bInterfaceProtocol != UIPROTO_MASS_BBB)) {
-
return (ENXIO);
-
}
-
return (BUS_PROBE_GENERIC);
-
}
同样都是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) |