Changes in uspace/lib/drv/generic/remote_usbhc.c [1e64b250:93f8da1] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhc.c
r1e64b250 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);292 ipc_answer_0(trans->caller, outcome); 258 293 async_transaction_destroy(trans); 259 294 return; … … 261 296 262 297 trans->size = actual_size; 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); 298 ipc_answer_1(trans->caller, USB_OUTCOME_OK, (sysarg_t)trans); 272 299 } 273 300 … … 284 311 { 285 312 if (!transfer_func) { 286 async_answer_0(callid, ENOTSUP);313 ipc_answer_0(callid, ENOTSUP); 287 314 return; 288 315 } … … 302 329 303 330 if (rc != EOK) { 304 async_answer_0(callid, rc);331 ipc_answer_0(callid, rc); 305 332 return; 306 333 } … … 312 339 free(buffer); 313 340 } 314 async_answer_0(callid, ENOMEM);341 ipc_answer_0(callid, ENOMEM); 315 342 return; 316 343 } … … 323 350 324 351 if (rc != EOK) { 325 async_answer_0(callid, rc);352 ipc_answer_0(callid, rc); 326 353 async_transaction_destroy(trans); 327 354 } … … 340 367 { 341 368 if (!transfer_func) { 342 async_answer_0(callid, ENOTSUP);369 ipc_answer_0(callid, ENOTSUP); 343 370 return; 344 371 } … … 350 377 }; 351 378 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 358 379 async_transaction_t *trans = async_transaction_create(callid); 359 380 if (trans == NULL) { 360 async_answer_0(callid, ENOMEM); 361 return; 362 } 363 trans->data_caller = data_callid; 381 ipc_answer_0(callid, ENOMEM); 382 return; 383 } 364 384 trans->buffer = malloc(len); 365 385 trans->size = len; … … 369 389 370 390 if (rc != EOK) { 371 async_answer_0(callid, rc);391 ipc_answer_0(callid, rc); 372 392 async_transaction_destroy(trans); 373 393 } … … 394 414 case USB_DIRECTION_IN: 395 415 if (!transfer_in_func) { 396 async_answer_0(callid, ENOTSUP);416 ipc_answer_0(callid, ENOTSUP); 397 417 return; 398 418 } … … 400 420 case USB_DIRECTION_OUT: 401 421 if (!transfer_out_func) { 402 async_answer_0(callid, ENOTSUP);422 ipc_answer_0(callid, ENOTSUP); 403 423 return; 404 424 } … … 416 436 async_transaction_t *trans = async_transaction_create(callid); 417 437 if (trans == NULL) { 418 async_answer_0(callid, ENOMEM);438 ipc_answer_0(callid, ENOMEM); 419 439 return; 420 440 } … … 436 456 437 457 if (rc != EOK) { 438 async_answer_0(callid, rc);458 ipc_answer_0(callid, rc); 439 459 async_transaction_destroy(trans); 440 460 } … … 529 549 530 550 if (!usb_iface->control_write) { 531 async_answer_0(callid, ENOTSUP);551 ipc_answer_0(callid, ENOTSUP); 532 552 return; 533 553 } … … 548 568 1, USB_MAX_PAYLOAD_SIZE, 0, &setup_packet_len); 549 569 if (rc != EOK) { 550 async_answer_0(callid, rc);570 ipc_answer_0(callid, rc); 551 571 return; 552 572 } … … 554 574 1, USB_MAX_PAYLOAD_SIZE, 0, &data_buffer_len); 555 575 if (rc != EOK) { 556 async_answer_0(callid, rc);576 ipc_answer_0(callid, rc); 557 577 free(setup_packet); 558 578 return; … … 561 581 async_transaction_t *trans = async_transaction_create(callid); 562 582 if (trans == NULL) { 563 async_answer_0(callid, ENOMEM);583 ipc_answer_0(callid, ENOMEM); 564 584 free(setup_packet); 565 585 free(data_buffer); … … 576 596 577 597 if (rc != EOK) { 578 async_answer_0(callid, rc);598 ipc_answer_0(callid, rc); 579 599 async_transaction_destroy(trans); 580 600 } … … 589 609 590 610 if (!usb_iface->control_read) { 591 async_answer_0(callid, ENOTSUP);611 ipc_answer_0(callid, ENOTSUP); 592 612 return; 593 613 } … … 607 627 1, USB_MAX_PAYLOAD_SIZE, 0, &setup_packet_len); 608 628 if (rc != EOK) { 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);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); 616 636 free(setup_packet); 617 637 return; 618 638 } 619 620 async_transaction_t *trans = async_transaction_create(callid);621 if (trans == NULL) {622 async_answer_0(callid, ENOMEM);623 free(setup_packet);624 return;625 }626 trans->data_caller = data_callid;627 639 trans->setup_packet = setup_packet; 628 640 trans->size = data_len; 629 641 trans->buffer = malloc(data_len); 630 642 if (trans->buffer == NULL) { 631 async_answer_0(callid, ENOMEM);643 ipc_answer_0(callid, ENOMEM); 632 644 async_transaction_destroy(trans); 633 645 return; … … 640 652 641 653 if (rc != EOK) { 642 async_answer_0(callid, rc);654 ipc_answer_0(callid, rc); 643 655 async_transaction_destroy(trans); 644 656 }
Note:
See TracChangeset
for help on using the changeset viewer.