Virtual USB host controller
[USB virtualization]

Driver simulating work of USB host controller. More...


Files

file  conn.h
 Connection handling of incoming calls.
file  conndev.c
 Connection handling of calls from virtual device (implementation).
file  connhost.c
 Host controller interface implementation.
file  hub.c
 Virtual USB hub.
file  hub.c
 Representation of an USB hub (implementation).
file  hub.h
 Virtual USB hub.
file  hub.h
 Representation of an USB hub.
file  main.c
 Virtual host controller.
file  vhcd.h
 Virtual USB host controller common definitions.
file  virthub.c
file  virthub.h
 USB hub as a virtual USB device.
file  virthubops.c
 Virtual USB hub operations.

Data Structures

struct  delay_port_state_change
 Structure for automatic (delayed) port state change. More...
struct  hub
 Hub device type. More...
struct  hub_descriptor_t
 Hub descriptor. More...
struct  hub_port_t
 Hub port information. More...
struct  vhc_data_t
struct  vhc_transfer_t
struct  vhc_virtdev_t

Defines

#define BITS2BYTES(bits)   (bits ? ((((bits)-1)>>3)+1) : 0)
#define CLASS_REQ(direction, recipient, req)
 Create a class request.
#define CLASS_REQ_IN(recipient)
 IN class request.
#define CLASS_REQ_OUT(recipient)
 OUT class request.
#define DIR_IN   USB_DIRECTION_IN
 Direction: in.
#define DIR_OUT   USB_DIRECTION_OUT
 Direction: out.
#define GET_VHC_DATA(fun)   ((vhc_data_t *)fun->dev->driver_data)
#define HUB_CONFIGURATION_ID   1
 Configuration value for hub configuration.
#define HUB_PORT_COUNT   2
#define HUB_STATUS_CHANGE_PIPE   1
 Endpoint number for status change pipe.
#define MAKE_BYTE(b0, b1, b2, b3, b4, b5, b6, b7)
 Produce a byte from bit values.
#define NAME   "vhc"
#define PLUGGED_DEVICE_NAME_MAXLEN   256
#define REC_DEVICE   USB_REQUEST_RECIPIENT_DEVICE
 Recipient: device.
#define REC_OTHER   USB_REQUEST_RECIPIENT_OTHER
 Recipient: other.
#define STD_REQ(direction, recipient, req)
 Create a standard request.
#define UNSUPPORTED(methodname)
#define VHC_DATA(vhc, fun)   vhc_data_t *vhc = GET_VHC_DATA(fun); assert(vhc->magic == 0xdeadbeef)

Typedefs

typedef hub hub_t

Enumerations

enum  hub_port_state_t
 Hub port internal state. More...
enum  hub_status_change_t
 Hub status change mask bits.

Functions

static int bind_address (ddf_fun_t *fun, usb_address_t address, devman_handle_t handle)
 Bind USB address with device devman handle.
