diff --git a/hw/usb/host-bsd.c b/hw/usb/host-bsd.c index ec26266..caf836f 100644 --- a/hw/usb/host-bsd.c +++ b/hw/usb/host-bsd.c @@ -36,6 +36,8 @@ #include #ifndef __DragonFly__ #include +#include +#include #else #include #endif @@ -159,7 +161,7 @@ static int usb_host_handle_control(USBDevice *dev, (request & 0xff) == UR_SET_INTERFACE) { aiface.uai_interface_index = index; - aiface.uai_alt_no = value; + aiface.uai_alt_index = value; ensure_eps_closed(s); /* can't do this without all eps closed */ ret = ioctl(s->devfd, USB_SET_ALTINTERFACE, &aiface); @@ -179,9 +181,20 @@ static int usb_host_handle_control(USBDevice *dev, USETW(req.ucr_request.wIndex, index); USETW(req.ucr_request.wLength, length); req.ucr_data = data; - req.ucr_flags = USBD_SHORT_XFER_OK; + req.ucr_flags = USB_SHORT_XFER_OK; - ret = ioctl(s->devfd, USB_SET_TIMEOUT, &timeout); + ret = ioctl(s->devfd, USB_SET_RX_TIMEOUT, &timeout); +#if defined(__NetBSD__) || defined(__OpenBSD__) + if (ret < 0 && errno != EINVAL) { +#else + if (ret < 0) { +#endif +#ifdef DEBUG + printf("handle_control: setting timeout failed - %s\n", + strerror(errno)); +#endif + } + ret = ioctl(s->devfd, USB_SET_TX_TIMEOUT, &timeout); #if defined(__NetBSD__) || defined(__OpenBSD__) if (ret < 0 && errno != EINVAL) { #else @@ -235,17 +248,30 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket *p) return USB_RET_NODEV; } - if (ioctl(fd, USB_SET_TIMEOUT, &timeout) < 0) { + if (ioctl(fd, USB_SET_RX_TIMEOUT, &timeout) < 0) { #ifdef DEBUG - printf("handle_data: failed to set timeout - %s\n", + printf("handle_data: failed to set RX timeout - %s\n", + strerror(errno)); +#endif + } + + if (ioctl(fd, USB_SET_TX_TIMEOUT, &timeout) < 0) { +#ifdef DEBUG + printf("handle_data: failed to set TX timeout - %s\n", strerror(errno)); #endif } if (shortpacket) { - if (ioctl(fd, USB_SET_SHORT_XFER, &one) < 0) { + if (ioctl(fd, USB_SET_RX_SHORT_XFER, &one) < 0) { #ifdef DEBUG - printf("handle_data: failed to set short xfer mode - %s\n", + printf("handle_data: failed to set short RX xfer mode - %s\n", + strerror(errno)); +#endif + } + if (ioctl(fd, USB_SET_TX_FORCE_SHORT, &one) < 0) { +#ifdef DEBUG + printf("handle_data: failed to set short TX xfer mode - %s\n", strerror(errno)); #endif sigprocmask(SIG_SETMASK, &old_mask, NULL); @@ -377,8 +403,10 @@ USBDevice *usb_host_device_open(USBBus *guest_bus, const char *devname) "host:%s", devname); } +#ifndef __FreeBSD__ pstrcpy(dev->devpath, sizeof(dev->devpath), "/dev/"); pstrcat(dev->devpath, sizeof(dev->devpath), dev_info.udi_devnames[0]); +#endif /* Mark the endpoints as not yet open */ for (i = 0; i < USB_MAX_ENDPOINTS; i++) {