Changeset dc06caa in mainline
- Timestamp:
- 2011-05-06T15:33:58Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e25a849
- Parents:
- a943106
- Location:
- uspace/lib/usbvirt
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbvirt/include/usbvirt/device.h
ra943106 rdc06caa 86 86 uint8_t *data, size_t *act_data_size); 87 87 88 /** Callback for control request on a virtual USB device. */ 88 /** Callback for control request on a virtual USB device. 89 * 90 * See usbvirt_control_reply_helper() for simple way of answering 91 * control read requests. 92 */ 89 93 typedef struct { 90 94 /** Request direction (in or out). */ -
uspace/lib/usbvirt/src/ctrltransfer.c
ra943106 rdc06caa 1 /* 2 * Copyright (c) 2011 Vojtech Horky 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** @addtogroup libusbvirt 30 * @{ 31 */ 32 /** @file 33 * Control transfer handling. 34 */ 1 35 #include "private.h" 2 36 #include <usb/request.h> … … 5 39 #include <errno.h> 6 40 41 /** Find and execute control transfer handler for virtual USB device. 42 * 43 * @param dev Target virtual device. 44 * @param control_handlers Array of control request handlers. 45 * @param setup Setup packet. 46 * @param data Extra data. 47 * @param data_sent_size Size of extra data in bytes. 48 * @return Error code. 49 * @retval EFORWARD No suitable handler found. 50 */ 7 51 int process_control_transfer(usbvirt_device_t *dev, 8 52 usbvirt_control_request_handler_t *control_handlers, … … 52 96 return EFORWARD; 53 97 } 98 99 100 /** 101 * @} 102 */ -
uspace/lib/usbvirt/src/ipc.c
ra943106 rdc06caa 273 273 } 274 274 275 /** Connect the device to the virtual host controller. 276 * 277 * @param dev The virtual device to be (virtually) plugged in. 278 * @param vhc_path Devman path to the virtual host controller. 279 * @return Error code. 280 */ 275 281 int usbvirt_device_plug(usbvirt_device_t *dev, const char *vhc_path) 276 282 { -
uspace/lib/usbvirt/src/private.h
ra943106 rdc06caa 1 /* 2 * Copyright (c) 2011 Vojtech Horky 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** @addtogroup libusbvirt 30 * @{ 31 */ 32 /** @file 33 * Private definitions. 34 */ 35 #ifndef USBVIRT_PRIVATE_H_ 36 #define USBVIRT_PRIVATE_H_ 37 1 38 #include <usbvirt/device.h> 2 39 … … 7 44 8 45 extern usbvirt_control_request_handler_t library_handlers[]; 46 47 #endif 48 /** 49 * @} 50 */ -
uspace/lib/usbvirt/src/stdreq.c
ra943106 rdc06caa 1 /* 2 * Copyright (c) 2011 Vojtech Horky 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** @addtogroup libusbvirt 30 * @{ 31 */ 32 /** @file 33 * Standard control request handlers. 34 */ 1 35 #include "private.h" 2 36 #include <usb/request.h> … … 4 38 #include <errno.h> 5 39 40 /** Helper for replying to control read transfer from virtual USB device. 41 * 42 * This function takes care of copying data to answer buffer taking care 43 * of buffer sizes properly. 44 * 45 * @param setup_packet The setup packet. 46 * @param data Data buffer to write to. 47 * @param act_size Where to write actual size of returned data. 48 * @param actual_data Data to be returned. 49 * @param actual_data_size Size of answer data (@p actual_data) in bytes. 50 */ 6 51 void usbvirt_control_reply_helper(const usb_device_request_setup_packet_t *setup_packet, 7 52 uint8_t *data, size_t *act_size, … … 144 189 } 145 190 191 /** Standard request handlers. */ 146 192 usbvirt_control_request_handler_t library_handlers[] = { 147 193 { … … 173 219 }; 174 220 221 /** 222 * @} 223 */ -
uspace/lib/usbvirt/src/transfer.c
ra943106 rdc06caa 31 31 */ 32 32 /** @file 33 * 33 * Transfer handling. 34 34 */ 35 35 #include <usbvirt/device.h> … … 39 39 #include "private.h" 40 40 41 /** Process a control transfer to the virtual USB device. 42 * 43 * @param dev Target device. 44 * @param setup Setup packet data. 45 * @param setup_size Size of setup packet. 46 * @param data Extra data (DATA stage). 47 * @param data_size Size of extra data in bytes. 48 * @param data_size_sent Number of actually send bytes during the transfer 49 * (only used for READ transfers). 50 * @return Error code. 51 */ 41 52 static int usbvirt_control_transfer(usbvirt_device_t *dev, 42 53 void *setup, size_t setup_size, … … 78 89 } 79 90 91 /** Issue a control write transfer to virtual USB device. 92 * 93 * @see usbvirt_control_transfer 94 * 95 * @param dev Target virtual device. 96 * @param setup Setup data. 97 * @param setup_size Size of setup packet. 98 * @param data Extra data (DATA stage). 99 * @param data_size Size of extra data buffer in bytes. 100 * @return Error code. 101 */ 80 102 int usbvirt_control_write(usbvirt_device_t *dev, void *setup, size_t setup_size, 81 103 void *data, size_t data_size) … … 85 107 } 86 108 109 /** Issue a control read transfer to virtual USB device. 110 * 111 * @see usbvirt_control_transfer 112 * 113 * @param dev Target virtual device. 114 * @param setup Setup data. 115 * @param setup_size Size of setup packet. 116 * @param data Extra data (DATA stage). 117 * @param data_size Size of extra data buffer in bytes. 118 * @param data_size_sent Number of actually send bytes during the transfer. 119 * @return Error code. 120 */ 87 121 int usbvirt_control_read(usbvirt_device_t *dev, void *setup, size_t setup_size, 88 122 void *data, size_t data_size, size_t *data_size_sent) … … 92 126 } 93 127 128 /** Send data to virtual USB device. 129 * 130 * @param dev Target virtual device. 131 * @param transf_type Transfer type (interrupt, bulk). 132 * @param endpoint Endpoint number. 133 * @param data Data sent from the driver to the device. 134 * @param data_size Size of the @p data buffer in bytes. 135 * @return Error code. 136 */ 94 137 int usbvirt_data_out(usbvirt_device_t *dev, usb_transfer_type_t transf_type, 95 138 usb_endpoint_t endpoint, void *data, size_t data_size) … … 108 151 } 109 152 153 /** Request data from virtual USB device. 154 * 155 * @param dev Target virtual device. 156 * @param transf_type Transfer type (interrupt, bulk). 157 * @param endpoint Endpoint number. 158 * @param data Where to stored data the device returns to the driver. 159 * @param data_size Size of the @p data buffer in bytes. 160 * @param data_size_sent Number of actually written bytes. 161 * @return Error code. 162 */ 110 163 int usbvirt_data_in(usbvirt_device_t *dev, usb_transfer_type_t transf_type, 111 164 usb_endpoint_t endpoint, void *data, size_t data_size, size_t *data_size_sent)
Note:
See TracChangeset
for help on using the changeset viewer.