source: mainline/uspace/drv/bus/usb/vhc/vhcd.h@ a46e56b

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since a46e56b was a46e56b, checked in by Jakub Jermar <jakub@…>, 7 years ago

Prefer handle over ID in naming handle variables

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 * Copyright (c) 2010 Vojtech Horky
3 * Copyright (c) 2018 Ondrej Hlavaty
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @addtogroup drvusbvhc
31 * @{
32 */
33/** @file
34 * @brief Virtual USB host controller common definitions.
35 */
36
37#ifndef VHCD_VHCD_H_
38#define VHCD_VHCD_H_
39
40#include <usbvirt/device.h>
41#include <async.h>
42#include <macros.h>
43
44#include <usb/host/hcd.h>
45#include <usb/host/usb2_bus.h>
46#include <usb/host/usb_transfer_batch.h>
47
48#define NAME "vhc"
49
50typedef struct {
51 link_t link;
52 async_sess_t *dev_sess;
53 usbvirt_device_t *dev_local;
54 bool plugged;
55 usb_address_t address;
56 fibril_mutex_t guard;
57 list_t transfer_queue;
58} vhc_virtdev_t;
59
60typedef struct {
61 hc_device_t base;
62
63 bus_t bus;
64 usb2_bus_helper_t bus_helper;
65
66 ddf_fun_t *virtual_fun;
67 list_t devices;
68 fibril_mutex_t guard;
69 usbvirt_device_t hub;
70} vhc_data_t;
71
72typedef struct {
73 usb_transfer_batch_t batch;
74 link_t link;
75} vhc_transfer_t;
76
77static inline vhc_data_t *hcd_to_vhc(hc_device_t *hcd)
78{
79 assert(hcd);
80 return (vhc_data_t *) hcd;
81}
82
83static inline vhc_data_t *bus_to_vhc(bus_t *bus)
84{
85 assert(bus);
86 return member_to_inst(bus, vhc_data_t, bus);
87}
88
89void on_client_close(ddf_fun_t *fun);
90void default_connection_handler(ddf_fun_t *fun, cap_call_handle_t icall_handle,
91 ipc_call_t *icall);
92
93errno_t vhc_virtdev_plug(vhc_data_t *, async_sess_t *, uintptr_t *);
94errno_t vhc_virtdev_plug_local(vhc_data_t *, usbvirt_device_t *, uintptr_t *);
95errno_t vhc_virtdev_plug_hub(vhc_data_t *, usbvirt_device_t *, uintptr_t *,
96 usb_address_t address);
97void vhc_virtdev_unplug(vhc_data_t *, uintptr_t);
98
99errno_t vhc_init(vhc_data_t *);
100errno_t vhc_schedule(usb_transfer_batch_t *);
101errno_t vhc_transfer_queue_processor(void *arg);
102
103#endif
104
105/**
106 * @}
107 */
Note: See TracBrowser for help on using the repository browser.