Ignore:
Timestamp:
2010-10-15T16:32:57Z (14 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/srv/hw/bus/usb/hcd/virtual/hc.c

    r73301a0 r47e3a8e  
    6868static link_t transaction_from_device_list;
    6969
    70 /** Pending transaction details. */
    71 typedef struct {
    72         /** Linked-list link. */
    73         link_t link;
    74         /** Device address. */
    75         usb_target_t target;
    76         /** Direction of the transaction. */
    77         usb_direction_t direction;
    78         /** Transfer type. */
    79         usb_transfer_type_t type;
    80         /** Transaction data buffer. */
    81         void * buffer;
    82         /** Transaction data length. */
    83         size_t len;
    84         /** Callback after transaction is done. */
    85         hc_transaction_done_callback_t callback;
    86         /** Argument to the callback. */
    87         void * callback_arg;
    88 } transaction_t;
    89 
    9070#define TRANSACTION_FORMAT "T[%d:%d %s %s (%d)]"
    9171#define TRANSACTION_PRINTF(t) \
     
    136116                }
    137117               
    138                 link_t * first_transaction_link = transaction_to_device_list.next;
    139                 transaction_t * transaction
     118                link_t *first_transaction_link = transaction_to_device_list.next;
     119                transaction_t *transaction
    140120                    = transaction_get_instance(first_transaction_link);
    141121                list_remove(first_transaction_link);
    142122               
    143                 virtdev_connection_t *dev = virtdev_find_by_address(
    144                     transaction->target.address);
    145                 usb_transaction_outcome_t outcome = USB_OUTCOME_OK;
    146                
    147                 if (dev != NULL) {
    148                         dprintf("sending data to device at %d.%d (phone %d)",
    149                             dev->address, transaction->target.endpoint,
    150                             dev->phone);
    151                         ipc_call_t answer_data;
    152                         ipcarg_t answer_rc;
    153                         aid_t req;
    154                         int rc;
    155                        
    156                         req = async_send_2(dev->phone,
    157                             IPC_M_USBVIRT_DATA_TO_DEVICE,
    158                             transaction->target.endpoint,
    159                             transaction->type,
    160                             &answer_data);
    161                        
    162                         rc = async_data_write_start(dev->phone,
    163                             transaction->buffer, transaction->len);
    164                         if (rc != EOK) {
    165                                 async_wait_for(req, NULL);
    166                         } else {
    167                                 async_wait_for(req, &answer_rc);
    168                                 rc = (int)answer_rc;
    169                         }
    170                        
    171                         if (rc != EOK) {
    172                                 outcome = USB_OUTCOME_BABBLE;
    173                         }
    174                 } else {
    175                         outcome = USB_OUTCOME_CRCERROR;
    176                 }
     123                usb_transaction_outcome_t outcome;
     124                outcome = virtdev_send_to_all(transaction);
    177125               
    178126                process_transaction_with_outcome(transaction, outcome);
Note: See TracChangeset for help on using the changeset viewer.