Changes in uspace/srv/devman/main.c [431d6d6:9934f7d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/main.c
r431d6d6 r9934f7d 39 39 #include <assert.h> 40 40 #include <ipc/services.h> 41 #include < ipc/ns.h>41 #include <ns.h> 42 42 #include <async.h> 43 43 #include <stdio.h> … … 108 108 fibril_mutex_lock(&driver->driver_mutex); 109 109 110 if (driver-> phone >= 0) {110 if (driver->sess) { 111 111 /* We already have a connection to the driver. */ 112 112 log_msg(LVL_ERROR, "Driver '%s' already started.\n", … … 128 128 break; 129 129 case DRIVER_RUNNING: 130 /* Should not happen since we do not have a connected phone*/130 /* Should not happen since we do not have a connected session */ 131 131 assert(false); 132 132 } … … 135 135 log_msg(LVL_DEBUG, "Creating connection to the `%s' driver.", 136 136 driver->name); 137 ipc_call_t call; 138 ipc_callid_t callid = async_get_call(&call); 139 if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) { 137 driver->sess = async_callback_receive(EXCHANGE_SERIALIZE); 138 if (!driver->sess) { 140 139 fibril_mutex_unlock(&driver->driver_mutex); 141 async_answer_0(callid, ENOTSUP);142 140 async_answer_0(iid, ENOTSUP); 143 141 return NULL; 144 142 } 145 143 146 /* Remember driver's phone. */147 driver->phone = IPC_GET_ARG5(call);148 149 144 fibril_mutex_unlock(&driver->driver_mutex); 150 145 151 log_msg(LVL_NOTE, 146 log_msg(LVL_NOTE, 152 147 "The `%s' driver was successfully registered as running.", 153 148 driver->name); 154 149 155 async_answer_0(callid, EOK);156 150 async_answer_0(iid, EOK); 157 151 … … 434 428 fibril_add_ready(fid); 435 429 436 ipc_callid_t callid; 437 ipc_call_t call; 438 bool cont = true; 439 while (cont) { 440 callid = async_get_call(&call); 430 while (true) { 431 ipc_call_t call; 432 ipc_callid_t callid = async_get_call(&call); 433 434 if (!IPC_GET_IMETHOD(call)) 435 break; 441 436 442 437 switch (IPC_GET_IMETHOD(call)) { 443 case IPC_M_PHONE_HUNGUP:444 cont = false;445 continue;446 438 case DEVMAN_ADD_FUNCTION: 447 439 devman_add_function(callid, &call); … … 559 551 async_answer_0(iid, EOK); 560 552 561 bool cont = true; 562 while (cont) { 553 while (true) { 563 554 ipc_call_t call; 564 555 ipc_callid_t callid = async_get_call(&call); 565 556 557 if (!IPC_GET_IMETHOD(call)) 558 break; 559 566 560 switch (IPC_GET_IMETHOD(call)) { 567 case IPC_M_PHONE_HUNGUP:568 cont = false;569 continue;570 561 case DEVMAN_DEVICE_GET_HANDLE: 571 562 devman_function_get_handle(callid, &call); … … 635 626 if (driver == NULL) { 636 627 log_msg(LVL_ERROR, "IPC forwarding refused - " \ 637 "the device %" PRIun "(%s) is not in usable state.", 638 handle, dev->pfun->pathname); 628 "the device %" PRIun " is not in usable state.", handle); 639 629 async_answer_0(iid, ENOENT); 640 630 return; … … 647 637 method = DRIVER_CLIENT; 648 638 649 if (driver->phone < 0) { 650 log_msg(LVL_ERROR, 651 "Could not forward to driver `%s' (phone is %d).", 652 driver->name, (int) driver->phone); 639 if (!driver->sess) { 640 log_msg(LVL_ERROR, 641 "Could not forward to driver `%s'.", driver->name); 653 642 async_answer_0(iid, EINVAL); 654 643 return; … … 664 653 dev->pfun->pathname, driver->name); 665 654 } 666 667 async_forward_fast(iid, driver->phone, method, fwd_h, 0, IPC_FF_NONE); 655 656 async_exch_t *exch = async_exchange_begin(driver->sess); 657 async_forward_fast(iid, exch, method, fwd_h, 0, IPC_FF_NONE); 658 async_exchange_end(exch); 668 659 } 669 660 … … 687 678 dev = fun->dev; 688 679 689 if ( dev->state != DEVICE_USABLE || dev->drv->phone < 0) {680 if ((dev->state != DEVICE_USABLE) || (!dev->drv->sess)) { 690 681 async_answer_0(iid, EINVAL); 691 682 return; 692 683 } 693 684 694 async_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, fun->handle, 0, 685 async_exch_t *exch = async_exchange_begin(dev->drv->sess); 686 async_forward_fast(iid, exch, DRIVER_CLIENT, fun->handle, 0, 695 687 IPC_FF_NONE); 696 log_msg(LVL_DEBUG, 688 async_exchange_end(exch); 689 690 log_msg(LVL_DEBUG, 697 691 "Forwarding devmapper request for `%s' function to driver `%s'.", 698 692 fun->pathname, dev->drv->name); … … 700 694 701 695 /** Function for handling connections to device manager. */ 702 static void devman_connection(ipc_callid_t iid, ipc_call_t *icall )696 static void devman_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 703 697 { 704 698 /* Select interface. */ … … 786 780 787 781 printf(NAME ": Accepting connections.\n"); 782 task_retval(0); 788 783 async_manager(); 789 784
Note:
See TracChangeset
for help on using the changeset viewer.