Changes in uspace/lib/drv/generic/remote_usbhc.c [93f8da1:1e64b250] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhc.c
r93f8da1 r1e64b250 33 33 */ 34 34 35 #include <ipc/ipc.h>36 35 #include <async.h> 37 36 #include <errno.h> … … 43 42 44 43 static void remote_usbhc_get_address(device_t *, void *, ipc_callid_t, ipc_call_t *); 45 static void remote_usbhc_get_buffer(device_t *, void *, ipc_callid_t, ipc_call_t *);46 44 static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *); 47 45 static void remote_usbhc_interrupt_in(device_t *, void *, ipc_callid_t, ipc_call_t *); … … 65 63 remote_usbhc_get_address, 66 64 67 remote_usbhc_get_buffer,68 69 65 remote_usbhc_reserve_default_address, 70 66 remote_usbhc_release_default_address, … … 99 95 typedef struct { 100 96 ipc_callid_t caller; 97 ipc_callid_t data_caller; 101 98 void *buffer; 102 99 void *setup_packet; … … 128 125 129 126 trans->caller = caller; 127 trans->data_caller = 0; 130 128 trans->buffer = NULL; 131 129 trans->setup_packet = NULL; … … 141 139 142 140 if (!usb_iface->tell_address) { 143 ipc_answer_0(callid, ENOTSUP);141 async_answer_0(callid, ENOTSUP); 144 142 return; 145 143 } … … 150 148 int rc = usb_iface->tell_address(device, handle, &address); 151 149 if (rc != EOK) { 152 ipc_answer_0(callid, rc);150 async_answer_0(callid, rc); 153 151 } else { 154 ipc_answer_1(callid, EOK, address); 155 } 156 } 157 158 void remote_usbhc_get_buffer(device_t *device, void *iface, 159 ipc_callid_t callid, ipc_call_t *call) 160 { 161 sysarg_t buffer_hash = DEV_IPC_GET_ARG1(*call); 162 async_transaction_t * trans = (async_transaction_t *)buffer_hash; 163 if (trans == NULL) { 164 ipc_answer_0(callid, ENOENT); 165 return; 166 } 167 if (trans->buffer == NULL) { 168 ipc_answer_0(callid, EINVAL); 169 async_transaction_destroy(trans); 170 return; 171 } 172 173 ipc_callid_t cid; 174 size_t accepted_size; 175 if (!async_data_read_receive(&cid, &accepted_size)) { 176 ipc_answer_0(callid, EINVAL); 177 async_transaction_destroy(trans); 178 return; 179 } 180 181 if (accepted_size > trans->size) { 182 accepted_size = trans->size; 183 } 184 async_data_read_finalize(cid, trans->buffer, accepted_size); 185 186 ipc_answer_1(callid, EOK, accepted_size); 187 188 async_transaction_destroy(trans); 152 async_answer_1(callid, EOK, address); 153 } 189 154 } 190 155 … … 195 160 196 161 if (!usb_iface->reserve_default_address) { 197 ipc_answer_0(callid, ENOTSUP);162 async_answer_0(callid, ENOTSUP); 198 163 return; 199 164 } … … 201 166 int rc = usb_iface->reserve_default_address(device); 202 167 203 ipc_answer_0(callid, rc);168 async_answer_0(callid, rc); 204 169 } 205 170 … … 210 175 211 176 if (!usb_iface->release_default_address) { 212 ipc_answer_0(callid, ENOTSUP);177 async_answer_0(callid, ENOTSUP); 213 178 return; 214 179 } … … 216 181 int rc = usb_iface->release_default_address(device); 217 182 218 ipc_answer_0(callid, rc);183 async_answer_0(callid, rc); 219 184 } 220 185 … … 225 190 226 191 if (!usb_iface->request_address) { 227 ipc_answer_0(callid, ENOTSUP);192 async_answer_0(callid, ENOTSUP); 228 193 return; 229 194 } … … 232 197 int rc = usb_iface->request_address(device, &address); 233 198 if (rc != EOK) { 234 ipc_answer_0(callid, rc);199 async_answer_0(callid, rc); 235 200 } else { 236 ipc_answer_1(callid, EOK, (sysarg_t) address);201 async_answer_1(callid, EOK, (sysarg_t) address); 237 202 } 238 203 } … … 244 209 245 210 if (!usb_iface->bind_address) { 246 ipc_answer_0(callid, ENOTSUP);211 async_answer_0(callid, ENOTSUP); 247 212 return; 248 213 } … … 253 218 int rc = usb_iface->bind_address(device, address, handle); 254 219 255 ipc_answer_0(callid, rc);220 async_answer_0(callid, rc); 256 221 } 257 222 … … 262 227 263 228 if (!usb_iface->release_address) { 264 ipc_answer_0(callid, ENOTSUP);229 async_answer_0(callid, ENOTSUP); 265 230 return; 266 231 } … … 270 235 int rc = usb_iface->release_address(device, address); 271 236 272 ipc_answer_0(callid, rc);237 async_answer_0(callid, rc); 273 238 } 274 239 … … 279 244 async_transaction_t *trans = (async_transaction_t *)arg; 280 245 281 ipc_answer_0(trans->caller, outcome);246 async_answer_0(trans->caller, outcome); 282 247 283 248 async_transaction_destroy(trans); … … 290 255 291 256 if (outcome != USB_OUTCOME_OK) { 292 ipc_answer_0(trans->caller, outcome);257 async_answer_0(trans->caller, outcome); 293 258 async_transaction_destroy(trans); 294 259 return; … … 296 261 297 262 trans->size = actual_size; 298 ipc_answer_1(trans->caller, USB_OUTCOME_OK, (sysarg_t)trans); 263 264 if (trans->data_caller) { 265 async_data_read_finalize(trans->data_caller, 266 trans->buffer, actual_size); 267 } 268 269 async_answer_0(trans->caller, USB_OUTCOME_OK); 270 271 async_transaction_destroy(trans); 299 272 } 300 273 … … 311 284 { 312 285 if (!transfer_func) { 313 ipc_answer_0(callid, ENOTSUP);286 async_answer_0(callid, ENOTSUP); 314 287 return; 315 288 } … … 329 302 330 303 if (rc != EOK) { 331 ipc_answer_0(callid, rc);304 async_answer_0(callid, rc); 332 305 return; 333 306 } … … 339 312 free(buffer); 340 313 } 341 ipc_answer_0(callid, ENOMEM);314 async_answer_0(callid, ENOMEM); 342 315 return; 343 316 } … … 350 323 351 324 if (rc != EOK) { 352 ipc_answer_0(callid, rc);325 async_answer_0(callid, rc); 353 326 async_transaction_destroy(trans); 354 327 } … … 367 340 { 368 341 if (!transfer_func) { 369 ipc_answer_0(callid, ENOTSUP);342 async_answer_0(callid, ENOTSUP); 370 343 return; 371 344 } … … 377 350 }; 378 351 352 ipc_callid_t data_callid; 353 if (!async_data_read_receive(&data_callid, &len)) { 354 async_answer_0(callid, EPARTY); 355 return; 356 } 357 379 358 async_transaction_t *trans = async_transaction_create(callid); 380 359 if (trans == NULL) { 381 ipc_answer_0(callid, ENOMEM); 382 return; 383 } 360 async_answer_0(callid, ENOMEM); 361 return; 362 } 363 trans->data_caller = data_callid; 384 364 trans->buffer = malloc(len); 385 365 trans->size = len; … … 389 369 390 370 if (rc != EOK) { 391 ipc_answer_0(callid, rc);371 async_answer_0(callid, rc); 392 372 async_transaction_destroy(trans); 393 373 } … … 414 394 case USB_DIRECTION_IN: 415 395 if (!transfer_in_func) { 416 ipc_answer_0(callid, ENOTSUP);396 async_answer_0(callid, ENOTSUP); 417 397 return; 418 398 } … … 420 400 case USB_DIRECTION_OUT: 421 401 if (!transfer_out_func) { 422 ipc_answer_0(callid, ENOTSUP);402 async_answer_0(callid, ENOTSUP); 423 403 return; 424 404 } … … 436 416 async_transaction_t *trans = async_transaction_create(callid); 437 417 if (trans == NULL) { 438 ipc_answer_0(callid, ENOMEM);418 async_answer_0(callid, ENOMEM); 439 419 return; 440 420 } … … 456 436 457 437 if (rc != EOK) { 458 ipc_answer_0(callid, rc);438 async_answer_0(callid, rc); 459 439 async_transaction_destroy(trans); 460 440 } … … 549 529 550 530 if (!usb_iface->control_write) { 551 ipc_answer_0(callid, ENOTSUP);531 async_answer_0(callid, ENOTSUP); 552 532 return; 553 533 } … … 568 548 1, USB_MAX_PAYLOAD_SIZE, 0, &setup_packet_len); 569 549 if (rc != EOK) { 570 ipc_answer_0(callid, rc);550 async_answer_0(callid, rc); 571 551 return; 572 552 } … … 574 554 1, USB_MAX_PAYLOAD_SIZE, 0, &data_buffer_len); 575 555 if (rc != EOK) { 576 ipc_answer_0(callid, rc);556 async_answer_0(callid, rc); 577 557 free(setup_packet); 578 558 return; … … 581 561 async_transaction_t *trans = async_transaction_create(callid); 582 562 if (trans == NULL) { 583 ipc_answer_0(callid, ENOMEM);563 async_answer_0(callid, ENOMEM); 584 564 free(setup_packet); 585 565 free(data_buffer); … … 596 576 597 577 if (rc != EOK) { 598 ipc_answer_0(callid, rc);578 async_answer_0(callid, rc); 599 579 async_transaction_destroy(trans); 600 580 } … … 609 589 610 590 if (!usb_iface->control_read) { 611 ipc_answer_0(callid, ENOTSUP);591 async_answer_0(callid, ENOTSUP); 612 592 return; 613 593 } … … 627 607 1, USB_MAX_PAYLOAD_SIZE, 0, &setup_packet_len); 628 608 if (rc != EOK) { 629 ipc_answer_0(callid, rc); 609 async_answer_0(callid, rc); 610 return; 611 } 612 613 ipc_callid_t data_callid; 614 if (!async_data_read_receive(&data_callid, &data_len)) { 615 async_answer_0(callid, EPARTY); 616 free(setup_packet); 630 617 return; 631 618 } … … 633 620 async_transaction_t *trans = async_transaction_create(callid); 634 621 if (trans == NULL) { 635 ipc_answer_0(callid, ENOMEM);622 async_answer_0(callid, ENOMEM); 636 623 free(setup_packet); 637 624 return; 638 625 } 626 trans->data_caller = data_callid; 639 627 trans->setup_packet = setup_packet; 640 628 trans->size = data_len; 641 629 trans->buffer = malloc(data_len); 642 630 if (trans->buffer == NULL) { 643 ipc_answer_0(callid, ENOMEM);631 async_answer_0(callid, ENOMEM); 644 632 async_transaction_destroy(trans); 645 633 return; … … 652 640 653 641 if (rc != EOK) { 654 ipc_answer_0(callid, rc);642 async_answer_0(callid, rc); 655 643 async_transaction_destroy(trans); 656 644 }
Note:
See TracChangeset
for help on using the changeset viewer.