Changeset b8507a1 in mainline


Ignore:
Timestamp:
2010-10-20T21:17:32Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6c741e1d
Parents:
08af5a6
Message:

Virtual USB HC has a hub

So far, the hub does not respond to requests and automatically enables
any port device connects to. Will be completed in next revisions (hope
very soon).

Location:
uspace/srv/hw/bus/usb/hcd/virtual
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hw/bus/usb/hcd/virtual/Makefile

    r08af5a6 rb8507a1  
    2828
    2929USPACE_PREFIX = ../../../../../..
    30 LIBS = $(LIBUSB_PREFIX)/libusb.a
     30LIBS = $(LIBUSB_PREFIX)/libusb.a $(LIBUSBVIRT_PREFIX)/libusbvirt.a
    3131EXTRA_CFLAGS = -I$(LIB_PREFIX)
    3232BINARY = vhcd
     
    3737        devices.c \
    3838        hc.c \
    39         hcd.c
     39        hcd.c \
     40        hub.c \
     41        hubops.c
    4042
    4143include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/hw/bus/usb/hcd/virtual/conndev.c

    r08af5a6 rb8507a1  
    4040#include "conn.h"
    4141#include "hc.h"
     42#include "hub.h"
    4243
    43 /** Handle data from device to function.
     44/** Handle data from device to host.
    4445 */
    4546static void handle_data_from_device(ipc_callid_t iid, ipc_call_t icall,
     
    5051                .endpoint = IPC_GET_ARG2(icall)
    5152        };
     53       
     54        if (!hub_can_device_signal(dev)) {
     55                ipc_answer_0(iid, EREFUSED);
     56                return;
     57        }
    5258       
    5359        dprintf("data from device %d [%d.%d]", dev->id,
  • uspace/srv/hw/bus/usb/hcd/virtual/devices.c

    r08af5a6 rb8507a1  
    4747
    4848#include "devices.h"
     49#include "hub.h"
    4950
    5051#define list_foreach(pos, head) \
     
    6162virtdev_connection_t *virtdev_recognise(int id, int phone)
    6263{
    63         virtdev_connection_t * dev = NULL;
    64         switch (id) {
    65                 case USBVIRT_DEV_KEYBOARD_ID:
    66                         dev = virtdev_add_device(phone);
    67                         break;
    68                 default:
    69                         break;
    70         }
     64        virtdev_connection_t * dev = virtdev_add_device(phone);
    7165       
    7266        /*
     
    9892        list_append(&dev->link, &devices);
    9993       
     94        hub_add_device(dev);
     95       
    10096        return dev;
    10197}
     
    105101void virtdev_destroy_device(virtdev_connection_t *dev)
    106102{
     103        hub_remove_device(dev);
    107104        list_remove(&dev->link);
    108105        free(dev);
     
    119116                virtdev_connection_t *dev
    120117                    = list_get_instance(pos, virtdev_connection_t, link);
     118               
     119                if (!hub_can_device_signal(dev)) {
     120                        continue;
     121                }
    121122               
    122123                ipc_call_t answer_data;
     
    143144       
    144145        /*
     146         * Send the data to the virtual hub as well
     147         * (if the address matches).
     148         */
     149        if (virthub_dev.address == transaction->target.address) {
     150                virthub_dev.receive_data(&virthub_dev, transaction->target.endpoint,
     151                    transaction->buffer, transaction->len);
     152        }
     153       
     154        /*
    145155         * TODO: maybe screw some transactions to get more
    146156         * real-life image.
  • uspace/srv/hw/bus/usb/hcd/virtual/hcd.c

    r08af5a6 rb8507a1  
    4848#include "hc.h"
    4949#include "devices.h"
     50#include "hub.h"
    5051#include "conn.h"
    5152
     
    135136        }
    136137       
     138        hub_init();
     139       
    137140        printf("%s: accepting connections.\n", NAME);
    138141        hc_manager();
  • uspace/srv/hw/bus/usb/hcd/virtual/vhcd.h

    r08af5a6 rb8507a1  
    3636#define VHCD_VHCD_H_
    3737
     38#include <stdio.h>
     39
    3840#define NAME "hcd-virt"
    3941#define NAMESPACE "usb"
Note: See TracChangeset for help on using the changeset viewer.