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