Changeset 72af8da in mainline for uspace/drv/uhci-hcd/iface.c
- Timestamp:
- 2011-03-16T18:50:17Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 42a3a57
- Parents:
- 3e7b7cd (diff), fcf07e6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/iface.c
r3e7b7cd r72af8da 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup usb28 /** @addtogroup drvusbuhcihc 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI driver 32 * @brief UHCI driver hc interface implementation 33 33 */ 34 34 #include <ddf/driver.h> … … 40 40 41 41 #include "iface.h" 42 #include "uhci .h"42 #include "uhci_hc.h" 43 43 #include "utils/device_keeper.h" 44 44 45 /** Reserve default address interface function 46 * 47 * @param[in] fun DDF function that was called. 48 * @param[in] speed Speed to associate with the new default address. 49 * @return Error code. 50 */ 45 51 /*----------------------------------------------------------------------------*/ 46 52 static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed) 47 53 { 48 54 assert(fun); 49 uhci_ t *hc = fun_to_uhci(fun);55 uhci_hc_t *hc = fun_to_uhci_hc(fun); 50 56 assert(hc); 51 57 usb_log_debug("Default address request with speed %d.\n", speed); … … 54 60 } 55 61 /*----------------------------------------------------------------------------*/ 62 /** Release default address interface function 63 * 64 * @param[in] fun DDF function that was called. 65 * @return Error code. 66 */ 56 67 static int release_default_address(ddf_fun_t *fun) 57 68 { 58 69 assert(fun); 59 uhci_ t *hc = fun_to_uhci(fun);70 uhci_hc_t *hc = fun_to_uhci_hc(fun); 60 71 assert(hc); 61 72 usb_log_debug("Default address release.\n"); … … 64 75 } 65 76 /*----------------------------------------------------------------------------*/ 77 /** Request address interface function 78 * 79 * @param[in] fun DDF function that was called. 80 * @param[in] speed Speed to associate with the new default address. 81 * @param[out] address Place to write a new address. 82 * @return Error code. 83 */ 66 84 static int request_address(ddf_fun_t *fun, usb_speed_t speed, 67 85 usb_address_t *address) 68 86 { 69 87 assert(fun); 70 uhci_ t *hc = fun_to_uhci(fun);88 uhci_hc_t *hc = fun_to_uhci_hc(fun); 71 89 assert(hc); 72 90 assert(address); … … 80 98 } 81 99 /*----------------------------------------------------------------------------*/ 100 /** Bind address interface function 101 * 102 * @param[in] fun DDF function that was called. 103 * @param[in] address Address of the device 104 * @param[in] handle Devman handle of the device driver. 105 * @return Error code. 106 */ 82 107 static int bind_address( 83 108 ddf_fun_t *fun, usb_address_t address, devman_handle_t handle) 84 109 { 85 110 assert(fun); 86 uhci_ t *hc = fun_to_uhci(fun);111 uhci_hc_t *hc = fun_to_uhci_hc(fun); 87 112 assert(hc); 88 113 usb_log_debug("Address bind %d-%d.\n", address, handle); … … 91 116 } 92 117 /*----------------------------------------------------------------------------*/ 118 /** Release address interface function 119 * 120 * @param[in] fun DDF function that was called. 121 * @param[in] address USB address to be released. 122 * @return Error code. 123 */ 93 124 static int release_address(ddf_fun_t *fun, usb_address_t address) 94 125 { 95 126 assert(fun); 96 uhci_ t *hc = fun_to_uhci(fun);127 uhci_hc_t *hc = fun_to_uhci_hc(fun); 97 128 assert(hc); 98 129 usb_log_debug("Address release %d.\n", address); … … 101 132 } 102 133 /*----------------------------------------------------------------------------*/ 134 /** Interrupt out transaction interface function 135 * 136 * @param[in] fun DDF function that was called. 137 * @param[in] target USB device to write to. 138 * @param[in] max_packet_size maximum size of data packet the device accepts 139 * @param[in] data Source of data. 140 * @param[in] size Size of data source. 141 * @param[in] callback Function to call on transaction completion 142 * @param[in] arg Additional for callback function. 143 * @return Error code. 144 */ 103 145 static int interrupt_out(ddf_fun_t *fun, usb_target_t target, 104 146 size_t max_packet_size, void *data, size_t size, … … 106 148 { 107 149 assert(fun); 108 uhci_ t *hc = fun_to_uhci(fun);150 uhci_hc_t *hc = fun_to_uhci_hc(fun); 109 151 assert(hc); 110 152 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address); … … 114 156 115 157 batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT, 116 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg); 158 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg, 159 &hc->device_manager); 117 160 if (!batch) 118 161 return ENOMEM; 119 162 batch_interrupt_out(batch); 120 return EOK; 121 } 122 /*----------------------------------------------------------------------------*/ 163 const int ret = uhci_hc_schedule(hc, batch); 164 if (ret != EOK) { 165 batch_dispose(batch); 166 return ret; 167 } 168 return EOK; 169 } 170 /*----------------------------------------------------------------------------*/ 171 /** Interrupt in transaction interface function 172 * 173 * @param[in] fun DDF function that was called. 174 * @param[in] target USB device to write to. 175 * @param[in] max_packet_size maximum size of data packet the device accepts 176 * @param[out] data Data destination. 177 * @param[in] size Size of data source. 178 * @param[in] callback Function to call on transaction completion 179 * @param[in] arg Additional for callback function. 180 * @return Error code. 181 */ 123 182 static int interrupt_in(ddf_fun_t *fun, usb_target_t target, 124 183 size_t max_packet_size, void *data, size_t size, … … 126 185 { 127 186 assert(fun); 128 uhci_ t *hc = fun_to_uhci(fun);187 uhci_hc_t *hc = fun_to_uhci_hc(fun); 129 188 assert(hc); 130 189 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address); … … 133 192 134 193 batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT, 135 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg); 194 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg, 195 &hc->device_manager); 136 196 if (!batch) 137 197 return ENOMEM; 138 198 batch_interrupt_in(batch); 139 return EOK; 140 } 141 /*----------------------------------------------------------------------------*/ 199 const int ret = uhci_hc_schedule(hc, batch); 200 if (ret != EOK) { 201 batch_dispose(batch); 202 return ret; 203 } 204 return EOK; 205 } 206 /*----------------------------------------------------------------------------*/ 207 /** Bulk out transaction interface function 208 * 209 * @param[in] fun DDF function that was called. 210 * @param[in] target USB device to write to. 211 * @param[in] max_packet_size maximum size of data packet the device accepts 212 * @param[in] data Source of data. 213 * @param[in] size Size of data source. 214 * @param[in] callback Function to call on transaction completion 215 * @param[in] arg Additional for callback function. 216 * @return Error code. 217 */ 218 static int bulk_out(ddf_fun_t *fun, usb_target_t target, 219 size_t max_packet_size, void *data, size_t size, 220 usbhc_iface_transfer_out_callback_t callback, void *arg) 221 { 222 assert(fun); 223 uhci_hc_t *hc = fun_to_uhci_hc(fun); 224 assert(hc); 225 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address); 226 227 usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n", 228 target.address, target.endpoint, size, max_packet_size); 229 230 batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK, 231 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg, 232 &hc->device_manager); 233 if (!batch) 234 return ENOMEM; 235 batch_bulk_out(batch); 236 const int ret = uhci_hc_schedule(hc, batch); 237 if (ret != EOK) { 238 batch_dispose(batch); 239 return ret; 240 } 241 return EOK; 242 } 243 /*----------------------------------------------------------------------------*/ 244 /** Bulk in transaction interface function 245 * 246 * @param[in] fun DDF function that was called. 247 * @param[in] target USB device to write to. 248 * @param[in] max_packet_size maximum size of data packet the device accepts 249 * @param[out] data Data destination. 250 * @param[in] size Size of data source. 251 * @param[in] callback Function to call on transaction completion 252 * @param[in] arg Additional for callback function. 253 * @return Error code. 254 */ 255 static int bulk_in(ddf_fun_t *fun, usb_target_t target, 256 size_t max_packet_size, void *data, size_t size, 257 usbhc_iface_transfer_in_callback_t callback, void *arg) 258 { 259 assert(fun); 260 uhci_hc_t *hc = fun_to_uhci_hc(fun); 261 assert(hc); 262 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address); 263 usb_log_debug("Bulk IN %d:%d %zu(%zu).\n", 264 target.address, target.endpoint, size, max_packet_size); 265 266 batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK, 267 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg, 268 &hc->device_manager); 269 if (!batch) 270 return ENOMEM; 271 batch_bulk_in(batch); 272 const int ret = uhci_hc_schedule(hc, batch); 273 if (ret != EOK) { 274 batch_dispose(batch); 275 return ret; 276 } 277 return EOK; 278 } 279 /*----------------------------------------------------------------------------*/ 280 /** Control write transaction interface function 281 * 282 * @param[in] fun DDF function that was called. 283 * @param[in] target USB device to write to. 284 * @param[in] max_packet_size maximum size of data packet the device accepts. 285 * @param[in] setup_data Data to send with SETUP packet. 286 * @param[in] setup_size Size of data to send with SETUP packet (should be 8B). 287 * @param[in] data Source of data. 288 * @param[in] size Size of data source. 289 * @param[in] callback Function to call on transaction completion. 290 * @param[in] arg Additional for callback function. 291 * @return Error code. 292 */ 142 293 static int control_write(ddf_fun_t *fun, usb_target_t target, 143 294 size_t max_packet_size, … … 146 297 { 147 298 assert(fun); 148 uhci_t *hc = fun_to_uhci(fun); 149 assert(hc); 150 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address); 151 usb_log_debug("Control WRITE %d:%d %zu(%zu).\n", 152 target.address, target.endpoint, size, max_packet_size); 299 uhci_hc_t *hc = fun_to_uhci_hc(fun); 300 assert(hc); 301 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address); 302 usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n", 303 speed, target.address, target.endpoint, size, max_packet_size); 304 305 if (setup_size != 8) 306 return EINVAL; 153 307 154 308 batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 155 309 max_packet_size, speed, data, size, setup_data, setup_size, 156 NULL, callback, arg); 157 if (!batch) 158 return ENOMEM; 310 NULL, callback, arg, &hc->device_manager); 311 if (!batch) 312 return ENOMEM; 313 device_keeper_reset_if_need(&hc->device_manager, target, setup_data); 159 314 batch_control_write(batch); 160 return EOK; 161 } 162 /*----------------------------------------------------------------------------*/ 315 const int ret = uhci_hc_schedule(hc, batch); 316 if (ret != EOK) { 317 batch_dispose(batch); 318 return ret; 319 } 320 return EOK; 321 } 322 /*----------------------------------------------------------------------------*/ 323 /** Control read transaction interface function 324 * 325 * @param[in] fun DDF function that was called. 326 * @param[in] target USB device to write to. 327 * @param[in] max_packet_size maximum size of data packet the device accepts. 328 * @param[in] setup_data Data to send with SETUP packet. 329 * @param[in] setup_size Size of data to send with SETUP packet (should be 8B). 330 * @param[out] data Source of data. 331 * @param[in] size Size of data source. 332 * @param[in] callback Function to call on transaction completion. 333 * @param[in] arg Additional for callback function. 334 * @return Error code. 335 */ 163 336 static int control_read(ddf_fun_t *fun, usb_target_t target, 164 337 size_t max_packet_size, … … 167 340 { 168 341 assert(fun); 169 uhci_ t *hc = fun_to_uhci(fun);170 assert(hc); 171 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address); 172 173 usb_log_debug("Control READ %d:%d %zu(%zu).\n",174 target.address, target.endpoint, size, max_packet_size);342 uhci_hc_t *hc = fun_to_uhci_hc(fun); 343 assert(hc); 344 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address); 345 346 usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n", 347 speed, target.address, target.endpoint, size, max_packet_size); 175 348 batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 176 349 max_packet_size, speed, data, size, setup_data, setup_size, callback, 177 NULL, arg );350 NULL, arg, &hc->device_manager); 178 351 if (!batch) 179 352 return ENOMEM; 180 353 batch_control_read(batch); 181 return EOK; 182 } 183 184 185 /*----------------------------------------------------------------------------*/ 186 usbhc_iface_t uhci_iface = { 354 const int ret = uhci_hc_schedule(hc, batch); 355 if (ret != EOK) { 356 batch_dispose(batch); 357 return ret; 358 } 359 return EOK; 360 } 361 /*----------------------------------------------------------------------------*/ 362 usbhc_iface_t uhci_hc_iface = { 187 363 .reserve_default_address = reserve_default_address, 188 364 .release_default_address = release_default_address, … … 194 370 .interrupt_in = interrupt_in, 195 371 372 .bulk_in = bulk_in, 373 .bulk_out = bulk_out, 374 196 375 .control_read = control_read, 197 376 .control_write = control_write,
Note:
See TracChangeset
for help on using the changeset viewer.