Changeset ba38f72c in mainline for uspace/srv/devman/main.c
- Timestamp:
- 2011-02-07T22:15:37Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1b367b4
- Parents:
- 8b5690f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/main.c
r8b5690f rba38f72c 199 199 static int assign_driver_fibril(void *arg) 200 200 { 201 node_t *node = (node_t *) arg;202 assign_driver( node, &drivers_list, &device_tree);201 dev_node_t *dev_node = (dev_node_t *) arg; 202 assign_driver(dev_node, &drivers_list, &device_tree); 203 203 return EOK; 204 204 } … … 215 215 216 216 fibril_rwlock_write_lock(&tree->rwlock); 217 node_t *parent= find_dev_node_no_lock(&device_tree, parent_handle);218 219 if (p arent== NULL) {217 dev_node_t *pdev = find_dev_node_no_lock(&device_tree, parent_handle); 218 219 if (pdev == NULL) { 220 220 fibril_rwlock_write_unlock(&tree->rwlock); 221 221 async_answer_0(callid, ENOENT); … … 223 223 } 224 224 225 char * dev_name = NULL;226 int rc = async_data_write_accept((void **)& dev_name, true, 0, 0, 0, 0);225 char *fun_name = NULL; 226 int rc = async_data_write_accept((void **)&fun_name, true, 0, 0, 0, 0); 227 227 if (rc != EOK) { 228 228 fibril_rwlock_write_unlock(&tree->rwlock); … … 231 231 } 232 232 233 node_t *node = create_dev_node();234 if (!insert_ dev_node(&device_tree, node, dev_name, parent)) {233 fun_node_t *fun = create_fun_node(); 234 if (!insert_fun_node(&device_tree, fun, fun_name, pdev)) { 235 235 fibril_rwlock_write_unlock(&tree->rwlock); 236 delete_ dev_node(node);236 delete_fun_node(fun); 237 237 async_answer_0(callid, ENOMEM); 238 238 return; 239 239 } 240 240 241 dev_node_t *dev; 242 243 dev = create_dev_node(); 244 if (dev == NULL) { 245 fibril_rwlock_write_unlock(&tree->rwlock); 246 delete_fun_node(fun); 247 async_answer_0(callid, ENOMEM); 248 return; 249 } 250 251 insert_dev_node(tree, dev, fun); 252 241 253 fibril_rwlock_write_unlock(&tree->rwlock); 242 254 243 printf(NAME ": devman_add_child %s\n", node->pathname);244 245 devman_receive_match_ids(match_count, & node->match_ids);255 printf(NAME ": devman_add_child %s\n", fun->pathname); 256 257 devman_receive_match_ids(match_count, &fun->match_ids); 246 258 247 259 /* … … 252 264 * task spawning which could take some time. 253 265 */ 254 fid_t assign_fibril = fibril_create(assign_driver_fibril, node);266 fid_t assign_fibril = fibril_create(assign_driver_fibril, dev); 255 267 if (assign_fibril == 0) { 256 268 /* … … 258 270 * Probably not needed as we will die soon anyway ;-). 259 271 */ 260 (void) assign_driver_fibril( node);272 (void) assign_driver_fibril(fun); 261 273 } else { 262 274 fibril_add_ready(assign_fibril); … … 264 276 265 277 /* Return device handle to parent's driver. */ 266 async_answer_1(callid, EOK, node->handle);278 async_answer_1(callid, EOK, fun->handle); 267 279 } 268 280 … … 288 300 * mapper. 289 301 */ 290 class_add_devmap_ device(&class_list, cli);302 class_add_devmap_function(&class_list, cli); 291 303 292 304 free(devmap_pathname); 293 305 } 294 306 295 static void devman_add_ device_to_class(ipc_callid_t callid, ipc_call_t *call)307 static void devman_add_function_to_class(ipc_callid_t callid, ipc_call_t *call) 296 308 { 297 309 devman_handle_t handle = IPC_GET_ARG1(*call); … … 306 318 } 307 319 308 node_t *dev = find_dev_node(&device_tree, handle);309 if ( dev== NULL) {320 fun_node_t *fun = find_fun_node(&device_tree, handle); 321 if (fun == NULL) { 310 322 async_answer_0(callid, ENOENT); 311 323 return; … … 313 325 314 326 dev_class_t *cl = get_dev_class(&class_list, class_name); 315 dev_class_info_t *class_info = add_ device_to_class(dev, cl, NULL);327 dev_class_info_t *class_info = add_function_to_class(fun, cl, NULL); 316 328 317 329 /* Register the device's class alias by devmapper. */ 318 330 devmap_register_class_dev(class_info); 319 331 320 printf(NAME ": device'%s' added to class '%s', class name '%s' was "321 "asigned to it\n", dev->pathname, class_name, class_info->dev_name);332 printf(NAME ": function'%s' added to class '%s', class name '%s' was " 333 "asigned to it\n", fun->pathname, class_name, class_info->dev_name); 322 334 323 335 async_answer_0(callid, EOK); … … 376 388 break; 377 389 case DEVMAN_ADD_DEVICE_TO_CLASS: 378 devman_add_ device_to_class(callid, &call);390 devman_add_function_to_class(callid, &call); 379 391 break; 380 392 default: … … 387 399 /** Find handle for the device instance identified by the device's path in the 388 400 * device tree. */ 389 static void devman_ device_get_handle(ipc_callid_t iid, ipc_call_t *icall)401 static void devman_function_get_handle(ipc_callid_t iid, ipc_call_t *icall) 390 402 { 391 403 char *pathname; … … 397 409 } 398 410 399 node_t * dev = find_dev_node_by_path(&device_tree, pathname);411 fun_node_t * fun = find_fun_node_by_path(&device_tree, pathname); 400 412 401 413 free(pathname); 402 414 403 if ( dev== NULL) {415 if (fun == NULL) { 404 416 async_answer_0(iid, ENOENT); 405 417 return; 406 418 } 407 419 408 async_answer_1(iid, EOK, dev->handle);420 async_answer_1(iid, EOK, fun->handle); 409 421 } 410 422 … … 426 438 continue; 427 439 case DEVMAN_DEVICE_GET_HANDLE: 428 devman_ device_get_handle(callid, &call);440 devman_function_get_handle(callid, &call); 429 441 break; 430 442 default: … … 439 451 devman_handle_t handle = IPC_GET_ARG2(*icall); 440 452 441 node_t *dev = find_dev_node(&device_tree, handle);442 if ( dev== NULL) {443 printf(NAME ": devman_forward error - no device with handle %" PRIun444 " was found.\n", handle);453 fun_node_t *fun = find_fun_node(&device_tree, handle); 454 if (fun == NULL) { 455 printf(NAME ": devman_forward error - no device function with " 456 "handle %" PRIun " was found.\n", handle); 445 457 async_answer_0(iid, ENOENT); 446 458 return; … … 450 462 451 463 if (drv_to_parent) { 452 if ( dev->parent!= NULL)453 driver = dev->parent->drv;454 } else if ( dev->state == DEVICE_USABLE) {455 driver = dev->drv;464 if (fun->dev->pfun != NULL) 465 driver = fun->dev->pfun->dev->drv; 466 } else if (fun->dev->state == DEVICE_USABLE) { 467 driver = fun->dev->drv; 456 468 assert(driver != NULL); 457 469 } … … 478 490 } 479 491 480 printf(NAME ": devman_forward: forward connection to device%s to "481 "driver %s.\n", dev->pathname, driver->name);482 async_forward_fast(iid, driver->phone, method, dev->handle, 0, IPC_FF_NONE);492 printf(NAME ": devman_forward: forward connection to function %s to " 493 "driver %s.\n", fun->pathname, driver->name); 494 async_forward_fast(iid, driver->phone, method, fun->handle, 0, IPC_FF_NONE); 483 495 } 484 496 … … 488 500 { 489 501 devmap_handle_t devmap_handle = IPC_GET_ARG2(*icall); 490 node_t *dev; 491 492 dev = find_devmap_tree_device(&device_tree, devmap_handle); 493 if (dev == NULL) 494 dev = find_devmap_class_device(&class_list, devmap_handle); 495 496 if (dev == NULL || dev->drv == NULL) { 502 fun_node_t *fun; 503 dev_node_t *dev; 504 505 fun = find_devmap_tree_function(&device_tree, devmap_handle); 506 if (fun == NULL) 507 fun = find_devmap_class_function(&class_list, devmap_handle); 508 509 if (fun == NULL || fun->dev->drv == NULL) { 497 510 async_answer_0(iid, ENOENT); 498 511 return; 499 512 } 513 514 dev = fun->dev; 500 515 501 516 if (dev->state != DEVICE_USABLE || dev->drv->phone <= 0) { … … 507 522 IPC_FF_NONE); 508 523 printf(NAME ": devman_connection_devmapper: forwarded connection to " 509 "device %s to driver %s.\n", dev->pathname, dev->drv->name);524 "device %s to driver %s.\n", fun->pathname, dev->drv->name); 510 525 } 511 526
Note:
See TracChangeset
for help on using the changeset viewer.