Changeset 1898


Ignore:
Timestamp:
05/03/07 04:46:03 (6 years ago)
Author:
andrew
Message:

Monitor commands to handle the USB gadget functionality, various gadgetfs usage fixes.

Location:
trunk/src/host/qemu-neo1973
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/host/qemu-neo1973/usb-linux-gadget.c

    r1864 r1898  
    362362        goto fail; 
    363363    cfg = (struct usb_config_descriptor *) src; 
     364    if (packet->len < cfg->wTotalLength) 
     365        goto fail; 
    364366    if (dl + cfg->wTotalLength > sizeof(buffer)) 
    365367        goto fail; 
     
    377379        goto fail; 
    378380    memcpy(dst, hci->dev_desc, hci->desc_len); 
     381    /* HACK: report always only a single Configuration */ 
     382    ((struct usb_device_descriptor *) dst)->bNumConfigurations = 1; 
    379383    dl += hci->desc_len; 
    380384    dst += hci->desc_len; 
     
    492496    int ret, len; 
    493497 
    494     if (!s->addr) 
     498    if (!s->connected) 
    495499        return; 
    496500 
     
    498502    if (ret < 0 && errno != EAGAIN) 
    499503        fprintf(stderr, "%s: event error: %i\n", __FUNCTION__, errno); 
    500     if (ret < sizeof(event)) 
     504    if (ret < (int) sizeof(event)) 
    501505        return; 
    502506 
     
    713717    atexit(gadget_done); 
    714718 
     719    hci->addr = 0; 
     720 
    715721    qemu_register_usb_port(&hci->port, hci, USB_INDEX_HOST, gadget_attach); 
    716722 
  • trunk/src/host/qemu-neo1973/vl.c

    r1825 r1898  
    39563956static USBPort *used_usb_ports; 
    39573957static USBPort *free_usb_ports; 
     3958static USBPort *host_usb_ports; 
     3959static USBDevice *usb_gadget; 
    39583960 
    39593961/* ??? Maybe change this to register a hub to keep track of the topology.  */ 
     
    39643966    port->index = index; 
    39653967    port->attach = attach; 
    3966     port->next = free_usb_ports; 
    3967     free_usb_ports = port; 
     3968    if (index == USB_INDEX_HOST) { 
     3969        port->next = host_usb_ports; 
     3970        host_usb_ports = port; 
     3971    } else { 
     3972        port->next = free_usb_ports; 
     3973        free_usb_ports = port; 
     3974    } 
     3975} 
     3976 
     3977void qemu_register_usb_gadget(USBDevice *device) 
     3978{ 
     3979    usb_gadget = device; 
    39683980} 
    39693981 
     
    39904002                return -1; 
    39914003        dev = usb_net_init(&nd_table[nr]); 
     4004    } else if (!strcmp(devname, "gadget")) { 
     4005        dev = usb_gadget; 
     4006        port = host_usb_ports; 
     4007        if (!dev || !port) 
     4008            return -1; 
     4009        goto attach; 
    39924010    } else { 
    3993         return -1; 
     4011        return 0; 
    39944012    } 
    39954013    if (!dev) 
     
    40144032    port->next = used_usb_ports; 
    40154033    used_usb_ports = port; 
     4034attach: 
    40164035    usb_attach(port, dev); 
    40174036    return 0; 
     
    40254044    int bus_num, addr; 
    40264045    const char *p; 
     4046 
     4047    if (!strcmp(devname, "gadget")) { 
     4048        port = host_usb_ports; 
     4049        if (!port) 
     4050            return -1; 
     4051        usb_attach(port, NULL); 
     4052        return 0; 
     4053    } 
    40274054 
    40284055    if (!used_usb_ports) 
  • trunk/src/host/qemu-neo1973/vl.h

    r1667 r1898  
    12301230/* usb ports of the VM */ 
    12311231 
     1232#define USB_INDEX_HOST  -1 
    12321233void qemu_register_usb_port(USBPort *port, void *opaque, int index, 
    12331234                            usb_attachfn attach); 
     1235void qemu_register_usb_gadget(USBDevice *device); 
    12341236 
    12351237#define VM_USB_HUB_SIZE 8 
     
    14581460#include "hw/i2c.h" 
    14591461 
     1462#define unlikely(cond)  __builtin_expect(cond, 0) 
     1463 
    14601464#ifdef TARGET_ARM 
    14611465#include "hw/pxa.h" 
Note: See TracChangeset for help on using the changeset viewer.