Changeset 47e3a8e in mainline for uspace/lib/usbvirt/main.c


Ignore:
Timestamp:
2010-10-15T16:32:57Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
186d630
Parents:
73301a0
Message:

Virtual USB device tracks its address

Now, each virtual device tracks its address and its state.

The virtual HC dispatches all transactions to all devices, thus
more precisely simulating situation on USB. The usbvirt framework
then decides whether it can accept the data or not, based on
their destination address.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbvirt/main.c

    r73301a0 r47e3a8e  
    5050static void handle_data_to_device(ipc_callid_t iid, ipc_call_t icall)
    5151{
    52         usb_endpoint_t endpoint = IPC_GET_ARG1(icall);
     52        usb_address_t address = IPC_GET_ARG1(icall);
     53        usb_endpoint_t endpoint = IPC_GET_ARG2(icall);
     54       
     55        if (address != device->address) {
     56                ipc_answer_0(iid, EADDRNOTAVAIL);
     57                return;
     58        }
    5359       
    5460        size_t len;
     
    95101}
    96102
     103static void device_init(usbvirt_device_t *dev)
     104{
     105        dev->send_data = usbvirt_data_to_host;
     106        dev->state = USBVIRT_STATE_DEFAULT;
     107        dev->address = 0;
     108}
     109
    97110int usbvirt_data_to_host(struct usbvirt_device *dev,
    98111    usb_endpoint_t endpoint, void *buffer, size_t size)
     
    112125        int rc;
    113126       
    114         req = async_send_1(phone,
     127        req = async_send_2(phone,
    115128            IPC_M_USBVIRT_DATA_FROM_DEVICE,
     129            dev->address,
    116130            endpoint,
    117131            &answer_data);
     
    174188       
    175189        dev->vhcd_phone_ = hcd_phone;
    176         dev->send_data = usbvirt_data_to_host;
     190        device_init(dev);
    177191       
    178192        device = dev;
Note: See TracChangeset for help on using the changeset viewer.