Changeset 186d630 in mainline


Ignore:
Timestamp:
2010-10-20T20:44:55Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bbfb86c
Parents:
47e3a8e
Message:

libusbvirt allows local device

By local device is meant virtual device in current task
(i.e. not connected through phones but called statically).

Location:
uspace/lib/usbvirt
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbvirt/device.h

    r47e3a8e r186d630  
    128128            usb_endpoint_t endpoint, void *buffer, size_t size);
    129129       
    130        
    131        
    132130        /* Device attributes. */
    133131       
     
    152150         */
    153151        int device_id_;
     152       
     153        /** Main routine called when data is received from HC.
     154         * @warning Do not change after initializing with
     155         * usbvirt_device_init().
     156         * This function is here merely to make the interface more OOP.
     157         */
     158        int (*receive_data)(struct usbvirt_device *dev,
     159            usb_endpoint_t endpoint, void *buffer, size_t size);
     160       
    154161} usbvirt_device_t;
    155162
  • uspace/lib/usbvirt/hub.h

    r47e3a8e r186d630  
    4646int usbvirt_connect(usbvirt_device_t *, const char *);
    4747int usbvirt_disconnect(void);
     48int usbvirt_connect_local(usbvirt_device_t *);
    4849
    4950#endif
  • uspace/lib/usbvirt/incoming.c

    r47e3a8e r186d630  
    3838#include "private.h"
    3939
    40 int handle_incoming_data(usb_endpoint_t endpoint, void *buffer, size_t size)
     40int handle_incoming_data(struct usbvirt_device *dev,
     41    usb_endpoint_t endpoint, void *buffer, size_t size)
    4142{
    4243        /*
  • uspace/lib/usbvirt/main.c

    r47e3a8e r186d630  
    6969        }
    7070       
    71         handle_incoming_data(endpoint, buffer, len);
     71        device->receive_data(device, endpoint, buffer, len);
    7272       
    7373        free(buffer);
     
    104104{
    105105        dev->send_data = usbvirt_data_to_host;
     106        dev->receive_data = handle_incoming_data;
    106107        dev->state = USBVIRT_STATE_DEFAULT;
    107108        dev->address = 0;
     
    160161 * @param hcd_path HCD identification under devfs
    161162 *     (without <code>/dev/usb/</code>).
    162  * @param device_id Internal device identification (used by HCD).
    163  * @param callback Handler for callbacks from HCD.
     163 * @param dev Device to connect.
    164164 * @return EOK on success or error code from errno.h.
    165165 */
     
    197197}
    198198
    199 
     199/** Prepares device as local.
     200 * This is useful if you want to have a virtual device in the same task
     201 * as HCD.
     202 *
     203 * @param dev Device to connect.
     204 * @return Always EOK.
     205 */
     206int usbvirt_connect_local(usbvirt_device_t *dev)
     207{
     208        dev->vhcd_phone_ = -1;
     209        device_init(dev);
     210       
     211        return EOK;
     212}
     213
     214/** Disconnects device from HCD.
     215 *
     216 * @return Always EOK.
     217 */
    200218int usbvirt_disconnect(void)
    201219{
  • uspace/lib/usbvirt/private.h

    r47e3a8e r186d630  
    5151    usb_endpoint_t endpoint, void *buffer, size_t size);
    5252
    53 int handle_incoming_data(usb_endpoint_t endpoint, void *buffer, size_t size);
     53int handle_incoming_data(struct usbvirt_device *dev,
     54    usb_endpoint_t endpoint, void *buffer, size_t size);
    5455
    5556int control_pipe(void *buffer, size_t size);
Note: See TracChangeset for help on using the changeset viewer.