static int bulk_in (ddf_fun_t *fun, usb_target_t target, void *data, size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
 Schedule bulk in transfer.
static int bulk_out (ddf_fun_t *fun, usb_target_t target, void *data, size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
 Schedule bulk out transfer.
static void clear_port_status_change (hub_port_t *port, uint16_t change)
 Clears a port status change on a port.
static int control_read (ddf_fun_t *fun, usb_target_t target, void *setup_packet, size_t setup_packet_size, void *data_buffer, size_t data_buffer_size, usbhc_iface_transfer_in_callback_t callback, void *arg)
 Schedule control read transfer.
static int control_write (ddf_fun_t *fun, usb_target_t target, void *setup_packet, size_t setup_packet_size, void *data_buffer, size_t data_buffer_size, usbhc_iface_transfer_out_callback_t callback, void *arg)
 Schedule control write transfer.
static int find_by_address (ddf_fun_t *fun, usb_address_t address, devman_handle_t *handle)
 Find device handle by address interface function.
static hub_port_tget_hub_port (hub_t *hub, size_t port)
 Find a port in a hub.
void hub_acquire (hub_t *hub)
 Acquire exclusive access to the hub.
void hub_clear_port_status_change (hub_t *hub, size_t port_index, hub_status_change_t change)
 Clear port status change bit.
size_t hub_connect_device (hub_t *hub, void *device)
 Connect a device to the hub.
int hub_disconnect_device (hub_t *hub, void *device)
 Disconnects a device from a hub.
size_t hub_find_device (hub_t *hub, void *device)
 Find port device is connected to.
hub_port_state_t hub_get_port_state (hub_t *hub, size_t port_index)
 Get port state.
uint32_t hub_get_port_status (hub_t *hub, size_t port_index)
 Get port status bits.
uint16_t hub_get_port_status_change (hub_t *hub, size_t port_index)
 Get port status change bits.
uint8_t hub_get_status_change_bitmap (hub_t *hub)
 Create hub status change bitmap.
void hub_init (hub_t *hub)
 Initialize the hub.
static void hub_init_port (hub_port_t *port, hub_t *hub, size_t index)
 Initialize single hub port.
char hub_port_state_to_char (hub_port_state_t state)
 Convert hub port state to a char.
static int hub_register_in_devman_fibril (void *arg)
 Register root hub in devman.
void hub_release (hub_t *hub)
 Give up exclusive access to the hub.
void hub_set_port_state (hub_t *hub, size_t port_index, hub_port_state_t state)
 Change port state.
void hub_set_port_state_all (hub_t *hub, hub_port_state_t state)
 Change state of all ports.
static int interrupt_in (ddf_fun_t *fun, usb_target_t target, void *data, size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
 Schedule interrupt in transfer.
static int interrupt_out (ddf_fun_t *fun, usb_target_t target, void *data, size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
 Schedule interrupt out transfer.
int main (int argc, char *argv[])
 Main entry point.
void on_client_close (ddf_fun_t *fun)
 Callback when client disconnects.
static void on_state_change (usbvirt_device_t *dev, usbvirt_device_state_t old_state, usbvirt_device_state_t new_state)
 Callback when device changes states.
static int pretend_port_rest (int unused, void *unused2)
static void receive_device_name (int phone)
 Receive device name.
static int register_endpoint (ddf_fun_t *fun, usb_address_t address, usb_speed_t speed, usb_endpoint_t endpoint, usb_transfer_type_t transfer_type, usb_direction_t direction, size_t max_packet_size, unsigned int interval)
 Register endpoint for bandwidth reservation.
static int release_address (ddf_fun_t *fun, usb_address_t address)
 Release previously requested address.
static int req_clear_hub_feature (usbvirt_device_t *dev, const usb_device_request_setup_packet_t *request, uint8_t *data, size_t *act_size)
 Handle ClearHubFeature request.
static int req_clear_port_feature (usbvirt_device_t *dev, const usb_device_request_setup_packet_t *request, uint8_t *data, size_t *act_size)
 Handle ClearPortFeature request.
static int req_get_bus_state (usbvirt_device_t *dev, const usb_device_request_setup_packet_t *request, uint8_t *data, size_t *act_size)
 Handle GetBusState request.
static int req_get_descriptor (usbvirt_device_t *dev, const usb_device_request_setup_packet_t *request, uint8_t *data, size_t *act_size)
 Handle GetDescriptor request.
static int req_get_hub_status (usbvirt_device_t *dev, const usb_device_request_setup_packet_t *request, uint8_t *data, size_t *act_size)
 Handle GetHubStatus request.
static int req_get_port_status (usbvirt_device_t *dev, const usb_device_request_setup_packet_t *request, uint8_t *data, size_t *act_size)
 Handle GetPortStatus request.
static int req_on_status_change_pipe (usbvirt_device_t *dev, usb_endpoint_t endpoint, usb_transfer_type_t tr_type, void *buffer, size_t buffer_size, size_t *actual_size)
 Callback for data request.
static int req_set_hub_feature (usbvirt_device_t *dev, const usb_device_request_setup_packet_t *request, uint8_t *data, size_t *act_size)
 Handle SetHubFeature request.
static int req_set_port_feature (usbvirt_device_t *dev, const usb_device_request_setup_packet_t *request, uint8_t *data, size_t *act_size)
 Handle SetPortFeature request.
static int request_address (ddf_fun_t *fun, usb_speed_t speed, usb_address_t *address)
 Found free USB address.
static void set_port_state_delayed (hub_t *hub, size_t port_index, suseconds_t delay_time_ms, hub_port_state_t old_state, hub_port_state_t new_state)
 Change port state with a delay.
static int set_port_state_delayed_fibril (void *arg)
 Fibril responsible for delayed port state change.
static void set_port_status_change (hub_port_t *port, hub_status_change_t change)
 Adds a port status change to a port.
static int tell_address (ddf_fun_t *fun, devman_handle_t handle, usb_address_t *address)
static int tell_address_rh (ddf_fun_t *root_hub_fun, devman_handle_t handle, usb_address_t *address)
static int unregister_endpoint (ddf_fun_t *fun, usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction)
 Unregister endpoint (free some bandwidth reservation).
static int usb_iface_get_hc_handle_rh_impl (ddf_fun_t *root_hub_fun, devman_handle_t *handle)
static int vhc_add_device (ddf_dev_t *dev)
vhc_transfer_tvhc_transfer_create (usb_address_t, usb_endpoint_t, usb_direction_t, usb_transfer_type_t, ddf_fun_t *, void *)
int vhc_transfer_queue_processor (void *arg)
int vhc_virtdev_add_transfer (vhc_data_t *, vhc_transfer_t *)
int vhc_virtdev_plug (vhc_data_t *, int, uintptr_t *)
int vhc_virtdev_plug_hub (vhc_data_t *, usbvirt_device_t *, uintptr_t *)
int vhc_virtdev_plug_local (vhc_data_t *, usbvirt_device_t *, uintptr_t *)
void vhc_virtdev_unplug (vhc_data_t *, uintptr_t)
int virthub_connect_device (usbvirt_device_t *dev, vhc_virtdev_t *conn)
 Connect a device to a virtual hub.
int virthub_disconnect_device (usbvirt_device_t *dev, vhc_virtdev_t *conn)
 Disconnect a device from a virtual hub.
void virthub_get_status (usbvirt_device_t *dev, char *status, size_t len)
 Format status of a virtual hub.
int virthub_init (usbvirt_device_t *dev)
 Initializes virtual hub device.
bool virthub_is_device_enabled (usbvirt_device_t *dev, vhc_virtdev_t *conn)
 Whether trafic is propagated to given device.
void virtual_hub_device_init (ddf_fun_t *hc_dev)

Variables

usbvirt_device_configuration_t configuration
 Hub configuration.
usbvirt_descriptors_t descriptors
 Hub standard descriptors.
usb_standard_endpoint_descriptor_t endpoint_descriptor
 Endpoint descriptor.
static usbvirt_control_request_handler_t endpoint_zero_handlers []
 Hub operations on control endpoint zero.
static usbvirt_device_configuration_extras_t extra_descriptors []
 All hub configuration descriptors.
hub_descriptor_t hub_descriptor
 Hub descriptor.
hub_descriptor_t hub_descriptor
 Hub descriptor.
usbvirt_device_ops_t hub_ops
 Hub operations.
usbvirt_device_ops_t hub_ops
 Hub operations.
static fibril_local uintptr_t plugged_device_handle = 0
static fibril_local char plugged_device_name [PLUGGED_DEVICE_NAME_MAXLEN+1] = "<unknown>"
static ddf_dev_ops_t rh_ops
usb_iface_t rh_usb_iface
usb_iface_t rh_usb_iface
usb_standard_configuration_descriptor_t std_configuration_descriptor
 Standard configuration descriptor.
usb_standard_device_descriptor_t std_device_descriptor
 Standard device descriptor.
usb_standard_interface_descriptor_t std_interface_descriptor
 Standard interface descriptor.
static driver_t vhc_driver
static driver_ops_t vhc_driver_ops
usbhc_iface_t vhc_iface
usbhc_iface_t vhc_iface
static ddf_dev_ops_t vhc_ops
usb_iface_t vhc_usb_iface
usb_iface_t vhc_usb_iface
usbvirt_device_t virtual_hub_device
usbvirt_device_t virtual_hub_device

Detailed Description

Driver simulating work of USB host controller.


Define Documentation

#define CLASS_REQ ( direction,
recipient,
req   ) 

Value:

.req_direction = direction, \
        .req_recipient = recipient, \
        .req_type = USB_REQUEST_TYPE_CLASS, \
        .request = req
Create a class request.

Parameters:
direction Request direction.
recipient Request recipient.
req Request code.

Definition at line 367 of file virthubops.c.

#define STD_REQ ( direction,
recipient,
req   ) 

Value:

.req_direction = direction, \
        .req_recipient = recipient, \
        .req_type = USB_REQUEST_TYPE_STANDARD, \
        .request = req
Create a standard request.

Parameters:
direction Request direction.
recipient Request recipient.
req Request code.

Definition at line 379 of file virthubops.c.


Enumeration Type Documentation

enum hub_port_state_t

Hub port internal state.

Some states (e.g. port over current) are not covered as they are not simulated at all.

Definition at line 49 of file hub.h.


Function Documentation

static int bind_address ( ddf_fun_t fun,
usb_address_t  address,
devman_handle_t  handle 
) [static]

Bind USB address with device devman handle.

Parameters:
[in] fun Device function the action was invoked on.
[in] address USB address of the device.
[in] handle Devman handle of the device.
Returns:
Error code.

Definition at line 84 of file connhost.c.

static int bulk_in ( ddf_fun_t fun,
usb_target_t  target,
void *  data,
size_t  size,
usbhc_iface_transfer_in_callback_t  callback,
void *  arg 
) [static]

Schedule bulk in transfer.

The callback is supposed to be called once the transfer (on the wire) is complete regardless of the outcome. However, the callback could be called only when this function returns with success status (i.e. returns EOK).

Parameters:
[in] fun Device function the action was invoked on.
[in] target Target pipe (address and endpoint number) specification.
[in] data Buffer where to store the data (in USB endianess, allocated and deallocated by the caller).
[in] size Size of the data buffer in bytes.
[in] callback Callback to be issued once the transfer is complete.
[in] arg Pass-through argument to the callback.
Returns:
Error code.

Definition at line 316 of file connhost.c.

static int bulk_out ( ddf_fun_t fun,
usb_target_t  target,
void *  data,
size_t  size,
usbhc_iface_transfer_out_callback_t  callback,
void *  arg 
) [static]

Schedule bulk out transfer.

The callback is supposed to be called once the transfer (on the wire) is complete regardless of the outcome. However, the callback could be called only when this function returns with success status (i.e. returns EOK).

Parameters:
[in] fun Device function the action was invoked on.
[in] target Target pipe (address and endpoint number) specification.
[in] data Data to be sent (in USB endianess, allocated and deallocated by the caller).
[in] size Size of the data buffer in bytes.
[in] callback Callback to be issued once the transfer is complete.
[in] arg Pass-through argument to the callback.
Returns:
Error code.

Definition at line 291 of file connhost.c.

static void clear_port_status_change ( hub_port_t port,
uint16_t  change 
) [static]

Clears a port status change on a port.

Parameters:
port The port with status change.
change Change to be removed from the status.

Definition at line 436 of file hub.c.

static int control_read ( ddf_fun_t fun,
usb_target_t  target,
void *  setup_packet,
size_t  setup_packet_size,
void *  data_buffer,
size_t  data_buffer_size,
usbhc_iface_transfer_in_callback_t  callback,
void *  arg 
) [static]

Schedule control read transfer.

The callback is supposed to be called once the transfer (on the wire) is complete regardless of the outcome. However, the callback could be called only when this function returns with success status (i.e. returns EOK).

Parameters:
[in] fun Device function the action was invoked on.
[in] target Target pipe (address and endpoint number) specification.
[in] setup_packet Setup packet buffer (in USB endianess, allocated and deallocated by the caller).
[in] setup_packet_size Size of setup_packet buffer in bytes.
[in] data_buffer Buffer where to store the data (in USB endianess, allocated and deallocated by the caller).
[in] data_buffer_size Size of data_buffer buffer in bytes.
[in] callback Callback to be issued once the transfer is complete.
[in] arg Pass-through argument to the callback.
Returns:
Error code.

Definition at line 392 of file connhost.c.

static int control_write ( ddf_fun_t fun,
usb_target_t  target,
void *  setup_packet,
size_t  setup_packet_size,
void *  data_buffer,
size_t  data_buffer_size,
usbhc_iface_transfer_out_callback_t  callback,
void *  arg 
) [static]

Schedule control write transfer.

The callback is supposed to be called once the transfer (on the wire) is complete regardless of the outcome. However, the callback could be called only when this function returns with success status (i.e. returns EOK).

Parameters:
[in] fun Device function the action was invoked on.
[in] target Target pipe (address and endpoint number) specification.
[in] setup_packet Setup packet buffer (in USB endianess, allocated and deallocated by the caller).
[in] setup_packet_size Size of setup_packet buffer in bytes.
[in] data_buffer Data buffer (in USB endianess, allocated and deallocated by the caller).
[in] data_buffer_size Size of data_buffer buffer in bytes.
[in] callback Callback to be issued once the transfer is complete.
[in] arg Pass-through argument to the callback.
Returns:
Error code.

Definition at line 344 of file connhost.c.

static int find_by_address ( ddf_fun_t fun,
usb_address_t  address,
devman_handle_t handle 
) [static]

Find device handle by address interface function.

Parameters:
[in] fun DDF function that was called.
[in] address Address in question.
[out] handle Where to store device handle if found.
Returns:
Error code.

Definition at line 102 of file connhost.c.

static hub_port_t * get_hub_port ( hub_t hub,
size_t  port 
) [static]

Find a port in a hub.

Parameters:
hub Hub in question.
port Port index (zero based).
Returns:
Port structure.
Return values:
NULL Invalid port index.

Definition at line 405 of file hub.c.

void hub_acquire ( hub_t hub  ) 

Acquire exclusive access to the hub.

Parameters:
hub Hub in question.

Definition at line 206 of file hub.c.

void hub_clear_port_status_change ( hub_t hub,
size_t  port_index,
hub_status_change_t  change 
)

Clear port status change bit.

Parameters:
hub Hub the port belongs to.
port_index Port index (zero based).
change Change to be cleared.

Definition at line 298 of file hub.c.

size_t hub_connect_device ( hub_t hub,
void *  device 
)

Connect a device to the hub.

Parameters:
hub Hub to connect device to.
device Device to be connected.
Returns:
Index of port the device was connected to.
Return values:
-1 No free port available.

Definition at line 129 of file hub.c.

int hub_disconnect_device ( hub_t hub,
void *  device 
)

Disconnects a device from a hub.

Parameters:
hub Hub the device was connected to.
device Device to be disconnected.
Returns:
Error code.

Definition at line 165 of file hub.c.

size_t hub_find_device ( hub_t hub,
void *  device 
)

Find port device is connected to.

Parameters:
hub Hub in question.
device Device in question.
Returns:
Port index (zero based).
Return values:
-1 Device is not connected.

Definition at line 188 of file hub.c.

hub_port_state_t hub_get_port_state ( hub_t hub,
size_t  port_index 
)

Get port state.

Parameters:
hub Hub the port belongs to.
port_index Port index (zero based).
Returns:
Port state.

Definition at line 282 of file hub.c.

uint32_t hub_get_port_status ( hub_t hub,
size_t  port_index 
)

Get port status bits.

Parameters:
hub Hub the port belongs to.
port_index Port index (zero based).
Returns:
Port status bitmap in standard format.

Definition at line 331 of file hub.c.

uint16_t hub_get_port_status_change ( hub_t hub,
size_t  port_index 
)

Get port status change bits.

Parameters:
hub Hub the port belongs to.
port_index Port index (zero based).
Returns:
Port status change bitmap in standard format.

Definition at line 315 of file hub.c.

uint8_t hub_get_status_change_bitmap ( hub_t hub  ) 

Create hub status change bitmap.

Warning:
This function assumes that the whole bitmap fits into 8 bits.
Parameters:
hub Hub in question.
Returns:
Hub status change bitmap.

Definition at line 375 of file hub.c.

void hub_init ( hub_t hub  ) 

Initialize the hub.

Parameters:
hub Hub to be initialized.

Definition at line 111 of file hub.c.

static void hub_init_port ( hub_port_t port,
hub_t hub,
size_t  index 
) [static]

Initialize single hub port.

Parameters:
port Port to be initialized.
index Port index (one based).

Definition at line 98 of file hub.c.

int hub_register_in_devman_fibril ( void *  arg  )  [static]

Register root hub in devman.

Parameters:
arg Host controller device (type device_t *).
Returns:
Error code.

Definition at line 92 of file hub.c.

void hub_release ( hub_t hub  ) 

Give up exclusive access to the hub.

Parameters:
hub Hub in question.

Definition at line 215 of file hub.c.

void hub_set_port_state ( hub_t hub,
size_t  port_index,
hub_port_state_t  state 
)

Change port state.

Parameters:
hub Hub the port belongs to.
port_index Port index (zero based).
state New port state.

Definition at line 226 of file hub.c.

void hub_set_port_state_all ( hub_t hub,
hub_port_state_t  state 
)

Change state of all ports.

Parameters:
hub Hub in question.
state New state for all ports.

Definition at line 268 of file hub.c.

static int interrupt_in ( ddf_fun_t fun,
usb_target_t  target,
void *  data,
size_t  size,
usbhc_iface_transfer_in_callback_t  callback,
void *  arg 
) [static]

Schedule interrupt in transfer.

The callback is supposed to be called once the transfer (on the wire) is complete regardless of the outcome. However, the callback could be called only when this function returns with success status (i.e. returns EOK).

Parameters:
[in] fun Device function the action was invoked on.
[in] target Target pipe (address and endpoint number) specification.
[in] data Buffer where to store the data (in USB endianess, allocated and deallocated by the caller).
[in] size Size of the data buffer in bytes.
[in] callback Callback to be issued once the transfer is complete.
[in] arg Pass-through argument to the callback.
Returns:
Error code.

Definition at line 249 of file connhost.c.

static int interrupt_out ( ddf_fun_t fun,
usb_target_t  target,
void *  data,
size_t  size,
usbhc_iface_transfer_out_callback_t  callback,
void *  arg 
) [static]

Schedule interrupt out transfer.

The callback is supposed to be called once the transfer (on the wire) is complete regardless of the outcome. However, the callback could be called only when this function returns with success status (i.e. returns EOK).

Parameters:
[in] fun Device function the action was invoked on.
[in] target Target pipe (address and endpoint number) specification.
[in] data Data to be sent (in USB endianess, allocated and deallocated by the caller).
[in] size Size of the data buffer in bytes.
[in] callback Callback to be issued once the transfer is complete.
[in] arg Pass-through argument to the callback.
Returns:
Error code.

Definition at line 207 of file connhost.c.

int main ( int  argc,
char *  argv[] 
)

Main entry point.

Parameters:
[in] argc Nmber of arguments in argv vector (ignored).
[in] argv Cmdline argument vector (ignored).
Returns:
Error code.
Driver debug level is set here.

Definition at line 141 of file main.c.

void on_client_close ( ddf_fun_t fun  ) 

Callback when client disconnects.

Used to unplug virtual USB device.

Parameters:
fun 

Definition at line 124 of file conndev.c.

static void receive_device_name ( int  phone  )  [static]

Receive device name.

Warning:
Errors are silently ignored.
Parameters:
phone Phone to the virtual device.

Definition at line 52 of file conndev.c.

static int register_endpoint ( ddf_fun_t fun,
usb_address_t  address,
usb_speed_t  speed,
usb_endpoint_t  endpoint,
usb_transfer_type_t  transfer_type,
usb_direction_t  direction,
size_t  max_packet_size,
unsigned int  interval 
) [static]

Register endpoint for bandwidth reservation.

Parameters:
[in] fun Device function the action was invoked on.
[in] address USB address of the device.
[in] speed Endpoint speed (invalid means to use device one).
[in] endpoint Endpoint number.
[in] transfer_type USB transfer type.
[in] direction Endpoint data direction.
[in] max_packet_size Max packet size of the endpoint.
[in] interval Polling interval.
Returns:
Error code.

Definition at line 138 of file connhost.c.

static int release_address ( ddf_fun_t fun,
usb_address_t  address 
) [static]

Release previously requested address.

Parameters:
[in] fun Device function the action was invoked on.
[in] address USB address to be released.
Returns:
Error code.

Definition at line 117 of file connhost.c.

static int req_clear_hub_feature ( usbvirt_device_t dev,
const usb_device_request_setup_packet_t request,
uint8_t *  data,
size_t act_size 
) [static]

Handle ClearHubFeature request.

Parameters:
dev Virtual device representing the hub.
request The SETUP packet of the control request.
data Extra data (when DATA stage present).
Returns:
Error code.

Definition at line 110 of file virthubops.c.

static int req_clear_port_feature ( usbvirt_device_t dev,
const usb_device_request_setup_packet_t request,
uint8_t *  data,
size_t act_size 
) [static]

Handle ClearPortFeature request.

Parameters:
dev Virtual device representing the hub.
request The SETUP packet of the control request.
data Extra data (when DATA stage present).
Returns:
Error code.

Definition at line 124 of file virthubops.c.

static int req_get_bus_state ( usbvirt_device_t dev,
const usb_device_request_setup_packet_t request,
uint8_t *  data,
size_t act_size 
) [static]

Handle GetBusState request.

Parameters:
dev Virtual device representing the hub.
request The SETUP packet of the control request.
data Extra data (when DATA stage present).
Returns:
Error code.

Definition at line 204 of file virthubops.c.

static int req_get_descriptor ( usbvirt_device_t dev,
const usb_device_request_setup_packet_t request,
uint8_t *  data,
size_t act_size 
) [static]

Handle GetDescriptor request.

Parameters:
dev Virtual device representing the hub.
request The SETUP packet of the control request.
data Extra data (when DATA stage present).
Returns:
Error code.

Definition at line 218 of file virthubops.c.

static int req_get_hub_status ( usbvirt_device_t dev,
const usb_device_request_setup_packet_t request,
uint8_t *  data,
size_t act_size 
) [static]

Handle GetHubStatus request.

Parameters:
dev Virtual device representing the hub.
request The SETUP packet of the control request.
data Extra data (when DATA stage present).
Returns:
Error code.

Definition at line 239 of file virthubops.c.

static int req_get_port_status ( usbvirt_device_t dev,
const usb_device_request_setup_packet_t request,
uint8_t *  data,
size_t act_size 
) [static]

Handle GetPortStatus request.

Parameters:
dev Virtual device representing the hub.
request The SETUP packet of the control request.
data Extra data (when DATA stage present).
Returns:
Error code.

Definition at line 258 of file virthubops.c.

static int req_set_hub_feature ( usbvirt_device_t dev,
const usb_device_request_setup_packet_t request,
uint8_t *  data,
size_t act_size 
) [static]

Handle SetHubFeature request.

Parameters:
dev Virtual device representing the hub.
request The SETUP packet of the control request.
data Extra data (when DATA stage present).
Returns:
Error code.

Definition at line 283 of file virthubops.c.

static int req_set_port_feature ( usbvirt_device_t dev,
const usb_device_request_setup_packet_t request,
uint8_t *  data,
size_t act_size 
) [static]

Handle SetPortFeature request.

Parameters:
dev Virtual device representing the hub.
request The SETUP packet of the control request.
data Extra data (when DATA stage present).
Returns:
Error code.

Definition at line 297 of file virthubops.c.

static int request_address ( ddf_fun_t fun,
usb_speed_t  speed,
usb_address_t address 
) [static]

Found free USB address.

Parameters:
[in] fun Device function the action was invoked on.
[in] speed Speed of the device that will get this address.
[out] address Non-null pointer where to store the free address.
Returns:
Error code.

Definition at line 59 of file connhost.c.

static void set_port_state_delayed ( hub_t hub,
size_t  port_index,
suseconds_t  delay_time_ms,
hub_port_state_t  old_state,
hub_port_state_t  new_state 
) [static]

Change port state with a delay.

Warning:
If the port state changes during the waiting phase, the state is not changed.
Parameters:
hub Hub in question.
port_index Port index (zero based).
delay_time_ms Delay time in miliseconds.
old_state Old (current) state of the port.
new_state New state of the port.

Definition at line 498 of file hub.c.

static int set_port_state_delayed_fibril ( void *  arg  )  [static]

Fibril responsible for delayed port state change.

Parameters:
arg Pointer to delay_port_state_change.
Returns:
Always EOK.

Definition at line 463 of file hub.c.

static void set_port_status_change ( hub_port_t port,
hub_status_change_t  change 
) [static]

Adds a port status change to a port.

Parameters:
port The port with status change.
change Change to be added to the status.

Definition at line 419 of file hub.c.

static int unregister_endpoint ( ddf_fun_t fun,
usb_address_t  address,
usb_endpoint_t  endpoint,
usb_direction_t  direction 
) [static]

Unregister endpoint (free some bandwidth reservation).

Parameters:
[in] fun Device function the action was invoked on.
[in] address USB address of the device.
[in] endpoint Endpoint number.
[in] direction Endpoint data direction.
Returns:
Error code.

Definition at line 174 of file connhost.c.

int virthub_connect_device ( usbvirt_device_t dev,
vhc_virtdev_t conn 
)

Connect a device to a virtual hub.

Parameters:
dev Virtual device representing the hub.
conn Device to be connected.
Returns:
Port device was connected to.

Definition at line 172 of file virthub.c.

int virthub_disconnect_device ( usbvirt_device_t dev,
vhc_virtdev_t conn 
)

Disconnect a device from a virtual hub.

Parameters:
dev Virtual device representing the hub.
conn Device to be disconnected.
Returns:
Error code.

Definition at line 192 of file virthub.c.

void virthub_get_status ( usbvirt_device_t dev,
char *  status,
size_t  len 
)

Format status of a virtual hub.

Parameters:
dev Virtual device representing the hub.
[out] status Hub status information.
[in] len Size of the status buffer.

Definition at line 237 of file virthub.c.

int virthub_init ( usbvirt_device_t dev  ) 

Initializes virtual hub device.

Parameters:
dev Virtual USB device backend.
Returns:
Error code.

Definition at line 147 of file virthub.c.

bool virthub_is_device_enabled ( usbvirt_device_t dev,
vhc_virtdev_t conn 
)

Whether trafic is propagated to given device.

Parameters:
dev Virtual device representing the hub.
conn Connected device.
Returns:
Whether port is signalling to the device.

Definition at line 212 of file virthub.c.


Generated on Thu Jun 2 07:45:56 2011 for HelenOS/USB by  doxygen 1.4.7