Changeset 6967c14 in mainline


Ignore:
Timestamp:
2011-01-25T17:44:06Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
875e7227
Parents:
afc4fbb
Message:

VHC registers device unplugging

The virtual host controller is now able to register that a virtual USB device
was unplugged (i.e. that the task representing the device closed the
connection).

However, the change is not yet propagated to the root hub of the host
controller.

Location:
uspace/drv/vhc
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/vhc/conn.h

    rafc4fbb r6967c14  
    5151
    5252void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *);
     53void on_client_close(device_t *);
    5354
    5455
  • uspace/drv/vhc/conndev.c

    rafc4fbb r6967c14  
    8888                int callback = IPC_GET_ARG5(*icall);
    8989                virtdev_connection_t *dev
    90                     = virtdev_add_device(callback);
     90                    = virtdev_add_device(callback, (sysarg_t)fibril_get_id());
    9191                if (!dev) {
    9292                        ipc_answer_0(icallid, EEXISTS);
     
    9999                int rc = get_device_name(callback, devname, DEVICE_NAME_MAXLENGTH);
    100100
    101                 dprintf(0, "virtual device connected (name: %s)",
    102                     rc == EOK ? devname : "<unknown>");
    103 
    104                 /* FIXME: destroy the device when the client disconnects. */
     101                dprintf(0, "virtual device connected (name: %s, id: %x)",
     102                    rc == EOK ? devname : "<unknown>", dev->id);
    105103
    106104                return;
     
    110108}
    111109
     110/** Callback for DDF when client disconnects.
     111 *
     112 * @param d Device the client was connected to.
     113 */
     114void on_client_close(device_t *d)
     115{
     116        /*
     117         * Maybe a virtual device is being unplugged.
     118         */
     119        virtdev_connection_t *dev = virtdev_find((sysarg_t)fibril_get_id());
     120        if (dev == NULL) {
     121                return;
     122        }
     123
     124        dprintf(0, "virtual device disconnected (id: %x)", dev->id);
     125        virtdev_destroy_device(dev);
     126}
     127
    112128
    113129/**
  • uspace/drv/vhc/devices.c

    rafc4fbb r6967c14  
    5959 *
    6060 * @param phone Callback phone.
     61 * @param id Device id.
    6162 * @return New device.
    6263 * @retval NULL Out of memory.
    6364 */
    64 virtdev_connection_t *virtdev_add_device(int phone)
     65virtdev_connection_t *virtdev_add_device(int phone, sysarg_t id)
    6566{
    6667        virtdev_connection_t *dev = (virtdev_connection_t *)
     
    7172
    7273        dev->phone = phone;
     74        dev->id = id;
    7375        list_append(&dev->link, &devices);
    7476       
     
    7678       
    7779        return dev;
     80}
     81
     82/** Find virtual device by id.
     83 *
     84 * @param id Device id.
     85 * @return Device with given id.
     86 * @retval NULL No such device.
     87 */
     88virtdev_connection_t *virtdev_find(sysarg_t id)
     89{
     90        link_t *pos;
     91        list_foreach(pos, &devices) {
     92                virtdev_connection_t *dev
     93                    = list_get_instance(pos, virtdev_connection_t, link);
     94                if (dev->id == id) {
     95                        return dev;
     96                }
     97        }
     98
     99        return NULL;
    78100}
    79101
  • uspace/drv/vhc/devices.h

    rafc4fbb r6967c14  
    4545        /** Phone used when sending data to device. */
    4646        int phone;
     47        /** Unique identification. */
     48        sysarg_t id;
    4749        /** Linked-list handle. */
    4850        link_t link;
    4951} virtdev_connection_t;
    5052
    51 virtdev_connection_t *virtdev_add_device(int);
    52 virtdev_connection_t *virtdev_get_mine(void);
     53virtdev_connection_t *virtdev_add_device(int, sysarg_t);
     54virtdev_connection_t *virtdev_find(sysarg_t);
    5355void virtdev_destroy_device(virtdev_connection_t *);
    5456usb_transaction_outcome_t virtdev_send_to_all(transaction_t *);
  • uspace/drv/vhc/hcd.c

    rafc4fbb r6967c14  
    6969        .interfaces[USBHC_DEV_IFACE] = &vhc_iface,
    7070        .interfaces[USB_DEV_IFACE] = &hc_usb_iface,
     71        .close = on_client_close,
    7172        .default_handler = default_connection_handler
    7273};
Note: See TracChangeset for help on using the changeset viewer.