亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? usb-linux.c

?? qemu性能直逼VMware的仿真器QEMU 的模擬速度約為實(shí)機(jī)的 25%;約為 Bochs 的 60 倍。Plex86、User-Mode-Linux、VMware 和 Virtual PC 則比
?? C
字號(hào):
/* * Linux host USB redirector * * Copyright (c) 2005 Fabrice Bellard *  * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */#include "vl.h"#if defined(__linux__)#include <dirent.h>#include <sys/ioctl.h>#include <linux/usbdevice_fs.h>#include <linux/version.h>/* We redefine it to avoid version problems */struct usb_ctrltransfer {    uint8_t  bRequestType;    uint8_t  bRequest;    uint16_t wValue;    uint16_t wIndex;    uint16_t wLength;    uint32_t timeout;    void *data;};typedef int USBScanFunc(void *opaque, int bus_num, int addr, int class_id,                        int vendor_id, int product_id,                         const char *product_name, int speed);static int usb_host_find_device(int *pbus_num, int *paddr,                                 char *product_name, int product_name_size,                                const char *devname);//#define DEBUG#define USBDEVFS_PATH "/proc/bus/usb"#define PRODUCT_NAME_SZ 32typedef struct USBHostDevice {    USBDevice dev;    int fd;} USBHostDevice;static void usb_host_handle_reset(USBDevice *dev){#if 0    USBHostDevice *s = (USBHostDevice *)dev;    /* USBDEVFS_RESET, but not the first time as it has already be       done by the host OS */    ioctl(s->fd, USBDEVFS_RESET);#endif} static void usb_host_handle_destroy(USBDevice *dev){    USBHostDevice *s = (USBHostDevice *)dev;    if (s->fd >= 0)        close(s->fd);    qemu_free(s);}static int usb_host_handle_control(USBDevice *dev,                                   int request,                                   int value,                                   int index,                                   int length,                                   uint8_t *data){    USBHostDevice *s = (USBHostDevice *)dev;    struct usb_ctrltransfer ct;    int ret;    if (request == (DeviceOutRequest | USB_REQ_SET_ADDRESS)) {        /* specific SET_ADDRESS support */        dev->addr = value;        return 0;    } else {        ct.bRequestType = request >> 8;        ct.bRequest = request;        ct.wValue = value;        ct.wIndex = index;        ct.wLength = length;        ct.timeout = 50;        ct.data = data;        ret = ioctl(s->fd, USBDEVFS_CONTROL, &ct);        if (ret < 0) {            switch(errno) {            case ETIMEDOUT:                return USB_RET_NAK;            default:                return USB_RET_STALL;            }        } else {            return ret;        }   }}static int usb_host_handle_data(USBDevice *dev, USBPacket *p){    USBHostDevice *s = (USBHostDevice *)dev;    struct usbdevfs_bulktransfer bt;    int ret;    uint8_t devep = p->devep;    /* XXX: optimize and handle all data types by looking at the       config descriptor */    if (p->pid == USB_TOKEN_IN)        devep |= 0x80;    bt.ep = devep;    bt.len = p->len;    bt.timeout = 50;    bt.data = p->data;    ret = ioctl(s->fd, USBDEVFS_BULK, &bt);    if (ret < 0) {        switch(errno) {        case ETIMEDOUT:            return USB_RET_NAK;        case EPIPE:        default:#ifdef DEBUG            printf("handle_data: errno=%d\n", errno);#endif            return USB_RET_STALL;        }    } else {        return ret;    }}/* XXX: exclude high speed devices or implement EHCI */USBDevice *usb_host_device_open(const char *devname){    int fd, interface, ret, i;    USBHostDevice *dev;    struct usbdevfs_connectinfo ci;    uint8_t descr[1024];    char buf[1024];    int descr_len, dev_descr_len, config_descr_len, nb_interfaces;    int bus_num, addr;    char product_name[PRODUCT_NAME_SZ];    if (usb_host_find_device(&bus_num, &addr,                              product_name, sizeof(product_name),                             devname) < 0)         return NULL;        snprintf(buf, sizeof(buf), USBDEVFS_PATH "/%03d/%03d",              bus_num, addr);    fd = open(buf, O_RDWR);    if (fd < 0) {        perror(buf);        return NULL;    }    /* read the config description */    descr_len = read(fd, descr, sizeof(descr));    if (descr_len <= 0) {        perror("read descr");        goto fail;    }        i = 0;    dev_descr_len = descr[0];    if (dev_descr_len > descr_len)        goto fail;    i += dev_descr_len;    config_descr_len = descr[i];    if (i + config_descr_len > descr_len)        goto fail;    nb_interfaces = descr[i + 4];    if (nb_interfaces != 1) {        /* NOTE: currently we grab only one interface */        fprintf(stderr, "usb_host: only one interface supported\n");        goto fail;    }#ifdef USBDEVFS_DISCONNECT    /* earlier Linux 2.4 do not support that */    {        struct usbdevfs_ioctl ctrl;        ctrl.ioctl_code = USBDEVFS_DISCONNECT;        ctrl.ifno = 0;        ret = ioctl(fd, USBDEVFS_IOCTL, &ctrl);        if (ret < 0 && errno != ENODATA) {            perror("USBDEVFS_DISCONNECT");            goto fail;        }    }#endif    /* XXX: only grab if all interfaces are free */    interface = 0;    ret = ioctl(fd, USBDEVFS_CLAIMINTERFACE, &interface);    if (ret < 0) {        if (errno == EBUSY) {            fprintf(stderr, "usb_host: device already grabbed\n");        } else {            perror("USBDEVFS_CLAIMINTERFACE");        }    fail:        close(fd);        return NULL;    }    ret = ioctl(fd, USBDEVFS_CONNECTINFO, &ci);    if (ret < 0) {        perror("USBDEVFS_CONNECTINFO");        goto fail;    }#ifdef DEBUG    printf("host USB device %d.%d grabbed\n", bus_num, addr);#endif        dev = qemu_mallocz(sizeof(USBHostDevice));    if (!dev)        goto fail;    dev->fd = fd;    if (ci.slow)        dev->dev.speed = USB_SPEED_LOW;    else        dev->dev.speed = USB_SPEED_HIGH;    dev->dev.handle_packet = usb_generic_handle_packet;    dev->dev.handle_reset = usb_host_handle_reset;    dev->dev.handle_control = usb_host_handle_control;    dev->dev.handle_data = usb_host_handle_data;    dev->dev.handle_destroy = usb_host_handle_destroy;    if (product_name[0] == '\0')        snprintf(dev->dev.devname, sizeof(dev->dev.devname),                 "host:%s", devname);    else        pstrcpy(dev->dev.devname, sizeof(dev->dev.devname),                product_name);    return (USBDevice *)dev;}static int get_tag_value(char *buf, int buf_size,                         const char *str, const char *tag,                          const char *stopchars){    const char *p;    char *q;    p = strstr(str, tag);    if (!p)        return -1;    p += strlen(tag);    while (isspace(*p))        p++;    q = buf;    while (*p != '\0' && !strchr(stopchars, *p)) {        if ((q - buf) < (buf_size - 1))            *q++ = *p;        p++;    }    *q = '\0';    return q - buf;}static int usb_host_scan(void *opaque, USBScanFunc *func){    FILE *f;    char line[1024];    char buf[1024];    int bus_num, addr, speed, device_count, class_id, product_id, vendor_id;    int ret;    char product_name[512];        f = fopen(USBDEVFS_PATH "/devices", "r");    if (!f) {        term_printf("Could not open %s\n", USBDEVFS_PATH "/devices");        return 0;    }    device_count = 0;    bus_num = addr = speed = class_id = product_id = vendor_id = 0;    ret = 0;    for(;;) {        if (fgets(line, sizeof(line), f) == NULL)            break;        if (strlen(line) > 0)            line[strlen(line) - 1] = '\0';        if (line[0] == 'T' && line[1] == ':') {            if (device_count && (vendor_id || product_id)) {                /* New device.  Add the previously discovered device.  */                ret = func(opaque, bus_num, addr, class_id, vendor_id,                            product_id, product_name, speed);                if (ret)                    goto the_end;            }            if (get_tag_value(buf, sizeof(buf), line, "Bus=", " ") < 0)                goto fail;            bus_num = atoi(buf);            if (get_tag_value(buf, sizeof(buf), line, "Dev#=", " ") < 0)                goto fail;            addr = atoi(buf);            if (get_tag_value(buf, sizeof(buf), line, "Spd=", " ") < 0)                goto fail;            if (!strcmp(buf, "480"))                speed = USB_SPEED_HIGH;            else if (!strcmp(buf, "1.5"))                speed = USB_SPEED_LOW;            else                speed = USB_SPEED_FULL;            product_name[0] = '\0';            class_id = 0xff;            device_count++;            product_id = 0;            vendor_id = 0;        } else if (line[0] == 'P' && line[1] == ':') {            if (get_tag_value(buf, sizeof(buf), line, "Vendor=", " ") < 0)                goto fail;            vendor_id = strtoul(buf, NULL, 16);            if (get_tag_value(buf, sizeof(buf), line, "ProdID=", " ") < 0)                goto fail;            product_id = strtoul(buf, NULL, 16);        } else if (line[0] == 'S' && line[1] == ':') {            if (get_tag_value(buf, sizeof(buf), line, "Product=", "") < 0)                goto fail;            pstrcpy(product_name, sizeof(product_name), buf);        } else if (line[0] == 'D' && line[1] == ':') {            if (get_tag_value(buf, sizeof(buf), line, "Cls=", " (") < 0)                goto fail;            class_id = strtoul(buf, NULL, 16);        }    fail: ;    }    if (device_count && (vendor_id || product_id)) {        /* Add the last device.  */        ret = func(opaque, bus_num, addr, class_id, vendor_id,                    product_id, product_name, speed);    } the_end:    fclose(f);    return ret;}typedef struct FindDeviceState {    int vendor_id;    int product_id;    int bus_num;    int addr;    char product_name[PRODUCT_NAME_SZ];} FindDeviceState;static int usb_host_find_device_scan(void *opaque, int bus_num, int addr,                                      int class_id,                                     int vendor_id, int product_id,                                      const char *product_name, int speed){    FindDeviceState *s = opaque;    if ((vendor_id == s->vendor_id &&        product_id == s->product_id) ||        (bus_num == s->bus_num &&        addr == s->addr)) {        pstrcpy(s->product_name, PRODUCT_NAME_SZ, product_name);        s->bus_num = bus_num;        s->addr = addr;        return 1;    } else {        return 0;    }}/* the syntax is :    'bus.addr' (decimal numbers) or    'vendor_id:product_id' (hexa numbers) */static int usb_host_find_device(int *pbus_num, int *paddr,                                 char *product_name, int product_name_size,                                const char *devname){    const char *p;    int ret;    FindDeviceState fs;    p = strchr(devname, '.');    if (p) {        *pbus_num = strtoul(devname, NULL, 0);        *paddr = strtoul(p + 1, NULL, 0);        fs.bus_num = *pbus_num;        fs.addr = *paddr;        ret = usb_host_scan(&fs, usb_host_find_device_scan);        if (ret)            pstrcpy(product_name, product_name_size, fs.product_name);        return 0;    }    p = strchr(devname, ':');    if (p) {        fs.vendor_id = strtoul(devname, NULL, 16);        fs.product_id = strtoul(p + 1, NULL, 16);        ret = usb_host_scan(&fs, usb_host_find_device_scan);        if (ret) {            *pbus_num = fs.bus_num;            *paddr = fs.addr;            pstrcpy(product_name, product_name_size, fs.product_name);            return 0;        }    }    return -1;}/**********************//* USB host device info */struct usb_class_info {    int class;    const char *class_name;};static const struct usb_class_info usb_class_info[] = {    { USB_CLASS_AUDIO, "Audio"},    { USB_CLASS_COMM, "Communication"},    { USB_CLASS_HID, "HID"},    { USB_CLASS_HUB, "Hub" },    { USB_CLASS_PHYSICAL, "Physical" },    { USB_CLASS_PRINTER, "Printer" },    { USB_CLASS_MASS_STORAGE, "Storage" },    { USB_CLASS_CDC_DATA, "Data" },    { USB_CLASS_APP_SPEC, "Application Specific" },    { USB_CLASS_VENDOR_SPEC, "Vendor Specific" },    { USB_CLASS_STILL_IMAGE, "Still Image" },    { USB_CLASS_CSCID, 	"Smart Card" },    { USB_CLASS_CONTENT_SEC, "Content Security" },    { -1, NULL }};static const char *usb_class_str(uint8_t class){    const struct usb_class_info *p;    for(p = usb_class_info; p->class != -1; p++) {        if (p->class == class)            break;    }    return p->class_name;}void usb_info_device(int bus_num, int addr, int class_id,                     int vendor_id, int product_id,                      const char *product_name,                     int speed){    const char *class_str, *speed_str;    switch(speed) {    case USB_SPEED_LOW:         speed_str = "1.5";         break;    case USB_SPEED_FULL:         speed_str = "12";         break;    case USB_SPEED_HIGH:         speed_str = "480";         break;    default:        speed_str = "?";         break;    }    term_printf("  Device %d.%d, speed %s Mb/s\n",                 bus_num, addr, speed_str);    class_str = usb_class_str(class_id);    if (class_str)         term_printf("    %s:", class_str);    else        term_printf("    Class %02x:", class_id);    term_printf(" USB device %04x:%04x", vendor_id, product_id);    if (product_name[0] != '\0')        term_printf(", %s", product_name);    term_printf("\n");}static int usb_host_info_device(void *opaque, int bus_num, int addr,                                 int class_id,                                int vendor_id, int product_id,                                 const char *product_name,                                int speed){    usb_info_device(bus_num, addr, class_id, vendor_id, product_id,                    product_name, speed);    return 0;}void usb_host_info(void){    usb_host_scan(NULL, usb_host_info_device);}#elsevoid usb_host_info(void){    term_printf("USB host devices not supported\n");}/* XXX: modify configure to compile the right host driver */USBDevice *usb_host_device_open(const char *devname){    return NULL;}#endif

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩成人免费电影| 亚洲另类中文字| 欧美顶级少妇做爰| 欧美日韩一区中文字幕| 色一情一乱一乱一91av| 99久久99久久精品免费看蜜桃| 国产精品一线二线三线| 国产一区二区导航在线播放| 国产一区二区三区蝌蚪| 激情成人综合网| 国产伦精品一区二区三区免费迷| 美女视频免费一区| 国产精品一区二区在线观看网站| 国产一区二区三区不卡在线观看| 麻豆精品一区二区综合av| 久久激情五月激情| 国产黑丝在线一区二区三区| 国产成人丝袜美腿| 日本伦理一区二区| 717成人午夜免费福利电影| 欧美一卡在线观看| 久久久精品日韩欧美| 国产精品久久久久久久久晋中| 综合久久久久综合| 日韩制服丝袜先锋影音| 国产一区二区三区在线观看免费视频 | 久久久夜色精品亚洲| 国产午夜亚洲精品午夜鲁丝片| 国产精品人成在线观看免费| 国产精品久久久久永久免费观看 | 精品视频一区二区不卡| 91精品综合久久久久久| 亚洲高清不卡在线| 日韩精品一区第一页| 国产成人免费在线视频| 欧洲日韩一区二区三区| 精品国精品国产尤物美女| 亚洲欧洲在线观看av| 日韩主播视频在线| 成人激情综合网站| 91精品国产麻豆| 国产精品美女久久久久久久久| 亚洲综合激情小说| 国产高清不卡二三区| 欧美影视一区二区三区| 久久久国际精品| 日韩黄色片在线观看| av一区二区三区黑人| 欧美肥妇bbw| 亚洲色图制服诱惑 | 国产精品欧美精品| 天堂一区二区在线| 色哟哟亚洲精品| 久久久青草青青国产亚洲免观| 亚洲一区二区av在线| 国内精品久久久久影院色| 欧美日韩一级片在线观看| 日本一区二区三区dvd视频在线| 亚洲成人动漫精品| 色噜噜夜夜夜综合网| 国产精品视频一二三| 久久99精品久久久久久动态图| 色诱亚洲精品久久久久久| 久久综合成人精品亚洲另类欧美| 亚洲制服丝袜av| 色天天综合色天天久久| 中文字幕免费一区| 国产福利精品导航| 国产亚洲成年网址在线观看| 久久国产免费看| 亚洲私人影院在线观看| 精品制服美女久久| 精品99一区二区| 美女www一区二区| 日韩欧美国产一区在线观看| 日韩一区精品字幕| 欧美肥妇bbw| 麻豆91免费看| 欧美精品一区二区三区很污很色的 | 一区二区三区在线高清| 国内精品写真在线观看| 欧美日韩精品欧美日韩精品| 国产精品福利一区| 成人午夜激情影院| 国产精品免费久久久久| 成人高清免费在线播放| 国产精品久久久久久久久果冻传媒 | 亚洲激情在线激情| 欧美在线观看视频在线| 五月天一区二区三区| 欧美一区二区免费| 国产激情一区二区三区| 国产精品久久久久永久免费观看| 成人涩涩免费视频| 亚洲香蕉伊在人在线观| 69av一区二区三区| 国产精品1区2区3区| 国产精品久久久久久久浪潮网站 | 亚洲色图欧洲色图婷婷| 色94色欧美sute亚洲线路一久| 亚洲一区在线观看免费| 日韩欧美在线一区二区三区| 国产成人在线影院| 亚洲卡通动漫在线| 日韩欧美中文字幕公布| 成人高清免费观看| 日本一不卡视频| 欧美激情综合网| 日本久久电影网| 蜜桃在线一区二区三区| 国产精品久久久一区麻豆最新章节| 91免费国产在线观看| 蜜臀va亚洲va欧美va天堂| 国产精品午夜春色av| 欧美日本韩国一区二区三区视频| 看片的网站亚洲| 一区二区三国产精华液| 国产性色一区二区| 欧美日韩国产欧美日美国产精品| 国产高清久久久| 日韩精品欧美精品| 亚洲视频一区在线| 精品欧美一区二区久久| 欧美在线观看视频一区二区| 国产一区二区毛片| 日本不卡在线视频| 一区二区三区成人| 欧美国产日韩a欧美在线观看| 91精品在线麻豆| 色狠狠色狠狠综合| 国产成人免费视| 久久精品国产精品青草| 午夜视频一区二区三区| 亚洲国产精品v| 久久精品亚洲麻豆av一区二区 | 国产日韩欧美激情| 日韩欧美自拍偷拍| 欧美老女人第四色| 欧美性感一区二区三区| 91麻豆国产香蕉久久精品| 国产精品18久久久久久久久 | 爽好久久久欧美精品| 亚洲蜜臀av乱码久久精品| 国产日韩欧美不卡在线| 精品国产乱码久久久久久1区2区| 欧美视频你懂的| 欧美制服丝袜第一页| 99国产欧美久久久精品| 丁香亚洲综合激情啪啪综合| 国产美女精品在线| 免费观看一级欧美片| 日韩精品一二三四| 三级一区在线视频先锋| 三级亚洲高清视频| 日韩av电影天堂| 男男视频亚洲欧美| 美国毛片一区二区三区| 久久97超碰国产精品超碰| 蜜桃视频一区二区三区在线观看 | 久久色视频免费观看| 久久亚洲综合色一区二区三区 | 久久久久久黄色| 国产性色一区二区| 国产精品久久久99| 亚洲精品中文在线| 亚洲香肠在线观看| 蜜桃av一区二区三区电影| 经典三级视频一区| 波多野结衣中文字幕一区| 99久久婷婷国产| 欧美日韩免费电影| 2020国产精品| 国产精品成人午夜| 亚洲国产精品欧美一二99| 日本大胆欧美人术艺术动态| 精品在线一区二区| 99精品视频在线观看| 欧美三级电影在线看| 久久色视频免费观看| 亚洲欧洲制服丝袜| 日韩精彩视频在线观看| 国产99久久久久久免费看农村| 99国产欧美久久久精品| 91精品国产综合久久福利软件 | 欧美日韩另类一区| 欧美tickling挠脚心丨vk| 中文字幕免费不卡| 午夜成人免费视频| 国产成人综合在线播放| 欧美丝袜自拍制服另类| 精品国产乱码久久久久久图片 | 久久久精品免费免费| 夜色激情一区二区| 国内精品伊人久久久久av一坑| 99re在线视频这里只有精品| 日韩一区二区麻豆国产| 亚洲欧美乱综合| 国产一区中文字幕| 欧美人妇做爰xxxⅹ性高电影 | 成人欧美一区二区三区小说|