Changes in uspace/lib/drv/generic/remote_usbhc.c [93f8da1:5842493] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhc.c
r93f8da1 r5842493 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); 258 if (trans->data_caller) { 259 async_answer_0(trans->data_caller, EINTR); 260 } 293 261 async_transaction_destroy(trans); 294 262 return; … … 296 264 297 265 trans->size = actual_size; 298 ipc_answer_1(trans->caller, USB_OUTCOME_OK, (sysarg_t)trans); 266 267 if (trans->data_caller) { 268 async_data_read_finalize(trans->data_caller, 269 trans->buffer, actual_size); 270 } 271 272 async_answer_0(trans->caller, USB_OUTCOME_OK); 273 274 async_transaction_destroy(trans); 299 275 } 300 276 … … 311 287 { 312 288 if (!transfer_func) { 313 ipc_answer_0(callid, ENOTSUP);289 async_answer_0(callid, ENOTSUP); 314 290 return; 315 291 } … … 329 305 330 306 if (rc != EOK) { 331 ipc_answer_0(callid, rc);307 async_answer_0(callid, rc); 332 308 return; 333 309 } … … 339 315 free(buffer); 340 316 } 341 ipc_answer_0(callid, ENOMEM);317 async_answer_0(callid, ENOMEM); 342 318 return; 343 319 } … … 350 326 351 327 if (rc != EOK) { 352 ipc_answer_0(callid, rc);328 async_answer_0(callid, rc); 353 329 async_transaction_destroy(trans); 354 330 } … … 367 343 { 368 344 if (!transfer_func) { 369 ipc_answer_0(callid, ENOTSUP);345 async_answer_0(callid, ENOTSUP); 370 346 return; 371 347 } … … 377 353 }; 378 354 355 ipc_callid_t data_callid; 356 if (!async_data_read_receive(&data_callid, &len)) { 357 async_answer_0(callid, EPARTY); 358 return; 359 } 360 379 361 async_transaction_t *trans = async_transaction_create(callid); 380 362 if (trans == NULL) { 381 ipc_answer_0(callid, ENOMEM); 382 return; 383 } 363 async_answer_0(callid, ENOMEM); 364 return; 365 } 366 trans->data_caller = data_callid; 384 367 trans->buffer = malloc(len); 385 368 trans->size = len; … … 389 372 390 373 if (rc != EOK) { 391 ipc_answer_0(callid, rc);374 async_answer_0(callid, rc); 392 375 async_transaction_destroy(trans); 393 376 } … … 414 397 case USB_DIRECTION_IN: 415 398 if (!transfer_in_func) { 416 ipc_answer_0(callid, ENOTSUP);399 async_answer_0(callid, ENOTSUP); 417 400 return; 418 401 } … … 420 403 case USB_DIRECTION_OUT: 421 404 if (!transfer_out_func) { 422 ipc_answer_0(callid, ENOTSUP);405 async_answer_0(callid, ENOTSUP); 423 406 return; 424 407 } … … 436 419 async_transaction_t *trans = async_transaction_create(callid); 437 420 if (trans == NULL) { 438 ipc_answer_0(callid, ENOMEM);421 async_answer_0(callid, ENOMEM); 439 422 return; 440 423 } … … 456 439 457 440 if (rc != EOK) { 458 ipc_answer_0(callid, rc);441 async_answer_0(callid, rc); 459 442 async_transaction_destroy(trans); 460 443 } … … 549 532 550 533 if (!usb_iface->control_write) { 551 ipc_answer_0(callid, ENOTSUP);534 async_answer_0(callid, ENOTSUP); 552 535 return; 553 536 } … … 568 551 1, USB_MAX_PAYLOAD_SIZE, 0, &setup_packet_len); 569 552 if (rc != EOK) { 570 ipc_answer_0(callid, rc);553 async_answer_0(callid, rc); 571 554 return; 572 555 } … … 574 557 1, USB_MAX_PAYLOAD_SIZE, 0, &data_buffer_len); 575 558 if (rc != EOK) { 576 ipc_answer_0(callid, rc);559 async_answer_0(callid, rc); 577 560 free(setup_packet); 578 561 return; … … 581 564 async_transaction_t *trans = async_transaction_create(callid); 582 565 if (trans == NULL) { 583 ipc_answer_0(callid, ENOMEM);566 async_answer_0(callid, ENOMEM); 584 567 free(setup_packet); 585 568 free(data_buffer); … … 596 579 597 580 if (rc != EOK) { 598 ipc_answer_0(callid, rc);581 async_answer_0(callid, rc); 599 582 async_transaction_destroy(trans); 600 583 } … … 609 592 610 593 if (!usb_iface->control_read) { 611 ipc_answer_0(callid, ENOTSUP);594 async_answer_0(callid, ENOTSUP); 612 595 return; 613 596 } … … 627 610 1, USB_MAX_PAYLOAD_SIZE, 0, &setup_packet_len); 628 611 if (rc != EOK) { 629 ipc_answer_0(callid, rc); 612 async_answer_0(callid, rc); 613 return; 614 } 615 616 ipc_callid_t data_callid; 617 if (!async_data_read_receive(&data_callid, &data_len)) { 618 async_answer_0(callid, EPARTY); 619 free(setup_packet); 630 620 return; 631 621 } … … 633 623 async_transaction_t *trans = async_transaction_create(callid); 634 624 if (trans == NULL) { 635 ipc_answer_0(callid, ENOMEM);625 async_answer_0(callid, ENOMEM); 636 626 free(setup_packet); 637 627 return; 638 628 } 629 trans->data_caller = data_callid; 639 630 trans->setup_packet = setup_packet; 640 631 trans->size = data_len; 641 632 trans->buffer = malloc(data_len); 642 633 if (trans->buffer == NULL) { 643 ipc_answer_0(callid, ENOMEM);634 async_answer_0(callid, ENOMEM); 644 635 async_transaction_destroy(trans); 645 636 return; … … 652 643 653 644 if (rc != EOK) { 654 ipc_answer_0(callid, rc);645 async_answer_0(callid, rc); 655 646 async_transaction_destroy(trans); 656 647 }
Note:
See TracChangeset
for help on using the changeset viewer.