Changes in uspace/lib/drv/generic/remote_usbhc.c [357a302:b7d8fd9] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhc.c
r357a302 rb7d8fd9 35 35 #include <async.h> 36 36 #include <errno.h> 37 #include <assert.h> 37 38 38 39 #include "usbhc_iface.h" 39 #include "d river.h"40 #include "ddf/driver.h" 40 41 41 42 #define USB_MAX_PAYLOAD_SIZE 1020 … … 43 44 #define HACK_MAX_PACKET_SIZE_INTERRUPT_IN 4 44 45 45 static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *); 46 static void remote_usbhc_interrupt_in(device_t *, void *, ipc_callid_t, ipc_call_t *); 47 static void remote_usbhc_bulk_out(device_t *, void *, ipc_callid_t, ipc_call_t *); 48 static void remote_usbhc_bulk_in(device_t *, void *, ipc_callid_t, ipc_call_t *); 49 static void remote_usbhc_control_write(device_t *, void *, ipc_callid_t, ipc_call_t *); 50 static void remote_usbhc_control_read(device_t *, void *, ipc_callid_t, ipc_call_t *); 51 static void remote_usbhc_reserve_default_address(device_t *, void *, ipc_callid_t, ipc_call_t *); 52 static void remote_usbhc_release_default_address(device_t *, void *, ipc_callid_t, ipc_call_t *); 53 static void remote_usbhc_request_address(device_t *, void *, ipc_callid_t, ipc_call_t *); 54 static void remote_usbhc_bind_address(device_t *, void *, ipc_callid_t, ipc_call_t *); 55 static void remote_usbhc_release_address(device_t *, void *, ipc_callid_t, ipc_call_t *); 56 //static void remote_usbhc(device_t *, void *, ipc_callid_t, ipc_call_t *); 46 static void remote_usbhc_interrupt_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 47 static void remote_usbhc_interrupt_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 48 static void remote_usbhc_bulk_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 49 static void remote_usbhc_bulk_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 50 static void remote_usbhc_control_write(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 51 static void remote_usbhc_control_read(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 52 static void remote_usbhc_reserve_default_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 53 static void remote_usbhc_release_default_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 54 static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 55 static void remote_usbhc_bind_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 56 static void remote_usbhc_release_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 57 static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 58 static void remote_usbhc_unregister_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 59 //static void remote_usbhc(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 57 60 58 61 /** Remote USB host controller interface operations. */ … … 72 75 73 76 remote_usbhc_control_write, 74 remote_usbhc_control_read 77 remote_usbhc_control_read, 78 79 remote_usbhc_register_endpoint, 80 remote_usbhc_unregister_endpoint 75 81 }; 76 82 … … 123 129 } 124 130 125 void remote_usbhc_reserve_default_address(d evice_t *device, void *iface,131 void remote_usbhc_reserve_default_address(ddf_fun_t *fun, void *iface, 126 132 ipc_callid_t callid, ipc_call_t *call) 127 133 { … … 135 141 usb_speed_t speed = DEV_IPC_GET_ARG1(*call); 136 142 137 int rc = usb_iface->reserve_default_address( device, speed);143 int rc = usb_iface->reserve_default_address(fun, speed); 138 144 139 145 async_answer_0(callid, rc); 140 146 } 141 147 142 void remote_usbhc_release_default_address(d evice_t *device, void *iface,148 void remote_usbhc_release_default_address(ddf_fun_t *fun, void *iface, 143 149 ipc_callid_t callid, ipc_call_t *call) 144 150 { … … 150 156 } 151 157 152 int rc = usb_iface->release_default_address( device);158 int rc = usb_iface->release_default_address(fun); 153 159 154 160 async_answer_0(callid, rc); 155 161 } 156 162 157 void remote_usbhc_request_address(d evice_t *device, void *iface,163 void remote_usbhc_request_address(ddf_fun_t *fun, void *iface, 158 164 ipc_callid_t callid, ipc_call_t *call) 159 165 { … … 168 174 169 175 usb_address_t address; 170 int rc = usb_iface->request_address( device, speed, &address);176 int rc = usb_iface->request_address(fun, speed, &address); 171 177 if (rc != EOK) { 172 178 async_answer_0(callid, rc); … … 176 182 } 177 183 178 void remote_usbhc_bind_address(d evice_t *device, void *iface,184 void remote_usbhc_bind_address(ddf_fun_t *fun, void *iface, 179 185 ipc_callid_t callid, ipc_call_t *call) 180 186 { … … 189 195 devman_handle_t handle = (devman_handle_t) DEV_IPC_GET_ARG2(*call); 190 196 191 int rc = usb_iface->bind_address( device, address, handle);197 int rc = usb_iface->bind_address(fun, address, handle); 192 198 193 199 async_answer_0(callid, rc); 194 200 } 195 201 196 void remote_usbhc_release_address(d evice_t *device, void *iface,202 void remote_usbhc_release_address(ddf_fun_t *fun, void *iface, 197 203 ipc_callid_t callid, ipc_call_t *call) 198 204 { … … 206 212 usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call); 207 213 208 int rc = usb_iface->release_address( device, address);214 int rc = usb_iface->release_address(fun, address); 209 215 210 216 async_answer_0(callid, rc); … … 212 218 213 219 214 static void callback_out(d evice_t *device,220 static void callback_out(ddf_fun_t *fun, 215 221 int outcome, void *arg) 216 222 { … … 222 228 } 223 229 224 static void callback_in(d evice_t *device,230 static void callback_in(ddf_fun_t *fun, 225 231 int outcome, size_t actual_size, void *arg) 226 232 { … … 255 261 * @param transfer_func Transfer function (might be NULL). 256 262 */ 257 static void remote_usbhc_out_transfer(d evice_t *device,263 static void remote_usbhc_out_transfer(ddf_fun_t *fun, 258 264 ipc_callid_t callid, ipc_call_t *call, 259 265 usbhc_iface_transfer_out_t transfer_func) … … 294 300 trans->size = len; 295 301 296 rc = transfer_func( device, target, max_packet_size,302 rc = transfer_func(fun, target, max_packet_size, 297 303 buffer, len, 298 304 callback_out, trans); … … 311 317 * @param transfer_func Transfer function (might be NULL). 312 318 */ 313 static void remote_usbhc_in_transfer(d evice_t *device,319 static void remote_usbhc_in_transfer(ddf_fun_t *fun, 314 320 ipc_callid_t callid, ipc_call_t *call, 315 321 usbhc_iface_transfer_in_t transfer_func) … … 342 348 trans->size = len; 343 349 344 int rc = transfer_func( device, target, max_packet_size,350 int rc = transfer_func(fun, target, max_packet_size, 345 351 trans->buffer, len, 346 352 callback_in, trans); … … 352 358 } 353 359 354 void remote_usbhc_interrupt_out(d evice_t *device, void *iface,360 void remote_usbhc_interrupt_out(ddf_fun_t *fun, void *iface, 355 361 ipc_callid_t callid, ipc_call_t *call) 356 362 { … … 358 364 assert(usb_iface != NULL); 359 365 360 return remote_usbhc_out_transfer( device, callid, call,366 return remote_usbhc_out_transfer(fun, callid, call, 361 367 usb_iface->interrupt_out); 362 368 } 363 369 364 void remote_usbhc_interrupt_in(d evice_t *device, void *iface,370 void remote_usbhc_interrupt_in(ddf_fun_t *fun, void *iface, 365 371 ipc_callid_t callid, ipc_call_t *call) 366 372 { … … 368 374 assert(usb_iface != NULL); 369 375 370 return remote_usbhc_in_transfer( device, callid, call,376 return remote_usbhc_in_transfer(fun, callid, call, 371 377 usb_iface->interrupt_in); 372 378 } 373 379 374 void remote_usbhc_bulk_out(d evice_t *device, void *iface,380 void remote_usbhc_bulk_out(ddf_fun_t *fun, void *iface, 375 381 ipc_callid_t callid, ipc_call_t *call) 376 382 { … … 378 384 assert(usb_iface != NULL); 379 385 380 return remote_usbhc_out_transfer( device, callid, call,386 return remote_usbhc_out_transfer(fun, callid, call, 381 387 usb_iface->bulk_out); 382 388 } 383 389 384 void remote_usbhc_bulk_in(d evice_t *device, void *iface,390 void remote_usbhc_bulk_in(ddf_fun_t *fun, void *iface, 385 391 ipc_callid_t callid, ipc_call_t *call) 386 392 { … … 388 394 assert(usb_iface != NULL); 389 395 390 return remote_usbhc_in_transfer( device, callid, call,396 return remote_usbhc_in_transfer(fun, callid, call, 391 397 usb_iface->bulk_in); 392 398 } 393 399 394 void remote_usbhc_control_write(d evice_t *device, void *iface,400 void remote_usbhc_control_write(ddf_fun_t *fun, void *iface, 395 401 ipc_callid_t callid, ipc_call_t *call) 396 402 { … … 444 450 trans->size = data_buffer_len; 445 451 446 rc = usb_iface->control_write( device, target, max_packet_size,452 rc = usb_iface->control_write(fun, target, max_packet_size, 447 453 setup_packet, setup_packet_len, 448 454 data_buffer, data_buffer_len, … … 456 462 457 463 458 void remote_usbhc_control_read(d evice_t *device, void *iface,464 void remote_usbhc_control_read(ddf_fun_t *fun, void *iface, 459 465 ipc_callid_t callid, ipc_call_t *call) 460 466 { … … 509 515 } 510 516 511 rc = usb_iface->control_read( device, target, max_packet_size,517 rc = usb_iface->control_read(fun, target, max_packet_size, 512 518 setup_packet, setup_packet_len, 513 519 trans->buffer, trans->size, … … 521 527 522 528 529 void remote_usbhc_register_endpoint(ddf_fun_t *fun, void *iface, 530 ipc_callid_t callid, ipc_call_t *call) 531 { 532 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface; 533 534 if (!usb_iface->register_endpoint) { 535 async_answer_0(callid, ENOTSUP); 536 return; 537 } 538 539 #define INIT_FROM_HIGH_DATA(type, var, arg_no) \ 540 type var = (type) DEV_IPC_GET_ARG##arg_no(*call) / 256 541 #define INIT_FROM_LOW_DATA(type, var, arg_no) \ 542 type var = (type) DEV_IPC_GET_ARG##arg_no(*call) % 256 543 544 INIT_FROM_HIGH_DATA(usb_address_t, address, 1); 545 INIT_FROM_LOW_DATA(usb_endpoint_t, endpoint, 1); 546 INIT_FROM_HIGH_DATA(usb_transfer_type_t, transfer_type, 2); 547 INIT_FROM_LOW_DATA(usb_direction_t, direction, 2); 548 549 #undef INIT_FROM_HIGH_DATA 550 #undef INIT_FROM_LOW_DATA 551 552 size_t max_packet_size = (size_t) DEV_IPC_GET_ARG3(*call); 553 unsigned int interval = (unsigned int) DEV_IPC_GET_ARG4(*call); 554 555 int rc = usb_iface->register_endpoint(fun, address, endpoint, 556 transfer_type, direction, max_packet_size, interval); 557 558 async_answer_0(callid, rc); 559 } 560 561 562 void remote_usbhc_unregister_endpoint(ddf_fun_t *fun, void *iface, 563 ipc_callid_t callid, ipc_call_t *call) 564 { 565 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface; 566 567 if (!usb_iface->unregister_endpoint) { 568 async_answer_0(callid, ENOTSUP); 569 return; 570 } 571 572 usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call); 573 usb_endpoint_t endpoint = (usb_endpoint_t) DEV_IPC_GET_ARG2(*call); 574 usb_direction_t direction = (usb_direction_t) DEV_IPC_GET_ARG3(*call); 575 576 int rc = usb_iface->unregister_endpoint(fun, 577 address, endpoint, direction); 578 579 async_answer_0(callid, rc); 580 } 581 523 582 524 583 /**
Note:
See TracChangeset
for help on using the changeset viewer.