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