Changes in uspace/srv/devman/main.c [0b5a4131:6e50466] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/main.c
r0b5a4131 r6e50466 36 36 */ 37 37 38 #include <inttypes.h> 38 39 #include <assert.h> 39 40 #include <ipc/services.h> … … 73 74 74 75 iid = async_get_call(&icall); 75 if (IPC_GET_ METHOD(icall) != DEVMAN_DRIVER_REGISTER) {76 if (IPC_GET_IMETHOD(icall) != DEVMAN_DRIVER_REGISTER) { 76 77 ipc_answer_0(iid, EREFUSED); 77 78 return NULL; … … 108 109 ipc_call_t call; 109 110 ipc_callid_t callid = async_get_call(&call); 110 if (IPC_GET_ METHOD(call) != IPC_M_CONNECT_TO_ME) {111 if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) { 111 112 ipc_answer_0(callid, ENOTSUP); 112 113 ipc_answer_0(iid, ENOTSUP); … … 140 141 141 142 callid = async_get_call(&call); 142 if (DEVMAN_ADD_MATCH_ID != IPC_GET_ METHOD(call)) {143 if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) { 143 144 printf(NAME ": ERROR: devman_receive_match_id - invalid " 144 145 "protocol.\n"); … … 183 184 * @return Zero on success, negative error code otherwise. 184 185 */ 185 static int devman_receive_match_ids( ipcarg_t match_count,186 static int devman_receive_match_ids(sysarg_t match_count, 186 187 match_id_list_t *match_ids) 187 188 { … … 196 197 } 197 198 199 static int assign_driver_fibril(void *arg) 200 { 201 node_t *node = (node_t *) arg; 202 assign_driver(node, &drivers_list, &device_tree); 203 return EOK; 204 } 205 198 206 /** Handle child device registration. 199 207 * … … 203 211 { 204 212 devman_handle_t parent_handle = IPC_GET_ARG1(*call); 205 ipcarg_t match_count = IPC_GET_ARG2(*call);213 sysarg_t match_count = IPC_GET_ARG2(*call); 206 214 dev_tree_t *tree = &device_tree; 207 215 … … 236 244 237 245 devman_receive_match_ids(match_count, &node->match_ids); 238 246 247 /* 248 * Try to find a suitable driver and assign it to the device. We do 249 * not want to block the current fibril that is used for processing 250 * incoming calls: we will launch a separate fibril to handle the 251 * driver assigning. That is because assign_driver can actually include 252 * task spawning which could take some time. 253 */ 254 fid_t assign_fibril = fibril_create(assign_driver_fibril, node); 255 if (assign_fibril == 0) { 256 /* 257 * Fallback in case we are out of memory. 258 * Probably not needed as we will die soon anyway ;-). 259 */ 260 (void) assign_driver_fibril(node); 261 } else { 262 fibril_add_ready(assign_fibril); 263 } 264 239 265 /* Return device handle to parent's driver. */ 240 266 ipc_answer_1(callid, EOK, node->handle); 241 242 /* Try to find suitable driver and assign it to the device. */243 assign_driver(node, &drivers_list, &device_tree);244 267 } 245 268 … … 258 281 * handle. 259 282 */ 260 devmap_device_register(devmap_pathname, &cli->devmap_handle); 283 devmap_device_register_with_iface(devmap_pathname, 284 &cli->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP); 261 285 262 286 /* … … 296 320 printf(NAME ": device '%s' added to class '%s', class name '%s' was " 297 321 "asigned to it\n", dev->pathname, class_name, class_info->dev_name); 298 322 299 323 ipc_answer_0(callid, EOK); 300 324 } … … 344 368 callid = async_get_call(&call); 345 369 346 switch (IPC_GET_ METHOD(call)) {370 switch (IPC_GET_IMETHOD(call)) { 347 371 case IPC_M_PHONE_HUNGUP: 348 372 cont = false; … … 397 421 ipc_callid_t callid = async_get_call(&call); 398 422 399 switch (IPC_GET_ METHOD(call)) {423 switch (IPC_GET_IMETHOD(call)) { 400 424 case IPC_M_PHONE_HUNGUP: 401 425 cont = false; … … 405 429 break; 406 430 default: 407 if (!(callid & IPC_CALLID_NOTIFICATION)) 408 ipc_answer_0(callid, ENOENT); 431 ipc_answer_0(callid, ENOENT); 409 432 } 410 433 } … … 418 441 node_t *dev = find_dev_node(&device_tree, handle); 419 442 if (dev == NULL) { 420 printf(NAME ": devman_forward error - no device with handle % x "421 " was found.\n", handle);443 printf(NAME ": devman_forward error - no device with handle %" PRIun 444 " was found.\n", handle); 422 445 ipc_answer_0(iid, ENOENT); 423 446 return; … … 435 458 436 459 if (driver == NULL) { 437 printf(NAME ": devman_forward error - the device is not in "438 " usable state.\n", handle);460 printf(NAME ": devman_forward error - the device is not in %" PRIun 461 " usable state.\n", handle); 439 462 ipc_answer_0(iid, ENOENT); 440 463 return; … … 450 473 printf(NAME ": devman_forward: cound not forward to driver %s ", 451 474 driver->name); 452 printf("the driver's phone is % x).\n", driver->phone);475 printf("the driver's phone is %" PRIun ").\n", driver->phone); 453 476 ipc_answer_0(iid, EINVAL); 454 477 return; … … 464 487 static void devman_connection_devmapper(ipc_callid_t iid, ipc_call_t *icall) 465 488 { 466 devmap_handle_t devmap_handle = IPC_GET_ METHOD(*icall);489 devmap_handle_t devmap_handle = IPC_GET_ARG2(*icall); 467 490 node_t *dev; 468 491 … … 481 504 } 482 505 483 printf(NAME ": devman_connection_devmapper: forward connection to "484 "device %s to driver %s.\n", dev->pathname, dev->drv->name);485 506 ipc_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, dev->handle, 0, 486 507 IPC_FF_NONE); 508 printf(NAME ": devman_connection_devmapper: forwarded connection to " 509 "device %s to driver %s.\n", dev->pathname, dev->drv->name); 487 510 } 488 511 … … 490 513 static void devman_connection(ipc_callid_t iid, ipc_call_t *icall) 491 514 { 492 /*493 * Silly hack to enable the device manager to register as a driver by494 * the device mapper. If the ipc method is not IPC_M_CONNECT_ME_TO, this495 * is not the forwarded connection from naming service, so it must be a496 * connection from the devmapper which thinks this is a devmapper-style497 * driver. So pretend this is a devmapper-style driver. (This does not498 * work for device with handle == IPC_M_CONNECT_ME_TO, because devmapper499 * passes device handle to the driver as an ipc method.)500 */501 if (IPC_GET_METHOD(*icall) != IPC_M_CONNECT_ME_TO)502 devman_connection_devmapper(iid, icall);503 504 /*505 * ipc method is IPC_M_CONNECT_ME_TO, so this is forwarded connection506 * from naming service by which we registered as device manager, so be507 * device manager.508 */509 510 515 /* Select interface. */ 511 switch (( ipcarg_t) (IPC_GET_ARG1(*icall))) {516 switch ((sysarg_t) (IPC_GET_ARG1(*icall))) { 512 517 case DEVMAN_DRIVER: 513 518 devman_connection_driver(iid, icall); … … 520 525 devman_forward(iid, icall, false); 521 526 break; 527 case DEVMAN_CONNECT_FROM_DEVMAP: 528 /* Someone connected through devmap node. */ 529 devman_connection_devmapper(iid, icall); 530 break; 522 531 case DEVMAN_CONNECT_TO_PARENTS_DEVICE: 523 532 /* Connect client to selected device. */ … … 577 586 578 587 /* Register device manager at naming service. */ 579 ipcarg_t phonead;588 sysarg_t phonead; 580 589 if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAN, 0, 0, &phonead) != 0) 581 590 return -1;
Note:
See TracChangeset
for help on using the changeset viewer.