Changes in uspace/lib/drv/generic/remote_usbhc.c [5842493:93f8da1] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhc.c
r5842493 r93f8da1 33 33 */ 34 34 35 #include <ipc/ipc.h> 35 36 #include <async.h> 36 37 #include <errno.h> … … 42 43 43 44 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 *); 44 46 static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *); 45 47 static void remote_usbhc_interrupt_in(device_t *, void *, ipc_callid_t, ipc_call_t *); … … 63 65 remote_usbhc_get_address, 64 66 67 remote_usbhc_get_buffer, 68 65 69 remote_usbhc_reserve_default_address, 66 70 remote_usbhc_release_default_address, … … 95 99 typedef struct { 96 100 ipc_callid_t caller; 97 ipc_callid_t data_caller;98 101 void *buffer; 99 102 void *setup_packet; … … 125 128 126 129 trans->caller = caller; 127 trans->data_caller = 0;128 130 trans->buffer = NULL; 129 131 trans->setup_packet = NULL; … … 139 141 140 142 if (!usb_iface->tell_address) { 141 async_answer_0(callid, ENOTSUP);143 ipc_answer_0(callid, ENOTSUP); 142 144 return; 143 145 } … … 148 150 int rc = usb_iface->tell_address(device, handle, &address); 149 151 if (rc != EOK) { 150 async_answer_0(callid, rc);152 ipc_answer_0(callid, rc); 151 153 } else { 152 async_answer_1(callid, EOK, address); 153 } 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); 154 189 } 155 190 … … 160 195 161 196 if (!usb_iface->reserve_default_address) { 162 async_answer_0(callid, ENOTSUP);197 ipc_answer_0(callid, ENOTSUP); 163 198 return; 164 199 } … … 166 201 int rc = usb_iface->reserve_default_address(device); 167 202 168 async_answer_0(callid, rc);203 ipc_answer_0(callid, rc); 169 204 } 170 205 … … 175 210 176 211 if (!usb_iface->release_default_address) { 177 async_answer_0(callid, ENOTSUP);212 ipc_answer_0(callid, ENOTSUP); 178 213 return; 179 214 } … … 181 216 int rc = usb_iface->release_default_address(device); 182 217 183 async_answer_0(callid, rc);218 ipc_answer_0(callid, rc); 184 219 } 185 220 … … 190 225 191 226 if (!usb_iface->request_address) { 192 async_answer_0(callid, ENOTSUP);227 ipc_answer_0(callid, ENOTSUP); 193 228 return; 194 229 } … … 197 232 int rc = usb_iface->request_address(device, &address); 198 233 if (rc != EOK) { 199 async_answer_0(callid, rc);234 ipc_answer_0(callid, rc); 200 235 } else { 201 async_answer_1(callid, EOK, (sysarg_t) address);236 ipc_answer_1(callid, EOK, (sysarg_t) address); 202 237 } 203 238 } … … 209 244 210 245 if (!usb_iface->bind_address) { 211 async_answer_0(callid, ENOTSUP);246 ipc_answer_0(callid, ENOTSUP); 212 247 return; 213 248 } … … 218 253 int rc = usb_iface->bind_address(device, address, handle); 219 254 220 async_answer_0(callid, rc);255 ipc_answer_0(callid, rc); 221 256 } 222 257 … … 227 262 228 263 if (!usb_iface->release_address) { 229 async_answer_0(callid, ENOTSUP);264 ipc_answer_0(callid, ENOTSUP); 230 265 return; 231 266 } … … 235 270 int rc = usb_iface->release_address(device, address); 236 271 237 async_answer_0(callid, rc);272 ipc_answer_0(callid, rc); 238 273 } 239 274 … … 244 279 async_transaction_t *trans = (async_transaction_t *)arg; 245 280 246 async_answer_0(trans->caller, outcome);281 ipc_answer_0(trans->caller, outcome); 247 282 248 283 async_transaction_destroy(trans); … … 255 290 256 291 if (outcome != USB_OUTCOME_OK) { 257 async_answer_0(trans->caller, outcome); 258 if (trans->data_caller) { 259 async_answer_0(trans->data_caller, EINTR); 260 } 292 ipc_answer_0(trans->caller, outcome); 261 293 async_transaction_destroy(trans); 262 294 return; … … 264 296 265 297 trans->size = actual_size; 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); 298 ipc_answer_1(trans->caller, USB_OUTCOME_OK, (sysarg_t)trans); 275 299 } 276 300 … … 287 311 { 288 312 if (!transfer_func) { 289 async_answer_0(callid, ENOTSUP);313 ipc_answer_0(callid, ENOTSUP); 290 314 return; 291 315 } … … 305 329 306 330 if (rc != EOK) { 307 async_answer_0(callid, rc);331 ipc_answer_0(callid, rc); 308 332 return; 309 333 } … … 315 339 free(buffer); 316 340 } 317 async_answer_0(callid, ENOMEM);341 ipc_answer_0(callid, ENOMEM); 318 342 return; 319 343 } … … 326 350 327 351 if (rc != EOK) { 328 async_answer_0(callid, rc);352 ipc_answer_0(callid, rc); 329 353 async_transaction_destroy(trans); 330 354 } … … 343 367 { 344 368 if (!transfer_func) { 345 async_answer_0(callid, ENOTSUP);369 ipc_answer_0(callid, ENOTSUP); 346 370 return; 347 371 } … … 353 377 }; 354 378 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 361 379 async_transaction_t *trans = async_transaction_create(callid); 362 380 if (trans == NULL) { 363 async_answer_0(callid, ENOMEM); 364 return; 365 } 366 trans->data_caller = data_callid; 381 ipc_answer_0(callid, ENOMEM); 382 return; 383 } 367 384 trans->buffer = malloc(len); 368 385 trans->size = len; … … 372 389 373 390 if (rc != EOK) { 374 async_answer_0(callid, rc);391 ipc_answer_0(callid, rc); 375 392 async_transaction_destroy(trans); 376 393 } … … 397 414 case USB_DIRECTION_IN: 398 415 if (!transfer_in_func) { 399 async_answer_0(callid, ENOTSUP);416 ipc_answer_0(callid, ENOTSUP); 400 417 return; 401 418 } … … 403 420 case USB_DIRECTION_OUT: 404 421 if (!transfer_out_func) { 405 async_answer_0(callid, ENOTSUP);422 ipc_answer_0(callid, ENOTSUP); 406 423 return; 407 424 } … … 419 436 async_transaction_t *trans = async_transaction_create(callid); 420 437 if (trans == NULL) { 421 async_answer_0(callid, ENOMEM);438 ipc_answer_0(callid, ENOMEM); 422 439 return; 423 440 } … … 439 456 440 457 if (rc != EOK) { 441 async_answer_0(callid, rc);458 ipc_answer_0(callid, rc); 442 459 async_transaction_destroy(trans); 443 460 } … … 532 549 533 550 if (!usb_iface->control_write) { 534 async_answer_0(callid, ENOTSUP);551 ipc_answer_0(callid, ENOTSUP); 535 552 return; 536 553 } … … 551 568 1, USB_MAX_PAYLOAD_SIZE, 0, &setup_packet_len); 552 569 if (rc != EOK) { 553 async_answer_0(callid, rc);570 ipc_answer_0(callid, rc); 554 571 return; 555 572 } … … 557 574 1, USB_MAX_PAYLOAD_SIZE, 0, &data_buffer_len); 558 575 if (rc != EOK) { 559 async_answer_0(callid, rc);576 ipc_answer_0(callid, rc); 560 577 free(setup_packet); 561 578 return; … … 564 581 async_transaction_t *trans = async_transaction_create(callid); 565 582 if (trans == NULL) { 566 async_answer_0(callid, ENOMEM);583 ipc_answer_0(callid, ENOMEM); 567 584 free(setup_packet); 568 585 free(data_buffer); … … 579 596 580 597 if (rc != EOK) { 581 async_answer_0(callid, rc);598 ipc_answer_0(callid, rc); 582 599 async_transaction_destroy(trans); 583 600 } … … 592 609 593 610 if (!usb_iface->control_read) { 594 async_answer_0(callid, ENOTSUP);611 ipc_answer_0(callid, ENOTSUP); 595 612 return; 596 613 } … … 610 627 1, USB_MAX_PAYLOAD_SIZE, 0, &setup_packet_len); 611 628 if (rc != EOK) { 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);629 ipc_answer_0(callid, rc); 630 return; 631 } 632 633 async_transaction_t *trans = async_transaction_create(callid); 634 if (trans == NULL) { 635 ipc_answer_0(callid, ENOMEM); 619 636 free(setup_packet); 620 637 return; 621 638 } 622 623 async_transaction_t *trans = async_transaction_create(callid);624 if (trans == NULL) {625 async_answer_0(callid, ENOMEM);626 free(setup_packet);627 return;628 }629 trans->data_caller = data_callid;630 639 trans->setup_packet = setup_packet; 631 640 trans->size = data_len; 632 641 trans->buffer = malloc(data_len); 633 642 if (trans->buffer == NULL) { 634 async_answer_0(callid, ENOMEM);643 ipc_answer_0(callid, ENOMEM); 635 644 async_transaction_destroy(trans); 636 645 return; … … 643 652 644 653 if (rc != EOK) { 645 async_answer_0(callid, rc);654 ipc_answer_0(callid, rc); 646 655 async_transaction_destroy(trans); 647 656 }
Note:
See TracChangeset
for help on using the changeset viewer.