Changeset 50ba203 in mainline for uspace/lib/drv/generic/remote_usbhc.c
- Timestamp:
- 2011-02-20T15:46:48Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6bb83c7
- Parents:
- d81ef61c (diff), 0c00dac (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/lib/drv/generic/remote_usbhc.c
rd81ef61c r50ba203 40 40 41 41 #define USB_MAX_PAYLOAD_SIZE 1020 42 #define HACK_MAX_PACKET_SIZE 8 43 #define HACK_MAX_PACKET_SIZE_INTERRUPT_IN 4 42 44 43 45 static void remote_usbhc_get_address(device_t *, void *, ipc_callid_t, ipc_call_t *); 44 static void remote_usbhc_get_buffer(device_t *, void *, ipc_callid_t, ipc_call_t *);45 46 static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *); 46 47 static void remote_usbhc_interrupt_in(device_t *, void *, ipc_callid_t, ipc_call_t *); … … 64 65 remote_usbhc_get_address, 65 66 66 remote_usbhc_get_buffer,67 68 67 remote_usbhc_reserve_default_address, 69 68 remote_usbhc_release_default_address, … … 98 97 typedef struct { 99 98 ipc_callid_t caller; 99 ipc_callid_t data_caller; 100 100 void *buffer; 101 101 void *setup_packet; … … 127 127 128 128 trans->caller = caller; 129 trans->data_caller = 0; 129 130 trans->buffer = NULL; 130 131 trans->setup_packet = NULL; … … 155 156 } 156 157 157 void remote_usbhc_get_buffer(device_t *device, void *iface,158 ipc_callid_t callid, ipc_call_t *call)159 {160 sysarg_t buffer_hash = DEV_IPC_GET_ARG1(*call);161 async_transaction_t * trans = (async_transaction_t *)buffer_hash;162 if (trans == NULL) {163 async_answer_0(callid, ENOENT);164 return;165 }166 if (trans->buffer == NULL) {167 async_answer_0(callid, EINVAL);168 async_transaction_destroy(trans);169 return;170 }171 172 ipc_callid_t cid;173 size_t accepted_size;174 if (!async_data_read_receive(&cid, &accepted_size)) {175 async_answer_0(callid, EINVAL);176 async_transaction_destroy(trans);177 return;178 }179 180 if (accepted_size > trans->size) {181 accepted_size = trans->size;182 }183 async_data_read_finalize(cid, trans->buffer, accepted_size);184 185 async_answer_1(callid, EOK, accepted_size);186 187 async_transaction_destroy(trans);188 }189 190 158 void remote_usbhc_reserve_default_address(device_t *device, void *iface, 191 159 ipc_callid_t callid, ipc_call_t *call) … … 197 165 return; 198 166 } 199 200 int rc = usb_iface->reserve_default_address(device); 167 168 bool full_speed = DEV_IPC_GET_ARG1(*call); 169 170 int rc = usb_iface->reserve_default_address(device, full_speed); 201 171 202 172 async_answer_0(callid, rc); … … 227 197 return; 228 198 } 199 200 bool full_speed = DEV_IPC_GET_ARG1(*call); 229 201 230 202 usb_address_t address; 231 int rc = usb_iface->request_address(device, &address);203 int rc = usb_iface->request_address(device, full_speed, &address); 232 204 if (rc != EOK) { 233 205 async_answer_0(callid, rc); … … 274 246 275 247 static void callback_out(device_t *device, 276 usb_transaction_outcome_t outcome, void *arg)248 int outcome, void *arg) 277 249 { 278 250 async_transaction_t *trans = (async_transaction_t *)arg; … … 284 256 285 257 static void callback_in(device_t *device, 286 usb_transaction_outcome_t outcome, size_t actual_size, void *arg)258 int outcome, size_t actual_size, void *arg) 287 259 { 288 260 async_transaction_t *trans = (async_transaction_t *)arg; 289 261 290 if (outcome != USB_OUTCOME_OK) {262 if (outcome != EOK) { 291 263 async_answer_0(trans->caller, outcome); 264 if (trans->data_caller) { 265 async_answer_0(trans->data_caller, EINTR); 266 } 292 267 async_transaction_destroy(trans); 293 268 return; … … 295 270 296 271 trans->size = actual_size; 297 async_answer_1(trans->caller, USB_OUTCOME_OK, (sysarg_t)trans); 272 273 if (trans->data_caller) { 274 async_data_read_finalize(trans->data_caller, 275 trans->buffer, actual_size); 276 } 277 278 async_answer_0(trans->caller, EOK); 279 280 async_transaction_destroy(trans); 298 281 } 299 282 … … 345 328 trans->size = len; 346 329 347 int rc = transfer_func(device, target, buffer, len, 330 int rc = transfer_func(device, target, HACK_MAX_PACKET_SIZE, 331 buffer, len, 348 332 callback_out, trans); 349 333 … … 376 360 }; 377 361 362 ipc_callid_t data_callid; 363 if (!async_data_read_receive(&data_callid, &len)) { 364 async_answer_0(callid, EPARTY); 365 return; 366 } 367 378 368 async_transaction_t *trans = async_transaction_create(callid); 379 369 if (trans == NULL) { … … 381 371 return; 382 372 } 373 trans->data_caller = data_callid; 383 374 trans->buffer = malloc(len); 384 375 trans->size = len; 385 376 386 int rc = transfer_func(device, target, trans->buffer, len, 377 int rc = transfer_func(device, target, HACK_MAX_PACKET_SIZE_INTERRUPT_IN, 378 trans->buffer, len, 387 379 callback_in, trans); 388 380 … … 556 548 .endpoint = DEV_IPC_GET_ARG2(*call) 557 549 }; 550 size_t data_buffer_len = DEV_IPC_GET_ARG3(*call); 558 551 559 552 int rc; … … 562 555 void *data_buffer = NULL; 563 556 size_t setup_packet_len = 0; 564 size_t data_buffer_len = 0;565 557 566 558 rc = async_data_write_accept(&setup_packet, false, … … 570 562 return; 571 563 } 572 rc = async_data_write_accept(&data_buffer, false, 573 1, USB_MAX_PAYLOAD_SIZE, 0, &data_buffer_len); 574 if (rc != EOK) { 575 async_answer_0(callid, rc); 576 free(setup_packet); 577 return; 564 565 if (data_buffer_len > 0) { 566 rc = async_data_write_accept(&data_buffer, false, 567 1, USB_MAX_PAYLOAD_SIZE, 0, &data_buffer_len); 568 if (rc != EOK) { 569 async_answer_0(callid, rc); 570 free(setup_packet); 571 return; 572 } 578 573 } 579 574 … … 589 584 trans->size = data_buffer_len; 590 585 591 rc = usb_iface->control_write(device, target, 586 rc = usb_iface->control_write(device, target, HACK_MAX_PACKET_SIZE, 592 587 setup_packet, setup_packet_len, 593 588 data_buffer, data_buffer_len, … … 612 607 } 613 608 614 size_t data_len = DEV_IPC_GET_ARG3(*call);615 609 usb_target_t target = { 616 610 .address = DEV_IPC_GET_ARG1(*call), … … 622 616 void *setup_packet = NULL; 623 617 size_t setup_packet_len = 0; 618 size_t data_len = 0; 624 619 625 620 rc = async_data_write_accept(&setup_packet, false, … … 627 622 if (rc != EOK) { 628 623 async_answer_0(callid, rc); 624 return; 625 } 626 627 ipc_callid_t data_callid; 628 if (!async_data_read_receive(&data_callid, &data_len)) { 629 async_answer_0(callid, EPARTY); 630 free(setup_packet); 629 631 return; 630 632 } … … 636 638 return; 637 639 } 640 trans->data_caller = data_callid; 638 641 trans->setup_packet = setup_packet; 639 642 trans->size = data_len; … … 645 648 } 646 649 647 rc = usb_iface->control_read(device, target, 650 rc = usb_iface->control_read(device, target, HACK_MAX_PACKET_SIZE, 648 651 setup_packet, setup_packet_len, 649 652 trans->buffer, trans->size,
Note:
See TracChangeset
for help on using the changeset viewer.